ezLCD+103 Driver  0.1
Driver code for the ezLCD+103
 All Files Functions Typedefs Enumerations Groups Pages
Macros | Typedefs | Functions
Common

Macros

#define EZLCD_WIDTH   320
 
#define EZLCD_HEIGHT   240
 
#define SETBIT(port, bit)   ((port) |= (1 << (bit)))
 
#define CLEARBIT(port, bit)   ((port) &= ~(1 << (bit)))
 
#define EZLCD_INIT_SPI()
 
#define EZLCD_SLAVE_SELECT()   CLEARBIT(EZLCD_SPI_PORT, EZLCD_SS_BAR_PIN);
 
#define EZLCD_SLAVE_DESELECT()   SETBIT(EZLCD_SPI_PORT, EZLCD_SS_BAR_PIN);
 

Typedefs

typedef unsigned char uint8_t
 
typedef signed char int8_t
 
typedef unsigned int uint16_t
 
typedef signed int int16_t
 
typedef unsigned long uint32_t
 
typedef unsigned long int32_t
 

Functions

uint8_t ezLCD_transfer_data (uint8_t data)
 
uint8_t ezLCD_transfer_data_long (uint8_t data, uint8_t end_transfer)
 

Detailed Description

This header file contains various macros and functions needed by other child header files in this library. Among them are functions to send SPI data as well as

Macro Definition Documentation

#define CLEARBIT (   port,
  bit 
)    ((port) &= ~(1 << (bit)))

Define CLEARBIT if not previously defined

#define EZLCD_HEIGHT   240

Height of the entire display in pixels

#define EZLCD_INIT_SPI ( )
Value:
EZLCD_SPCR = ((0 << EZLCD_SPIE) | \
(1 << EZLCD_SPE) | \
(0 << EZLCD_DORD) | \
(1 << EZLCD_MSTR) | \
(0 << EZLCD_CPOL) | \
(0 << EZLCD_CPHA) | \
(0 << EZLCD_SPR1) | \
(0 << EZLCD_SPR0)); \
#define EZLCD_SPSR
Definition: ezLCD_103_user_config.h:52
#define CLEARBIT(port, bit)
Definition: ezLCD_103_common.h:43
#define EZLCD_CPOL
Definition: ezLCD_103_user_config.h:71
#define EZLCD_CPHA
Definition: ezLCD_103_user_config.h:73
#define EZLCD_SPR1
Definition: ezLCD_103_user_config.h:75
#define EZLCD_DORD
Definition: ezLCD_103_user_config.h:67
#define EZLCD_MSTR
Definition: ezLCD_103_user_config.h:69
#define EZLCD_SPIE
Definition: ezLCD_103_user_config.h:63
#define EZLCD_SPCR
Definition: ezLCD_103_user_config.h:61
#define EZLCD_SPR2X
Definition: ezLCD_103_user_config.h:54
#define EZLCD_SPR0
Definition: ezLCD_103_user_config.h:77
#define EZLCD_SPE
Definition: ezLCD_103_user_config.h:65

Initialize SPI communication:
SPIE - SPI Interrupt DISABLED (we will poll instead)
SPE - SPI ENABLED
DORD - MSB First
MSTR - Configured as a MASTER
CPOL - Clock Polarity = 0
CPHA - Clock Phase = 0
SPI - Clock = f_clk/4 (EA EZLCD+103 can handle up to 4MHz)
SPR1 - CLEARED
SPR0 - CLEARED
SPR2X - CLEARED

#define EZLCD_SLAVE_DESELECT ( )    SETBIT(EZLCD_SPI_PORT, EZLCD_SS_BAR_PIN);

Deselect the EZLCD+103

#define EZLCD_SLAVE_SELECT ( )    CLEARBIT(EZLCD_SPI_PORT, EZLCD_SS_BAR_PIN);

Select the EZLCD+103

#define EZLCD_WIDTH   320

Width of the entire display in pixels

#define SETBIT (   port,
  bit 
)    ((port) |= (1 << (bit)))

Define SETBIT if not previously defined

Typedef Documentation

typedef signed int int16_t

portable 16-bit signed integer

typedef unsigned long int32_t

portable 32-bit signed number

typedef signed char int8_t

portable 8-bit signed integer

typedef unsigned int uint16_t

portable 16-bit unsigned integer

typedef unsigned long uint32_t

portable 32-bit unsigned number

typedef unsigned char uint8_t

portable 8-bit unsigned integer

Function Documentation

uint8_t ezLCD_transfer_data ( uint8_t  data)

This function is used to send one byte of data over SPI. It may be modified should the user choose to use a different serial protocol instead of SPI.

Parameters
  • data = the byte that is to be sent to the SPI slave.
Assumptions
  • The user has initialized the MCU's SPI interface with the EZLCD_INIT_SPI() macro.
  • The user has set the MCU's SPI pins to inputs and outputs appropriately.

    • SS_BAR = OUTPUT
    • SCK = OUTPUT
    • MOSI = OUTPUT
    • MISO = INPUT
Returns
The contents of the SPI data register (EZLCD_SPDR) after the data transfer has completed.
uint8_t ezLCD_transfer_data_long ( uint8_t  data,
uint8_t  end_transfer 
)

This function is used to send multiple bytes of data over SPI through subsequent calls to this function. In other words, it does not unassert the chip select until the transmission has been completed. It may be modified should the user choose to use a different serial protocol instead of SPI.

Parameters
  • data = the byte that is to be sent to the SPI slave.
  • end_transfer =
    • 0 to continue transfer
    • 1 to end the transfer
Assumptions
  • The user has initialized the MCU's SPI interface with the EZLCD_INIT_SPI() macro.
  • The user does not deselect the display in between transfers.
  • The user has set the MCU's SPI pins to inputs and outputs appropriately.

    • SS_BAR = OUTPUT
    • SCK = OUTPUT
    • MOSI = OUTPUT
    • MISO = INPUT
Returns
The contents of the SPI data register (EZLCD_SPDR) after each subsequent call.