59 lines
2.3 KiB
C
59 lines
2.3 KiB
C
/*
|
|
* LCD interface header file
|
|
* See lcd.c for more info
|
|
*/
|
|
|
|
#ifndef _HD44780_H_
|
|
#define _HD44780_H_
|
|
|
|
//#include "main.h"
|
|
#include <avr/io.h>
|
|
#include <util/delay.h>
|
|
|
|
/*--------------------------------------------------------------------------------------------------
|
|
Interface definition prototypes
|
|
--------------------------------------------------------------------------------------------------*/
|
|
#ifndef _LCD_PINS_
|
|
#define _LCD_PINS_
|
|
#define LCD_E_PIN PD0
|
|
#define LCD_RS_PIN PD1
|
|
#define LCD_D7_PIN PD7
|
|
#define LCD_D6_PIN PD6
|
|
#define LCD_D5_PIN PD5
|
|
#define LCD_D4_PIN PD4
|
|
#define LCD_DDR DDRD
|
|
#define LCD_PORT PORTD
|
|
#endif // _LCD_PINS_*/
|
|
|
|
#define BIT(i) (1<<i)
|
|
#define LCD_E_set LCD_PORT|=BIT(LCD_E_PIN) //Enable
|
|
#define LCD_E_clr LCD_PORT&=~BIT(LCD_E_PIN)
|
|
#define LCD_RS_set LCD_PORT|=BIT(LCD_RS_PIN) //Command / Data
|
|
#define LCD_RS_clr LCD_PORT&=~BIT(LCD_RS_PIN)
|
|
#define LCD_D7_set LCD_PORT|=BIT(LCD_D7_PIN) //D7
|
|
#define LCD_D7_clr LCD_PORT&=~BIT(LCD_D7_PIN)
|
|
#define LCD_D6_set LCD_PORT|=BIT(LCD_D6_PIN) //D6
|
|
#define LCD_D6_clr LCD_PORT&=~BIT(LCD_D6_PIN)
|
|
#define LCD_D5_set LCD_PORT|=BIT(LCD_D5_PIN) //D5
|
|
#define LCD_D5_clr LCD_PORT&=~BIT(LCD_D5_PIN)
|
|
#define LCD_D4_set LCD_PORT|=BIT(LCD_D4_PIN) //D4
|
|
#define LCD_D4_clr LCD_PORT&=~BIT(LCD_D4_PIN)
|
|
|
|
|
|
/*--------------------------------------------------------------------------------------------------
|
|
Public function prototypes
|
|
--------------------------------------------------------------------------------------------------*/
|
|
#define delay_1us _delay_us(1); //delay 1us
|
|
#define delay_1ms _delay_ms(1); //delay 1ms
|
|
#define LCD_STROBE ((LCD_E_set),(LCD_E_clr))
|
|
|
|
void LCD_clear(void); /* Clear and home the LCD */
|
|
#define LCD_cursor(x) lcd_write(((x)&0x7F)|0x80)/* Set the cursor position */
|
|
void LCD_goto(unsigned char pos);/* Go to the specified position */
|
|
void LCD_init(void); /* intialize the LCD - call before anything else */
|
|
void LCD_putc(char); /* write a character to the LCD */
|
|
void LCD_write(const char * s); /* write a string of characters to the LCD */
|
|
void LCD_write_byte(unsigned char); /* write a byte to the LCD in 4 bit mode */
|
|
|
|
#endif // _HD44780_H_
|