From 0041396f05bc1f43657c343df6b291fc4bbdc901 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 11 Apr 2018 16:14:58 +1000 Subject: [PATCH] stm32/pin: In pin AF object, remove union of periph ptr types. 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. --- ports/stm32/boards/stm32f4xx_prefix.c | 2 +- ports/stm32/pin.h | 7 +------ ports/stm32/pin_defs_stm32.h | 12 ------------ ports/teensy/mk20dx256_prefix.c | 2 +- ports/teensy/pin_defs_teensy.h | 6 ------ 5 files changed, 3 insertions(+), 26 deletions(-) diff --git a/ports/stm32/boards/stm32f4xx_prefix.c b/ports/stm32/boards/stm32f4xx_prefix.c index f4ffdab68e..3bcd6e6410 100644 --- a/ports/stm32/boards/stm32f4xx_prefix.c +++ b/ports/stm32/boards/stm32f4xx_prefix.c @@ -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) \ diff --git a/ports/stm32/pin.h b/ports/stm32/pin.h index b0e05256fe..ea57b0a274 100644 --- a/ports/stm32/pin.h +++ b/ports/stm32/pin.h @@ -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 { diff --git a/ports/stm32/pin_defs_stm32.h b/ports/stm32/pin_defs_stm32.h index c5b2862835..feaf56ae97 100644 --- a/ports/stm32/pin_defs_stm32.h +++ b/ports/stm32/pin_defs_stm32.h @@ -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; diff --git a/ports/teensy/mk20dx256_prefix.c b/ports/teensy/mk20dx256_prefix.c index d8e7480b58..58ab07d6ec 100644 --- a/ports/teensy/mk20dx256_prefix.c +++ b/ports/teensy/mk20dx256_prefix.c @@ -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) \ diff --git a/ports/teensy/pin_defs_teensy.h b/ports/teensy/pin_defs_teensy.h index 54a6055f1a..d3a700be21 100644 --- a/ports/teensy/pin_defs_teensy.h +++ b/ports/teensy/pin_defs_teensy.h @@ -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;