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