FreeRTOS_tick_config.c 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * FreeRTOS V202104.00
  3. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  6. * this software and associated documentation files (the "Software"), to deal in
  7. * the Software without restriction, including without limitation the rights to
  8. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  9. * the Software, and to permit persons to whom the Software is furnished to do so,
  10. * subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in all
  13. * copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  17. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  18. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  19. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  20. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * http://www.FreeRTOS.org
  23. * http://aws.amazon.com/freertos
  24. *
  25. * 1 tab == 4 spaces!
  26. */
  27. /* FreeRTOS includes. */
  28. #include "FreeRTOS.h"
  29. #include "task.h"
  30. /* Library includes. */
  31. #include "board.h"
  32. #include "chip.h"
  33. /*
  34. * The FreeRTOS tick handler. This function must be installed as the handler
  35. * for the timer used to generate the tick interrupt. Note that the interrupt
  36. * generated by the PIT is shared by other system peripherals, so if the PIT is
  37. * used for Tick generation then FreeRTOS_Tick_Handler() can only be installed
  38. * directly as the PIT handler if no other system interrupts need to be
  39. * serviced. If system interrupts other than the PIT need to be serviced then
  40. * install System_Handler() as the PIT interrupt handler in place of
  41. * FreeRTOS_Tick_Handler() and add additional interrupt processing into the
  42. * implementation of System_Handler().
  43. */
  44. extern void FreeRTOS_Tick_Handler( void );
  45. /*-----------------------------------------------------------*/
  46. static void System_Handler( void *para )
  47. {
  48. vTimerClrInt((uint32_t)para);
  49. /* See the comments above the function prototype in this file. */
  50. FreeRTOS_Tick_Handler();
  51. }
  52. /*-----------------------------------------------------------*/
  53. /*
  54. * The application must provide a function that configures a peripheral to
  55. * create the FreeRTOS tick interrupt, then define configSETUP_TICK_INTERRUPT()
  56. * in FreeRTOSConfig.h to call the function. This file contains a function
  57. * that is suitable for use on the Atmel SAMA5.
  58. */
  59. void vConfigureTickInterrupt( void )
  60. {
  61. vTimerInit(TIMER_ID0, 1, 1, configTICK_RATE_HZ);
  62. vTimerEnable(TIMER_ID0);
  63. request_irq(TIMER0_IRQn, 0, System_Handler, (void*)TIMER_ID0);
  64. AIC_EnableIT(TIMER0_IRQn);
  65. /* Prevent compiler warnings in the case where System_Handler() is not used
  66. as the handler. See the comments above the System_Handler() function
  67. prototype at the top of this file. */
  68. ( void ) System_Handler;
  69. }
  70. /*-----------------------------------------------------------*/