board.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _BOARD_H_
00011 #define _BOARD_H_
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #define LEDS_MB851A 2
00026
00027
00028
00029 #define LEDS_MB851B 2
00030
00031
00032
00033 #define LEDS_MB851C 2
00034
00035
00036
00037 #define LEDS_MB954A 2
00038
00039
00040
00041 #define LEDS_MB954B 2
00042
00043
00044
00045 #define LEDS_MB950A 2
00046
00047
00048
00049 #define LEDS_MB951A 2
00050
00051
00052
00053
00054 #define BUTTONS_MB851A 1
00055
00056
00057
00058 #define BUTTONS_MB851B 1
00059
00060
00061
00062 #define BUTTONS_MB851C 1
00063
00064
00065
00066 #define BUTTONS_MB954A 1
00067
00068
00069
00070 #define BUTTONS_MB954B 1
00071
00072
00073
00074 #define BUTTONS_MB950A 5
00075
00076
00077
00078 #define BUTTONS_MB951A 0
00079
00080
00081
00082
00083 typedef struct LedResourceStruct {
00084
00085 char *name;
00086
00087 int8u gpioPort;
00088
00089 int8u gpioPin;
00090 } LedResourceType;
00091
00092 typedef LedResourceType InfraRedLedResourceType;
00093
00094
00095
00096
00097 typedef struct ButtonResourceStruct {
00098
00099 char *name;
00100
00101 int8u gpioPort;
00102
00103 int8u gpioPin;
00104 } ButtonResourceType;
00105
00106
00107
00108
00109 typedef struct MemsResourceStruct {
00110
00111 char *name;
00112
00113 int8u scPort;
00114 } MemsResourceType;
00115
00116
00117
00118
00119 typedef struct TempSensorResourceStruct {
00120
00121 char *name;
00122
00123 int8u gpioPort;
00124
00125 int8u gpioPin;
00126
00127 boolean adcFix;
00128 } TempSensorResourceType;
00129
00130
00131
00132
00133 typedef struct BoardIOStruct {
00134
00135 const LedResourceType *leds;
00136
00137 const ButtonResourceType *buttons;
00138 } BoardIOType;
00139
00140
00141
00142
00143 #define BOARD_HAS_MEMS (1 << 0)
00144
00145
00146
00147 #define BOARD_HAS_TEMP_SENSOR (1 << 1)
00148
00149
00150
00151 #define BOARD_HAS_PA (1 << 2)
00152
00153
00154
00155 #define BOARD_HAS_EEPROM (1 << 3)
00156
00157
00158
00159 #define BOARD_HAS_FTDI (1 << 4)
00160
00161
00162
00163 #define BOARD_HAS_STM32F (1 << 5)
00164
00165
00166
00167
00168 typedef struct BoardResourcesStruct {
00169 const char *name;
00170 const int32u flags;
00171
00172 int8u buttons;
00173
00174 int8u leds;
00175
00176 const BoardIOType *io;
00177
00178 const InfraRedLedResourceType* infraredLed;
00179
00180 const MemsResourceType *mems;
00181
00182 const TempSensorResourceType *temperatureSensor;
00183 } BoardResourcesType;
00184
00185 extern BoardResourcesType const *boardDescription;
00186
00187
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
00193 #define GPIO_Px_OFFSET (GPIO_PBCFGL_ADDR-GPIO_PACFGL_ADDR)
00194
00195
00196
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
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
00221 #define UART_TX PORTB_PIN(1)
00222 #define UART_RX PORTB_PIN(2)
00223 #define UART_RX_WAKE_SOURCE 0x00000400
00224
00225
00226 #define TEMPERATURE_SENSOR_GPIO PORTx_PIN(boardDescription->temperatureSensor->gpioPort, boardDescription->temperatureSensor->gpioPin) // PORTB_PIN(7)
00227
00228
00229
00230
00231
00232
00233 BoardResourcesType const *halBoardGetDescription(void);
00234
00235
00236
00237
00238
00239
00240 void halBoardInit(void);
00241
00242
00243
00244
00245
00246
00247 void halBoardPowerUp(void);
00248
00249
00250
00251
00252
00253
00254 void halBoardPowerDown(void);
00255
00256 #endif
00257
00258
00259