diff options
| author | hathach <[email protected]> | 2013-11-13 12:40:11 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-11-13 12:40:11 +0700 |
| commit | 92d9c36dbcfd933f872c91ad061e2e5ab184b020 (patch) | |
| tree | 1864f26f579d65878f1cbd09d65b8cbb90b3f02b /tinyusb | |
| parent | d8f32a79fc9e04136afcd8f4d79abe7a9b0c2eb9 (diff) | |
able to build and run cdc device demo on lpc11uxx
Diffstat (limited to 'tinyusb')
| -rw-r--r-- | tinyusb/class/hid_device.c | 4 | ||||
| -rw-r--r-- | tinyusb/class/msc_device.c | 17 | ||||
| -rw-r--r-- | tinyusb/class/msc_device.h | 2 | ||||
| -rw-r--r-- | tinyusb/device/dcd_lpc_11uxx_13uxx.c (renamed from tinyusb/device/dcd_lpc13uxx.c) | 32 | ||||
| -rw-r--r-- | tinyusb/device/dcd_lpc_11uxx_13uxx.h (renamed from tinyusb/device/dcd_lpc13uxx.h) | 0 | ||||
| -rw-r--r-- | tinyusb/device/usbd.c | 8 | ||||
| -rw-r--r-- | tinyusb/hal/hal_lpc11uxx.c | 1 | ||||
| -rw-r--r-- | tinyusb/hal/hal_lpc11uxx.h | 14 | ||||
| -rw-r--r-- | tinyusb/hal/hal_lpc13uxx.c | 3 | ||||
| -rw-r--r-- | tinyusb/hal/hal_lpc43xx.c | 6 | ||||
| -rw-r--r-- | tinyusb/mcu_capacity.h | 4 | ||||
| -rw-r--r-- | tinyusb/tusb.c | 8 | ||||
| -rw-r--r-- | tinyusb/tusb_option.h | 4 |
13 files changed, 64 insertions, 39 deletions
diff --git a/tinyusb/class/hid_device.c b/tinyusb/class/hid_device.c index ec77ccc74..40a46cd03 100644 --- a/tinyusb/class/hid_device.c +++ b/tinyusb/class/hid_device.c @@ -121,12 +121,12 @@ tusb_error_t tusbd_hid_mouse_send(uint8_t coreid, hid_mouse_report_t const *p_re //--------------------------------------------------------------------+ void hidd_init(void) { - + // TODO not implemented yet } void hidd_bus_reset(uint8_t coreid) { - + // TODO not implemented yet } tusb_error_t hidd_control_request(uint8_t coreid, tusb_control_request_t const * p_request) diff --git a/tinyusb/class/msc_device.c b/tinyusb/class/msc_device.c index 6e537810e..cd9e8eb68 100644 --- a/tinyusb/class/msc_device.c +++ b/tinyusb/class/msc_device.c @@ -56,9 +56,10 @@ typedef struct { endpoint_handle_t edpt_in, edpt_out;
// must be in USB ram
- uint8_t max_lun;
- msc_cmd_block_wrapper_t cbw;
- msc_cmd_status_wrapper_t csw;
+ ATTR_USB_MIN_ALIGNMENT uint8_t max_lun;
+
+ ATTR_USB_MIN_ALIGNMENT msc_cmd_block_wrapper_t cbw;
+ ATTR_USB_MIN_ALIGNMENT msc_cmd_status_wrapper_t csw;
}mscd_interface_t;
STATIC_VAR mscd_interface_t mscd_data TUSB_CFG_ATTR_USBRAM;
@@ -69,6 +70,16 @@ STATIC_VAR mscd_interface_t mscd_data TUSB_CFG_ATTR_USBRAM; //--------------------------------------------------------------------+
// USBD-CLASS API
//--------------------------------------------------------------------+
+void mscd_init(void)
+{
+ // TODO not implemented
+}
+
+void mscd_bus_reset(uint8_t coreid)
+{
+ // TODO not implemented yet
+}
+
tusb_error_t mscd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_interface_desc, uint16_t *p_length)
{
ASSERT( ( MSC_SUBCLASS_SCSI == p_interface_desc->bInterfaceSubClass &&
diff --git a/tinyusb/class/msc_device.h b/tinyusb/class/msc_device.h index a2d73945e..fd117da95 100644 --- a/tinyusb/class/msc_device.h +++ b/tinyusb/class/msc_device.h @@ -58,6 +58,8 @@ msc_csw_status_t tusbd_msc_scsi_received_isr (uint8_t coreid, uint8_t lun, uint8 //--------------------------------------------------------------------+
#ifdef _TINY_USB_SOURCE_FILE_
+void mscd_init(void);
+void mscd_bus_reset(uint8_t coreid);
tusb_error_t mscd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_interface_desc, uint16_t *p_length);
tusb_error_t mscd_control_request(uint8_t coreid, tusb_control_request_t const * p_request);
void mscd_isr(endpoint_handle_t edpt_hdl, tusb_event_t event, uint32_t xferred_bytes);
diff --git a/tinyusb/device/dcd_lpc13uxx.c b/tinyusb/device/dcd_lpc_11uxx_13uxx.c index 25739d31f..73d2f759a 100644 --- a/tinyusb/device/dcd_lpc13uxx.c +++ b/tinyusb/device/dcd_lpc_11uxx_13uxx.c @@ -1,6 +1,6 @@ /**************************************************************************/
/*!
- @file dcd_lpc13xx_12adc.c
+ @file dcd_lpc_11uxx_13uxx.c
@author hathach (tinyusb.org)
@section LICENSE
@@ -38,7 +38,7 @@ #include "tusb_option.h"
-#if MODE_DEVICE_SUPPORTED && MCU == MCU_LPC13UXX
+#if MODE_DEVICE_SUPPORTED && (MCU == MCU_LPC11UXX || MCU == MCU_LPC13UXX)
#define _TINY_USB_SOURCE_FILE_
//--------------------------------------------------------------------+
@@ -51,7 +51,7 @@ #include "dcd.h"
#include "usbd_dcd.h"
-#include "dcd_lpc13uxx.h"
+#include "dcd_lpc_11uxx_13uxx.h"
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
@@ -164,7 +164,6 @@ void dcd_controller_set_address(uint8_t coreid, uint8_t dev_addr) LPC_USB->DEVCMDSTAT |= dev_addr;
}
-
tusb_error_t dcd_init(void)
{
LPC_USB->EPLISTSTART = (uint32_t) dcd_data.qhd;
@@ -226,7 +225,8 @@ void dcd_isr(uint8_t coreid) }
- LPC_USB->DEVCMDSTAT |= CMDSTAT_MASK_RESET_CHANGE | CMDSTAT_MASK_SUSPEND_CHANGE | CMDSTAT_MASK_CONNECT_CHANGE;
+ LPC_USB->DEVCMDSTAT |= CMDSTAT_MASK_RESET_CHANGE | CMDSTAT_MASK_CONNECT_CHANGE
+ /* CMDSTAT_MASK_SUSPEND_CHANGE | */;
}
//------------- Control Endpoint -------------//
@@ -325,8 +325,22 @@ static inline uint8_t edpt_phy2log(uint8_t physical_endpoint) //--------------------------------------------------------------------+
// BULK/INTERRUPT/ISOCHRONOUS PIPE API
//--------------------------------------------------------------------+
+tusb_error_t dcd_pipe_stall(endpoint_handle_t edpt_hdl)
+{
+ ASSERT( !dcd_pipe_is_busy(edpt_hdl), TUSB_ERROR_INTERFACE_IS_BUSY); // endpoint must not in transferring
+
+ dcd_data.qhd[edpt_hdl.index][0].stall = 1;
+
+ return TUSB_ERROR_NONE;
+}
+
tusb_error_t dcd_pipe_clear_stall(uint8_t coreid, uint8_t edpt_addr)
{
+ uint8_t ep_id = edpt_addr2phy(edpt_addr);
+
+ dcd_data.qhd[ep_id][0].stall = 0;
+ dcd_data.qhd[ep_id][0].toggle_reset = 1;
+
return TUSB_ERROR_NONE;
}
@@ -371,10 +385,10 @@ bool dcd_pipe_is_busy(endpoint_handle_t edpt_hdl) // return TUSB_ERROR_NONE;
//}
-tusb_error_t dcd_pipe_queue_xfer(endpoint_handle_t edpt_hdl, void * buffer, uint16_t total_bytes)
-{
-
-}
+//tusb_error_t dcd_pipe_queue_xfer(endpoint_handle_t edpt_hdl, void * buffer, uint16_t total_bytes)
+//{
+//
+//}
tusb_error_t dcd_pipe_xfer(endpoint_handle_t edpt_hdl, void* buffer, uint16_t total_bytes, bool int_on_complete)
{
diff --git a/tinyusb/device/dcd_lpc13uxx.h b/tinyusb/device/dcd_lpc_11uxx_13uxx.h index 0a84741c7..0a84741c7 100644 --- a/tinyusb/device/dcd_lpc13uxx.h +++ b/tinyusb/device/dcd_lpc_11uxx_13uxx.h diff --git a/tinyusb/device/usbd.c b/tinyusb/device/usbd.c index 4f0b42a1b..d3480b370 100644 --- a/tinyusb/device/usbd.c +++ b/tinyusb/device/usbd.c @@ -124,6 +124,14 @@ tusb_error_t usbd_init (void) { ASSERT_STATUS ( dcd_init() ); +#if (TUSB_CFG_CONTROLLER_0_MODE & TUSB_MODE_DEVICE) + dcd_controller_connect(0); +#endif + +#if (TUSB_CFG_CONTROLLER_1_MODE & TUSB_MODE_DEVICE) + dcd_controller_connect(1); +#endif + for (tusb_std_class_code_t class_code = TUSB_CLASS_AUDIO; class_code <= TUSB_CLASS_AUDIO_VIDEO; class_code++) { if ( usbd_class_drivers[class_code].init ) diff --git a/tinyusb/hal/hal_lpc11uxx.c b/tinyusb/hal/hal_lpc11uxx.c index 4395a705c..9cb188e9c 100644 --- a/tinyusb/hal/hal_lpc11uxx.c +++ b/tinyusb/hal/hal_lpc11uxx.c @@ -51,6 +51,7 @@ tusb_error_t hal_init(void) address the wrong status in VBUSDebouncing bit in CmdStatus register. */ LPC_IOCON->PIO0_3 &= ~0x1F; LPC_IOCON->PIO0_3 |= (0x01<<0); /* Secondary function VBUS */ + LPC_IOCON->PIO0_6 &= ~0x07; LPC_IOCON->PIO0_6 |= (0x01<<0); /* Secondary function SoftConn */ diff --git a/tinyusb/hal/hal_lpc11uxx.h b/tinyusb/hal/hal_lpc11uxx.h index 65e75d46f..b9764ce65 100644 --- a/tinyusb/hal/hal_lpc11uxx.h +++ b/tinyusb/hal/hal_lpc11uxx.h @@ -36,12 +36,6 @@ */ /**************************************************************************/ -/** \file - * \brief TBD - * - * \note TBD - */ - /** \ingroup TBD * \defgroup TBD * \brief TBD @@ -58,15 +52,15 @@ extern "C" { #endif -static inline void hal_interrupt_enable(uint8_t controller_id) +static inline void hal_interrupt_enable(uint8_t coreid) { - (void) controller_id; // discard compiler's warning + (void) coreid; // discard compiler's warning NVIC_EnableIRQ(USB_IRQn); } -static inline void hal_interrupt_disable(uint8_t controller_id) +static inline void hal_interrupt_disable(uint8_t coreid) { - (void) controller_id; // discard compiler's warning + (void) coreid; // discard compiler's warning NVIC_DisableIRQ(USB_IRQn); } diff --git a/tinyusb/hal/hal_lpc13uxx.c b/tinyusb/hal/hal_lpc13uxx.c index fad4ea888..d4e3fa984 100644 --- a/tinyusb/hal/hal_lpc13uxx.c +++ b/tinyusb/hal/hal_lpc13uxx.c @@ -57,9 +57,6 @@ tusb_error_t hal_init(void) LPC_IOCON->PIO0_6 &= ~0x07; LPC_IOCON->PIO0_6 |= (0x01<<0); /* Secondary function SoftConn */ - dcd_controller_connect(0); - hal_interrupt_enable(0); - return TUSB_ERROR_NONE; } diff --git a/tinyusb/hal/hal_lpc43xx.c b/tinyusb/hal/hal_lpc43xx.c index fc7b78904..9cb07deff 100644 --- a/tinyusb/hal/hal_lpc43xx.c +++ b/tinyusb/hal/hal_lpc43xx.c @@ -81,7 +81,6 @@ tusb_error_t hal_init(void) CGU_EntityConnect(CGU_CLKSRC_XTAL_OSC, CGU_CLKSRC_PLL0);
CGU_EnableEntity(CGU_CLKSRC_PLL0, ENABLE); /* Enable PLL after all setting is done */
-
// reset controller & set role
ASSERT_STATUS( hal_controller_reset(0) );
@@ -93,10 +92,7 @@ tusb_error_t hal_init(void) #if TUSB_CFG_DEVICE_FULLSPEED // TODO for easy testing
LPC_USB0->PORTSC1_D |= (1<<24); // force full speed
#endif
- dcd_controller_connect(0);
#endif
-
- hal_interrupt_enable(0);
#endif
//------------- USB1 -------------//
@@ -114,11 +110,9 @@ tusb_error_t hal_init(void) LPC_USB1->USBMODE_H = LPC43XX_USBMODE_HOST | (LPC43XX_USBMODE_VBUS_HIGH << 5);
#else // TODO OTG
LPC_USB1->USBMODE_D = LPC43XX_USBMODE_DEVICE;
- dcd_controller_connect(1);
#endif
LPC_USB1->PORTSC1_D |= (1<<24); // TODO abtract, force port to fullspeed
- hal_interrupt_enable(1);
#endif
return TUSB_ERROR_NONE;
diff --git a/tinyusb/mcu_capacity.h b/tinyusb/mcu_capacity.h index 958a71f01..b5944ebed 100644 --- a/tinyusb/mcu_capacity.h +++ b/tinyusb/mcu_capacity.h @@ -78,10 +78,6 @@ #define CAP_MODE_HOST
#endif
-#if MCU == MCU_LPC43XX || MCU == MCU_LPC18XX || MCU == MCU_LPC11UXX || MCU == MCU_LPC13UXX
- #define CAP_DEVICE_ROMDRIVER
-#endif
-
//--------------------------------------------------------------------+
// Validation
//--------------------------------------------------------------------+
diff --git a/tinyusb/tusb.c b/tinyusb/tusb.c index 695cc1d3d..800fa0a2d 100644 --- a/tinyusb/tusb.c +++ b/tinyusb/tusb.c @@ -52,6 +52,14 @@ tusb_error_t tusb_init(void) ASSERT_STATUS ( usbd_init() ); // device stack init #endif +#if (TUSB_CFG_CONTROLLER_0_MODE) + hal_interrupt_enable(0); +#endif + +#if (TUSB_CFG_CONTROLLER_1_MODE) + hal_interrupt_enable(1); +#endif + return TUSB_ERROR_NONE; } diff --git a/tinyusb/tusb_option.h b/tinyusb/tusb_option.h index 0280f026c..b356047ed 100644 --- a/tinyusb/tusb_option.h +++ b/tinyusb/tusb_option.h @@ -51,8 +51,8 @@ /** \defgroup MCU_ MCU Selection
* \brief TUSB_CFG_MCU must be defined to one of these
* @{ */
-#define MCU_LPC13UXX 1 ///< NXP LPC13xx 12 bit ADC family with USB on-chip Rom Driver (not supported yet)
-#define MCU_LPC13XX_10ADC 2 ///< NXP LPC13xx 10 bit ADC family (not supported yet)
+#define MCU_LPC13UXX 1 ///< NXP LPC13xx 12 bit ADC family with USB on-chip Rom Driver (not supported yet)
+#define MCU_LPC13XX 2 ///< NXP LPC13xx 10 bit ADC family (not supported yet)
#define MCU_LPC11UXX 3 ///< NXP LPC11Uxx family (not supported yet)
#define MCU_LPC43XX 4 ///< NXP LPC43xx family
#define MCU_LPC18XX 5 ///< NXP LPC18xx family (not supported yet)
|
