X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fstm%2Fstm32l.h;h=cb66df6c9bdb440d4e745ba5b34aa0abf7cd752e;hb=629f43e7c7abbff33e14b168a08a4b6a9c88b937;hp=10a53a477fd7932d654dbbc0d2e34cb3af973814;hpb=1489263b895a2a825e29d0560c9b1dbba8a3f431;p=fw%2Faltos diff --git a/src/stm/stm32l.h b/src/stm/stm32l.h index 10a53a47..cb66df6c 100644 --- a/src/stm/stm32l.h +++ b/src/stm/stm32l.h @@ -855,10 +855,7 @@ isr(tim7) struct stm_syscfg { vuint32_t memrmp; vuint32_t pmc; - vuint32_t exticr1; - vuint32_t exticr2; - vuint32_t exticr3; - vuint32_t exticr4; + vuint32_t exticr[4]; }; extern struct stm_syscfg stm_syscfg; @@ -871,6 +868,34 @@ extern struct stm_syscfg stm_syscfg; #define STM_SYSCFG_PMC_USB_PU 0 +#define STM_SYSCFG_EXTICR_PA 0 +#define STM_SYSCFG_EXTICR_PB 1 +#define STM_SYSCFG_EXTICR_PC 2 +#define STM_SYSCFG_EXTICR_PD 3 +#define STM_SYSCFG_EXTICR_PE 4 +#define STM_SYSCFG_EXTICR_PH 5 + +static inline void +stm_exticr_set(struct stm_gpio *gpio, int pin) { + uint8_t reg = pin >> 2; + uint8_t shift = (pin & 3) << 2; + uint8_t val = 0; + + if (gpio == &stm_gpioa) + val = STM_SYSCFG_EXTICR_PA; + else if (gpio == &stm_gpiob) + val = STM_SYSCFG_EXTICR_PB; + else if (gpio == &stm_gpioc) + val = STM_SYSCFG_EXTICR_PC; + else if (gpio == &stm_gpiod) + val = STM_SYSCFG_EXTICR_PD; + else if (gpio == &stm_gpioe) + val = STM_SYSCFG_EXTICR_PE; + + stm_syscfg.exticr[reg] = (stm_syscfg.exticr[reg] & ~(0xf << shift)) | val << shift; +} + + struct stm_dma_channel { vuint32_t ccr; vuint32_t cndtr; @@ -953,8 +978,8 @@ extern struct stm_dma stm_dma; #define STM_DMA_CHANNEL_USART2_TX 7 #define STM_DMA_CHANNEL_I2C2_TX 4 #define STM_DMA_CHANNEL_I2C2_RX 5 -#define STM_DMA_CHANNEL_I2C1_RX 6 -#define STM_DMA_CHANNEL_I2C1_TX 7 +#define STM_DMA_CHANNEL_I2C1_TX 6 +#define STM_DMA_CHANNEL_I2C1_RX 7 #define STM_DMA_CHANNEL_TIM2_CH3 1 #define STM_DMA_CHANNEL_TIM2_UP 2 #define STM_DMA_CHANNEL_TIM2_CH1 5