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

📄 stm32f10x_rtc.lst

📁 STM32利用正交编码器实现电机的控制
💻 LST
📖 第 1 页 / 共 2 页
字号:
##############################################################################
#                                                                            #
# IAR ARM ANSI C/C++ Compiler V4.42A/W32               15/May/2008  12:06:32 #
# Copyright 1999-2005 IAR Systems. All rights reserved.                      #
#                                                                            #
#    Cpu mode        =  thumb                                                #
#    Endian          =  little                                               #
#    Stack alignment =  4                                                    #
#    Source file     =  C:\David JIANG\ST MCU\Docs\STM32\AN_JIANG\TIM        #
#                       Encoder\example\FWLib\src\stm32f10x_rtc.c            #
#    Command line    =  "C:\David JIANG\ST MCU\Docs\STM32\AN_JIANG\TIM       #
#                       Encoder\example\FWLib\src\stm32f10x_rtc.c" -D        #
#                       VECT_TAB_FLASH -lcN "C:\David JIANG\ST               #
#                       MCU\Docs\STM32\AN_JIANG\TIM                          #
#                       Encoder\example\project\EWARM\BOOT_FLASH\List\" -lb  #
#                       "C:\David JIANG\ST MCU\Docs\STM32\AN_JIANG\TIM       #
#                       Encoder\example\project\EWARM\BOOT_FLASH\List\" -o   #
#                       "C:\David JIANG\ST MCU\Docs\STM32\AN_JIANG\TIM       #
#                       Encoder\example\project\EWARM\BOOT_FLASH\Obj\" -z3   #
#                       --no_cse --no_unroll --no_inline --no_code_motion    #
#                       --no_tbaa --no_clustering --no_scheduling --debug    #
#                       --cpu_mode thumb --endian little --cpu cortex-M3     #
#                       --stack_align 4 --require_prototypes --fpu None      #
#                       --dlib_config "C:\Program Files\IAR                  #
#                       Systems\Embedded Workbench                           #
#                       4.0\arm\LIB\dl7mptnnl8f.h" -I "C:\David JIANG\ST     #
#                       MCU\Docs\STM32\AN_JIANG\TIM                          #
#                       Encoder\example\project\EWARM\" -I "C:\David         #
#                       JIANG\ST MCU\Docs\STM32\AN_JIANG\TIM                 #
#                       Encoder\example\project\EWARM\..\include\" -I        #
#                       "C:\David JIANG\ST MCU\Docs\STM32\AN_JIANG\TIM       #
#                       Encoder\example\project\EWARM\..\..\FWLib\inc\" -I   #
#                       "C:\Program Files\IAR Systems\Embedded Workbench     #
#                       4.0\arm\INC\"                                        #
#    List file       =  C:\David JIANG\ST MCU\Docs\STM32\AN_JIANG\TIM        #
#                       Encoder\example\project\EWARM\BOOT_FLASH\List\stm32f #
#                       10x_rtc.lst                                          #
#    Object file     =  C:\David JIANG\ST MCU\Docs\STM32\AN_JIANG\TIM        #
#                       Encoder\example\project\EWARM\BOOT_FLASH\Obj\stm32f1 #
#                       0x_rtc.r79                                           #
#                                                                            #
#                                                                            #
##############################################################################

