dcd nrf change atoimc_bool to atomic_flag

This commit is contained in:
hathach 2024-04-22 12:12:56 +07:00
parent 9d1d171b0c
commit 2e383bf901
No known key found for this signature in database
GPG Key ID: 26FAB84F615C3C52
6 changed files with 11 additions and 14 deletions

View File

@ -1,6 +1,5 @@
set(MCU_VARIANT nrf52840)
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/../../linker/nrf52840_s140_v6.ld)
#set(LD_FILE_GNU ${NRFX_DIR}/mdk/nrf52840_xxaa.ld)
# enable max3421 host driver for this board
set(MAX3421_HOST 1)

View File

@ -30,10 +30,10 @@ set(FAMILY_MCUS NRF5X CACHE INTERNAL "")
# only need to be built ONCE for all examples
function(add_board_target BOARD_TARGET)
if (NOT TARGET ${BOARD_TARGET})
if (NOT DEFINED LD_FILE_${CMAKE_C_COMPILER_ID})
if (NOT DEFINED LD_FILE_GNU)
set(LD_FILE_GNU ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/${MCU_VARIANT}_xxaa.ld)
set(LD_FILE_Clang ${LD_FILE_GNU})
endif ()
set(LD_FILE_Clang ${LD_FILE_GNU})
if (NOT DEFINED STARTUP_FILE_${CMAKE_C_COMPILER_ID})
set(STARTUP_FILE_GNU ${NRFX_DIR}/mdk/gcc_startup_${MCU_VARIANT}.S)

View File

@ -1,7 +1,7 @@
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)
/*GROUP(-lgcc -lc -lnosys) not compatible with clang*/
MEMORY
{

View File

@ -1,6 +1,7 @@
/* Linker script to configure memory regions. */
SEARCH_DIR(.)
/*GROUP(-lgcc -lc -lnosys) not compatible with clang*/
MEMORY
{
@ -10,7 +11,6 @@ MEMORY
CODE_RAM (rwx) : ORIGIN = 0x800000, LENGTH = 0x40000
}
INCLUDE "nrf_common.ld"
/* nrfx v2 linker does not define __tbss_start/end__ __sbss_start/end__*/
@ -18,9 +18,3 @@ INCLUDE "nrf_common.ld"
/*__tbss_end__ = __tbss_end;*/
/*__sbss_start__ = __sbss_start;*/
/*__sbss_end__ = __sbss_end;*/
/* picolibc crt0 */
/*__data_source = __copy_table_start__;*/
/*__tls_base = __tdata_start;*/
/*PROVIDE( __tls_align = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)) );*/
/*PROVIDE( __arm32_tls_tcb_offset = MAX(8, __tls_align) );*/

View File

@ -388,3 +388,8 @@ bool tuh_max3421_spi_xfer_api(uint8_t rhport, uint8_t const* tx_buf, uint8_t* rx
}
#endif
void HardFault_Handler(void) {
__BKPT(0);
while (1);
}

View File

@ -119,7 +119,7 @@ static struct {
xfer_td_t xfer[EP_CBI_COUNT + 1][2];
// nRF can only carry one DMA at a time, this is used to guard the access to EasyDMA
atomic_bool dma_running;
atomic_flag dma_running;
} _dcd;
/*------------------------------------------------------------------*/
@ -155,7 +155,6 @@ static void edpt_dma_start(volatile uint32_t* reg_startep) {
// DMA is complete
static void edpt_dma_end(void) {
TU_ASSERT(_dcd.dma_running,);
atomic_flag_clear(&_dcd.dma_running);
}
@ -618,7 +617,7 @@ void dcd_int_handler(uint8_t rhport) {
}
if (int_status & USBD_INTEN_USBEVENT_Msk) {
TU_LOG(3, "EVENTCAUSE = 0x%04lX\r\n", NRF_USBD->EVENTCAUSE);
TU_LOG(3, "EVENTCAUSE = 0x%04" PRIX32 "\r\n", NRF_USBD->EVENTCAUSE);
enum {
EVT_CAUSE_MASK = USBD_EVENTCAUSE_SUSPEND_Msk | USBD_EVENTCAUSE_RESUME_Msk | USBD_EVENTCAUSE_USBWUALLOWED_Msk |