#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>
Include dependency graph for lcd.c:
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 | |
__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. | |
HANDLER_WRAPPER ("lcd_refresh_next_byte","lcd_refresh_next_byte_core") | |
lcd refresh handler, called from system timer interrupt | |
void | lcd_refresh_next_byte_core (void) |
alternate name for the refresh next byte routine | |
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_refresh_counter |
counter for lcd refresh in ms | |
unsigned char | lcd_byte_counter |
LCD byte to refresh. | |
unsigned char | lcd_refresh_period = 2 |
LCD refresh period in ms. | |
unsigned char | lcd_shadow [LCD_DATA_OFFSET+LCD_DATA_SIZE] |
lcd_shadow buffer: |
Definition in file lcd.c.
|
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(). |
|
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(). |
|
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(). |
|
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. |
|
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, SDA, set, and slowdown. Referenced by lcd_write_data(). |
|
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(). |
|
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(). |
|
write one byte to the i2c bus.
Definition at line 169 of file lcd.c. References clr, SCL, SDA, set, and slowdown. Referenced by lcd_write_data(). |
|
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, I2C_WRITE, lcd_byte_counter, LCD_DEV_ID, LCD_LONG_CMD, lcd_power_on(), lcd_refresh_counter, lcd_shadow, LCD_SHORT_CMD, memset(), PORT6_DDR, rom_port6_ddr, SCL, and SDA. |
|
show number on LCD display
|
|
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_DISABLE, LCD_MODE_SET, lcd_refresh(), lcd_shadow, LCD_SHORT_CMD, lcd_write_data(), SCL, and SDA. |
|
power on LCD display, also called from lcd_init() the LCD controller is enabled. Definition at line 266 of file lcd.c. References LCD_ENABLE, LCD_MODE_SET, lcd_shadow, LCD_SHORT_CMD, and lcd_write_data(). Referenced by lcd_init(). |
|
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_DATA_OFFSET, LCD_DATA_SIZE, LCD_LONG_CMD, lcd_shadow, and lcd_write_data(). Referenced by lcd_power_off(), show_off(), and show_on(). |
|
alternate name for the refresh next byte routine
Definition at line 229 of file lcd.c. References display_memory, lcd_byte_counter, LCD_DATA_OFFSET, LCD_DATA_SIZE, lcd_shadow, LCD_SHORT_CMD, and lcd_write_data(). |
|
write an array of bytes to the i2c bus.
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(), lcd_refresh(), and lcd_refresh_next_byte_core(). |
|
LCD byte to refresh.
Definition at line 43 of file lcd.c. Referenced by lcd_init(), and lcd_refresh_next_byte_core(). |
|
counter for lcd refresh in ms
Definition at line 42 of file lcd.c. Referenced by lcd_init(). |
|
LCD refresh period in ms.
|
|
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(), lcd_refresh(), and lcd_refresh_next_byte_core(). |
brickOS is released under the
Mozilla Public License.
Original code copyright 1998-2002 by the authors. |