system_psoc6.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. /***************************************************************************//**
  2. * \file system_psoc6.h
  3. * \version 2.95.1
  4. *
  5. * \brief Device system header file.
  6. *
  7. ********************************************************************************
  8. * \copyright
  9. * Copyright 2016-2021 Cypress Semiconductor Corporation
  10. * SPDX-License-Identifier: Apache-2.0
  11. *
  12. * Licensed under the Apache License, Version 2.0 (the "License");
  13. * you may not use this file except in compliance with the License.
  14. * You may obtain a copy of the License at
  15. *
  16. * http://www.apache.org/licenses/LICENSE-2.0
  17. *
  18. * Unless required by applicable law or agreed to in writing, software
  19. * distributed under the License is distributed on an "AS IS" BASIS,
  20. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  21. * See the License for the specific language governing permissions and
  22. * limitations under the License.
  23. *******************************************************************************/
  24. #ifndef _SYSTEM_PSOC6_H_
  25. #define _SYSTEM_PSOC6_H_
  26. /**
  27. * \addtogroup group_system_config_cm4
  28. * \{
  29. * Provides device startup, system configuration, and linker script files.
  30. * The system startup provides the followings features:
  31. * - See \ref group_system_config_device_initialization for the:
  32. * * \ref group_system_config_dual_core_device_initialization
  33. * * \ref group_system_config_single_core_device_initialization
  34. * - \ref group_system_config_device_memory_definition
  35. * - \ref group_system_config_heap_stack_config
  36. * - \ref group_system_config_default_handlers
  37. * - \ref group_system_config_device_vector_table
  38. * - \ref group_system_config_cm4_functions
  39. *
  40. * \section group_system_config_configuration Configuration Considerations
  41. *
  42. * \subsection group_system_config_device_memory_definition Device Memory Definition
  43. * The flash and RAM allocation for each CPU is defined by the linker scripts.
  44. * For dual-core devices, the physical flash and RAM memory is shared between the CPU cores.
  45. * 2 KB of RAM (allocated at the end of RAM) are reserved for system use.
  46. * For Single-Core devices the system reserves additional 80 bytes of RAM.
  47. * Using the reserved memory area for other purposes will lead to unexpected behavior.
  48. *
  49. * \note The linker files provided with the PDL are generic and handle all common
  50. * use cases. Your project may not use every section defined in the linker files.
  51. * In that case you may see warnings during the build process. To eliminate build
  52. * warnings in your project, you can simply comment out or remove the relevant
  53. * code in the linker file.
  54. *
  55. * \note For the PSoC 64 Secure MCUs devices, refer to the following page:
  56. * https://www.cypress.com/documentation/software-and-drivers/psoc-64-secure-mcu-secure-boot-sdk-user-guide
  57. *
  58. *
  59. * <b>ARM GCC</b>\n
  60. * The flash and RAM sections for the CPU are defined in the linker files:
  61. * 'xx_yy.ld', where 'xx' is the device group, and 'yy' is the target CPU; for example,
  62. * 'cy8c6xx7_cm0plus.ld' and 'cy8c6xx7_cm4_dual.ld'.
  63. * \note If the start of the Cortex-M4 application image is changed, the value
  64. * of the \ref CY_CORTEX_M4_APPL_ADDR should also be changed. The
  65. * \ref CY_CORTEX_M4_APPL_ADDR macro should be used as the parameter for the
  66. * Cy_SysEnableCM4() function call.
  67. * By default, the COMPONENT_CM0P_SLEEP prebuilt image is used for the CM0p core.
  68. * More about CM0+ prebuilt images, see here:
  69. * https://github.com/Infineon/psoc6cm0p
  70. *
  71. * Change the flash and RAM sizes by editing the macros value in the
  72. * linker files for both CPUs:
  73. * - 'xx_cm0plus.ld', where 'xx' is the device group:
  74. * \code
  75. * flash (rx) : ORIGIN = 0x10000000, LENGTH = 0x2000
  76. * ram (rwx) : ORIGIN = 0x08000000, LENGTH = 0x2000
  77. * \endcode
  78. * - 'xx_cm4_dual.ld', where 'xx' is the device group:
  79. * \code
  80. * flash (rx) : ORIGIN = 0x10000000, LENGTH = 0x100000
  81. * ram (rwx) : ORIGIN = 0x08002000, LENGTH = 0x45800
  82. * \endcode
  83. *
  84. * Change the value of the \ref CY_CORTEX_M4_APPL_ADDR macro to the ROM ORIGIN's
  85. * value (0x10000000) + FLASH_CM0P_SIZE value (0x2000, the size of a flash image
  86. * of the Cortex-M0+ application should be the same value as the flash LENGTH in
  87. * 'xx_cm0plus.ld') in the 'xx_cm4_dual.ld' file, where 'xx' is the device group.
  88. * Do this by either:
  89. * - Passing the following commands to the compiler:\n
  90. * \code -D CY_CORTEX_M4_APPL_ADDR=0x10002000 \endcode
  91. * or
  92. * - Editing the \ref CY_CORTEX_M4_APPL_ADDR value in the 'system_xx.h', where
  93. * 'xx' is the device family:\n
  94. * \code #define CY_CORTEX_M4_APPL_ADDR (0x10002000u) \endcode
  95. *
  96. * <b>ARM Compiler</b>\n
  97. * The flash and RAM sections for the CPU are defined in the linker files:
  98. * 'xx_yy.sct', where 'xx' is the device group, and 'yy' is the target CPU; for
  99. * example 'cy8c6xx7_cm0plus.sct' and 'cy8c6xx7_cm4_dual.sct'.
  100. * \note If the start of the Cortex-M4 application image is changed, the value
  101. * of the of the \ref CY_CORTEX_M4_APPL_ADDR should also be changed. The
  102. * \ref CY_CORTEX_M4_APPL_ADDR macro should be used as the parameter for the \ref
  103. * Cy_SysEnableCM4() function call.
  104. * By default, the COMPONENT_CM0P_SLEEP prebuilt image is used for the CM0p core.
  105. * More about CM0+ prebuilt images, see here:
  106. * https://github.com/Infineon/psoc6cm0p
  107. *
  108. * \note The linker files provided with the PDL are generic and handle all common
  109. * use cases. Your project may not use every section defined in the linker files.
  110. * In that case you may see the warnings during the build process:
  111. * L6314W (no section matches pattern) and/or L6329W
  112. * (pattern only matches removed unused sections). In your project, you can
  113. * suppress the warning by passing the "--diag_suppress=L6314W,L6329W" option to
  114. * the linker. You can also comment out or remove the relevant code in the linker
  115. * file.
  116. *
  117. * Change the flash and RAM sizes by editing the macros value in the
  118. * linker files for both CPUs:
  119. * - 'xx_cm0plus.sct', where 'xx' is the device group:
  120. * \code
  121. * #define FLASH_START 0x10000000
  122. * #define FLASH_SIZE 0x00002000
  123. * #define RAM_START 0x08000000
  124. * #define RAM_SIZE 0x00002000
  125. * \endcode
  126. * - 'xx_cm4_dual.sct', where 'xx' is the device group:
  127. * \code
  128. * #define FLASH_START 0x10000000
  129. * #define FLASH_SIZE 0x00100000
  130. * #define RAM_START 0x08002000
  131. * #define RAM_SIZE 0x00045800
  132. * \endcode
  133. *
  134. * Change the value of the \ref CY_CORTEX_M4_APPL_ADDR macro to the FLASH_START
  135. * value (0x10000000) + FLASH_CM0P_SIZE value (0x2000, the size of a flash image
  136. * of the Cortex-M0+ application should be the same value as the FLASH_SIZE in the
  137. * 'xx_cm0plus.sct') in the 'xx_cm4_dual.sct' file, where 'xx' is the device group.
  138. * Do this by either:
  139. * - Passing the following commands to the compiler:\n
  140. * \code -D CY_CORTEX_M4_APPL_ADDR=0x10002000 \endcode
  141. * or
  142. * - Editing the \ref CY_CORTEX_M4_APPL_ADDR value in the 'system_xx.h', where
  143. * 'xx' is the device family:\n
  144. * \code #define CY_CORTEX_M4_APPL_ADDR (0x10002000u) \endcode
  145. *
  146. * <b>IAR</b>\n
  147. * The flash and RAM sections for the CPU are defined in the linker files:
  148. * 'xx_yy.icf', where 'xx' is the device group, and 'yy' is the target CPU; for example,
  149. * 'cy8c6xx7_cm0plus.icf' and 'cy8c6xx7_cm4_dual.icf'.
  150. * \note If the start of the Cortex-M4 application image is changed, the value
  151. * of the of the \ref CY_CORTEX_M4_APPL_ADDR should also be changed. The
  152. * \ref CY_CORTEX_M4_APPL_ADDR macro should be used as the parameter for the \ref
  153. * Cy_SysEnableCM4() function call.
  154. * By default, the COMPONENT_CM0P_SLEEP prebuilt image is used for the CM0p core.
  155. * More about CM0+ prebuilt images, see here:
  156. * https://github.com/Infineon/psoc6cm0p
  157. *
  158. * Change the flash and RAM sizes by editing the macros value in the
  159. * linker files for both CPUs:
  160. * - 'xx_cm0plus.icf', where 'xx' is the device group:
  161. * \code
  162. * define symbol __ICFEDIT_region_IROM1_start__ = 0x10000000;
  163. * define symbol __ICFEDIT_region_IROM1_end__ = 0x10001FFF;
  164. * define symbol __ICFEDIT_region_IRAM1_start__ = 0x08000000;
  165. * define symbol __ICFEDIT_region_IRAM1_end__ = 0x08001FFF;
  166. * \endcode
  167. * - 'xx_cm4_dual.icf', where 'xx' is the device group:
  168. * \code
  169. * define symbol __ICFEDIT_region_IROM1_start__ = 0x10000000;
  170. * define symbol __ICFEDIT_region_IROM1_end__ = 0x100FFFFF;
  171. * define symbol __ICFEDIT_region_IRAM1_start__ = 0x08002000;
  172. * define symbol __ICFEDIT_region_IRAM1_end__ = 0x080477FF;
  173. * \endcode
  174. *
  175. * Change the value of the \ref CY_CORTEX_M4_APPL_ADDR macro to the
  176. * __ICFEDIT_region_IROM1_start__ value (0x10000000) + FLASH_CM0P_SIZE value
  177. * (0x2000, the size of a flash image of the Cortex-M0+ application) in the
  178. * 'xx_cm4_dual.icf' file, where 'xx' is the device group. The sum result
  179. * should be the same as (__ICFEDIT_region_IROM1_end__ + 1) value in the
  180. * 'xx_cm0plus.icf'. Do this by either:
  181. * - Passing the following commands to the compiler:\n
  182. * \code -D CY_CORTEX_M4_APPL_ADDR=0x10002000 \endcode
  183. * or
  184. * - Editing the \ref CY_CORTEX_M4_APPL_ADDR value in the 'system_xx.h', where
  185. * 'xx' is the device family:\n
  186. * \code #define CY_CORTEX_M4_APPL_ADDR (0x10002000u) \endcode
  187. *
  188. * \subsection group_system_config_device_initialization Device Initialization
  189. * After a power-on-reset (POR), the boot process is handled by the boot code
  190. * from the on-chip ROM that is always executed by the Cortex-M0+ core. The boot
  191. * code passes the control to the Cortex-M0+ startup code located in flash.
  192. *
  193. * \subsubsection group_system_config_dual_core_device_initialization Dual-Core Devices
  194. * The Cortex-M0+ startup code performs the device initialization by a call to
  195. * SystemInit() and then calls the main() function. The Cortex-M4 core is disabled
  196. * by default. Enable the core using the \ref Cy_SysEnableCM4() function.
  197. * See \ref group_system_config_cm4_functions for more details.
  198. * \note Startup code executes SystemInit() function for the both Cortex-M0+ and Cortex-M4 cores.
  199. * The function has a separate implementation on each core.
  200. * Both function implementations unlock and disable the WDT.
  201. * Therefore enable the WDT after both cores have been initialized.
  202. *
  203. * \subsubsection group_system_config_single_core_device_initialization Single-Core Devices
  204. * The Cortex-M0+ core is not user-accessible on these devices. In this case the
  205. * Flash Boot handles setup of the CM0+ core and starts the Cortex-M4 core.
  206. *
  207. * \subsection group_system_config_heap_stack_config Heap and Stack Configuration
  208. * There are two ways to adjust heap and stack configurations:
  209. * -# Editing source code files
  210. * -# Specifying via command line
  211. *
  212. * By default, the stack size is set to 0x00001000 and the heap size is allocated
  213. * dynamically to the whole available free memory up to stack memory and it
  214. * is set to the 0x00000400 (for ARM GCC and IAR compilers) as minimal value.
  215. *
  216. * \subsubsection group_system_config_heap_stack_config_gcc ARM GCC
  217. * - <b>Editing source code files</b>\n
  218. * The heap and stack sizes are defined in the assembler startup files
  219. * (e.g. startup_psoc6_01_cm0plus.S and startup_psoc6_01_cm4.S).
  220. * Change the heap and stack sizes by modifying the following lines:\n
  221. * \code .equ Stack_Size, 0x00001000 \endcode
  222. * \code .equ Heap_Size, 0x00000400 \endcode
  223. * Also, the stack size is defined in the linker script files: 'xx_yy.ld',
  224. * where 'xx' is the device family, and 'yy' is the target CPU; for example,
  225. * cy8c6xx7_cm0plus.ld and cy8c6xx7_cm4_dual.ld.
  226. * Change the stack size by modifying the following line:\n
  227. * \code STACK_SIZE = 0x1000; \endcode
  228. *
  229. * \note Correct operation of malloc and related functions depends on the working
  230. * implementation of the 'sbrk' function. Newlib-nano (default C runtime library
  231. * used by the GNU Arm Embedded toolchain) provides weak 'sbrk' implementation that
  232. * doesn't check for heap and stack collisions during excessive memory allocations.
  233. * To ensure the heap always remains within the range defined by __HeapBase and
  234. * __HeapLimit linker symbols, provide a strong override for the 'sbrk' function:
  235. * \snippet startup/snippet/main.c snippet_sbrk
  236. * For FreeRTOS-enabled multi-threaded applications, it is sufficient to include
  237. * clib-support library that provides newlib-compatible implementations of
  238. * 'sbrk', '__malloc_lock' and '__malloc_unlock':
  239. * <br>
  240. * https://github.com/Infineon/clib-support.
  241. *
  242. * \subsubsection group_system_config_heap_stack_config_mdk ARM Compiler
  243. * - <b>Editing source code files</b>\n
  244. * The stack size is defined in the linker script files: 'xx_yy.sct',
  245. * where 'xx' is the device family, and 'yy' is the target CPU; for example,
  246. * cy8c6xx7_cm0plus.sct and cy8c6xx7_cm4_dual.sct.
  247. * Change the stack size by modifying the following line:\n
  248. * \code STACK_SIZE = 0x1000; \endcode
  249. *
  250. * \subsubsection group_system_config_heap_stack_config_iar IAR
  251. * - <b>Editing source code files</b>\n
  252. * The heap and stack sizes are defined in the linker script files: 'xx_yy.icf',
  253. * where 'xx' is the device family, and 'yy' is the target CPU; for example,
  254. * cy8c6xx7_cm0plus.icf and cy8c6xx7_cm4_dual.icf.
  255. * Change the heap and stack sizes by modifying the following lines:\n
  256. * \code Stack_Size EQU 0x00001000 \endcode
  257. * \code Heap_Size EQU 0x00000400 \endcode
  258. *
  259. * - <b>Specifying via command line</b>\n
  260. * Change the heap and stack sizes passing the following commands to the
  261. * linker (including quotation marks):\n
  262. * \code --define_symbol __STACK_SIZE=0x000000400 \endcode
  263. * \code --define_symbol __HEAP_SIZE=0x000000100 \endcode
  264. *
  265. * \subsection group_system_config_default_handlers Default Interrupt Handlers Definition
  266. * The default interrupt handler functions are defined as weak functions to a dummy
  267. * handler in the startup file. The naming convention for the interrupt handler names
  268. * is \<interrupt_name\>_IRQHandler. A default interrupt handler can be overwritten in
  269. * user code by defining the handler function using the same name. For example:
  270. * \code
  271. * void scb_0_interrupt_IRQHandler(void)
  272. *{
  273. * ...
  274. *}
  275. * \endcode
  276. *
  277. * \subsection group_system_config_device_vector_table Vectors Table Copy from Flash to RAM
  278. * This process uses memory sections defined in the linker script. The startup
  279. * code actually defines the contents of the vector table and performs the copy.
  280. * \subsubsection group_system_config_device_vector_table_gcc ARM GCC
  281. * The linker script file is 'xx_yy.ld', where 'xx' is the device family, and
  282. * 'yy' is the target CPU; for example, cy8c6xx7_cm0plus.ld and cy8c6xx7_cm4_dual.ld.
  283. * It defines sections and locations in memory.\n
  284. * Copy interrupt vectors from flash to RAM: \n
  285. * From: \code LONG (__Vectors) \endcode
  286. * To: \code LONG (__ram_vectors_start__) \endcode
  287. * Size: \code LONG (__Vectors_End - __Vectors) \endcode
  288. * The vector table address (and the vector table itself) are defined in the
  289. * assembler startup files (e.g. startup_psoc6_01_cm0plus.S and startup_psoc6_01_cm4.S).
  290. * The code in these files copies the vector table from Flash to RAM.
  291. * \subsubsection group_system_config_device_vector_table_mdk ARM Compiler
  292. * The linker script file is 'xx_yy.sct', where 'xx' is the device family,
  293. * and 'yy' is the target CPU; for example, cy8c6xx7_cm0plus.sct and
  294. * cy8c6xx7_cm4_dual.sct. The linker script specifies that the vector table
  295. * (RESET_RAM) shall be first in the RAM section.\n
  296. * RESET_RAM represents the vector table. It is defined in the assembler startup
  297. * files (e.g. startup_psoc6_01_cm0plus.s and startup_psoc6_01_cm4.s).
  298. * The code in these files copies the vector table from Flash to RAM.
  299. *
  300. * \subsubsection group_system_config_device_vector_table_iar IAR
  301. * The linker script file is 'xx_yy.icf', where 'xx' is the device family, and
  302. * 'yy' is the target CPU; for example, cy8c6xx7_cm0plus.icf and cy8c6xx7_cm4_dual.icf.
  303. * This file defines the .intvec_ram section and its location.
  304. * \code place at start of IRAM1_region { readwrite section .intvec_ram}; \endcode
  305. * The vector table address (and the vector table itself) are defined in the
  306. * assembler startup files (e.g. startup_psoc6_01_cm0plus.s and startup_psoc6_01_cm4.s).
  307. * The code in these files copies the vector table from Flash to RAM.
  308. *
  309. * \section group_system_config_MISRA MISRA Compliance
  310. *
  311. * <table class="doxtable">
  312. * <tr>
  313. * <th>MISRA Rule</th>
  314. * <th>Rule Class (Required/Advisory)</th>
  315. * <th>Rule Description</th>
  316. * <th>Description of Deviation(s)</th>
  317. * </tr>
  318. * <tr>
  319. * <td>2.3</td>
  320. * <td>R</td>
  321. * <td>The character sequence // shall not be used within a comment.</td>
  322. * <td>The comments provide a useful WEB link to the documentation.</td>
  323. * </tr>
  324. * </table>
  325. *
  326. * \section group_system_config_changelog Changelog
  327. * <table class="doxtable">
  328. * <tr>
  329. * <th>Version</th>
  330. * <th>Changes</th>
  331. * <th>Reason for Change</th>
  332. * </tr>
  333. * <tr>
  334. * <td rowspan="1">2.95.1</td>
  335. * <td>Restructured documentation.</td>
  336. * <td>Documentation update.</td>
  337. * </tr>
  338. * <tr>
  339. * <td rowspan="1">2.95</td>
  340. * <td>Update FPU enable function with CMSIS macros to disable/enable interrupts</td>
  341. * <td>Move to stadnard inline CMSIS ARM macros</td>
  342. * </tr>
  343. * <tr>
  344. * <td rowspan="2">2.91</td>
  345. * <td>Updated memory configuration for PSoC 64 devices.</td>
  346. * <td>Flash and RAM memory allocation updated.</td>
  347. * </tr>
  348. * <tr>
  349. * <td>Added cys06xxa_cm4 linker scripts.</td>
  350. * <td>New device support.</td>
  351. * </tr>
  352. * <tr>
  353. * <td rowspan="4">2.90.1</td>
  354. * <td>Updated \ref group_system_config_heap_stack_config_gcc section with the note
  355. * on the dynamic memory allocation for ARM GCC.</td>
  356. * <td>Documentation update.</td>
  357. * </tr>
  358. * <tr>
  359. * <td>Updated system_psoc6.h to include custom CY_SYSTEM_PSOC6_CONFIG passed as compiler macro.</td>
  360. * <td>Improve configuration flexibility.</td>
  361. * </tr>
  362. * <tr>
  363. * <td>Updated attribute usage for the linker section placement in CM0+ startup code</td>
  364. * <td>Enhancement based on usability feedback.</td>
  365. * </tr>
  366. * <tr>
  367. * <td>Renamed the '.cy_xip' linker script region as 'cy_xip'</td>
  368. * <td>Enable access to the XIP region start/end addresses from the C code.</td>
  369. * </tr>
  370. * <tr>
  371. * <td>2.90</td>
  372. * <td>Updated linker scripts for PSoC 64 Secure MCU cyb06xx7 devices.</td>
  373. * <td>Flash allocation adjustment.</td>
  374. * </tr>
  375. * <tr>
  376. * <td rowspan="2">2.80</td>
  377. * <td>Updated linker scripts for PSoC 64 Secure MCU devices.</td>
  378. * <td>Updated FLASH and SRAM memory area definitions in cyb0xxx linker script templates
  379. * in accordance with the PSoC 64 Secure Boot SDK policies.</td>
  380. * </tr>
  381. * <tr>
  382. * <td>Added \ref Cy_PRA_Init() call to \ref SystemInit() Cortex-M0+ and Cortex-M4 functions for PSoC 64 Secure MCU.</td>
  383. * <td>Updated PSoC 64 Secure MCU startup sequence to initialize the Protected Register Access driver.</td>
  384. * </tr>
  385. * <tr>
  386. * <td>2.70.1</td>
  387. * <td>Updated documentation for the better description of the existing startup implementation.</td>
  388. * <td>User experience enhancement.</td>
  389. * </tr>
  390. * <tr>
  391. * <td rowspan="5">2.70</td>
  392. * <td>Updated \ref SystemCoreClockUpdate() implementation - The SysClk API is reused.</td>
  393. * <td>Code optimization.</td>
  394. * </tr>
  395. * <tr>
  396. * <td>Updated \ref SystemInit() implementation - The IPC7 structure is initialized for both cores.</td>
  397. * <td>Provided support for SysPM driver updates.</td>
  398. * </tr>
  399. * <tr>
  400. * <td>Updated the linker scripts.</td>
  401. * <td>Reserved FLASH area for the MCU boot headers.</td>
  402. * </tr>
  403. * <tr>
  404. * <td>Added System Pipe initialization for all devices. </td>
  405. * <td>Improved PDL usability according to user experience.</td>
  406. * </tr>
  407. * <tr>
  408. * <td>Removed redundant legacy macros: CY_CLK_EXT_FREQ_HZ, CY_CLK_ECO_FREQ_HZ and CY_CLK_ALTHF_FREQ_HZ.
  409. * Use \ref Cy_SysClk_ExtClkSetFrequency, \ref Cy_SysClk_EcoConfigure and \ref Cy_BLE_EcoConfigure functions instead them. </td>
  410. * <td>Defect fixing.</td>
  411. * </tr>
  412. * <tr>
  413. * <td>2.60</td>
  414. * <td>Updated linker scripts.</td>
  415. * <td>Provided support for new devices, updated usage of CM0p prebuilt image.</td>
  416. * </tr>
  417. * <tr>
  418. * <td>2.50</td>
  419. * <td>Updated assembler files, C files, linker scripts.</td>
  420. * <td>Dynamic allocated HEAP size for Arm Compiler 6, IAR 8.</td>
  421. * </tr>
  422. * <tr>
  423. * <td>2.40</td>
  424. * <td>Updated assembler files, C files, linker scripts.</td>
  425. * <td>Added Arm Compiler 6 support.</td>
  426. * </tr>
  427. * <tr>
  428. * <td rowspan="2">2.30</td>
  429. * <td>Added assembler files, linker scripts for Mbed OS.</td>
  430. * <td>Added Arm Mbed OS embedded operating system support.</td>
  431. * </tr>
  432. * <tr>
  433. * <td>Updated linker scripts to extend the Flash and Ram memories size available for the CM4 core.</td>
  434. * <td>Enhanced PDL usability.</td>
  435. * </tr>
  436. * <tr>
  437. * <td>2.20</td>
  438. * <td>Moved the Cy_IPC_SystemSemaInit(), Cy_IPC_SystemPipeInit() functions implementation from IPC to Startup.</td>
  439. * <td>Changed the IPC driver configuration method from compile time to run time.</td>
  440. * </tr>
  441. * <tr>
  442. * <td rowspan="2"> 2.10</td>
  443. * <td>Added constructor attribute to SystemInit() function declaration for ARM MDK compiler. \n
  444. * Removed $Sub$$main symbol for ARM MDK compiler.
  445. * </td>
  446. * <td>uVision Debugger support.</td>
  447. * </tr>
  448. * <tr>
  449. * <td>Updated description of the Startup behavior for Single-Core Devices. \n
  450. * Added note about WDT disabling by SystemInit() function.
  451. * </td>
  452. * <td>Documentation improvement.</td>
  453. * </tr>
  454. * <tr>
  455. * <td rowspan="4"> 2.0</td>
  456. * <td>Added restoring of FLL registers to the default state in SystemInit() API for single core devices.
  457. * Single core device support.
  458. * </td>
  459. * <td></td>
  460. * </tr>
  461. * <tr>
  462. * <td>Added Normal Access Restrictions, Public Key, TOC part2 and TOC part2 copy to Supervisory flash linker memory regions. \n
  463. * Renamed 'wflash' memory region to 'em_eeprom'.
  464. * </td>
  465. * <td>Linker scripts usability improvement.</td>
  466. * </tr>
  467. * <tr>
  468. * <td>Added Cy_IPC_SystemSemaInit(), Cy_IPC_SystemPipeInit(), Cy_Flash_Init() functions call to SystemInit() API.</td>
  469. * <td>Reserved system resources for internal operations.</td>
  470. * </tr>
  471. * <tr>
  472. * <td>Added clearing and releasing of IPC structure #7 (reserved for the Deep-Sleep operations) to SystemInit() API.</td>
  473. * <td>To avoid deadlocks in case of SW or WDT reset during Deep-Sleep entering.</td>
  474. * </tr>
  475. * <tr>
  476. * <td>1.0</td>
  477. * <td>Initial version</td>
  478. * <td></td>
  479. * </tr>
  480. * </table>
  481. *
  482. *
  483. * \defgroup group_system_config_macro Macros
  484. * \{
  485. * \defgroup group_system_config_system_macro System Macros
  486. * \defgroup group_system_config_cm4_status_macro Cortex-M4 Status Macros
  487. * \defgroup group_system_config_user_settings_macro User Settings Macros
  488. * \}
  489. * \defgroup group_system_config_functions Functions
  490. * \{
  491. * \defgroup group_system_config_cm4_functions Cortex-M4 Control Functions
  492. * \}
  493. * \defgroup group_system_config_globals Global Variables
  494. *
  495. * \}
  496. */
  497. #ifdef __cplusplus
  498. extern "C" {
  499. #endif
  500. /*******************************************************************************
  501. * Include files
  502. *******************************************************************************/
  503. #include <stdint.h>
  504. /*******************************************************************************
  505. * Global preprocessor symbols/macros ('define')
  506. *******************************************************************************/
  507. #if ((defined(__GNUC__) && (__ARM_ARCH == 6) && (__ARM_ARCH_6M__ == 1)) || \
  508. (defined (__ICCARM__) && (__CORE__ == __ARM6M__)) || \
  509. (defined(__ARMCC_VERSION) && (__TARGET_ARCH_THUMB == 3)))
  510. #define CY_SYSTEM_CPU_CM0P 1UL
  511. #else
  512. #define CY_SYSTEM_CPU_CM0P 0UL
  513. #endif
  514. /*******************************************************************************
  515. *
  516. * START OF USER SETTINGS HERE
  517. * ===========================
  518. *
  519. * All lines with '<<<' can be set by user.
  520. *
  521. *******************************************************************************/
  522. /**
  523. * \addtogroup group_system_config_user_settings_macro
  524. * \{
  525. */
  526. /*
  527. * Include optional application-specific configuration header.
  528. *
  529. * For example, custom system_psoc6_config.h can be included here
  530. * by adding the below macro definition to the build system:
  531. * DEFINES+=CY_SYSTEM_PSOC6_CONFIG='"system_psoc6_config.h"'
  532. */
  533. #if defined(CY_SYSTEM_PSOC6_CONFIG)
  534. #include CY_SYSTEM_PSOC6_CONFIG
  535. #endif
  536. /***************************************************************************//**
  537. * \brief Start address of the Cortex-M4 application ([address]UL)
  538. * <i>(USER SETTING)</i>
  539. *******************************************************************************/
  540. #if !defined (CY_CORTEX_M4_APPL_ADDR)
  541. #define CY_CORTEX_M4_APPL_ADDR (CY_FLASH_BASE + 0x2000U) /* <<< 8 kB of flash is reserved for the Cortex-M0+ application */
  542. #endif /* (CY_CORTEX_M4_APPL_ADDR) */
  543. /***************************************************************************//**
  544. * \brief IPC Semaphores allocation ([value]UL).
  545. * <i>(USER SETTING)</i>
  546. *******************************************************************************/
  547. #define CY_IPC_SEMA_COUNT (128UL) /* <<< This will allow 128 (4*32) semaphores */
  548. /***************************************************************************//**
  549. * \brief IPC Pipe definitions ([value]UL).
  550. * <i>(USER SETTING)</i>
  551. *******************************************************************************/
  552. #define CY_IPC_MAX_ENDPOINTS (8UL) /* <<< 8 endpoints */
  553. /*******************************************************************************
  554. *
  555. * END OF USER SETTINGS HERE
  556. * =========================
  557. *
  558. *******************************************************************************/
  559. /** \} group_system_config_user_settings_macro */
  560. /**
  561. * \addtogroup group_system_config_system_macro
  562. * \{
  563. */
  564. #if (CY_SYSTEM_CPU_CM0P == 1UL) || defined(CY_DOXYGEN)
  565. /** The Cortex-M0+ startup driver identifier */
  566. #define CY_STARTUP_M0P_ID ((uint32_t)((uint32_t)((0x0EU) & 0x3FFFU) << 18U))
  567. #endif /* (CY_SYSTEM_CPU_CM0P == 1UL) */
  568. #if (CY_SYSTEM_CPU_CM0P != 1UL) || defined(CY_DOXYGEN)
  569. /** The Cortex-M4 startup driver identifier */
  570. #define CY_STARTUP_M4_ID ((uint32_t)((uint32_t)((0x0FU) & 0x3FFFU) << 18U))
  571. #endif /* (CY_SYSTEM_CPU_CM0P != 1UL) */
  572. /** \} group_system_config_system_macro */
  573. /** \cond */
  574. #if defined(__ARMCC_VERSION)
  575. extern void SystemInit(void) __attribute__((constructor));
  576. #else
  577. extern void SystemInit(void);
  578. #endif /* (__ARMCC_VERSION) */
  579. extern void SystemCoreClockUpdate(void);
  580. /** \endcond */
  581. /**
  582. * \addtogroup group_system_config_cm4_functions
  583. * \{
  584. */
  585. extern uint32_t Cy_SysGetCM4Status(void);
  586. extern void Cy_SysEnableCM4(uint32_t vectorTableOffset);
  587. extern void Cy_SysDisableCM4(void);
  588. extern void Cy_SysRetainCM4(void);
  589. extern void Cy_SysResetCM4(void);
  590. /** \} group_system_config_cm4_functions */
  591. /** \cond */
  592. extern void Default_Handler (void);
  593. void Cy_SysIpcPipeIsrCm0(void);
  594. void Cy_SysIpcPipeIsrCm4(void);
  595. extern void Cy_SystemInit(void);
  596. extern void Cy_SystemInitFpuEnable(void);
  597. extern uint32_t cy_delayFreqKhz;
  598. extern uint8_t cy_delayFreqMhz;
  599. /** \endcond */
  600. #if (CY_SYSTEM_CPU_CM0P == 1UL) || defined(CY_DOXYGEN)
  601. /**
  602. * \addtogroup group_system_config_cm4_status_macro
  603. * \{
  604. */
  605. #define CY_SYS_CM4_STATUS_ENABLED (3U) /**< The Cortex-M4 core is enabled: power on, clock on, no isolate, no reset and no retain. */
  606. #define CY_SYS_CM4_STATUS_DISABLED (0U) /**< The Cortex-M4 core is disabled: power off, clock off, isolate, reset and no retain. */
  607. #define CY_SYS_CM4_STATUS_RETAINED (2U) /**< The Cortex-M4 core is retained. power off, clock off, isolate, no reset and retain. */
  608. #define CY_SYS_CM4_STATUS_RESET (1U) /**< The Cortex-M4 core is in the Reset mode: clock off, no isolated, no retain and reset. */
  609. /** \} group_system_config_cm4_status_macro */
  610. #endif /* (CY_SYSTEM_CPU_CM0P == 1UL) */
  611. /*******************************************************************************
  612. * IPC Configuration
  613. * =========================
  614. *******************************************************************************/
  615. /* IPC CY_PIPE default configuration */
  616. #define CY_SYS_CYPIPE_CLIENT_CNT (8UL)
  617. #define CY_SYS_INTR_CYPIPE_MUX_EP0 (1UL) /* IPC CYPRESS PIPE */
  618. #define CY_SYS_INTR_CYPIPE_PRIOR_EP0 (1UL) /* Notifier Priority */
  619. #define CY_SYS_INTR_CYPIPE_PRIOR_EP1 (1UL) /* Notifier Priority */
  620. #define CY_SYS_CYPIPE_CHAN_MASK_EP0 (0x0001UL << CY_IPC_CHAN_CYPIPE_EP0)
  621. #define CY_SYS_CYPIPE_CHAN_MASK_EP1 (0x0001UL << CY_IPC_CHAN_CYPIPE_EP1)
  622. /******************************************************************************/
  623. /*
  624. * The System pipe configuration defines the IPC channel number, interrupt
  625. * number, and the pipe interrupt mask for the endpoint.
  626. *
  627. * The format of the endPoint configuration
  628. * Bits[31:16] Interrupt Mask
  629. * Bits[15:8 ] IPC interrupt
  630. * Bits[ 7:0 ] IPC channel
  631. */
  632. /* System Pipe addresses */
  633. /* CyPipe defines */
  634. #define CY_SYS_CYPIPE_INTR_MASK ( CY_SYS_CYPIPE_CHAN_MASK_EP0 | CY_SYS_CYPIPE_CHAN_MASK_EP1 )
  635. #define CY_SYS_CYPIPE_CONFIG_EP0 ( (CY_SYS_CYPIPE_INTR_MASK << CY_IPC_PIPE_CFG_IMASK_Pos) \
  636. | (CY_IPC_INTR_CYPIPE_EP0 << CY_IPC_PIPE_CFG_INTR_Pos) \
  637. | CY_IPC_CHAN_CYPIPE_EP0)
  638. #define CY_SYS_CYPIPE_CONFIG_EP1 ( (CY_SYS_CYPIPE_INTR_MASK << CY_IPC_PIPE_CFG_IMASK_Pos) \
  639. | (CY_IPC_INTR_CYPIPE_EP1 << CY_IPC_PIPE_CFG_INTR_Pos) \
  640. | CY_IPC_CHAN_CYPIPE_EP1)
  641. /******************************************************************************/
  642. /** \addtogroup group_system_config_globals
  643. * \{
  644. */
  645. extern uint32_t cy_BleEcoClockFreqHz;
  646. /** \} group_system_config_globals */
  647. /** \cond INTERNAL */
  648. extern uint32_t cy_Hfclk0FreqHz;
  649. extern uint32_t cy_PeriClkFreqHz;
  650. extern uint32_t SystemCoreClock;
  651. extern uint32_t cy_AhbFreqHz;
  652. /*******************************************************************************
  653. * Backward compatibility macros. The following code is DEPRECATED and must
  654. * not be used in new projects
  655. *******************************************************************************/
  656. /* BWC defines for functions related to enter/exit critical section */
  657. #define Cy_SaveIRQ Cy_SysLib_EnterCriticalSection
  658. #define Cy_RestoreIRQ Cy_SysLib_ExitCriticalSection
  659. #define CY_SYS_INTR_CYPIPE_EP0 (CY_IPC_INTR_CYPIPE_EP0)
  660. #define CY_SYS_INTR_CYPIPE_EP1 (CY_IPC_INTR_CYPIPE_EP1)
  661. #define cy_delayFreqHz (SystemCoreClock)
  662. /** \endcond */
  663. #ifdef __cplusplus
  664. }
  665. #endif
  666. #endif /* _SYSTEM_PSOC6_H_ */
  667. /* [] END OF FILE */