diff --git a/examples/device/cdc_msc_hid/ses/samd21/samd21.emProject b/examples/device/cdc_msc_hid/ses/samd21/samd21.emProject index e65873008..30aad55ca 100644 --- a/examples/device/cdc_msc_hid/ses/samd21/samd21.emProject +++ b/examples/device/cdc_msc_hid/ses/samd21/samd21.emProject @@ -67,6 +67,11 @@ + + + + + diff --git a/examples/device/cdc_msc_hid/src/main.c b/examples/device/cdc_msc_hid/src/main.c index a203e567e..12e331af7 100644 --- a/examples/device/cdc_msc_hid/src/main.c +++ b/examples/device/cdc_msc_hid/src/main.c @@ -135,7 +135,7 @@ void usb_hid_task(void) if ( board_millis() < start_ms + interval_ms) return; // not enough time start_ms += interval_ms; - uint32_t const btn = board_buttons(); + uint32_t const btn = board_button_read(); if ( tud_suspended() && btn ) { diff --git a/examples/device/cdc_msc_hid_freertos/src/main.c b/examples/device/cdc_msc_hid_freertos/src/main.c index 388bd9ad1..e47937bd5 100644 --- a/examples/device/cdc_msc_hid_freertos/src/main.c +++ b/examples/device/cdc_msc_hid_freertos/src/main.c @@ -158,7 +158,7 @@ void usb_hid_task(void* params) if ( board_millis() < start_ms + interval_ms) return; // not enough time start_ms += interval_ms; - uint32_t const btn = board_buttons(); + uint32_t const btn = board_button_read(); /*------------- Keyboard -------------*/ if ( tud_hid_keyboard_ready() ) diff --git a/hw/bsp/board.h b/hw/bsp/board.h index df9d5d11d..7d12d68fb 100644 --- a/hw/bsp/board.h +++ b/hw/bsp/board.h @@ -46,6 +46,7 @@ //--------------------------------------------------------------------+ // Board Porting API +// For simplicity, only one LED and one Button are used //--------------------------------------------------------------------+ // Initialize on-board peripherals : led, button, uart and USB @@ -54,9 +55,9 @@ void board_init(void); // Turn LED on or off void board_led_control(bool state); -// Get the current state of buttons on the board -// \return Bitmask where a '1' means active (pressed), a '0' means inactive. -uint32_t board_buttons(void); +// Get the current state of button +// a '1' means active (pressed), a '0' means inactive. +uint32_t board_button_read(void); // Get characters from UART int board_uart_read(uint8_t* buf, int len); @@ -65,28 +66,20 @@ int board_uart_read(uint8_t* buf, int len); int board_uart_write(void const * buf, int len); #if CFG_TUSB_OS == OPT_OS_NONE - -// Get current milliseconds, must be implemented in board.c when no OS is used -uint32_t board_millis(void); - + // Get current milliseconds, must be implemented when no RTOS is used + uint32_t board_millis(void); #elif CFG_TUSB_OS == OPT_OS_FREERTOS - -static inline uint32_t board_millis(void) -{ - return ( ( ((uint64_t) xTaskGetTickCount()) * 1000) / configTICK_RATE_HZ ); -} - + static inline uint32_t board_millis(void) + { + return ( ( ((uint64_t) xTaskGetTickCount()) * 1000) / configTICK_RATE_HZ ); + } #elif CFG_TUSB_OS == OPT_OS_MYNEWT - -static inline uint32_t board_millis(void) -{ - return os_time_ticks_to_ms32( os_time_get() ); -} - + static inline uint32_t board_millis(void) + { + return os_time_ticks_to_ms32( os_time_get() ); + } #elif - -#error "Need to implement board_millis() for this OS" - + #error "Need to implement board_millis() for this OS" #endif //--------------------------------------------------------------------+ diff --git a/hw/bsp/ea4088qs/board_ea4088qs.c b/hw/bsp/ea4088qs/board_ea4088qs.c index 4f4e19ee0..2d5110d25 100644 --- a/hw/bsp/ea4088qs/board_ea4088qs.c +++ b/hw/bsp/ea4088qs/board_ea4088qs.c @@ -127,7 +127,7 @@ static bool button_read(uint8_t id) } #endif -uint32_t board_buttons(void) +uint32_t board_button_read(void) { uint32_t result = 0; diff --git a/hw/bsp/ea4357/board_ea4357.c b/hw/bsp/ea4357/board_ea4357.c index 6d7d936db..898ad38ad 100644 --- a/hw/bsp/ea4357/board_ea4357.c +++ b/hw/bsp/ea4357/board_ea4357.c @@ -269,7 +269,7 @@ static bool button_read(uint8_t id) } #endif -uint32_t board_buttons(void) +uint32_t board_button_read(void) { uint32_t result = 0; diff --git a/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c b/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c index fa0966831..e1f1fd366 100644 --- a/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c +++ b/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c @@ -121,7 +121,7 @@ void board_led_control(bool state) //--------------------------------------------------------------------+ // Buttons //--------------------------------------------------------------------+ -uint32_t board_buttons(void) +uint32_t board_button_read(void) { // for(uint8_t i=0; iLFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk); NRF_CLOCK->TASKS_LFCLKSTART = 1UL; - // LEDs + // LED nrf_gpio_cfg_output(LED_PIN); board_led_control(false); // Button - for(uint8_t i=0; i