diff options
author | Keith Packard <keithp@keithp.com> | 2013-06-24 14:23:53 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2013-06-24 14:30:22 -0700 |
commit | 0dd148e388944d8d265da51d62806c4a00b2c13d (patch) | |
tree | e1212b3cbc0d5a77d0fe1d676e07f86fef91a52f /src/lpc/ao_arch_funcs.h | |
parent | 2568b36ae9d38ae1607ec08b84b06e0fe84bd3ba (diff) |
altos/lpc: Add boot loader
Support the USB boot loader, add USB pull-up support.
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 | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/lpc/ao_arch_funcs.h b/src/lpc/ao_arch_funcs.h index 1bbb14f5..9a3219a2 100644 --- a/src/lpc/ao_arch_funcs.h +++ b/src/lpc/ao_arch_funcs.h @@ -22,12 +22,13 @@ #define ao_spi_put_bit(reg,bit,pin,bus) ao_spi_put_mask(reg,(1<<bit),bus) #define ao_enable_port(port) (lpc_scb.sysahbclkctrl |= (1 << LPC_SCB_SYSAHBCLKCTRL_GPIO)) +#define ao_disable_port(port) (lpc_scb.sysahbclkctrl &= ~(1 << LPC_SCB_SYSAHBCLKCTRL_GPIO)) #define lpc_all_bit(port,bit) (((port) << 5) | (bit)) #define ao_gpio_set(port, bit, pin, v) (lpc_gpio.byte[lpc_all_bit(port,bit)] = (v)) -#define ao_gpio_get(port, bit, pin) (lpc_gpio_byte[lpc_all_bit(port,bit)]) +#define ao_gpio_get(port, bit, pin) (lpc_gpio.byte[lpc_all_bit(port,bit)]) #define ao_enable_output(port,bit,pin,v) do { \ ao_enable_port(port); \ @@ -35,11 +36,9 @@ lpc_gpio.dir[port] |= (1 << bit); \ } while (0) -#define ao_enable_input(port,bit,mode) do { \ +#define ao_gpio_set_mode(port,bit,mode) do { \ vuint32_t *_ioconf = &lpc_ioconf.pio0_0 + ((port)*24+(bit)); \ vuint32_t _mode; \ - ao_enable_port(port); \ - lpc_gpio.dir[port] &= ~(1 << bit); \ if (mode == AO_EXTI_MODE_PULL_UP) \ _mode = LPC_IOCONF_MODE_PULL_UP << LPC_IOCONF_MODE; \ else if (mode == AO_EXTI_MODE_PULL_DOWN) \ @@ -51,6 +50,12 @@ (1 << LPC_IOCONF_ADMODE)); \ } while (0) +#define ao_enable_input(port,bit,mode) do { \ + ao_enable_port(port); \ + lpc_gpio.dir[port] &= ~(1 << bit); \ + ao_gpio_set_mode(port,bit,mode); \ + } while (0) + #define lpc_token_paster_2(x,y) x ## y #define lpc_token_evaluator_2(x,y) lpc_token_paster_2(x,y) #define lpc_token_paster_3(x,y,z) x ## y ## z @@ -87,6 +92,7 @@ ao_arch_memory_barrier() { asm volatile("" ::: "memory"); } +#if HAS_TASK static inline void ao_arch_init_stack(struct ao_task *task, void *start) { @@ -153,6 +159,8 @@ static inline void ao_arch_restore_stack(void) { #define ao_arch_isr_stack() +#endif /* HAS_TASK */ + #define ao_arch_wait_interrupt() do { \ asm(".global ao_idle_loc\n\twfi\nao_idle_loc:"); \ ao_arch_release_interrupts(); \ |