diff options
| author | hathach <[email protected]> | 2018-11-22 17:40:20 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-11-22 17:40:20 +0700 |
| commit | 569e85a0c0a80848e3076b64363ce0e589d3a604 (patch) | |
| tree | aebb98121194b9a4333d4933701ce25a79baf071 /src | |
| parent | 60d8cde6951fa9fe9c43064ee701598e9da566f7 (diff) | |
cdc work ok with lpc43xx
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/compiler/tusb_compiler_gcc.h | 2 | ||||
| -rw-r--r-- | src/common/compiler/tusb_compiler_iar.h | 2 | ||||
| -rw-r--r-- | src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c | 71 |
3 files changed, 37 insertions, 38 deletions
diff --git a/src/common/compiler/tusb_compiler_gcc.h b/src/common/compiler/tusb_compiler_gcc.h index c9f716d48..e40ad9c41 100644 --- a/src/common/compiler/tusb_compiler_gcc.h +++ b/src/common/compiler/tusb_compiler_gcc.h @@ -66,10 +66,8 @@ /// The packed attribute specifies that a variable or structure field should have the smallest possible alignment—one byte for a variable, and one bit for a field, unless you specify a larger value with the aligned attribute #define ATTR_PACKED __attribute__ ((packed)) - #define ATTR_PREPACKED -#define ATTR_PACKED_STRUCT(x) x __attribute__ ((packed)) /** @} */ /** \defgroup Group_FuncAttr Function Attributes diff --git a/src/common/compiler/tusb_compiler_iar.h b/src/common/compiler/tusb_compiler_iar.h index 1703ea45f..1f8936859 100644 --- a/src/common/compiler/tusb_compiler_iar.h +++ b/src/common/compiler/tusb_compiler_iar.h @@ -53,8 +53,6 @@ #endif
#define ALIGN_OF(x) __ALIGNOF__(x)
-
-#define ATTR_PACKED_STRUCT(x) __packed x
#define ATTR_PREPACKED __packed
#define ATTR_PACKED
//#define ATTR_SECTION(section) _Pragma((#section))
diff --git a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c index 64a2c257a..07f6eef82 100644 --- a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c +++ b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c @@ -237,40 +237,7 @@ static inline uint8_t qtd_find_free(uint8_t rhport) }
//--------------------------------------------------------------------+
-// CONTROL PIPE API
-//--------------------------------------------------------------------+
-
-// control transfer does not need to use qtd find function
-// follows UM 24.10.8.1.1 Setup packet handling using setup lockout mechanism
-bool dcd_control_xfer(uint8_t rhport, uint8_t dir, uint8_t * p_buffer, uint16_t length)
-{
- LPC_USB0_Type* const lpc_usb = LPC_USB[rhport];
- dcd_data_t* const p_dcd = dcd_data_ptr[rhport];
-
- uint8_t const ep_phy = (dir == TUSB_DIR_IN) ? 1 : 0;
-
- dcd_qhd_t* qhd = &p_dcd->qhd[ep_phy];
-
- // wait until ENDPTSETUPSTAT before priming data/status in response TODO add time out
- while(lpc_usb->ENDPTSETUPSTAT & BIT_(0)) {}
-
- TU_VERIFY( !qhd->qtd_overlay.active );
-
- dcd_qtd_t* qtd = &p_dcd->qtd[0];
- qtd_init(qtd, p_buffer, length);
-
- // skip xfer complete for Status
- qtd->int_on_complete = (length > 0 ? 1 : 0);
-
- qhd->qtd_overlay.next = (uint32_t) qtd;
-
- lpc_usb->ENDPTPRIME = BIT_(edpt_phy2pos(ep_phy));
-
- return true;
-}
-
-//--------------------------------------------------------------------+
-// BULK/INTERRUPT/ISOCHRONOUS PIPE API
+// DCD Endpoint Port
//--------------------------------------------------------------------+
static inline volatile uint32_t * get_reg_control_addr(uint8_t rhport, uint8_t physical_endpoint)
{
@@ -345,6 +312,36 @@ bool dcd_edpt_busy(uint8_t rhport, uint8_t ep_addr) // return !p_qhd->qtd_overlay.halted && p_qhd->qtd_overlay.active;
}
+// control transfer does not need to use qtd find function
+// follows UM 24.10.8.1.1 Setup packet handling using setup lockout mechanism
+bool dcd_control_xfer(uint8_t rhport, uint8_t dir, uint8_t * p_buffer, uint16_t length)
+{
+ LPC_USB0_Type* const lpc_usb = LPC_USB[rhport];
+ dcd_data_t* const p_dcd = dcd_data_ptr[rhport];
+
+ uint8_t const ep_phy = (dir == TUSB_DIR_IN) ? 1 : 0;
+
+ dcd_qhd_t* qhd = &p_dcd->qhd[ep_phy];
+
+ // wait until ENDPTSETUPSTAT before priming data/status in response TODO add time out
+ while(lpc_usb->ENDPTSETUPSTAT & BIT_(0)) {}
+
+ TU_VERIFY( !qhd->qtd_overlay.active );
+
+ dcd_qtd_t* qtd = &p_dcd->qtd[0];
+ qtd_init(qtd, p_buffer, length);
+
+ // skip xfer complete for Status
+ qtd->int_on_complete = (length > 0 ? 1 : 0);
+
+ qhd->qtd_overlay.next = (uint32_t) qtd;
+
+ lpc_usb->ENDPTPRIME = BIT_(edpt_phy2pos(ep_phy));
+
+ return true;
+}
+
+
// add only, controller virtually cannot know
// TODO remove and merge to dcd_edpt_xfer
static bool pipe_add_xfer(uint8_t rhport, uint8_t ed_idx, void * buffer, uint16_t total_bytes, bool int_on_complete)
@@ -377,6 +374,11 @@ static bool pipe_add_xfer(uint8_t rhport, uint8_t ed_idx, void * buffer, uint16_ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
{
+ if ( edpt_number(ep_addr) == 0 )
+ {
+ return dcd_control_xfer(rhport, edpt_dir(ep_addr), buffer, total_bytes);
+ }
+
uint8_t ep_idx = edpt_addr2phy(ep_addr);
TU_VERIFY ( pipe_add_xfer(rhport, ep_idx, buffer, total_bytes, true) );
@@ -391,6 +393,7 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t return true;
}
+
//--------------------------------------------------------------------+
// ISR
//--------------------------------------------------------------------+
|
