Navigation Menu

Skip to content

Commit

Permalink
stm32/pin: In pin AF object, remove union of periph ptr types.
Browse files Browse the repository at this point in the history
The individual union members (like SPI, I2C) are never used, only the
generic "reg" entry is.  And the union names can clash with macro
definitions in the HAL so better to remove them.
  • Loading branch information
dpgeorge committed Apr 11, 2018
1 parent f1073e7 commit 0041396
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 26 deletions.
2 changes: 1 addition & 1 deletion ports/stm32/boards/stm32f4xx_prefix.c
Expand Up @@ -14,7 +14,7 @@
.fn = AF_FN_ ## af_fn, \
.unit = (af_unit), \
.type = AF_PIN_TYPE_ ## af_fn ## _ ## af_type, \
.af_fn = (af_ptr) \
.reg = (af_ptr) \
}

#define PIN(p_port, p_pin, p_af, p_adc_num, p_adc_channel) \
Expand Down
7 changes: 1 addition & 6 deletions ports/stm32/pin.h
Expand Up @@ -39,12 +39,7 @@ typedef struct {
uint8_t fn;
uint8_t unit;
uint8_t type;

union {
void *reg;

PIN_DEFS_PORT_AF_UNION
};
void *reg; // The peripheral associated with this AF
} pin_af_obj_t;

typedef struct {
Expand Down
12 changes: 0 additions & 12 deletions ports/stm32/pin_defs_stm32.h
Expand Up @@ -115,17 +115,5 @@ enum {
PIN_ADC3 = (1 << 2),
};

// Note that SPI and I2S are really the same peripheral as far as the HAL
// is concerned, so there is no I2S_TypeDef.
// We use void* for SDMMC because not all MCUs have the SDMMC_TypeDef type.
#define PIN_DEFS_PORT_AF_UNION \
TIM_TypeDef *TIM; \
I2C_TypeDef *I2C; \
USART_TypeDef *USART; \
USART_TypeDef *UART; \
SPI_TypeDef *SPI;\
SPI_TypeDef *I2S; \
void *SDMMC; \

typedef GPIO_TypeDef pin_gpio_t;

2 changes: 1 addition & 1 deletion ports/teensy/mk20dx256_prefix.c
Expand Up @@ -15,7 +15,7 @@
.fn = AF_FN_ ## af_fn, \
.unit = (af_unit), \
.type = AF_PIN_TYPE_ ## af_fn ## _ ## af_type, \
.af_fn = (af_ptr) \
.reg = (af_ptr) \
}

#define PIN(p_port, p_pin, p_num_af, p_af, p_adc_num, p_adc_channel) \
Expand Down
6 changes: 0 additions & 6 deletions ports/teensy/pin_defs_teensy.h
Expand Up @@ -40,10 +40,4 @@ enum {
AF_PIN_TYPE_UART_RTS,
};

#define PIN_DEFS_PORT_AF_UNION \
FTM_TypeDef *FTM; \
I2C_TypeDef *I2C; \
UART_TypeDef *UART; \
SPI_TypeDef *SPI;

typedef GPIO_TypeDef pin_gpio_t;

0 comments on commit 0041396

Please sign in to comment.