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

#include <SRPI.hh>

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

Classes

class  InputPin
 

Public Member Functions

 SRPI (Board::DigitalPin sda=Board::D3, Board::DigitalPin scl=Board::D4, Board::DigitalPin pld=Board::D5)
 
bool is_set (uint8_t pin)
 
void is_clear (uint8_t pin)
 
void update ()
 

Static Public Attributes

static const uint8_t PINS = N * CHARBITS
 

Protected Attributes

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

Detailed Description

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

Soft N-Shift Register Parallel Input. The shift registers (74HC165) may be cascaded for N*8-bit parallel input 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

74HC165 (VCC)
+----U----+ |
(D5/PLD)---+--------1-|/PL VCC|-16-+
(D4/SCL)-+-)--------2-|CP /CE|-15-----------(GND)
(Q4)-----)-)--------3-|D4 D3|-14------------(Q3)
(Q5)-----)-)--------4-|D5 D2|-13------------(Q2)
(Q6)-----)-)--------5-|D6 D1|-12------------(Q1)
(Q7)-----)-)--------6-|D7 D0|-11------------(Q0)
| | 7-|/Q7 DS|-10-----------------+
| | +-8-|GND Q7|--9--------(SDA/D3) |
| | | +---------+ |
| | | 0.1uF |
| | (GND)-----||-------(VCC) |
| | | |
| | 74HC165 | |
| | +----U----+ | |
| +--------1-|/PL VCC|-16-+ |
+-)--------2-|CP /CE|-15-----------(GND) |
(Q12)----)-)--------3-|D4 D3|-14-----------(Q11) |
(Q13)----)-)--------4-|D5 D2|-13-----------(Q10) |
(Q14)----)-)--------5-|D6 D1|-12------------(Q9) |
(Q15)----)-)--------6-|D7 D0|-11------------(Q8) |
| | 7-|/Q7 DS|-10-----------------)--+
| | +-8-|GND Q7|--9-----------------+ |
| | | +---------+ |
| | | 0.1uF |
v v (GND)-----||-------(VCC) v
Parameters
[in]Nnumber of shift registers (N * 8 input pins).

Definition at line 69 of file SRPI.hh.

Constructor & Destructor Documentation

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

Construct N-shift register connected to given pins.

Parameters
[in]sdaserial input data (Default D3).
[in]sclserial clock (Default D4).
[in]pldload (Default D5).

Definition at line 80 of file SRPI.hh.

Member Function Documentation

template<uint8_t N>
void Soft::SRPI< 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 109 of file SRPI.hh.

template<uint8_t N>
bool Soft::SRPI< 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 96 of file SRPI.hh.

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

Update shadow register with value of shift registers. Parallel load and shift from register.

Definition at line 120 of file SRPI.hh.

Member Data Documentation

template<uint8_t N>
OutputPin Soft::SRPI< N >::m_pld
protected

Parallel load output pin

Definition at line 177 of file SRPI.hh.

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

Shadow port register; LSB..MSB byte

Definition at line 168 of file SRPI.hh.

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

Serial clock output pin

Definition at line 174 of file SRPI.hh.

template<uint8_t N>
::InputPin Soft::SRPI< N >::m_sda
protected

Serial data input pin

Definition at line 171 of file SRPI.hh.

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

Number of pins for N ports

Definition at line 72 of file SRPI.hh.


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