mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-09-02 04:13:54 -04:00
Add FreeRTOS-Plus directory.
This commit is contained in:
parent
7bd5f21ad5
commit
f508a5f653
6798 changed files with 134949 additions and 19 deletions
|
@ -0,0 +1,66 @@
|
|||
/***********************************************************************/
|
||||
/* */
|
||||
/* FILE :dbsct.c */
|
||||
/* DATE :Wed, Aug 11, 2010 */
|
||||
/* DESCRIPTION :Setting of B,R Section */
|
||||
/* CPU TYPE :Other */
|
||||
/* */
|
||||
/* This file is generated by Renesas Project Generator (Ver.4.50). */
|
||||
/* NOTE:THIS IS A TYPICAL EXAMPLE. */
|
||||
/* */
|
||||
/***********************************************************************/
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Device : RX
|
||||
*
|
||||
* File Name : dbsct.c
|
||||
*
|
||||
* Abstract : Setting of B,R Section.
|
||||
*
|
||||
* History : 1.00 (2009-08-07)
|
||||
*
|
||||
* NOTE : THIS IS A TYPICAL EXAMPLE.
|
||||
*
|
||||
* Copyright(c) 2009 Renesas Technology Corp.
|
||||
* And Renesas Solutions Corp.,All Rights Reserved.
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
#include "typedefine.h"
|
||||
|
||||
#pragma unpack
|
||||
|
||||
#pragma section C C$DSEC
|
||||
extern const struct {
|
||||
_UBYTE *rom_s; /* Start address of the initialized data section in ROM */
|
||||
_UBYTE *rom_e; /* End address of the initialized data section in ROM */
|
||||
_UBYTE *ram_s; /* Start address of the initialized data section in RAM */
|
||||
} _DTBL[] = {
|
||||
{ __sectop("D"), __secend("D"), __sectop("R") },
|
||||
{ __sectop("D_2"), __secend("D_2"), __sectop("R_2") },
|
||||
{ __sectop("D_1"), __secend("D_1"), __sectop("R_1") }
|
||||
};
|
||||
#pragma section C C$BSEC
|
||||
extern const struct {
|
||||
_UBYTE *b_s; /* Start address of non-initialized data section */
|
||||
_UBYTE *b_e; /* End address of non-initialized data section */
|
||||
} _BTBL[] = {
|
||||
{ __sectop("B"), __secend("B") },
|
||||
{ __sectop("B_2"), __secend("B_2") },
|
||||
{ __sectop("B_1"), __secend("B_1") }
|
||||
};
|
||||
|
||||
#pragma section
|
||||
|
||||
/*
|
||||
** CTBL prevents excessive output of L1100 messages when linking.
|
||||
** Even if CTBL is deleted, the operation of the program does not change.
|
||||
*/
|
||||
_UBYTE * const _CTBL[] = {
|
||||
__sectop("C_1"), __sectop("C_2"), __sectop("C"),
|
||||
__sectop("W_1"), __sectop("W_2"), __sectop("W")
|
||||
};
|
||||
|
||||
#pragma packoption
|
|
@ -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
|
||||
|
||||
|
|
@ -0,0 +1,217 @@
|
|||
/******************************************************************************
|
||||
* DISCLAIMER
|
||||
|
||||
* This software is supplied by Renesas Technology Corp. and is only
|
||||
* intended for use with Renesas products. No other uses are authorized.
|
||||
|
||||
* This software is owned by Renesas Technology Corp. and is protected under
|
||||
* all applicable laws, including copyright laws.
|
||||
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES
|
||||
* REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY
|
||||
* DISCLAIMED.
|
||||
|
||||
* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
|
||||
* TECHNOLOGY CORP. NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||
* FOR ANY REASON RELATED TO THE THIS SOFTWARE, EVEN IF RENESAS OR ITS
|
||||
* AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
* Renesas reserves the right, without notice, to make changes to this
|
||||
* software and to discontinue the availability of this software.
|
||||
* By using this software, you agree to the additional terms and
|
||||
* conditions found by accessing the following link:
|
||||
* http://www.renesas.com/disclaimer
|
||||
******************************************************************************
|
||||
* Copyright (C) 2008. Renesas Technology Corp., All Rights Reserved.
|
||||
*******************************************************************************
|
||||
* File Name : hwsetup.c
|
||||
* Version : 1.00
|
||||
* Description : Power up hardware initializations
|
||||
******************************************************************************
|
||||
* History : DD.MM.YYYY Version Description
|
||||
* : 15.02.2010 1.00 First Release
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
Includes <System Includes> , "Project Includes"
|
||||
******************************************************************************/
|
||||
#include <stdint.h>
|
||||
#include "iodefine.h"
|
||||
#include "rskrx210def.h"
|
||||
#include "hd44780.h" /* EZ-LCD include file */
|
||||
|
||||
/******************************************************************************
|
||||
Typedef definitions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
Macro definitions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
Imported global variables and functions (from other files)
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
Exported global variables and functions (to be accessed by other files)
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
Private global variables and functions
|
||||
******************************************************************************/
|
||||
void io_set_cpg(void);
|
||||
void ConfigurePortPins(void);
|
||||
void EnablePeripheralModules(void);
|
||||
|
||||
/******************************************************************************
|
||||
* Function Name: HardwareSetup
|
||||
* Description : This function does initial setting for CPG port pins used in
|
||||
* : the Demo including the MII pins of the Ethernet PHY connection.
|
||||
* Arguments : none
|
||||
* Return Value : none
|
||||
******************************************************************************/
|
||||
void HardwareSetup(void)
|
||||
{
|
||||
/* CPG setting */
|
||||
io_set_cpg();
|
||||
|
||||
/* Setup the port pins */
|
||||
ConfigurePortPins();
|
||||
|
||||
/* Enables peripherals */
|
||||
EnablePeripheralModules();
|
||||
|
||||
#if INCLUDE_LCD == 1
|
||||
/* Initialize display */
|
||||
InitialiseDisplay();
|
||||
#endif
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function Name: EnablePeripheralModules
|
||||
* Description : Enables Peripheral Modules before use
|
||||
* Arguments : none
|
||||
* Return Value : none
|
||||
******************************************************************************/
|
||||
void EnablePeripheralModules(void)
|
||||
{
|
||||
/* Module standby clear */
|
||||
SYSTEM.MSTPCRA.BIT.MSTPA15 = 0; /* CMT0 */
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function Name: ConfigurePortPins
|
||||
* Description : Configures port pins.
|
||||
* Arguments : none
|
||||
* Return Value : none
|
||||
******************************************************************************/
|
||||
void ConfigurePortPins(void)
|
||||
{
|
||||
/* Port pins default to inputs. To ensure safe initialisation set the pin states
|
||||
before changing the data direction registers. This will avoid any unintentional
|
||||
state changes on the external ports.
|
||||
Many peripheral modules will override the setting of the port registers. Ensure
|
||||
that the state is safe for external devices if the internal peripheral module is
|
||||
disabled or powered down. */
|
||||
/* Configure LED 0-4 pin settings */
|
||||
PORT1.PODR.BIT.B4 = 1;
|
||||
PORT1.PODR.BIT.B5 = 1;
|
||||
PORT1.PODR.BIT.B6 = 1;
|
||||
PORT1.PODR.BIT.B7 = 1;
|
||||
|
||||
PORT1.PDR.BIT.B4 = 1;
|
||||
PORT1.PDR.BIT.B5 = 1;
|
||||
PORT1.PDR.BIT.B6 = 1;
|
||||
PORT1.PDR.BIT.B7 = 1;
|
||||
|
||||
|
||||
|
||||
|
||||
#if INCLUDE_LCD == 1
|
||||
/* Set LCD pins as outputs */
|
||||
/* LCD-RS */
|
||||
PORTJ.PDR.BIT.B1 = 1;
|
||||
/* LCD-EN */
|
||||
PORTJ.PDR.BIT.B3 = 1;
|
||||
/*LCD-data */
|
||||
PORTH.PDR.BYTE = 0x0F;
|
||||
#endif
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function Name: io_set_cpg
|
||||
* Description : Sets up operating speed
|
||||
* Arguments : none
|
||||
* Return Value : none
|
||||
******************************************************************************/
|
||||
void io_set_cpg(void)
|
||||
{
|
||||
/* Set CPU PLL operating frequencies. Changes to the peripheral clock will require
|
||||
changes to the debugger and flash kernel BRR settings. */
|
||||
|
||||
/* ==== CPG setting ==== */
|
||||
|
||||
unsigned int i;
|
||||
|
||||
SYSTEM.PRCR.WORD = 0xA503; /* Protect off */
|
||||
|
||||
#if (CLK_SRC_HOCO == 1)
|
||||
SYSTEM.HOCOPCR.BYTE = 0x00; /* HOCO power supply on */
|
||||
SYSTEM.HOCOCR2.BYTE = 0x03; /* Select - 50MHz */
|
||||
SYSTEM.HOCOCR.BYTE = 0x01; /* HOCO is operating */
|
||||
|
||||
for(i=0; i<10; i++){ /* wait over 60us */
|
||||
}
|
||||
#else
|
||||
SYSTEM.MOSCWTCR.BYTE = 0x0C; /* Main Clock Oscillator Wait Control Register */
|
||||
/* 65536 states */
|
||||
/* wait over 2 ms @20MHz */
|
||||
|
||||
SYSTEM.PLLWTCR.BYTE = 0x0B; /* PLL Wait Control Register */
|
||||
/* 262144 states */
|
||||
/* wait over 2.1 ms @PLL = 80Hz */
|
||||
/* (20/2x8*8) */
|
||||
|
||||
SYSTEM.PLLCR.WORD = 0x0701; /* x8 @PLL */
|
||||
/* Input to PLL (EXTAL in) / 2 */
|
||||
/* Therefore:
|
||||
PLL = EXTAL / 2
|
||||
= 20M / 2
|
||||
= 10MHz
|
||||
PLL * 8 = 80Mhz */
|
||||
|
||||
SYSTEM.MOSCCR.BYTE = 0x02; /* EXTAL ON */
|
||||
/* External oscillation input selection */
|
||||
SYSTEM.PLLCR2.BYTE = 0x00; /* PLL ON */
|
||||
|
||||
for(i = 0; i<263; i++){ /* wait over 2.1ms */
|
||||
}
|
||||
#endif
|
||||
|
||||
// SYSTEM.SCKCR.LONG = 0x21823333; /* ICK=PLL/2,FCK,PCK,BCL=PLL/4 */
|
||||
/************************************************************************/
|
||||
/* If setting bits individually, rather than a single long write, */
|
||||
/* set the BCK value before that of ICK */
|
||||
/************************************************************************/
|
||||
SYSTEM.SCKCR.BIT.PCKD = 3; /* PLL/8 = 10MHz */
|
||||
SYSTEM.SCKCR.BIT.PCKC = 3; /* PLL/8 = 10MHz */
|
||||
SYSTEM.SCKCR.BIT.PCKB = 3; /* PLL/8 = 10MHz */
|
||||
SYSTEM.SCKCR.BIT.PCKA = 3; /* PLL/8 = 10MHz */
|
||||
SYSTEM.SCKCR.BIT.BCK = 3; /* PLL/8 = 10MHz */
|
||||
SYSTEM.SCKCR.BIT.PSTOP1 = 1; /* BUS CLK OUT Disabled */
|
||||
SYSTEM.SCKCR.BIT.ICK = 1; /* PLL/2 = 40MHz */
|
||||
SYSTEM.SCKCR.BIT.FCK = 2; /* PLL/4 = 20MHz */
|
||||
|
||||
while(SYSTEM.OPCCR.BIT.OPCMTSF == 1);
|
||||
SYSTEM.OPCCR.BIT.OLPCM = 0;
|
||||
while(SYSTEM.OPCCR.BIT.OPCMTSF == 1);
|
||||
#if (CLK_SRC_HOCO == 1)
|
||||
SYSTEM.SCKCR3.WORD = 0x0100; /* LOCO -> HOCO */
|
||||
#else
|
||||
SYSTEM.SCKCR3.WORD = 0x0400; /* LOCO -> PLL */
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/***********************************************************************/
|
||||
/* */
|
||||
/* FILE :intprg.c */
|
||||
/* DATE :Wed, Aug 11, 2010 */
|
||||
/* DESCRIPTION :Interrupt Program */
|
||||
/* CPU TYPE :Other */
|
||||
/* */
|
||||
/* This file is generated by Renesas Project Generator (Ver.4.50). */
|
||||
/* NOTE:THIS IS A TYPICAL EXAMPLE. */
|
||||
/* */
|
||||
/***********************************************************************/
|
||||
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Device : RX/RX200
|
||||
*
|
||||
* File Name : intprg.c
|
||||
*
|
||||
* Abstract : Interrupt Program.
|
||||
*
|
||||
* History : 1.00 (2009-08-07)
|
||||
*
|
||||
* NOTE : THIS IS A TYPICAL EXAMPLE.
|
||||
*
|
||||
* Copyright(c) 2009 Renesas Technology Corp.
|
||||
* And Renesas Solutions Corp.,All Rights Reserved.
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
#include <machine.h>
|
||||
#include "vect.h"
|
||||
#pragma section IntPRG
|
||||
|
||||
// Exception(Supervisor Instruction)
|
||||
void Excep_SuperVisorInst(void){/* brk(); */}
|
||||
|
||||
// Exception(Undefined Instruction)
|
||||
void Excep_UndefinedInst(void){/* brk(); */}
|
||||
|
||||
// Exception(Floating Point)
|
||||
void Excep_FloatingPoint(void){/* brk(); */}
|
||||
|
||||
// NMI
|
||||
void NonMaskableInterrupt(void){/* brk(); */}
|
||||
|
||||
// Dummy
|
||||
void Dummy(void){/* brk(); */}
|
||||
|
||||
// BRK
|
||||
void Excep_BRK(void){ wait(); }
|
||||
|
|
@ -0,0 +1,219 @@
|
|||
/***********************************************************************************
|
||||
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"
|
||||
|
||||
/*****************************************************************************
|
||||
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
|
||||
***********************************************************************************/
|
||||
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
|
||||
; Comment out the orginal code
|
||||
.IF 0
|
||||
|
||||
;------------------------------------------------------------------------
|
||||
; |
|
||||
; FILE :lowlvl.src |
|
||||
; DATE :Wed, Jun 16, 2010 |
|
||||
; DESCRIPTION :Program of Low level |
|
||||
; CPU TYPE :Other |
|
||||
; |
|
||||
; This file is generated by Renesas Project Generator (Ver.4.50). |
|
||||
; NOTE:THIS IS A TYPICAL EXAMPLE. |
|
||||
; |
|
||||
;------------------------------------------------------------------------
|
||||
|
||||
|
||||
.GLB _charput
|
||||
.GLB _charget
|
||||
|
||||
SIM_IO .EQU 0h
|
||||
|
||||
.SECTION P,CODE
|
||||
;-----------------------------------------------------------------------
|
||||
; _charput:
|
||||
;-----------------------------------------------------------------------
|
||||
_charput:
|
||||
MOV.L #IO_BUF,R2
|
||||
MOV.B R1,[R2]
|
||||
MOV.L #1220000h,R1
|
||||
MOV.L #PARM,R3
|
||||
MOV.L R2,[R3]
|
||||
MOV.L R3,R2
|
||||
MOV.L #SIM_IO,R3
|
||||
JSR R3
|
||||
RTS
|
||||
|
||||
;-----------------------------------------------------------------------
|
||||
; _charget:
|
||||
;-----------------------------------------------------------------------
|
||||
_charget:
|
||||
MOV.L #1210000h,R1
|
||||
MOV.L #IO_BUF,R2
|
||||
MOV.L #PARM,R3
|
||||
MOV.L R2,[R3]
|
||||
MOV.L R3,R2
|
||||
MOV.L #SIM_IO,R3
|
||||
JSR R3
|
||||
MOV.L #IO_BUF,R2
|
||||
MOVU.B [R2],R1
|
||||
RTS
|
||||
|
||||
;-----------------------------------------------------------------------
|
||||
; I/O Buffer
|
||||
;-----------------------------------------------------------------------
|
||||
.SECTION B,DATA,ALIGN=4
|
||||
PARM: .BLKL 1
|
||||
.SECTION B_1,DATA
|
||||
IO_BUF: .BLKB 1
|
||||
; .END ; Commented out for conditional assembly
|
||||
|
||||
; Code below is for debug console
|
||||
.ELSE
|
||||
|
||||
;-----------------------------------------------------------------------
|
||||
;
|
||||
; FILE :lowlvl.src
|
||||
; DATE :Wed, Jul 01, 2009
|
||||
; DESCRIPTION :Program of Low level
|
||||
; CPU TYPE :RX
|
||||
;
|
||||
;-----------------------------------------------------------------------
|
||||
.GLB _charput
|
||||
.GLB _charget
|
||||
|
||||
FC2E0 .EQU 00084080h
|
||||
FE2C0 .EQU 00084090h
|
||||
DBGSTAT .EQU 000840C0h
|
||||
RXFL0EN .EQU 00001000h
|
||||
TXFL0EN .EQU 00000100h
|
||||
|
||||
.SECTION P,CODE
|
||||
|
||||
;-----------------------------------------------------------------------
|
||||
; _charput:
|
||||
;-----------------------------------------------------------------------
|
||||
_charput:
|
||||
.STACK _charput = 00000000h
|
||||
__C2ESTART: MOV.L #TXFL0EN,R3
|
||||
MOV.L #DBGSTAT,R4
|
||||
__TXLOOP: MOV.L [R4],R5
|
||||
AND R3,R5
|
||||
BNZ __TXLOOP
|
||||
__WRITEFC2E0: MOV.L #FC2E0,R2
|
||||
MOV.L R1,[R2]
|
||||
__CHARPUTEXIT: RTS
|
||||
|
||||
;-----------------------------------------------------------------------
|
||||
; _charget:
|
||||
;-----------------------------------------------------------------------
|
||||
_charget:
|
||||
.STACK _charget = 00000000h
|
||||
__E2CSTART: MOV.L #RXFL0EN,R3
|
||||
MOV.L #DBGSTAT,R4
|
||||
__RXLOOP: MOV.L [R4],R5
|
||||
AND R3,R5
|
||||
BZ __RXLOOP
|
||||
__READFE2C0: MOV.L #FE2C0,R2
|
||||
MOV.L [R2],R1
|
||||
__CHARGETEXIT: RTS
|
||||
|
||||
;-----------------------------------------------------------------------
|
||||
|
||||
; End of conditional code
|
||||
.ENDIF
|
||||
|
||||
.END
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,329 @@
|
|||
/***********************************************************************/
|
||||
/* */
|
||||
/* FILE :lowsrc.c */
|
||||
/* DATE :Wed, Jun 16, 2010 */
|
||||
/* DESCRIPTION :Program of I/O Stream */
|
||||
/* CPU TYPE :Other */
|
||||
/* */
|
||||
/* This file is generated by Renesas Project Generator (Ver.4.50). */
|
||||
/* NOTE:THIS IS A TYPICAL EXAMPLE. */
|
||||
/* */
|
||||
/***********************************************************************/
|
||||
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Device : RX
|
||||
*
|
||||
* File Name : lowsrc.c
|
||||
*
|
||||
* Abstract : Program of I/O Stream.
|
||||
*
|
||||
* History : 1.00 (2009-08-07)
|
||||
*
|
||||
* NOTE : THIS IS A TYPICAL EXAMPLE.
|
||||
*
|
||||
* Copyright(c) 2009 Renesas Technology Corp.
|
||||
* And Renesas Solutions Corp.,All Rights Reserved.
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include "lowsrc.h"
|
||||
|
||||
/* file number */
|
||||
#define STDIN 0 /* Standard input (console) */
|
||||
#define STDOUT 1 /* Standard output (console) */
|
||||
#define STDERR 2 /* Standard error output (console) */
|
||||
|
||||
#define FLMIN 0 /* Minimum file number */
|
||||
#define _MOPENR 0x1
|
||||
#define _MOPENW 0x2
|
||||
#define _MOPENA 0x4
|
||||
#define _MTRUNC 0x8
|
||||
#define _MCREAT 0x10
|
||||
#define _MBIN 0x20
|
||||
#define _MEXCL 0x40
|
||||
#define _MALBUF 0x40
|
||||
#define _MALFIL 0x80
|
||||
#define _MEOF 0x100
|
||||
#define _MERR 0x200
|
||||
#define _MLBF 0x400
|
||||
#define _MNBF 0x800
|
||||
#define _MREAD 0x1000
|
||||
#define _MWRITE 0x2000
|
||||
#define _MBYTE 0x4000
|
||||
#define _MWIDE 0x8000
|
||||
/* File Flags */
|
||||
#define O_RDONLY 0x0001 /* Read only */
|
||||
#define O_WRONLY 0x0002 /* Write only */
|
||||
#define O_RDWR 0x0004 /* Both read and Write */
|
||||
#define O_CREAT 0x0008 /* A file is created if it is not existed */
|
||||
#define O_TRUNC 0x0010 /* The file size is changed to 0 if it is existed. */
|
||||
#define O_APPEND 0x0020 /* The position is set for next reading/writing */
|
||||
/* 0: Top of the file 1: End of file */
|
||||
|
||||
/* Special character code */
|
||||
#define CR 0x0d /* Carriage return */
|
||||
#define LF 0x0a /* Line feed */
|
||||
|
||||
#if defined( __RX )
|
||||
const long _nfiles = IOSTREAM; /* The number of files for input/output files */
|
||||
#else
|
||||
const int _nfiles = IOSTREAM; /* The number of files for input/output files */
|
||||
#endif
|
||||
char flmod[IOSTREAM]; /* The location for the mode of opened file. */
|
||||
|
||||
unsigned char sml_buf[IOSTREAM];
|
||||
|
||||
#define FPATH_STDIN "C:\\stdin"
|
||||
#define FPATH_STDOUT "C:\\stdout"
|
||||
#define FPATH_STDERR "C:\\stderr"
|
||||
|
||||
/* H8 Normal mode ,SH and RX */
|
||||
#if defined( __2000N__ ) || defined( __2600N__ ) || defined( __300HN__ ) || defined( _SH )
|
||||
/* Output one character to standard output */
|
||||
extern void charput(char);
|
||||
/* Input one character from standard input */
|
||||
extern char charget(void);
|
||||
/* Output one character to the file */
|
||||
extern char fcharput(char, unsigned char);
|
||||
/* Input one character from the file */
|
||||
extern char fcharget(char*, unsigned char);
|
||||
/* Open the file */
|
||||
extern char fileopen(char*, unsigned char, unsigned char*);
|
||||
/* Close the file */
|
||||
extern char fileclose(unsigned char);
|
||||
/* Move the file offset */
|
||||
extern char fpseek(unsigned char, long, unsigned char);
|
||||
/* Get the file offset */
|
||||
extern char fptell(unsigned char, long*);
|
||||
|
||||
/* RX */
|
||||
#elif defined( __RX )
|
||||
/* Output one character to standard output */
|
||||
extern void charput(unsigned char);
|
||||
/* Input one character from standard input */
|
||||
extern unsigned char charget(void);
|
||||
|
||||
/* H8 Advanced mode */
|
||||
#elif defined( __2000A__ ) || defined( __2600A__ ) || defined( __300HA__ ) || defined( __H8SXN__ ) || defined( __H8SXA__ ) || defined( __H8SXM__ ) || defined( __H8SXX__ )
|
||||
/* Output one character to standard output */
|
||||
extern void charput(char);
|
||||
/* Input one character from standard input */
|
||||
extern char charget(void);
|
||||
/* Output one character to the file */
|
||||
extern char fcharput(char, unsigned char);
|
||||
/* Input one character from the file */
|
||||
extern char fcharget(char*, unsigned char);
|
||||
/* Open the file */
|
||||
/* Specified as the number of register which stored paramter is 3 */
|
||||
extern char __regparam3 fileopen(char*, unsigned char, unsigned char*);
|
||||
/* Close the file */
|
||||
extern char fileclose(unsigned char);
|
||||
/* Move the file offset */
|
||||
extern char fpseek(unsigned char, long, unsigned char);
|
||||
/* Get the file offset */
|
||||
extern char fptell(unsigned char, long*);
|
||||
|
||||
/* H8300 and H8300L */
|
||||
#elif defined( __300__ ) || defined( __300L__ )
|
||||
/* Output one character to standard output */
|
||||
extern void charput(char);
|
||||
/* Input one character from standard input */
|
||||
extern char charget(void);
|
||||
/* Output one character to the file */
|
||||
extern char fcharput(char, unsigned char);
|
||||
/* Input one character from the file */
|
||||
extern char fcharget(char*, unsigned char);
|
||||
/* Open the file */
|
||||
/* Specified as the number of register which stored paramter is 3 */
|
||||
extern char __regparam3 fileopen(char*, unsigned char, unsigned char*);
|
||||
/* Close the file */
|
||||
extern char fileclose(unsigned char);
|
||||
/* Move the file offset */
|
||||
/* Move the file offset */
|
||||
extern char __regparam3 fpseek(unsigned char, long, unsigned char);
|
||||
/* Get the file offset */
|
||||
extern char fptell(unsigned char, long*);
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
FILE *_Files[IOSTREAM]; // structure for FILE
|
||||
char *env_list[] = { // Array for environment variables(**environ)
|
||||
"ENV1=temp01",
|
||||
"ENV2=temp02",
|
||||
"ENV9=end",
|
||||
'\0' // Terminal for environment variables
|
||||
};
|
||||
|
||||
char **environ = env_list;
|
||||
|
||||
/****************************************************************************/
|
||||
/* _INIT_IOLIB */
|
||||
/* Initialize C library Functions, if necessary. */
|
||||
/* Define USES_SIMIO on Assembler Option. */
|
||||
/****************************************************************************/
|
||||
void _INIT_IOLIB( void )
|
||||
{
|
||||
/* A file for standard input/output is opened or created. Each FILE */
|
||||
/* structure members are initialized by the library. Each _Buf member */
|
||||
/* in it is re-set the end of buffer pointer. */
|
||||
|
||||
/* Standard Input File */
|
||||
if( freopen( FPATH_STDIN, "r", stdin ) == NULL )
|
||||
stdin->_Mode = 0xffff; /* Not allow the access if it fails to open */
|
||||
stdin->_Mode = _MOPENR; /* Read only attribute */
|
||||
stdin->_Mode |= _MNBF; /* Non-buffering for data */
|
||||
stdin->_Bend = stdin->_Buf + 1; /* Re-set pointer to the end of buffer */
|
||||
|
||||
/* Standard Output File */
|
||||
if( freopen( FPATH_STDOUT, "w", stdout ) == NULL )
|
||||
stdout->_Mode = 0xffff; /* Not allow the access if it fails to open */
|
||||
stdout->_Mode |= _MNBF; /* Non-buffering for data */
|
||||
stdout->_Bend = stdout->_Buf + 1;/* Re-set pointer to the end of buffer */
|
||||
|
||||
/* Standard Error File */
|
||||
if( freopen( FPATH_STDERR, "w", stderr ) == NULL )
|
||||
stderr->_Mode = 0xffff; /* Not allow the access if it fails to open */
|
||||
stderr->_Mode |= _MNBF; /* Non-buffering for data */
|
||||
stderr->_Bend = stderr->_Buf + 1;/* Re-set pointer to the end of buffer */
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* _CLOSEALL */
|
||||
/****************************************************************************/
|
||||
void _CLOSEALL( void )
|
||||
{
|
||||
long i;
|
||||
|
||||
for( i=0; i < _nfiles; i++ )
|
||||
{
|
||||
/* Checks if the file is opened or not */
|
||||
if( _Files[i]->_Mode & (_MOPENR | _MOPENW | _MOPENA ) )
|
||||
fclose( _Files[i] ); /* Closes the file */
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/* open:file open */
|
||||
/* Return value:File number (Pass) */
|
||||
/* -1 (Failure) */
|
||||
/**************************************************************************/
|
||||
#if defined( __RX )
|
||||
long open(const char *name, /* File name */
|
||||
long mode, /* Open mode */
|
||||
long flg) /* Open flag */
|
||||
#else
|
||||
int open(char *name, /* File name */
|
||||
int mode, /* Open mode */
|
||||
int flg) /* Open flag */
|
||||
#endif
|
||||
{
|
||||
|
||||
|
||||
if( strcmp( name, FPATH_STDIN ) == 0 ) /* Standard Input file? */
|
||||
{
|
||||
if( ( mode & O_RDONLY ) == 0 ) return -1;
|
||||
flmod[STDIN] = mode;
|
||||
return STDIN;
|
||||
}
|
||||
else if( strcmp( name, FPATH_STDOUT ) == 0 )/* Standard Output file? */
|
||||
{
|
||||
if( ( mode & O_WRONLY ) == 0 ) return -1;
|
||||
flmod[STDOUT] = mode;
|
||||
return STDOUT;
|
||||
}
|
||||
else if(strcmp(name, FPATH_STDERR ) == 0 ) /* Standard Error file? */
|
||||
{
|
||||
if( ( mode & O_WRONLY ) == 0 ) return -1;
|
||||
flmod[STDERR] = mode;
|
||||
return STDERR;
|
||||
}
|
||||
else return -1; /*Others */
|
||||
}
|
||||
|
||||
#if defined( __RX )
|
||||
long close( long fileno )
|
||||
#else
|
||||
int close( int fileno )
|
||||
#endif
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/* write:Data write */
|
||||
/* Return value:Number of write characters (Pass) */
|
||||
/* -1 (Failure) */
|
||||
/**************************************************************************/
|
||||
#if defined( __RX )
|
||||
long write(long fileno, /* File number */
|
||||
const unsigned char *buf, /* The address of destination buffer */
|
||||
long count) /* The number of chacter to write */
|
||||
#else
|
||||
int write(int fileno, /* File number */
|
||||
char *buf, /* The address of destination buffer */
|
||||
int count) /* The number of chacter to write */
|
||||
#endif
|
||||
{
|
||||
long i; /* A variable for counter */
|
||||
unsigned char c; /* An output character */
|
||||
|
||||
/* Checking the mode of file , output each character */
|
||||
/* Checking the attribute for Write-Only, Read-Only or Read-Write */
|
||||
if(flmod[fileno]&O_WRONLY || flmod[fileno]&O_RDWR)
|
||||
{
|
||||
if( fileno == STDIN ) return -1; /* Standard Input */
|
||||
else if( (fileno == STDOUT) || (fileno == STDERR) )
|
||||
/* Standard Error/output */
|
||||
{
|
||||
for( i = count; i > 0; --i )
|
||||
{
|
||||
c = *buf++;
|
||||
charput(c);
|
||||
}
|
||||
return count; /*Return the number of written characters */
|
||||
}
|
||||
else return -1; /* Incorrect file number */
|
||||
}
|
||||
else return -1; /* An error */
|
||||
}
|
||||
|
||||
#if defined( __RX )
|
||||
long read( long fileno, unsigned char *buf, long count )
|
||||
#else
|
||||
int read( int fileno, char *buf, unsigned int count )
|
||||
#endif
|
||||
{
|
||||
long i;
|
||||
|
||||
/* Checking the file mode with the file number, each character is input and stored the buffer */
|
||||
|
||||
if((flmod[fileno]&_MOPENR) || (flmod[fileno]&O_RDWR)){
|
||||
for(i = count; i > 0; i--){
|
||||
*buf = charget();
|
||||
if(*buf==CR){ /* Replace the new line character */
|
||||
*buf = LF;
|
||||
}
|
||||
buf++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined( __RX )
|
||||
long lseek( long fileno, long offset, long base )
|
||||
#else
|
||||
long lseek( int fileno, long offset, int base )
|
||||
#endif
|
||||
{
|
||||
return -1L;
|
||||
}
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
/***********************************************************************/
|
||||
/* */
|
||||
/* FILE :resetprg.c */
|
||||
/* DATE :Wed, Aug 11, 2010 */
|
||||
/* DESCRIPTION :Reset Program */
|
||||
/* CPU TYPE :Other */
|
||||
/* */
|
||||
/* This file is generated by Renesas Project Generator (Ver.4.50). */
|
||||
/* NOTE:THIS IS A TYPICAL EXAMPLE. */
|
||||
/* */
|
||||
/***********************************************************************/
|
||||
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Device : RX/RX200
|
||||
*
|
||||
* File Name : resetprg.c
|
||||
*
|
||||
* Abstract : Reset Program.
|
||||
*
|
||||
* History : 1.00 (2009-08-07)
|
||||
*
|
||||
* NOTE : THIS IS A TYPICAL EXAMPLE.
|
||||
*
|
||||
* Copyright(c) 2009 Renesas Technology Corp.
|
||||
* And Renesas Solutions Corp.,All Rights Reserved.
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
#include <machine.h>
|
||||
#include <_h_c_lib.h>
|
||||
//#include <stddef.h> // Remove the comment when you use errno
|
||||
//#include <stdlib.h> // Remove the comment when you use rand()
|
||||
#include "typedefine.h"
|
||||
#include "stacksct.h"
|
||||
|
||||
#pragma inline_asm Change_PSW_PM_to_UserMode
|
||||
static void Change_PSW_PM_to_UserMode(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void PowerON_Reset_PC(void);
|
||||
void main(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus // Use SIM I/O
|
||||
extern "C" {
|
||||
#endif
|
||||
extern void _INIT_IOLIB(void);
|
||||
extern void _CLOSEALL(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define PSW_init 0x00010000
|
||||
#define FPSW_init 0x00000100
|
||||
|
||||
//extern void srand(_UINT); // Remove the comment when you use rand()
|
||||
//extern _SBYTE *_s1ptr; // Remove the comment when you use strtok()
|
||||
|
||||
//#ifdef __cplusplus // Use Hardware Setup
|
||||
//extern "C" {
|
||||
//#endif
|
||||
//extern void HardwareSetup(void);
|
||||
//#ifdef __cplusplus
|
||||
//}
|
||||
//#endif
|
||||
|
||||
//#ifdef __cplusplus // Remove the comment when you use global class object
|
||||
//extern "C" { // Sections C$INIT and C$END will be generated
|
||||
//#endif
|
||||
//extern void _CALL_INIT(void);
|
||||
//extern void _CALL_END(void);
|
||||
//#ifdef __cplusplus
|
||||
//}
|
||||
//#endif
|
||||
|
||||
#pragma section ResetPRG
|
||||
|
||||
#pragma entry PowerON_Reset_PC
|
||||
|
||||
void PowerON_Reset_PC(void)
|
||||
{
|
||||
set_intb((void*)__sectop("C$VECT"));
|
||||
// set_fpsw(FPSW_init);
|
||||
|
||||
_INITSCT();
|
||||
|
||||
// _INIT_IOLIB(); // Remove the comment when you use SIM I/O
|
||||
|
||||
// errno=0; // Remove the comment when you use errno
|
||||
// srand((_UINT)1); // Remove the comment when you use rand()
|
||||
// _s1ptr=NULL; // Remove the comment when you use strtok()
|
||||
|
||||
// HardwareSetup(); // Use Hardware Setup
|
||||
nop();
|
||||
|
||||
// _CALL_INIT(); // Remove the comment when you use global class object
|
||||
|
||||
set_psw(PSW_init); // Set Ubit & Ibit for PSW
|
||||
// Change_PSW_PM_to_UserMode(); // DO NOT CHANGE TO USER MODE IF USING FREERTOS!
|
||||
( void ) Change_PSW_PM_to_UserMode; // Just to avoid compiler warnings.
|
||||
|
||||
main();
|
||||
|
||||
// _CLOSEALL(); // Use SIM I/O
|
||||
|
||||
// _CALL_END(); // Remove the comment when you use global class object
|
||||
|
||||
brk();
|
||||
}
|
||||
|
||||
static void Change_PSW_PM_to_UserMode(void)
|
||||
{
|
||||
MVFC PSW,R1
|
||||
OR #00100000h,R1
|
||||
PUSH.L R1
|
||||
MVFC PC,R1
|
||||
ADD #10,R1
|
||||
PUSH.L R1
|
||||
RTE
|
||||
NOP
|
||||
NOP
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#define HEAPSIZE 0x400
|
||||
signed char *sbrk( size_t size );
|
||||
union HEAP_TYPE
|
||||
{
|
||||
signed long dummy;
|
||||
signed char heap[HEAPSIZE];
|
||||
};
|
||||
static union HEAP_TYPE heap_area;
|
||||
|
||||
/* End address allocated by sbrk */
|
||||
static signed char *brk = ( signed char * ) &heap_area;
|
||||
signed char *sbrk( size_t size )
|
||||
{
|
||||
signed char *p;
|
||||
if( brk + size > heap_area.heap + HEAPSIZE )
|
||||
{
|
||||
p = ( signed char * ) - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
p = brk;
|
||||
brk += size;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/***********************************************************************/
|
||||
/* */
|
||||
/* FILE :vecttbl.c */
|
||||
/* DATE :Wed, Aug 11, 2010 */
|
||||
/* DESCRIPTION :Initialize of Vector Table */
|
||||
/* CPU TYPE :Other */
|
||||
/* */
|
||||
/* This file is generated by Renesas Project Generator (Ver.4.50). */
|
||||
/* NOTE:THIS IS A TYPICAL EXAMPLE. */
|
||||
/* */
|
||||
/***********************************************************************/
|
||||
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*
|
||||
* Device : RX/RX200
|
||||
*
|
||||
* File Name : vecttbl.c
|
||||
*
|
||||
* Abstract : Initialize of Vector Table.
|
||||
*
|
||||
* History : 1.00 (2009-08-07)
|
||||
*
|
||||
* NOTE : THIS IS A TYPICAL EXAMPLE.
|
||||
*
|
||||
* Copyright(c) 2009 Renesas Technology Corp.
|
||||
* And Renesas Solutions Corp.,All Rights Reserved.
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
#include "vect.h"
|
||||
|
||||
#pragma section C FIXEDVECT
|
||||
|
||||
void* const Fixed_Vectors[] = {
|
||||
//;0xffffffd0 Exception(Supervisor Instruction)
|
||||
(void*) Excep_SuperVisorInst,
|
||||
//;0xffffffd4 Reserved
|
||||
Dummy,
|
||||
//;0xffffffd8 Reserved
|
||||
Dummy,
|
||||
//;0xffffffdc Exception(Undefined Instruction)
|
||||
(void*) Excep_UndefinedInst,
|
||||
//;0xffffffe0 Reserved
|
||||
Dummy,
|
||||
//;0xffffffe4 Exception(Floating Point)
|
||||
(void*) Excep_FloatingPoint,
|
||||
//;0xffffffe8 Reserved
|
||||
Dummy,
|
||||
//;0xffffffec Reserved
|
||||
Dummy,
|
||||
//;0xfffffff0 Reserved
|
||||
Dummy,
|
||||
//;0xfffffff4 Reserved
|
||||
Dummy,
|
||||
//;0xfffffff8 NMI
|
||||
(void*) NonMaskableInterrupt,
|
||||
//;0xfffffffc RESET
|
||||
//;<<VECTOR DATA START (POWER ON RESET)>>
|
||||
//;Power On Reset PC
|
||||
PowerON_Reset_PC
|
||||
//;<<VECTOR DATA END (POWER ON RESET)>>
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue