EA DOGM128 Driver  0.1
Driver code for the EA DOGM128
 All Files Functions Typedefs Enumerations Groups Pages
Macros | Typedefs | Enumerations | Functions
Common

Macros

#define DOG_WIDTH   128
 
#define DOG_HEIGHT   64
 
#define DOG_PAGE_HEIGHT   8
 
#define SETBIT(port, bit)   ((port) |= (1 << (bit)))
 
#define CLEARBIT(port, bit)   ((port) &= ~(1 << (bit)))
 
#define DOG_INIT_SPI()
 
#define DOG_SLAVE_SELECT()   CLEARBIT(DOG_SPI_PORT, DOG_SS_BAR_PIN);
 
#define DOG_SLAVE_DESELECT()   SETBIT(DOG_SPI_PORT, DOG_SS_BAR_PIN);
 
#define DOG_ASSERT_RESET()   CLEARBIT(DOG_RESET_PORT, DOG_RESET_PIN);
 
#define DOG_UNASSERT_RESET()   SETBIT(DOG_RESET_PORT, DOG_RESET_PIN);
 
#define DOG_SEND_DATA()   SETBIT(DOG_DATA_OR_COMMAND_PORT, DOG_DATA_OR_COMMAND_PIN);
 
#define DOG_SEND_COMMAND()   CLEARBIT(DOG_DATA_OR_COMMAND_PORT, DOG_DATA_OR_COMMAND_PIN);
 

Typedefs

typedef unsigned char uint8_t
 
typedef signed char int8_t
 
typedef unsigned int uint16_t
 
typedef signed int int16_t
 

Enumerations

enum  dog_power_state_t { DOG_OFF = 0, DOG_ON }
 
enum  dog_display_mode_t { DOG_NORMAL_DISPLAY = 0, DOG_INVERTED_DISPLAY }
 

Functions

void dog_init (dog_display_mode_t display_mode, uint8_t contrast)
 
void dog_clear_display (void)
 
void dog_clear_buffer (void)
 
void dog_print_buffer (void)
 
void dog_set_contrast (uint8_t contrast)
 
void dog_invert_pixels (dog_display_mode_t display_mode)
 
void dog_power (dog_power_state_t state)
 

Detailed Description

This file contains various SPI macros, common constants, common typedefs, and various function prototypes which interface with the DOG module itself. The library is organized in such a way that the user should not have to interface with any of the macros in this file dealing with SPI communication. The user will mostly only find the function prototypes in this file of interest and perhaps the constants and typedefs should they choose to expand upon the library.

Macro Definition Documentation

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

Define CLEARBIT if not previously defined

#define DOG_ASSERT_RESET ( )    CLEARBIT(DOG_RESET_PORT, DOG_RESET_PIN);

Activate DOGM128 reset

#define DOG_HEIGHT   64

Height of the entire display in pixels

#define DOG_INIT_SPI ( )
Value:
DOG_SPCR = ((0 << DOG_SPIE)| \
(1 << DOG_SPE) | \
(0 << DORD) | \
(1 << MSTR) | \
(0 << DOG_CPOL) | \
(0 << DOG_CPHA) | \
(0 << DOG_SPR1) | \
(0 << DOG_SPR0)); \
#define SETBIT(port, bit)
Definition: DOGM128_common.h:46
#define DOG_SPR1
Definition: DOGM128_user_config.h:64
#define DOG_SPR0
Definition: DOGM128_user_config.h:66
#define DOG_CPHA
Definition: DOGM128_user_config.h:62
#define DOG_SPCR
Definition: DOGM128_user_config.h:50
#define DOG_CPOL
Definition: DOGM128_user_config.h:60
#define DOG_SPE
Definition: DOGM128_user_config.h:54
#define DOG_SPIE
Definition: DOGM128_user_config.h:52
#define DOG_SPSR
Definition: DOGM128_user_config.h:41
#define DOG_SPR2X
Definition: DOGM128_user_config.h:43

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/2 (EA DOGM128 can handle up to 20MHz)
SPR1 - CLEARED
SPR0 - CLEARED
SPR2X - SET (When available)

#define DOG_PAGE_HEIGHT   8

Height of a single page in pixels

#define DOG_SEND_COMMAND ( )    CLEARBIT(DOG_DATA_OR_COMMAND_PORT, DOG_DATA_OR_COMMAND_PIN);

