本文整理汇总了C++中RTC_ReadBackupRegister函数的典型用法代码示例。如果您正苦于以下问题:C++ RTC_ReadBackupRegister函数的具体用法?C++ RTC_ReadBackupRegister怎么用?C++ RTC_ReadBackupRegister使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTC_ReadBackupRegister函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PIOS_WDG_Init
/**
* @brief Initialize the watchdog timer for a specified timeout
*
* It is important to note that this function returns the achieved timeout
* for this hardware. For hardware independence this should be checked when
* scheduling updates. Other hardware dependent details may need to be
* considered such as a window time which sets a minimum update time,
* and this function should return a recommended delay for clearing.
*
* For the STM32 nominal clock rate is 32 khz, but for the maximum clock rate of
* 60 khz and a prescaler of 4 yields a clock rate of 15 khz. The delay that is
* set in the watchdog assumes the nominal clock rate, but the delay for FreeRTOS
* to use is 75% of the minimal delay.
*
* @returns Maximum recommended delay between updates based on PIOS_WATCHDOG_TIMEOUT constant
*/
uint16_t PIOS_WDG_Init()
{
uint16_t delay = ((uint32_t) PIOS_WATCHDOG_TIMEOUT * 60) / 16;
if (delay > 0x0fff)
delay = 0x0fff;
#if defined(PIOS_INCLUDE_WDG)
DBGMCU_Config(DBGMCU_IWDG_STOP, ENABLE); // make the watchdog stop counting in debug mode
IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
IWDG_SetPrescaler(IWDG_Prescaler_16);
IWDG_SetReload(delay);
IWDG_ReloadCounter();
IWDG_Enable();
// watchdog flags now stored in backup registers
PWR_BackupAccessCmd(ENABLE);
wdg_configuration.bootup_flags = RTC_ReadBackupRegister(PIOS_WDG_REGISTER);
/*
* Start from an empty set of registered flags so previous boots
* can't influence the current one
*/
RTC_WriteBackupRegister(PIOS_WDG_REGISTER, 0);
#endif
return delay;
}
示例2: ad_store_flash
/**
* 存储flash数据
* @param value
* @return None
*/
void ad_store_flash(uint16_t *convert_value)
{
uint8_t i;
uint8_t buf[12];
uint32_t flash_wr_addr; /**< flash写地址 */
/** 读取实时钟(6 byte) */
rtc_rd_calendar(&buf[0]);
/** 读取传感器值 */
for(i = 0; i < 3; i++)
{
buf[2 * i + 6] = (*(convert_value + i)) / 256; /**< 传感器数据高八位在前 */
buf[2 * i + 7] = (*(convert_value + i)) % 256;
}
/** 更新flash写指针 */
flash_wr_addr = RTC_ReadBackupRegister(RTC_BKP_flash_wr_addr); /**< 读出这次要写入的地址 */
/** 当从第一扇区开始写,或者如果写一帧数据(12 bytes)超过最后一个扇区,
则将第一扇区擦除并从第一扇区开始写 */
if((flash_wr_addr + 12) > 0x1FFFFF)
{
spi_falsh_specify_sector_erase(0);
flash_wr_addr = 0;
}
/** 如果写一帧数据(12 bytes)达到下一扇区,则将下一扇区进行擦除 */
else if(((flash_wr_addr + 12) & 0xFF0000) > (flash_wr_addr & 0xFF0000))
{
spi_falsh_specify_sector_erase(((flash_wr_addr & 0xFF0000) >> 16) + 1);
}
示例3: test
void test(void)
{
//Reads data from the specified RTC Backup data Register.
//入侵检测
if (RTC_ReadBackupRegister(RTC_BKP_DR0) != 0x32F2)
{
/* RTC configuration */
RTC_Config();
/* Configure the time&date register */
RTC_TimeRegulate();
}
else
{
/* Enable the PWR clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
/* Allow access to RTC */
PWR_BackupAccessCmd(ENABLE);
/* Wait for RTC APB registers synchronisation */
RTC_WaitForSynchro();
/* Clear the RTC Alarm Flag */
RTC_ClearFlag(RTC_FLAG_ALRAF);
/* Clear the EXTI Line 17 Pending bit (Connected internally to RTC Alarm) */
EXTI_ClearITPendingBit(EXTI_Line17);
}
while (1);
}
示例4: RTC_cfg
unsigned int RTC_cfg(void)
{
unsigned int ret;
RTC_DateTypeDef RTC_DateStruct;
RTC_TimeTypeDef RTC_TimeStruct;
ret = 0;
if (RTC_ReadBackupRegister(RTC_BKP_DR1) != 0xA5A5)
{
ret = 1;
/* Allow access to BKP Domain */
PWR_BackupAccessCmd(ENABLE);
/* Reset Backup Domain */
RTC_DeInit();
/* Enable LSE */
RCC_LSEConfig(RCC_LSE_ON);
/* Wait till LSE is ready */
while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
{}
/* Select LSE as RTC Clock Source */
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
/* Enable RTC Clock */
RCC_RTCCLKCmd(ENABLE);
/* Wait for RTC registers synchronization */
RTC_WaitForSynchro();
/* Adjust time */
RTC_DateStruct.RTC_Year = 13;
RTC_DateStruct.RTC_Month = 05;
RTC_DateStruct.RTC_Date = 29;
RTC_DateStruct.RTC_WeekDay = 3;
RTC_TimeStruct.RTC_Hours = 11;
RTC_TimeStruct.RTC_Minutes = 0;
RTC_TimeStruct.RTC_Seconds = 0;
RTC_SetTime(RTC_Format_BIN, &RTC_TimeStruct);
RTC_SetDate(RTC_Format_BIN, &RTC_DateStruct);
RTC_WriteBackupRegister(RTC_BKP_DR1, 0xA5A5);
}
else
{
/* Allow access to BKP Domain */
PWR_BackupAccessCmd(ENABLE);
/* Wait for RTC registers synchronization */
RTC_WaitForSynchro();
while (RTC_GetFlagStatus(RTC_FLAG_RSF) == RESET);
}
return ret;
}
示例5: PIOS_IAP_CheckRequest
/*!
* \brief Determines if an In-Application-Programming request has been made.
* \param *comm - Which communication stream to use for the IAP (USB, Telemetry, I2C, SPI, etc)
* \return TRUE - if correct sequence found, along with 'comm' updated.
* FALSE - Note that 'comm' will have an invalid comm identifier.
* \retval
*
*/
uint32_t PIOS_IAP_CheckRequest( void )
{
uint32_t retval = false;
uint16_t reg1;
uint16_t reg2;
reg1 = RTC_ReadBackupRegister( MAGIC_REG_1 );
reg2 = RTC_ReadBackupRegister( MAGIC_REG_2 );
if( reg1 == IAP_MAGIC_WORD_1 && reg2 == IAP_MAGIC_WORD_2 ) {
// We have a match.
retval = true;
} else {
retval = false;
}
return retval;
}
示例6: ReadRTC_BKP_DR
/*
*********************************************************************************************************
* 函 数 名: ReadRTC_BKP_DR
* 功能说明: 读取备份域数据
* 形 参:RTCBackupIndex 寄存器索引值
* 返 回 值:
*********************************************************************************************************
*/
uint32_t ReadRTC_BKP_DR(uint8_t RTCBackupIndex)
{
if (RTCBackupIndex < RTC_BKP_DR_NUMBER)
{
return RTC_ReadBackupRegister(aRTC_BKP_DR[RTCBackupIndex]);
}
return 0xFFFFFFFF;
}
示例7: platform_rtc_init
OSStatus platform_rtc_init(void)
{
#ifdef MICO_ENABLE_MCU_RTC
RTC_InitTypeDef RTC_InitStruct;
RTC_DeInit( );
RTC_InitStruct.RTC_HourFormat = RTC_HourFormat_24;
/* RTC ticks every second */
RTC_InitStruct.RTC_AsynchPrediv = 0x7F;
RTC_InitStruct.RTC_SynchPrediv = 0xFF;
RTC_Init( &RTC_InitStruct );
#ifdef USE_RTC_BKP
/* Enable the PWR clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
/* Allow access to BKP Domain */
PWR_BackupAccessCmd(ENABLE);
PWR_BackupRegulatorCmd(ENABLE);
#endif
/* Enable the LSE OSC */
RCC_LSEConfig(RCC_LSE_ON);
/* Wait till LSE is ready */
while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
{
}
/* Select the RTC Clock Source */
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
/* Enable the RTC Clock */
RCC_RTCCLKCmd(ENABLE);
/* RTC configuration -------------------------------------------------------*/
/* Wait for RTC APB registers synchronisation */
RTC_WaitForSynchro();
#ifdef USE_RTC_BKP
if (RTC_ReadBackupRegister(RTC_BKP_DR0) != USE_RTC_BKP) {
/* set it to 12:20:30 08/04/2013 monday */
platform_rtc_set_time(&default_rtc_time);
RTC_WriteBackupRegister(RTC_BKP_DR0, USE_RTC_BKP);
}
#else
//#ifdef RTC_ENABLED
/* application must have mico_application_default_time structure declared somewhere, otherwise it wont compile */
/* write default application time inside rtc */
platform_rtc_set_time(&mico_default_time);
//#endif /* RTC_ENABLED */
#endif
return kNoErr;
#else
return kUnsupportedErr;
#endif
}
示例8: MOD_GetParam
/**
* @brief Retreive parameters from the backup memory
* @param mem_base: parameters memory address in the backup sram
* @param cfg: configuration parameters structure
* @retval None
*/
void MOD_GetParam(uint16_t mem_base , uint32_t *cfg)
{
if ( RTC_Error == 0)
{
*cfg = RTC_ReadBackupRegister(mem_base);
}
else
{
*cfg = 0;
}
}
示例9: LowPower_EnterSTANDBYMode_RTCAlarm
/**
* @brief Enters MCU in STANDBY mode. The wake-up from STANDBY mode is performed
* by an RTC Alarm event.
* @param None
* @retval None
*/
void LowPower_EnterSTANDBYMode_RTCAlarm(void)
{
// LCD_Clear(LCD_COLOR_WHITE);
/* Set the LCD Back Color */
// LCD_SetBackColor(LCD_COLOR_BLUE);
/* Set the LCD Text Color */
// LCD_SetTextColor(LCD_COLOR_WHITE);
/* External Interrupt Disable */
//Demo_IntExtOnOffCmd(DISABLE);
/* Enable WakeUp pin */
PWR_WakeUpPinCmd(PWR_WakeUpPin_1, ENABLE);
/* Check if the StandBy flag is set */
if (PWR_GetFlagStatus(PWR_FLAG_SB) != RESET)
{
/* Clear StandBy flag */
PWR_ClearFlag(PWR_FLAG_SB);
RTC_WaitForSynchro();
}
if (RTC_ReadBackupRegister(RTC_BKP_DR0) != 0x5AA5)
{
// LCD_DisplayStringLine(LCD_LINE_1, "Time and Date are ");
// LCD_DisplayStringLine(LCD_LINE_2, "not configured, ");
// LCD_DisplayStringLine(LCD_LINE_3, "please go to the ");
// LCD_DisplayStringLine(LCD_LINE_4, "calendar menu and ");
// LCD_DisplayStringLine(LCD_LINE_5, "set the time and ");
// LCD_DisplayStringLine(LCD_LINE_6, "date parameters. ");
// LCD_DisplayStringLine(LCD_LINE_7, "Press JoyStick to ");
// LCD_DisplayStringLine(LCD_LINE_8, "continue... ");
/* External Interrupt Enable */
//Demo_IntExtOnOffCmd(ENABLE);
return;
}
Calendar_AlarmPreAdjust_A();
// LCD_DisplayStringLine(LCD_LINE_7, " MCU in STANDBY Mode");
// LCD_DisplayStringLine(LCD_LINE_8, " Wait For RTC Alarm ");
/* Request to enter STANDBY mode (Wake Up flag is cleared in PWR_EnterSTANDBYMode function) */
PWR_EnterSTANDBYMode();
}
示例10: CheckRTC_BKP_DR
/**
* @brief Checks if the RTC Backup DRx registers values are correct or not.
* @param FirstRTCBackupData: data to be compared with RTC Backup data registers.
* @retval - 0: All RTC Backup DRx registers values are correct
* - Value different from 0: Number of the first Backup register
* which value is not correct
*/
static uint32_t CheckRTC_BKP_DR(uint32_t FirstRTCBackupData)
{
uint32_t index = 0;
for (index = 0; index < RTC_BKP_DR_NUMBER; index++)
{
/* Read from data register */
if (RTC_ReadBackupRegister(aRTC_BKP_DR[index]) != (FirstRTCBackupData + (index * 0x5A)))
{
return (index + 1);
}
}
return 0;
}
示例11: CheckBackupReg
/**
* @brief Checks if the Backup data registers values are correct or not.
* @param FirstBackupData: data to read from first backup data register
* @retval - 0: All Backup DRx registers data are correct
* - Value different from 0: Number of the first Backup register which
* value is not correct
*/
uint32_t CheckBackupReg(uint16_t FirstBackupData)
{
uint32_t index = 0;
for (index = 0; index < RTC_BKP_DR_NUMBER; index++)
{
if (RTC_ReadBackupRegister(BKPDataReg[index]) != (FirstBackupData + (index * 0x5A)))
{
return (index + 1);
}
}
return 0;
}
示例12: IsBackupRegReset
/**
* @brief Checks if the RTC Backup DRx registers are reset or not.
* @param None
* @retval - 0: All RTC Backup DRx registers are reset
* - Value different from 0: Number of the first Backup register
* not reset
*/
uint32_t IsBackupRegReset(void)
{
uint32_t index = 0;
for (index = 0; index < RTC_BKP_DR_NUMBER; index++)
{
/* Read from bkp Data Register */
if (RTC_ReadBackupRegister(aRTC_BKP_DR[index]) != 0)
{
return (index + 1);
}
}
return 0;
}
示例13: rtc_init
void rtc_init(void) {
rtc_ok = RTC_ReadBackupRegister(RTC_BKP_DR0) == 0xCA7E;
if(rtc_ok) {
// Enable the PWR clock
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
// Allow access to RTC
PWR_BackupAccessCmd(ENABLE);
// Wait for RTC APB registers synchronisation
RTC_WaitForSynchro();
}
}
示例14: PIOS_WDG_UpdateFlag
/**
* @brief Function called by modules to indicate they are still running
*
* This function will set this flag in the active flags register (which is
* a backup regsiter) and if all the registered flags are set will clear
* the watchdog and set only this flag in the backup register
*
* @param[in] flag the flag to set
* @return true if the watchdog cleared, false if flags are pending
*/
bool PIOS_WDG_UpdateFlag(uint16_t flag)
{
// we can probably avoid using a semaphore here which will be good for
// efficiency and not blocking critical tasks. race condition could
// overwrite their flag update, but unlikely to block _all_ of them
// for the timeout window
uint16_t cur_flags = RTC_ReadBackupRegister(PIOS_WDG_REGISTER);
if ((cur_flags | flag) == wdg_configuration.used_flags) {
PIOS_WDG_Clear();
RTC_WriteBackupRegister(PIOS_WDG_REGISTER, flag);
return true;
} else {
RTC_WriteBackupRegister(PIOS_WDG_REGISTER, cur_flags | flag);
return false;
}
}
示例15: platform_rtc_init
void platform_rtc_init(void)
{
RTC_InitTypeDef RTC_InitStruct;
RTC_InitStruct.RTC_HourFormat = RTC_HourFormat_24;
/* RTC ticks every second */
RTC_InitStruct.RTC_AsynchPrediv = 0x7F;
RTC_InitStruct.RTC_SynchPrediv = 0xFF;
/* Enable the PWR clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
/* RTC clock source configuration ------------------------------------------*/
/* Allow access to BKP Domain */
PWR_BackupAccessCmd(ENABLE);
RTC_Init( &RTC_InitStruct );
/* Enable the LSE OSC */
RCC_LSEConfig(RCC_LSE_ON);
/* Wait till LSE is ready */
while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
{
}
/* Select the RTC Clock Source */
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
/* Enable the RTC Clock */
RCC_RTCCLKCmd(ENABLE);
/* RTC configuration -------------------------------------------------------*/
/* Wait for RTC APB registers synchronisation */
RTC_WaitForSynchro();
#ifdef USE_RTC_BKP
if (RTC_ReadBackupRegister(RTC_BKP_DR0) != USE_RTC_BKP) {
/* set it to 12:20:30 08/04/2013 monday */
MicoRtcSetTime(&mico_default_time);
RTC_WriteBackupRegister(RTC_BKP_DR0, USE_RTC_BKP);
}
#else
/* write default application time inside rtc */
MicoRtcSetTime(&mico_default_time);
#endif
}