mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-11 00:39:57 +00:00
add board_noos_millis() for blinky
This commit is contained in:
parent
43eb1a8b16
commit
df1aac44b8
@ -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
|
||||
|
@ -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
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -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
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -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
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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" {
|
||||
|
11
tools/build_all.py
Normal file
11
tools/build_all.py
Normal file
@ -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)
|
Loading…
x
Reference in New Issue
Block a user