COSA
An Object-Oriented Platform for Arduino Programming
HD44780::SR3WSPI Class Reference

#include <HD44780.hh>

Inheritance diagram for HD44780::SR3WSPI:
Inheritance graph
Collaboration diagram for HD44780::SR3WSPI:
Collaboration graph

Classes

union  port_t
 

Public Member Functions

 SR3WSPI (Board::DigitalPin en=Board::D5)
 
virtual bool setup ()
 
virtual void write4b (uint8_t data)
 
virtual void write8b (uint8_t data)
 
virtual void set_mode (uint8_t flag)
 
virtual void set_backlight (uint8_t flag)
 
virtual void write8n (const void *buf, size_t size)
 
void set_clock (Clock rate)
 
void set_clock (uint32_t freq)
 

Static Public Member Functions

static Clock clock (uint32_t freq)
 
static Clock cycle (uint16_t ns)
 

Protected Attributes

port_t m_port
 Port setting. More...
 
Driverm_next
 List of drivers. More...
 
Interrupt::Handlerm_irq
 Interrupt handler. More...
 
OutputPin m_cs
 Device chip select pin. More...
 
Pulse m_pulse
 Chip select pulse width. More...
 
uint8_t m_spcr
 SPI/SPCR hardware control register setting. More...
 
uint8_t m_spsr
 SPI/SPSR hardware status register. More...
 

Static Protected Attributes

static const uint16_t SHORT_EXEC_TIME = 24
 

Detailed Description

HD44780 (LCD-II) Dot Matix Liquid Crystal Display Controller/Driver Shift Register 3-Wire Port using SPI (SR3WSPI), 74HC595 (SR[pin]). The enable pulse pin acts as the SPI chip select.

Circuit

74HC595 (VCC)
+----U----+ |
(LCD D5)------------1-|Q1 VCC|-16-+
(LCD D6)------------2-|Q2 Q0|-15-----------(LCD D4)
(LCD D7)------------3-|Q3 SER|-14-----------(MOSI/D11)
(LCD RS)------------4-|Q4 /OE|-13-----------(GND)
(LCD BT)------------5-|Q5 RCLK|-12-----------(EN/D5)
6-|Q6 SCLK|-11-----------(SCK/D13)
7-|Q7 /MR|-10-----------(VCC)
+-8-|GND Q6'|--9
| +---------+
| 0.1uF
(GND)-----||----(VCC)
(LCD EN)---------------------------------------(EN/D5)
(LCD RW)---------------------------------------(GND)
(LCD K)----------------------------------------(GND)
(LCD A)-----------------[330]------------------(VCC)

Alternative circuit with 74HC164.

74HC164 (VCC)
+----U----+ |
(D11/MOSI)--------+-1-|DSA VCC|-14-+
+-2-|DSB Q7|-13
(LCD D4)------------3-|Q0 Q6|-12
(LCD D5)------------4-|Q1 Q5|-11--------(LCD BT)
(LCD D6)------------5-|Q2 Q4|-10--------(LCD RS)
(LCD D7)------------6-|Q3 /MR|--9-----------(VCC)
+-7-|GND CP|--8-------(SCK/D13)
| +---------+
| 0.1uF
(GND)-----||----(VCC)
(LCD EN)---------------------------------------(EN/D5)
(LCD RW)---------------------------------------(GND)
(LCD K)----------------------------------------(GND)
(LCD A)-----------------[330]------------------(VCC)

Performance

The SPI transfer is so fast that a longer delay is required.

Definition at line 618 of file HD44780.hh.

Constructor & Destructor Documentation

HD44780::SR3WSPI::SR3WSPI ( Board::DigitalPin  en = Board::D5)

Construct HD44780 4-wire serial port connected to given enable and chip select pin. Uses the SPI::MOSI(D11) and SPI:SCK(D13) pins.

Parameters
[in]enenable pulse (Default D5, Tiny/D3)

Definition at line 23 of file HD44780_SR3WSPI.cpp.

