Skip to content

daisy::ShiftRegister4021

Module: LIBDAISY / DEVICE / SHIFTREGISTER

Device Driver for CD4021 shift register. More...

#include <sr_4021.h>

Public Classes

Name
struct Config

Public Functions

Name
ShiftRegister4021()
~ShiftRegister4021()
void Init(const Config & cfg)
void Update()
bool State(int index) const
const Config & GetConfig() const

Detailed Description

template <size_t num_daisychained =1,
size_t num_parallel =1>
class daisy::ShiftRegister4021;

Device Driver for CD4021 shift register.

Author: shensley

CD4021B-Q1: CMOS 8-STAGE STATIC SHIFT REGISTER

Supply Voltage: 3V to 18V Clock Freq: 3MHz at 5V (less at 3v3) -> 8.5MHz at 15V Pin Descriptions:

  • Parallel Data[1-8] - 7, 6, 5, 4, 13, 14, 115, 1
  • Serial Data - 11
  • Clock - 10
  • P/!S - 9
  • Q[6-8] - 2, 12, 3

Driver has support for daisy chaining and running up to 2 same-sized chains in parallel from a single set of clk/latch pins to reduce pin/code overhead when using multiple devices.

When dealing with multiple parallel/daisy-chained devices the states of all inputs will be filled in the following order (example uses two chained and two parallel): data[chain0,parallel0], data[chain1,parallel0], data[chain0,parallel1], data[chain1,parallel1];

When combining multiple daisy chained and parallel devices the number of devices chained should match for each parallel device chain.

Public Functions Documentation

function ShiftRegister4021

inline ShiftRegister4021()

function ~ShiftRegister4021

inline ~ShiftRegister4021()

function Init

inline void Init(
    const Config & cfg
)

Initializes the Device(s)


function Update

inline void Update()

Reads the states of all pins on the connected device(s)


function State

inline bool State(
    int index
) const

returns the last read state of the input at the index. true indicates the pin is held HIGH.

See above for the layout of data when using multiple devices in series or parallel.


function GetConfig

inline const Config & GetConfig() const

---

Updated on 2024-01-03 at 19:41:01 +0000