]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/startup/boot_multicore_slave.c
a52514f4fd9a74570d20cc8946ec3956f8bb3b3e
[freertos] / FreeRTOS / Demo / CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso / NXP_Code / startup / boot_multicore_slave.c
1 //*****************************************************************************\r
2 // boot_multicore_slave.c\r
3 //\r
4 // Provides functions to boot slave core in LPC55xx multicore system\r
5 //\r
6 // Version : 190215\r
7 //\r
8 //*****************************************************************************\r
9 //\r
10 // Copyright(C) NXP Semiconductors, 2019\r
11 // All rights reserved.\r
12 //\r
13 // Software that is described herein is for illustrative purposes only\r
14 // which provides customers with programming information regarding the\r
15 // LPC products.  This software is supplied "AS IS" without any warranties of\r
16 // any kind, and NXP Semiconductors and its licensor disclaim any and\r
17 // all warranties, express or implied, including all implied warranties of\r
18 // merchantability, fitness for a particular purpose and non-infringement of\r
19 // intellectual property rights.  NXP Semiconductors assumes no responsibility\r
20 // or liability for the use of the software, conveys no license or rights under any\r
21 // patent, copyright, mask work right, or any other intellectual property rights in\r
22 // or to any products. NXP Semiconductors reserves the right to make changes\r
23 // in the software without notification. NXP Semiconductors also makes no\r
24 // representation or warranty that such application will be suitable for the\r
25 // specified use without further testing or modification.\r
26 //\r
27 // Permission to use, copy, modify, and distribute this software and its\r
28 // documentation is hereby granted, under NXP Semiconductors' and its\r
29 // licensor's relevant copyrights in the software, without fee, provided that it\r
30 // is used in conjunction with NXP Semiconductors microcontrollers.  This\r
31 // copyright, permission, and disclaimer notice must appear in all copies of\r
32 // this code.\r
33 //*****************************************************************************\r
34 \r
35 #if defined (__MULTICORE_MASTER)\r
36 \r
37 #include <stdint.h>\r
38 \r
39 // ==================================================================\r
40 // Define registers related to multicore CPU Control and setup\r
41 // ==================================================================\r
42 #define SYSCON_BASE                               ((uint32_t) 0x50000000)\r
43 #define CPUCTRL                   (((volatile uint32_t *) (SYSCON_BASE + 0x800)))\r
44 #define CPBOOT                                    (((volatile uint32_t *) (SYSCON_BASE + 0x804)))\r
45 #define CPSTACK                                   (((volatile uint32_t *) (SYSCON_BASE + 0x808)))\r
46 #define CPSTAT                                    (((volatile uint32_t *) (SYSCON_BASE + 0x80C)))\r
47 #define CPUCTRL_KEY               ((uint32_t)(0x0000C0C4 << 16))\r
48 #define CORE1_CLK_ENA             (1<<3)\r
49 #define CORE1_RESET_ENA           (1<<5)\r
50 \r
51 \r
52 // ==================================================================\r
53 // Function to boot the slave (core 1)\r
54 // ==================================================================\r
55 void slave_core1_boot(uint32_t *coentry, uint32_t *costackptr) {\r
56 \r
57         volatile uint32_t *u32REG, u32Val;\r
58 \r
59     // Load the slave's stack pointer value\r
60         *CPSTACK = (uint32_t) costackptr;\r
61         // Load address of the slave code in memory (for slave's VTOR)\r
62         *CPBOOT =  (uint32_t) coentry;\r
63 \r
64         // Read CPU control register and update to start slave execution\r
65     u32REG = (uint32_t *) CPUCTRL;\r
66     u32Val = *u32REG;\r
67     // Enable slave clock and reset\r
68     u32Val |= (CPUCTRL_KEY | ((CORE1_CLK_ENA | CORE1_RESET_ENA) & 0x7F));\r
69     *u32REG = u32Val;\r
70     // Clear slave reset\r
71     u32Val &= ~CORE1_RESET_ENA;\r
72     *u32REG = u32Val;\r
73     // Slave is now executing\r
74 }\r
75 \r
76 // ==================================================================\r
77 // Address of slave code in memory - provided by linker script\r
78 extern uint8_t __core_m33slave_START__;\r
79 // ==================================================================\r
80 \r
81 // ==================================================================\r
82 // Top level function to boot the slave core\r
83 // ==================================================================\r
84 void boot_multicore_slave(void) {\r
85 \r
86         // Get the address of the slave code in memory\r
87         uint32_t *slavevectortable_ptr = (uint32_t *)&__core_m33slave_START__;\r
88 \r
89     // Get initial address for slave's stack pointer\r
90     volatile  unsigned int spaddr;\r
91     spaddr = *slavevectortable_ptr;\r
92 \r
93     // Boot the slave - passing address of code and stack pointer\r
94     slave_core1_boot(slavevectortable_ptr, (uint32_t *)spaddr);\r
95 \r
96 }\r
97 #endif //defined (__MULTICORE_MASTER)\r