jump_table.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /**************************************************************************************************
  2. Phyplus Microelectronics Limited confidential and proprietary.
  3. All rights reserved.
  4. IMPORTANT: All rights of this software belong to Phyplus Microelectronics
  5. Limited ("Phyplus"). Your use of this Software is limited to those
  6. specific rights granted under the terms of the business contract, the
  7. confidential agreement, the non-disclosure agreement and any other forms
  8. of agreements as a customer or a partner of Phyplus. You may not use this
  9. Software unless you agree to abide by the terms of these agreements.
  10. You acknowledge that the Software may not be modified, copied,
  11. distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
  12. (BLE) integrated circuit, either as a product or is integrated into your
  13. products. Other than for the aforementioned purposes, you may not use,
  14. reproduce, copy, prepare derivative works of, modify, distribute, perform,
  15. display or sell this Software and/or its documentation for any purposes.
  16. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  17. PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  18. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  19. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  20. PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
  21. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  22. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  23. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  24. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  25. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  26. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  27. **************************************************************************************************/
  28. /**************************************************************************************************
  29. Filename: jump_table.c
  30. Revised:
  31. Revision:
  32. Description: Jump table that holds function pointers and veriables used in ROM code.
  33. **************************************************************************************************/
  34. /*******************************************************************************
  35. * INCLUDES
  36. */
  37. #include "jump_function.h"
  38. #include "global_config.h"
  39. #include "OSAL_Tasks.h"
  40. #include "rf_phy_driver.h"
  41. #include "pwrmgr.h"
  42. #include "adc.h"
  43. #include "gpio.h"
  44. #include "uart.h"
  45. #include "i2c_s.h"
  46. #include "kscan.h"
  47. #include "rflib.h"
  48. #include "log.h"
  49. #include "spi.h"
  50. #include "watchdog.h"
  51. #include "ap_timer.h"
  52. /*******************************************************************************
  53. * MACROS
  54. */
  55. // unsigned int __current_sp(void);
  56. static void hard_fault(void)
  57. {
  58. unsigned int cur_sp = __current_sp();
  59. AT_LOG("Hard Fault SP is %x\n",cur_sp);
  60. for(int i = 0; i< 0x10; i++){
  61. AT_LOG("0x%x,", ((uint32_t*)cur_sp)[i]);
  62. }
  63. while(1){
  64. ;
  65. }
  66. }
  67. void PendSV_Handler( void ) __attribute__((weak));
  68. void SysTick_Handler( void ) __attribute__((weak));
  69. /*******************************************************************************
  70. * CONSTANTS
  71. */
  72. // jump table, this table save the function entry which will be called by ROM code
  73. // item 1 - 4 for OSAL task entry
  74. // item 224 - 255 for ISR(Interrupt Service Routine) entry
  75. // others are reserved by ROM code
  76. const uint32_t* const jump_table_base[256] __attribute__((section("jump_table_mem_area"))) =
  77. {
  78. (const uint32_t*)0, // 0. write Log
  79. (const uint32_t*)osalInitTasks, // 1. init entry of app
  80. (const uint32_t*)tasksArr, // 2. task list
  81. (const uint32_t*)&tasksCnt, // 3. task count
  82. (const uint32_t*)&tasksEvents, // 4. task events
  83. 0, 0, 0, 0, 0, // 5 - 9, reserved by phyplus
  84. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 10 - 19, reserved by phyplus
  85. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20 - 29, reserved by phyplus
  86. 0, 0, 0, 0, 0, 0, 0, 0, // <30 - - 37>
  87. 0, 0,
  88. 0, 0, 0, 0, 0, 0, //40 - 45
  89. 0, 0, 0, 0, //46 - 49
  90. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 50 - 59, reserved by phyplus
  91. 0, // < 60 -
  92. 0,
  93. 0,
  94. 0,
  95. 0, 0, 0, 0, 0, 0, // -69>, reserved by phyplus
  96. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 70 -79, reserved by phyplus
  97. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 80 - 89, reserved by phyplus
  98. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 90 - 99, reserved by phyplus
  99. (const uint32_t*)hal_pwrmgr_sleep_process, // <100 -
  100. (const uint32_t*)hal_pwrmgr_wakeup_process,
  101. (const uint32_t*)rf_phy_ini,
  102. 0,
  103. 0,
  104. 0,
  105. 0, 0, 0, 0, // - 109, reserved by phyplus
  106. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 110 -119, reserved by phyplus
  107. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 120 -129, reserved by phyplus
  108. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 130 -139, reserved by phyplus
  109. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 140 -149, reserved by phyplus
  110. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 150 -159, reserved by phyplus
  111. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 160 -169, reserved by phyplus
  112. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 170 -179, reserved by phyplus
  113. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 180 -189, reserved by phyplus
  114. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 190 -199, reserved by phyplus
  115. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 200 - 209, reserved by phyplus
  116. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 210 - 219, reserved by phyplus
  117. (const uint32_t*)hard_fault, 0, (const uint32_t *)PendSV_Handler, (const uint32_t *)SysTick_Handler, 0, 0, 0, 0, // 220 - 227
  118. 0,
  119. (const uint32_t*)hal_KSCAN_IRQHandler, // 228 - 229
  120. 0, 0, 0, (const uint32_t*)AP_TIMER_IRQHandler, 0, // 230 - 234
  121. (const uint32_t*)hal_UART0_IRQHandler, // 235 uart irq handler
  122. (const uint32_t*)hal_I2C0_IRQHandler,
  123. (const uint32_t*)hal_I2C1_IRQHandler,
  124. (const uint32_t*)hal_SPI0_IRQHandler,
  125. (const uint32_t*)hal_SPI1_IRQHandler, // 236 - 239
  126. (const uint32_t*)hal_GPIO_IRQHandler, //240 gpio interrupt handler
  127. 0, 0, 0, 0, 0, 0, 0, 0, 0, // 241 - 249, for ISR entry
  128. 0, 0, 0, (const uint32_t*)hal_ADC_IRQHandler, 0, 0 // 250 - 255, for ISR entry
  129. };
  130. /*******************************************************************************
  131. * Prototypes
  132. */
  133. /*******************************************************************************
  134. * LOCAL VARIABLES
  135. */
  136. /*********************************************************************
  137. * EXTERNAL VARIABLES
  138. */
  139. uint32 global_config[SOFT_PARAMETER_NUM] __attribute__((section("global_config_area")));