#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
/* 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)
#include "core/lpc_core_cm0.h"
#include "core/system.h"
#include "lib/string.h"
+#include "drivers/gpio.h"
#include "drivers/i2c.h"
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)
#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
*/
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
{
}
/* 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);
/* 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();
}
*/
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();
}
}
/* 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 */