#ifndef __GLOBAL_H__ #define __GLOBAL_H__ #include #include #include #include #include /* The IRQ header must be included before stm32_device.h since ST defines a bunch of messy macros there. */ #include /* Header generated from stm32***_startup.s in Makefile */ #include #include #define DMA_ISR_FLAGS_Pos(channel) (4 * ((channel) - 1)) #define DMA_ISR_FLAGS_CH(channel) (0xf << DMA_ISR_FLAGS_Pos(channel)) #define COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x]))))) #define APB1_PRESC (1<<(APBPrescTable[(RCC->CFGR & RCC_CFGR_PPRE1_Msk) >> RCC_CFGR_PPRE1_Pos])) #define AHB_PRESC (1<<(AHBPrescTable[(RCC->CFGR & RCC_CFGR_HPRE_Msk) >> RCC_CFGR_HPRE_Pos])) #define AFRL(pin, val) ((val) << ((pin)*4)) #define AFRH(pin, val) ((val) << (((pin)-8)*4)) #define AF(pin) (2<<(2*(pin))) #define OUT(pin) (1<<(2*(pin))) #define IN(pin) (0) #define ANALOG(pin) (3<<(2*(pin))) #define CLEAR(pin) (3<<(2*(pin))) #define PULLUP(pin) (1<<(2*pin)) #define PULLDOWN(pin) (2<<(2*pin)) #define BSRR_CLEAR(pin) ((1<