diff options
author | Keith Packard <keithp@keithp.com> | 2014-11-06 16:04:56 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2014-11-06 16:04:56 -0800 |
commit | 6a082d9b5ed169b9d4153885f3535987e5ae5d84 (patch) | |
tree | 54f823510473dd415abe0d22da3c6ec1ba7530ab /src/lpc/ao_arch_funcs.h | |
parent | 58db263cc835be0abb972654c2d7369718c88b37 (diff) |
altos/lpc: Disable JTAG when using pins for GPIO
JTAG is enabled by default, making those pins not support GPIO unless
specifically configured.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/lpc/ao_arch_funcs.h')
-rw-r--r-- | src/lpc/ao_arch_funcs.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lpc/ao_arch_funcs.h b/src/lpc/ao_arch_funcs.h index ff8a184d..69f2cbfb 100644 --- a/src/lpc/ao_arch_funcs.h +++ b/src/lpc/ao_arch_funcs.h @@ -30,8 +30,19 @@ #define ao_gpio_get(port, bit, pin) (lpc_gpio.byte[lpc_all_bit(port,bit)]) +#define PORT0_JTAG_REGS ((1 << 11) | (1 << 12) | (1 << 14)) + +static inline void lpc_set_gpio(int port, int bit) { + if (port == 0 && (1 << bit) & (PORT0_JTAG_REGS)) { + vuint32_t *_ioconf = &lpc_ioconf.pio0_0 + ((port)*24+(bit)); + + *_ioconf = (*_ioconf & ~LPC_IOCONF_FUNC_MASK) | LPC_IOCONF_FUNC_PIO0_11; + } +} + #define ao_enable_output(port,bit,pin,v) do { \ ao_enable_port(port); \ + lpc_set_gpio(port,bit); \ ao_gpio_set(port, bit, pin, v); \ lpc_gpio.dir[port] |= (1 << bit); \ } while (0) @@ -52,6 +63,7 @@ #define ao_enable_input(port,bit,mode) do { \ ao_enable_port(port); \ + lpc_set_gpio(port,bit); \ lpc_gpio.dir[port] &= ~(1 << bit); \ ao_gpio_set_mode(port,bit,mode); \ } while (0) |