osd-contiki/cpu/stm32w108/hal/micro/micro-common.h

153 lines
4.9 KiB
C
Raw Normal View History

2014-06-19 14:30:33 +02:00
/** @file cpu/stm32w108/hal/micro/micro-common.h
2010-10-25 11:03:38 +02:00
* @brief Minimal Hal functions common across all microcontroller-specific files.
* See @ref micro for documentation.
*
* <!--(C) COPYRIGHT 2010 STMicroelectronics. All rights reserved. -->
*/
2014-06-19 14:30:33 +02:00
/**
* @addtogroup stm32w-cpu
* @{ */
/** @defgroup micro Micro
2010-10-25 11:03:38 +02:00
* Many of the supplied example applications use these microcontroller functions.
* See hal/micro/micro-common.h for source code.
*
*@{
*/
#ifndef MICRO_COMMON_H_
#define MICRO_COMMON_H_
2010-10-25 11:03:38 +02:00
2011-03-21 13:11:52 +01:00
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#ifndef __STSTATUS_TYPE__
#define __STSTATUS_TYPE__
//This is necessary here because halSleepForQsWithOptions returns an
//StStatus and not adding this typedef to this file breaks a
//whole lot of builds.
typedef uint8_t StStatus;
2011-03-21 13:11:52 +01:00
#endif //__STSTATUS_TYPE__
#endif // DOXYGEN_SHOULD_SKIP_THIS
2010-10-25 11:03:38 +02:00
/** @brief Initializes microcontroller-specific peripherals.
*/
void halInit(void);
/** @brief Restarts the microcontroller and therefore everything else.
*/
void halReboot(void);
/** @brief Powers up microcontroller peripherals and board peripherals.
*/
void halPowerUp(void);
/** @brief Powers down microcontroller peripherals and board peripherals.
*/
void halPowerDown(void);
2014-06-19 14:28:13 +02:00
/** @brief The value that must be passed as the single parameter to
* ::halInternalDisableWatchDog() in order to sucessfully disable the watchdog
2010-10-25 11:03:38 +02:00
* timer.
2014-06-19 14:28:13 +02:00
*/
2010-10-25 11:03:38 +02:00
#define MICRO_DISABLE_WATCH_DOG_KEY 0xA5
/** @brief Enables the watchdog timer.
*/
void halInternalEnableWatchDog(void);
/** @brief Disables the watchdog timer.
*
2014-06-19 14:28:13 +02:00
* @note To prevent the watchdog from being disabled accidentally,
2010-10-25 11:03:38 +02:00
* a magic key must be provided.
2014-06-19 14:28:13 +02:00
*
2010-10-25 11:03:38 +02:00
* @param magicKey A value (::MICRO_DISABLE_WATCH_DOG_KEY) that enables the function.
*/
void halInternalDisableWatchDog(uint8_t magicKey);
2010-10-25 11:03:38 +02:00
/** @brief Determines whether the watchdog has been enabled or disabled.
*
* @return A boolean value indicating if the watchdog is current enabled.
*/
boolean halInternalWatchDogEnabled( void );
#ifdef DOXYGEN_SHOULD_SKIP_THIS
/** @brief Enumerations for the possible microcontroller sleep modes.
* - SLEEPMODE_RUNNING
* Everything is active and running. In practice this mode is not
* used, but it is defined for completeness of information.
* - SLEEPMODE_IDLE
* Only the CPU is idled. The rest of the chip continues runing
* normally. The chip will wake from any interrupt.
* - SLEEPMODE_WAKETIMER
* The sleep timer clock sources remain running. The RC is always
* running and the 32kHz XTAL depends on the board header. Wakeup
* is possible from both GPIO and the sleep timer. System time
* is maintained. The sleep timer is assumed to be configured
* properly for wake events.
* - SLEEPMODE_MAINTAINTIMER
* The sleep timer clock sources remain running. The RC is always
* running and the 32kHz XTAL depends on the board header. Wakeup
* is possible from only GPIO. System time is maintained.
* - SLEEPMODE_NOTIMER
* The sleep timer clock sources (both RC and XTAL) are turned off.
* Wakeup is possible from only GPIO. System time is lost.
*/
enum SleepModes
#else
typedef uint8_t SleepModes;
2010-10-25 11:03:38 +02:00
enum
#endif
{
SLEEPMODE_RUNNING = 0,
SLEEPMODE_IDLE = 1,
SLEEPMODE_WAKETIMER = 2,
SLEEPMODE_MAINTAINTIMER = 3,
SLEEPMODE_NOTIMER = 4,
};
/** @brief Blocks the current thread of execution for the specified
* amount of time, in microseconds.
*
* The function is implemented with cycle-counted busy loops
* and is intended to create the short delays required when interfacing with
* hardware peripherals.
*
* The accuracy of the timing provided by this function is not specified,
* but a general rule is that when running off of a crystal oscillator it will
* be within 10us. If the micro is running off of another type of oscillator
* (e.g. RC) the timing accuracy will potentially be much worse.
*
2014-06-19 14:28:13 +02:00
* @param us The specified time, in microseconds.
2010-10-25 11:03:38 +02:00
Values should be between 1 and 65535 microseconds.
*/
void halCommonDelayMicroseconds(uint16_t us);
2010-10-25 11:03:38 +02:00
2011-03-21 13:11:52 +01:00
/** @brief Request the appplication to enter in bootloader mode
*
* This function will check whwther the user flash contains the bootloader
* and if yes it will jump into it according to the user parameters.
2014-06-19 14:28:13 +02:00
*
2011-03-21 13:11:52 +01:00
*
* @param mode The bootloader mode, 0 UART mode, 1 RF mode. All other
* values are reserved
* @param channel The channel where the booloader will operate. 0 means
* default channel (only vaild for RF mode).
* @param panID The panID where the booloader will operate. 0xFFFF means
* default panID (only vaild for RF mode).
* @return An error code or it will never return.
*/
StStatus halBootloaderStart(uint8_t mode, uint8_t channel, uint16_t panId);
2011-03-21 13:11:52 +01:00
#ifdef CORTEXM3_STM32F103
#include "micro/cortexm3/stm32f103ret/micro-specific.h"
#endif
#ifdef CORTEXM3_STM32W108
#include "micro/cortexm3/micro-common.h"
#endif
2010-10-25 11:03:38 +02:00
#endif //MICRO_COMMON_H_
2010-10-25 11:03:38 +02:00
/** @} END micro group */
/** @} */
2014-06-19 14:28:13 +02:00