diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2019-03-04 23:35:11 -0500 |
---|---|---|
committer | KevinOConnor <kevin@koconnor.net> | 2019-03-17 19:38:18 -0400 |
commit | b28e95ca1aa2860c0869041c29a3ba27054e5967 (patch) | |
tree | b507c6a45c52fff68a449f20213d39b6bc8e4a29 /src | |
parent | 7eda55e2b042566020ade34d7b2cdb9296f37f1d (diff) | |
download | kutter-b28e95ca1aa2860c0869041c29a3ba27054e5967.tar.gz kutter-b28e95ca1aa2860c0869041c29a3ba27054e5967.tar.xz kutter-b28e95ca1aa2860c0869041c29a3ba27054e5967.zip |
command: Always pass a string to the DECL_CONSTANT() macro
Make it clear that the name of the constant being defined is a string.
When the value being defined is also a string, use a new
DECL_CONSTANT_STR() macro.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/atsam/adc.c | 2 | ||||
-rw-r--r-- | src/atsam/hard_pwm.c | 2 | ||||
-rw-r--r-- | src/atsam/main.c | 2 | ||||
-rw-r--r-- | src/atsam/sam4e_afec.c | 2 | ||||
-rw-r--r-- | src/atsamd/adc.c | 2 | ||||
-rw-r--r-- | src/atsamd/hard_pwm.c | 2 | ||||
-rw-r--r-- | src/atsamd/main.c | 2 | ||||
-rw-r--r-- | src/avr/adc.c | 2 | ||||
-rw-r--r-- | src/avr/hard_pwm.c | 2 | ||||
-rw-r--r-- | src/avr/main.c | 2 | ||||
-rw-r--r-- | src/avr/timer.c | 2 | ||||
-rw-r--r-- | src/basecmd.c | 2 | ||||
-rw-r--r-- | src/command.h | 8 | ||||
-rw-r--r-- | src/generic/armcm_timer.c | 2 | ||||
-rw-r--r-- | src/generic/serial_irq.c | 4 | ||||
-rw-r--r-- | src/generic/timer_irq.c | 2 | ||||
-rw-r--r-- | src/gpiocmds.c | 2 | ||||
-rw-r--r-- | src/linux/analog.c | 2 | ||||
-rw-r--r-- | src/linux/main.c | 2 | ||||
-rw-r--r-- | src/linux/pca9685.c | 2 | ||||
-rw-r--r-- | src/linux/timer.c | 2 | ||||
-rw-r--r-- | src/lpc176x/adc.c | 2 | ||||
-rw-r--r-- | src/lpc176x/main.c | 2 | ||||
-rw-r--r-- | src/pru/adc.c | 2 | ||||
-rw-r--r-- | src/pru/main.c | 2 | ||||
-rw-r--r-- | src/stepper.c | 2 | ||||
-rw-r--r-- | src/stm32f1/adc.c | 2 | ||||
-rw-r--r-- | src/stm32f1/main.c | 2 |
28 files changed, 32 insertions, 32 deletions
diff --git a/src/atsam/adc.c b/src/atsam/adc.c index d5e74676..816b388e 100644 --- a/src/atsam/adc.c +++ b/src/atsam/adc.c @@ -27,7 +27,7 @@ static const uint8_t adc_pins[] = { }; #define ADC_FREQ_MAX 20000000 -DECL_CONSTANT(ADC_MAX, 4095); +DECL_CONSTANT("ADC_MAX", 4095); struct gpio_adc gpio_adc_setup(uint8_t pin) diff --git a/src/atsam/hard_pwm.c b/src/atsam/hard_pwm.c index 7d1881a6..0b238b24 100644 --- a/src/atsam/hard_pwm.c +++ b/src/atsam/hard_pwm.c @@ -54,7 +54,7 @@ static const struct gpio_pwm_info pwm_regs[] = { #define MAX_PWM 255 -DECL_CONSTANT(PWM_MAX, MAX_PWM); +DECL_CONSTANT("PWM_MAX", MAX_PWM); struct gpio_pwm gpio_pwm_setup(uint8_t pin, uint32_t cycle_time, uint8_t val) diff --git a/src/atsam/main.c b/src/atsam/main.c index b6be2864..0bb9ff83 100644 --- a/src/atsam/main.c +++ b/src/atsam/main.c @@ -10,7 +10,7 @@ #include "internal.h" // WDT #include "sched.h" // sched_main -DECL_CONSTANT(MCU, CONFIG_MCU); +DECL_CONSTANT_STR("MCU", CONFIG_MCU); /**************************************************************** diff --git a/src/atsam/sam4e_afec.c b/src/atsam/sam4e_afec.c index 002e092f..4c78e958 100644 --- a/src/atsam/sam4e_afec.c +++ b/src/atsam/sam4e_afec.c @@ -51,7 +51,7 @@ gpio_adc_to_afec_chan(struct gpio_adc g) } #define ADC_FREQ_MAX 6000000UL -DECL_CONSTANT(ADC_MAX, 4095); +DECL_CONSTANT("ADC_MAX", 4095); static int init_afec(Afec* afec) { diff --git a/src/atsamd/adc.c b/src/atsamd/adc.c index 26465c2d..8d25d2f4 100644 --- a/src/atsamd/adc.c +++ b/src/atsamd/adc.c @@ -37,7 +37,7 @@ static const uint8_t adc_pins[] = { }; #endif -DECL_CONSTANT(ADC_MAX, 4095); +DECL_CONSTANT("ADC_MAX", 4095); static struct gpio_adc gpio_adc_pin_to_struct(uint8_t pin) { diff --git a/src/atsamd/hard_pwm.c b/src/atsamd/hard_pwm.c index 3f510520..0b3a6ba4 100644 --- a/src/atsamd/hard_pwm.c +++ b/src/atsamd/hard_pwm.c @@ -41,7 +41,7 @@ static const struct gpio_pwm_info pwm_regs[] = { #define MAX_PWM 255 -DECL_CONSTANT(PWM_MAX, MAX_PWM); +DECL_CONSTANT("PWM_MAX", MAX_PWM); struct gpio_pwm gpio_pwm_setup(uint8_t pin, uint32_t cycle_time, uint8_t val) diff --git a/src/atsamd/main.c b/src/atsamd/main.c index 5a5a374d..c7dbe9fd 100644 --- a/src/atsamd/main.c +++ b/src/atsamd/main.c @@ -8,7 +8,7 @@ #include "internal.h" // NVIC_SystemReset #include "sched.h" // sched_main -DECL_CONSTANT(MCU, CONFIG_MCU); +DECL_CONSTANT_STR("MCU", CONFIG_MCU); // Return the start of memory available for dynamic allocations void * diff --git a/src/avr/adc.c b/src/avr/adc.c index 3087dce1..8b478d08 100644 --- a/src/avr/adc.c +++ b/src/avr/adc.c @@ -36,7 +36,7 @@ static const uint8_t adc_pins[] PROGMEM = { enum { ADMUX_DEFAULT = 0x40 }; enum { ADC_ENABLE = (1<<ADPS0)|(1<<ADPS1)|(1<<ADPS2)|(1<<ADEN)|(1<<ADIF) }; -DECL_CONSTANT(ADC_MAX, 1023); +DECL_CONSTANT("ADC_MAX", 1023); struct gpio_adc gpio_adc_setup(uint8_t pin) diff --git a/src/avr/hard_pwm.c b/src/avr/hard_pwm.c index a6609313..01d0bd9e 100644 --- a/src/avr/hard_pwm.c +++ b/src/avr/hard_pwm.c @@ -74,7 +74,7 @@ static const struct gpio_pwm_info pwm_regs[] PROGMEM = { #endif }; -DECL_CONSTANT(PWM_MAX, 255); +DECL_CONSTANT("PWM_MAX", 255); struct gpio_pwm gpio_pwm_setup(uint8_t pin, uint32_t cycle_time, uint8_t val) diff --git a/src/avr/main.c b/src/avr/main.c index 57aa3c01..0523af41 100644 --- a/src/avr/main.c +++ b/src/avr/main.c @@ -12,7 +12,7 @@ #include "irq.h" // irq_enable #include "sched.h" // sched_main -DECL_CONSTANT(MCU, CONFIG_MCU); +DECL_CONSTANT_STR("MCU", CONFIG_MCU); /**************************************************************** diff --git a/src/avr/timer.c b/src/avr/timer.c index e8880a64..fb8738cc 100644 --- a/src/avr/timer.c +++ b/src/avr/timer.c @@ -16,7 +16,7 @@ * Low level timer code ****************************************************************/ -DECL_CONSTANT(CLOCK_FREQ, CONFIG_CLOCK_FREQ); +DECL_CONSTANT("CLOCK_FREQ", CONFIG_CLOCK_FREQ); // Return the number of clock ticks for a given number of microseconds uint32_t diff --git a/src/basecmd.c b/src/basecmd.c index f554c13e..95511885 100644 --- a/src/basecmd.c +++ b/src/basecmd.c @@ -258,7 +258,7 @@ command_get_uptime(uint32_t *args) DECL_COMMAND_FLAGS(command_get_uptime, HF_IN_SHUTDOWN, "get_uptime"); #define SUMSQ_BASE 256 -DECL_CONSTANT(STATS_SUMSQ_BASE, SUMSQ_BASE); +DECL_CONSTANT("STATS_SUMSQ_BASE", SUMSQ_BASE); void stats_update(uint32_t start, uint32_t cur) diff --git a/src/command.h b/src/command.h index 92315f38..c924e59d 100644 --- a/src/command.h +++ b/src/command.h @@ -16,8 +16,8 @@ #define HF_IN_SHUTDOWN 0x01 // Handler can run even when in emergency stop // Declare a constant exported to the host -#define DECL_CONSTANT(NAME, VALUE) \ - _DECL_CONSTANT(NAME, VALUE) +#define DECL_CONSTANT(NAME, VALUE) _DECL_CONSTANT(NAME, __stringify(VALUE)) +#define DECL_CONSTANT_STR(NAME, VALUE) _DECL_CONSTANT(NAME, VALUE) // Send an output message (and declare a static message type for it) #define output(FMT, args...) \ @@ -88,8 +88,8 @@ uint8_t ctr_lookup_static_string(const char *str); #define _DECL_COMMAND(FUNC, FLAGS, MSG) \ DECL_CTR("_DECL_COMMAND " __stringify(FUNC) " " __stringify(FLAGS) " " MSG) -#define _DECL_CONSTANT(NAME, VALUE) \ - DECL_CTR("_DECL_CONSTANT " __stringify(NAME) " " __stringify(VALUE)) +#define _DECL_CONSTANT(NAME, VALUE) \ + DECL_CTR("_DECL_CONSTANT " NAME " " VALUE) #define _DECL_ENCODER(FMT) ({ \ DECL_CTR("_DECL_ENCODER " FMT); \ diff --git a/src/generic/armcm_timer.c b/src/generic/armcm_timer.c index f1bc11fa..a9c8ab9f 100644 --- a/src/generic/armcm_timer.c +++ b/src/generic/armcm_timer.c @@ -11,7 +11,7 @@ #include "command.h" // shutdown #include "sched.h" // sched_timer_dispatch -DECL_CONSTANT(CLOCK_FREQ, CONFIG_CLOCK_FREQ); +DECL_CONSTANT("CLOCK_FREQ", CONFIG_CLOCK_FREQ); // Return the number of clock ticks for a given number of microseconds uint32_t diff --git a/src/generic/serial_irq.c b/src/generic/serial_irq.c index 76304323..c2b23864 100644 --- a/src/generic/serial_irq.c +++ b/src/generic/serial_irq.c @@ -19,8 +19,8 @@ static uint8_t receive_buf[RX_BUFFER_SIZE], receive_pos; static uint8_t transmit_buf[96], transmit_pos, transmit_max; -DECL_CONSTANT(SERIAL_BAUD, CONFIG_SERIAL_BAUD); -DECL_CONSTANT(RECEIVE_WINDOW, RX_BUFFER_SIZE); +DECL_CONSTANT("SERIAL_BAUD", CONFIG_SERIAL_BAUD); +DECL_CONSTANT("RECEIVE_WINDOW", RX_BUFFER_SIZE); // Rx interrupt - store read data void diff --git a/src/generic/timer_irq.c b/src/generic/timer_irq.c index f7e255e6..40e9336b 100644 --- a/src/generic/timer_irq.c +++ b/src/generic/timer_irq.c @@ -11,7 +11,7 @@ #include "command.h" // shutdown #include "sched.h" // sched_timer_dispatch -DECL_CONSTANT(CLOCK_FREQ, CONFIG_CLOCK_FREQ); +DECL_CONSTANT("CLOCK_FREQ", CONFIG_CLOCK_FREQ); // Return the number of clock ticks for a given number of microseconds uint32_t diff --git a/src/gpiocmds.c b/src/gpiocmds.c index 105d9d88..1d48a40e 100644 --- a/src/gpiocmds.c +++ b/src/gpiocmds.c @@ -107,7 +107,7 @@ DECL_COMMAND(command_set_digital_out, "set_digital_out pin=%u value=%c"); ****************************************************************/ #define MAX_SOFT_PWM 256 -DECL_CONSTANT(SOFT_PWM_MAX, MAX_SOFT_PWM); +DECL_CONSTANT("SOFT_PWM_MAX", MAX_SOFT_PWM); struct soft_pwm_s { struct timer timer; diff --git a/src/linux/analog.c b/src/linux/analog.c index 990f6c4a..5011f531 100644 --- a/src/linux/analog.c +++ b/src/linux/analog.c @@ -13,7 +13,7 @@ #include "internal.h" // report_errno #include "sched.h" // sched_shutdown -DECL_CONSTANT(ADC_MAX, 4095); // Assume 12bit adc +DECL_CONSTANT("ADC_MAX", 4095); // Assume 12bit adc #define IIO_PATH "/sys/bus/iio/devices/iio:device0/in_voltage%d_raw" diff --git a/src/linux/main.c b/src/linux/main.c index f351ec1f..4c5478eb 100644 --- a/src/linux/main.c +++ b/src/linux/main.c @@ -13,7 +13,7 @@ #include "internal.h" // console_setup #include "sched.h" // sched_main -DECL_CONSTANT(MCU, "linux"); +DECL_CONSTANT_STR("MCU", "linux"); /**************************************************************** diff --git a/src/linux/pca9685.c b/src/linux/pca9685.c index 0b9ff73d..14eefb15 100644 --- a/src/linux/pca9685.c +++ b/src/linux/pca9685.c @@ -136,7 +136,7 @@ struct i2cpwm_s { uint32_t max_duration; }; -DECL_CONSTANT(PCA9685_MAX, VALUE_MAX); +DECL_CONSTANT("PCA9685_MAX", VALUE_MAX); static uint_fast8_t pca9685_end_event(struct timer *timer) diff --git a/src/linux/timer.c b/src/linux/timer.c index faf6a5d2..15e5ab76 100644 --- a/src/linux/timer.c +++ b/src/linux/timer.c @@ -106,7 +106,7 @@ timer_check_periodic(struct timespec *ts) * Timers ****************************************************************/ -DECL_CONSTANT(CLOCK_FREQ, CONFIG_CLOCK_FREQ); +DECL_CONSTANT("CLOCK_FREQ", CONFIG_CLOCK_FREQ); // Return the number of clock ticks for a given number of microseconds uint32_t diff --git a/src/lpc176x/adc.c b/src/lpc176x/adc.c index e5ce6a96..1f5fbbde 100644 --- a/src/lpc176x/adc.c +++ b/src/lpc176x/adc.c @@ -23,7 +23,7 @@ static const uint8_t adc_pin_funcs[] = { }; #define ADC_FREQ_MAX 13000000 -DECL_CONSTANT(ADC_MAX, 4095); +DECL_CONSTANT("ADC_MAX", 4095); // The lpc176x adc is extremely noisy. Implement a 5 entry median // filter to weed out obviously incorrect readings. diff --git a/src/lpc176x/main.c b/src/lpc176x/main.c index 82777bc1..1147faec 100644 --- a/src/lpc176x/main.c +++ b/src/lpc176x/main.c @@ -8,7 +8,7 @@ #include "command.h" // DECL_CONSTANT #include "sched.h" // sched_main -DECL_CONSTANT(MCU, "lpc176x"); +DECL_CONSTANT_STR("MCU", "lpc176x"); /**************************************************************** diff --git a/src/pru/adc.c b/src/pru/adc.c index 62aca60a..81ec7fe3 100644 --- a/src/pru/adc.c +++ b/src/pru/adc.c @@ -16,7 +16,7 @@ * Analog to Digital Converter (ADC) pins ****************************************************************/ -DECL_CONSTANT(ADC_MAX, 4095); +DECL_CONSTANT("ADC_MAX", 4095); static void adc_full_reset(void) diff --git a/src/pru/main.c b/src/pru/main.c index 6019d087..88e622a6 100644 --- a/src/pru/main.c +++ b/src/pru/main.c @@ -17,7 +17,7 @@ #include "internal.h" // SHARED_MEM #include "sched.h" // sched_main -DECL_CONSTANT(MCU, "pru"); +DECL_CONSTANT_STR("MCU", "pru"); /**************************************************************** diff --git a/src/stepper.c b/src/stepper.c index 8f4ec816..d8129c4a 100644 --- a/src/stepper.c +++ b/src/stepper.c @@ -13,7 +13,7 @@ #include "sched.h" // struct timer #include "stepper.h" // command_config_stepper -DECL_CONSTANT(STEP_DELAY, CONFIG_STEP_DELAY); +DECL_CONSTANT("STEP_DELAY", CONFIG_STEP_DELAY); /**************************************************************** diff --git a/src/stm32f1/adc.c b/src/stm32f1/adc.c index 8eda4f8f..fcdcb911 100644 --- a/src/stm32f1/adc.c +++ b/src/stm32f1/adc.c @@ -14,7 +14,7 @@ #include "stm32f1xx_ll_gpio.h" // LL_GPIO_SetPinMode #include "sched.h" // sched_shutdown -DECL_CONSTANT(ADC_MAX, 4095); +DECL_CONSTANT("ADC_MAX", 4095); #define ADC_DELAY (240 * 8) diff --git a/src/stm32f1/main.c b/src/stm32f1/main.c index 3abb03a3..258578da 100644 --- a/src/stm32f1/main.c +++ b/src/stm32f1/main.c @@ -19,7 +19,7 @@ #include "stm32f1xx_ll_spi.h" #include "sched.h" // sched_main -DECL_CONSTANT(MCU, "stm32f103"); +DECL_CONSTANT_STR("MCU", "stm32f103"); /**************************************************************** |