Main Page   Class Hierarchy   Compound List   File List   Header Files   Compound Members   File Members  

legOS/kernel/lcd.c File Reference

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


Defines

#define set (b)
set/clear single bit convenience macros.

#define clr (b)
#define slowdown ()
generate the necessary delay for the i2c bus. More...


Functions

void lcd_number (int i,lcd_number_style n,lcd_comma_style c )
show number on LCD display. More...

 __asm__ (" .text .align 1 .globl _lcd_number _lcd_number: push r6 ; save r6 push r2 ; comma_style -> stack push r0 ; number -> stack mov.w r1,r6 ; number_style -> r6 jsr @lcd_number ; call ROM adds #0x02,sp ; clear stack adds #0x02,sp pop r6 ; restore r6 rts ")
__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. More...

__inline__ void i2c_write (unsigned char val)
write one byte to the i2c bus. More...

void lcd_write_data (unsigned char *data, unsigned char len)
write an array of bytes to the i2c bus. More...

 HANDLER_WRAPPER ("lcd_refresh_next_byte", "lcd_refresh_next_byte_core")
lcd refresh handler, called from system timer interrupt. More...

void lcd_refresh_next_byte_core (void)
void lcd_refresh (void)
show LCD display contents to the world. More...

void lcd_power_on (void)
power on LCD display, also called from lcd_init(). More...

void lcd_power_off (void)
power off LCD display. More...

void lcd_init (void)
initialize LCD driver. More...


Variables

unsigned char lcd_refresh_counter
counter for lcd refresh in ms.

unsigned char lcd_byte_counter
LCD byte to refresh.

unsigned char lcd_refresh_period
LCD refresh period in ms.

unsigned char lcd_shadow [LCD_DATA_OFFSET + LCD_DATA_SIZE]
lcd_shadow buffer:. More...


Detailed Description

wrapper for ROM LCD number display functions.

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

Define Documentation

#define set (b)

set/clear single bit convenience macros.

#define clr (b)

#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.


Function Documentation

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

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

__inline__ void i2c_start (void) [static]

generate an i2c start condition.

__inline__ void i2c_stop (void) [static]

generate an i2c stop condition.

__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.

__inline__ void i2c_write (unsigned char val) [static]

write one byte to the i2c bus.

Parameters:
val   byte to write to the i2c bus

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.

HANDLER_WRAPPER ("lcd_refresh_next_byte", "lcd_refresh_next_byte_core")

lcd refresh handler, called from system timer interrupt.

refresh one byte of display_memory.

Bytes are refreshed in round robin fashon and the lcd_shadow buffer is updated. If there was no difference between display_memory and the lcd_shadow buffer, the actual write to the LCD controller is skipped.

This routine is called every 6ms from the timer interrupt, resulting in a complete LCD update every 54ms, which is a refresh rate of 18 updates per second.

void lcd_refresh_next_byte_core (void)

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.

void lcd_power_on (void)

power on LCD display, also called from lcd_init().

the LCD controller is enabled.

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.

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.


Variable Documentation

unsigned char lcd_refresh_counter

counter for lcd refresh in ms.

unsigned char lcd_byte_counter

LCD byte to refresh.

unsigned char lcd_refresh_period

LCD refresh period in ms.

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

legOS-0.2.4 is released under the Mozilla Public License. Original code copyright 1998-1999 by the authors.