libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
daisy::ShiftRegister4021< num_daisychained, num_parallel > Class Template Reference

Device Driver for CD4021 shift register. More...

Detailed Description

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

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.

#include <sr_4021.h>

Classes

struct  Config
 

Public Member Functions

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

Constructor & Destructor Documentation

◆ ShiftRegister4021()

template<size_t num_daisychained = 1, size_t num_parallel = 1>
daisy::ShiftRegister4021< num_daisychained, num_parallel >::ShiftRegister4021 ( )
inline

◆ ~ShiftRegister4021()

template<size_t num_daisychained = 1, size_t num_parallel = 1>
daisy::ShiftRegister4021< num_daisychained, num_parallel >::~ShiftRegister4021 ( )
inline

Member Function Documentation

◆ GetConfig()

template<size_t num_daisychained = 1, size_t num_parallel = 1>
const Config & daisy::ShiftRegister4021< num_daisychained, num_parallel >::GetConfig ( ) const
inline

◆ Init()

template<size_t num_daisychained = 1, size_t num_parallel = 1>
void daisy::ShiftRegister4021< num_daisychained, num_parallel >::Init ( const Config cfg)
inline

Initializes the Device(s)

◆ State()

template<size_t num_daisychained = 1, size_t num_parallel = 1>
bool daisy::ShiftRegister4021< num_daisychained, num_parallel >::State ( int  index) const
inline

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.

◆ Update()

template<size_t num_daisychained = 1, size_t num_parallel = 1>
void daisy::ShiftRegister4021< num_daisychained, num_parallel >::Update ( )
inline

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


The documentation for this class was generated from the following file: