Moved some files into the Renesas-Files folder that were previously in the root.

This commit is contained in:
Richard Barry 2011-09-16 14:47:36 +00:00
parent 93940b4717
commit 47455d6d1b
4 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,445 @@
/*------------------------------------------------------------------------/
/ EZ-LCD - Generic control module for HD44780 LCDC - R0.01c
/-------------------------------------------------------------------------/
/
/ Copyright (C) 2010, ChaN, all right reserved.
/
/ * This software is a free software and there is NO WARRANTY.
/ * No restriction on use. You can use, modify and redistribute it for
/ personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
/ * Redistributions of source code must retain the above copyright notice.
/
/-------------------------------------------------------------------------/
/ Nov 12,'10 R0.01c First release.
/------------------------------------------------------------------------*/
#include <machine.h>
#include "hd44780.h"
/*-------------------------------------------------------------------------*/
/* Platform dependent macros and functions needed to be modified */
/*-------------------------------------------------------------------------*/
/* Bus controls */
#include "iodefine.h" /* Device specific include file */
#include "rskrx210def.h"
#define IF_BUS 4 /* Data bus width (4 or 8) */
#define IF_INIT() {} /* Initialize control port */
#define E1_HIGH() LCD_EN = 1 /* Set E(E1) high */
#define E1_LOW() LCD_EN = 0 /* Set E(E1) low */
#define E2_HIGH() /* Set E2 high (dual controller only) */
#define E2_LOW() /* Set E2 low (dual controller only) */
#define RS_HIGH() LCD_RS = 1 /* Set RS high */
#define RS_LOW() LCD_RS = 0 /* Set RS low */
#define OUT_DATA(d) LCD_DATA = (d & 0x0F)//LCD_DATA = ((LCD_DATA & 0xF0) | (d & 0x0F)) /* Output a byte d on the data bus (higher 4 bits of d in 4-bit mode) */
#define IF_DLY60() {nop();nop();nop(); } /* Delay >=60ns (can be blanked for most uC) */
#define IF_DLY450() {unsigned long x; for(x=0; x<22; x++){nop();}} /* Delay >=450ns@3V, >=250ns@5V */
#define DELAY_US(n) {unsigned long x; for(x=0; x<(n*50); x++){nop();}} /* Delay n microseconds */
/* Characteristics of LCD module */
#define LCD_ETIME_1 1530 /* Execution time of Clear Display command [us] */
#define LCD_ETIME_2 43 /* Execution time of other command and data write [us] */
#define LCD_DLF 2.0 /* Delay factor (>=2.0) */
/*-------------------------------------------------------------------------*/
#if _LCD_ROWS >= 2 || _LCD_COLS > 8
#define LCD_IF_2ROW 8 /* 2-row cfg. */
#if _LCD_ROWS == 1
#define LCD_IF_SPLIT 1 /* Half split row */
#else
#define LCD_IF_SPLIT 0 /* Direct row */
#endif
#else
#define LCD_IF_2ROW 0 /* 1-row cfg. */
#endif
#if _LCD_ROWS == 4 && _LCD_COLS <= 20
#define LCD_IF_ALTROW 1 /* Alternate row layout */
#else
#define LCD_IF_ALTROW 0 /* Incremental row layout */
#endif
#if _LCD_ROWS == 4 && _LCD_COLS > 20
#define LCD_IF_DUAL 1 /* Dual controller */
#else
#define LCD_IF_DUAL 0 /* Single controller */
#endif
#define LCD_DT1 ((uint16_t)(LCD_ETIME_1 * LCD_DLF))
#define LCD_DT2 ((uint16_t)(LCD_ETIME_2 * LCD_DLF))
static
uint8_t Row, Column; /* Current cursor position */
#if _USE_CURSOR
static
uint8_t Csr; /* Current cursor state */
#endif
/*----------------------------------------------*/
/* Write a byte to the LCD controller */
/*----------------------------------------------*/
static
void lcd_write (
uint8_t reg, /* b0:command(0)/data(1), b2..1:E1(2)/E2(1)/both(0)(don't care on single controller), b3:write high nibble only(don't care on 8-bit bus) */
uint8_t dat /* Byte to be written */
)
{
if (reg & 1) /* Select register */
RS_HIGH();
else
RS_LOW();
IF_DLY60();
#if IF_BUS == 4
if (!(reg & 8)) {
OUT_DATA(dat);
#if LCD_IF_DUAL
if (!(reg & 2)) E1_HIGH();
if (!(reg & 4)) E2_HIGH();
IF_DLY450();
E1_LOW();
E2_LOW();
#else
E1_HIGH();
IF_DLY450();
E1_LOW();
#endif
IF_DLY450();
dat <<= 4;
}
#endif
OUT_DATA(dat);
#if LCD_IF_DUAL
if (!(reg & 2)) E1_HIGH();
if (!(reg & 4)) E2_HIGH();
IF_DLY450();
E1_LOW();
E2_LOW();
#else
E1_HIGH();
IF_DLY450();
E1_LOW();
#endif
DELAY_US(LCD_DT2); /* Always use timer */
}
/*-----------------------------------------------------------------------*/
/* Initialize LCD module */
/*-----------------------------------------------------------------------*/
void lcd_init (void)
{
uint8_t d;
E1_HIGH();
DELAY_US(40000);
E1_LOW();
// IF_INIT();
// DELAY_US(40000);
lcd_write(8, 0x30);
DELAY_US(4100);
lcd_write(8, 0x30);
DELAY_US(100);
lcd_write(8, 0x30);
d = (IF_BUS == 4 ? 0x20 : 0x30) | LCD_IF_2ROW;
lcd_write(8, d);
#if IF_BUS == 4
lcd_write(0, d);
#endif
lcd_write(0, 0x08);
lcd_write(0, 0x01);
DELAY_US(LCD_DT1);
lcd_write(0, 0x06);
lcd_write(0, 0x0C);
Row = Column = 0;
#if _USE_CURSOR
Csr = 0;
#endif
}
/*-----------------------------------------------------------------------*/
/* Set cursor position */
/*-----------------------------------------------------------------------*/
void lcd_locate (
uint8_t row, /* Cursor row position (0.._LCD_ROWS-1) */
uint8_t col /* Cursor column position (0.._LCD_COLS-1) */
)
{
Row = row; Column = col;
if (row < _LCD_ROWS && col < _LCD_COLS) {
if (_LCD_COLS >= 2 && (row & 1)) col += 0x40;
if (LCD_IF_SPLIT && col >= _LCD_COLS / 2) col += 0x40 - _LCD_COLS / 2;
if (LCD_IF_ALTROW && (row & 2)) col += _LCD_COLS;
col |= 0x80;
} else {
col = 0x0C;
}
#if LCD_IF_DUAL
if (_USE_CURSOR && !(row &= 2)) row |= 4;
lcd_write(row, col);
#if _USE_CURSOR
if (col != 0x0C) lcd_write(row, Csr | 0x0C);
row ^= 6;
lcd_write(row, 0x0C);
#endif
#else
lcd_write(0, col);
#if _USE_CURSOR
if (col != 0x0C) lcd_write(0, Csr | 0x0C);
#endif
#endif
}
/*-----------------------------------------------------------------------*/
/* Put a character */
/*-----------------------------------------------------------------------*/
void lcd_putc (
uint8_t chr
)
{
if (chr == '\f') { /* Clear Screen and Return Home */
lcd_write(0, 0x01);
DELAY_US(LCD_DT1);
lcd_locate(0, 0);
return;
}
if (Row >= _LCD_ROWS) return;
if (chr == '\r') { /* Cursor return */
lcd_locate(Row, 0);
return;
}
if (chr == '\n') { /* Next row */
lcd_locate(Row + 1, 0);
return;
}
if (chr == '\b') { /* Cursor back */
if (Column)
lcd_locate(Row, Column - 1);
return;
}
if (Column >= _LCD_COLS) return;
lcd_write((LCD_IF_DUAL && Row >= 2) ? 3 : 5, chr);
Column++;
if (LCD_IF_SPLIT && Column == _LCD_COLS / 2)
lcd_write(0, 0x40);
if (Column >= _LCD_COLS)
lcd_locate(Row + 1, 0);
}
/*-----------------------------------------------------------------------*/
/* Set cursor form */
/*-----------------------------------------------------------------------*/
#if _USE_CURSOR
void lcd_cursor (
uint8_t stat /* 0:off, 1:blinking block, 2:under-line */
)
{
Csr = stat & 3;
lcd_locate(Row, Column);
}
#endif
/*-----------------------------------------------------------------------*/
/* Register user character pattern */
/*-----------------------------------------------------------------------*/
#if _USE_CGRAM
void lcd_setcg (
uint8_t chr, /* Character code to be registered (0..7) */
uint8_t n, /* Number of characters to register */
const uint8_t* p /* Pointer to the character pattern (8 * n bytes) */
)
{
lcd_write(0, 0x40 | chr * 8);
n *= 8;
do
lcd_write(1, *p++);
while (--n);
lcd_locate(Row, Column);
}
#endif
/*-----------------------------------------------------------------------*/
/* Put a fuel indicator */
/*-----------------------------------------------------------------------*/
#if _USE_FUEL && _USE_CGRAM
void lcd_put_fuel (
int8_t val, /* Fuel level (-1:plugged, 0:empty cell, ..., 5:full cell) */
uint8_t chr /* User character to use */
)
{
static const uint8_t plg[8] = {10,10,31,31,14,4,7,0};
uint8_t gfx[8], d, *p;
int8_t i;
if (val >= 0) { /* Cell (0..5) */
p = &gfx[8];
*(--p) = 0; *(--p) = 0x1F;
for (i = 1; i <= 5; i++) {
d = 0x1F;
if (val < i) d = (i == 5) ? 0x1B : 0x11;
*(--p) = d;
}
*(--p) = 0x0E;
} else { /* Plug (-1) */
p = (uint8_t*)plg;
}
lcd_setcg(chr, 1, p);
lcd_putc(chr);
}
#endif
/*-----------------------------------------------------------------------*/
/* Draw bargraph */
/*-----------------------------------------------------------------------*/
#if _USE_BAR && _USE_CGRAM
void lcd_put_bar (
uint16_t val, /* Bar length (0 to _MAX_BAR represents bar length from left end) */
uint8_t width, /* Display area (number of chars from cursor position) */
uint8_t chr /* User character code (2 chars used from this) */
)
{
static const uint8_t ptn[] = {
0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0x80, 0,
0xF0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0xC0, 0,
0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0
};
const uint8_t *pp;
uint16_t n, m, s, gi;
uint8_t gfx[16];
for (n = 0; n < 16; n++) /* Register common pattern (space/fill) */
gfx[n] = n < 7 ? 0 : 0xFF;
lcd_setcg(_BASE_GRAPH, 2, gfx);
/* Draw edge pattern into gfx[] */
val = (unsigned long)val * (width * 18) / (_MAX_BAR + 1);
pp = &ptn[(val % 3) * 8]; /* Get edge pattern */
s = val / 3 % 6; /* Bit shift */
for (n = 0; n < 7; n++) { /* Draw edge pattern into the pattern buffer */
m = (*pp++ | 0xFF00) >> s;
gfx[n] = m;
gfx[n + 8] = m >> 6;
}
/* Put graphic pattern into the LCD module */
gi = val / 18; /* Indicator start position */
for (n = 1; n <= width; n++) { /* Draw each location in the bargraph */
if (n == gi) { /* When edge pattern is exist at the location */
m = chr + 1; /* A edge pattern */
} else {
if (n == gi + 1) {
lcd_setcg(chr, 2, gfx); /* Register edge pattern */
m = chr;
} else {
m = (n >= gi) ? _BASE_GRAPH : _BASE_GRAPH + 1; /* A space or fill */
}
}
lcd_putc(m); /* Put the character into the LCD */
}
}
#endif
/*-----------------------------------------------------------------------*/
/* Draw point indicator */
/*-----------------------------------------------------------------------*/
#if _USE_POINT && _USE_CGRAM
void lcd_put_point (
uint16_t val, /* Dot position (0 to _MAX_POINT represents left end to write end) */
uint8_t width, /* Display area (number of chars from cursor position) */
uint8_t chr /* User character code (2 chars used from this) */
)
{
static const uint8_t ptn[] = {
0x06, 0x0C, 0x0C, 0x0C, 0x18, 0x18, 0x18, 0,
0x06, 0x06, 0x0C, 0x0C, 0x0C, 0x18, 0x18, 0,
0x06, 0x06, 0x06, 0x0C, 0x0C, 0x0C, 0x18, 0
};
const uint8_t *pp;
uint16_t n, m, s, gi;
uint8_t gfx[16];
for (n = 0; n < 16; n++) /* Register common pattern (space) */
gfx[n] = n < 7 ? 0 : 0xFF;
lcd_setcg(_BASE_GRAPH, 1, gfx);
/* Draw edge pattern into gfx[] */
val = (uint32_t)val * (width * 18 - 12) / (_MAX_BAR + 1);
pp = &ptn[(val % 3) * 8]; /* Get edge pattern */
s = val / 3 % 6; /* Bit shift */
for (n = 0; n < 7; n++) { /* Draw edge pattern into the pattern buffer */
m = *pp++; m <<= 6; m >>= s;
gfx[n] = m;
gfx[n + 8] = m >> 6;
}
lcd_setcg(chr, 2, gfx); /* Register dot pattern */
/* Put graphic pattern into the LCD module */
gi = val / 18; /* Indicator start position */
for (n = 0; n < width; n++) { /* Draw each location in the bargraph */
if (n == gi) { /* When edge pattern is exist at the location */
m = chr + 1; /* A edge pattern */
} else {
if (n == gi + 1)
m = chr;
else
m = _BASE_GRAPH; /* A space */
}
lcd_putc(m); /* Put the character into the LCD */
}
}
#endif

