From eb1caa84eca2959ba2a90085a394228ce7e17f9b Mon Sep 17 00:00:00 2001 From: Nathael Pajani Date: Sun, 7 Dec 2014 22:04:33 +0100 Subject: [PATCH] use const for functions which do not modify the pio structures. --- core/pio.c | 4 ++-- drivers/gpio.c | 6 +++--- include/core/pio.h | 4 ++-- include/drivers/gpio.h | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/pio.c b/core/pio.c index 0cb773c..149cbc0 100644 --- a/core/pio.c +++ b/core/pio.c @@ -97,7 +97,7 @@ static volatile uint32_t* pio_regs_handles_port2[PORT2_NB_PINS] = { }; /* Simple copy function. */ -void pio_copy(struct pio* dst, struct pio* src) +void pio_copy(struct pio* dst, const struct pio* src) { if ((dst == NULL) || (src == NULL)) { return; @@ -108,7 +108,7 @@ void pio_copy(struct pio* dst, struct pio* src) } /* Configure the pin in the requested function and mode. */ -void config_pio(struct pio* pp, uint32_t mode) +void config_pio(const struct pio* pp, uint32_t mode) { volatile uint32_t* handle = NULL; diff --git a/drivers/gpio.c b/drivers/gpio.c index d978cae..be0da15 100644 --- a/drivers/gpio.c +++ b/drivers/gpio.c @@ -71,7 +71,7 @@ void gpio_off(void) * This function calls the config_pio() function for the gpio with the given * mode, configures the direction of the pin and sets the initial state. */ -void config_gpio(struct pio* gpio, uint32_t mode, uint8_t dir, uint8_t ini_val) +void config_gpio(const struct pio* gpio, uint32_t mode, uint8_t dir, uint8_t ini_val) { struct lpc_gpio* gpio_port = LPC_GPIO_REGS(gpio->port); @@ -96,7 +96,7 @@ static void (*gpio_calbacks_port0[PORT0_NB_PINS]) (uint32_t); static void (*gpio_calbacks_port1[PORT1_NB_PINS]) (uint32_t); static void (*gpio_calbacks_port2[PORT2_NB_PINS]) (uint32_t); -int set_gpio_callback(void (*callback) (uint32_t), struct pio* gpio, uint8_t sense) +int set_gpio_callback(void (*callback) (uint32_t), const struct pio* gpio, uint8_t sense) { struct lpc_gpio* gpio_port = LPC_GPIO_REGS(gpio->port); uint32_t irq = 0; @@ -161,7 +161,7 @@ int set_gpio_callback(void (*callback) (uint32_t), struct pio* gpio, uint8_t sen NVIC_EnableIRQ(irq); return 0; } -void remove_gpio_callback(struct pio* gpio) +void remove_gpio_callback(const struct pio* gpio) { struct lpc_gpio* gpio_port = LPC_GPIO_REGS(gpio->port); uint32_t irq = 0; diff --git a/include/core/pio.h b/include/core/pio.h index 66a6593..fb558fe 100644 --- a/include/core/pio.h +++ b/include/core/pio.h @@ -42,10 +42,10 @@ struct pio { #define PORT2_NB_PINS 16 /* Simple copy function. */ -void pio_copy(struct pio* dst, struct pio* src); +void pio_copy(struct pio* dst, const struct pio* src); /* Configure the pin in the requested function and mode. */ -void config_pio(struct pio* pp, uint32_t mode); +void config_pio(const struct pio* pp, uint32_t mode); /****************************************************************************/ diff --git a/include/drivers/gpio.h b/include/drivers/gpio.h index a7fae5a..c1589cd 100644 --- a/include/drivers/gpio.h +++ b/include/drivers/gpio.h @@ -39,8 +39,8 @@ enum gpio_interrupt_senses { }; /* GPIO Interrupts */ -int set_gpio_callback(void (*callback) (uint32_t), struct pio* gpio, uint8_t sense); -void remove_gpio_callback(struct pio* gpio); +int set_gpio_callback(void (*callback) (uint32_t), const struct pio* gpio, uint8_t sense); +void remove_gpio_callback(const struct pio* gpio); /* GPIO Activation */ @@ -52,7 +52,7 @@ void gpio_off(void); * This function calls the config_pio() function for the gpio with the given * mode, configures the direction of the pin and sets the initial state. */ -void config_gpio(struct pio* gpio, uint32_t mode, uint8_t dir, uint8_t ini_val); +void config_gpio(const struct pio* gpio, uint32_t mode, uint8_t dir, uint8_t ini_val); #endif /* DRIVERS_GPIO_H */ -- 2.43.0