@@ -51,8 +51,9 @@ void SystemClock_Config(void)
5151 __HAL_PWR_VOLTAGESCALING_CONFIG (PWR_REGULATOR_VOLTAGE_SCALE1 );
5252
5353 /* Enable HSE Oscillator and activate PLL with HSE as source */
54- RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_HSE ;
54+ RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_LSI ;
5555 RCC_OscInitStruct .HSEState = RCC_HSE_ON ;
56+ RCC_OscInitStruct .LSIState = RCC_LSI_ON ;
5657 RCC_OscInitStruct .PLL .PLLState = RCC_PLL_ON ;
5758 RCC_OscInitStruct .PLL .PLLSource = RCC_PLLSOURCE_HSE ;
5859 RCC_OscInitStruct .PLL .PLLM = 8 ;
@@ -81,6 +82,99 @@ void SystemClock_Config(void)
8182}
8283#endif
8384
85+ /**
86+ * @brief This function is executed in case of error occurrence.
87+ * @param None
88+ * @retval None
89+ */
90+ void Error_Handler (void ) {
91+ while (1 ) {
92+ /* Infinite loop */
93+ };
94+ }
95+
96+ /*
97+ * @brief Configure all GPIO as analog to reduce current consumption on non used IOs
98+ */
99+ void ms_bsp_gpios_reset (void )
100+ {
101+ GPIO_InitTypeDef GPIO_InitStruct ;
102+
103+ /* Configure all GPIO as analog to reduce current consumption on non used IOs */
104+ /* Enable GPIOs clock */
105+ __HAL_RCC_GPIOA_CLK_ENABLE ();
106+ __HAL_RCC_GPIOB_CLK_ENABLE ();
107+ __HAL_RCC_GPIOC_CLK_ENABLE ();
108+ __HAL_RCC_GPIOD_CLK_ENABLE ();
109+ __HAL_RCC_GPIOH_CLK_ENABLE ();
110+
111+ GPIO_InitStruct .Mode = GPIO_MODE_ANALOG ;
112+ GPIO_InitStruct .Speed = GPIO_SPEED_HIGH ;
113+ GPIO_InitStruct .Pull = GPIO_NOPULL ;
114+ GPIO_InitStruct .Pin = GPIO_PIN_All ;
115+
116+ //HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
117+ HAL_GPIO_Init (GPIOB , & GPIO_InitStruct );
118+ HAL_GPIO_Init (GPIOC , & GPIO_InitStruct );
119+ HAL_GPIO_Init (GPIOD , & GPIO_InitStruct );
120+ //HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
121+
122+ /* Disable GPIOs clock */
123+ __HAL_RCC_GPIOA_CLK_DISABLE ();
124+ __HAL_RCC_GPIOB_CLK_DISABLE ();
125+ __HAL_RCC_GPIOC_CLK_DISABLE ();
126+ __HAL_RCC_GPIOD_CLK_DISABLE ();
127+ __HAL_RCC_GPIOH_CLK_DISABLE ();
128+ }
129+
130+ /**
131+ * @brief Configures system clock after wake-up from STOP: enable HSI, PLL
132+ * and select PLL as system clock source.
133+ * @param None
134+ * @retval None
135+ */
136+ void SYSCLKConfig_STOP (void )
137+ {
138+ RCC_ClkInitTypeDef RCC_ClkInitStruct ;
139+ RCC_OscInitTypeDef RCC_OscInitStruct ;
140+ uint32_t pFLatency = 0 ;
141+
142+ /* Get the Oscillators configuration according to the internal RCC registers */
143+ HAL_RCC_GetOscConfig (& RCC_OscInitStruct );
144+
145+ /* After wake-up from STOP reconfigure the system clock: Enable HSI and PLL */
146+ RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_HSI ;
147+ RCC_OscInitStruct .HSIState = RCC_HSI_ON ;
148+ RCC_OscInitStruct .HSICalibrationValue = (uint32_t )0x10 ; /* Default HSI calibration trimming value */ ;
149+ RCC_OscInitStruct .PLL .PLLState = RCC_PLL_ON ;
150+ RCC_OscInitStruct .PLL .PLLSource = RCC_PLLSOURCE_HSI ;
151+ RCC_OscInitStruct .PLL .PLLM = 16 ;
152+ RCC_OscInitStruct .PLL .PLLN = 160 ;
153+ RCC_OscInitStruct .PLL .PLLP = RCC_PLLP_DIV2 ;
154+ RCC_OscInitStruct .PLL .PLLQ = 7 ;
155+ RCC_OscInitStruct .PLL .PLLR = 2 ;
156+ if (HAL_RCC_OscConfig (& RCC_OscInitStruct ) != HAL_OK )
157+ {
158+ /* Initialization Error */
159+ Error_Handler ();
160+ }
161+
162+ /* Get the Clocks configuration according to the internal RCC registers */
163+ HAL_RCC_GetClockConfig (& RCC_ClkInitStruct , & pFLatency );
164+
165+ /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
166+ clocks dividers */
167+ RCC_ClkInitStruct .ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2 );
168+ RCC_ClkInitStruct .SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK ;
169+ RCC_ClkInitStruct .AHBCLKDivider = RCC_SYSCLK_DIV1 ;
170+ RCC_ClkInitStruct .APB1CLKDivider = RCC_HCLK_DIV2 ;
171+ RCC_ClkInitStruct .APB2CLKDivider = RCC_HCLK_DIV1 ;
172+ if (HAL_RCC_ClockConfig (& RCC_ClkInitStruct , pFLatency ) != HAL_OK )
173+ {
174+ Error_Handler ();
175+ }
176+ }
177+
84178/**
85179 * @brief Initial printk interface.
86180 *
@@ -153,6 +247,7 @@ void ms_bsp_shutdown(void)
153247#if (MS_CFG_SHELL_MODULE_EN > 0 ) && (BSP_CFG_CONSOLE_DEV != BSP_CONSOLE_NULL )
154248/**
155249 * @brief Shell thread.
250+ * @note Tick-less mode is useless while using 'BSP_CONSOLE_TRACE' as 'BSP_CFG_CONSOLE_DEV'
156251 *
157252 * @param[in] arg Shell thread argument
158253 *
@@ -228,8 +323,9 @@ static void ms_esp_at_net_init_done(ms_ptr_t arg)
228323#endif
229324#endif
230325}
326+ #endif
231327
232- #if MS_CFG_SHELL_MODULE_EN > 0
328+ #if MS_CFG_SHELL_MODULE_EN > 0 && BSP_CFG_ESP8266_EN > 0
233329/**
234330 * @brief smartcfg command.
235331 *
@@ -248,7 +344,6 @@ static void __ms_shell_esp8266_smartcfg(int argc, char *argv[], const ms_shell_i
248344
249345MS_SHELL_CMD (smartcfg , __ms_shell_esp8266_smartcfg , "ESP8266 smart configure" , __ms_shell_cmd_smartcfg );
250346#endif
251- #endif
252347
253348/**
254349 * @brief Boot thread.
@@ -321,7 +416,7 @@ static void boot_thread(ms_ptr_t arg)
321416 ms_apps_start ("ms-boot-param.dtb" );
322417#endif
323418
324- ms_process_create ("iotpi_sddc" , 0x08040000 , 65536 , 4096 , 9 , 0 , 0 , MS_NULL , MS_NULL , MS_NULL );
419+ ms_process_create ("iotpi_sddc" , ( ms_addr_t ) 0x08040000 , 65536 , 4096 , 9 , 0 , 0 , MS_NULL , MS_NULL , MS_NULL );
325420}
326421
327422#if BSP_CFG_HW_TEST_EN > 0
@@ -684,73 +779,6 @@ void bsp_init(void)
684779 while (MS_TRUE ) {
685780 }
686781}
687-
688- #if BSP_CFG_I2C_EN > 0
689-
690- /**
691- * @brief I2C MSP Initialization
692- * This function configures the hardware resources used in this example:
693- * - Peripheral's clock enable
694- * - Peripheral's GPIO Configuration
695- * - DMA configuration for transmission request by peripheral
696- * - NVIC configuration for DMA interrupt request enable
697- * @param hi2c: I2C handle pointer
698- * @retval None
699- */
700- void HAL_I2C_MspInit (I2C_HandleTypeDef * hi2c )
701- {
702- GPIO_InitTypeDef GPIO_InitStruct ;
703-
704- if (hi2c -> Instance == I2C3 ) {
705- /* Enable GPIO TX/RX clock */
706- __HAL_RCC_GPIOA_CLK_ENABLE ();
707- __HAL_RCC_GPIOB_CLK_ENABLE ();
708-
709- /* Enable I2C3 clock */
710- __HAL_RCC_I2C3_CLK_ENABLE ();
711-
712- /* I2C TX GPIO pin configuration */
713- GPIO_InitStruct .Pin = GPIO_PIN_8 ;
714- GPIO_InitStruct .Mode = GPIO_MODE_AF_OD ;
715- GPIO_InitStruct .Pull = GPIO_PULLUP ;
716- GPIO_InitStruct .Speed = GPIO_SPEED_FAST ;
717- GPIO_InitStruct .Alternate = GPIO_AF4_I2C3 ;
718-
719- HAL_GPIO_Init (GPIOA , & GPIO_InitStruct );
720-
721- /* I2C TX GPIO pin configuration */
722- GPIO_InitStruct .Pin = GPIO_PIN_4 ;
723- GPIO_InitStruct .Mode = GPIO_MODE_AF_OD ;
724- GPIO_InitStruct .Pull = GPIO_PULLUP ;
725- GPIO_InitStruct .Speed = GPIO_SPEED_FAST ;
726- GPIO_InitStruct .Alternate = GPIO_AF9_I2C3 ;
727-
728- HAL_GPIO_Init (GPIOB , & GPIO_InitStruct );
729- }
730- }
731-
732- /**
733- * @brief I2C MSP De-Initialization
734- * This function frees the hardware resources used in this example:
735- * - Disable the Peripheral's clock
736- * - Revert GPIO, DMA and NVIC configuration to their default state
737- * @param hi2c: I2C handle pointer
738- * @retval None
739- */
740- void HAL_I2C_MspDeInit (I2C_HandleTypeDef * hi2c )
741- {
742- if (hi2c -> Instance == I2C3 ) {
743- __HAL_RCC_I2C3_FORCE_RESET ();
744- __HAL_RCC_I2C3_RELEASE_RESET ();
745-
746- /* Configure I2C Tx as alternate function */
747- HAL_GPIO_DeInit (GPIOA , GPIO_PIN_8 );
748- HAL_GPIO_DeInit (GPIOB , GPIO_PIN_4 );
749- }
750- }
751-
752- #endif
753-
754782/*********************************************************************************************************
755783 END
756784*********************************************************************************************************/
0 commit comments