New paste Repaste Download
\ ------------------------------------------------------------------------------ \
\ gpio-1.fs
\ purpose: gpio configs
\ PA1 is ANALOG INPUT for LMT-01 PULSES
\ PC1 is OUTPUT HIGH to power LMT-01 or FLOATING/LOW to disable LMT-01
: gpio-init ( -- )
\ Enable GPIOA and GPIOC
true IOPAEN      \ enable GPIOA for inputs
true IOPCEN      \ enable GPIOC for leds
+ RCC_AHBENR bis!
\ PA1 is COMP1 & 2 INPUT. I/Os used as comparators inputs must be configured in analog mode.
ANALOG MODER1 GPIOA_MODER bis!
\ PA5 is TIM2_CH1_ETR external clock via AF2
AF MODER5 GPIOA_MODER bis!
AF2 AFRL5 GPIOA_AFRL bis!
\ PA6 COMP1 OUT for LMT01 pulses
AF  MODER6 GPIOA_MODER bis!
AF7 AFRL6  GPIOA_AFRL bis!
\ PA7 is INPUT for TIM14_CH1 via AF4
AF MODER7 GPIOA_MODER bis!
AF4 AFRL7  GPIOA_AFRL bis!
\ PA12 is COMP2 out via AF7 for LED
AF MODER12 GPIOA_MODER bis!    \ select AF mode
AF7 AFRH12 GPIOA_AFRH bis!    \ set AF7 for PA12
\ Power to LMT-01 via PC1
OUTPUT MODER1  GPIOC_MODER bis! \ PC1 to output (%01) PUSH PULL
true BR1 GPIOC_BSRR ! \ PC1 set, BSRR is atomic so no bis! is needed
\ GPIOC 8 and 9 drive leds
OUTPUT MODER8 \ blue led
OUTPUT MODER9 \ green led
+ GPIOC_MODER bis!
;
Filename: gpio-1.fs. Size: 1kb. View raw, , hex, or download this file.

This paste expires on 2025-09-17 01:22:34.513510. Pasted through v1-api.