Contiki 2.6

stm32w_systick.h

00001 /******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
00002 * File Name          : stm32f10x_systick.h
00003 * Author             : MCD Application Team
00004 * Version            : V2.0.3
00005 * Date               : 09/22/2008
00006 * Description        : This file contains all the functions prototypes for the
00007 *                      SysTick firmware library.
00008 ********************************************************************************
00009 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00010 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
00011 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
00012 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
00013 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
00014 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00015 *******************************************************************************/
00016 
00017 /* Define to prevent recursive inclusion -------------------------------------*/
00018 #ifndef __STM32W_SYSTICK_H
00019 #define __STM32W_SYSTICK_H
00020 
00021 #include "stm32w108_type.h"
00022 #include "stm32w_conf.h"
00023 
00024 #ifndef EXT
00025   #define EXT extern
00026 #endif /* EXT */
00027 
00028 typedef struct
00029 {
00030   vu32 CTRL;
00031   vu32 LOAD;
00032   vu32 VAL;
00033   vuc32 CALIB;
00034 } SysTick_TypeDef;
00035 
00036 /* System Control Space memory map */
00037 #define SCS_BASE              ((u32)0xE000E000)
00038 
00039 #define SysTick_BASE          (SCS_BASE + 0x0010)
00040 #define NVIC_BASE             (SCS_BASE + 0x0100)
00041 #define SCB_BASE              (SCS_BASE + 0x0D00)
00042 
00043 #ifdef _SysTick
00044   #define SysTick             ((SysTick_TypeDef *) SysTick_BASE)
00045 #endif /*_SysTick */
00046 
00047 
00048 /*****************  Bit definition for SysTick_CTRL register  *****************/
00049 #define  SysTick_CTRL_ENABLE                 ((u32)0x00000001)        /* Counter enable */
00050 #define  SysTick_CTRL_TICKINT                ((u32)0x00000002)        /* Counting down to 0 pends the SysTick handler */
00051 #define  SysTick_CTRL_CLKSOURCE              ((u32)0x00000004)        /* Clock source */
00052 #define  SysTick_CTRL_COUNTFLAG              ((u32)0x00010000)        /* Count Flag */
00053 
00054 
00055 /*****************  Bit definition for SysTick_LOAD register  *****************/
00056 #define  SysTick_LOAD_RELOAD                 ((u32)0x00FFFFFF)        /* Value to load into the SysTick Current Value Register when the counter reaches 0 */
00057 
00058 
00059 /*****************  Bit definition for SysTick_VAL register  ******************/
00060 #define  SysTick_VAL_CURRENT                 ((u32)0x00FFFFFF)        /* Current value at the time the register is accessed */
00061 
00062 
00063 /*****************  Bit definition for SysTick_CALIB register  ****************/
00064 #define  SysTick_CALIB_TENMS                 ((u32)0x00FFFFFF)        /* Reload value to use for 10ms timing */
00065 #define  SysTick_CALIB_SKEW                  ((u32)0x40000000)        /* Calibration value is not exactly 10 ms */
00066 #define  SysTick_CALIB_NOREF                 ((u32)0x80000000)        /* The reference clock is not provided */
00067 
00068 
00069 /* Exported types ------------------------------------------------------------*/
00070 /* Exported constants --------------------------------------------------------*/
00071 /* SysTick clock source */
00072 #define SysTick_CLKSource_HCLK_Div8    ((u32)0xFFFFFFFB)
00073 #define SysTick_CLKSource_HCLK         ((u32)0x00000004)
00074 
00075 #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \
00076                                        ((SOURCE) == SysTick_CLKSource_HCLK_Div8))
00077 
00078 /* SysTick counter state */
00079 #define SysTick_Counter_Disable        ((u32)0xFFFFFFFE)
00080 #define SysTick_Counter_Enable         ((u32)0x00000001)
00081 #define SysTick_Counter_Clear          ((u32)0x00000000)
00082 
00083 #define IS_SYSTICK_COUNTER(COUNTER) (((COUNTER) == SysTick_Counter_Disable) || \
00084                                      ((COUNTER) == SysTick_Counter_Enable)  || \
00085                                      ((COUNTER) == SysTick_Counter_Clear))
00086 
00087 /* SysTick Flag */
00088 #define SysTick_FLAG_COUNT             ((u32)0x00000010)
00089 #define SysTick_FLAG_SKEW              ((u32)0x0000001E)
00090 #define SysTick_FLAG_NOREF             ((u32)0x0000001F)
00091 
00092 #define IS_SYSTICK_FLAG(FLAG) (((FLAG) == SysTick_FLAG_COUNT) || \
00093                                ((FLAG) == SysTick_FLAG_SKEW)  || \
00094                                ((FLAG) == SysTick_FLAG_NOREF))
00095 
00096 #define IS_SYSTICK_RELOAD(RELOAD) (((RELOAD) > 0) && ((RELOAD) <= 0xFFFFFF))
00097 
00098 /* Exported macro ------------------------------------------------------------*/
00099 /* Exported functions ------------------------------------------------------- */
00100 void SysTick_CLKSourceConfig(u32 SysTick_CLKSource);
00101 void SysTick_SetReload(u32 Reload);
00102 void SysTick_CounterCmd(u32 SysTick_Counter);
00103 void SysTick_ITConfig(FunctionalState NewState);
00104 u32 SysTick_GetCounter(void);
00105 FlagStatus SysTick_GetFlagStatus(u8 SysTick_FLAG);
00106 
00107 #endif /* __STM32F10x_SYSTICK_H */
00108 
00109 /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/