Clear A_0 pin; allows DOGM128 to receive commands.

#define DOG_SEND_DATA ( )    SETBIT(DOG_DATA_OR_COMMAND_PORT, DOG_DATA_OR_COMMAND_PIN);

Set A_0 pin; allows DOGM128 to receive data.

#define DOG_SLAVE_DESELECT ( )    SETBIT(DOG_SPI_PORT, DOG_SS_BAR_PIN);

Deselect the DOGM128

#define DOG_SLAVE_SELECT ( )    CLEARBIT(DOG_SPI_PORT, DOG_SS_BAR_PIN);

Select the DOGM128

#define DOG_UNASSERT_RESET ( )    SETBIT(DOG_RESET_PORT, DOG_RESET_PIN);

Deactivate DOGM128 reset

#define DOG_WIDTH   128

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 signed char int8_t

portable 8-bit signed integer

typedef unsigned int uint16_t

portable 16-bit unsigned integer

typedef unsigned char uint8_t

portable 8-bit unsigned integer

Enumeration Type Documentation

used for display mode

used for power-on and power off

Function Documentation

void dog_clear_buffer ( void  )

This function is used to clear the entire character buffer; however it does not clear the display.

Algorithm
The function simply advances through the two-dimensional array which makes up the buffer and sets its contents equal to zero.
Assumptions
  • None
void dog_clear_display ( void  )

This function is used to clear the entire LCD display; however it does not clear the buffer.

Algorithm
Beginning at page 0, column 0, the function mimics an old typewriter with a manual carriage return. It sends a value of zero to the display continuously for each column of the page until it reaches the end of the line (page). At which point, the page is manually advanced and the column reset to zero (left side of display). It continues along this route until reaching the bottom-right corner. Finally, it resets the carriage to the top-left corner for future display writes.
Assumptions
void dog_init ( dog_display_mode_t  display_mode,
uint8_t  contrast 
)

This function is used to initialize the EA DOGM128; it must be called prior to any of the other functions in this file and should only be called once. It also clears the display.

Parameters
  • display_mode = When set to DOG_NORMAL_DISPLAY, the pixels are normally off. When set to DOG_INVERTED_DISPLAY, the pixels are normally on (inverted).
  • contrast = Contrast value ranging on the set [0,63]. Higher number means higher contrast.
Algorithm
The function initializes SPI communication between the EA DOGM128 and the microcontroller. It then sends various setup commands to the LCD as specified by the datasheet. Finally, it clears the display to remove any random pixels on the screen.
Assumptions
  • The user has correctly connected the screen to the microcontroller (keep your wiring neat) and has configured the user_config.h file according to his or her needs should the default configuration be changed.
void dog_invert_pixels ( dog_display_mode_t  display_mode)

This function is used set the display_mode of the DOG module.

Parameters
  • display_mode = When set to DOG_NORMAL_DISPLAY, the pixels are normally off. When set to DOG_INVERTED_DISPLAY, the pixels are normally on (inverted).
Algorithm
The function begins by masking out all bits except the LSB of the supplied display_mode value. It then sends this value to the display using the display mode set command as specified by the datasheet.
Assumptions
void dog_power ( dog_power_state_t  state)

This function is used to turn the DOG module on or off. The DOG module is powered on by default once the dog_init() function is called; this function can be used for toggling power once the dog_init() function has been called. It DOES NOT control the backlight.

Parameters
  • state = DOG_OFF to power down, DOG_ON to power up.
Algorithm
The function begins simply transmits the on/off command to the display
Assumptions
void dog_print_buffer ( void  )

This function is used to print the entire contents of the buffer to the display.

Algorithm
Beginning at page 0, column 0, the function mimics an old typewriter with a manual carriage return. It sends the corresponding buffer contents to the display continuously for each column of the page until it reaches the end of the line (page). At which point, the page is manually advanced and the column reset to zero (left side of display). It continues along this route until reaching the bottom-right corner. Finally, it resets the carriage to the top-left corner for future display writes.
Assumptions
void dog_set_contrast ( uint8_t  contrast)

This function is used set the contrast of the DOG module.

Parameters
  • contrast = Contrast value ranging on the set [0,63]. Higher number means higher contrast.
Algorithm
The function begins by masking out the 2 MSB's of the supplied contrast value. It then sends this value to the display using the contrast set commands as specified by the datasheet.
Assumptions