⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 73x_rtc.c

📁 国外LPC2000系列的一些源程序,请大家快快下载
💻 C
📖 第 1 页 / 共 2 页
字号:
    RTC_WaitForLastTask();
  }
}

/*******************************************************************************
* Function Name  : RTC_GetPrescalerValue
* Description    : Gets the RTC Prescaler value.
* Input          : None
* Output         : None
* Return         : The Prescaler value
*******************************************************************************/
u32 RTC_GetPrescalerValue (void)
{
  u16 tmp = RTC->PRLL;
  return ( (u32)(RTC->PRLH & 0x000F) << 16 ) | tmp ;
}

/******************************************************************************
* Function Name  : RTC_SetAlarm                                              
* Description    : Sets the new RTC alarm Value           
* Input          : RTC_alarm: new Alarm Value  
* Output         : None                                
* Return         : None                                                      
*******************************************************************************/
void RTC_SetAlarm(u32 RTC_alarm)
{
  /* Wait For Last Task Completion */
  RTC_WaitForLastTask ();
  /* Enter In Configuration Mode */
  RTC_EnterCfgMode ();
  /* Set the ALARM MSB word */
  RTC->ALRH = (RTC_alarm & 0xFFFF0000) >> 16;
  /* Set the ALARM LSB word */
  RTC->ALRL = (RTC_alarm & 0x0000FFFF);
  /* Exit From Configuration Mode */
  RTC_ExitCfgMode ();
  /* Wait For Last Task Completion */
  RTC_WaitForLastTask();
}

/*******************************************************************************
* Function Name  : RTC_GetAlarmValue
* Description    : Gets the RTC alarm Value.
* Input          : None
* Output         : None
* Return         : The Alarm value
*******************************************************************************/
u32 RTC_GetAlarmValue(void)
{
   u16 tmp = RTC->ALRL ;
   return ( (u32)RTC->ALRH << 16 ) | tmp ;
}

/*******************************************************************************
* Function Name  : RTC_FlagClear
* Description    : Clears the RTC flags passed as parameters.
* Input          : RTC_Flag: flag to clear. This parameter can be any 
*                  combination of the following values:
*                       - RTC_FLAG_GL:  Global flag
*                       - RTC_FLAG_OV:  Overflow flag
*                       - RTC_FLAG_ALA: Alarm flag
*                       - RTC_FLAG_SEC: Second flag
* Output         : None
* Return         : None
*******************************************************************************/
void RTC_FlagClear(u16 RTC_Flag)
{
  /* Clear the coressponding RTC flag */
  RTC->CRL &= ~RTC_Flag;
}

/*******************************************************************************
* Function Name  : RTC_FlagStatus
* Description    : Checks whether the specified RTC flag is set or not.
* Input          : RTC_Flag: flag to check. This parameter can be one of the
*                  following values:
*                       - RTC_FLAG_GL:  Global flag
*                       - RTC_FLAG_OV:  Overflow flag
*                       - RTC_FLAG_ALA: Alarm flag
*                       - RTC_FLAG_SEC: Second flag
* Output         : None
* Return         : The new state of the RTC_Flag (SET or RESET).
*******************************************************************************/
FlagStatus RTC_FlagStatus(u16 RTC_Flag)
{
  if((RTC->CRL & RTC_Flag) != RESET )
  {
    return SET;
  }
  else
  {
    return RESET;
  }
}

/*******************************************************************************
* Function Name  : RTC_ITConfig
* Description    : This routine is used to configure the RTC interrupts
* Input          : - RTC_IT: interrupt to enable or disable. This parameter can
*                    be any combination of the following values:
*                         - RTC_IT_GL:  Global interrupt
*                         - RTC_IT_OV:  Overflow interrupt
*                         - RTC_IT_ALA: Alarm interrupt
*                         - RTC_IT_SEC: Second interrupt
*                  - NewState: new state of the specified RTC interrupts.
*                    This parameter can be: ENABLE or DISABLE.
* Output         : None
* Return         : None
*******************************************************************************/
void RTC_ITConfig(u16 RTC_IT, FunctionalState NewState)
{
  if(NewState == ENABLE)
  {
    RTC->CRH |= RTC_IT;
  }
  else
  {
    RTC->CRH &= ~RTC_IT;
  }
}

/*******************************************************************************
* Function Name  : RTC_ITStatus
* Description    : Gets the RTC interrupts status
* Input          : - RTC_IT: interrupt to check. This parameter can
*                    be one of the following values:
*                         - RTC_IT_GL:  Global interrupt
*                         - RTC_IT_OV:  Overflow interrupt
*                         - RTC_IT_ALA: Alarm interrupt
*                         - RTC_IT_SEC: Second interrupt
* Output         : None
* Return         : The State of the RTC_IT (ENABLE or DISABLE)
*******************************************************************************/
FunctionalState RTC_ITStatus(u16 RTC_IT)
{
  if(RTC->CRH & RTC_IT)
  {
    return ENABLE;
  }
  else
  {
    return DISABLE;
  }
}

/******************************************************************************
* Function Name  : RTC_EnterCfgMode                                          
* Description    : Enters in the Configuration Mode.   
* Input          : None
* Output         : None                                                       
* Return         : None                                                      
*******************************************************************************/
void RTC_EnterCfgMode(void)
{
  /* Set the CNF flag to enter in the Configuration Mode */
  RTC->CRL |= RTC_CNF_Mask;
}

/******************************************************************************
* Function Name  : RTC_ExitCfgMode                                           
* Description    : Exits from the Configuration Mode.
* Input          : None 
* Output         : None                                                      
* Return         : None                                                      
*******************************************************************************/
void RTC_ExitCfgMode(void)
{
  /* Reset the CNF flag to exit from the Configuration Mode */
  RTC->CRL &= ~RTC_CNF_Mask;
}

/******************************************************************************
* Function Name  : RTC_WaitForLastTask                                       
* Description    : Waits for the last task completion.           
* Input          : None  
* Output         : None                                                     
* Return         : None                                                      
*******************************************************************************/
void RTC_WaitForLastTask(void)
{
  /* Loop until the Last operation Completion */
  while (!(RTC->CRL & RTC_RTOFF_Mask));
}

/******************* (C) COPYRIGHT 2005 STMicroelectronics *****END OF FILE****/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -