Skip to content

Group shiftregister

Modules > shiftregister

Classes

Type Name
class daisy::ShiftRegister4021 <num_daisychained, num_parallel>
Device Driver for CD4021 shift register.
class daisy::ShiftRegister595
Device Driver for 8-bit shift register. CD74HC595 - 8-bit serial to parallel output shift.

Public Types

Type Name
enum Pins

Public Functions

Type Name
void Init (Pin * pin_cfg, size_t num_daisy_chained=1)
void Set (uint8_t idx, bool state)
ShiftRegister595 ()
void Write ()
~ShiftRegister595 ()

Public Types Documentation

enum Pins

enum Pins {
    PIN_LATCH,
    PIN_CLK,
    PIN_DATA,
    NUM_PINS
};

The following pins correspond to the hardware connections to the 595.

Note:

TODO: This should probably be switched to using a pin config structure similar to other drivers


Public Functions Documentation

function Init

void Init (
    Pin * pin_cfg,
    size_t num_daisy_chained=1
) 

Initializes the GPIO, and data for the ShiftRegister

Parameters:

  • pin_cfg is an array of Pin corresponding the the Pins enum above.
  • num_daisy_chained (default = 1) is the number of 595 devices daisy chained together.

function Set

void Set (
    uint8_t idx,
    bool state
) 

Sets the state of the specified output.

Parameters:

  • idx The index starts with QA on the first device and ends with QH on the last device.
  • state A true state will set the output HIGH, while a false state will set the output LOW.

function ShiftRegister595

inline ShiftRegister595 () 

function Write

void Write () 

Writes the states of shift register out to the connected devices.


function ~ShiftRegister595

inline ~ShiftRegister595 ()