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 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 /** @brief Enumerations for the possible microcontroller sleep modes.
74  */
75 #ifdef DOXYGEN_SHOULD_SKIP_THIS
77 #else
78 typedef uint8_t SleepModes;
79 enum
80 #endif
81 {
82  /**
83  * Everything is active and running. In practice this mode is not
84  * used, but it is defined for completeness of information.
85  */
87  /**
88  * Oly the CPU is idled. The rest of the chip continues runing
89  * normally. The chip will wake from any interrupt.
90  */
92  /**
93  * The sleep timer clock sources remain running. The RC is always
94  * running and the 32kHz XTAL depends on the board header. Wakeup
95  * is possible from both GPIO and the sleep timer. System time
96  * is maintained. The sleep timer is assumed to be configured
97  * properly for wake events.
98  */
100  /**
101  * The sleep timer clock sources remain running. The RC is always
102  * running and the 32kHz XTAL depends on the board header. Wakeup
103  * is possible from only GPIO. System time is maintained.
104  */
106  /**
107  * The sleep timer clock sources (both RC and XTAL) are turned off.
108  * Wakeup is possible from only GPIO. System time is lost.
109  */
111 };
112 
113 /** @brief Blocks the current thread of execution for the specified
114  * amount of time, in microseconds.
115  *
116  * The function is implemented with cycle-counted busy loops
117  * and is intended to create the short delays required when interfacing with
118  * hardware peripherals.
119  *
120  * The accuracy of the timing provided by this function is not specified,
121  * but a general rule is that when running off of a crystal oscillator it will
122  * be within 10us. If the micro is running off of another type of oscillator
123  * (e.g. RC) the timing accuracy will potentially be much worse.
124  *
125  * @param us The specified time, in microseconds.
126  Values should be between 1 and 65535 microseconds.
127  */
128 void halCommonDelayMicroseconds(uint16_t us);
129 
130 /** @brief Request the appplication to enter in bootloader mode
131  *
132  * This function will check whwther the user flash contains the bootloader
133  * and if yes it will jump into it according to the user parameters.
134  *
135  *
136  * @param mode The bootloader mode, 0 UART mode, 1 RF mode. All other
137  * values are reserved
138  * @param channel The channel where the booloader will operate. 0 means
139  * default channel (only vaild for RF mode).
140  * @param panID The panID where the booloader will operate. 0xFFFF means
141  * default panID (only vaild for RF mode).
142  * @return An error code or it will never return.
143  */
144 StStatus halBootloaderStart(uint8_t mode, uint8_t channel, uint16_t panID);
145 
146 #ifdef CORTEXM3_STM32F103
147 #include "micro/cortexm3/stm32f103ret/micro-specific.h"
148 #endif
149 #ifdef CORTEXM3_STM32W108
151 #endif
152 
153 #endif //MICRO_COMMON_H_
154 
155 /** @} END micro group */
156 /** @} */
The sleep timer clock sources (both RC and XTAL) are turned off.
Definition: micro-common.h:110
Oly the CPU is idled.
Definition: micro-common.h:91
StStatus halBootloaderStart(uint8_t mode, uint8_t channel, uint16_t panID)
Request the appplication to enter in bootloader mode.
Definition: micro.c:130
void halInit(void)
Initializes microcontroller-specific peripherals.
Definition: micro.c:23
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 halPowerUp(void)
Powers up microcontroller peripherals and board peripherals.
Definition: micro.c:65
void halInternalDisableWatchDog(uint8_t magicKey)
Disables the watchdog timer.
Definition: micro-common.c:31
The sleep timer clock sources remain running.
Definition: micro-common.h:105
boolean halInternalWatchDogEnabled(void)
Determines whether the watchdog has been enabled or disabled.
Definition: micro-common.c:39
void halCommonDelayMicroseconds(uint16_t us)
Blocks the current thread of execution for the specified amount of time, in microseconds.
The sleep timer clock sources remain running.
Definition: micro-common.h:99
void halReboot(void)
Restarts the microcontroller and therefore everything else.
Definition: micro.c:43
SleepModes
Enumerations for the possible microcontroller sleep modes.
Definition: micro-common.h:76
Everything is active and running.
Definition: micro-common.h:86
uint8_t StStatus
Return type for St functions.
Definition: error.h:18