csi_core.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. /*
  2. * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /******************************************************************************
  17. * @file csi_core.h
  18. * @brief CSI Core Layer Header File
  19. * @version V1.0
  20. * @date 02. June 2017
  21. ******************************************************************************/
  22. #ifndef _CORE_H_
  23. #define _CORE_H_
  24. #include <stdint.h>
  25. #include "csi_gcc.h"
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. /* ################################## NVIC function ############################################ */
  30. /**
  31. \brief initialize the NVIC interrupt controller
  32. \param [in] prio_bits the priority bits of NVIC interrupt controller.
  33. */
  34. void drv_nvic_init(uint32_t prio_bits);
  35. /**
  36. \brief Enable External Interrupt
  37. \details Enables a device-specific interrupt in the NVIC interrupt controller.
  38. \param [in] irq_num External interrupt number. Value cannot be negative.
  39. */
  40. void drv_nvic_enable_irq(int32_t irq_num);
  41. /**
  42. \brief Disable External Interrupt
  43. \details Disables a device-specific interrupt in the NVIC interrupt controller.
  44. \param [in] irq_num External interrupt number. Value cannot be negative.
  45. */
  46. void drv_nvic_disable_irq(int32_t irq_num);
  47. /**
  48. \brief Get Pending Interrupt
  49. \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt.
  50. \param [in] irq_num Interrupt number.
  51. \return 0 Interrupt status is not pending.
  52. \return 1 Interrupt status is pending.
  53. */
  54. uint32_t drv_nvic_get_pending_irq(int32_t irq_num);
  55. /**
  56. \brief Set Pending Interrupt
  57. \details Sets the pending bit of an external interrupt.
  58. \param [in] irq_num Interrupt number. Value cannot be negative.
  59. */
  60. void drv_nvic_set_pending_irq(int32_t irq_num);
  61. /**
  62. \brief Clear Pending Interrupt
  63. \details Clears the pending bit of an external interrupt.
  64. \param [in] irq_num External interrupt number. Value cannot be negative.
  65. */
  66. void drv_nvic_clear_pending_irq(int32_t irq_num);
  67. /**
  68. \brief Get Active Interrupt
  69. \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt.
  70. \param [in] irq_num Device specific interrupt number.
  71. \return 0 Interrupt status is not active.
  72. \return 1 Interrupt status is active.
  73. \note irq_num must not be negative.
  74. */
  75. uint32_t drv_nvic_get_active(int32_t irq_num);
  76. /**
  77. \brief Set Interrupt Priority
  78. \details Sets the priority of an interrupt.
  79. \note The priority cannot be set for every core interrupt.
  80. \param [in] irq_num Interrupt number.
  81. \param [in] priority Priority to set.
  82. */
  83. void drv_nvic_set_prio(int32_t irq_num, uint32_t priority);
  84. /**
  85. \brief Get Interrupt Priority
  86. \details Reads the priority of an interrupt.
  87. The interrupt number can be positive to specify an external (device specific) interrupt,
  88. or negative to specify an internal (core) interrupt.
  89. \param [in] irq_num Interrupt number.
  90. \return Interrupt Priority.
  91. Value is aligned automatically to the implemented priority bits of the microcontroller.
  92. */
  93. uint32_t drv_nvic_get_prio(int32_t irq_num);
  94. /*@} end of CSI_Core_NVICFunctions */
  95. /* ########################## Cache functions #################################### */
  96. /**
  97. \brief Enable I-Cache
  98. \details Turns on I-Cache
  99. */
  100. void drv_icache_enable(void);
  101. /**
  102. \brief Disable I-Cache
  103. \details Turns off I-Cache
  104. */
  105. void drv_icache_disable(void);
  106. /**
  107. \brief Invalidate I-Cache
  108. \details Invalidates I-Cache
  109. */
  110. void drv_icache_invalid(void);
  111. /**
  112. \brief Enable D-Cache
  113. \details Turns on D-Cache
  114. \note I-Cache also turns on.
  115. */
  116. void drv_dcache_enable(void);
  117. /**
  118. \brief Disable D-Cache
  119. \details Turns off D-Cache
  120. \note I-Cache also turns off.
  121. */
  122. void drv_dcache_disable(void);
  123. /**
  124. \brief Invalidate D-Cache
  125. \details Invalidates D-Cache
  126. \note I-Cache also invalid
  127. */
  128. void drv_dcache_invalid(void);
  129. /**
  130. \brief Clean D-Cache
  131. \details Cleans D-Cache
  132. \note I-Cache also cleans
  133. */
  134. void drv_dcache_clean(void);
  135. /**
  136. \brief Clean & Invalidate D-Cache
  137. \details Cleans and Invalidates D-Cache
  138. \note I-Cache also flush.
  139. */
  140. void drv_dcache_clean_invalid(void);
  141. /**
  142. \brief D-Cache Invalidate by address
  143. \details Invalidates D-Cache for the given address
  144. \param[in] addr address (aligned to 16-byte boundary)
  145. \param[in] dsize size of memory block (in number of bytes)
  146. */
  147. void drv_dcache_invalid_range(uint32_t *addr, int32_t dsize);
  148. /**
  149. \brief D-Cache Clean by address
  150. \details Cleans D-Cache for the given address
  151. \param[in] addr address (aligned to 16-byte boundary)
  152. \param[in] dsize size of memory block (in number of bytes)
  153. */
  154. void drv_dcache_clean_range(uint32_t *addr, int32_t dsize);
  155. /**
  156. \brief D-Cache Clean and Invalidate by address
  157. \details Cleans and invalidates D_Cache for the given address
  158. \param[in] addr address (aligned to 16-byte boundary)
  159. \param[in] dsize size of memory block (in number of bytes)
  160. */
  161. void drv_dcache_clean_invalid_range(uint32_t *addr, int32_t dsize);
  162. /**
  163. \brief setup cacheable range Cache
  164. \details setup Cache range
  165. */
  166. void drv_cache_set_range(uint32_t index, uint32_t baseAddr, uint32_t size, uint32_t enable);
  167. /**
  168. \brief Enable cache profile
  169. \details Turns on Cache profile
  170. */
  171. void drv_cache_enable_profile(void);
  172. /**
  173. \brief Disable cache profile
  174. \details Turns off Cache profile
  175. */
  176. void drv_cache_disable_profile(void);
  177. /**
  178. \brief Reset cache profile
  179. \details Reset Cache profile
  180. */
  181. void drv_cache_reset_profile(void);
  182. /**
  183. \brief cache access times
  184. \details Cache access times
  185. \note every 256 access add 1.
  186. */
  187. uint32_t drv_cache_get_access_time(void);
  188. /**
  189. \brief cache miss times
  190. \details Cache miss times
  191. \note every 256 miss add 1.
  192. */
  193. uint32_t drv_cache_get_miss_time(void);
  194. /* ################################## SysTick function ############################################ */
  195. /**
  196. \brief CORE timer Configuration
  197. \details Initializes the System Timer and its interrupt, and starts the System Tick Timer.
  198. Counter is in free running mode to generate periodic interrupts.
  199. \param [in] ticks Number of ticks between two interrupts.
  200. \param [in] irq_num core timer Interrupt number.
  201. \return 0 Function succeeded.
  202. \return 1 Function failed.
  203. \note When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
  204. function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
  205. must contain a vendor-specific implementation of this function.
  206. */
  207. uint32_t drv_coret_config(uint32_t ticks, int32_t irq_num);
  208. #ifdef __cplusplus
  209. }
  210. #endif
  211. #endif /* _CORE_H_ */