From: Nathael Pajani Date: Sun, 29 Dec 2013 01:50:45 +0000 (+0100) Subject: Make use of config_gpio() function in all drivers. Remove unuseful calls to io_config... X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=28a900a92bbab227180a1a86b2768fe40f5bd651;p=soft%2Flpc122x%2Fcore Make use of config_gpio() function in all drivers. Remove unuseful calls to io_config_clk_*() functions. --- diff --git a/drivers/adc.c b/drivers/adc.c index de786ce..e230fe3 100644 --- a/drivers/adc.c +++ b/drivers/adc.c @@ -28,6 +28,7 @@ #include "core/lpc_regs_12xx.h" #include "core/lpc_core_cm0.h" #include "core/system.h" +#include "drivers/gpio.h" /* Should be as near to 9MHz as possible */ #define adc_clk_Val 9000000 @@ -125,19 +126,13 @@ void adc_set_resolution(int bits) /* ADC Setup : private part : Clocks, Pins, Power and Mode */ void set_adc_pins(void) { - struct lpc_io_control* ioctrl = LPC_IO_CONTROL; - - /* Make sure IO_Config is clocked */ - io_config_clk_on(); /* Configure ADC pins */ - ioctrl->pio0_30 = LPC_IO_FUNC_ALT(3) | LPC_IO_ANALOG; - ioctrl->pio0_31 = LPC_IO_FUNC_ALT(3) | LPC_IO_ANALOG; - ioctrl->pio1_0 = LPC_IO_FUNC_ALT(2) | LPC_IO_ANALOG; - ioctrl->pio1_1 = LPC_IO_FUNC_ALT(2) | LPC_IO_ANALOG; - ioctrl->pio1_2 = LPC_IO_FUNC_ALT(2) | LPC_IO_ANALOG; - ioctrl->pio1_3 = LPC_IO_FUNC_ALT(1) | LPC_IO_ANALOG; - /* Config done, power off IO_CONFIG block */ - io_config_clk_off(); + config_gpio(0, 30, (LPC_IO_FUNC_ALT(3) | LPC_IO_ANALOG)); + config_gpio(0, 31, (LPC_IO_FUNC_ALT(3) | LPC_IO_ANALOG)); + config_gpio(1, 0, (LPC_IO_FUNC_ALT(2) | LPC_IO_ANALOG)); + config_gpio(1, 1, (LPC_IO_FUNC_ALT(2) | LPC_IO_ANALOG)); + config_gpio(1, 2, (LPC_IO_FUNC_ALT(2) | LPC_IO_ANALOG)); + config_gpio(1, 3, (LPC_IO_FUNC_ALT(1) | LPC_IO_ANALOG)); } void adc_clk_update(void) diff --git a/drivers/i2c.c b/drivers/i2c.c index dc25e7a..3b47b27 100644 --- a/drivers/i2c.c +++ b/drivers/i2c.c @@ -26,6 +26,7 @@ #include "core/lpc_core_cm0.h" #include "core/system.h" #include "lib/string.h" +#include "drivers/gpio.h" #include "drivers/i2c.h" @@ -449,14 +450,8 @@ static void i2c_clock_on(uint32_t i2c_clk_freq) void set_i2c_pins(void) { - struct lpc_io_control* ioctrl = LPC_IO_CONTROL; - - /* Make sure IO_Config is clocked */ - io_config_clk_on(); - ioctrl->pio0_10 = LPC_IO_FUNC_ALT(2) | LPC_IO_OPEN_DRAIN_ENABLE; /* True open drain */ - ioctrl->pio0_11 = LPC_IO_FUNC_ALT(2) | LPC_IO_OPEN_DRAIN_ENABLE; - /* Config done, power off IO_CONFIG block */ - io_config_clk_off(); + config_gpio(0, 10, (LPC_IO_FUNC_ALT(2) | LPC_IO_OPEN_DRAIN_ENABLE)); /* True open drain */ + config_gpio(0, 11, (LPC_IO_FUNC_ALT(2) | LPC_IO_OPEN_DRAIN_ENABLE)); } void i2c_on(uint32_t i2c_clk_freq) diff --git a/drivers/serial.c b/drivers/serial.c index 5a1ee3a..b8bb6f1 100644 --- a/drivers/serial.c +++ b/drivers/serial.c @@ -31,6 +31,7 @@ #include "core/system.h" #include "lib/string.h" #include "drivers/timers.h" +#include "drivers/gpio.h" #define SERIAL_OUT_BUFF_SIZE 64 struct uart_device @@ -226,23 +227,17 @@ static uint32_t uart_mode_setup(uint32_t uart_num) */ static void uart_set_pin_func(uint32_t uart_num) { - struct lpc_io_control* ioctrl = LPC_IO_CONTROL; - - /* Make sure IO_Config is clocked */ - io_config_clk_on(); /* Configure UART pins (Only Rx and Tx) */ switch (uart_num) { case 0: - ioctrl->pio0_1 = LPC_IO_FUNC_ALT(2) | LPC_IO_DIGITAL; - ioctrl->pio0_2 = LPC_IO_FUNC_ALT(2) | LPC_IO_DIGITAL; + config_gpio(0, 1, (LPC_IO_FUNC_ALT(2) | LPC_IO_DIGITAL)); + config_gpio(0, 2, (LPC_IO_FUNC_ALT(2) | LPC_IO_DIGITAL)); break; case 1: - ioctrl->pio0_8 = LPC_IO_FUNC_ALT(2) | LPC_IO_DIGITAL; - ioctrl->pio0_9 = LPC_IO_FUNC_ALT(2) | LPC_IO_DIGITAL; + config_gpio(0, 8, (LPC_IO_FUNC_ALT(2) | LPC_IO_DIGITAL)); + config_gpio(0, 9, (LPC_IO_FUNC_ALT(2) | LPC_IO_DIGITAL)); break; } - /* Config done, power off IO_CONFIG block */ - io_config_clk_off(); } struct uart_def { diff --git a/drivers/ssp.c b/drivers/ssp.c index 1194291..43331bc 100644 --- a/drivers/ssp.c +++ b/drivers/ssp.c @@ -101,9 +101,7 @@ int spi_device_cs_pull_low(void) } /* Configure pin as GPIO */ - io_config_clk_on(); config_gpio(0, SPI_CS_PIN, (LPC_IO_FUNC_ALT(0) | LPC_IO_MODE_PULL_UP | LPC_IO_DIGITAL)); - io_config_clk_off(); /* Configure pin as output and set it low */ gpio0->data_dir |= (1 << SPI_CS_PIN); gpio0->clear = (1 << SPI_CS_PIN); @@ -116,9 +114,7 @@ void spi_device_cs_release(void) /* Set pin high */ gpio0->set = (1 << SPI_CS_PIN); /* Configure pin as SPI again */ - io_config_clk_on(); config_gpio(0, SPI_CS_PIN, (LPC_IO_FUNC_ALT(2) | LPC_IO_DIGITAL)); /* SPI Chip Select */ - io_config_clk_off(); } @@ -251,14 +247,10 @@ void ssp_clk_update(void) */ void set_ssp_pins(void) { - /* Make sure IO_Config is clocked */ - io_config_clk_on(); /* Main SPI pins */ config_gpio(0, 14, (LPC_IO_FUNC_ALT(2) | LPC_IO_DIGITAL)); /* SPI Clock */ config_gpio(0, 16, (LPC_IO_FUNC_ALT(2) | LPC_IO_DIGITAL)); /* SPI MISO */ config_gpio(0, 17, (LPC_IO_FUNC_ALT(2) | LPC_IO_DIGITAL)); /* SPI MOSI */ - /* Config done, power off IO_CONFIG block */ - io_config_clk_off(); } @@ -321,10 +313,7 @@ int ssp_slave_on(uint8_t frame_type, uint8_t data_width, uint8_t out_en, uint32_ } /* Use SPI as Device : configure the SSEL pin */ - /* Make sure IO_Config is clocked */ - io_config_clk_on(); config_gpio(0, SPI_CS_PIN, (LPC_IO_FUNC_ALT(2) | LPC_IO_DIGITAL)); /* SPI Chip Select */ - io_config_clk_off(); /* Configure the clock : done after basic configuration. * Our clock must be at least 12 times the master clock */