LCD  1.0
HD44780 compatible lcd driver for Xmega devices
 All Files Functions Variables Macros
Functions | Variables
lcd.c File Reference

lcd driver for Xmega More...

#include <avr/io.h>
#include "lcd.h"
#include <util/delay.h>

Functions

void lcd_init (void)
 Initialize the lcd. More...
 
void lcd_putc (char c)
 Writes a character to the LCD. More...
 
void lcd_cmd (uint8_t cmd)
 Writes a command char to the LCD. More...
 
void lcd_data (uint8_t b)
 Writes a data byte to the LCD. More...
 
void lcd_puts (char *s)
 Writes a string to the LCD. More...
 
void lcd_gotoxy (uint8_t x, uint8_t y)
 Set cursor to specified position. More...
 
void lcd_clear (void)
 Clear lcd. More...
 
void lcd_home (void)
 Cursor to home position. More...
 

Variables

volatile uint8_t lcd_line = 0
 Current line number (0 is first line)
 

Detailed Description

lcd driver for Xmega

Author
Wim Dolman (w.e.dolman@hva.nl)
Date
21-10-2013
Version
1.0

This file contains the routines for interfacing a HD44780U-based text lcd display for Atmel Xmega devices.

It is based on the lcd libray from Peter Fleury (http://homepage.hispeed.ch/peterfleury/) for the ATmega devices.

This library is suitable for four different io modes:

There are defines for these four modes:

In 8 bit mode all 8 data pins must be connected to one 8-pin port of the Xmega. In 4 bit mode all 4 data pins must be connected to one port of Xmega, but the 4 data lines may be connected to any pin of that port and in any order. The header file lcd.h contains macro definitions that can be for that purpose.

The control lines RS, E and R/W can connected to any pin of any port of the Xmega.

Warning
Be careful using the busyflag. Most alfanumeric displays are 5 Volt devices. Xmega's are not 5 Volt tolerant. When using the busyflag, information is also send from the LCD to the Xmega. So you can damage your Xmega.

Function Documentation

void lcd_clear ( void  )

Clear lcd.

This function clears the LCD and sets cursor to home position.

Returns
none
void lcd_cmd ( uint8_t  cmd)

Writes a command char to the LCD.

This function writes a command char to the LCD.

Parameters
cmdcommand character
Returns
none
void lcd_data ( uint8_t  b)

Writes a data byte to the LCD.

This function writes a data byte to the LCD.

Parameters
bdata byte
Returns
none
void lcd_gotoxy ( uint8_t  x,
uint8_t  y 
)

Set cursor to specified position.

This function sets the cursor to the specified position.

Parameters
xhorizontal position (0: left most position)
yvertical position (0: first line)
Returns
none
void lcd_home ( void  )

Cursor to home position.

This function sets cursor to home position.

Returns
none
void lcd_init ( void  )

Initialize the lcd.

This function initializes the LCD in one of the four modes depending on de values of LCD_4BIT_MODE and LCD_BUSY_FLAG in the header file.

Returns
none
void lcd_putc ( char  c)

Writes a character to the LCD.

This function writes a character to the LCD. The characters '\n' and '\f' have a special meaning

  • '\n' (new line) : go to the start of the next line
  • '\f' (formfeed) : clears display and start at the home position
Parameters
cthe character to be written
Returns
none
void lcd_puts ( char *  s)

Writes a string to the LCD.

This function writes a character string to the LCD.

Parameters
spointer to the character string
Returns
none