//! General-purpose I/O port heads. //! //! For STM32F4 series of high-performance MCUs with DSP and FPU instructions. use drone_core::periph; use drone_cortexm::reg::marker::*; periph! { /// Generic GPIO port head peripheral variant. pub trait GpioHeadMap {} /// Generic GPIO port head peripheral. pub struct GpioHeadPeriph; RCC { BUSENR { 0x20 RwRegBitBand Shared; GPIOEN { RwRwRegFieldBitBand } } BUSRSTR { 0x20 RwRegBitBand Shared; GPIORST { RwRwRegFieldBitBand } } #[cfg(any( stm32_mcu = "stm32f401", stm32_mcu = "stm32f405", stm32_mcu = "stm32f407", stm32_mcu = "stm32f410", stm32_mcu = "stm32f411", stm32_mcu = "stm32f412", stm32_mcu = "stm32f413", stm32_mcu = "stm32f427", stm32_mcu = "stm32f429", stm32_mcu = "stm32f446", stm32_mcu = "stm32f469", ))] BUSSMENR { 0x20 RwRegBitBand Shared; GPIOSMEN { RwRwRegFieldBitBand } } } GPIO { LCKR { 0x20 RwReg Shared; LCKK { RwRwRegFieldBit } } } } macro_rules! map_gpio_port_head { ( $port_macro_doc:expr, $port_macro:ident, $port_ty_doc:expr, $port_ty:ident, $busenr:ident, $busrstr:ident, $bussmenr:ident, $gpio:ident, $gpioen:ident, $gpiorst:ident, $gpiosmen:ident, ) => { periph::map! { #[doc = $port_macro_doc] pub macro $port_macro; #[doc = $port_ty_doc] pub struct $port_ty; impl GpioHeadMap for $port_ty {} drone_stm32_map_pieces::reg; crate::head; RCC { BUSENR { $busenr Shared; GPIOEN { $gpioen } } BUSRSTR { $busrstr Shared; GPIORST { $gpiorst } } #[cfg(any( stm32_mcu = "stm32f401", stm32_mcu = "stm32f405", stm32_mcu = "stm32f407", stm32_mcu = "stm32f410", stm32_mcu = "stm32f411", stm32_mcu = "stm32f412", stm32_mcu = "stm32f413", stm32_mcu = "stm32f427", stm32_mcu = "stm32f429", stm32_mcu = "stm32f446", stm32_mcu = "stm32f469", ))] BUSSMENR { $bussmenr Shared; GPIOSMEN { $gpiosmen } } } GPIO { $gpio; LCKR { LCKR Shared; LCKK { LCKK } } } } }; } map_gpio_port_head! { "Extracts GPIO port A head register tokens.", periph_gpio_a_head, "GPIO port A head peripheral variant.", GpioAHead, AHB1ENR, AHB1RSTR, AHB1LPENR, GPIOA, GPIOAEN, GPIOARST, GPIOALPEN, } map_gpio_port_head! { "Extracts GPIO port B head register tokens.", periph_gpio_b_head, "GPIO port B head peripheral variant.", GpioBHead, AHB1ENR, AHB1RSTR, AHB1LPENR, GPIOB, GPIOBEN, GPIOBRST, GPIOBLPEN, } map_gpio_port_head! { "Extracts GPIO port C head register tokens.", periph_gpio_c_head, "GPIO port C head peripheral variant.", GpioCHead, AHB1ENR, AHB1RSTR, AHB1LPENR, GPIOC, GPIOCEN, GPIOCRST, GPIOCLPEN, } #[cfg(any( stm32_mcu = "stm32f401", stm32_mcu = "stm32f405", stm32_mcu = "stm32f407", stm32_mcu = "stm32f411", stm32_mcu = "stm32f412", stm32_mcu = "stm32f413", stm32_mcu = "stm32f427", stm32_mcu = "stm32f429", stm32_mcu = "stm32f446", stm32_mcu = "stm32f469", ))] map_gpio_port_head! { "Extracts GPIO port D head register tokens.", periph_gpio_d_head, "GPIO port D head peripheral variant.", GpioDHead, AHB1ENR, AHB1RSTR, AHB1LPENR, GPIOD, GPIODEN, GPIODRST, GPIODLPEN, } #[cfg(any( stm32_mcu = "stm32f401", stm32_mcu = "stm32f405", stm32_mcu = "stm32f407", stm32_mcu = "stm32f411", stm32_mcu = "stm32f412", stm32_mcu = "stm32f413", stm32_mcu = "stm32f427", stm32_mcu = "stm32f429", stm32_mcu = "stm32f446", stm32_mcu = "stm32f469", ))] map_gpio_port_head! { "Extracts GPIO port E head register tokens.", periph_gpio_e_head, "GPIO port E head peripheral variant.", GpioEHead, AHB1ENR, AHB1RSTR, AHB1LPENR, GPIOE, GPIOEEN, GPIOERST, GPIOELPEN, } #[cfg(any( stm32_mcu = "stm32f405", stm32_mcu = "stm32f407", stm32_mcu = "stm32f412", stm32_mcu = "stm32f413", stm32_mcu = "stm32f427", stm32_mcu = "stm32f429", stm32_mcu = "stm32f446", stm32_mcu = "stm32f469", ))] map_gpio_port_head! { "Extracts GPIO port F head register tokens.", periph_gpio_f_head, "GPIO port F head peripheral variant.", GpioFHead, AHB1ENR, AHB1RSTR, AHB1LPENR, GPIOF, GPIOFEN, GPIOFRST, GPIOFLPEN, } #[cfg(any( stm32_mcu = "stm32f405", stm32_mcu = "stm32f407", stm32_mcu = "stm32f412", stm32_mcu = "stm32f413", stm32_mcu = "stm32f427", stm32_mcu = "stm32f429", stm32_mcu = "stm32f446", stm32_mcu = "stm32f469", ))] map_gpio_port_head! { "Extracts GPIO port G head register tokens.", periph_gpio_g_head, "GPIO port G head peripheral variant.", GpioGHead, AHB1ENR, AHB1RSTR, AHB1LPENR, GPIOG, GPIOGEN, GPIOGRST, GPIOGLPEN, } map_gpio_port_head! { "Extracts GPIO port H head register tokens.", periph_gpio_h_head, "GPIO port H head peripheral variant.", GpioHHead, AHB1ENR, AHB1RSTR, AHB1LPENR, GPIOH, GPIOHEN, GPIOHRST, GPIOHLPEN, } #[cfg(any( stm32_mcu = "stm32f405", stm32_mcu = "stm32f407", stm32_mcu = "stm32f427", stm32_mcu = "stm32f429", stm32_mcu = "stm32f469", ))] map_gpio_port_head! { "Extracts GPIO port I head register tokens.", periph_gpio_i_head, "GPIO port I head peripheral variant.", GpioIHead, AHB1ENR, AHB1RSTR, AHB1LPENR, GPIOI, GPIOIEN, GPIOIRST, GPIOILPEN, } #[cfg(any( stm32_mcu = "stm32f405", stm32_mcu = "stm32f407", stm32_mcu = "stm32f427", stm32_mcu = "stm32f429", stm32_mcu = "stm32f469", ))] map_gpio_port_head! { "Extracts GPIO port J head register tokens.", periph_gpio_j_head, "GPIO port J head peripheral variant.", GpioJHead, AHB1ENR, AHB1RSTR, AHB1LPENR, GPIOJ, GPIOJEN, GPIOJRST, GPIOJLPEN, } #[cfg(any( stm32_mcu = "stm32f405", stm32_mcu = "stm32f407", stm32_mcu = "stm32f427", stm32_mcu = "stm32f429", stm32_mcu = "stm32f469", ))] map_gpio_port_head! { "Extracts GPIO port K head register tokens.", periph_gpio_k_head, "GPIO port K head peripheral variant.", GpioKHead, AHB1ENR, AHB1RSTR, AHB1LPENR, GPIOK, GPIOKEN, GPIOKRST, GPIOKLPEN, }