summaryrefslogtreecommitdiff
path: root/src/stm/ao_arch_funcs.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/stm/ao_arch_funcs.h')
-rw-r--r--src/stm/ao_arch_funcs.h26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/stm/ao_arch_funcs.h b/src/stm/ao_arch_funcs.h
index f3d68202..1e78cabc 100644
--- a/src/stm/ao_arch_funcs.h
+++ b/src/stm/ao_arch_funcs.h
@@ -113,6 +113,19 @@ ao_spi_init(void);
stm_rcc.ahbenr |= (1 << STM_RCC_AHBENR_GPIOEEN); \
} while (0)
+#define ao_disable_port(port) do { \
+ if ((port) == &stm_gpioa) \
+ stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_GPIOAEN); \
+ else if ((port) == &stm_gpiob) \
+ stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_GPIOBEN); \
+ else if ((port) == &stm_gpioc) \
+ stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_GPIOCEN); \
+ else if ((port) == &stm_gpiod) \
+ stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_GPIODEN); \
+ else if ((port) == &stm_gpioe) \
+ stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_GPIOEEN); \
+ } while (0)
+
#define ao_gpio_set(port, bit, pin, v) stm_gpio_set(port, bit, v)
@@ -124,9 +137,7 @@ ao_spi_init(void);
stm_moder_set(port, bit, STM_MODER_OUTPUT);\
} while (0)
-#define ao_enable_input(port,bit,mode) do { \
- ao_enable_port(port); \
- stm_moder_set(port, bit, STM_MODER_INPUT); \
+#define ao_gpio_set_mode(port,bit,mode) do { \
if (mode == AO_EXTI_MODE_PULL_UP) \
stm_pupdr_set(port, bit, STM_PUPDR_PULL_UP); \
else if (mode == AO_EXTI_MODE_PULL_DOWN) \
@@ -134,6 +145,12 @@ ao_spi_init(void);
else \
stm_pupdr_set(port, bit, STM_PUPDR_NONE); \
} while (0)
+
+#define ao_enable_input(port,bit,mode) do { \
+ ao_enable_port(port); \
+ stm_moder_set(port, bit, STM_MODER_INPUT); \
+ ao_gpio_set_mode(port, bit, mode); \
+ } while (0)
#define ao_enable_cs(port,bit) do { \
stm_gpio_set((port), bit, 1); \
@@ -250,6 +267,7 @@ ao_arch_memory_barrier() {
asm volatile("" ::: "memory");
}
+#if HAS_TASK
static inline void
ao_arch_init_stack(struct ao_task *task, void *start)
{
@@ -332,6 +350,8 @@ static inline void ao_arch_start_scheduler(void) {
#define ao_arch_isr_stack()
+#endif
+
#define ao_arch_wait_interrupt() do { \
asm(".global ao_idle_loc\n\twfi\nao_idle_loc:"); \
ao_arch_release_interrupts(); \