C:\David JIANG\ST MCU\Docs\STM32\AN_JIANG\TIM Encoder\example\FWLib\src\stm32f10x_rtc.c
      1          /******************** (C) COPYRIGHT 2007 STMicroelectronics ********************
      2          * File Name          : stm32f10x_rtc.c
      3          * Author             : MCD Application Team
      4          * Date First Issued  : 09/29/2006
      5          * Description        : This file provides all the RTC firmware functions.
      6          ********************************************************************************
      7          * History:
      8          * 05/21/2007: V0.3
      9          * 04/02/2007: V0.2
     10          * 02/05/2007: V0.1
     11          * 09/29/2006: V0.01
     12          ********************************************************************************
     13          * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
     14          * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
     15          * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
     16          * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
     17          * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
     18          * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
     19          *******************************************************************************/
     20          
     21          /* Includes ------------------------------------------------------------------*/
     22          #include "stm32f10x_rtc.h"
     23          
     24          /* Private typedef -----------------------------------------------------------*/
     25          /* Private define ------------------------------------------------------------*/
     26          #define CRL_CNF_Set      ((u16)0x0010)      /* Configuration Flag Enable Mask */
     27          #define CRL_CNF_Reset    ((u16)0xFFEF)      /* Configuration Flag Disable Mask */
     28          #define RTC_LSB_Mask     ((u32)0x0000FFFF)  /* RTC LSB Mask */
     29          #define RTC_MSB_Mask     ((u32)0xFFFF0000)  /* RTC MSB Mask */
     30          #define PRLH_MSB_Mask    ((u32)0x000F0000)  /* RTC Prescaler MSB Mask */
     31          
     32          /* Private macro -------------------------------------------------------------*/
     33          /* Private variables ---------------------------------------------------------*/
     34          /* Private function prototypes -----------------------------------------------*/
     35          /* Private functions ---------------------------------------------------------*/
     36          
     37          /*******************************************************************************
     38          * Function Name  : RTC_ITConfig
     39          * Description    : Enables or disables the specified RTC interrupts.
     40          * Input          : - RTC_IT: specifies the RTC interrupts sources to be enabled
     41          *                    or disabled.
     42          *                    This parameter can be any combination of the following values:
     43          *                       - RTC_IT_OW: Overflow interrupt
     44          *                       - RTC_IT_ALR: Alarm interrupt
     45          *                       - RTC_IT_SEC: Second interrupt
     46          *                  - NewState: new state of the specified RTC interrupts.
     47          *                    This parameter can be: ENABLE or DISABLE.
     48          * Output         : None
     49          * Return         : None
     50          *******************************************************************************/
     51          void RTC_ITConfig(u16 RTC_IT, FunctionalState NewState)
     52          {
     53            /* Check the parameters */
     54            assert(IS_RTC_IT(RTC_IT));  
     55            assert(IS_FUNCTIONAL_STATE(NewState));
     56            
     57            if (NewState != DISABLE)
     58            {
     59              RTC->CRH |= RTC_IT;
     60            }
     61            else
     62            {
     63              RTC->CRH &= (u16)~RTC_IT;
     64            }
     65          }
     66          
     67          /*******************************************************************************
     68          * Function Name  : RTC_EnterConfigMode
     69          * Description    : Enters the RTC configuration mode.
     70          * Input          : None
     71          * Output         : None
     72          * Return         : None
     73          *******************************************************************************/
     74          void RTC_EnterConfigMode(void)
     75          {
     76            /* Set the CNF flag to enter in the Configuration Mode */
     77            RTC->CRL |= CRL_CNF_Set;
     78          }
     79          
     80          /*******************************************************************************
     81          * Function Name  : RTC_ExitConfigMode
     82          * Description    : Exits from the RTC configuration mode.
     83          * Input          : None
     84          * Output         : None
     85          * Return         : None
     86          *******************************************************************************/
     87          void RTC_ExitConfigMode(void)
     88          {
     89            /* Reset the CNF flag to exit from the Configuration Mode */
     90            RTC->CRL &= CRL_CNF_Reset;
     91          }
     92          
     93          /*******************************************************************************
     94          * Function Name  : RTC_GetCounter
     95          * Description    : Gets the RTC counter value.
     96          * Input          : None
     97          * Output         : None
     98          * Return         : RTC counter value.
     99          *******************************************************************************/
    100          u32 RTC_GetCounter(void)
    101          {
    102            u16 tmp = 0;
    103            tmp = RTC->CNTL;
    104          
    105            return (((u32)RTC->CNTH << 16 ) | tmp) ;
    106          }
    107          
    108          /*******************************************************************************
    109          * Function Name  : RTC_SetCounter
    110          * Description    : Sets the RTC counter value.
    111          * Input          : - CounterValue: RTC counter new value.
    112          * Output         : None
    113          * Return         : None
    114          *******************************************************************************/
    115          void RTC_SetCounter(u32 CounterValue)
    116          { 
    117            RTC_EnterConfigMode();
    118          
    119            /* Set RTC COUNTER MSB word */
    120            RTC->CNTH = (CounterValue & RTC_MSB_Mask) >> 16;
    121            /* Set RTC COUNTER LSB word */
    122            RTC->CNTL = (CounterValue & RTC_LSB_Mask);
    123          
    124            RTC_ExitConfigMode();
    125          }
    126          
    127          /*******************************************************************************
    128          * Function Name  : RTC_GetPrescaler
    129          * Description    : Gets the RTC prescaler value.
    130          * Input          : None
    131          * Output         : None
    132          * Return         : RTC prescaler value.
    133          *******************************************************************************/
    134          u32 RTC_GetPrescaler(void)
    135          {
    136            u32 tmp = 0x00;
    137          
    138            tmp = ((u32)RTC->PRLH & (u32)0x000F) << 0x10;
    139            tmp |= RTC->PRLL;
    140          
    141            return tmp;
    142          }
    143          
    144          /*******************************************************************************
    145          * Function Name  : RTC_SetPrescaler
    146          * Description    : Sets the RTC prescaler value.
    147          * Input          : - PrescalerValue: RTC prescaler new value.
    148          * Output         : None
    149          * Return         : None
    150          *******************************************************************************/
    151          void RTC_SetPrescaler(u32 PrescalerValue)
    152          {
    153            /* Check the parameters */
    154            assert(IS_RTC_PRESCALER(PrescalerValue));
    155            
    156            RTC_EnterConfigMode();
    157          
    158            /* Set RTC PRESCALER MSB word */
    159            RTC->PRLH = (PrescalerValue & PRLH_MSB_Mask) >> 0x10;
    160            /* Set RTC PRESCALER LSB word */
    161            RTC->PRLL = (PrescalerValue & RTC_LSB_Mask);
    162          
    163            RTC_ExitConfigMode();
    164          }
    165          
    166          /*******************************************************************************
    167          * Function Name  : RTC_SetAlarm
    168          * Description    : Sets the RTC alarm value.
    169          * Input          : - AlarmValue: RTC alarm new value.
    170          * Output         : None
    171          * Return         : None
    172          *******************************************************************************/
    173          void RTC_SetAlarm(u32 AlarmValue)
    174          {  
    175            RTC_EnterConfigMode();
    176          
    177            /* Set the ALARM MSB word */
    178            RTC->ALRH = (AlarmValue & RTC_MSB_Mask) >> 16;

⌨️ 快捷键说明

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