17
17
#include "fsl_clock_config.h"
18
18
#include "fsl_clock.h"
19
19
#include "fsl_xbara.h"
20
+ #include "fsl_iomuxc.h"
21
+ #include "fsl_gpio.h"
20
22
#include "lpm.h"
21
23
22
24
#define LPSPI_CLOCK_SOURCE_DIVIDER (7U)
@@ -40,10 +42,10 @@ void BOARD_ConfigMPU(void)
40
42
41
43
/* MPU configure:
42
44
* Use ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, SubRegionDisable, Size)
43
- * API in core_cm7 .h.
45
+ * API in mpu_armv7 .h.
44
46
* param DisableExec Instruction access (XN) disable bit,0=instruction fetches enabled, 1=instruction fetches disabled.
45
47
* param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode.
46
- * Use MACROS defined in core_cm7 .h: ARM_MPU_AP_NONE/ARM_MPU_AP_PRIV/ARM_MPU_AP_URO/ARM_MPU_AP_FULL/ARM_MPU_AP_PRO/ARM_MPU_AP_RO
48
+ * Use MACROS defined in mpu_armv7 .h: ARM_MPU_AP_NONE/ARM_MPU_AP_PRIV/ARM_MPU_AP_URO/ARM_MPU_AP_FULL/ARM_MPU_AP_PRO/ARM_MPU_AP_RO
47
49
* Combine TypeExtField/IsShareable/IsCacheable/IsBufferable to configure MPU memory access attributes.
48
50
* TypeExtField IsShareable IsCacheable IsBufferable Memory Attribtue Shareability Cache
49
51
* 0 x 0 0 Strongly Ordered shareable
@@ -60,26 +62,22 @@ void BOARD_ConfigMPU(void)
60
62
* Above are normal use settings, if your want to see more details or want to config different inner/outter cache policy.
61
63
* please refer to Table 4-55 /4-56 in arm cortex-M7 generic user guide <dui0646b_cortex_m7_dgug.pdf>
62
64
* param SubRegionDisable Sub-region disable field. 0=sub-region is enabled, 1=sub-region is disabled.
63
- * param Size Region size of the region to be configured. use ARM_MPU_REGION_SIZE_xxx MACRO in core_cm7 .h.
65
+ * param Size Region size of the region to be configured. use ARM_MPU_REGION_SIZE_xxx MACRO in mpu_armv7 .h.
64
66
*/
65
67
66
68
/* Region 0 setting: Memory with Device type, not shareable, non-cacheable. */
67
- MPU -> RBAR = ARM_MPU_RBAR (0 , 0xC0000000U );
69
+ MPU -> RBAR = ARM_MPU_RBAR (0 , 0x80000000U );
68
70
MPU -> RASR = ARM_MPU_RASR (0 , ARM_MPU_AP_FULL , 2 , 0 , 0 , 0 , 0 , ARM_MPU_REGION_SIZE_512MB );
69
71
70
72
/* Region 1 setting: Memory with Device type, not shareable, non-cacheable. */
71
- MPU -> RBAR = ARM_MPU_RBAR (1 , 0x80000000U );
72
- MPU -> RASR = ARM_MPU_RASR (0 , ARM_MPU_AP_FULL , 2 , 0 , 0 , 0 , 0 , ARM_MPU_REGION_SIZE_1GB );
73
+ MPU -> RBAR = ARM_MPU_RBAR (1 , 0x60000000U );
74
+ MPU -> RASR = ARM_MPU_RASR (0 , ARM_MPU_AP_FULL , 2 , 0 , 0 , 0 , 0 , ARM_MPU_REGION_SIZE_512MB );
73
75
74
- /* Region 2 setting */
76
+ /* Region 2 setting */
75
77
#if defined(XIP_EXTERNAL_FLASH ) && (XIP_EXTERNAL_FLASH == 1 )
76
78
/* Setting Memory with Normal type, not shareable, outer/inner write back. */
77
79
MPU -> RBAR = ARM_MPU_RBAR (2 , 0x60000000U );
78
- MPU -> RASR = ARM_MPU_RASR (0 , ARM_MPU_AP_FULL , 0 , 0 , 1 , 1 , 0 , ARM_MPU_REGION_SIZE_512MB );
79
- #else
80
- /* Setting Memory with Device type, not shareable, non-cacheable. */
81
- MPU -> RBAR = ARM_MPU_RBAR (2 , 0x60000000U );
82
- MPU -> RASR = ARM_MPU_RASR (0 , ARM_MPU_AP_FULL , 2 , 0 , 0 , 0 , 0 , ARM_MPU_REGION_SIZE_512MB );
80
+ MPU -> RASR = ARM_MPU_RASR (0 , ARM_MPU_AP_RO , 0 , 0 , 1 , 1 , 0 , ARM_MPU_REGION_SIZE_64MB );
83
81
#endif
84
82
85
83
/* Region 3 setting: Memory with Device type, not shareable, non-cacheable. */
@@ -98,9 +96,9 @@ void BOARD_ConfigMPU(void)
98
96
MPU -> RBAR = ARM_MPU_RBAR (6 , 0x20200000U );
99
97
MPU -> RASR = ARM_MPU_RASR (0 , ARM_MPU_AP_FULL , 0 , 0 , 1 , 1 , 0 , ARM_MPU_REGION_SIZE_256KB );
100
98
101
- /* The define sets the cacheable memory to shareable,
102
- * this suggestion is referred from chapter 2.2.1 Memory regions,
103
- * types and attributes in Cortex-M7 Devices, Generic User Guide */
99
+ /* The define sets the cacheable memory to shareable,
100
+ * this suggestion is referred from chapter 2.2.1 Memory regions,
101
+ * types and attributes in Cortex-M7 Devices, Generic User Guide */
104
102
#if defined(SDRAM_IS_SHAREABLE )
105
103
/* Region 7 setting: Memory with Normal type, shareable, outer/inner write back, write/read allocate */
106
104
MPU -> RBAR = ARM_MPU_RBAR (7 , 0x80000000U );
@@ -125,38 +123,44 @@ void BOARD_ConfigMPU(void)
125
123
SCB_EnableICache ();
126
124
}
127
125
128
- #if defined(TOOLCHAIN_GCC_ARM )
129
- extern uint32_t __ram_function_flash_start [];
130
- #define __RAM_FUNCTION_FLASH_START __ram_function_flash_start
131
- extern uint32_t __ram_function_ram_start [];
132
- #define __RAM_FUNCTION_RAM_START __ram_function_ram_start
133
- extern uint32_t __ram_function_size [];
134
- #define __RAM_FUNCTION_SIZE __ram_function_size
135
- void Board_CopyToRam ()
136
- {
137
- unsigned char * source ;
138
- unsigned char * destiny ;
139
- unsigned int size ;
140
-
141
- source = (unsigned char * )(__RAM_FUNCTION_FLASH_START );
142
- destiny = (unsigned char * )(__RAM_FUNCTION_RAM_START );
143
- size = (unsigned long )(__RAM_FUNCTION_SIZE );
144
-
145
- while (size -- )
146
- {
147
- * destiny ++ = * source ++ ;
148
- }
126
+ void BOARD_Init_PMIC_STBY_REQ (void ) {
127
+ CLOCK_EnableClock (kCLOCK_IomuxcSnvs ); /* iomuxc_snvs clock (iomuxc_snvs_clk_enable): 0x03U */
128
+
129
+ /* GPIO configuration of PERI_PWREN on PMIC_STBY_REQ (pin L7) */
130
+ gpio_pin_config_t PERI_PWREN_config = {
131
+ .direction = kGPIO_DigitalOutput ,
132
+ .outputLogic = 0U ,
133
+ .interruptMode = kGPIO_NoIntmode
134
+ };
135
+ /* Initialize GPIO functionality on PMIC_STBY_REQ (pin L7) */
136
+ GPIO_PinInit (GPIO5 , 2U , & PERI_PWREN_config );
137
+
138
+ IOMUXC_SetPinMux (
139
+ IOMUXC_SNVS_PMIC_STBY_REQ_GPIO5_IO02 , /* PMIC_STBY_REQ is configured as GPIO5_IO02 */
140
+ 0U ); /* Software Input On Field: Input Path is determined by functionality */
141
+ IOMUXC_SetPinConfig (
142
+ IOMUXC_SNVS_PMIC_STBY_REQ_GPIO5_IO02 , /* PMIC_STBY_REQ PAD functional properties : */
143
+ 0x10B0U ); /* Slew Rate Field: Slow Slew Rate
144
+ Drive Strength Field: R0/6
145
+ Speed Field: medium(100MHz)
146
+ Open Drain Enable Field: Open Drain Disabled
147
+ Pull / Keep Enable Field: Pull/Keeper Enabled
148
+ Pull / Keep Select Field: Keeper
149
+ Pull Up / Down Config. Field: 100K Ohm Pull Down
150
+ Hyst. Enable Field: Hysteresis Disabled */
149
151
}
150
- #endif
151
152
152
153
// called before main
153
154
void mbed_sdk_init ()
154
155
{
155
156
BOARD_ConfigMPU ();
156
157
BOARD_BootClockRUN ();
157
- #if defined(TOOLCHAIN_GCC_ARM )
158
- Board_CopyToRam ();
159
- #endif
158
+
159
+ /* Since SNVS_PMIC_STBY_REQ_GPIO5_IO02 will output a high-level signal under Stop Mode(Suspend Mode) and this pin is
160
+ * connected to LCD power switch circuit. So it needs to be configured as a low-level output GPIO to reduce the
161
+ * current. */
162
+ BOARD_Init_PMIC_STBY_REQ ();
163
+
160
164
LPM_Init ();
161
165
}
162
166
@@ -187,16 +191,15 @@ uint32_t us_ticker_get_clock()
187
191
188
192
void serial_setup_clock (void )
189
193
{
190
- /* We assume default PLL and divider settings */
194
+ /* Configure UART divider to default */
195
+ CLOCK_SetMux (kCLOCK_UartMux , 1 ); /* Set UART source to OSC 24M */
196
+ CLOCK_SetDiv (kCLOCK_UartDiv , 0 ); /* Set UART divider to 1 */
191
197
}
192
198
193
199
uint32_t serial_get_clock (void )
194
200
{
195
201
uint32_t clock_freq ;
196
202
197
- /* We assume default PLL and divider settings, and the only variable
198
- * from application is use PLL3 source or OSC source
199
- */
200
203
if (CLOCK_GetMux (kCLOCK_UartMux ) == 0 ) /* PLL3 div6 80M */ {
201
204
clock_freq = (CLOCK_GetPllFreq (kCLOCK_PllUsb1 ) / 6U ) / (CLOCK_GetDiv (kCLOCK_UartDiv ) + 1U );
202
205
} else {
0 commit comments