From bd463547d0df81624da7716da40fe78e278094ce Mon Sep 17 00:00:00 2001 From: crinq Date: Wed, 15 Dec 2021 15:32:30 +0100 Subject: [PATCH] fix variable scope, multiple declerations error with gcc 10 --- inc/setup.h | 3 --- src/comps/adc.c | 3 +++ src/comps/enc_fb.c | 4 ++-- src/comps/encf.c | 14 +++++++------- src/comps/encs.c | 4 ++-- src/comps/smartabs.c | 1 + src/comps/sserial.c | 20 ++++++++++---------- src/comps/yaskawa.c | 18 +++++++++--------- src/main.c | 2 ++ src/setup.c | 4 ++++ 10 files changed, 40 insertions(+), 33 deletions(-) diff --git a/inc/setup.h b/inc/setup.h index 3a2bf730..1ea2d10f 100644 --- a/inc/setup.h +++ b/inc/setup.h @@ -18,7 +18,4 @@ void setup(void); void setup_res(void); -volatile uint32_t ADC_DMA_Buffer0[ADC_SAMPLES_IN_RT]; //240 -volatile uint32_t ADC_DMA_Buffer1[ADC_SAMPLES_IN_RT]; -RCC_ClocksTypeDef RCC_Clocks; diff --git a/src/comps/adc.c b/src/comps/adc.c index 9ea36c7a..3d1ef513 100644 --- a/src/comps/adc.c +++ b/src/comps/adc.c @@ -13,6 +13,9 @@ #define TERM_NUM_WAVES 8 +extern volatile uint32_t ADC_DMA_Buffer0[ADC_SAMPLES_IN_RT]; //240 +extern volatile uint32_t ADC_DMA_Buffer1[ADC_SAMPLES_IN_RT]; + HAL_COMP(adc); HAL_PIN(sin0); //sin output diff --git a/src/comps/enc_fb.c b/src/comps/enc_fb.c index 305d0d89..01970d26 100644 --- a/src/comps/enc_fb.c +++ b/src/comps/enc_fb.c @@ -37,8 +37,8 @@ struct enc_fb_ctx_t { float absoffset; }; -int indexpos = 0; -int indexprint = 0; +static int indexpos = 0; +static int indexprint = 0; static void nrt_init(void *ctx_ptr, hal_pin_inst_t *pin_ptr) { struct enc_fb_ctx_t *ctx = (struct enc_fb_ctx_t *)ctx_ptr; diff --git a/src/comps/encf.c b/src/comps/encf.c index e161dab1..6899c721 100644 --- a/src/comps/encf.c +++ b/src/comps/encf.c @@ -28,9 +28,9 @@ HAL_PIN(crc_er); HAL_PIN(freq); HAL_PIN(bit_ticks); -volatile uint32_t sendf; -uint32_t send_counterf; -volatile uint16_t tim_data[160]; +static volatile uint32_t sendf; +static uint32_t send_counterf; +static volatile uint16_t tim_data[160]; #pragma pack(push, 1) typedef struct { @@ -90,14 +90,14 @@ data regardless of the index status. Note that the commutation track seems to be interpolated so is not better than maybe 1% accuracy */ -union { +static union { uint8_t enc_data[10]; fanuc_t fanuc; } data; -uint8_t print_buf[10]; +static uint8_t print_buf[10]; -int32_t pos_offset; -uint32_t state_counter; +static int32_t pos_offset; +static uint32_t state_counter; static void nrt_init(void *ctx_ptr, hal_pin_inst_t *pin_ptr) { // struct encf_ctx_t *ctx = (struct encf_ctx_t *)ctx_ptr; diff --git a/src/comps/encs.c b/src/comps/encs.c index c610e752..daaed6eb 100644 --- a/src/comps/encs.c +++ b/src/comps/encs.c @@ -35,8 +35,8 @@ HAL_PIN(pos); HAL_PIN(error); HAL_PIN(state); -volatile uint32_t request_buf[24]; -volatile uint16_t tim_data[300]; +static volatile uint32_t request_buf[24]; +static volatile uint16_t tim_data[300]; #pragma pack(push, 1) typedef union { diff --git a/src/comps/smartabs.c b/src/comps/smartabs.c index d75449ea..b9004419 100644 --- a/src/comps/smartabs.c +++ b/src/comps/smartabs.c @@ -2,6 +2,7 @@ #include "commands.h" #include "hal.h" #include "math.h" +#include "crc.h" #include "defines.h" #include "angle.h" #include "stm32f4xx_conf.h" diff --git a/src/comps/sserial.c b/src/comps/sserial.c index 2135780b..f8cb9a08 100644 --- a/src/comps/sserial.c +++ b/src/comps/sserial.c @@ -70,16 +70,16 @@ struct sserial_ctx_t { uint32_t phase; }; -volatile uint8_t rxbuf[128]; //rx dma buffer -volatile uint8_t txbuf[128]; //tx dma buffer -uint16_t address; //current address pointer -int rxpos; //read pointer for rx ringbuffer -uint32_t timeout; -lbp_t lbp; -const char name[] = LBPCardName; -unit_no_t unit; -uint32_t max_waste_ticks; -uint32_t block_bytes; +static volatile uint8_t rxbuf[128]; //rx dma buffer +static volatile uint8_t txbuf[128]; //tx dma buffer +static uint16_t address; //current address pointer +static int rxpos; //read pointer for rx ringbuffer +static uint32_t timeout; +static lbp_t lbp; +static const char name[] = LBPCardName; +static unit_no_t unit; +static uint32_t max_waste_ticks; +static uint32_t block_bytes; #pragma pack(push, 1) //***************************************************************************** diff --git a/src/comps/yaskawa.c b/src/comps/yaskawa.c index fdd29dd0..4698c0b6 100644 --- a/src/comps/yaskawa.c +++ b/src/comps/yaskawa.c @@ -34,15 +34,15 @@ HAL_PIN(crc_ok); HAL_PIN(crc_error); //TODO: use context -volatile uint32_t txbuf[128]; -int pos; -int dfdf; -volatile char m_data[150]; -volatile char m_data2[150]; -volatile uint16_t tim_data[300]; -DMA_InitTypeDef DMA_InitStructuretx; -DMA_InitTypeDef DMA_InitStructurerx; -uint8_t yaskawa_reply[14]; +static volatile uint32_t txbuf[128]; +static int pos; +static int dfdf; +static volatile char m_data[150]; +static volatile char m_data2[150]; +static volatile uint16_t tim_data[300]; +static DMA_InitTypeDef DMA_InitStructuretx; +static DMA_InitTypeDef DMA_InitStructurerx; +static uint8_t yaskawa_reply[14]; //uint8_t yaskara_reply_len; static void nrt_init(void *ctx_ptr, hal_pin_inst_t *pin_ptr) { diff --git a/src/main.c b/src/main.c index 4776fd67..ce011204 100644 --- a/src/main.c +++ b/src/main.c @@ -28,6 +28,8 @@ #include "main.h" #include "commands.h" +extern RCC_ClocksTypeDef RCC_Clocks; + uint32_t hal_get_systick_value() { return (SysTick->VAL); } diff --git a/src/setup.c b/src/setup.c index 92ddda26..372c81d1 100644 --- a/src/setup.c +++ b/src/setup.c @@ -10,6 +10,10 @@ #include "usbd_cdc_if.h" #include "defines.h" +RCC_ClocksTypeDef RCC_Clocks; +volatile uint32_t ADC_DMA_Buffer0[ADC_SAMPLES_IN_RT]; //240 +volatile uint32_t ADC_DMA_Buffer1[ADC_SAMPLES_IN_RT]; + void setup() { //Enable clocks //TODO: small f4 does not have GPIOE