X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Flpc%2Fao_arch_funcs.h;h=3cd873ec89c3017a4364fbd063935e4d094be012;hb=3587bfd248e115bb1abb28f71b263575b4e8e367;hp=94d876f6676f9eb4084849ed3df81028183651fa;hpb=935a7ff38010ec4ad19f315f8a2a1557c01ae554;p=fw%2Faltos diff --git a/src/lpc/ao_arch_funcs.h b/src/lpc/ao_arch_funcs.h index 94d876f6..3cd873ec 100644 --- a/src/lpc/ao_arch_funcs.h +++ b/src/lpc/ao_arch_funcs.h @@ -36,16 +36,29 @@ } while (0) #define ao_enable_input(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) \ - stm_pupdr_set(port, bit, STM_PUPDR_PULL_UP); \ + _mode = LPC_IOCONF_MODE_PULL_UP << LPC_IOCONF_MODE; \ else if (mode == AO_EXTI_MODE_PULL_DOWN) \ - stm_pupdr_set(port, bit, STM_PUPDR_PULL_DOWN); \ + _mode = LPC_IOCONF_MODE_PULL_UP << LPC_IOCONF_MODE; \ else \ - stm_pupdr_set(port, bit, STM_PUPDR_NONE); \ + _mode = LPC_IOCONF_MODE_INACTIVE << LPC_IOCONF_MODE; \ + *_ioconf = ((*_ioconf & ~(LPC_IOCONF_MODE_MASK << LPC_IOCONF_MODE)) | \ + _mode | \ + (1 << LPC_IOCONF_ADMODE)); \ } while (0) +#define ao_enable_analog(port,bit) do { \ + vuint32_t *_ioconf = &lpc_ioconf.pio0_0 + ((port)*24+(bit)); \ + ao_enable_port(port); \ + lpc_gpio.dir[port] &= ~(1 << bit); \ + *_ioconf = *_ioconf & ~((1 << LPC_IOCONF_ADMODE) | \ + (LPC_IOCONF_MODE_MASK << LPC_IOCONF_MODE)); \ + } while (0) + #define ARM_PUSH32(stack, val) (*(--(stack)) = (val)) static inline uint32_t @@ -195,4 +208,17 @@ ao_spi_init(void); } \ } while (0) +#define HAS_ARCH_START_SCHEDULER 1 + +static inline void ao_arch_start_scheduler(void) { + uint32_t sp; + uint32_t control; + + asm("mrs %0,msp" : "=&r" (sp)); + asm("msr psp,%0" : : "r" (sp)); + asm("mrs %0,control" : "=&r" (control)); + control |= (1 << 1); + asm("msr control,%0" : : "r" (control)); +} + #endif /* _AO_ARCH_FUNCS_H_ */