COSA
An Object-Oriented Platform for Arduino Programming
Soft::SRPO< N > Class Template Reference

#include <SRPO.hh>

Collaboration diagram for Soft::SRPO< N >:
Collaboration graph

Classes

class  OutputPin
 

Public Member Functions

 SRPO (Board::DigitalPin sda=Board::D3, Board::DigitalPin scl=Board::D4)
 
bool is_set (uint8_t pin)
 
void is_clear (uint8_t pin)
 
void set (uint8_t pin)
 
void clear (uint8_t pin)
 
void toggle (uint8_t pin)
 
void set ()
 
void clear ()
 
void update ()
 

Static Public Attributes

static const uint8_t PINS = N * CHARBITS
 

Protected Attributes

uint8_t m_port [N]
 
::OutputPin m_sda
 
::OutputPin m_scl
 

Detailed Description

template<uint8_t N>
class Soft::SRPO< N >

Soft N-Shift Register Parallel Output, 2-pin. The shift registers (74HC164/74HC595) may be cascaded for N*8-bit parallel output port (see circuit below). The pins are numbered from the first connect shift register (Q0..Q7) and updwards in the chain (Q8..Q15) and so on.

Circuit

74HC164 (VCC)
+----U----+ |
(D3/SDA)----------+-1-|DSA VCC|-14-+
+-2-|DSB Q7|-13------------(Q7)--+
(Q0)----------------3-|Q0 Q6|-12------------(Q6) |
(Q1)----------------4-|Q1 Q5|-11------------(Q5) |
(Q2)----------------5-|Q2 Q4|-10------------(Q4) |
(Q3)----------------6-|Q3 /MR|--9-----------(VCC) |
+-7-|GND CP|--8--------(SCL/D4)--)-+
| +---------+ | |
| 0.1uF | |
(GND)-----||-------(VCC) | |
| |
+-----------------------------------+ |
| |
| 74HC164 (VCC) |
| +----U----+ | |
+-1-|DSA VCC|-14-+ |
+-2-|DSB Q7|-13-----------(Q15)--+ |
(Q8)----------------3-|Q0 Q6|-12-----------(Q14) | |
(Q9)----------------4-|Q1 Q5|-11-----------(Q13) | |
(Q10)---------------5-|Q2 Q4|-10-----------(Q12) | |
(Q11)---------------6-|Q3 /MR|--9-----------(VCC) | |
+-7-|GND CP|--8------------------)-+
| +---------+ | |
| 0.1uF | |
(GND)-----||-------(VCC) v v
Parameters
[in]Nnumber of shift registers (N * 8 output pins).

Definition at line 69 of file SRPO.hh.

Constructor & Destructor Documentation

template<uint8_t N>
Soft::SRPO< N >::SRPO ( Board::DigitalPin  sda = Board::D3,
Board::DigitalPin  scl = Board::D4 
)
inline

Construct N-shift register connected to given pins.

Parameters
[in]sdaserial output data (Default D3).
[in]sclserial clock (Default D4).

Definition at line 79 of file SRPO.hh.

Member Function Documentation

template<uint8_t N>
void Soft::SRPO< N >::clear ( uint8_t  pin)
inline

Clear given pin in shadow register. Call update() to write to shift register.

Parameters
[in]pinpin number.

Definition at line 131 of file SRPO.hh.

template<uint8_t N>
void Soft::SRPO< N >::clear ( )
inline

Clear the shadow registers. Call update() to write to shift register.

Definition at line 166 of file SRPO.hh.

template<uint8_t N>
void Soft::SRPO< N >::is_clear ( uint8_t  pin)
inline

Return true(1) if the given pin in shadow register is set, otherwise false(0).

Parameters
[in]pinpin number.
Returns
bool.

Definition at line 107 of file SRPO.hh.

template<uint8_t N>
bool Soft::SRPO< N >::is_set ( uint8_t  pin)
inline

Return true(1) if the given pin in shadow register is set, otherwise false(0).

Parameters
[in]pinpin number.
Returns
bool.

Definition at line 94 of file SRPO.hh.

template<uint8_t N>
void Soft::SRPO< N >::set ( uint8_t  pin)
inline

Set given pin in shadow register. Call update() to write to shift register.

Parameters
[in]pinpin number.

Definition at line 119 of file SRPO.hh.

template<uint8_t N>
void Soft::SRPO< N >::set ( )
inline

Set the shadow registers. Call update() to write to shift register.

Definition at line 156 of file SRPO.hh.

template<uint8_t N>
void Soft::SRPO< N >::toggle ( uint8_t  pin)
inline

Toggle given pin in shadow register. Call update() to write to shift register.

Parameters
[in]pinpin number.

Definition at line 143 of file SRPO.hh.

template<uint8_t N>
void Soft::SRPO< N >::update ( )
inline

Update shift register with value of shadow registers.

Definition at line 175 of file SRPO.hh.

Member Data Documentation

template<uint8_t N>
uint8_t Soft::SRPO< N >::m_port[N]
protected

Shadow port register.

Definition at line 229 of file SRPO.hh.

template<uint8_t N>
::OutputPin Soft::SRPO< N >::m_scl
protected

Serial clock output pin

Definition at line 235 of file SRPO.hh.

template<uint8_t N>
::OutputPin Soft::SRPO< N >::m_sda
protected

Serial data output pin

Definition at line 232 of file SRPO.hh.

template<uint8_t N>
const uint8_t Soft::SRPO< N >::PINS = N * CHARBITS
static

Number of pins for N ports

Definition at line 72 of file SRPO.hh.


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