Files
@ c1b1dfc6c2f4
Branch filter:
Location: FeatherHAB/wsprhab/src/system.c - annotation
c1b1dfc6c2f4
1.9 KiB
text/plain
Modularize code a bit and switch to new GPS setup. Untested on hardware.
c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 c1b1dfc6c2f4 | //
// System: basic low-level system configuration
//
#include "stm32f0xx_hal.h"
#include "wspr.h"
void enter_sleep(void)
{
//HAL_SuspendTick();
wspr_sleep();
HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);
wspr_wakeup();
//HAL_ResumeTick();
}
void enter_deepsleep(void)
{
// Request to enter STOP mode with regulator in low power mode
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
// After wake-up from STOP reconfigure the PLL
sysclk_init();
}
// Initialize system clocks
void sysclk_init(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInit;
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSI14;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSI14State = RCC_HSI14_ON;
RCC_OscInitStruct.HSICalibrationValue = 16;
RCC_OscInitStruct.HSI14CalibrationValue = 16;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0);
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_I2C1;
PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_SYSCLK; //RCC_USART1CLKSOURCE_PCLK1;
PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_SYSCLK;
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit);
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
__SYSCFG_CLK_ENABLE();
// SysTick_IRQn interrupt configuration
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
}
|