67 #include PLATFORM_HEADER
70 #include "stack/include/ember.h"
71 #include "stack/include/error.h"
73 #define PORTA (0 << 3)
74 #define PORTB (1 << 3)
75 #define PORTC (2 << 3)
385 #define PORT_NAME(x) ((x == PORTA) ? "A": ((x == PORTB) ? "B" : ((x == PORTC) ? "C": "?")))
391 boardDescription =
NULL;
393 halCommonGetToken(boardName, TOKEN_MFG_BOARD_NAME);
395 halCommonGetMfgToken(boardName, TOKEN_MFG_BOARD_NAME);
399 while ((i >= 0) && (boardName[i] == 0xFF)) {
404 for (i = 0; i < (
sizeof(boardList)/4) ; i++)
405 if (strcmp(boardName, (boardList[i])->name) == 0) {
410 if (boardDescription ==
NULL) {
419 return boardDescription;
425 GPIO_PACFGL = (GPIOCFG_IN <<PA0_CFG_BIT)|
426 (GPIOCFG_IN <<PA1_CFG_BIT)|
427 (GPIOCFG_IN <<PA2_CFG_BIT)|
428 (GPIOCFG_IN <<PA3_CFG_BIT);
429 GPIO_PACFGH = (GPIOCFG_IN <<PA4_CFG_BIT)|
430 (GPIOCFG_IN <<PA5_CFG_BIT)|
431 (GPIOCFG_IN <<PA6_CFG_BIT)|
432 (GPIOCFG_IN <<PA7_CFG_BIT);
433 GPIO_PBCFGL = (GPIOCFG_IN <<PB0_CFG_BIT)|
434 (GPIOCFG_IN <<PB1_CFG_BIT)|
435 (GPIOCFG_IN <<PB2_CFG_BIT)|
436 (GPIOCFG_IN <<PB3_CFG_BIT);
437 GPIO_PBCFGH = (GPIOCFG_IN <<PB4_CFG_BIT)|
438 (GPIOCFG_IN <<PB5_CFG_BIT)|
439 (GPIOCFG_IN <<PB6_CFG_BIT)|
440 (GPIOCFG_IN <<PB7_CFG_BIT);
441 GPIO_PCCFGL = (GPIOCFG_IN <<PC0_CFG_BIT)|
442 (GPIOCFG_IN <<PC1_CFG_BIT)|
443 (GPIOCFG_IN <<PC2_CFG_BIT)|
444 (GPIOCFG_IN <<PC3_CFG_BIT);
445 GPIO_PCCFGH = (GPIOCFG_IN <<PC4_CFG_BIT)|
446 (GPIOCFG_IN <<PC5_CFG_BIT)|
448 (CFG_C6 <<PC6_CFG_BIT)|
449 (CFG_C7 <<PC7_CFG_BIT);
451 (GPIOCFG_IN <<PC6_CFG_BIT)|
452 (GPIOCFG_IN <<PC7_CFG_BIT);
460 for (i = 0; i < boardDescription->
buttons; i++) {
470 for (i = 0; i < boardDescription->
leds; i++) {
492 GPIO_PACFGL = (GPIOCFG_IN <<PA0_CFG_BIT)|
493 (GPIOCFG_IN <<PA1_CFG_BIT)|
494 (GPIOCFG_IN <<PA2_CFG_BIT)|
495 (GPIOCFG_IN <<PA3_CFG_BIT);
496 GPIO_PACFGH = (GPIOCFG_IN <<PA4_CFG_BIT)|
497 (GPIOCFG_IN <<PA5_CFG_BIT)|
498 (GPIOCFG_IN <<PA6_CFG_BIT)|
499 (GPIOCFG_IN <<PA7_CFG_BIT);
500 GPIO_PBCFGL = (GPIOCFG_IN <<PB0_CFG_BIT)|
501 (GPIOCFG_OUT_ALT <<PB1_CFG_BIT)|
502 (GPIOCFG_IN <<PB2_CFG_BIT)|
503 (GPIOCFG_IN <<PB3_CFG_BIT);
504 GPIO_PBCFGH = (GPIOCFG_IN <<PB4_CFG_BIT)|
505 (GPIOCFG_IN <<PB5_CFG_BIT)|
506 (GPIOCFG_IN <<PB6_CFG_BIT)|
507 (GPIOCFG_IN <<PB7_CFG_BIT);
508 GPIO_PCCFGL = (GPIOCFG_IN <<PC0_CFG_BIT)|
509 (GPIOCFG_IN <<PC1_CFG_BIT)|
510 (GPIOCFG_IN <<PC2_CFG_BIT)|
511 (GPIOCFG_IN <<PC3_CFG_BIT);
512 GPIO_PCCFGH = (GPIOCFG_IN <<PC4_CFG_BIT)|
513 (GPIOCFG_IN <<PC5_CFG_BIT)|
515 (CFG_C6 <<PC6_CFG_BIT)|
516 (CFG_C7 <<PC7_CFG_BIT);
518 (GPIOCFG_IN <<PC6_CFG_BIT)|
519 (GPIOCFG_IN <<PC7_CFG_BIT);
538 for (i = 0; i < boardDescription->
leds; i++) {
548 for (i = 0; i < boardDescription->
buttons; i++) {
572 void printLeds (
void)
577 while (i < boardDescription->leds) {
578 printf (
"Led %s (port:%s, bit:%d)\r\n", leds->name, PORT_NAME(leds->gpioPort), leds->gpioPin);
583 void printButtons (
void)
588 while (i < boardDescription->buttons) {
589 printf (
"Button %s (port:%s, bit:%d)\r\n", buttons->name, PORT_NAME(buttons->gpioPort), buttons->gpioPin);
594 void boardPrintStringDescription(
void)
597 if (boardDescription !=
NULL) {
598 printf (
"*************************************\r\n");
599 printf (
"Board name = %s\r\n", boardDescription->name);
600 printf (
"*************************************\r\n");
601 printf(
"Number of leds on the board: %d\n", boardDescription->
leds);
602 printf(
"Number of buttons on the board: %d\n", boardDescription->
buttons);
605 if (boardDescription->
mems) {
606 printf (
"MEMS = %s\r\n", boardDescription->
mems->
name);
609 printf (
"Temp sensor = %s, port:%s, pin:%d, div:%d, adcFix:%s\r\n",
618 printf (
"EEProm:%s\r\n", (boardDescription->flags &
BOARD_HAS_EEPROM) ?
"Yes" :
"No");
619 printf (
"PC i/f:%s\r\n", (boardDescription->flags &
BOARD_HAS_FTDI) ?
"FTDI" :
"STM32F");
620 printf (
"Power Amplifier:%s\r\n", (boardDescription->flags &
BOARD_HAS_PA) ?
"Yes" :
"No");
uint8_t buttons
Number of buttons.
#define BOARD_HAS_FTDI
Flag to indicate if FTDI is used as PC interface.
#define BOARD_HAS_MEMS
Flag to indicate if MEMS is present.
uint8_t leds
Number of leds.
#define LEDS_MB851C
Define the number of LEDs in the specific board revision.
#define BUTTONS_MB851C
Define the number of user buttons in the specific board revision.
#define LEDS_MB954C
Define the number of LEDs in the specific board revision.
Data structure for board user I/O.
char * name
Name of the temperature sensor device.
Cortex-M3 Manufacturing token system.
const LedResourceType * leds
Pointer to LED resources.
#define PORTC_PIN(y)
Some registers and variables require indentifying GPIO by a single number instead of the port and pin...
Data structure for button description.
#define BOARD_HAS_EEPROM
Flag to indicate if EEPROM is present.
#define BUTTONS_MB950B
Define the number of user buttons in the specific board revision.
#define PORTB
Peripheral PORTB base pointer.
uint8_t gpioPort
GPIO port associated with the sensor.
#define BUTTONS_MB954B
Define the number of user buttons in the specific board revision.
#define BUTTONS_MB954C
Define the number of user buttons in the specific board revision.
#define NULL
The null pointer.
#define BUTTONS_MB954A
Define the number of user buttons in the specific board revision.
#define BUTTONS_MB851A
Define the number of user buttons in the specific board revision.
#define BOARD_HAS_STM32F
Flag to indicate if STM32F is used as PC interface.
void halBoardPowerDown(void)
Perform board specific action to power down the system, usually before going to deep sleep...
#define LEDS_MB951B
Define the number of LEDs in the specific board revision.
#define PORTx_PIN(x, y)
Some registers and variables require indentifying GPIO by a single number instead of the port and pin...
void halGpioSet(uint32_t gpio, boolean value)
Set/Clear single GPIO bit.
Data structure for temperature sensor description.
char * name
Name of the MEMS device.
#define BUTTONS_MB851D
Define the number of user buttons in the specific board revision.
#define LEDS_IDZ401V1
Define the number of LEDs in the specific board revision.
#define LEDS_MB951A
Define the number of LEDs in the specific board revision.
BoardResourcesType const * halBoardGetDescription(void)
Return pointer to board description structure.
void i2c_enable(void)
Configure serial controller in I2C mode and set I2C speed.
#define BUTTONS_MB851B
Define the number of user buttons in the specific board revision.
#define TRUE
An alias for one, used for clarity.
#define PORTA_PIN(y)
Some registers and variables require indentifying GPIO by a single number instead of the port and pin...
boolean adcFix
Flag to indicate whether the ADC range extension bug fix is implemented.
#define BUTTONS_MB951A
Define the number of user buttons in the specific board revision.
#define LEDS_MB851D
Define the number of LEDs in the specific board revision.
#define BOARD_HAS_PA
Flag to indicate if external power amplifier is present.
#define BOARD_HAS_TEMP_SENSOR
Flag to indicate if temeprature sensor is present.
#define LEDS_MB954A
Define the number of LEDs in the specific board revision.
#define BUTTONS_IDZ401V1
Define the number of user buttons in the specific board revision.
Data structure for MEMS description.
const MemsResourceType * mems
Board infrared MEMS description.
#define BUTTONS_MB951B
Define the number of user buttons in the specific board revision.
void halBoardInit(void)
Initialize the board description data structure after autodetect of the boards based on the CIB Board...
#define PORTA
Peripheral PORTA base pointer.
Generic set of HAL includes for all platforms.
#define BUTTONS_MB950A
Define the number of user buttons in the specific board revision.
void halBoardPowerUp(void)
Perform board specific action to power up the system.
uint8_t gpioPin
GPIO pin associated with the sensor.
const ButtonResourceType * buttons
Pointer to button resources.
const TempSensorResourceType * temperatureSensor
Board infrared temeprature sensor description.
Data structure describing board features.
uint8_t div
Voltage divider network from sensor vout and GPIO.
#define FALSE
An alias for zero, used for clarity.
Data structure for led description.
#define PORTB_PIN(y)
Some registers and variables require indentifying GPIO by a single number instead of the port and pin...
const BoardIOType * io
Board I/O description.
void halGpioConfig(uint32_t io, uint32_t config)
Configure an IO pin's operating mode.
#define LEDS_MB950A
Define the number of LEDs in the specific board revision.
#define LEDS_MB950B
Define the number of LEDs in the specific board revision.
#define LEDS_MB851A
Define the number of LEDs in the specific board revision.
#define LEDS_MB954B
Define the number of LEDs in the specific board revision.
#define LEDS_MB851B
Define the number of LEDs in the specific board revision.