mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-17 04:21:23 +00:00
clean up
This commit is contained in:
parent
16b3f11d9f
commit
a3cc52829b
@ -18,11 +18,12 @@
|
||||
arm_target_debug_interface_type="ADIv5"
|
||||
arm_target_device_name="LPC1769"
|
||||
arm_target_interface_type="SWD"
|
||||
build_treat_warnings_as_errors="Yes"
|
||||
build_treat_warnings_as_errors="No"
|
||||
c_preprocessor_definitions="LPC175x_6x;__LPC1700_FAMILY;__LPC176x_SUBFAMILY;ARM_MATH_CM3;FLASH_PLACEMENT=1;BOARD_LPCXPRESSO1769;CFG_TUSB_MCU=OPT_MCU_LPC175X_6X;CFG_TUSB_MEM_SECTION= __attribute__((section(".bss2")))"
|
||||
c_user_include_directories="../../src;$(rootDir)/hw/cmsis/Include;$(rootDir)/hw;$(rootDir)/src;$(lpcDir)/CMSIS_CORE_LPC17xx/inc;$(lpcDir)/LPC17xx_DriverLib/include"
|
||||
debug_register_definition_file="LPC176x5x_Registers.xml"
|
||||
debug_target_connection="J-Link"
|
||||
gcc_enable_all_warnings="Yes"
|
||||
gcc_entry_point="Reset_Handler"
|
||||
link_use_linker_script_file="No"
|
||||
linker_memory_map_file="LPC1769_MemoryMap.xml"
|
||||
|
@ -47,7 +47,7 @@
|
||||
#define BOARD_LED_PORT (0)
|
||||
#define BOARD_LED_PIN (22)
|
||||
|
||||
const static struct {
|
||||
static const struct {
|
||||
uint8_t port;
|
||||
uint8_t pin;
|
||||
} buttons[] =
|
||||
|
@ -191,12 +191,12 @@ bool dcd_init(uint8_t rhport)
|
||||
bus_reset();
|
||||
|
||||
LPC_USB->USBDevIntEn = (DEV_INT_DEVICE_STATUS_MASK | DEV_INT_ENDPOINT_SLOW_MASK | DEV_INT_ERROR_MASK);
|
||||
LPC_USB->USBUDCAH = (uint32_t) _dcd.udca;
|
||||
LPC_USB->USBDMAIntEn = (DMA_INT_END_OF_XFER_MASK | DMA_INT_ERROR_MASK );
|
||||
LPC_USB->USBUDCAH = (uint32_t) _dcd.udca;
|
||||
LPC_USB->USBDMAIntEn = (DMA_INT_END_OF_XFER_MASK | DMA_INT_ERROR_MASK);
|
||||
|
||||
sie_write(SIE_CMDCODE_DEVICE_STATUS, 1, 1); // connect
|
||||
sie_write(SIE_CMDCODE_DEVICE_STATUS, 1, 1); // connect
|
||||
|
||||
NVIC_EnableIRQ(USB_IRQn);
|
||||
NVIC_EnableIRQ(USB_IRQn);
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
@ -327,6 +327,7 @@ void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr)
|
||||
|
||||
void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr)
|
||||
{
|
||||
(void) rhport;
|
||||
uint8_t ep_id = edpt_addr2phy(ep_addr);
|
||||
|
||||
sie_write(SIE_CMDCODE_ENDPOINT_SET_STATUS+ep_id, 1, 0);
|
||||
@ -334,6 +335,7 @@ void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr)
|
||||
|
||||
bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr)
|
||||
{
|
||||
(void) rhport;
|
||||
// TODO implement later
|
||||
return false;
|
||||
}
|
||||
@ -471,16 +473,13 @@ static void endpoint_non_control_isr(uint32_t eot_int)
|
||||
}
|
||||
}
|
||||
|
||||
static void endpoint_control_isr(void)
|
||||
static void control_xfer_isr(uint8_t rhport)
|
||||
{
|
||||
uint32_t const interrupt_enable = LPC_USB->USBEpIntEn;
|
||||
uint32_t const endpoint_int_status = LPC_USB->USBEpIntSt & interrupt_enable;
|
||||
// LPC_USB->USBEpIntClr = endpoint_int_status; // acknowledge interrupt TODO cannot immediately acknowledge setup packet
|
||||
|
||||
dcd_event_t event = { .rhport = 0 };
|
||||
uint32_t const ep_int_status = LPC_USB->USBEpIntSt & LPC_USB->USBEpIntEn;
|
||||
// LPC_USB->USBEpIntClr = ep_int_status; // acknowledge interrupt TODO cannot immediately acknowledge setup packet
|
||||
|
||||
//------------- Setup Received-------------//
|
||||
if ( (endpoint_int_status & BIT_(0)) &&
|
||||
if ( (ep_int_status & BIT_(0)) &&
|
||||
(sie_read(SIE_CMDCODE_ENDPOINT_SELECT+0, 1) & SIE_SELECT_ENDPOINT_SETUP_RECEIVED_MASK) )
|
||||
{
|
||||
(void) sie_read(SIE_CMDCODE_ENDPOINT_SELECT_CLEAR_INTERRUPT+0, 1); // clear setup bit
|
||||
@ -488,12 +487,12 @@ static void endpoint_control_isr(void)
|
||||
uint8_t setup_packet[8];
|
||||
control_ep_read(setup_packet, 8); // TODO read before clear setup above
|
||||
|
||||
dcd_event_setup_received(0, setup_packet, true);
|
||||
dcd_event_setup_received(rhport, setup_packet, true);
|
||||
}
|
||||
else if (endpoint_int_status & 0x03)
|
||||
else if (ep_int_status & 0x03)
|
||||
{
|
||||
// Control out complete
|
||||
if ( endpoint_int_status & BIT_(0) )
|
||||
if ( ep_int_status & BIT_(0) )
|
||||
{
|
||||
if ( _dcd.control.out_buffer )
|
||||
{
|
||||
@ -503,7 +502,7 @@ static void endpoint_control_isr(void)
|
||||
_dcd.control.out_buffer = NULL;
|
||||
_dcd.control.out_bytes = 0;
|
||||
|
||||
dcd_event_xfer_complete(0, 0, received, XFER_RESULT_SUCCESS, true);
|
||||
dcd_event_xfer_complete(rhport, 0, received, XFER_RESULT_SUCCESS, true);
|
||||
}else
|
||||
{
|
||||
// mark as received
|
||||
@ -512,13 +511,13 @@ static void endpoint_control_isr(void)
|
||||
}
|
||||
|
||||
// Control In complete
|
||||
if ( endpoint_int_status & BIT_(1) )
|
||||
if ( ep_int_status & BIT_(1) )
|
||||
{
|
||||
dcd_event_xfer_complete(0, TUSB_DIR_IN_MASK, _dcd.control.in_bytes, XFER_RESULT_SUCCESS, true);
|
||||
dcd_event_xfer_complete(rhport, TUSB_DIR_IN_MASK, _dcd.control.in_bytes, XFER_RESULT_SUCCESS, true);
|
||||
}
|
||||
}
|
||||
|
||||
LPC_USB->USBEpIntClr = endpoint_int_status; // acknowledge interrupt TODO cannot immediately acknowledge setup packet
|
||||
LPC_USB->USBEpIntClr = ep_int_status; // acknowledge interrupt TODO cannot immediately acknowledge setup packet
|
||||
}
|
||||
|
||||
void hal_dcd_isr(uint8_t rhport)
|
||||
@ -561,7 +560,7 @@ void hal_dcd_isr(uint8_t rhport)
|
||||
//------------- Control Endpoint (Slave Mode) -------------//
|
||||
if (device_int_status & DEV_INT_ENDPOINT_SLOW_MASK)
|
||||
{
|
||||
endpoint_control_isr();
|
||||
control_xfer_isr(rhport);
|
||||
}
|
||||
|
||||
//------------- Non-Control Endpoint (DMA Mode) -------------//
|
||||
|
Loading…
x
Reference in New Issue
Block a user