Contiki 2.5
stm32w_systick.h
1 /******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
2 * File Name : stm32f10x_systick.h
3 * Author : MCD Application Team
4 * Version : V2.0.3
5 * Date : 09/22/2008
6 * Description : This file contains all the functions prototypes for the
7 * SysTick firmware library.
8 ********************************************************************************
9 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
10 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
11 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
12 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
13 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
14 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
15 *******************************************************************************/
16 
17 /* Define to prevent recursive inclusion -------------------------------------*/
18 #ifndef __STM32W_SYSTICK_H
19 #define __STM32W_SYSTICK_H
20 
21 #include "stm32w108_type.h"
22 #include "stm32w_conf.h"
23 
24 #ifndef EXT
25  #define EXT extern
26 #endif /* EXT */
27 
28 typedef struct
29 {
30  vu32 CTRL;
31  vu32 LOAD;
32  vu32 VAL;
33  vuc32 CALIB;
34 } SysTick_TypeDef;
35 
36 /* System Control Space memory map */
37 #define SCS_BASE ((u32)0xE000E000)
38 
39 #define SysTick_BASE (SCS_BASE + 0x0010)
40 #define NVIC_BASE (SCS_BASE + 0x0100)
41 #define SCB_BASE (SCS_BASE + 0x0D00)
42 
43 #ifdef _SysTick
44  #define SysTick ((SysTick_TypeDef *) SysTick_BASE)
45 #endif /*_SysTick */
46 
47 
48 /***************** Bit definition for SysTick_CTRL register *****************/
49 #define SysTick_CTRL_ENABLE ((u32)0x00000001) /* Counter enable */
50 #define SysTick_CTRL_TICKINT ((u32)0x00000002) /* Counting down to 0 pends the SysTick handler */
51 #define SysTick_CTRL_CLKSOURCE ((u32)0x00000004) /* Clock source */
52 #define SysTick_CTRL_COUNTFLAG ((u32)0x00010000) /* Count Flag */
53 
54 
55 /***************** Bit definition for SysTick_LOAD register *****************/
56 #define SysTick_LOAD_RELOAD ((u32)0x00FFFFFF) /* Value to load into the SysTick Current Value Register when the counter reaches 0 */
57 
58 
59 /***************** Bit definition for SysTick_VAL register ******************/
60 #define SysTick_VAL_CURRENT ((u32)0x00FFFFFF) /* Current value at the time the register is accessed */
61 
62 
63 /***************** Bit definition for SysTick_CALIB register ****************/
64 #define SysTick_CALIB_TENMS ((u32)0x00FFFFFF) /* Reload value to use for 10ms timing */
65 #define SysTick_CALIB_SKEW ((u32)0x40000000) /* Calibration value is not exactly 10 ms */
66 #define SysTick_CALIB_NOREF ((u32)0x80000000) /* The reference clock is not provided */
67 
68 
69 /* Exported types ------------------------------------------------------------*/
70 /* Exported constants --------------------------------------------------------*/
71 /* SysTick clock source */
72 #define SysTick_CLKSource_HCLK_Div8 ((u32)0xFFFFFFFB)
73 #define SysTick_CLKSource_HCLK ((u32)0x00000004)
74 
75 #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \
76  ((SOURCE) == SysTick_CLKSource_HCLK_Div8))
77 
78 /* SysTick counter state */
79 #define SysTick_Counter_Disable ((u32)0xFFFFFFFE)
80 #define SysTick_Counter_Enable ((u32)0x00000001)
81 #define SysTick_Counter_Clear ((u32)0x00000000)
82 
83 #define IS_SYSTICK_COUNTER(COUNTER) (((COUNTER) == SysTick_Counter_Disable) || \
84  ((COUNTER) == SysTick_Counter_Enable) || \
85  ((COUNTER) == SysTick_Counter_Clear))
86 
87 /* SysTick Flag */
88 #define SysTick_FLAG_COUNT ((u32)0x00000010)
89 #define SysTick_FLAG_SKEW ((u32)0x0000001E)
90 #define SysTick_FLAG_NOREF ((u32)0x0000001F)
91 
92 #define IS_SYSTICK_FLAG(FLAG) (((FLAG) == SysTick_FLAG_COUNT) || \
93  ((FLAG) == SysTick_FLAG_SKEW) || \
94  ((FLAG) == SysTick_FLAG_NOREF))
95 
96 #define IS_SYSTICK_RELOAD(RELOAD) (((RELOAD) > 0) && ((RELOAD) <= 0xFFFFFF))
97 
98 /* Exported macro ------------------------------------------------------------*/
99 /* Exported functions ------------------------------------------------------- */
100 void SysTick_CLKSourceConfig(u32 SysTick_CLKSource);
101 void SysTick_SetReload(u32 Reload);
102 void SysTick_CounterCmd(u32 SysTick_Counter);
103 void SysTick_ITConfig(FunctionalState NewState);
104 u32 SysTick_GetCounter(void);
105 FlagStatus SysTick_GetFlagStatus(u8 SysTick_FLAG);
106 
107 #endif /* __STM32F10x_SYSTICK_H */
108 
109 /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/