File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020#define MICROPY_HW_ENABLE_SPI3 (0)
2121#define MICROPY_HW_ENABLE_CAN (1)
2222
23+ // The pyboard has a 32kHz crystal for the RTC
24+ #define MICROPY_HW_RTC_USE_LSE (1)
25+
2326// USRSW has no pullup or pulldown, and pressing the switch makes the input go low
2427#define MICROPY_HW_USRSW_PIN (pin_B3)
2528#define MICROPY_HW_USRSW_PULL (GPIO_PULLUP)
Original file line number Diff line number Diff line change 1919#define MICROPY_HW_ENABLE_SPI3 (0)
2020#define MICROPY_HW_ENABLE_CAN (1)
2121
22+ // The pyboard has a 32kHz crystal for the RTC
23+ #define MICROPY_HW_RTC_USE_LSE (1)
24+
2225// USRSW has no pullup or pulldown, and pressing the switch makes the input go low
2326#define MICROPY_HW_USRSW_PIN (pin_A13)
2427#define MICROPY_HW_USRSW_PULL (GPIO_PULLUP)
Original file line number Diff line number Diff line change 1919#define MICROPY_HW_ENABLE_SPI3 (0)
2020#define MICROPY_HW_ENABLE_CAN (1)
2121
22+ // The pyboard has a 32kHz crystal for the RTC
23+ #define MICROPY_HW_RTC_USE_LSE (1)
24+
2225// USRSW has no pullup or pulldown, and pressing the switch makes the input go low
2326#define MICROPY_HW_USRSW_PIN (pin_B3)
2427#define MICROPY_HW_USRSW_PULL (GPIO_PULLUP)
Original file line number Diff line number Diff line change @@ -256,18 +256,29 @@ void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc) {
256256 __HAL_RCC_BACKUPRESET_RELEASE().
257257 - Configure the needed RTc clock source */
258258
259- // set LSE as RTC clock source
259+ // RTC clock source uses LSE (external crystal) only if relevant
260+ // configuration variable is set. Otherwise it uses LSI (internal osc).
261+
260262 RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE ;
261263 RCC_OscInitStruct .PLL .PLLState = RCC_PLL_NONE ;
264+ #if defined(MICROPY_HW_RTC_USE_LSE ) && MICROPY_HW_RTC_USE_LSE
262265 RCC_OscInitStruct .LSEState = RCC_LSE_ON ;
263266 RCC_OscInitStruct .LSIState = RCC_LSI_OFF ;
267+ #else
268+ RCC_OscInitStruct .LSEState = RCC_LSE_OFF ;
269+ RCC_OscInitStruct .LSIState = RCC_LSI_ON ;
270+ #endif
264271 if (HAL_RCC_OscConfig (& RCC_OscInitStruct ) != HAL_OK ) {
265272 //Error_Handler();
266273 return ;
267274 }
268275
269276 PeriphClkInitStruct .PeriphClockSelection = RCC_PERIPHCLK_RTC ;
277+ #if defined(MICROPY_HW_RTC_USE_LSE ) && MICROPY_HW_RTC_USE_LSE
270278 PeriphClkInitStruct .RTCClockSelection = RCC_RTCCLKSOURCE_LSE ;
279+ #else
280+ PeriphClkInitStruct .RTCClockSelection = RCC_RTCCLKSOURCE_LSI ;
281+ #endif
271282 if (HAL_RCCEx_PeriphCLKConfig (& PeriphClkInitStruct ) != HAL_OK ) {
272283 //Error_Handler();
273284 return ;
You can’t perform that action at this time.
0 commit comments