Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

lcd.c File Reference

Implementation: wrapper for ROM LCD number display functions. More...

#include <config.h>
#include <dlcd.h>
#include <conio.h>
#include <string.h>
#include <sys/h8.h>
#include <sys/lcd.h>
#include <rom/registers.h>
#include <lnp/sys/irq.h>

Go to the source code of this file.

Defines

#define set(b)   __asm__ __volatile__("bset %0,@0xbb:8" : : "i"(b));
 set single bit convenience macro
#define clr(b)   __asm__ __volatile__("bclr %0,@0xbb:8" : : "i"(b));
 clear single bit convenience macro
#define slowdown()
 generate the necessary delay for the i2c bus.

Functions

void lcd_number (int i, lcd_number_style n, lcd_comma_style c)
 show number on LCD display
 __asm__ ("\n\ .text\n\ .align 1\n\ .globl _lcd_number\n\ _lcd_number:\n\ push r6 ; save r6\n\ \n\ push r2 ; comma_style -> stack\n\ push r0 ; number -> stack\n\ \n\ mov.w r1,r6 ; number_style -> r6\n\ \n\ jsr @lcd_number ; call ROM\n\ \n\ adds #0x02,sp ; clear stack\n\ adds #0x02,sp\n\ \n\ pop r6 ; restore r6\n\ rts\n\ \n\ ")
__inline__ void i2c_start (void)
 generate an i2c start condition.
__inline__ void i2c_stop (void)
 generate an i2c stop condition.
__inline__ void i2c_read_ack (void)
 read the acknoledge from the i2c bus.
__inline__ void i2c_write (unsigned char val)
 write one byte to the i2c bus.
void lcd_write_data (unsigned char *data, unsigned char len)
 write an array of bytes to the i2c bus.
void lcd_refresh (void)
 show LCD display contents to the world
void lcd_power_on (void)
 power on LCD display, also called from lcd_init()
void lcd_power_off (void)
 power off LCD display
void lcd_init (void)
 initialize LCD driver

Variables

unsigned char lcd_shadow [LCD_DATA_OFFSET+LCD_DATA_SIZE]
 lcd_shadow buffer:


Detailed Description

Implementation: wrapper for ROM LCD number display functions.

Author:
Markus L. Noga <markus@noga.de>

Definition in file lcd.c.


Define Documentation

#define clr  )     __asm__ __volatile__("bclr %0,@0xbb:8" : : "i"(b));
 

clear single bit convenience macro

Definition at line 113 of file lcd.c.

Referenced by i2c_read_ack(), i2c_start(), i2c_stop(), i2c_write(), lcd_init(), and lcd_power_off().

#define set  )     __asm__ __volatile__("bset %0,@0xbb:8" : : "i"(b));
 

set single bit convenience macro

Definition at line 111 of file lcd.c.

Referenced by i2c_read_ack(), i2c_start(), i2c_stop(), and i2c_write().

 
#define slowdown  ) 
 

generate the necessary delay for the i2c bus.

the h8/300 at 16 MHz is slow enough to run without delay, when running this code from RAM. There might be some delay necessary when running from ROM.

Definition at line 121 of file lcd.c.

Referenced by i2c_read_ack(), i2c_start(), i2c_stop(), and i2c_write().


Function Documentation

__asm__ "\n\.text\n\.align 1\n\.globl _lcd_number\n\_lcd_number:\n\ push r6 ; save r6\n\ \n\ push r2 ; comma_style -> stack\n\ push r0 ; number -> stack\n\ \n\ mov.w   r1,
r6;number_style-> r6\n\\n\jsr @lcd_number;call ROM\n\\n\adds#  0x02,
sp;clear stack\n\adds#  0x02,
sp\n\\n\pop r6;restore r6\n\rts\n\\n\" 
 

Referenced by dbutton(), disable_irqs(), enable_irqs(), lcd_clear(), lcd_hide(), lcd_show(), memcpy(), memset(), power_init(), power_off(), sound_playing(), and sound_system().

__inline__ void i2c_read_ack void   )  [static]
 

read the acknoledge from the i2c bus.

Warning: the value of the acknoledge is ignored. We can't do much on errors anyway.

Definition at line 153 of file lcd.c.

