board.h

Go to the documentation of this file.
00001 /** @file board.h
00002  * @brief Header file x STM32W108 Kits boards abstraction.
00003  * See @ref board for documentation.
00004  *
00005  *
00006  * See hal/micro/cortexm3/stm32w108/board.h for source code.
00007  *
00008  * <!--(C) COPYRIGHT 2010 STMicroelectronics. All rights reserved.        -->
00009  */
00010 #ifndef _BOARD_H_
00011 #define _BOARD_H_
00012 
00013 /** @addtogroup board
00014  * @brief ST board abstraction layer
00015  *
00016  * This header defines API and data structures to handle ST boards with thei associated resources
00017  * on algorithm behavior.
00018  * See hal/micro/cortexm3/stm32w108/board.h for source code.
00019  *@{
00020  */
00021  
00022 /**
00023  * @brief Define the number of LEDs in the specific board revision
00024  */
00025 #define LEDS_MB851A 2
00026 /**
00027  * @brief Define the number of LEDs in the specific board revision
00028  */
00029 #define LEDS_MB851B 2
00030 /**
00031  * @brief Define the number of LEDs in the specific board revision
00032  */
00033 #define LEDS_MB851C 2
00034 /**
00035  * @brief Define the number of LEDs in the specific board revision
00036  */
00037 #define LEDS_MB954A 2
00038 /**
00039  * @brief Define the number of LEDs in the specific board revision
00040  */
00041 #define LEDS_MB954B 2
00042 /**
00043  * @brief Define the number of LEDs in the specific board revision
00044  */
00045 #define LEDS_MB950A 2
00046 /**
00047  * @brief Define the number of LEDs in the specific board revision
00048  */
00049 #define LEDS_MB951A 2
00050 
00051 /**
00052  * @brief Define the number of user buttons in the specific board revision
00053  */
00054 #define BUTTONS_MB851A 1
00055 /**
00056  * @brief Define the number of user buttons in the specific board revision
00057  */
00058 #define BUTTONS_MB851B 1
00059 /**
00060  * @brief Define the number of user buttons in the specific board revision
00061  */
00062 #define BUTTONS_MB851C 1
00063 /**
00064  * @brief Define the number of user buttons in the specific board revision
00065  */
00066 #define BUTTONS_MB954A 1
00067 /**
00068  * @brief Define the number of user buttons in the specific board revision
00069  */
00070 #define BUTTONS_MB954B 1
00071 /**
00072  * @brief Define the number of user buttons in the specific board revision
00073  */
00074 #define BUTTONS_MB950A 5
00075 /**
00076  * @brief Define the number of user buttons in the specific board revision
00077  */
00078 #define BUTTONS_MB951A 0
00079 
00080 /**
00081  * @brief Data structure for led description
00082  */
00083 typedef struct LedResourceStruct {
00084   /** Name of the LED as printed in the board */
00085   char *name;
00086   /** GPIO port associated with the LED */
00087   int8u    gpioPort;
00088   /** GPIO pin associated with the LED */
00089   int8u    gpioPin;
00090 } LedResourceType;
00091 
00092 typedef LedResourceType InfraRedLedResourceType;
00093 
00094 /**
00095  * @brief Data structure for button description
00096  */
00097 typedef struct ButtonResourceStruct {
00098   /** Name of the button as printed in the board */
00099   char *name;
00100   /** GPIO port associated with the button */
00101   int8u    gpioPort;
00102   /** GPIO pin associated with the button */
00103   int8u    gpioPin;
00104 } ButtonResourceType;
00105 
00106 /**
00107  * @brief Data structure for MEMS description
00108  */
00109 typedef struct MemsResourceStruct {
00110   /** Name of the MEMS device */
00111   char *name;
00112   /** Serial communication port associated with the MEMS */
00113   int8u    scPort;
00114 } MemsResourceType;
00115 
00116 /**
00117  * @brief Data structure for temperature sensor description
00118  */
00119 typedef struct TempSensorResourceStruct {
00120   /** Name of the temperature sensor device */
00121   char *name;
00122   /** GPIO port associated with the sensor */
00123   int8u    gpioPort;
00124   /** GPIO pin associated with the sensor */
00125   int8u    gpioPin;
00126   /** Flag to indicate whether the ADC range extension bug fix is implemented */
00127   boolean  adcFix;
00128 } TempSensorResourceType;
00129 
00130 /**
00131  * @brief Data structure for board user I/O
00132  */
00133 typedef struct BoardIOStruct {
00134   /** Pointer to LED resources */
00135   const LedResourceType *leds;
00136   /** Pointer to button resources */
00137   const ButtonResourceType *buttons;  
00138 } BoardIOType;
00139 
00140 /**
00141  * @brief Flag to indicate if MEMS is present
00142  */
00143 #define BOARD_HAS_MEMS        (1 << 0)
00144 /**
00145  * @brief Flag to indicate if temeprature sensor is present
00146  */
00147 #define BOARD_HAS_TEMP_SENSOR (1 << 1)
00148 /**
00149  * @brief Flag to indicate if external power amplifier is present
00150  */
00151 #define BOARD_HAS_PA          (1 << 2)
00152 /**
00153  * @brief Flag to indicate if EEPROM is present
00154  */
00155 #define BOARD_HAS_EEPROM      (1 << 3)
00156 /**
00157  * @brief Flag to indicate if FTDI is used as PC interface
00158  */
00159 #define BOARD_HAS_FTDI        (1 << 4)
00160 /**
00161  * @brief Flag to indicate if STM32F is used as PC interface
00162  */
00163 #define BOARD_HAS_STM32F      (1 << 5)
00164 
00165 /**
00166  * @brief Data structure describing board features
00167  */
00168 typedef struct BoardResourcesStruct {
00169   const char *name;
00170   const int32u flags;
00171   /** Number of buttons */
00172   int8u    buttons;
00173   /** Number of leds */
00174   int8u    leds;
00175   /** Board I/O description */
00176   const BoardIOType *io;
00177   /** Board infrared led description */
00178   const InfraRedLedResourceType* infraredLed;
00179   /** Board infrared MEMS description */
00180   const MemsResourceType *mems;
00181   /** Board infrared temeprature sensor description */
00182   const TempSensorResourceType *temperatureSensor;
00183 } BoardResourcesType;
00184 
00185 extern BoardResourcesType const *boardDescription;
00186 
00187 // Generic definitions
00188 #define GPIO_PxCLR_BASE (GPIO_PACLR_ADDR)
00189 #define GPIO_PxSET_BASE (GPIO_PASET_ADDR)
00190 #define GPIO_PxOUT_BASE (GPIO_PAOUT_ADDR)
00191 #define GPIO_PxIN_BASE  (GPIO_PAIN_ADDR)
00192 // Each port is offset from the previous port by the same amount
00193 #define GPIO_Px_OFFSET  (GPIO_PBCFGL_ADDR-GPIO_PACFGL_ADDR)
00194 
00195 
00196 /* leds definitions */
00197 #define LED_D1 PORTx_PIN(boardDescription->io->leds[0].gpioPort, boardDescription->io->leds[0].gpioPin)  //PORTB_PIN(6)
00198 #define LED_D3 PORTx_PIN(boardDescription->io->leds[1].gpioPort, boardDescription->io->leds[1].gpioPin) // PORTB_PIN(5)
00199 #define DUMMY_LED 0xff
00200 
00201 
00202 /** Description buttons definition */
00203 #define BUTTON_Sn(n) (PORTx_PIN(boardDescription->io->buttons[n].gpioPort, boardDescription->io->buttons[n].gpioPin))
00204 #define BUTTON_Sn_WAKE_SOURCE(n) (1 << ((boardDescription->io->buttons[n].gpioPin) + (8 * (boardDescription->io->buttons[n].gpioPort >> 3))))
00205 #define BUTTON_INPUT_GPIO(port) *((volatile int32u *) (GPIO_PxIN_BASE + GPIO_Px_OFFSET * port))
00206 #define DUMMY_BUTTON 0xff
00207 
00208 #define BUTTON_S1 (boardDescription->buttons>0 ? BUTTON_Sn(0): DUMMY_BUTTON)
00209 #define BUTTON_S2 (boardDescription->buttons>1 ? BUTTON_Sn(1): DUMMY_BUTTON)
00210 #define BUTTON_S3 (boardDescription->buttons>2 ? BUTTON_Sn(2): DUMMY_BUTTON)
00211 #define BUTTON_S4 (boardDescription->buttons>3 ? BUTTON_Sn(3): DUMMY_BUTTON)
00212 #define BUTTON_S5 (boardDescription->buttons>4 ? BUTTON_Sn(4): DUMMY_BUTTON)
00213 
00214 #define BUTTON_S1_WAKE_SOURCE (boardDescription->buttons>0 ? BUTTON_Sn_WAKE_SOURCE(0): 0)
00215 #define BUTTON_S2_WAKE_SOURCE (boardDescription->buttons>1 ? BUTTON_Sn_WAKE_SOURCE(1): 0)
00216 #define BUTTON_S3_WAKE_SOURCE (boardDescription->buttons>2 ? BUTTON_Sn_WAKE_SOURCE(2): 0)
00217 #define BUTTON_S4_WAKE_SOURCE (boardDescription->buttons>3 ? BUTTON_Sn_WAKE_SOURCE(3): 0)
00218 #define BUTTON_S5_WAKE_SOURCE (boardDescription->buttons>4 ? BUTTON_Sn_WAKE_SOURCE(4): 0)
00219 
00220 /** Description uart definition */
00221 #define UART_TX PORTB_PIN(1)
00222 #define UART_RX PORTB_PIN(2)
00223 #define UART_RX_WAKE_SOURCE   0x00000400
00224 
00225 /** Description temperature sensor GPIO */
00226 #define TEMPERATURE_SENSOR_GPIO  PORTx_PIN(boardDescription->temperatureSensor->gpioPort, boardDescription->temperatureSensor->gpioPin) // PORTB_PIN(7)
00227 
00228 /** @brief Return pointer to board description structure
00229  *
00230  * 
00231  * @return Pointer to board description structure
00232  */
00233 BoardResourcesType const *halBoardGetDescription(void);
00234 /**
00235  * @brief Initialize the board description data structure after
00236  *        autodetect of the boards based on the CIB Board name field
00237  *        content. In case of invalid CIB data it will default to MB851A.
00238  *        Customer normally needs to modify this file to adapt it to their specific board.
00239  */
00240 void halBoardInit(void);
00241 /**
00242  * @brief Perform board specific action to power up the system.
00243  *        This code depends on the actual board features and configure
00244  *        the stm32w and on board devices for proper operation.
00245  *        Customer normally needs to modify this file to adapt it to their specific board.
00246  */
00247 void halBoardPowerUp(void);
00248 /**
00249  * @brief Perform board specific action to power down the system, usually before going to deep sleep.
00250  *        This code depends on the actual board features and configure
00251  *        the stm32w and on board devices for minimal power consumption.
00252  *        Customer normally needs to modify this file to adapt it to their specific board.
00253  */
00254 void halBoardPowerDown(void);
00255 
00256 #endif /* _BOARD_H_ */
00257 
00258 /** @} // END addtogroup
00259  */

Generated on Mon Apr 11 14:23:40 2011 for Contiki 2.5 by  doxygen 1.6.1