spi_clk_update();
}
+/* IO config clock */
+/* To change GPIO config the io config block must be powered on */
+void io_config_clk_on(void)
+{
+ subsystem_power(LPC_SYS_ABH_CLK_CTRL_IO_CONFIG, 1);
+}
+void io_config_clk_off(void)
+{
+ subsystem_power(LPC_SYS_ABH_CLK_CTRL_IO_CONFIG, 0);
+}
+
/***************************************************************************** */
/* CLK Out */
/***************************************************************************** */
void config_gpio(volatile uint32_t* handle, uint32_t mode)
{
/* Make sure IO_Config is clocked */
- subsystem_power(LPC_SYS_ABH_CLK_CTRL_IO_CONFIG, 1);
+ io_config_clk_on();
*handle = mode;
/* Config done, power off IO_CONFIG block */
- subsystem_power(LPC_SYS_ABH_CLK_CTRL_IO_CONFIG, 0);
+ io_config_clk_off();
}
void gpio_on(void)
struct lpc_io_control* ioctrl = LPC_IO_CONTROL;
/* Make sure IO_Config is clocked */
- subsystem_power(LPC_SYS_ABH_CLK_CTRL_IO_CONFIG, 1);
+ io_config_clk_on();
/* Configure GPIO pins */
ioctrl->pio0_0 = LPC_IO_FUNC_ALT(0) | LPC_IO_MODE_PULL_UP;
ioctrl->pio1_3 = LPC_IO_FUNC_ALT(1) | LPC_IO_ANALOG;
/* Config done, power off IO_CONFIG block */
- subsystem_power(LPC_SYS_ABH_CLK_CTRL_IO_CONFIG, 1);
+ io_config_clk_off();
}
/* Handlers */
struct lpc_io_control* ioctrl = LPC_IO_CONTROL;
/* Make sure IO_Config is clocked */
- subsystem_power(LPC_SYS_ABH_CLK_CTRL_IO_CONFIG, 1);
+ 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 */
- subsystem_power(LPC_SYS_ABH_CLK_CTRL_IO_CONFIG, 0);
+ io_config_clk_off();
}
void i2c_on(uint32_t i2c_clk_freq)
*/
static void uart_set_pin_func(uint32_t uart_num)
{
- struct lpc_sys_control* sys_ctrl = LPC_SYS_CONTROL;
struct lpc_io_control* ioctrl = LPC_IO_CONTROL;
/* Make sure IO_Config is clocked */
- sys_ctrl->sys_AHB_clk_ctrl |= LPC_SYS_ABH_CLK_CTRL_IO_CONFIG;
+ io_config_clk_on();
/* Configure UART pins (Only Rx and Tx) */
switch (uart_num) {
case 0:
break;
}
/* Config done, power off IO_CONFIG block */
- sys_ctrl->sys_AHB_clk_ctrl &= ~LPC_SYS_ABH_CLK_CTRL_IO_CONFIG;
+ io_config_clk_off();
}
struct uart_def
{
/* return current main clock */
uint32_t get_main_clock(void);
+/* IO config clock */
+/* To change GPIO config the io config block must be powered on */
+void io_config_clk_on(void);
+void io_config_clk_off(void);
/* This is mainly a debug feature, but can be used to provide a clock to an
* external peripheral */