tinyusb  0.4
Click here to lend your support to tinyusb donation and make a donation at pledgie.com
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
board.c
Go to the documentation of this file.
1 /**************************************************************************/
37 /**************************************************************************/
38 
39 #include "board.h"
40 #include "app_os_prio.h"
41 
42 #if TUSB_CFG_OS == TUSB_OS_NONE
43 
44 volatile uint32_t system_ticks = 0;
45 
46 void SysTick_Handler (void)
47 {
48  system_ticks++;
49 }
50 
51 uint32_t tusb_tick_get(void)
52 {
53  return system_ticks;
54 }
55 
56 #endif
57 
58 //--------------------------------------------------------------------+
59 // BLINKING TASK
60 //--------------------------------------------------------------------+
61 OSAL_TASK_DEF(led_blinking_task, 128, LED_BLINKING_APP_TASK_PRIO);
62 static uint32_t led_blink_interval_ms = 1000; // default is 1 second
63 
65 {
66  led_blink_interval_ms = 1000;
67  ASSERT(TUSB_ERROR_NONE == osal_task_create( OSAL_TASK_REF(led_blinking_task) ), VOID_RETURN );
68 }
69 
70 void led_blinking_set_interval(uint32_t ms)
71 {
72  led_blink_interval_ms = ms;
73 }
74 
75 OSAL_TASK_FUNCTION( led_blinking_task , p_task_para)
76 {
77  OSAL_TASK_LOOP_BEGIN
78 
79  static uint32_t led_on_mask = 0;
80 
81  osal_task_delay(led_blink_interval_ms);
82 
83  board_leds(led_on_mask, 1 - led_on_mask);
84  led_on_mask = 1 - led_on_mask; // toggle
85 
86 // uint32_t btn_mask;
87 // btn_mask = board_buttons();
88 //
89 // for(uint8_t i=0; i<32; i++)
90 // {
91 // if ( BIT_TEST_(btn_mask, i) ) printf("button %d is pressed\n", i);
92 // }
93 
94  OSAL_TASK_LOOP_END
95 }
96 
97 // TODO remove legacy cmsis code
98 void check_failed(uint8_t *file, uint32_t line)
99 {
100  (void) file;
101  (void) line;
102 }
void led_blinking_init(void)
Initialize the LED blinking task application. The initial blinking rate is 1 Hert (1 per second) ...
Definition: board.c:64
void board_leds(uint32_t on_mask, uint32_t off_mask)
Turns on and off leds on the board.
void led_blinking_set_interval(uint32_t ms)
Change the blinking rate.
Definition: board.c:70