enable USBMC for uno r4, add board_init_after_tusb() API

add BOARD_UPPERCASE for board detection
This commit is contained in:
hathach
2023-07-31 19:09:40 +07:00
parent cb47231518
commit 3f788a4e5a
32 changed files with 123 additions and 3 deletions

View File

@@ -54,6 +54,9 @@
// Initialize on-board peripherals : led, button, uart and USB
void board_init(void);
// Init board after tinyusb is initialized
void board_init_after_tusb(void) TU_ATTR_WEAK;
// Turn LED on or off
void board_led_write(bool state);

View File

@@ -181,6 +181,11 @@ endfunction()
function(family_configure_common TARGET RTOS)
family_add_rtos(${TARGET} ${RTOS})
string(TOUPPER ${BOARD} BOARD_UPPER)
target_compile_definitions(${TARGET} PUBLIC
BOARD_${BOARD_UPPER}
)
# run size after build
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND ${CMAKE_SIZE} $<TARGET_FILE:${TARGET}>

View File

@@ -1,7 +1,7 @@
CPU_CORE = cortex-m4
MCU_VARIANT = ra4m1
LD_FILE = $(BOARD_PATH)/${BOARD}.ld
LD_FILE = ${BOARD_PATH}/${BOARD}.ld
# For flash-jlink target
JLINK_DEVICE = R7FA4M1AB

View File

@@ -124,6 +124,13 @@ void board_init(void) {
board_led_write(false);
}
void board_init_after_tusb(void) {
// For board that use USB LDO regulator
#if defined(BOARD_UNO_R4)
R_USB_FS0->USBMC |= R_USB_FS0_USBMC_VDCEN_Msk;
#endif
}
void board_led_write(bool state) {
R_IOPORT_PinWrite(&port_ctrl, LED1, state ? LED_STATE_ON : !LED_STATE_ON);
}