start to work with doxygen

fix mem_size/mem_base usage with device rom driver
This commit is contained in:
hathach 2012-11-29 10:41:33 +07:00
parent 851f5bfd06
commit 8cd811e2a9
14 changed files with 188 additions and 89 deletions

View File

@ -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) ); ASSERT_STATUS( USBD_API->hid->init(hUsb, &hid_param) );
/* update memory variables */ /* update memory variables */
*mem_base = hid_param.mem_base; *mem_base += (*mem_size - hid_param.mem_size);
*mem_size = hid_param.mem_size; *mem_size = hid_param.mem_size;
return LPC_OK; return LPC_OK;

View File

@ -35,19 +35,28 @@
* This file is part of the tiny usb stack. * 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_ #ifndef _TUSB_ARCH_H_
#define _TUSB_ARCH_H_ #define _TUSB_ARCH_H_
#ifdef __cplusplus
extern "C" {
#endif
#define ARCH_LPC134X 1 #define ARCH_LPC134X 1
#define ARCH_LPC43XX 2 #define ARCH_LPC43XX 2
#define ARCH ARCH_LPC134X #define ARCH ARCH_LPC134X
#define ENDIAN_LITTLE #define ENDIAN_LITTLE ///< MCU Endian
#define ALIGNMENT (4) #define ALIGNMENT (4) ///< MCU Alignment
#if ARCH == ARCH_LPC134X #if ARCH == ARCH_LPC134X
#include "arch_lpc134x.h" #include "arch_lpc134x.h"
@ -55,8 +64,4 @@
#endif #endif
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_ARCH_H_ */ #endif /* _TUSB_ARCH_H_ */

View File

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

View File

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

View File

@ -35,18 +35,22 @@
* This file is part of the tiny usb stack. * 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_ #ifndef _TUSB_ARM_MX_H_
#define _TUSB_ARM_MX_H_ #define _TUSB_ARM_MX_H_
#ifdef __cplusplus
extern "C" {
#endif
#define ENDIAN_LITTLE #define ENDIAN_LITTLE
#define ALIGNMENT (4) #define ALIGNMENT (4)
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_ARM_MX_H_ */ #endif /* _TUSB_ARM_MX_H_ */
/// @}

View File

@ -35,13 +35,22 @@
* This file is part of the tiny usb stack. * 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_ #ifndef _TUSB_COMMON_H_
#define _TUSB_COMMON_H_ #define _TUSB_COMMON_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h> #include <stddef.h>
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
@ -78,8 +87,4 @@
#define ASSERT_STATUS(sts) ASSERT_STATUS_MESSAGE(sts, NULL) #define ASSERT_STATUS(sts) ASSERT_STATUS_MESSAGE(sts, NULL)
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_COMMON_H_ */ #endif /* _TUSB_COMMON_H_ */

View File

@ -35,19 +35,25 @@
* This file is part of the tiny usb stack. * 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_ #ifndef _TUSB_COMPILER_H_
#define _TUSB_COMPILER_H_ #define _TUSB_COMPILER_H_
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__GNUC__) #if defined(__GNUC__)
#include "compiler_gcc.h" #include "compiler_gcc.h"
#endif #endif
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_COMPILER_H_ */ #endif /* _TUSB_COMPILER_H_ */
/// @}

View File

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

View File

@ -35,3 +35,8 @@
* This file is part of the tiny usb stack. * 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
};

View File

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

View File

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

View File

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

View File

@ -35,6 +35,18 @@
* This file is part of the tiny usb stack. * 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_ #ifndef _TUSB_H_
#define _TUSB_H_ #define _TUSB_H_
@ -58,3 +70,5 @@
#endif #endif
#endif /* _TUSB_H_ */ #endif /* _TUSB_H_ */
/** @} */

View File

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