Contiki 2.5
micro-common.h
1 /** @file micro-common.h
2  * @brief Minimal Hal functions common across all microcontroller-specific files.
3  * See @ref micro for documentation.
4  *
5  * <!--(C) COPYRIGHT 2010 STMicroelectronics. All rights reserved. -->
6  */
7 
8 /** @addtogroup micro
9  * Many of the supplied example applications use these microcontroller functions.
10  * See hal/micro/micro-common.h for source code.
11  *
12  *@{
13  */
14 
15 #ifndef __MICRO_COMMON_H__
16 #define __MICRO_COMMON_H__
17 
18 #ifndef DOXYGEN_SHOULD_SKIP_THIS
19 #ifndef __STSTATUS_TYPE__
20 #define __STSTATUS_TYPE__
21  //This is necessary here because halSleepForQsWithOptions returns an
22  //StStatus and not adding this typedef to this file breaks a
23  //whole lot of builds.
24  typedef int8u StStatus;
25 #endif //__STSTATUS_TYPE__
26 #endif // DOXYGEN_SHOULD_SKIP_THIS
27 
28 /** @brief Initializes microcontroller-specific peripherals.
29 */
30 void halInit(void);
31 
32 /** @brief Restarts the microcontroller and therefore everything else.
33 */
34 void halReboot(void);
35 
36 /** @brief Powers up microcontroller peripherals and board peripherals.
37 */
38 void halPowerUp(void);
39 
40 /** @brief Powers down microcontroller peripherals and board peripherals.
41 */
42 void halPowerDown(void);
43 
44 /** @brief The value that must be passed as the single parameter to
45  * ::halInternalDisableWatchDog() in order to sucessfully disable the watchdog
46  * timer.
47  */
48 #define MICRO_DISABLE_WATCH_DOG_KEY 0xA5
49 
50 /** @brief Enables the watchdog timer.
51  */
52 void halInternalEnableWatchDog(void);
53 
54 /** @brief Disables the watchdog timer.
55  *
56  * @note To prevent the watchdog from being disabled accidentally,
57  * a magic key must be provided.
58  *
59  * @param magicKey A value (::MICRO_DISABLE_WATCH_DOG_KEY) that enables the function.
60  */
61 void halInternalDisableWatchDog(int8u magicKey);
62 
63 /** @brief Determines whether the watchdog has been enabled or disabled.
64  *
65  * @return A boolean value indicating if the watchdog is current enabled.
66  */
67 boolean halInternalWatchDogEnabled( void );
68 
69 #ifdef DOXYGEN_SHOULD_SKIP_THIS
70 /** @brief Enumerations for the possible microcontroller sleep modes.
71  * - SLEEPMODE_RUNNING
72  * Everything is active and running. In practice this mode is not
73  * used, but it is defined for completeness of information.
74  * - SLEEPMODE_IDLE
75  * Only the CPU is idled. The rest of the chip continues runing
76  * normally. The chip will wake from any interrupt.
77  * - SLEEPMODE_WAKETIMER
78  * The sleep timer clock sources remain running. The RC is always
79  * running and the 32kHz XTAL depends on the board header. Wakeup
80  * is possible from both GPIO and the sleep timer. System time
81  * is maintained. The sleep timer is assumed to be configured
82  * properly for wake events.
83  * - SLEEPMODE_MAINTAINTIMER
84  * The sleep timer clock sources remain running. The RC is always
85  * running and the 32kHz XTAL depends on the board header. Wakeup
86  * is possible from only GPIO. System time is maintained.
87  * - SLEEPMODE_NOTIMER
88  * The sleep timer clock sources (both RC and XTAL) are turned off.
89  * Wakeup is possible from only GPIO. System time is lost.
90  */
91 enum SleepModes
92 #else
93 typedef int8u SleepModes;
94 enum
95 #endif
96 {
97  SLEEPMODE_RUNNING = 0,
98  SLEEPMODE_IDLE = 1,
99  SLEEPMODE_WAKETIMER = 2,
100  SLEEPMODE_MAINTAINTIMER = 3,
101  SLEEPMODE_NOTIMER = 4,
102 };
103 
104 /** @brief Blocks the current thread of execution for the specified
105  * amount of time, in microseconds.
106  *
107  * The function is implemented with cycle-counted busy loops
108  * and is intended to create the short delays required when interfacing with
109  * hardware peripherals.
110  *
111  * The accuracy of the timing provided by this function is not specified,
112  * but a general rule is that when running off of a crystal oscillator it will
113  * be within 10us. If the micro is running off of another type of oscillator
114  * (e.g. RC) the timing accuracy will potentially be much worse.
115  *
116  * @param us The specified time, in microseconds.
117  Values should be between 1 and 65535 microseconds.
118  */
119 void halCommonDelayMicroseconds(int16u us);
120 
121 /** @brief Request the appplication to enter in bootloader mode
122  *
123  * This function will check whwther the user flash contains the bootloader
124  * and if yes it will jump into it according to the user parameters.
125  *
126  *
127  * @param mode The bootloader mode, 0 UART mode, 1 RF mode. All other
128  * values are reserved
129  * @param channel The channel where the booloader will operate. 0 means
130  * default channel (only vaild for RF mode).
131  * @param panID The panID where the booloader will operate. 0xFFFF means
132  * default panID (only vaild for RF mode).
133  * @return An error code or it will never return.
134  */
135 StStatus halBootloaderStart(int8u mode, int8u channel, int16u panId);
136 
137 #ifdef CORTEXM3_STM32F103
138 #include "micro/cortexm3/stm32f103ret/micro-specific.h"
139 #endif
140 #ifdef CORTEXM3_STM32W108
142 #endif
143 
144 #endif //__MICRO_COMMON_H__
145 
146 /** @} END micro group */
147