mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-27 20:37:30 +00:00
add DEVICE_ROM_DRIVER_ADDR macro in hal to point to rom driver add
add TUSB_ATTR_RAM_SECTION in tinyusb_config.h to abtract usb ram placement to application remove power_api.h (mcu dependency)
This commit is contained in:
parent
c16632da0b
commit
25f6cee73b
@ -55,6 +55,10 @@ void board_init(void)
|
|||||||
|
|
||||||
SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / CFG_TICKS_PER_SECOND); // 1 msec tick timer
|
SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / CFG_TICKS_PER_SECOND); // 1 msec tick timer
|
||||||
|
|
||||||
|
// USB Host Power Enable
|
||||||
|
// USB0
|
||||||
|
// TODO USB1
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// Leds Init
|
// Leds Init
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
@ -89,7 +93,7 @@ void board_init(void)
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// LEDS
|
// LEDS
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void board_leds(uint32_t mask, uint32_t state) __attribute__ ((deprecated("not supported yet")));
|
void board_leds(uint32_t mask, uint32_t state) __attribute__ ((warning("not supported yet")));
|
||||||
void board_leds(uint32_t mask, uint32_t state)
|
void board_leds(uint32_t mask, uint32_t state)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
//-------------------------------------------------------------------- +
|
//-------------------------------------------------------------------- +
|
||||||
// LPCXpresso printf redirection +
|
// LPCXpresso printf redirection +
|
||||||
//-------------------------------------------------------------------- +
|
//-------------------------------------------------------------------- +
|
||||||
#if CFG_PRINTF_TARGET != PRINTF_TARGET_DEBUG_CONSOLE
|
#if (defined __CODE_RED) && (CFG_PRINTF_TARGET != PRINTF_TARGET_DEBUG_CONSOLE)
|
||||||
// Called by bottom level of printf routine within RedLib C library to write
|
// Called by bottom level of printf routine within RedLib C library to write
|
||||||
// a character. With the default semihosting stub, this would write the character
|
// a character. With the default semihosting stub, this would write the character
|
||||||
// to the debugger console window . But this version writes
|
// to the debugger console window . But this version writes
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
#include "descriptors.h"
|
#include "descriptors.h"
|
||||||
|
|
||||||
#ifdef TUSB_CFG_DEVICE_HID_KEYBOARD
|
#ifdef TUSB_CFG_DEVICE_HID_KEYBOARD
|
||||||
ATTR_ALIGNED(4) const uint8_t HID_KeyboardReportDescriptor[] = {
|
TUSB_ATTR_RAM_SECTION ATTR_ALIGNED(4) const uint8_t HID_KeyboardReportDescriptor[] = {
|
||||||
HID_UsagePage ( HID_USAGE_PAGE_GENERIC ),
|
HID_UsagePage ( HID_USAGE_PAGE_GENERIC ),
|
||||||
HID_Usage ( HID_USAGE_GENERIC_KEYBOARD ),
|
HID_Usage ( HID_USAGE_GENERIC_KEYBOARD ),
|
||||||
HID_Collection ( HID_Application ),
|
HID_Collection ( HID_Application ),
|
||||||
@ -81,7 +81,7 @@ ATTR_ALIGNED(4) const uint8_t HID_KeyboardReportDescriptor[] = {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TUSB_CFG_DEVICE_HID_MOUSE
|
#ifdef TUSB_CFG_DEVICE_HID_MOUSE
|
||||||
ATTR_ALIGNED(4) const uint8_t HID_MouseReportDescriptor[] = {
|
TUSB_ATTR_RAM_SECTION ATTR_ALIGNED(4) const uint8_t HID_MouseReportDescriptor[] = {
|
||||||
HID_UsagePage ( HID_USAGE_PAGE_GENERIC ),
|
HID_UsagePage ( HID_USAGE_PAGE_GENERIC ),
|
||||||
HID_Usage ( HID_USAGE_GENERIC_MOUSE ),
|
HID_Usage ( HID_USAGE_GENERIC_MOUSE ),
|
||||||
HID_Collection ( HID_Application ),
|
HID_Collection ( HID_Application ),
|
||||||
@ -119,7 +119,7 @@ ATTR_ALIGNED(4) const uint8_t HID_MouseReportDescriptor[] = {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* USB Standard Device Descriptor */
|
/* USB Standard Device Descriptor */
|
||||||
ATTR_ALIGNED(4) const USB_DEVICE_DESCRIPTOR USB_DeviceDescriptor =
|
TUSB_ATTR_RAM_SECTION ATTR_ALIGNED(4) const USB_DEVICE_DESCRIPTOR USB_DeviceDescriptor =
|
||||||
{
|
{
|
||||||
.bLength = sizeof(USB_DEVICE_DESCRIPTOR),
|
.bLength = sizeof(USB_DEVICE_DESCRIPTOR),
|
||||||
.bDescriptorType = USB_DEVICE_DESCRIPTOR_TYPE,
|
.bDescriptorType = USB_DEVICE_DESCRIPTOR_TYPE,
|
||||||
@ -153,7 +153,7 @@ ATTR_ALIGNED(4) const USB_DEVICE_DESCRIPTOR USB_DeviceDescriptor =
|
|||||||
.bNumConfigurations = 0x01
|
.bNumConfigurations = 0x01
|
||||||
};
|
};
|
||||||
|
|
||||||
ATTR_ALIGNED(4) const USB_FS_CONFIGURATION_DESCRIPTOR USB_FsConfigDescriptor =
|
TUSB_ATTR_RAM_SECTION ATTR_ALIGNED(4) const USB_FS_CONFIGURATION_DESCRIPTOR USB_FsConfigDescriptor =
|
||||||
{
|
{
|
||||||
.Config =
|
.Config =
|
||||||
{
|
{
|
||||||
@ -358,7 +358,7 @@ ATTR_ALIGNED(4) const USB_FS_CONFIGURATION_DESCRIPTOR USB_FsConfigDescriptor =
|
|||||||
.ConfigDescTermination = 0,
|
.ConfigDescTermination = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
ATTR_ALIGNED(4) const USB_STR_DESCRIPTOR USB_StringDescriptor =
|
TUSB_ATTR_RAM_SECTION ATTR_ALIGNED(4) const USB_STR_DESCRIPTOR USB_StringDescriptor =
|
||||||
{
|
{
|
||||||
.LangID = { .bLength = 0x04, .bDescriptorType = USB_STRING_DESCRIPTOR_TYPE },
|
.LangID = { .bLength = 0x04, .bDescriptorType = USB_STRING_DESCRIPTOR_TYPE },
|
||||||
.strLangID= {0x0409}, // US English
|
.strLangID= {0x0409}, // US English
|
||||||
|
@ -59,13 +59,23 @@
|
|||||||
#define TUSB_CFG_DEVICE
|
#define TUSB_CFG_DEVICE
|
||||||
|
|
||||||
/// Enable CDC Support
|
/// Enable CDC Support
|
||||||
#define TUSB_CFG_DEVICE_CDC
|
//#define TUSB_CFG_DEVICE_CDC
|
||||||
|
|
||||||
/// Enable HID Keyboard support
|
/// Enable HID Keyboard support
|
||||||
#define TUSB_CFG_DEVICE_HID_KEYBOARD
|
#define TUSB_CFG_DEVICE_HID_KEYBOARD
|
||||||
|
|
||||||
/// Enable HID Mouse support
|
/// Enable HID Mouse support
|
||||||
#define TUSB_CFG_DEVICE_HID_MOUSE
|
//#define TUSB_CFG_DEVICE_HID_MOUSE
|
||||||
|
|
||||||
|
#ifdef __CODE_RED // make use of code red's support for ram region macros
|
||||||
|
#if (MCU == MCU_LPC11UXX) || (MCU == MCU_LPC13UXX)
|
||||||
|
#define TUSB_RAM_SECTION ".data.$RAM2"
|
||||||
|
#elif (MCU == MCU_LPC43XX)
|
||||||
|
#define TUSB_RAM_SECTION ".data.$RAM3"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TUSB_ATTR_RAM_SECTION __attribute__ ((section(TUSB_RAM_SECTION)))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -320,7 +320,7 @@ TUSB_Error_t tusb_cdc_configured(USBD_HANDLE_T hUsb)
|
|||||||
fifo_init (&ffTX, qBuffer[0], CDC_BUFFER_SIZE, false, USB0_IRQn); // TODO USB1 TX is non-overwritable
|
fifo_init (&ffTX, qBuffer[0], CDC_BUFFER_SIZE, false, USB0_IRQn); // TODO USB1 TX is non-overwritable
|
||||||
fifo_init (&ffRX, qBuffer[1], CDC_BUFFER_SIZE, true, USB0_IRQn); // RX is overwritable
|
fifo_init (&ffRX, qBuffer[1], CDC_BUFFER_SIZE, true, USB0_IRQn); // RX is overwritable
|
||||||
#else
|
#else
|
||||||
#error No MCU defined" // TODO asbtract MCU
|
#error No MCU defined // TODO asbtract MCU
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return tERROR_NONE;
|
return tERROR_NONE;
|
||||||
|
@ -41,11 +41,10 @@
|
|||||||
|
|
||||||
// TODO refractor later
|
// TODO refractor later
|
||||||
#include "descriptors.h"
|
#include "descriptors.h"
|
||||||
#include <cr_section_macros.h>
|
|
||||||
|
|
||||||
// TODO dcd abstract later
|
// TODO dcd abstract later
|
||||||
#define USB_ROM_SIZE (1024*2)
|
#define USB_ROM_SIZE (1024*2)
|
||||||
uint8_t usb_RomDriver_buffer[USB_ROM_SIZE] ATTR_ALIGNED(2048) __DATA(RAM2);
|
uint8_t usb_RomDriver_buffer[USB_ROM_SIZE] ATTR_ALIGNED(2048) TUSB_ATTR_RAM_SECTION;
|
||||||
USBD_HANDLE_T g_hUsb;
|
USBD_HANDLE_T g_hUsb;
|
||||||
static volatile bool isConfigured = false;
|
static volatile bool isConfigured = false;
|
||||||
|
|
||||||
|
@ -58,9 +58,8 @@
|
|||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
|
|
||||||
#ifdef DEVICE_ROMDRIVER
|
#ifdef DEVICE_ROMDRIVER
|
||||||
#include "romdriver/mw_usbd_rom_api.h"
|
#include "romdriver/mw_usbd_rom_api.h"
|
||||||
#include "romdriver/power_api.h"
|
#define USBD_API ((USBD_API_T*) DEVICE_ROM_DRIVER_ADDR)
|
||||||
#define USBD_API ((*(ROM **)(0x1FFF1FF8))->pUSBD) // TODO HAL
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,7 +39,6 @@
|
|||||||
#include "mw_usbd_dfuuser.h"
|
#include "mw_usbd_dfuuser.h"
|
||||||
#include "mw_usbd_hiduser.h"
|
#include "mw_usbd_hiduser.h"
|
||||||
#include "mw_usbd_cdcuser.h"
|
#include "mw_usbd_cdcuser.h"
|
||||||
//#include "power_api.h"
|
|
||||||
|
|
||||||
/** \brief Main USBD API functions structure.
|
/** \brief Main USBD API functions structure.
|
||||||
* \ingroup Group_USBD
|
* \ingroup Group_USBD
|
||||||
|
@ -1,88 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* $Id:: power_api.h 6249 2011-01-25 19:23:47Z usb01267 $
|
|
||||||
* Project: NXP LPC13Uxx software example
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Power API Header File for NXP LPC13Uxx Device Series
|
|
||||||
*
|
|
||||||
****************************************************************************
|
|
||||||
* Software that is described herein is for illustrative purposes only
|
|
||||||
* which provides customers with programming information regarding the
|
|
||||||
* products. This software is supplied "AS IS" without any warranties.
|
|
||||||
* NXP Semiconductors assumes no responsibility or liability for the
|
|
||||||
* use of the software, conveys no license or title under any patent,
|
|
||||||
* copyright, or mask work right to the product. NXP Semiconductors
|
|
||||||
* reserves the right to make changes in the software without
|
|
||||||
* notification. NXP Semiconductors also make no representation or
|
|
||||||
* warranty that such application will be suitable for the specified
|
|
||||||
* use without further testing or modification.
|
|
||||||
****************************************************************************/
|
|
||||||
#ifndef __LPC13UXX_POWER_API_H__
|
|
||||||
#define __LPC13UXX_POWER_API_H__
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define PWRROMD_PRESENT
|
|
||||||
|
|
||||||
#define USBROMD_PRESENT
|
|
||||||
|
|
||||||
#ifdef USBROMD_PRESENT
|
|
||||||
#include "mw_usbd_rom_api.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct _PWRD {
|
|
||||||
void (*set_pll)(unsigned int cmd[], unsigned int resp[]);
|
|
||||||
void (*set_power)(unsigned int cmd[], unsigned int resp[]);
|
|
||||||
} PWRD;
|
|
||||||
|
|
||||||
typedef struct _ROM {
|
|
||||||
#ifdef USBROMD_PRESENT
|
|
||||||
const USBD_API_T * pUSBD;
|
|
||||||
#else
|
|
||||||
const unsigned p_usbd;
|
|
||||||
#endif /* USBROMD_PRESENT */
|
|
||||||
const unsigned p_clib;
|
|
||||||
const unsigned p_cand;
|
|
||||||
#ifdef PWRROMD_PRESENT
|
|
||||||
const PWRD * pPWRD;
|
|
||||||
#else
|
|
||||||
const unsigned p_pwrd;
|
|
||||||
#endif /* PWRROMD_PRESENT */
|
|
||||||
const unsigned p_dev1;
|
|
||||||
const unsigned p_dev2;
|
|
||||||
const unsigned p_dev3;
|
|
||||||
const unsigned p_dev4;
|
|
||||||
} ROM;
|
|
||||||
|
|
||||||
//PLL setup related definitions
|
|
||||||
#define CPU_FREQ_EQU 0 //main PLL freq must be equal to the specified
|
|
||||||
#define CPU_FREQ_LTE 1 //main PLL freq must be less than or equal the specified
|
|
||||||
#define CPU_FREQ_GTE 2 //main PLL freq must be greater than or equal the specified
|
|
||||||
#define CPU_FREQ_APPROX 3 //main PLL freq must be as close as possible the specified
|
|
||||||
|
|
||||||
#define PLL_CMD_SUCCESS 0 //PLL setup successfully found
|
|
||||||
#define PLL_INVALID_FREQ 1 //specified freq out of range (either input or output)
|
|
||||||
#define PLL_INVALID_MODE 2 //invalid mode (see above for valid) specified
|
|
||||||
#define PLL_FREQ_NOT_FOUND 3 //specified freq not found under specified conditions
|
|
||||||
#define PLL_NOT_LOCKED 4 //PLL not locked => no changes to the PLL setup
|
|
||||||
|
|
||||||
//power setup elated definitions
|
|
||||||
#define PARAM_DEFAULT 0 //default power settings (voltage regulator, flash interface)
|
|
||||||
#define PARAM_CPU_PERFORMANCE 1 //setup for maximum CPU performance (higher current, more computation)
|
|
||||||
#define PARAM_EFFICIENCY 2 //balanced setting (power vs CPU performance)
|
|
||||||
#define PARAM_LOW_CURRENT 3 //lowest active current, lowest CPU performance
|
|
||||||
|
|
||||||
#define PARAM_CMD_SUCCESS 0 //power setting successfully found
|
|
||||||
#define PARAM_INVALID_FREQ 1 //specified freq out of range (=0 or > 50 MHz)
|
|
||||||
#define PARAM_INVALID_MODE 2 //specified mode not valid (see above for valid)
|
|
||||||
|
|
||||||
#define MAX_CLOCK_KHZ_PARAM 50000
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __LPC13UXX_POWER_API_H__ */
|
|
||||||
|
|
@ -55,6 +55,9 @@
|
|||||||
|
|
||||||
#define DEVICE_ROMDRIVER
|
#define DEVICE_ROMDRIVER
|
||||||
#define DEVICE_ROM_REG_BASE LPC_USB_BASE
|
#define DEVICE_ROM_REG_BASE LPC_USB_BASE
|
||||||
|
#define DEVICE_ROM_DRIVER_ADDR 0x1FFF1FF8
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
|
|
||||||
#define DEVICE_ROMDRIVER
|
#define DEVICE_ROMDRIVER
|
||||||
#define DEVICE_ROM_REG_BASE LPC_USB_BASE
|
#define DEVICE_ROM_REG_BASE LPC_USB_BASE
|
||||||
|
#define DEVICE_ROM_DRIVER_ADDR 0x1FFF1FF8
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -60,17 +60,16 @@
|
|||||||
|
|
||||||
#define DEVICE_ROMDRIVER
|
#define DEVICE_ROMDRIVER
|
||||||
#define DEVICE_ROM_REG_BASE LPC_USB0_BASE // TODO USB1
|
#define DEVICE_ROM_REG_BASE LPC_USB0_BASE // TODO USB1
|
||||||
|
#define DEVICE_ROM_DRIVER_ADDR 0x1040011C
|
||||||
|
|
||||||
static inline void hal_interrupt_enable()
|
static inline void hal_interrupt_enable()
|
||||||
{
|
{
|
||||||
// TODO support multiple controller later
|
NVIC_EnableIRQ(USB0_IRQn); // TODO USB1
|
||||||
NVIC_EnableIRQ(USB0_IRQn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void hal_interrupt_disable()
|
static inline void hal_interrupt_disable()
|
||||||
{
|
{
|
||||||
// TODO support multiple controller later
|
NVIC_DisableIRQ(USB0_IRQn); // TODO USB1
|
||||||
NVIC_DisableIRQ(USB0_IRQn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -55,12 +55,13 @@
|
|||||||
|
|
||||||
/// define this symbol will make tinyusb look for external configure file
|
/// define this symbol will make tinyusb look for external configure file
|
||||||
#ifndef _TEST_ // TODO allow configurable name
|
#ifndef _TEST_ // TODO allow configurable name
|
||||||
#include "tusb_config.h"
|
#include "tusb_config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// 0: no debug infor 3: most debug infor provided
|
/// 0: no debug information 3: most debug information provided
|
||||||
#ifndef TUSB_CFG_DEBUG
|
#ifndef TUSB_CFG_DEBUG
|
||||||
#define TUSB_CFG_DEBUG 3
|
#define TUSB_CFG_DEBUG 3
|
||||||
|
#warning TUSB_CFG_DEBUG is not defined, default value is 3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Enable Host Support
|
/// Enable Host Support
|
||||||
@ -69,6 +70,13 @@
|
|||||||
/// Enable Device Support
|
/// Enable Device Support
|
||||||
//#define TUSB_CFG_DEVICE
|
//#define TUSB_CFG_DEVICE
|
||||||
|
|
||||||
|
/// USB RAM Section Placement, MCU's usb controller often has limited access to specific RAM region. This will be used to declare internal variables as follow:
|
||||||
|
/// uint8_t tinyusb_data[10] TUSB_ATTR_RAM_SECTION;
|
||||||
|
/// if your mcu's usb controller has no such limit, define TUSB_ATTR_RAM_SECTION as empty macro.
|
||||||
|
#ifndef TUSB_ATTR_RAM_SECTION
|
||||||
|
#error TUSB_ATTR_RAM_SECTION is not defined, needed to place data in accessible RAM for usb controller
|
||||||
|
#endif
|
||||||
|
|
||||||
#define DEVICE_CLASS_HID ( (defined TUSB_CFG_DEVICE_HID_KEYBOARD) || (defined TUSB_CFG_DEVICE_HID_MOUSE) )
|
#define DEVICE_CLASS_HID ( (defined TUSB_CFG_DEVICE_HID_KEYBOARD) || (defined TUSB_CFG_DEVICE_HID_MOUSE) )
|
||||||
#define HOST_EHCI
|
#define HOST_EHCI
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user