Member Function Documentation

static Clock SPI::Driver::clock ( uint32_t  freq)
inlinestaticinherited

Calculate SPI clock rate (scale factor) for given frequency.

Parameters
[in]freqdevice max frequency (in Hz).
Returns
clock rate.

Definition at line 117 of file SPI.hh.

static Clock SPI::Driver::cycle ( uint16_t  ns)
inlinestaticinherited

Calculate SPI clock rate (scale factor) for given clock cycle time in nano seconds.

Parameters
[in]nsmin device clock cycle time.
Returns
clock rate.

Definition at line 135 of file SPI.hh.

void HD44780::SR3WSPI::set_backlight ( uint8_t  flag)
virtual

Set backlight on/off using bt pin.

Parameters
[in]flag.

Implements HD44780::IO.

Definition at line 69 of file HD44780_SR3WSPI.cpp.

void SPI::Driver::set_clock ( Clock  rate)
inherited

Set SPI master clock rate.

Parameters
[in]clockrate.

Definition at line 297 of file SPI.cpp.

void SPI::Driver::set_clock ( uint32_t  freq)
inlineinherited

Set SPI master clock frequency.

Parameters
[in]freqdevice max frequency (in Hz).

Definition at line 157 of file SPI.hh.

void HD44780::SR3WSPI::set_mode ( uint8_t  flag)
virtual

Set instruction/data mode using given rs pin; zero for instruction, non-zero for data mode.

Parameters
[in]flag.

Implements HD44780::IO.

Definition at line 63 of file HD44780_SR3WSPI.cpp.

bool HD44780::SR3WSPI::setup ( )
virtual

Initiate serial port. Returns false.

Returns
bool.

Implements HD44780::IO.

Definition at line 30 of file HD44780_SR3WSPI.cpp.

void HD44780::SR3WSPI::write4b ( uint8_t  data)
virtual

Write LSB nibble to display using serial port.

Parameters
[in]data(4b) to write.

Implements HD44780::IO.

Definition at line 36 of file HD44780_SR3WSPI.cpp.

void HD44780::SR3WSPI::write8b ( uint8_t  data)
virtual

Write byte (8bit) to display.

Parameters
[in]data(8b) to write.

Reimplemented from HD44780::IO.

Definition at line 47 of file HD44780_SR3WSPI.cpp.

void HD44780::IO::write8n ( const void *  buf,
size_t  size 
)
virtualinherited

Write character buffer to display.

Parameters
[in]bufpointer to buffer.
[in]sizenumber of bytes in buffer.

Reimplemented in ERM1602_5, Adafruit_I2C_LCD_Backpack, DFRobot_IIC_LCD_Module, MJKDZ_LCD_Module, and SainSmart_LCD2004.

Definition at line 31 of file HD44780_IO.cpp.

Member Data Documentation

OutputPin SPI::Driver::m_cs
protectedinherited

Device chip select pin.

Definition at line 166 of file SPI.hh.

Interrupt::Handler* SPI::Driver::m_irq
protectedinherited

Interrupt handler.

Definition at line 165 of file SPI.hh.

Driver* SPI::Driver::m_next
protectedinherited

List of drivers.

Definition at line 164 of file SPI.hh.

port_t HD44780::SR3WSPI::m_port
protected

Port setting.

Definition at line 694 of file HD44780.hh.

Pulse SPI::Driver::m_pulse
protectedinherited

Chip select pulse width.

Definition at line 167 of file SPI.hh.

uint8_t SPI::Driver::m_spcr
protectedinherited

SPI/SPCR hardware control register setting.

Definition at line 173 of file SPI.hh.

uint8_t SPI::Driver::m_spsr
protectedinherited

SPI/SPSR hardware status register.

Definition at line 174 of file SPI.hh.

const uint16_t HD44780::SR3WSPI::SHORT_EXEC_TIME = 24
staticprotected

Execution time delay (us).

Definition at line 670 of file HD44780.hh.


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