View file

@ -0,0 +1,56 @@
/*-----------------------------------------------------------------------*/
/* EZ-LCD - Generic control module include/configuration file */
/*-----------------------------------------------------------------------*/
#ifndef _EZ_LCD
#define _EZ_LCD
/*--------------------------------------------------*/
/* Configuration Options */
/*--------------------------------------------------*/
#define _LCD_ROWS 2 /* Number of Rows (1,2 or 4) */
#define _LCD_COLS 8 /* Number of Columns (8..40) */
#define _USE_CURSOR 0 /* 1:Enable lcd_cursor function */
#define _USE_CGRAM 0 /* 1:Enable lcd_setcg function */
#define _USE_FUEL 0 /* 1:Enable lcd_put_fuel function (_USE_CGRAM must be 1) */
#define _USE_BAR 0 /* 1:Enable lcd_put_bar function (_USE_CGRAM must be 1) */
#define _MAX_BAR 255 /* Maximum value for lcd_put_bar function */
#define _USE_POINT 0 /* 1:Enable lcd_put_point function (_USE_CGRAM must be 1) */
#define _MAX_POINT 255 /* Maximum value for lcd_put_point function */
#define _BASE_GRAPH 0 /* Common user character used by lcd_put_bar/lcd_put_point function (2 chars from this) */
/*--------------------------------------------------*/
/* API declareations */
/*--------------------------------------------------*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
void lcd_init (void);
void lcd_locate (uint8_t, uint8_t);
void lcd_putc (uint8_t);
void lcd_cursor (uint8_t);
void lcd_setcg (uint8_t, uint8_t, const uint8_t*);
void lcd_put_fuel (int8_t, uint8_t);
void lcd_put_bar (uint16_t, uint8_t, uint8_t);
void lcd_put_point (uint16_t, uint8_t, uint8_t);
#ifdef __cplusplus
}
#endif
#define CSR_OFF 0
#define CSR_BLOCK 1
#define CSR_UNDER 2
#endif /* #ifndef _EZLCD */

