Skip to main content

Hc595Cols

Struct Hc595Cols 

Source
pub struct Hc595Cols<'peripherals> {
    clk: Output<'peripherals>,
    data: Output<'peripherals>,
    latch: Output<'peripherals>,
    shifter_delay_cycles: u32,
}
Expand description

Driver for a 74HC595 shift register used to drive keyboard matrix columns.

Controls three GPIO output pins to clock serial data into the shift register and latch it to the parallel outputs, selecting the active matrix column.

Fields§

§clk: Output<'peripherals>

Clock pin (SHCP / SRCLK), used to shift data on each rising edge.

§data: Output<'peripherals>

Serial data pin (DS / SER), used to shift bits into the register.

§latch: Output<'peripherals>

Latch pin (STCP / RCLK), used to transfer the shift register to the output register.

§shifter_delay_cycles: u32

CPU cycles between shift register pin transitions.

Implementations§

Source§

impl<'peripherals> Hc595Cols<'peripherals>

Source

pub const fn new( data: Output<'peripherals>, clk: Output<'peripherals>, latch: Output<'peripherals>, shifter_delay_cycles: u32, ) -> Self

Creates a new Hc595Cols instance from the given GPIO output pins.

Source

fn pulse(&mut self)

Pulses the clock pin high then low to advance the shift register by one bit.

Source

pub fn select_col(&mut self, col: usize)

Selects a single column by driving its output low (active-low logic).

All other columns are driven high. The column index is mapped MSB-first, so col = 0 drives bit 15 low.

Source

pub fn unselect_all(&mut self)

Deselects all columns by driving all outputs high (active-low logic).

Source

pub fn write_u16_lsb_first(&mut self, value: u16)

Shifts out 16 bits LSB-first into the shift register, then latches the outputs.

Pulls the latch pin low before shifting and high then low again after all bits have been clocked in, transferring the shift register contents to the parallel outputs.

Auto Trait Implementations§

§

impl<'peripherals> Freeze for Hc595Cols<'peripherals>

§

impl<'peripherals> RefUnwindSafe for Hc595Cols<'peripherals>

§

impl<'peripherals> Send for Hc595Cols<'peripherals>

§

impl<'peripherals> Sync for Hc595Cols<'peripherals>

§

impl<'peripherals> Unpin for Hc595Cols<'peripherals>

§

impl<'peripherals> UnsafeUnpin for Hc595Cols<'peripherals>

§

impl<'peripherals> !UnwindSafe for Hc595Cols<'peripherals>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.