Contiki-Inga 3.x
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
platform
mbxxx
board.h
Go to the documentation of this file.
1
/**
2
* \addtogroup mbxxx-platform
3
*
4
* @{
5
*/
6
/*
7
* Copyright (c) 2010, STMicroelectronics.
8
* All rights reserved.
9
*
10
* Redistribution and use in source and binary forms, with or without
11
* modification, are permitted provided that the following conditions
12
* are met:
13
* 1. Redistributions of source code must retain the above copyright
14
* notice, this list of conditions and the following disclaimer.
15
* 2. Redistributions in binary form must reproduce the above
16
* copyright notice, this list of conditions and the following
17
* disclaimer in the documentation and/or other materials provided
18
* with the distribution.
19
* 3. The name of the author may not be used to endorse or promote
20
* products derived from this software without specific prior
21
* written permission.
22
*
23
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
24
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
27
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
*
35
* This file is part of the Contiki OS
36
*
37
*/
38
/*---------------------------------------------------------------------------*/
39
/**
40
* \file
41
* Header file x STM32W108 Kits boards abstraction.
42
* \brief
43
* Header file x STM32W108 Kits boards abstraction.
44
* See \ref board for documentation.
45
*
46
*
47
* See hal/micro/cortexm3/stm32w108/board.h for source code.
48
*
49
*/
50
/*---------------------------------------------------------------------------*/
51
#ifndef BOARD_H_
52
#define BOARD_H_
53
54
char
boardName[16];
55
56
/** @addtogroup board
57
* \brief ST board abstraction layer
58
*
59
* This header defines API and data structures to handle ST boards with thei associated resources
60
* on algorithm behavior.
61
* See hal/micro/cortexm3/stm32w108/board.h for source code.
62
*@{
63
*/
64
65
/**
66
* \brief Define the number of LEDs in the specific board revision
67
*/
68
#define LEDS_MB851A 2
69
/**
70
* \brief Define the number of LEDs in the specific board revision
71
*/
72
#define LEDS_MB851B 2
73
/**
74
* \brief Define the number of LEDs in the specific board revision
75
*/
76
#define LEDS_MB851C 2
77
/**
78
* \brief Define the number of LEDs in the specific board revision
79
*/
80
#define LEDS_MB851D 2
81
82
83
84
/**
85
* \brief Define the number of LEDs in the specific board revision
86
*/
87
#define LEDS_MB954A 2
88
/**
89
* \brief Define the number of LEDs in the specific board revision
90
*/
91
#define LEDS_MB954B 2
92
/**
93
* \brief Define the number of LEDs in the specific board revision
94
*/
95
#define LEDS_MB954C 2
96
97
98
99
/**
100
* \brief Define the number of LEDs in the specific board revision
101
*/
102
#define LEDS_MB950A 2
103
/**
104
* \brief Define the number of LEDs in the specific board revision
105
*/
106
#define LEDS_MB950B 2
107
/**
108
* \brief Define the number of LEDs in the specific board revision
109
*/
110
#define LEDS_MB951A 2
111
/**
112
* \brief Define the number of LEDs in the specific board revision
113
*/
114
#define LEDS_MB951B 2
115
116
117
118
/**
119
* \brief Define the number of LEDs in the specific board revision
120
*/
121
#define LEDS_IDZ401V1 1
122
123
124
125
/**
126
* \brief Define the number of user buttons in the specific board revision
127
*/
128
#define BUTTONS_MB851A 1
129
/**
130
* \brief Define the number of user buttons in the specific board revision
131
*/
132
#define BUTTONS_MB851B 1
133
/**
134
* \brief Define the number of user buttons in the specific board revision
135
*/
136
#define BUTTONS_MB851C 1
137
/**
138
* \brief Define the number of user buttons in the specific board revision
139
*/
140
#define BUTTONS_MB851D 1
141
142
143
144
/**
145
* \brief Define the number of user buttons in the specific board revision
146
*/
147
#define BUTTONS_MB954A 1
148
/**
149
* \brief Define the number of user buttons in the specific board revision
150
*/
151
#define BUTTONS_MB954B 1
152
/**
153
* \brief Define the number of user buttons in the specific board revision
154
*/
155
#define BUTTONS_MB954C 1
156
157
158
159
/**
160
* \brief Define the number of user buttons in the specific board revision
161
*/
162
#define BUTTONS_MB950A 5
163
/**
164
* \brief Define the number of user buttons in the specific board revision
165
*/
166
#define BUTTONS_MB950B 5
167
/**
168
* \brief Define the number of user buttons in the specific board revision
169
*/
170
#define BUTTONS_MB951A 1
171
/**
172
* \brief Define the number of user buttons in the specific board revision
173
*/
174
#define BUTTONS_MB951B 1
175
176
177
178
/**
179
* \brief Define the number of user buttons in the specific board revision
180
*/
181
#define BUTTONS_IDZ401V1 0
182
183
184
185
/**
186
* \brief Data structure for led description
187
*/
188
typedef
struct
LedResourceStruct
{
189
/** Name of the LED as printed in the board */
190
char
*
name
;
191
/** GPIO port associated with the LED */
192
uint8_t
gpioPort
;
193
/** GPIO pin associated with the LED */
194
uint8_t
gpioPin
;
195
}
LedResourceType
;
196
197
typedef
LedResourceType
InfraRedLedResourceType
;
198
199
/**
200
* \brief Data structure for button description
201
*/
202
typedef
struct
ButtonResourceStruct
{
203
/** Name of the button as printed in the board */
204
char
*
name
;
205
/** GPIO port associated with the button */
206
uint8_t
gpioPort
;
207
/** GPIO pin associated with the button */
208
uint8_t
gpioPin
;
209
}
ButtonResourceType
;
210
211
/**
212
* \brief Data structure for MEMS description
213
*/
214
typedef
struct
MemsResourceStruct
{
215
/** Name of the MEMS device */
216
char
*
name
;
217
/** Serial communication port associated with the MEMS */
218
uint8_t
scPort
;
219
}
MemsResourceType
;
220
221
/**
222
* \brief Data structure for temperature sensor description
223
*/
224
typedef
struct
TempSensorResourceStruct
{
225
/** Name of the temperature sensor device */
226
char
*
name
;
227
/** GPIO port associated with the sensor */
228
uint8_t
gpioPort
;
229
/** GPIO pin associated with the sensor */
230
uint8_t
gpioPin
;
231
/** Voltage divider network from sensor vout and GPIO */
232
uint8_t
div
;
233
/** Flag to indicate whether the ADC range extension bug fix is implemented */
234
boolean
adcFix
;
235
}
TempSensorResourceType
;
236
237
/**
238
* \brief Data structure for board user I/O
239
*/
240
typedef
struct
BoardIOStruct
{
241
/** Pointer to LED resources */
242
const
LedResourceType
*
leds
;
243
/** Pointer to button resources */
244
const
ButtonResourceType
*
buttons
;
245
}
BoardIOType
;
246
247
/**
248
* \brief Flag to indicate if MEMS is present
249
*/
250
#define BOARD_HAS_MEMS (1 << 0)
251
/**
252
* \brief Flag to indicate if temeprature sensor is present
253
*/
254
#define BOARD_HAS_TEMP_SENSOR (1 << 1)
255
/**
256
* \brief Flag to indicate if external power amplifier is present
257
*/
258
#define BOARD_HAS_PA (1 << 2)
259
/**
260
* \brief Flag to indicate if EEPROM is present
261
*/
262
#define BOARD_HAS_EEPROM (1 << 3)
263
/**
264
* \brief Flag to indicate if FTDI is used as PC interface
265
*/
266
#define BOARD_HAS_FTDI (1 << 4)
267
/**
268
* \brief Flag to indicate if STM32F is used as PC interface
269
*/
270
#define BOARD_HAS_STM32F (1 << 5)
271
272
/**
273
* \brief Data structure describing board features
274
*/
275
typedef
struct
BoardResourcesStruct
{
276
const
char
*name;
277
const
uint32_t flags;
278
/** Number of buttons */
279
uint8_t
buttons
;
280
/** Number of leds */
281
uint8_t
leds
;
282
/** Board I/O description */
283
const
BoardIOType
*
io
;
284
/** Board infrared led description */
285
const
InfraRedLedResourceType
*
infraredLed
;
286
/** Board infrared MEMS description */
287
const
MemsResourceType
*
mems
;
288
/** Board infrared temeprature sensor description */
289
const
TempSensorResourceType
*
temperatureSensor
;
290
}
BoardResourcesType
;
291
292
extern
BoardResourcesType
const
*boardDescription;
293
294
// Generic definitions
295
#define GPIO_PxCLR_BASE (GPIO_PACLR_ADDR)
296
#define GPIO_PxSET_BASE (GPIO_PASET_ADDR)
297
#define GPIO_PxOUT_BASE (GPIO_PAOUT_ADDR)
298
#define GPIO_PxIN_BASE (GPIO_PAIN_ADDR)
299
// Each port is offset from the previous port by the same amount
300
#define GPIO_Px_OFFSET (GPIO_PBCFGL_ADDR-GPIO_PACFGL_ADDR)
301
302
303
/* leds definitions */
304
#define LED_D1 PORTx_PIN(boardDescription->io->leds[0].gpioPort, boardDescription->io->leds[0].gpioPin) //PORTB_PIN(6)
305
#define LED_D3 PORTx_PIN(boardDescription->io->leds[1].gpioPort, boardDescription->io->leds[1].gpioPin) // PORTB_PIN(5)
306
#define DUMMY_LED 0xff
307
308
309
/** Description buttons definition */
310
#define BUTTON_Sn(n) (PORTx_PIN(boardDescription->io->buttons[n].gpioPort, boardDescription->io->buttons[n].gpioPin))
311
#define BUTTON_Sn_WAKE_SOURCE(n) (1 << ((boardDescription->io->buttons[n].gpioPin) + (8 * (boardDescription->io->buttons[n].gpioPort >> 3))))
312
#define BUTTON_INPUT_GPIO(port) *((volatile uint32_t *) (GPIO_PxIN_BASE + GPIO_Px_OFFSET * port))
313
#define DUMMY_BUTTON 0xff
314
315
#define BUTTON_S1 (boardDescription->buttons>0 ? BUTTON_Sn(0): DUMMY_BUTTON)
316
#define BUTTON_S2 (boardDescription->buttons>1 ? BUTTON_Sn(1): DUMMY_BUTTON)
317
#define BUTTON_S3 (boardDescription->buttons>2 ? BUTTON_Sn(2): DUMMY_BUTTON)
318
#define BUTTON_S4 (boardDescription->buttons>3 ? BUTTON_Sn(3): DUMMY_BUTTON)
319
#define BUTTON_S5 (boardDescription->buttons>4 ? BUTTON_Sn(4): DUMMY_BUTTON)
320
321
#define BUTTON_S1_WAKE_SOURCE (boardDescription->buttons>0 ? BUTTON_Sn_WAKE_SOURCE(0): 0)
322
#define BUTTON_S2_WAKE_SOURCE (boardDescription->buttons>1 ? BUTTON_Sn_WAKE_SOURCE(1): 0)
323
#define BUTTON_S3_WAKE_SOURCE (boardDescription->buttons>2 ? BUTTON_Sn_WAKE_SOURCE(2): 0)
324
#define BUTTON_S4_WAKE_SOURCE (boardDescription->buttons>3 ? BUTTON_Sn_WAKE_SOURCE(3): 0)
325
#define BUTTON_S5_WAKE_SOURCE (boardDescription->buttons>4 ? BUTTON_Sn_WAKE_SOURCE(4): 0)
326
327
/** Description uart definition */
328
#define UART_TX PORTB_PIN(1)
329
#define UART_RX PORTB_PIN(2)
330
#define UART_RX_WAKE_SOURCE 0x00000400
331
332
/** Description temperature sensor GPIO */
333
#define TEMPERATURE_SENSOR_GPIO PORTx_PIN(boardDescription->temperatureSensor->gpioPort, boardDescription->temperatureSensor->gpioPin) // PORTB_PIN(7)
334
335
/** \brief Return pointer to board description structure
336
*
337
*
338
* @return Pointer to board description structure
339
*/
340
BoardResourcesType
const
*
halBoardGetDescription
(
void
);
341
/**
342
* \brief Initialize the board description data structure after
343
* autodetect of the boards based on the CIB Board name field
344
* content. In case of invalid CIB data it will default to MB851A.
345
* Customer normally needs to modify this file to adapt it to their specific board.
346
*/
347
void
halBoardInit
(
void
);
348
/**
349
* \brief Perform board specific action to power up the system.
350
* This code depends on the actual board features and configure
351
* the stm32w and on board devices for proper operation.
352
* Customer normally needs to modify this file to adapt it to their specific board.
353
*/
354
void
halBoardPowerUp
(
void
);
355
/**
356
* \brief Perform board specific action to power down the system, usually before going to deep sleep.
357
* This code depends on the actual board features and configure
358
* the stm32w and on board devices for minimal power consumption.
359
* Customer normally needs to modify this file to adapt it to their specific board.
360
*/
361
void
halBoardPowerDown
(
void
);
362
363
364
void
boardPrintStringDescription(
void
);
365
366
#endif
/*BOARD_H_ */
367
368
/** @} // END addtogroup
369
*/
370
/** @} */
Generated on Thu Apr 24 2014 16:26:15 for Contiki-Inga 3.x by
1.8.3.1