本文整理汇总了C++中HAL_PWR_EnableBkUpAccess函数的典型用法代码示例。如果您正苦于以下问题:C++ HAL_PWR_EnableBkUpAccess函数的具体用法?C++ HAL_PWR_EnableBkUpAccess怎么用?C++ HAL_PWR_EnableBkUpAccess使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HAL_PWR_EnableBkUpAccess函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: rtc_init_start
void rtc_init_start(bool force_init) {
RTCHandle.Instance = RTC;
/* Configure RTC prescaler and RTC data registers */
/* RTC configured as follow:
- Hour Format = Format 24
- Asynch Prediv = Value according to source clock
- Synch Prediv = Value according to source clock
- OutPut = Output Disable
- OutPutPolarity = High Polarity
- OutPutType = Open Drain */
RTCHandle.Init.HourFormat = RTC_HOURFORMAT_24;
RTCHandle.Init.AsynchPrediv = RTC_ASYNCH_PREDIV;
RTCHandle.Init.SynchPrediv = RTC_SYNCH_PREDIV;
RTCHandle.Init.OutPut = RTC_OUTPUT_DISABLE;
RTCHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
RTCHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
rtc_need_init_finalise = false;
if (!force_init) {
uint32_t bdcr = RCC->BDCR;
if ((bdcr & (RCC_BDCR_RTCEN | RCC_BDCR_RTCSEL | RCC_BDCR_LSEON | RCC_BDCR_LSERDY))
== (RCC_BDCR_RTCEN | RCC_BDCR_RTCSEL_0 | RCC_BDCR_LSEON | RCC_BDCR_LSERDY)) {
// LSE is enabled & ready --> no need to (re-)init RTC
// remove Backup Domain write protection
HAL_PWR_EnableBkUpAccess();
// Clear source Reset Flag
__HAL_RCC_CLEAR_RESET_FLAGS();
// provide some status information
rtc_info |= 0x40000 | (RCC->BDCR & 7) | (RCC->CSR & 3) << 8;
return;
} else if ((bdcr & (RCC_BDCR_RTCEN | RCC_BDCR_RTCSEL))
== (RCC_BDCR_RTCEN | RCC_BDCR_RTCSEL_1)) {
// LSI configured as the RTC clock source --> no need to (re-)init RTC
// remove Backup Domain write protection
HAL_PWR_EnableBkUpAccess();
// Clear source Reset Flag
__HAL_RCC_CLEAR_RESET_FLAGS();
// Turn the LSI on (it may need this even if the RTC is running)
RCC->CSR |= RCC_CSR_LSION;
// provide some status information
rtc_info |= 0x80000 | (RCC->BDCR & 7) | (RCC->CSR & 3) << 8;
return;
}
}
rtc_startup_tick = HAL_GetTick();
rtc_info = 0x3f000000 | (rtc_startup_tick & 0xffffff);
if (rtc_use_lse) {
if (lse_magic()) {
// don't even try LSE
rtc_use_lse = false;
rtc_info &= ~0x01000000;
}
}
PYB_RTC_MspInit_Kick(&RTCHandle, rtc_use_lse);
}
开发者ID:kaspar030,项目名称:micropython,代码行数:58,代码来源:rtc.c
示例2: Init_RTC
/**
* @brief Initialize RTC block
*
* @note
* @param None
* @retval None
*/
static void Init_RTC(void)
{
/* Initialize the HW - 37Khz LSI being used*/
/* Enable the LSI clock */
__HAL_RCC_LSI_ENABLE();
/* Enable power module clock */
__PWR_CLK_ENABLE();
/* Enable acces to the RTC registers */
HAL_PWR_EnableBkUpAccess();
/**
* Write twice the value to flush the APB-AHB bridge
* This bit shall be written in the register before writing the next one
*/
HAL_PWR_EnableBkUpAccess();
/* Select LSI as RTC Input */
__HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSI);
/* Enable RTC */
__HAL_RCC_RTC_ENABLE();
hrtc.Instance = RTC; /**< Define instance */
hrtc.Lock = HAL_UNLOCKED; /**< Initialize lock */
hrtc.State = HAL_RTC_STATE_READY; /**< Initialize state */
/**
* Bypass the shadow register
*/
HAL_RTCEx_EnableBypassShadow(&hrtc);
/**
* Set the Asynchronous prescaler
*/
hrtc.Init.AsynchPrediv = RTC_ASYNCH_PRESCALER;
hrtc.Init.SynchPrediv = RTC_SYNCH_PRESCALER;
HAL_RTC_Init(&hrtc);
/* Disable Write Protection */
__HAL_RTC_WRITEPROTECTION_DISABLE(&hrtc) ;
HAL_APP_RTC_Set_Wucksel(&hrtc, WUCKSEL_DIVIDER); /**< Tick timer is 55us */
/* Wait for LSI to be stable */
while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSIRDY) == 0);
return;
}
开发者ID:icelittle,项目名称:hid_ble,代码行数:58,代码来源:main.c
示例3: StandbyBKPSRAMMode_Measure
/**
* @brief This function configures the system to enter Standby mode with
* backup SRAM ON for current consumption measurement purpose.
* STANDBY Mode
* ============
* - RTC OFF
* - IWDG and LSI OFF
* - Backup SRAM ON
* - Wakeup using WakeUp Pin (PI.11)
* @param None
* @retval None
*/
void StandbyBKPSRAMMode_Measure(void)
{
/* Enable Power Clock*/
__HAL_RCC_PWR_CLK_ENABLE();
/* Allow access to Backup */
HAL_PWR_EnableBkUpAccess();
/* Reset RTC Domain */
__HAL_RCC_BACKUPRESET_FORCE();
__HAL_RCC_BACKUPRESET_RELEASE();
/* Disable all used wakeup sources: Pin6(PI.11) */
HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN6);
/* Clear all related wakeup flags */
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
/* Re-enable all used wakeup sources: Pin6(PI.11) */
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN6);
/* Enable BKPRAM Clock */
__HAL_RCC_BKPSRAM_CLK_ENABLE();
/* Enable the Backup SRAM low power Regulator */
HAL_PWREx_EnableBkUpReg();
/* Request to enter STANDBY mode */
HAL_PWR_EnterSTANDBYMode();
}
开发者ID:RadMie,项目名称:STM32F7DiscoveryBase,代码行数:42,代码来源:stm32f7xx_lp_modes.c
示例4: rtc_init
void rtc_init(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
uint32_t rtc_freq = 0;
if (rtc_inited) return;
rtc_inited = 1;
RtcHandle.Instance = RTC;
// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;
// Enable Power clock
__PWR_CLK_ENABLE();
// Enable access to Backup domain
HAL_PWR_EnableBkUpAccess();
// Reset Backup domain
__HAL_RCC_BACKUPRESET_FORCE();
__HAL_RCC_BACKUPRESET_RELEASE();
// Enable LSE Oscillator
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; /* Mandatory, otherwise the PLL is reconfigured! */
RCC_OscInitStruct.LSEState = RCC_LSE_ON; /* External 32.768 kHz clock on OSC_IN/OSC_OUT */
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) == HAL_OK) {
// Connect LSE to RTC
__HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSE);
rtc_freq = LSE_VALUE;
} else {
// Enable LSI clock
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // Mandatory, otherwise the PLL is reconfigured!
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
error("RTC error: LSI clock initialization failed.");
}
// Connect LSI to RTC
__HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSI);
// Note: The LSI clock can be measured precisely using a timer input capture.
rtc_freq = LSI_VALUE;
}
// Enable RTC
__HAL_RCC_RTC_ENABLE();
RtcHandle.Init.HourFormat = RTC_HOURFORMAT_24;
RtcHandle.Init.AsynchPrediv = 127;
RtcHandle.Init.SynchPrediv = (rtc_freq / 128) - 1;
RtcHandle.Init.OutPut = RTC_OUTPUT_DISABLE;
RtcHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
RtcHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
if (HAL_RTC_Init(&RtcHandle) != HAL_OK) {
error("RTC error: RTC initialization failed.");
}
}
开发者ID:lintwins,项目名称:mbed,代码行数:60,代码来源:rtc_api.c
示例5: HAL_IWDG_MspInit
/** @defgroup HAL_MSP_Private_Functions
* @{
*/
void HAL_IWDG_MspInit(IWDG_HandleTypeDef* hiwdg)
{
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWR_EnableBkUpAccess();
}
开发者ID:pengphei,项目名称:STM32Cube_L0,代码行数:10,代码来源:stm32l0xx_hal_msp.c
示例6: rtc_free
void rtc_free(void)
{
// Enable Power clock
__PWR_CLK_ENABLE();
// Enable access to Backup domain
HAL_PWR_EnableBkUpAccess();
// Reset Backup domain
__HAL_RCC_BACKUPRESET_FORCE();
__HAL_RCC_BACKUPRESET_RELEASE();
// Disable access to Backup domain
HAL_PWR_DisableBkUpAccess();
// Disable LSI and LSE clocks
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSIState = RCC_LSI_OFF;
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
rtc_inited = 0;
}
开发者ID:nickmolo,项目名称:ECE477,代码行数:25,代码来源:rtc_api.c
示例7: HAL_RTC_MspInit
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWR_EnableBkUpAccess();
/*##-2- Configure LSE as RTC clock source ###################################*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
//Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
//Error_Handler();
}
/*##-3- Enable RTC peripheral Clocks #######################################*/
/* Enable RTC Clock */
__HAL_RCC_RTC_ENABLE();
}
开发者ID:HitszChen,项目名称:intorobot-firmware,代码行数:27,代码来源:wiring_time_hal.cpp
示例8: rtc_backup_init
/* USER CODE BEGIN 1 */
static void rtc_backup_init()
{
uint32_t temp;
//__HAL_RCC_BKP_CLK_ENABLE();//for backup sram
/* Allow access to Backup */
HAL_PWR_EnableBkUpAccess();
}
开发者ID:hlmpost,项目名称:code_backup,代码行数:8,代码来源:rtc.c
示例9: HAL_RTC_MspInit
/**
* @brief RTC MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* @param hrtc: RTC handle pointer
* @note Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to select
* the RTC clock source; in this case the Backup domain will be reset in
* order to modify the RTC Clock source, as consequence RTC registers (including
* the backup registers) and RCC_CSR register are set to their reset values.
* @retval None
*/
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
/*##-1- Enables the PWR Clock and Enables access to the backup domain ###################################*/
/* To change the source clock of the RTC feature (LSE, LSI), You have to:
- Enable the power clock using __HAL_RCC_PWR_CLK_ENABLE()
- Enable write access using HAL_PWR_EnableBkUpAccess() function before to
configure the RTC clock source (to be done once after reset).
- Reset the Back up Domain using __HAL_RCC_BACKUPRESET_FORCE() and
__HAL_RCC_BACKUPRESET_RELEASE().
- Configure the needed RTC clock source */
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWR_EnableBkUpAccess();
/* Enable BKP CLK enable for backup registers */
__HAL_RCC_BKP_CLK_ENABLE();
#ifdef RTC_CLOCK_SOURCE_LSE
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.LSIState = RCC_LSI_OFF;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}
#elif defined (RTC_CLOCK_SOURCE_LSI)
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}
#else
#error Please select the RTC Clock source inside the main.h file
#endif /*RTC_CLOCK_SOURCE_LSE*/
/*##-2- Enable the RTC & BKP peripheral Clock ##############################*/
/* Enable RTC Clock */
__HAL_RCC_RTC_ENABLE();
}
开发者ID:Lembed,项目名称:STM32CubeF1-mirrors,代码行数:71,代码来源:stm32f1xx_hal_msp.c
示例10: HAL_LCD_MspInit
/**
* @brief LCD MSP Init.
* @param hlcd: LCD handle
* @retval None
*/
void HAL_LCD_MspInit(LCD_HandleTypeDef *hlcd)
{
GPIO_InitTypeDef GPIO_InitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct;
/*##-1- Enable PWR peripheral Clock #######################################*/
__PWR_CLK_ENABLE();
/*##-2- Allow Access and Reset the Backup Domaine ##########################*/
/* Allow Access to Backup Domaine */
HAL_PWR_EnableBkUpAccess();
/* Reset the Backup Domaine */
__HAL_RCC_BACKUPRESET_FORCE();
__HAL_RCC_BACKUPRESET_RELEASE();
/*##-3- Configue LSE as RTC clock soucre ###################################*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
/* Infinite loop */
while(1);
}
__HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSE);
/*##-4- Enable LCD GPIO Clocks #############################################*/
__GPIOA_CLK_ENABLE();
__GPIOB_CLK_ENABLE();
__GPIOC_CLK_ENABLE();
/*##-5- Configure peripheral GPIO ##########################################*/
/* Configure Output for LCD */
/* Port A */
GPIO_InitStruct.Pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_8 | GPIO_PIN_9 |GPIO_PIN_10 |GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
GPIO_InitStruct.Alternate = GPIO_AF1_LCD;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* Configure Output for LCD */
/* Port B */
GPIO_InitStruct.Pin = GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_8 | GPIO_PIN_9 \
| GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* Configure Output for LCD */
/* Port C*/
GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_6 \
| GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 |GPIO_PIN_11 ;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/*##-6- Enable LCD peripheral Clock ########################################*/
__LCD_CLK_ENABLE();
}
开发者ID:shjere,项目名称:common,代码行数:65,代码来源:stm32l0xx_hal_msp.c
示例11: StandbyMode_Measure
/**
* @brief This function configures the system to enter Standby mode for
* current consumption measurement purpose.
* STANDBY Mode
* ============
* - Backup SRAM and RTC OFF
* - IWDG and LSI OFF
* - Wakeup using WakeUp Pin (PA.00)
* @param None
* @retval None
*/
void StandbyMode_Measure(void)
{
/* Enable Power Clock*/
__HAL_RCC_PWR_CLK_ENABLE();
/* Allow access to Backup */
HAL_PWR_EnableBkUpAccess();
/* Reset RTC Domain */
__HAL_RCC_BACKUPRESET_FORCE();
__HAL_RCC_BACKUPRESET_RELEASE();
/* Disable all used wakeup sources: Pin1(PA.0) */
HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
/* Clear all related wakeup flags */
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
/* Re-enable all used wakeup sources: Pin1(PA.0) */
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);
/*## Enter Standby Mode ####################################################*/
/* Request to enter STANDBY mode */
HAL_PWR_EnterSTANDBYMode();
}
开发者ID:Lembed,项目名称:STM32CubeF4-mirrors,代码行数:36,代码来源:stm32f4xx_lp_modes.c
示例12: StandbyMode_Measure
/**
* @brief This function configures the system to enter Standby mode for
* current consumption measurement purpose.
* STANDBY Mode
* ============
* - RTC OFF
* - IWDG and LSI OFF
* - Wakeup using WakeUp Pin (wire Vdd to PA.00)
* @retval None
*/
void StandbyMode_Measure(void)
{
/* Enable Power Clock*/
__HAL_RCC_PWR_CLK_ENABLE();
/* Allow access to Backup */
HAL_PWR_EnableBkUpAccess();
/* Reset RTC Domain */
__HAL_RCC_BACKUPRESET_FORCE();
__HAL_RCC_BACKUPRESET_RELEASE();
/* The Following Wakeup sequence is highly recommended prior to each Standby mode entry
mainly when using more than one wakeup source this is to not miss any wakeup event.
- Disable all used wakeup sources,
- Clear all related wakeup flags,
- Re-enable all used wakeup sources,
- Enter the Standby mode.
*/
/*#### Disable all used wakeup sources: WKUP pin ###########################*/
HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
/*#### Clear all related wakeup flags ######################################*/
/* Clear PWR wake up Flag */
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
/* Enable WKUP pin */
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);
/* Request to enter STANDBY mode */
HAL_PWR_EnterSTANDBYMode();
}
开发者ID:PaxInstruments,项目名称:STM32CubeF3,代码行数:43,代码来源:stm32f3xx_lp_modes.c
示例13: RTC_Config
/**
* @brief Configures the RTC.
* @param None
* @retval None
*/
static void RTC_Config(void)
{
/* Enable Power Clock*/
__PWR_CLK_ENABLE();
/* Allow Access to RTC Backup domaine */
HAL_PWR_EnableBkUpAccess();
RtcHandle.Instance= RTC;
/* Check if the system was resumed from StandBy mode */
if (__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)
{
/* Clear StandBy flag */
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
/* Disable the write protection for RTC registers */
__HAL_RTC_WRITEPROTECTION_DISABLE(&RtcHandle);
/* Wait for RTC APB registers synchronisation (needed after start-up from Reset)*/
if (HAL_RTC_WaitForSynchro(&RtcHandle) != HAL_OK)
{
while(1);
}
/* Enable the write protection for RTC registers */
__HAL_RTC_WRITEPROTECTION_ENABLE(&RtcHandle);
/* No need to configure the RTC as the RTC config(clock source, enable,
prescaler,...) are kept after wake-up from STANDBY */
}
else
{
/* Reset Backup Domaine */
__HAL_RCC_BACKUPRESET_FORCE();
__HAL_RCC_BACKUPRESET_RELEASE();
/* Set the RTC time base to 1s */
/* Configure RTC prescaler and RTC data registers as follows:
- Hour Format = Format 24
- Asynch Prediv = Value according to source clock
- Synch Prediv = Value according to source clock
- OutPut = Output Disable
- OutPutPolarity = High Polarity
- OutPutType = Open Drain */
RtcHandle.Init.HourFormat = RTC_HOURFORMAT_24;
RtcHandle.Init.AsynchPrediv = RTC_ASYNCH_PREDIV;
RtcHandle.Init.SynchPrediv = RTC_SYNCH_PREDIV;
RtcHandle.Init.OutPut = RTC_OUTPUT_DISABLE;
RtcHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
RtcHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
if(HAL_RTC_Init(&RtcHandle) != HAL_OK)
{
/* Initialization Error */
while(1);
}
}
}
开发者ID:GreyCardinalRus,项目名称:stm32-cube,代码行数:62,代码来源:lowpower_app.c
示例14: HAL_IWDG_MspInit
/**
* @brief IWDG MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* - LSI enable
* @param hwwdg: IWDG handle pointer
* @retval None
*/
void HAL_IWDG_MspInit(IWDG_HandleTypeDef* hiwdg)
{
__PWR_CLK_ENABLE();
HAL_PWR_EnableBkUpAccess();
/*## Enable peripherals and GPIO Clocks ####################################*/
/* RCC LSI clock enable */
__HAL_RCC_LSI_ENABLE();
/* Wait till LSI is ready */
while (__HAL_RCC_GET_FLAG(RCC_FLAG_LSIRDY) == RESET)
{}
}
开发者ID:shjere,项目名称:common,代码行数:22,代码来源:stm32l0xx_hal_msp.c
示例15: ParamInit
void ParamInit(void)
{
uint8_t i;
sParamGeneral paramGeneral;
Flash_M25P64_Read_Buffer((uint8_t*)¶mGeneral, ADDRESS_PARAM_GENERAL, sizeof(paramGeneral));
if(paramGeneral.final != FINAL_OK) { /* if settings are empty, usb mode */
HAL_PWR_EnableBkUpAccess();
BACUP_STATUS->BACUP_STATUS_REG = USB_ENABLED;
HAL_PWR_DisableBkUpAccess();
NVIC_SystemReset();
}
else
{
开发者ID:khomin,项目名称:PLK_Firmware,代码行数:14,代码来源:parameters.c
示例16: rtc_init
void rtc_init(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
if (rtc_inited) return;
rtc_inited = 1;
RtcHandle.Instance = RTC;
// Enable Power clock
__HAL_RCC_PWR_CLK_ENABLE();
// Enable access to Backup domain
HAL_PWR_EnableBkUpAccess();
// Reset Backup domain
__HAL_RCC_BACKUPRESET_FORCE();
__HAL_RCC_BACKUPRESET_RELEASE();
// Enable LSE Oscillator
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // Mandatory, otherwise the PLL is reconfigured!
RCC_OscInitStruct.LSEState = RCC_LSE_ON; // External 32.768 kHz clock on OSC_IN/OSC_OUT
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) == HAL_OK) {
// Connect LSE to RTC
__HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSE);
} else {
// Enable LSI clock
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // Mandatory, otherwise the PLL is reconfigured!
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
error("RTC error: LSI clock initialization failed.");
}
// Connect LSI to RTC
__HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSI);
}
// Enable RTC
__HAL_RCC_RTC_ENABLE();
RtcHandle.Init.AsynchPrediv = RTC_AUTO_1_SECOND;
if (HAL_RTC_Init(&RtcHandle) != HAL_OK) {
error("RTC error: RTC initialization failed.");
}
}
开发者ID:1deus,项目名称:tmk_keyboard,代码行数:48,代码来源:rtc_api.c
示例17: rtc_init
void rtc_init(void) {
if (rtc_inited) return;
rtc_inited = 1;
RtcHandle.Instance = RTC;
// Enable Power clock
__PWR_CLK_ENABLE();
// Allow access to RTC
HAL_PWR_EnableBkUpAccess();
// Reset Backup domain
__HAL_RCC_BACKUPRESET_FORCE();
__HAL_RCC_BACKUPRESET_RELEASE();
// Enable LSI clock
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
error("RTC error: LSI clock initialization failed.");
}
// Connect LSI to RTC
__HAL_RCC_RTC_CLKPRESCALER(RCC_RTCCLKSOURCE_LSI);
__HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSI);
// Enable RTC clock
__HAL_RCC_RTC_ENABLE();
// [TODO] This value is LSI typical value. To be measured precisely using a timer input capture
uint32_t lsi_freq = 32000;
RtcHandle.Init.HourFormat = RTC_HOURFORMAT_24;
RtcHandle.Init.AsynchPrediv = 127;
RtcHandle.Init.SynchPrediv = (lsi_freq / 128) - 1;
RtcHandle.Init.OutPut = RTC_OUTPUT_DISABLE;
RtcHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
RtcHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
if (HAL_RTC_Init(&RtcHandle) != HAL_OK) {
error("RTC error: RTC initialization failed.");
}
}
开发者ID:ElAbbassi,项目名称:mbed,代码行数:46,代码来源:rtc_api.c
示例18: HAL_RTC_MspInit
void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
{
if(hrtc->Instance==RTC)
{
/* USER CODE BEGIN RTC_MspInit 0 */
/* USER CODE END RTC_MspInit 0 */
HAL_PWR_EnableBkUpAccess();
/* Enable BKP CLK enable for backup registers */
__HAL_RCC_BKP_CLK_ENABLE();
/* Peripheral clock enable */
__HAL_RCC_RTC_ENABLE();
/* USER CODE BEGIN RTC_MspInit 1 */
/* USER CODE END RTC_MspInit 1 */
}
}
开发者ID:lexi6725,项目名称:STemWin_Demo_STM32F103,代码行数:18,代码来源:rtc.c
示例19: HAL_RTC_MspInit
/**
* @brief RTC MSP Initialization
* This function configures the hardware resources used in this example
* @param hrtc RTC handle pointer
*
* @note Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to select
* the RTC clock source; in this case the Backup domain will be reset in
* order to modify the RTC Clock source, as consequence RTC registers (including
* the backup registers) and RCC_BDCR register are set to their reset values.
*
* @retval None
*/
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
/*##-1- Enables the PWR Clock and Enables access to the backup domain ###################################*/
/* To change the source clock of the RTC feature (LSE, LSI), You have to:
- Enable the power clock using __HAL_RCC_PWR_CLK_ENABLE()
- Enable write access using HAL_PWR_EnableBkUpAccess() function before to
configure the RTC clock source (to be done once after reset).
- Reset the Back up Domain using __HAL_RCC_BACKUPRESET_FORCE() and
__HAL_RCC_BACKUPRESET_RELEASE().
- Configure the needed RTc clock source */
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWR_EnableBkUpAccess();
#ifdef RTC_CLOCK_SOURCE_LSE
/* Note: For STM32F3xx MCU families it is recommended to use the low drive mode configuration
of the LSE JUMPER_POSITION (low drive capability in LSEDRV register) due to the 6pF load capacitance
of the crystal on board*/
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
#endif /* RTC_CLOCK_SOURCE_LSE */
/*##-2- Configure LSE as RTC clock source ###################################*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}
/*##-3- Enable RTC peripheral Clocks #######################################*/
/* Enable RTC Clock */
__HAL_RCC_RTC_ENABLE();
}
开发者ID:PaxInstruments,项目名称:STM32CubeF3,代码行数:56,代码来源:stm32f3xx_hal_msp.c
示例20: InitRTC
/*
Conditions:
0
Exit points:
0
M = 0 - 0 + 2 = 2
Cyclomatic complexity
2
*/
void InitRTC(void)
{
__PWR_CLK_ENABLE();
HAL_PWR_EnableBkUpAccess();
__HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_HSE_DIV16);
__HAL_RCC_RTC_ENABLE();
rtc.Instance = RTC;
rtc.Init.AsynchPrediv = 0x63; // Step down the clock by a factor of 100
rtc.Init.SynchPrediv = 0x1387; // Step down the clock by a factor of 5000
rtc.Init.HourFormat = RTC_HOURFORMAT_24;
rtc.Init.OutPut = RTC_OUTPUT_DISABLE;
rtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_LOW;
rtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
}
开发者ID:ChicoState,项目名称:eggbeater,代码行数:28,代码来源:fingerprint_reader.c
注:本文中的HAL_PWR_EnableBkUpAccess函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论