board.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /**************************************************************************/
  2. /*!
  3. @file board.c
  4. @author hathach (tinyusb.org)
  5. @section LICENSE
  6. Software License Agreement (BSD License)
  7. Copyright (c) 2013, hathach (tinyusb.org)
  8. All rights reserved.
  9. Redistribution and use in source and binary forms, with or without
  10. modification, are permitted provided that the following conditions are met:
  11. 1. Redistributions of source code must retain the above copyright
  12. notice, this list of conditions and the following disclaimer.
  13. 2. Redistributions in binary form must reproduce the above copyright
  14. notice, this list of conditions and the following disclaimer in the
  15. documentation and/or other materials provided with the distribution.
  16. 3. Neither the name of the copyright holders nor the
  17. names of its contributors may be used to endorse or promote products
  18. derived from this software without specific prior written permission.
  19. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
  20. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
  23. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
  26. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. This file is part of the tinyusb stack.
  30. */
  31. /**************************************************************************/
  32. #include "board.h"
  33. //#include "app_os_prio.h"
  34. #if TUSB_CFG_OS == TUSB_OS_NONE
  35. volatile uint32_t system_ticks = 0;
  36. void SysTick_Handler (void)
  37. {
  38. system_ticks++;
  39. }
  40. uint32_t hal_tick_get(void)
  41. {
  42. return system_ticks;
  43. }
  44. #endif
  45. #if 0
  46. //--------------------------------------------------------------------+
  47. // BLINKING TASK
  48. //--------------------------------------------------------------------+
  49. static uint32_t led_blink_interval_ms = 1000; // default is 1 second
  50. void led_blinking_init(void)
  51. {
  52. led_blink_interval_ms = 1000;
  53. osal_task_create(led_blinking_task, "blinky", 128, NULL, LED_BLINKING_APP_TASK_PRIO);
  54. }
  55. void led_blinking_set_interval(uint32_t ms)
  56. {
  57. led_blink_interval_ms = ms;
  58. }
  59. tusb_error_t led_blinking_subtask(void);
  60. void led_blinking_task(void* param)
  61. {
  62. (void) param;
  63. OSAL_TASK_BEGIN
  64. led_blinking_subtask();
  65. OSAL_TASK_END
  66. }
  67. tusb_error_t led_blinking_subtask(void)
  68. {
  69. OSAL_SUBTASK_BEGIN
  70. static uint32_t led_on_mask = 0;
  71. osal_task_delay(led_blink_interval_ms);
  72. board_leds(led_on_mask, 1 - led_on_mask);
  73. led_on_mask = 1 - led_on_mask; // toggle
  74. // uint32_t btn_mask;
  75. // btn_mask = board_buttons();
  76. //
  77. // for(uint8_t i=0; i<32; i++)
  78. // {
  79. // if ( BIT_TEST_(btn_mask, i) ) printf("button %d is pressed\n", i);
  80. // }
  81. OSAL_SUBTASK_END
  82. }
  83. #endif
  84. // TODO remove legacy cmsis code
  85. void check_failed(uint8_t *file, uint32_t line)
  86. {
  87. (void) file;
  88. (void) line;
  89. }