Atmel Software Framework

st7565r.h File Reference

ST7565R display controller driver.

Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.

#include <compiler.h>
#include <sysclk.h>
#include <ioport.h>
#include <status_codes.h>
#include <delay.h>
#include "conf_st7565r.h"
#include <usart_spi.h>

Macros

#define ST7565R_SERIAL_INTERFACE
 
Command defines
#define ST7565R_CMD_DISPLAY_ON   0xAF
 
#define ST7565R_CMD_DISPLAY_OFF   0xAE
 
#define ST7565R_CMD_START_LINE_SET(line)   (0x40 | (line))
 
#define ST7565R_CMD_PAGE_ADDRESS_SET(page)   (0xB0 | (page))
 
#define ST7565R_CMD_COLUMN_ADDRESS_SET_MSB(column)   (0x10 | (column))
 
#define ST7565R_CMD_COLUMN_ADDRESS_SET_LSB(column)   (0x00 | (column))
 
#define ST7565R_CMD_ADC_NORMAL   0xA0
 
#define ST7565R_CMD_ADC_REVERSE   0xA1
 
#define ST7565R_CMD_DISPLAY_NORMAL   0xA6
 
#define ST7565R_CMD_DISPLAY_REVERSE   0xA7
 
#define ST7565R_CMD_DISPLAY_ALL_POINTS_OFF   0xA4
 
#define ST7565R_CMD_DISPLAY_ALL_POINTS_ON   0xA5
 
#define ST7565R_CMD_LCD_BIAS_1_DIV_5_DUTY33   0xA1
 
#define ST7565R_CMD_LCD_BIAS_1_DIV_6_DUTY33   0xA2
 
#define ST7565R_CMD_NORMAL_SCAN_DIRECTION   0xC0
 
#define ST7565R_CMD_REVERSE_SCAN_DIRECTION   0xC8
 
#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_0   0x20
 
#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_1   0x21
 
#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_2   0x22
 
#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_3   0x23
 
#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_4   0x24
 
#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_5   0x25
 
#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_6   0x26
 
#define ST7565R_CMD_VOLTAGE_RESISTOR_RATIO_7   0x27
 
#define ST7565R_CMD_POWER_CTRL_ALL_ON   0x2F
 
#define ST7565R_CMD_SLEEP_MODE   0xAC
 
#define ST7565R_CMD_NORMAL_MODE   0xAD
 
#define ST7565R_CMD_RESET   0xE2
 
#define ST7565R_CMD_NOP   0xE3
 
#define ST7565R_CMD_ELECTRONIC_VOLUME_MODE_SET   0x81
 
#define ST7565R_CMD_ELECTRONIC_VOLUME(volume)   (0x3F & (~volume))
 
#define ST7565R_CMD_BOOSTER_RATIO_SET   0xF8
 
#define ST7565R_CMD_BOOSTER_RATIO_2X_3X_4X   0x00
 
#define ST7565R_CMD_BOOSTER_RATIO_5X   0x01
 
#define ST7565R_CMD_BOOSTER_RATIO_6X   0x03
 
#define ST7565R_CMD_STATUS_READ   0x00
 
#define ST7565R_CMD_END   0xEE
 
#define ST7565R_CMD_READ_MODIFY_WRITE   0xE0
 
Interface selection

The LCD controller support both serial and parallel mode, that means there is a number of possible ways of interfacing the controller using different AVR peripherals.

The different interfaces can be selected using different defines. This driver supports the serial communication mode using an USART in Master SPI mode by defining ST7565R_USART_SPI_INTERFACE, and a normal SPI in Master Mode by defining ST7565R_SPI_INTERFACE.

Note
The current driver only support serial mode.
#define ST7565R_USART_SPI_INTERFACE
 Select the a USART SPI interface. More...
 
#define ST7565R_SPI_INTERFACE
 Select the normal SPI peripheral interface. More...
 

Functions

LCD controller write and read functions
static void st7565r_write_command (uint8_t command)
 Writes a command to the display controller. More...
 
static void st7565r_write_data (uint8_t data)
 Write data to the display controller. More...
 
static uint8_t st7565r_read_data (void)
 Read data from the controller. More...
 
static uint8_t st7565r_get_status (void)
 Read status from the controller. More...
 
LCD Controller reset
static void st7565r_soft_reset (void)
 Perform a soft reset of the LCD controller. More...
 
static void st7565r_hard_reset (void)
 Perform a hard reset of the LCD controller. More...
 
Sleep control
static void st7565r_sleep_enable (void)
 Enable the LCD sleep mode. More...
 
static void st7565r_sleep_disable (void)
 Disable the LCD sleep mode. More...
 
Address setup for the LCD
static void st7565r_set_page_address (uint8_t address)
 Set current page in display RAM. More...
 
static void st7565r_set_column_address (uint8_t address)
 Set current column in display RAM. More...
 
static void st7565r_set_display_start_line_address (uint8_t address)
 Set the display start draw line address. More...
 
Display hardware control
static void st7565r_display_on (void)
 Turn the LCD display on. More...
 
static void st7565r_display_off (void)
 Turn the LCD display off. More...
 
static void st7565r_set_all_pixels (bool pixels_on)
 Sets all LCD pixels on. More...
 
static uint8_t st7565r_set_contrast (uint8_t contrast)
 Set the LCD contrast level. More...
 
static void st7565r_display_invert_enable (void)
 Invert all pixels on the device. More...
 
static void st7565r_display_invert_disable (void)
 Disable invert of all pixels on the device. More...
 
Initialization
void st7565r_init (void)
 Initialize the LCD controller. More...