Explorar o código

start to work with doxygen
fix mem_size/mem_base usage with device rom driver

hathach %!s(int64=13) %!d(string=hai) anos
pai
achega
8cd811e2a9

+ 1 - 1
tinyusb/class/hid.c

@@ -210,7 +210,7 @@ ErrorCode_t usb_hid_init(USBD_HANDLE_T hUsb, USB_INTERFACE_DESCRIPTOR const *con
   ASSERT_STATUS( USBD_API->hid->init(hUsb, &hid_param) );
 
   /* update memory variables */
-  *mem_base = hid_param.mem_base;
+  *mem_base += (*mem_size - hid_param.mem_size);
   *mem_size = hid_param.mem_size;
 
   return LPC_OK;

+ 15 - 10
tinyusb/common/arch/arch.h

@@ -35,19 +35,28 @@
  * This file is part of the tiny usb stack.
  */
 
+/** \file
+ *  \brief Architecture Header
+ *
+ *  \note TBD
+ */
+
+/** \ingroup Group_Common
+ *  \defgroup Group_Arch Architecture
+ *  \brief Group_Arch brief
+ *
+ *  @{
+ */
+
 #ifndef _TUSB_ARCH_H_
 #define _TUSB_ARCH_H_
 
-#ifdef __cplusplus
- extern "C" {
-#endif
-
 #define ARCH_LPC134X 1
 #define ARCH_LPC43XX 2
 #define ARCH ARCH_LPC134X
 
-#define ENDIAN_LITTLE
-#define ALIGNMENT (4)
+#define ENDIAN_LITTLE ///< MCU Endian
+#define ALIGNMENT (4) ///< MCU Alignment
 
 #if ARCH == ARCH_LPC134X
   #include "arch_lpc134x.h"
@@ -55,8 +64,4 @@
 
 #endif
 
-#ifdef __cplusplus
- }
-#endif
-
 #endif /* _TUSB_ARCH_H_ */

+ 11 - 8
tinyusb/common/arch/arch_lpc134x.h

@@ -35,13 +35,20 @@
  * This file is part of the tiny usb stack.
  */
 
+/** \file
+ *  \brief LPC13Uxx Header
+ *
+ *  \note TBD
+ */
+
+/** \ingroup Group_Arch
+ *
+ *  @{
+ */
+
 #ifndef _TUSB_ARCH_LPC134_X_H_
 #define _TUSB_ARCH_LPC134_X_H_
 
-#ifdef __cplusplus
- extern "C" {
-#endif
-
 #include "arm_mx.h"
 #include "LPC13Uxx.h"
 
@@ -49,8 +56,4 @@
 
 #define DEVICE_ROMDRIVER
 
-#ifdef __cplusplus
- }
-#endif
-
 #endif /* _TUSB_ARCH_LPC134_X_H_ */

+ 13 - 8
tinyusb/common/arch/arch_lpc43xx.h

@@ -35,20 +35,25 @@
  * This file is part of the tiny usb stack.
  */
 
+/** \file
+ *  \brief LPC43xx Header
+ *
+ *  \note TBD
+ */
+
+/** \ingroup Group_Arch
+ *
+ *  @{
+ */
+
 #ifndef _TUSB_ARCH_LPC43XX_H_
 #define _TUSB_ARCH_LPC43XX_H_
 
-#ifdef __cplusplus
- extern "C" {
-#endif
-
 #define ARM_M4
 //#define ARM_M0
 
 #include "arm_mx.h"
 
-#ifdef __cplusplus
- }
-#endif
-
 #endif /* _TUSB_ARCH_LPC43XX_H_ */
+
+/// @}

+ 12 - 8
tinyusb/common/arch/arm_mx.h

@@ -35,18 +35,22 @@
  * This file is part of the tiny usb stack.
  */
 
+/** \file
+ *  \brief ARM Cortex Mx Header
+ *
+ *  \note TBD
+ */
+
+/** \ingroup Group_Arch
+ *
+ *  @{
+ */
+
 #ifndef _TUSB_ARM_MX_H_
 #define _TUSB_ARM_MX_H_
 
-#ifdef __cplusplus
- extern "C" {
-#endif
-
 #define ENDIAN_LITTLE
 #define ALIGNMENT (4)
 
-#ifdef __cplusplus
- }
-#endif
-
 #endif /* _TUSB_ARM_MX_H_ */
+/// @}

+ 13 - 8
tinyusb/common/common.h

@@ -35,13 +35,22 @@
  * This file is part of the tiny usb stack.
  */
 
+/** \file
+ *  \brief Common Header File
+ *
+ *  \note TBD
+ */
+
+/** \ingroup Group_TinyUSB
+ *  \defgroup Group_Common Common Files
+ *  \brief Group_Common brief
+ *
+ *  @{
+ */
+
 #ifndef _TUSB_COMMON_H_
 #define _TUSB_COMMON_H_
 
-#ifdef __cplusplus
- extern "C" {
-#endif
-
 #include <stddef.h>
 #include <stdbool.h>
 #include <string.h>
@@ -78,8 +87,4 @@
 
 #define ASSERT_STATUS(sts)		ASSERT_STATUS_MESSAGE(sts, NULL)
 
-#ifdef __cplusplus
- }
-#endif
-
 #endif /* _TUSB_COMMON_H_ */

+ 14 - 8
tinyusb/common/compiler/compiler.h

@@ -35,19 +35,25 @@
  * This file is part of the tiny usb stack.
  */
 
+/** \file
+ *  \brief Compiler Header
+ *
+ *  \note TBD
+ */
+
+/** \ingroup Group_Common
+ *  \defgroup Group_Compiler Compiler
+ *  \brief Group_Compiler brief
+ *
+ *  @{
+ */
+
 #ifndef _TUSB_COMPILER_H_
 #define _TUSB_COMPILER_H_
 
-#ifdef __cplusplus
- extern "C" {
-#endif
-
 #if defined(__GNUC__)
   #include "compiler_gcc.h"
 #endif
 
-#ifdef __cplusplus
- }
-#endif
-
 #endif /* _TUSB_COMPILER_H_ */
+/// @}

+ 12 - 7
tinyusb/common/compiler/compiler_gcc.h

@@ -35,9 +35,16 @@
  * This file is part of the tiny usb stack.
  */
 
-#ifdef __cplusplus
- extern "C" {
-#endif
+/** \file
+ *  \brief GCC Header
+ *
+ *  \note TBD
+ */
+
+/** \ingroup Group_Compiler
+ *
+ *  @{
+ */
 
 #ifndef _TUSB_COMPILER_GCC_H_
 #define _TUSB_COMPILER_GCC_H_
@@ -56,8 +63,6 @@
 #define ATTR_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
 #define ATTR_ALWAYS_INLINE			__attribute__ ((always_inline))
 
-#ifdef __cplusplus
- }
-#endif
-
 #endif /* _TUSB_COMPILER_GCC_H_ */
+
+/// @}

+ 5 - 0
tinyusb/common/errors.c

@@ -35,3 +35,8 @@
  * This file is part of the tiny usb stack.
  */
 
+char const* const TUSB_ErrorStr[] = {
+#   define ERROR_ENUM(x) #x,
+#   include "errors_def"
+#   undef ERROR_ENUM
+};

+ 18 - 0
tinyusb/common/errors.h

@@ -35,13 +35,31 @@
  * This file is part of the tiny usb stack.
  */
 
+/** \file
+ *  \brief Error Header
+ *
+ *  \note TBD
+ */
+
+/** \ingroup Group_Common
+ *
+ *  @{
+ */
+
 #ifndef _TUSB_ERRORS_H_
 #define _TUSB_ERRORS_H_
 
+enum TUSB_ERROR {
+#   define ERROR_ENUM(x) x,
+#   include "errors_def"
+#   undef ERROR_ENUM
+};
+
 #ifdef __cplusplus
  extern "C" {
 #endif
 
+extern char const* const TUSB_ErrorStr[];
 
 #ifdef __cplusplus
  }

+ 30 - 9
tinyusb/common/fifo.h

@@ -35,23 +35,40 @@
  * This file is part of the tiny usb stack.
  */
 
+/** \file
+ *  \brief Error Header
+ *
+ *  \note TBD
+ */
+
+/** \ingroup Group_Common
+ *
+ *  @{
+ */
+
 #ifndef _TUSB_FIFO_H_
 #define _TUSB_FIFO_H_
 
 #include "common/common.h"
 
-/* ToDo: Describe each field in fifo_t */
-typedef struct _fifo_t
+/**
+ * \brief Simple FIFO
+ */
+typedef struct
 {
-  uint8_t* buf;
-  uint16_t size;
-  volatile uint16_t len;
-  volatile uint16_t wr_ptr;
-  volatile uint16_t rd_ptr;
-  bool overwritable;
-  IRQn_Type irq;
+  uint8_t* buf; ///< buffer pointer
+  uint16_t size; ///< buffer size
+  volatile uint16_t len; ///< bytes in fifo
+  volatile uint16_t wr_ptr; ///< write pointer
+  volatile uint16_t rd_ptr; ///< read pointer
+  bool overwritable; ///< allow overwrite data when full
+  IRQn_Type irq; ///< interrupt used to lock fifo
 } fifo_t;
 
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
 void fifo_init(fifo_t* f, uint8_t* buffer, uint16_t size, bool overwritable, IRQn_Type irq);
 bool fifo_write(fifo_t* f, uint8_t data);
 bool fifo_read(fifo_t* f, uint8_t *data);
@@ -73,4 +90,8 @@ static inline uint16_t fifo_getLength(fifo_t* f)
   return f->len;
 }
 
