diff options
| author | hathach <[email protected]> | 2019-03-23 16:51:07 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2019-03-23 16:51:07 +0700 |
| commit | df1aac44b839f65bf8b5961d4d184c515ad18f5c (patch) | |
| tree | a01d718b7ee77bf1363b521f2dd66e3dc2510c20 | |
| parent | 43eb1a8b1631ed4b460db123717a7226c10c701f (diff) | |
add board_noos_millis() for blinky
| -rw-r--r-- | examples/device/cdc_msc_hid/src/main.c | 7 | ||||
| -rw-r--r-- | hw/bsp/board.h | 3 | ||||
| -rw-r--r-- | hw/bsp/ea4088qs/board_ea4088qs.c | 8 | ||||
| -rw-r--r-- | hw/bsp/ea4357/board_ea4357.c | 8 | ||||
| -rw-r--r-- | hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c | 11 | ||||
| -rw-r--r-- | hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c | 13 | ||||
| -rw-r--r-- | hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c | 8 | ||||
| -rw-r--r-- | hw/bsp/mcb1800/board_mcb1800.c | 8 | ||||
| -rw-r--r-- | hw/bsp/metro_m0_express/board_metro_m0_express.c | 11 | ||||
| -rw-r--r-- | hw/bsp/metro_m4_express/board_metro_m4_express.c | 10 | ||||
| -rw-r--r-- | hw/bsp/pca10056/board_pca10056.c | 8 | ||||
| -rw-r--r-- | hw/bsp/stm32f303disc/board_stm32f303disc.c | 10 | ||||
| -rw-r--r-- | hw/bsp/stm32f407g_disc1/board_stm32f407g_disc1.c | 10 | ||||
| -rw-r--r-- | src/common/tusb_timeout.h | 4 | ||||
| -rw-r--r-- | tools/build_all.py | 11 |
15 files changed, 110 insertions, 20 deletions
diff --git a/examples/device/cdc_msc_hid/src/main.c b/examples/device/cdc_msc_hid/src/main.c index b2a902835..be0b14933 100644 --- a/examples/device/cdc_msc_hid/src/main.c +++ b/examples/device/cdc_msc_hid/src/main.c @@ -193,11 +193,12 @@ void tud_umount_cb(void) //--------------------------------------------------------------------+ void led_blinking_task(void) { - static tu_timeout_t tm = { .start = 0, .interval = 1000 }; // Blink every 1000 ms + static uint32_t start_ms = 0; static bool led_state = false; - if ( !tu_timeout_expired(&tm) ) return; // not enough time - tu_timeout_reset(&tm); + // Blink every 1000 ms + if ( board_noos_millis() < start_ms + 1000) return; // not enough time + start_ms += 1000; board_led_control(led_state); led_state = 1 - led_state; // toggle diff --git a/hw/bsp/board.h b/hw/bsp/board.h index ec0b1311a..44dba7ecf 100644 --- a/hw/bsp/board.h +++ b/hw/bsp/board.h @@ -64,6 +64,9 @@ int board_uart_read(uint8_t* buf, int len); // Send characters to UART int board_uart_write(void const * buf, int len); +// Get current milliseconds with no rtos configure (TUSB_CFG_OS = OPT_OS_NONE) +uint32_t board_noos_millis(void); + //--------------------------------------------------------------------+ // Helper functions //--------------------------------------------------------------------+ diff --git a/hw/bsp/ea4088qs/board_ea4088qs.c b/hw/bsp/ea4088qs/board_ea4088qs.c index d8ab2973d..e4b006c74 100644 --- a/hw/bsp/ea4088qs/board_ea4088qs.c +++ b/hw/bsp/ea4088qs/board_ea4088qs.c @@ -81,7 +81,8 @@ void board_init(void) SystemCoreClockUpdate(); #if CFG_TUSB_OS == OPT_OS_NONE - SysTick_Config(SystemCoreClock / BOARD_TICKS_HZ); + // 1ms tick timer + SysTick_Config(SystemCoreClock / 1000); #elif CFG_TUSB_OS == OPT_OS_FREERTOS // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher ) NVIC_SetPriority(USB_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ); @@ -174,6 +175,11 @@ uint32_t tusb_hal_millis(void) return board_tick2ms(system_ticks); } +uint32_t board_noos_millis(void) +{ + return system_ticks; +} + #endif #endif diff --git a/hw/bsp/ea4357/board_ea4357.c b/hw/bsp/ea4357/board_ea4357.c index a9af16633..3bb846cc1 100644 --- a/hw/bsp/ea4357/board_ea4357.c +++ b/hw/bsp/ea4357/board_ea4357.c @@ -74,6 +74,11 @@ uint32_t tusb_hal_millis(void) return board_tick2ms(system_ticks); } +uint32_t board_noos_millis(void) +{ + return system_ticks; +} + #endif /*------------------------------------------------------------------*/ @@ -126,7 +131,8 @@ void board_init(void) SystemCoreClockUpdate(); #if CFG_TUSB_OS == OPT_OS_NONE - SysTick_Config( SystemCoreClock / BOARD_TICKS_HZ ); + // 1ms tick timer + SysTick_Config(SystemCoreClock / 1000); #endif Chip_GPIO_Init(LPC_GPIO_PORT); diff --git a/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c b/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c index 472204d66..ca7e699c0 100644 --- a/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c +++ b/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c @@ -71,7 +71,11 @@ void board_init(void) SystemCoreClockUpdate(); #if CFG_TUSB_OS == OPT_OS_NONE - SysTick_Config(SystemCoreClock / BOARD_TICKS_HZ); // 1 msec tick timer + // 1ms tick timer + SysTick_Config(SystemCoreClock / 1000); +#elif CFG_TUSB_OS == OPT_OS_FREERTOS + // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher ) + NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ); #endif Chip_GPIO_Init(LPC_GPIO); @@ -106,6 +110,11 @@ uint32_t tusb_hal_millis(void) return board_tick2ms(system_ticks); } +uint32_t board_noos_millis(void) +{ + return system_ticks; +} + #endif //--------------------------------------------------------------------+ diff --git a/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c b/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c index e7ed229a5..18853c5fb 100644 --- a/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c +++ b/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c @@ -87,6 +87,14 @@ void board_init(void) SysTick_Config(SystemCoreClock / BOARD_TICKS_HZ); // 1 msec tick timer #endif +#if CFG_TUSB_OS == OPT_OS_NONE + // 1ms tick timer + SysTick_Config(SystemCoreClock / 1000); +#elif CFG_TUSB_OS == OPT_OS_FREERTOS + // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher ) + NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ); +#endif + Chip_GPIO_Init(LPC_GPIO_PORT); //------------- LED -------------// @@ -119,6 +127,11 @@ uint32_t tusb_hal_millis(void) return board_tick2ms(system_ticks); } +uint32_t board_noos_millis(void) +{ + return system_ticks; +} + #endif //--------------------------------------------------------------------+ diff --git a/hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c b/hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c index 32273aa75..5578ae5d6 100644 --- a/hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c +++ b/hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c @@ -85,7 +85,8 @@ void board_init(void) SystemCoreClockUpdate(); #if CFG_TUSB_OS == OPT_OS_NONE - SysTick_Config(SystemCoreClock / BOARD_TICKS_HZ); + // 1ms tick timer + SysTick_Config(SystemCoreClock / 1000); #elif CFG_TUSB_OS == OPT_OS_FREERTOS // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher ) NVIC_SetPriority(USB_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ); @@ -162,6 +163,11 @@ uint32_t tusb_hal_millis(void) return board_tick2ms(system_ticks); } +uint32_t board_noos_millis(void) +{ + return system_ticks; +} + #endif //--------------------------------------------------------------------+ diff --git a/hw/bsp/mcb1800/board_mcb1800.c b/hw/bsp/mcb1800/board_mcb1800.c index b7ddf46eb..d6b45090d 100644 --- a/hw/bsp/mcb1800/board_mcb1800.c +++ b/hw/bsp/mcb1800/board_mcb1800.c @@ -95,7 +95,8 @@ void board_init(void) SystemCoreClockUpdate(); #if CFG_TUSB_OS == OPT_OS_NONE - SysTick_Config( SystemCoreClock / BOARD_TICKS_HZ ); + // 1ms tick timer + SysTick_Config(SystemCoreClock / 1000); #endif Chip_GPIO_Init(LPC_GPIO_PORT); @@ -240,6 +241,11 @@ uint32_t tusb_hal_millis(void) return board_tick2ms(system_ticks); } +uint32_t board_noos_millis(void) +{ + return system_ticks; +} + #endif #endif diff --git a/hw/bsp/metro_m0_express/board_metro_m0_express.c b/hw/bsp/metro_m0_express/board_metro_m0_express.c index 8bca69a30..06d8407ab 100644 --- a/hw/bsp/metro_m0_express/board_metro_m0_express.c +++ b/hw/bsp/metro_m0_express/board_metro_m0_express.c @@ -66,8 +66,8 @@ void board_init(void) gpio_set_pin_level(LED_PIN, 0); #if CFG_TUSB_OS == OPT_OS_NONE - // Tick init, samd SystemCoreClock may not correct - SysTick_Config(CONF_CPU_FREQUENCY/1000); + // 1ms tick timer (samd SystemCoreClock may not correct) + SysTick_Config(CONF_CPU_FREQUENCY / 1000); #endif /* USB Clock init @@ -119,4 +119,11 @@ uint32_t tusb_hal_millis(void) { return board_tick2ms(system_ticks); } + +uint32_t board_noos_millis(void) +{ + return system_ticks; +} + + #endif diff --git a/hw/bsp/metro_m4_express/board_metro_m4_express.c b/hw/bsp/metro_m4_express/board_metro_m4_express.c index b14ce31d6..d20a04537 100644 --- a/hw/bsp/metro_m4_express/board_metro_m4_express.c +++ b/hw/bsp/metro_m4_express/board_metro_m4_express.c @@ -63,10 +63,9 @@ void board_init(void) gpio_set_pin_direction(LED_PIN, GPIO_DIRECTION_OUT); gpio_set_pin_level(LED_PIN, 0); - // Systick init #if CFG_TUSB_OS == OPT_OS_NONE - // Tick init, samd SystemCoreClock may not correct - SysTick_Config(SystemCoreClock / 1000); + // 1ms tick timer (samd SystemCoreClock may not correct) + SysTick_Config(CONF_CPU_FREQUENCY / 1000); #endif /* USB Clock init @@ -109,4 +108,9 @@ uint32_t tusb_hal_millis(void) { return board_tick2ms(system_ticks); } + +uint32_t board_noos_millis(void) +{ + return system_ticks; +} #endif diff --git a/hw/bsp/pca10056/board_pca10056.c b/hw/bsp/pca10056/board_pca10056.c index c82b1544f..179b22dcc 100644 --- a/hw/bsp/pca10056/board_pca10056.c +++ b/hw/bsp/pca10056/board_pca10056.c @@ -65,6 +65,12 @@ uint32_t tusb_hal_millis(void) { return board_tick2ms(system_ticks); } + +uint32_t board_noos_millis(void) +{ + return system_ticks; +} + #endif /*------------------------------------------------------------------*/ @@ -89,7 +95,7 @@ void board_init(void) for(uint8_t i=0; i<BOARD_BUTTON_COUNT; i++) nrf_gpio_cfg_input(_button_pins[i], NRF_GPIO_PIN_PULLUP); #if CFG_TUSB_OS == OPT_OS_NONE - // Tick init + // 1ms tick timer SysTick_Config(SystemCoreClock/1000); #endif diff --git a/hw/bsp/stm32f303disc/board_stm32f303disc.c b/hw/bsp/stm32f303disc/board_stm32f303disc.c index 00740acca..e1cc8c689 100644 --- a/hw/bsp/stm32f303disc/board_stm32f303disc.c +++ b/hw/bsp/stm32f303disc/board_stm32f303disc.c @@ -55,9 +55,10 @@ void board_init(void) // Notify runtime of frequency change. SystemCoreClockUpdate(); - // Systick init + #if CFG_TUSB_OS == OPT_OS_NONE - SysTick_Config(SystemCoreClock / 1000); + // 1ms tick timer + SysTick_Config(SystemCoreClock / 1000); #endif /* -1- Enable GPIOE Clock (to be able to program the configuration registers) */ @@ -112,6 +113,11 @@ uint32_t tusb_hal_millis(void) { return board_tick2ms(system_ticks); } + +uint32_t board_noos_millis(void) +{ + return system_ticks; +} #endif void HardFault_Handler (void) diff --git a/hw/bsp/stm32f407g_disc1/board_stm32f407g_disc1.c b/hw/bsp/stm32f407g_disc1/board_stm32f407g_disc1.c index bf45eb5a0..ddafa42b2 100644 --- a/hw/bsp/stm32f407g_disc1/board_stm32f407g_disc1.c +++ b/hw/bsp/stm32f407g_disc1/board_stm32f407g_disc1.c @@ -60,9 +60,10 @@ void board_init(void) // Notify runtime of frequency change. SystemCoreClockUpdate(); - // Systick init + #if CFG_TUSB_OS == OPT_OS_NONE - SysTick_Config(SystemCoreClock / 1000); + // 1ms tick timer + SysTick_Config(SystemCoreClock / 1000); #endif RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN; @@ -108,6 +109,11 @@ uint32_t tusb_hal_millis(void) { return board_tick2ms(system_ticks); } + +uint32_t board_noos_millis(void) +{ + return system_ticks; +} #endif void HardFault_Handler (void) diff --git a/src/common/tusb_timeout.h b/src/common/tusb_timeout.h index 556b8d4a3..bdade6b42 100644 --- a/src/common/tusb_timeout.h +++ b/src/common/tusb_timeout.h @@ -28,11 +28,11 @@ * \defgroup Group_TimeoutTimer timeout timer
* @{ */
-
#ifndef _TUSB_TIMEOUT_H_
#define _TUSB_TIMEOUT_H_
-#include "tusb_compiler.h"
+#include <stdbool.h>
+#include <stdint.h>
#ifdef __cplusplus
extern "C" {
diff --git a/tools/build_all.py b/tools/build_all.py new file mode 100644 index 000000000..4b6fa5775 --- /dev/null +++ b/tools/build_all.py @@ -0,0 +1,11 @@ +import os +import shutil +import sys +import subprocess +import time + +all_boards = ["metro_m0_express", "metro_m4_express", "pca10056", "stm32f407g_disc1"] + +for board in all_boards: + subprocess.run("make -j2 -C examples/device/cdc_msc_hid BOARD={} clean".format(board), shell=True) + subprocess.run("make -j2 -C examples/device/cdc_msc_hid BOARD={} all".format(board), shell=True) |