View file

@ -0,0 +1,392 @@
/***********************************************************************************
Filename: lcd.c
DESCRIPTION LCD Module utility functions.
Written for KS0066u compatible LCD Module.
(8 characters by 2 lines)
Copyright : 2006 Renesas Technology Europe Ltd.
Copyright : 2006 Renesas Technology Corporation.
All Rights Reserved
***********************************************************************************/
/***********************************************************************************
Revision History
DD.MM.YYYY OSO-UID Description
26.07.2006 RTE-MBA First Release
***********************************************************************************/
/**********************************************************************************
System Includes
***********************************************************************************/
#include <machine.h>
/**********************************************************************************
User Includes
***********************************************************************************/
/* iodefine.h provides a structure to access all of the device registers. */
#include "iodefine.h"
/* rsk1664def.h provides common defines for widely used items. */
#include "rskrx210def.h"
#include "lcd.h"
/* Kernel includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
/**********************************************************************************
Global variables
***********************************************************************************/
xQueueHandle SwitchQueue;
xSemaphoreHandle LCD_Mutex;
char datastring[]=
"........Rx210 Highlights....1.56 DMips/MHz....DSP functions....1.62V-5.5V operation....200 uA/MHz....Up to 512 kBytes Flash....up to 64 kbytes SRAM....EE Dataflash with 100k w/e....1.3 uA in Real Time Clock Mode....Powerful Motor control timer....4 x 16-bit timers....4 x 8-bit timers....Full Real Time Clock calendar with calibration and alarm functions....Up to 16 channels 1 uS 12-bit ADC, with Dual group programmable SCAN, 3 sample and holds, sample accumulate function....DMA controller....Data Transfer Controller....Up to 9 serial Channels....Up to 6 USARTs ( with Simple I2C / SPI )....USART ( with unique Frame based protocol support )....Multimaster IIC....RSPI....Temperature Sensor....Event Link Controller....Comparators....Safety features include CRC....March X....Dual watchdog Timers with window and independent oscillator....ADC self test....I/O Pin Test....Supported with E1 on chip debugger and RSK210 evaluation system....Rx210 Highlights........";
struct _LCD_Params Line1 =
{
LCD_LINE1, 215, datastring
};
struct _LCD_Params Line2 =
{
LCD_LINE2, 350, datastring
};
/**********************************************************************************
User Program Code
***********************************************************************************/
/*****************************************************************************
Name: InitDisplay
Parameters: none
Returns: none
Description: Intializes the LCD display.
*****************************************************************************/
void InitialiseDisplay( void )
{
/* Power Up Delay for LCD Module */
EN_PIN = SET_BIT_HIGH;
DisplayDelay(7000);
EN_PIN = SET_BIT_LOW;
/* Display initialises in 8 bit mode - so send one write (seen as 8 bit)
to set to 4 bit mode. */
/* Function Set */
LCD_nibble_write(CTRL_WR,0x03);
LCD_nibble_write(CTRL_WR,0x03);
DisplayDelay(39);
/* Configure display */
LCD_nibble_write(CTRL_WR,0x03);
LCD_nibble_write(CTRL_WR,0x02);
LCD_nibble_write(CTRL_WR,(LCD_DISPLAY_ON | LCD_TWO_LINE ));
LCD_nibble_write(CTRL_WR,(LCD_DISPLAY_ON | LCD_TWO_LINE ));
DisplayDelay(39);
/* Display ON/OFF control */
LCD_write(CTRL_WR,LCD_CURSOR_OFF);
DisplayDelay(39);
/* Display Clear */
LCD_write(CTRL_WR,LCD_CLEAR);
DisplayDelay(1530);
/* Entry Mode Set */
LCD_write(CTRL_WR,0x06);
LCD_write(CTRL_WR,LCD_HOME_L1);
}
/**********************************************************************************
End of function InitialiseDisplay
***********************************************************************************/
/*****************************************************************************
Name: DisplayString
Parameters: position Line number of display
string Pointer to data to be written to display.
Last character should be null.
Returns: none
Description: This function controls LCD writes to line 1 or 2 of the LCD.
You need to use the defines LCD_LINE1 and LCD_LINE2 in order
to specify the starting position.
For example, to start at the 2nd position on line 1...
DisplayString(LCD_LINE1 + 1, "Hello")
*****************************************************************************/
void DisplayString(unsigned char position, char * string)
{
static unsigned char next_pos = 0xFF;
/* Set line position if needed. We don't want to if we don't need
to because LCD control operations take longer than LCD data
operations. */
if( next_pos != position)
{
if(position < LCD_LINE2)
{
/* Display on Line 1 */
LCD_write(CTRL_WR, (unsigned char)(LCD_HOME_L1 + position) );
}
else
{
/* Display on Line 2 */
LCD_write(CTRL_WR, (unsigned char)(LCD_HOME_L2 + position - LCD_LINE2) );
}
/* set position index to known value */
next_pos = position;
}
do
{
LCD_write(DATA_WR,*string++);
/* increment position index */
next_pos++;
}
while(*string);
}
/**********************************************************************************
End of function DisplayString
***********************************************************************************/
/*****************************************************************************
Name: LCD_write
Parameters: value - the value to write
data_or_ctrl - To write value as DATA or CONTROL
1 = DATA
0 = CONTROL
Returns: none
Description: Writes data to display. Sends command to display.
*****************************************************************************/
void LCD_write(unsigned char data_or_ctrl, unsigned char value)
{
/* Write upper nibble first */
LCD_nibble_write(data_or_ctrl, (value & 0xF0) >> 4);
/* Write lower nibble second */
LCD_nibble_write(data_or_ctrl, (value & 0x0F));
}
/**********************************************************************************
End of function LCD_write
***********************************************************************************/
/*****************************************************************************
Name: LCD_nibble_write
Parameters: value - the value to write
data_or_ctrl - To write value as DATA or CONTROL
1 = DATA
0 = CONTROL
Returns: none
Description: Writes data to display. Sends command to display.
*****************************************************************************/
void LCD_nibble_write(unsigned char data_or_ctrl, unsigned char value)
{
unsigned char ucStore;
if (data_or_ctrl == DATA_WR)
{
RS_PIN = SET_BIT_HIGH;
}
else
{
RS_PIN = SET_BIT_LOW;
}
/* There must be 40ns between RS write and EN write */
DisplayDelay(1);
/* EN enable chip (HIGH) */
EN_PIN = SET_BIT_HIGH;
/* Tiny delay */
DisplayDelay(1);
/* Clear port bits used */
/* Set upper lower 4 bits of nibble on port pins. */
ucStore = DATA_PORT;
ucStore &= ~DATA_PORT_MASK;
/* OR in data */
ucStore |= ((value << DATA_PORT_SHIFT) & DATA_PORT_MASK );
/* Write lower 4 bits of nibble */
DATA_PORT = ucStore;
/* write delay while En High */
DisplayDelay(20);
/* Latch data by dropping EN */
EN_PIN = SET_BIT_LOW;
/* Data hold delay */
DisplayDelay(20);
if(data_or_ctrl == CTRL_WR)
{
/* Extra delay needed for control writes */
DisplayDelay(40);
}
}
/**********************************************************************************
End of function LCD_nibble_write
***********************************************************************************/
/*****************************************************************************
Name: DisplayDelay
Parameters: units - Approximately in microseconds
Returns: none
Description: Delay routine for LCD display.
*****************************************************************************/
void DisplayDelay(unsigned long int units)
{
unsigned long counter = units * DELAY_TIMING;
while(counter--)
{
nop(); // ~ 10ns
}
}
/**********************************************************************************
End of function DisplayDelay
***********************************************************************************/
void prvLCDTaskLine1( void *pvParameters )
{
#define RIGHT_TO_LEFT 0
#define LEFT_TO_RIGHT 1
struct _LCD_Params *Local_Params = (struct _LCD_Params*)pvParameters;
char str_lcd[9];
unsigned short pos = 0;
unsigned char Direction = RIGHT_TO_LEFT;
for(;;)
{
vTaskDelay( Local_Params->Speed / portTICK_RATE_MS );
strncpy(str_lcd, &Local_Params->ptr_str[pos], 8);
xSemaphoreTake( LCD_Mutex, portMAX_DELAY );
DisplayString(Local_Params->Line, str_lcd);
xSemaphoreGive( LCD_Mutex );
if(Direction == RIGHT_TO_LEFT)
{
pos++;
if( pos == strlen(datastring) - 7)
{
Direction = LEFT_TO_RIGHT;
pos--;
}
}
else
{
pos--;
if( pos == 0 )
{
Direction = RIGHT_TO_LEFT;
}
}
}
}
void prvLCDTaskLine2( void *pvParameters )
{
#define RIGHT_TO_LEFT 0
#define LEFT_TO_RIGHT 1
#define RUNNING 0
#define STOPPED 1
struct _LCD_Params *Local_Params = (struct _LCD_Params*)pvParameters;
char str_lcd[9];
unsigned short pos = 0;
unsigned char Direction = RIGHT_TO_LEFT;
unsigned char Status = RUNNING;
unsigned char QueueData;
portTickType Delay = ( Local_Params->Speed / portTICK_RATE_MS );
for(;;)
{
// vTaskDelay( Local_Params->Speed / portTICK_RATE_MS );
if( xQueueReceive (SwitchQueue, &QueueData, Delay) != pdPASS )
{
strncpy(str_lcd, &Local_Params->ptr_str[pos], 8);
xSemaphoreTake( LCD_Mutex, portMAX_DELAY );
DisplayString(Local_Params->Line, str_lcd);
xSemaphoreGive( LCD_Mutex );
if(Direction == RIGHT_TO_LEFT)
{
pos++;
if( pos == strlen(datastring) - 7)
{
Direction = LEFT_TO_RIGHT;
pos--;
}
}
else
{
pos--;
if( pos == 0 )
{
Direction = RIGHT_TO_LEFT;
}
}
}
else
{
if(QueueData == 0x02) // stop/start
{
if(Delay != portMAX_DELAY)
{
Delay = portMAX_DELAY;
Status = STOPPED;
}
else
{
Delay = ( Local_Params->Speed / portTICK_RATE_MS );
Status = RUNNING;
}
}
if(QueueData == 0x01) // RIGHT or shift back
{
if(Status == STOPPED)
{
if(pos != 0)
{
pos--;
strncpy(str_lcd, &Local_Params->ptr_str[pos], 8);
xSemaphoreTake( LCD_Mutex, portMAX_DELAY );
DisplayString(Local_Params->Line, str_lcd);
xSemaphoreGive( LCD_Mutex );
}
}
}
if(QueueData == 0x03) // LEFT or shift forward
{
if(Status == STOPPED)
{
if(pos != strlen(datastring) - 7)
{
pos++;
strncpy(str_lcd, &Local_Params->ptr_str[pos], 8);
xSemaphoreTake( LCD_Mutex, portMAX_DELAY );
DisplayString(Local_Params->Line, str_lcd);
xSemaphoreGive( LCD_Mutex );
}
}
}
}
}
}