+#ifdef __cplusplus
+ }
+#endif
+
 #endif /* _TUSB_FIFO_H_ */

+ 14 - 7
tinyusb/device/dcd.c

@@ -39,9 +39,10 @@
 
 // TODO refractor later
 #include "descriptors.h"
+#include <cr_section_macros.h>
 
 #define USB_ROM_SIZE (1024*2)
-uint8_t usb_RomDriver_buffer[USB_ROM_SIZE]ALIGNED(2048) /*__BSS(RAM2)*/;
+uint8_t usb_RomDriver_buffer[USB_ROM_SIZE] ATTR_ALIGNED(2048) __BSS(RAM2);
 USBD_HANDLE_T g_hUsb;
 volatile static bool isConfigured = false;
 
@@ -83,12 +84,15 @@ ErrorCode_t USB_Reset_Event (USBD_HANDLE_T hUsb)
 void dcd_init()
 {
   /* ROM DRIVER INIT */
+  uint32_t membase = (uint32_t) usb_RomDriver_buffer;
+  uint32_t memsize = USB_ROM_SIZE;
+
   USBD_API_INIT_PARAM_T usb_param =
   {
     .usb_reg_base        = LPC_USB_BASE,
     .max_num_ep          = USB_MAX_EP_NUM,
-    .mem_base            = (uint32_t) usb_RomDriver_buffer,
-    .mem_size            = USB_ROM_SIZE, //USBD_API->hw->GetMemSize()
+    .mem_base            = membase,
+    .mem_size            = memsize,
 
     .USB_Configure_Event = USB_Configure_Event,
     .USB_Reset_Event     = USB_Reset_Event
@@ -106,22 +110,25 @@ void dcd_init()
   /* Start USB hardware initialisation */
   ASSERT_STATUS(USBD_API->hw->Init(&g_hUsb, &DeviceDes, &usb_param));
 
-    /* Initialise the class driver(s) */
+  membase += (memsize - usb_param.mem_size);
+  memsize = usb_param.mem_size;
+
+  /* Initialise the class driver(s) */
   #ifdef CFG_USB_CDC
     ASSERT_STATUS( usb_cdc_init(g_hUsb, &USB_FsConfigDescriptor.CDC_CCI_Interface,
-            &USB_FsConfigDescriptor.CDC_DCI_Interface, &usb_param.mem_base, &usb_param.mem_size) );
+            &USB_FsConfigDescriptor.CDC_DCI_Interface, &membase, &memsize) );
   #endif
 
   #ifdef CFG_CLASS_HID_KEYBOARD
     ASSERT_STATUS( usb_hid_init(g_hUsb , &USB_FsConfigDescriptor.HID_KeyboardInterface ,
             HID_KeyboardReportDescriptor, USB_FsConfigDescriptor.HID_KeyboardHID.DescriptorList[0].wDescriptorLength,
-            &usb_param.mem_base , &usb_param.mem_size) );
+            &membase , &memsize) );
   #endif
 
   #ifdef CFG_USB_HID_MOUSE
     ASSERT_STATUS( usb_hid_init(g_hUsb , &USB_FsConfigDescriptor.HID_MouseInterface    ,
             HID_MouseReportDescriptor, USB_FsConfigDescriptor.HID_MouseHID.DescriptorList[0].wDescriptorLength,
-            &usb_param.mem_base , &usb_param.mem_size) );
+            &membase , &memsize) );
   #endif
 
   /* Enable the USB interrupt */

