brickOS Kernel Developer v0.9.0
|
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.
Macros | |
#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 | |
static __inline__ void | i2c_start (void) |
generate an i2c start condition. | |
static __inline__ void | i2c_stop (void) |
generate an i2c stop condition. | |
static __inline__ void | i2c_read_ack (void) |
read the acknoledge from the i2c bus. | |
static __inline__ void | i2c_write (unsigned char val) |
write one byte to the i2c bus. | |
static 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) |
refresh the entire LCD display | |
void | lcd_power_on (void) |
power on the LCD controller | |
void | lcd_power_off (void) |
power off the LCD controller | |
void | lcd_init (void) |
initialize the LCD display 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. | |
static unsigned char | lcd_shadow [LCD_DATA_OFFSET+LCD_DATA_SIZE] |
lcd_shadow buffer: | |
Implementation: wrapper for ROM LCD number display functions.
Definition in file lcd.c.
#define clr | ( | b | ) | __asm__ __volatile__("bclr %0,@0xbb:8" : : "i"(b)); |
#define set | ( | b | ) | __asm__ __volatile__("bset %0,@0xbb:8" : : "i"(b)); |
#define slowdown | ( | ) |
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.
|
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, SDA, set, and slowdown.
Referenced by lcd_write_data().
|
static |
|
static |
|
static |
void lcd_init | ( | void | ) |
initialize the LCD display driver
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.
void lcd_number | ( | int | i, |
lcd_number_style | n, | ||
lcd_comma_style | c | ||
) |
show number on LCD display
i | the number |
n | a number style |
c | a comma style |
void lcd_power_off | ( | void | ) |
power off the LCD controller
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.
void lcd_power_on | ( | void | ) |
power on the LCD controller
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().
void lcd_refresh | ( | void | ) |
refresh the entire LCD display
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().
void lcd_refresh_next_byte_core | ( | void | ) |
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().
|
static |
write an array of bytes to the i2c bus.
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(), lcd_refresh(), and lcd_refresh_next_byte_core().
unsigned char lcd_byte_counter |
LCD byte to refresh.
Definition at line 43 of file lcd.c.
Referenced by lcd_init(), and lcd_refresh_next_byte_core().
unsigned char lcd_refresh_counter |
|
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(), lcd_refresh(), and lcd_refresh_next_byte_core().