From: Nathael Pajani Date: Thu, 31 Jul 2014 19:54:22 +0000 (+0200) Subject: Declare a weak "empty" pio struct for each driver inside the driver so that there... X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=5ccdf288885330118a6af427a5eb5c7b123b9c3f;p=soft%2Flpc122x%2Fcore Declare a weak "empty" pio struct for each driver inside the driver so that there's no need to do it in the "main.c" file when the function is not used. --- diff --git a/core/pio.c b/core/pio.c index d1cb89d..0cb773c 100644 --- a/core/pio.c +++ b/core/pio.c @@ -22,6 +22,7 @@ /* GPIOs */ /***************************************************************************** */ +/* Public access to Pins setup */ #include @@ -31,8 +32,8 @@ #include "core/pio.h" + /***************************************************************************** */ -/* Public access to GPIO setup */ static volatile uint32_t* pio_regs_handles_port0[PORT0_NB_PINS] = { &(LPC_IO_CONTROL->pio0_0), &(LPC_IO_CONTROL->pio0_1), diff --git a/drivers/adc.c b/drivers/adc.c index 29f8bf0..f35323b 100644 --- a/drivers/adc.c +++ b/drivers/adc.c @@ -148,7 +148,9 @@ void adc_set_resolution(int bits) /***************************************************************************** */ /* ADC Setup : private part : Clocks, Pins, Power and Mode */ -extern struct pio adc_pins[]; +struct pio adc_pins[] __attribute__ ((weak)) = { + ARRAY_LAST_PIN, +}; static void set_adc_pins(void) { diff --git a/drivers/gpio.c b/drivers/gpio.c index 8fa1d21..d978cae 100644 --- a/drivers/gpio.c +++ b/drivers/gpio.c @@ -37,7 +37,9 @@ /* GPIO setup */ /* Set all GPIO used in a default state */ -extern struct pio gpio_pins[]; +struct pio gpio_pins[] __attribute__ ((weak)) = { + ARRAY_LAST_PIN, +}; static void set_gpio_pins(void) { diff --git a/drivers/i2c.c b/drivers/i2c.c index 41a2e71..3934500 100644 --- a/drivers/i2c.c +++ b/drivers/i2c.c @@ -454,7 +454,10 @@ static void i2c_clock_on(uint32_t i2c_clk_freq) } /* I2C Pins configuration */ -extern struct pio i2c0_pins[]; +struct pio i2c0_pins[] __attribute__ ((weak)) = { + ARRAY_LAST_PIN, +}; + static void set_i2c_pins(void) { diff --git a/drivers/serial.c b/drivers/serial.c index 02527db..24c7d9b 100644 --- a/drivers/serial.c +++ b/drivers/serial.c @@ -235,8 +235,12 @@ static uint32_t uart_setup(uint32_t uart_num) /* Note : We MUST set LPC_IO_DIGITAL for Rx even if the bit is marked as "Reserved" in * the datasheet ! */ -extern struct pio uart0_pins[]; -extern struct pio uart1_pins[]; +struct pio uart0_pins[] __attribute__ ((weak)) = { + ARRAY_LAST_PIN, +}; +struct pio uart1_pins[] __attribute__ ((weak)) = { + ARRAY_LAST_PIN, +}; static void uart_set_pin_func(uint32_t uart_num) { diff --git a/drivers/ssp.c b/drivers/ssp.c index 37d3f54..cb323dd 100644 --- a/drivers/ssp.c +++ b/drivers/ssp.c @@ -305,7 +305,9 @@ void ssp_clk_update(void) } /* Configure all SPI pins. */ -extern struct pio ssp0_pins[]; +struct pio ssp0_pins[] __attribute__ ((weak)) = { + ARRAY_LAST_PIN, +}; static void ssp_set_pin_func(uint32_t ssp_num) { int i = 0; diff --git a/drivers/timers.c b/drivers/timers.c index 8a28cab..544ffe3 100644 --- a/drivers/timers.c +++ b/drivers/timers.c @@ -200,10 +200,18 @@ int timer_setup(uint32_t timer_num, struct timer_config* conf) /* Setup timer pins to be used as match or capture pin */ -extern struct pio timer0_pins[]; -extern struct pio timer1_pins[]; -extern struct pio timer2_pins[]; -extern struct pio timer3_pins[]; +struct pio timer0_pins[] __attribute__ ((weak)) = { + ARRAY_LAST_PIN, +}; +struct pio timer1_pins[] __attribute__ ((weak)) = { + ARRAY_LAST_PIN, +}; +struct pio timer2_pins[] __attribute__ ((weak)) = { + ARRAY_LAST_PIN, +}; +struct pio timer3_pins[] __attribute__ ((weak)) = { + ARRAY_LAST_PIN, +}; #define LPC_TIMER_PIN_CONFIG (LPC_IO_MODE_PULL_UP | LPC_IO_DIGITAL | LPC_IO_DRIVE_HIGHCURENT) static void timer_pins_setup(uint32_t timer_num) diff --git a/include/core/pio.h b/include/core/pio.h index 97daffc..66a6593 100644 --- a/include/core/pio.h +++ b/include/core/pio.h @@ -21,6 +21,11 @@ #ifndef CORE_PIO_H #define CORE_PIO_H +/* The "PIO" module gives access to the configuration of all the pins of the + * micro-controller, whatever the function of the pin. + * It has nothing related to GPIO function of the pins. + */ + #include struct pio {