+ 14 - 0
tinyusb/tusb.h

@@ -35,6 +35,18 @@
  * This file is part of the tiny usb stack.
  */
 
+/** \file
+ *  \brief Tiny USB header
+ *
+ *  \note Tiny USB header Note
+ */
+
+/** \defgroup Group_TinyUSB Tiny USB
+ *  \brief Group_TinyUSB brief
+ *
+ *  @{
+ */
+
 #ifndef _TUSB_H_
 #define _TUSB_H_
 
@@ -58,3 +70,5 @@
 #endif
 
 #endif /* _TUSB_H_ */
+
+/** @} */

+ 16 - 15
tinyusb/tusb_cfg.h

@@ -35,23 +35,26 @@
  * This file is part of the tiny usb stack.
  */
 
-#ifndef _TUSB_CFG_H_
-#define _TUSB_CFG_H_
-
-#ifdef __cplusplus
- extern "C" {
-#endif
+/** \file
+ *  \brief Configure File
+ *
+ *  \note TBD
+ */
 
-#include "common/common.h"
+/** \ingroup Group_TinyUSB
+ *
+ *  @{
+ */
 
-#define CFG_TUSB_HOST
-#define CFG_TUSB_DEVICE
+#ifndef _TUSB_CFG_H_
+#define _TUSB_CFG_H_
 
-#define CFG_CLASS_HID_KEYBOARD
+#define CFG_TUSB_HOST ///< Enable Host Support
+#define CFG_TUSB_DEVICE ///< Enable Device Support
+#define CFG_CLASS_HID_KEYBOARD ///< Enable HID Keyboard support
 
 #define CLASS_HID (defined CFG_CLASS_HID_KEYBOARD)
 
-
 // TODO APP
 #define USB_MAX_IF_NUM          8
 #define USB_MAX_EP_NUM          5
@@ -75,8 +78,6 @@
 #define  CDC_NOTIFICATION_EP_MAXPACKETSIZE  8
 #define  CDC_DATA_EP_MAXPACKET_SIZE         16
 
-#ifdef __cplusplus
- }
-#endif
-
 #endif /* _TUSB_CFG_H_ */
+
+/** @} */