View file

@ -0,0 +1,97 @@
#ifndef LCD_H
#define LCD_H
/***********************************************************************************
FILE NAME lcd.h
DESCRIPTION Driver for KS0066u LCD Module Controller (8 characters by 2 lines )
on the Renesas RSK boards - header file
Copyright : 2006 Renesas Technology Europe Ltd.
Copyright : 2006 Renesas Technology Corporation.
All Rights Reserved
***********************************************************************************/
/***********************************************************************************
Revision History
DD.MM.YYYY OSO-UID Description
26.07.2006 RTE-MBA First Release
***********************************************************************************/
void InitialiseDisplay( void );
void DisplayString(unsigned char position, char * string);
void LCD_write(unsigned char data_or_ctrl, unsigned char value);
void LCD_nibble_write(unsigned char data_or_ctrl, unsigned char value);
void DisplayDelay(unsigned long int units);
#define SET_BIT_HIGH (1)
#define SET_BIT_LOW (0)
#define SET_BYTE_HIGH (0xFF)
#define SET_BYTE_LOW (0x00)
struct _LCD_Params {
unsigned char Line;
unsigned short Speed;
char *ptr_str;
};
void prvLCDTaskLine1( void *pvParameters );
void prvLCDTaskLine2( void *pvParameters );
/* RS Register Select pin */
#define RS_PIN PORTJ.PODR.BIT.B1
/* Display Enable pin */
#define EN_PIN PORTJ.PODR.BIT.B3
/* Data bus port */
#define DATA_PORT PORTH.PODR.BYTE
/* Bit mask from entire port */
#define DATA_PORT_MASK 0x0F
/* Number of bits data needs to shift */
#define DATA_PORT_SHIFT 0
#define DATA_WR 1
#define CTRL_WR 0
/* Set to ensure base delay of 1microS minimum */
//#define DELAY_TIMING 0x2F
#define DELAY_TIMING 50
/* number of lines on the LCD display */
#define NUMB_CHARS_PER_LINE 8
/* Maximum charactors per line of LCD display. */
#define MAXIMUM_LINES 2
#define LCD_LINE1 0
#define LCD_LINE2 16
/**********************************************************************************/
/* LCD commands - use LCD_write function to write these commands to the LCD. */
/**********************************************************************************/
/* Clear LCD display and home cursor */
#define LCD_CLEAR 0x01
/* move cursor to line 1 */
#define LCD_HOME_L1 0x80
/* move cursor to line 2 */
#define LCD_HOME_L2 0xC0
/* Cursor auto decrement after R/W */
#define CURSOR_MODE_DEC 0x04
/* Cursor auto increment after R/W */
#define CURSOR_MODE_INC 0x06
/* Setup, 4 bits,2 lines, 5X7 */
#define FUNCTION_SET 0x28
/* Display ON with Cursor */
#define LCD_CURSOR_ON 0x0E
/* Display ON with Cursor off */
#define LCD_CURSOR_OFF 0x0C
/* Display on with blinking cursor */
#define LCD_CURSOR_BLINK 0x0D
/*Move Cursor Left One Position */
#define LCD_CURSOR_LEFT 0x10
/* Move Cursor Right One Position */
#define LCD_CURSOR_RIGHT 0x14
#define LCD_DISPLAY_ON 0x04
#define LCD_TWO_LINE 0x08
#endif