Hi everyone,
I want to create a GPIO initialization procedure based on the version of the evaluation board that is used. So, I have a structure with the GPIOs and then two macros for setting the GPIOs
Code:
struct GPIO_def {
uint8_t def_MUX_ADD0; /**< MUX Address channel 1 */
uint8_t def_MUX_ADD1; /**< MUX Address channel 2 */
uint8_t def_MUX_ADD2; /**< MUX Address channel 3 */
uint8_t def_IMU_wakeUp_INT1; /**< sense IMU's interrupt from channel 1 */
uint8_t def_IMU_INT2; /**< IMU Interrupt pin */
uint8_t def_vibrator; /**< Control the vibrator - 0: vibrator OFF , 1: vibrator ON */
uint8_t def_WC_CHG; /**< Monitor WPT (Wireless Power Transfer) - 0: wireless charging ON , 1: wireless charging OFF */
uint8_t def_BM; /**< Battery monitor */
uint8_t def_PG; /**< Power good indication of back converter */
uint8_t def_CTRL; /**< Enable/disable the auxiliary load output of back converter */
uint8_t def_ADC_IN; /**< Read Op Amps output */
};
#define GPIO_EVB_V2_DEF \
{ \
.def_MUX_ADD0 = 33, \
.def_MUX_ADD1 = 34, \
.def_MUX_ADD2 = 35, \
.def_IMU_wakeUp_INT1 = 39, \
.def_IMU_INT2 = 40, \
.def_WC_CHG = 46, \
.def_BM = 47, \
.def_PG = 42, \
.def_CTRL = 43, \
.def_ADC_IN = 3 \
}
#define GPIO_EVB_V3_DEF \
{ \
.def_MUX_ADD0 = 6, \
.def_MUX_ADD1 = 8, \
.def_MUX_ADD2 = 41, \
.def_IMU_wakeUp_INT1 = 44, \
.def_IMU_INT2 = 42, \
.def_vibrator = 4, \
.def_WC_CHG = 5, \
.def_BM = 10, \
.def_PG = 15, \
.def_CTRL = 13, \
.def_ADC_IN = 30 \
}
Then I have the GPIO_init function to assing the GPIO values based on the version of the evaluation board
Code:
void GPIO_init(uint8_t evb) {
struct GPIO_def GPIO_set;
switch (evb) {
case EVB_V2: ;
GPIO_set = GPIO_EVB_V2_DEF;
break;
case EVB_V3: ;
GPIO_set = GPIO_EVB_V3_DEF;
break;
default:
break;
}
}
The problem is that when I create the structure instance and use the switch..case statement to assing the GPIO values the program do not compile...
It returns this error
https://cboard.cprogramming.com/imag...AASUVORK5CYII=
but I am sure that I do not have forget any bracket or comma or stuff like that.. I 've noticed that when I initialize like this
Code:
struct GPIO_def GPIO_set = GPIO_EVB_V2_DEF;
before switch statement it compiles..
How could I work around this?