pub struct GpioDriver<'a> {
callbacks: [Option<Box<dyn FnMut(u32, EventType) + 'a>>; 16],
configs: [GpioConfig; 16],
}Expand description
A GPIO driver for STM32F407
Fields§
§callbacks: [Option<Box<dyn FnMut(u32, EventType) + 'a>>; 16]Callbacks for each pin (indexed by pin number)
configs: [GpioConfig; 16]Configuration for each pin
Implementations§
Source§impl<'a> GpioDriver<'a>
impl<'a> GpioDriver<'a>
pub fn new() -> Self
Sourcefn get_gpio_regs(port: u8) -> *mut RegisterBlock
fn get_gpio_regs(port: u8) -> *mut RegisterBlock
Get GPIO register block for a given port
Sourcefn get_rcc_regs() -> *mut RegisterBlock
fn get_rcc_regs() -> *mut RegisterBlock
Get RCC register block
Sourcefn enable_gpio_clock(port: u8)
fn enable_gpio_clock(port: u8)
Enable GPIO port clock
Sourcefn decode_pin(pin: u32) -> (u8, u8)
fn decode_pin(pin: u32) -> (u8, u8)
Extract port and pin from Pin identifier Pin format: (port << 4) | pin_number where port: 0=GPIOA, 1=GPIOB, 2=GPIOC, 3=GPIOD, 4=GPIOE and pin_number: 0-15
Sourcefn encode_pin(port: u8, pin_num: u8) -> u32
fn encode_pin(port: u8, pin_num: u8) -> u32
Encode port and pin into Pin identifier
Sourcefn configure_pin(&mut self, pin: u32, config: GpioConfig) -> Result<(), i32>
fn configure_pin(&mut self, pin: u32, config: GpioConfig) -> Result<(), i32>
Configure a GPIO pin
Trait Implementations§
Source§impl<'a> Gpio<'a> for GpioDriver<'a>
impl<'a> Gpio<'a> for GpioDriver<'a>
Source§fn setup(
&mut self,
pin: u32,
callback: impl FnMut(u32, EventType) + 'a,
) -> Result<(), i32>
fn setup( &mut self, pin: u32, callback: impl FnMut(u32, EventType) + 'a, ) -> Result<(), i32>
Initializes a GPIO pin and registers a callback for events.
Source§fn set_direction(&mut self, pin: u32, direction: Direction) -> Result<(), i32>
fn set_direction(&mut self, pin: u32, direction: Direction) -> Result<(), i32>
Sets the direction of a GPIO pin.
Source§fn set_output_mode(&mut self, pin: u32, mode: OutputMode) -> Result<(), i32>
fn set_output_mode(&mut self, pin: u32, mode: OutputMode) -> Result<(), i32>
Sets the output mode of a GPIO pin.
Source§fn set_pull_resistor(
&mut self,
pin: u32,
resistor: PullResistor,
) -> Result<(), i32>
fn set_pull_resistor( &mut self, pin: u32, resistor: PullResistor, ) -> Result<(), i32>
Sets the internal pull-up or pull-down resistor for a GPIO pin.
Source§fn set_event_trigger(
&mut self,
pin: u32,
trigger: EventTrigger,
) -> Result<(), i32>
fn set_event_trigger( &mut self, pin: u32, trigger: EventTrigger, ) -> Result<(), i32>
Sets the event trigger for a GPIO pin.
Source§fn set_output(&mut self, pin: u32, value: bool)
fn set_output(&mut self, pin: u32, value: bool)
Sets the output level of a GPIO pin.
value is true for high, false for low.Auto Trait Implementations§
impl<'a> Freeze for GpioDriver<'a>
impl<'a> !RefUnwindSafe for GpioDriver<'a>
impl<'a> !Send for GpioDriver<'a>
impl<'a> !Sync for GpioDriver<'a>
impl<'a> Unpin for GpioDriver<'a>
impl<'a> !UnwindSafe for GpioDriver<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more