Contiki 2.6
|
00001 /** @file micro-common.h 00002 * @brief Minimal Hal functions common across all microcontroller-specific files. 00003 * See @ref micro for documentation. 00004 * 00005 * <!--(C) COPYRIGHT 2010 STMicroelectronics. All rights reserved. --> 00006 */ 00007 00008 /** @addtogroup micro 00009 * Many of the supplied example applications use these microcontroller functions. 00010 * See hal/micro/micro-common.h for source code. 00011 * 00012 *@{ 00013 */ 00014 00015 #ifndef __MICRO_COMMON_H__ 00016 #define __MICRO_COMMON_H__ 00017 00018 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00019 #ifndef __STSTATUS_TYPE__ 00020 #define __STSTATUS_TYPE__ 00021 //This is necessary here because halSleepForQsWithOptions returns an 00022 //StStatus and not adding this typedef to this file breaks a 00023 //whole lot of builds. 00024 typedef int8u StStatus; 00025 #endif //__STSTATUS_TYPE__ 00026 #endif // DOXYGEN_SHOULD_SKIP_THIS 00027 00028 /** @brief Initializes microcontroller-specific peripherals. 00029 */ 00030 void halInit(void); 00031 00032 /** @brief Restarts the microcontroller and therefore everything else. 00033 */ 00034 void halReboot(void); 00035 00036 /** @brief Powers up microcontroller peripherals and board peripherals. 00037 */ 00038 void halPowerUp(void); 00039 00040 /** @brief Powers down microcontroller peripherals and board peripherals. 00041 */ 00042 void halPowerDown(void); 00043 00044 /** @brief The value that must be passed as the single parameter to 00045 * ::halInternalDisableWatchDog() in order to sucessfully disable the watchdog 00046 * timer. 00047 */ 00048 #define MICRO_DISABLE_WATCH_DOG_KEY 0xA5 00049 00050 /** @brief Enables the watchdog timer. 00051 */ 00052 void halInternalEnableWatchDog(void); 00053 00054 /** @brief Disables the watchdog timer. 00055 * 00056 * @note To prevent the watchdog from being disabled accidentally, 00057 * a magic key must be provided. 00058 * 00059 * @param magicKey A value (::MICRO_DISABLE_WATCH_DOG_KEY) that enables the function. 00060 */ 00061 void halInternalDisableWatchDog(int8u magicKey); 00062 00063 /** @brief Determines whether the watchdog has been enabled or disabled. 00064 * 00065 * @return A boolean value indicating if the watchdog is current enabled. 00066 */ 00067 boolean halInternalWatchDogEnabled( void ); 00068 00069 #ifdef DOXYGEN_SHOULD_SKIP_THIS 00070 /** @brief Enumerations for the possible microcontroller sleep modes. 00071 * - SLEEPMODE_RUNNING 00072 * Everything is active and running. In practice this mode is not 00073 * used, but it is defined for completeness of information. 00074 * - SLEEPMODE_IDLE 00075 * Only the CPU is idled. The rest of the chip continues runing 00076 * normally. The chip will wake from any interrupt. 00077 * - SLEEPMODE_WAKETIMER 00078 * The sleep timer clock sources remain running. The RC is always 00079 * running and the 32kHz XTAL depends on the board header. Wakeup 00080 * is possible from both GPIO and the sleep timer. System time 00081 * is maintained. The sleep timer is assumed to be configured 00082 * properly for wake events. 00083 * - SLEEPMODE_MAINTAINTIMER 00084 * The sleep timer clock sources remain running. The RC is always 00085 * running and the 32kHz XTAL depends on the board header. Wakeup 00086 * is possible from only GPIO. System time is maintained. 00087 * - SLEEPMODE_NOTIMER 00088 * The sleep timer clock sources (both RC and XTAL) are turned off. 00089 * Wakeup is possible from only GPIO. System time is lost. 00090 */ 00091 enum SleepModes 00092 #else 00093 typedef int8u SleepModes; 00094 enum 00095 #endif 00096 { 00097 SLEEPMODE_RUNNING = 0, 00098 SLEEPMODE_IDLE = 1, 00099 SLEEPMODE_WAKETIMER = 2, 00100 SLEEPMODE_MAINTAINTIMER = 3, 00101 SLEEPMODE_NOTIMER = 4, 00102 }; 00103 00104 /** @brief Blocks the current thread of execution for the specified 00105 * amount of time, in microseconds. 00106 * 00107 * The function is implemented with cycle-counted busy loops 00108 * and is intended to create the short delays required when interfacing with 00109 * hardware peripherals. 00110 * 00111 * The accuracy of the timing provided by this function is not specified, 00112 * but a general rule is that when running off of a crystal oscillator it will 00113 * be within 10us. If the micro is running off of another type of oscillator 00114 * (e.g. RC) the timing accuracy will potentially be much worse. 00115 * 00116 * @param us The specified time, in microseconds. 00117 Values should be between 1 and 65535 microseconds. 00118 */ 00119 void halCommonDelayMicroseconds(int16u us); 00120 00121 /** @brief Request the appplication to enter in bootloader mode 00122 * 00123 * This function will check whwther the user flash contains the bootloader 00124 * and if yes it will jump into it according to the user parameters. 00125 * 00126 * 00127 * @param mode The bootloader mode, 0 UART mode, 1 RF mode. All other 00128 * values are reserved 00129 * @param channel The channel where the booloader will operate. 0 means 00130 * default channel (only vaild for RF mode). 00131 * @param panID The panID where the booloader will operate. 0xFFFF means 00132 * default panID (only vaild for RF mode). 00133 * @return An error code or it will never return. 00134 */ 00135 StStatus halBootloaderStart(int8u mode, int8u channel, int16u panId); 00136 00137 #ifdef CORTEXM3_STM32F103 00138 #include "micro/cortexm3/stm32f103ret/micro-specific.h" 00139 #endif 00140 #ifdef CORTEXM3_STM32W108 00141 #include "micro/cortexm3/micro-common.h" 00142 #endif 00143 00144 #endif //__MICRO_COMMON_H__ 00145 00146 /** @} END micro group */ 00147