References clr, PORT6_DDR, rom_port6_ddr, SCL, set, and slowdown.

Referenced by lcd_write_data().

__inline__ void i2c_start void   )  [static]
 

generate an i2c start condition.

Definition at line 124 of file lcd.c.

References clr, SCL, SDA, set, and slowdown.

Referenced by lcd_write_data().

__inline__ void i2c_stop void   )  [static]
 

generate an i2c stop condition.

Definition at line 136 of file lcd.c.

References clr, SCL, SDA, set, and slowdown.

Referenced by lcd_write_data().

__inline__ void i2c_write unsigned char  val  )  [static]
 

write one byte to the i2c bus.

Parameters:
val byte to write to the i2c bus

Definition at line 169 of file lcd.c.

References clr, SCL, SDA, set, and slowdown.

Referenced by lcd_write_data().

void lcd_init void   ) 
 

initialize LCD driver

output drivers are configured as outputs. the lcd_shadow buffer is cleared and initialized. the LCD controller is enabled.

Definition at line 295 of file lcd.c.

References clr, LCD_DEV_ID, lcd_power_on(), lcd_shadow, memset(), PORT6_DDR, rom_port6_ddr, SCL, and SDA.

Referenced by kmain().

void lcd_number int  i,
lcd_number_style  n,
lcd_comma_style  c
 

show number on LCD display

Parameters:
i the number
n a number style
c a comma style

void lcd_power_off void   ) 
 

power off LCD display

the LCD controller is put in low power mode and output drivers to the LCD controller are disabled.

Note: without disabling the output drivers the CPU will not save power in sleep mode.

Definition at line 279 of file lcd.c.

References clr, LCD_MODE_SET, lcd_refresh(), lcd_shadow, LCD_SHORT_CMD, lcd_write_data(), SCL, and SDA.

Referenced by kmain().

void lcd_power_on void   ) 
 

power on LCD display, also called from lcd_init()

the LCD controller is enabled.

Definition at line 266 of file lcd.c.

References LCD_MODE_SET, lcd_shadow, LCD_SHORT_CMD, and lcd_write_data().

Referenced by lcd_init().

void lcd_refresh void   ) 
 

show LCD display contents to the world

the entire 9 bytes of display_memory are written to the LCD controller unconditionally. lcd_shadow is updated to the new values.

Definition at line 254 of file lcd.c.

References display_memory, LCD_LONG_CMD, lcd_shadow, and lcd_write_data().

Referenced by kmain(), lcd_power_off(), show_off(), and show_on().

void lcd_write_data unsigned char *  data,
unsigned char  len
[static]
 

write an array of bytes to the i2c bus.

Parameters:
data array of bytes to write to the i2c bus
len number of bytes to write
len bytes are written to the i2c bus, including initial start condition and final stop condition. The first byte must contain a device address and the r/w flag.

Definition at line 195 of file lcd.c.

References i2c_read_ack(), i2c_start(), i2c_stop(), and i2c_write().

Referenced by lcd_power_off(), lcd_power_on(), and lcd_refresh().


Variable Documentation

unsigned char lcd_shadow[LCD_DATA_OFFSET+LCD_DATA_SIZE] [static]
 

lcd_shadow buffer:

contains the last display_memory bytes written to the LCD controller at position LCD_DATA_OFFSET.

lcd_shadow also contains the buffer for the i2c commands written to the LCD controller.

At offset LCD_SHORT_CMD a small piece of memory is reserved for direct commands to the LCD controller. This is used for power on/off, and for single byte updates.

At offset LCD_LONG_CMD a small piece of memory is reserved for the i2c command header to do a full LCD update. The display data directly follows this header.

The entire buffer in memory looks like this:

0 1 2 3 4 5 +------+------+------+------+------+--- ---+ | Addr | Cmd | Data | Addr | 0x00 | display data (9 bytes) | +------+------+------+------+------+--- ---+ / / LCD_SHORT_CMD LCD_LONG_CMD with display data

Definition at line 72 of file lcd.c.

Referenced by lcd_init(), lcd_power_off(), lcd_power_on(), and lcd_refresh().


Generated on Fri Feb 25 08:02:43 2005 for brickos by  doxygen 1.3.9.1