Update the Renesas provided BSP files in the RDK RX63N project.

This commit is contained in:
Richard Barry 2012-04-18 09:08:56 +00:00
parent 3bc093f562
commit aa85a68636
38 changed files with 41660 additions and 1632 deletions

View file

@ -0,0 +1,83 @@
/***********************************************************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No
* other uses are authorized. This software is owned by Renesas Electronics Corporation 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 ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES
* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO 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) 2012 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
/***********************************************************************************************************************
* File Name : dbsct.c
* Device(s) : RX
* Description : Defines the structure of the ROM and RAM areas.
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 26.10.2011 1.00 First Release
***********************************************************************************************************************/
/***********************************************************************************************************************
Includes <System Includes> , "Project Includes"
***********************************************************************************************************************/
/* Defines type structures used in this file */
#include <stdint.h>
/* Preprocessor directive */
#pragma unpack
/* Section start */
#pragma section C C$DSEC
/* MCU ROM and RAM structure definition */
extern const struct {
uint8_t *rom_s; /* Start address of the initialized data section in ROM */
uint8_t *rom_e; /* End address of the initialized data section in ROM */
uint8_t *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") }
};
/* Section start */
#pragma section C C$BSEC
/* MCU ROM and RAM structure definition */
extern const struct {
uint8_t *b_s; /* Start address of non-initialized data section */
uint8_t *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") }
};
/* Section start */
#pragma section
/* CTBL prevents excessive output of L1100 messages when linking.
Even if CTBL is deleted, the operation of the program does not change. */
uint8_t * const _CTBL[] = {
__sectop("C_1"), __sectop("C_2"), __sectop("C"),
__sectop("W_1"), __sectop("W_2"), __sectop("W")
};
/* Preprocessor directive */
#pragma packoption
/* This is to ensure compatibility with new L section in version 1.1 and up of the RXC compiler. Do not remove! */
#pragma section C L
const unsigned long deadSpace = 0xDEADDEAD;
#pragma section

View file

@ -0,0 +1,124 @@
/***********************************************************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No
* other uses are authorized. This software is owned by Renesas Electronics Corporation 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 ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES
* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO 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) 2012 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
/***********************************************************************************************************************
* File Name : flash_options.c
* Device(s) : RX63x
* Description : Some options of the RX63x are set through registers that are found in ROM. These registers and options
* are defined in the 'Option-Setting Memory' section of the HW Manual. These memory locations are defined
* below with descriptions of what is being set.
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 31.10.2011 1.00 First Release
* : 13.03.2012 1.10 USER_BOOT_ENABLE macro from r_bsp_config.h is now used to set Option-Setting Memory
* area to boot into User Boot Mode.
***********************************************************************************************************************/
/***********************************************************************************************************************
Includes <System Includes> , "Project Includes"
***********************************************************************************************************************/
/* Used for fixed-width typedefs. */
#include <stdint.h>
/* Determines whether user boot is used or not. */
#include "platform.h"
/* The UB Code A, UB Code B, and Endian select register B (MDEB) are located in the User Boot space. Immediately
following the MDEB register is the User Boot Reset Vector so it is defined below as well. These settings will only
be used when the MCU is reset in User Boot Mode. In order for the MCU to start up in User Boot Mode the following
conditions must be met:
1) UB code A is 55736572h and 426F6F74h.
2) UB code B is FFFF FF07h and 0008 C04Ch.
3) The low level is being input on the MD pin.
4) The high level is being input on the PC7 pin.
Please see the Option-Setting Memory section of your MCU's HW manual for more information. */
/* 0xFF7FFFE8 - 0xFF7FFFEF : UB Code A register
0xFF7FFFF0 - 0xFF7FFFF7 : UB Code B register
0xFF7FFFF8 - 0xFF7FFFFB : MDEB register
0xFF7FFFFC - 0xFF7FFFFF : User Boot Reset Vector */
#pragma address user_boot_settings = 0xFF7FFFE8
#if USER_BOOT_ENABLE == 1
extern void PowerON_Reset_PC(void);
/* Use this array if you are using User Boot. Make sure to fill in valid address for UB Reset Vector. */
const uint32_t user_boot_settings[6] =
{
0x55736572, //Required setting for UB Code A to get into User Boot
0x426f6f74, //Required setting for UB Code A to get into User Boot
0xffffff07, //Required setting for UB Code B to get into User Boot
0x0008c04c, //Required setting for UB Code B to get into User Boot
/* Choose endian for user application code
MDEB Register - Endian Select Register B
b31:b3 Reserved (set to 1)
b2:b0 MDE - Endian Select (0 = Big Endian, 7 = Little Endian) */
0xFFFFFFFF, //Select Little Endian for User Boot Code
(uint32_t) PowerON_Reset_PC //This is the User Boot Reset Vector. When using User Boot put in the reset address here
};
#endif
/* The Endian select register S (MDES), Option function select register 1 (OFS1), and Option function select register 0
(OFS0) are located in User ROM. */
/* 0xFFFFFF80 - 0xFFFFFF83 : MDES register
0xFFFFFF84 - 0xFFFFFF87 : Reserved space (0xFF's)
0xFFFFFF88 - 0xFFFFFF8B : OFS1 register
0xFFFFFF8C - 0xFFFFFF8F : OFS0 register */
#pragma address flash_options = 0xFFFFFF80
const uint32_t flash_options[] =
{
/* Choose endian for user application code
MDES Register - Endian Select Register S
b31:b3 Reserved (set to 1)
b2:b0 MDE - Endian Select (0 = Big Endian, 7 = Little Endian) */
0xFFFFFFFF, //Little Endian chosen for User Application
0xFFFFFFFF, //Reserved space
/* Configure whether voltage detection 0 circuit and HOCO are enabled after reset.
OFS1 - Option Function Select Register 1
b31:b9 Reserved (set to 1)
b8 HOCOEN - Enable/disable HOCO oscillation after a reset (0=enable, 1=disable)
b7:b3 Reserved (set to 1)
b2 LVDAS - Choose to enable/disable Voltage Detection 0 Circuit after a reset (0=enable, 1=disable)
b1:b0 Reserved (set to 1) */
0xFFFFFFFF, //Both are disabled.
/* Configure WDT and IWDT settings.
OFS0 - Option Function Select Register 0
b31:b29 Reserved (set to 1)
b28 WDTRSTIRQS - WDT Reset Interrupt Request - What to do on underflow (0=take interrupt, 1=reset MCU)
b27:b26 WDTRPSS - WDT Window Start Position Select - (0=25%, 1=50%, 2=75%, 3=100%,don't use)
b25:b24 WDTRPES - WDT Window End Position Select - (0=75%, 1=50%, 2=25%, 3=0%,don't use)
b23:b20 WDTCKS - WDT Clock Frequency Division Ratio - (1=/4, 4=/64, 0xF=/128, 6=/512, 7=/2048, 8=/8192)
b19:b18 WDTTOPS - WDT Timeout Period Select - (0=1024 cycles, 1=4096, 2=8192, 3=16384)
b17 WDTSTRT - WDT Start Mode Select - (0=auto-start after reset, halt after reset)
b16:b15 Reserved (set to 1)
b14 IWDTSLCSTP - IWDT Sleep Mode Count Stop Control - (0=can't stop count, 1=stop w/some low power modes)
b13 Reserved (set to 1)
b12 IWDTRSTIRQS - IWDT Reset Interrupt Request - What to do on underflow (0=take interrupt, 1=reset MCU)
b11:b10 IWDTRPSS - IWDT Window Start Position Select - (0=25%, 1=50%, 2=75%, 3=100%,don't use)
b9:b8 IWDTRPES - IWDT Window End Position Select - (0=75%, 1=50%, 2=25%, 3=0%,don't use)
b7:b4 IWDTCKS - IWDT Clock Frequency Division Ratio - (0=none, 2=/16, 3 = /32, 4=/64, 0xF=/128, 5=/256)
b3:b2 IWDTTOPS - IWDT Timeout Period Select - (0=1024 cycles, 1=4096, 2=8192, 3=16384)
b1 IWDTSTRT - IWDT Start Mode Select - (0=auto-start after reset, halt after reset)
b0 Reserved (set to 1) */
0xFFFFFFFF
};

View file

@ -0,0 +1,157 @@
/***********************************************************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No
* other uses are authorized. This software is owned by Renesas Electronics Corporation 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 ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES
* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO 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) 2012 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
/***********************************************************************************************************************
* File Name : hwsetup.c
* Device(s) : RX
* H/W Platform : RSK+RX63N
* Description : Defines the initialisation routines used each time the MCU is restarted.
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 22.11.2011 1.00 First Release
***********************************************************************************************************************/
/***********************************************************************************************************************
Includes <System Includes> , "Project Includes"
***********************************************************************************************************************/
/* I/O Register and board definitions */
#include "platform.h"
/* Contains delcarations for the functions defined in this file */
#include "hwsetup.h"
/***********************************************************************************************************************
Private global variables and functions
***********************************************************************************************************************/
/* MCU I/O port configuration function delcaration */
static void output_ports_configure(void);
/* Interrupt configuration function delcaration */
static void interrupts_configure(void);
/* MCU peripheral module configuration function declaration */
static void peripheral_modules_enable(void);
/***********************************************************************************************************************
* Function name: hardware_setup
* Description : Contains setup functions called at device restart
* Arguments : none
* Return value : none
***********************************************************************************************************************/
void hardware_setup(void)
{
output_ports_configure();
interrupts_configure();
peripheral_modules_enable();
}
/***********************************************************************************************************************
* Function name: output_ports_configure
* Description : Configures the port and pin direction settings, and sets the pin outputs to a safe level.
* Arguments : none
* Return value : none
***********************************************************************************************************************/
void output_ports_configure(void)
{
/* Enable LEDs. */
/* Start with LEDs off. */
LED0 = LED_OFF;
LED1 = LED_OFF;
LED2 = LED_OFF;
LED3 = LED_OFF;
/* Set LED pins as outputs. */
LED0_PDR = 1;
LED1_PDR = 1;
LED2_PDR = 1;
LED3_PDR = 1;
/* Enable switches. */
/* Set pins as inputs. */
SW1_PDR = 0;
SW2_PDR = 0;
SW3_PDR = 0;
/* Set port mode registers for switches. */
SW1_PMR = 0;
SW2_PMR = 0;
SW3_PMR = 0;
/* Initialize RSPI pins that are used with on-board SPI flash. */
/* Set pin outputs to low to begin with. */
PORT2.PODR.BIT.B7 = 0x00; /* RSPCKB */
PORT2.PODR.BIT.B6 = 0x00; /* MOSIB */
PORT3.PODR.BIT.B0 = 0x00; /* MISOB */
PORT3.PODR.BIT.B1 = 0x00; /* SSLB0 */
/* All GPIO for now */
PORT2.PMR.BIT.B7 = 0x00;
PORT2.PMR.BIT.B6 = 0x00;
PORT3.PMR.BIT.B0 = 0x00;
PORT3.PMR.BIT.B1 = 0x00;
/* Unlock MPC registers to enable writing to them. */
MPC.PWPR.BIT.B0WI = 0 ; /* Unlock protection register */
MPC.PWPR.BIT.PFSWE = 1 ; /* Unlock MPC registers */
/* Set MPC for RSPI pins */
MPC.P27PFS.BYTE = 0x0D;
MPC.P26PFS.BYTE = 0x0D;
MPC.P30PFS.BYTE = 0x0D;
/* RSPI pins assigned to RSPI peripheral. */
PORT2.PMR.BIT.B7 = 1;
PORT2.PMR.BIT.B6 = 1;
PORT3.PMR.BIT.B0 = 1;
PORT3.PMR.BIT.B1 = 1;
/* RSPCKB is output. */
PORT2.PDR.BIT.B7 = 1;
/* MOSIB is output. */
PORT2.PDR.BIT.B6 = 1;
/* MISOB is input. */
PORT3.PDR.BIT.B0 = 0;
/* SSLB0 is output. */
PORT3.PDR.BIT.B1 = 1;
/* Configure the pin connected to the ADC Pot as an input */
PORT4.PDR.BIT.B0 = 0;
}
/***********************************************************************************************************************
* Function name: interrupts_configure
* Description : Configures interrupts used
* Arguments : none
* Return value : none
***********************************************************************************************************************/
void interrupts_configure(void)
{
/* Add code here to setup additional interrupts */
}
/***********************************************************************************************************************
* Function name: peripheral_modules_enable
* Description : Enables and configures peripheral devices on the MCU
* Arguments : none
* Return value : none
***********************************************************************************************************************/
void peripheral_modules_enable(void)
{
/* Add code here to enable peripherals used by the application */
}

View file

@ -0,0 +1,42 @@
/***********************************************************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No
* other uses are authorized. This software is owned by Renesas Electronics Corporation 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 ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES
* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO 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) 2012 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
/***********************************************************************************************************************
* File Name : hwsetup.h
* Description : Hardware setup header file.
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 26.10.2011 1.00 First Release
***********************************************************************************************************************/
/***********************************************************************************************************************
Macro definitions
***********************************************************************************************************************/
/* Multiple inclusion prevention macro */
#ifndef HWSETUP_H
#define HWSETUP_H
/***********************************************************************************************************************
Exported global functions (to be accessed by other files)
***********************************************************************************************************************/
/* Hardware setup funtion declaration */
void hardware_setup(void);
/* End of multiple inclusion prevention macro */
#endif

View file

@ -0,0 +1,254 @@
/***********************************************************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No
* other uses are authorized. This software is owned by Renesas Electronics Corporation 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 ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES
* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO 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) 2012 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
/***********************************************************************************************************************
* File Name : lcd.c
* Device(s) : RX
* H/W Platform : RSK+RX63N
* Description : Provides variable and function declarations for lcd.c file
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 22.11.2011 1.00 First Release
***********************************************************************************************************************/
/***********************************************************************************************************************
Includes <System Includes> , "Project Includes"
***********************************************************************************************************************/
/* Processor-specific details */
#include <machine.h>
/* Standard string manipulation & formatting functions */
#include <stdio.h>
#include <string.h>
/* Defines standard variable types used in this function */
#include <stdint.h>
/* Bring in board includes. */
#include "platform.h"
/* Following header file provides function prototypes for LCD controlling functions & macro defines */
#include "lcd.h"
/***********************************************************************************************************************
Private global variables and functions
***********************************************************************************************************************/
static void lcd_delay(volatile int32_t nsecs);
static void lcd_nibble_write(uint8_t data_or_ctrl, uint8_t value);
static void lcd_write(uint8_t data_or_ctrl, uint8_t value);
/***********************************************************************************************************************
* Function name : lcd_initialize
* Description : Initializes the LCD display.
* Arguments : none
* Return Value : none
***********************************************************************************************************************/
void lcd_initialize(void)
{
/* Set LCD data pins as outputs. */
PORT8.PDR.BYTE |= 0xF0;
/* Set LCD control pins as outputs. */
RS_PIN_DDR = 1;
E_PIN_DDR = 1;
/* Power Up Delay for the LCD Module */
lcd_delay(50000000);
/* Display initialises in 8 bit mode - so send one write (seen as 8 bit) to set to 4 bit mode. */
lcd_nibble_write(CTRL_WR, 0x03);
lcd_delay(5000000);
lcd_nibble_write(CTRL_WR, 0x03);
lcd_delay(5000000);
lcd_nibble_write(CTRL_WR, 0x03);
lcd_delay(5000000);
/* Function Set */
lcd_nibble_write(CTRL_WR, 0x02);
lcd_delay(39000);
lcd_nibble_write(CTRL_WR, 0x02);
lcd_nibble_write(CTRL_WR, (LCD_DISPLAY_ON | LCD_TWO_LINE ));
lcd_delay(39000);
/* Display ON/OFF control */
lcd_write(CTRL_WR, LCD_CURSOR_OFF);
lcd_delay(39000);
/* Display Clear */
lcd_write(CTRL_WR, LCD_CLEAR);
lcd_delay(2000000);
/* Entry Mode Set */
lcd_write(CTRL_WR, 0x06);
lcd_delay(39000);
/* Home the cursor */
lcd_write(CTRL_WR, LCD_HOME_L1);
lcd_delay(5000000);
}
/***********************************************************************************************************************
* Function name : lcd_clear
* Description : Clears the LCD
* Arguments : none
* Return Value : none
***********************************************************************************************************************/
void lcd_clear(void)
{
/* Display Clear */
lcd_write(CTRL_WR, LCD_CLEAR);
lcd_delay(2000000);
}
/***********************************************************************************************************************
* Function name : lcd_display
* 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...
* lcd_display(LCD_LINE1 + 1, "Hello")
* Arguments : position -
* Line number of display
* string -
* Pointer to null terminated string
* Return Value : none
***********************************************************************************************************************/
void lcd_display(uint8_t position, uint8_t const * string)
{
/* Declare next position variable */
static uint8_t 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, ((uint8_t)(LCD_HOME_L1 + position)));
}
else
{
/* Display on Line 2 */
lcd_write(CTRL_WR, ((uint8_t)((LCD_HOME_L2 + position) - LCD_LINE2)));
}
lcd_delay(39000);
/* set position index to known value */
next_pos = position;
}
do
{
/* Write character to LCD. */
lcd_write(DATA_WR,*string++);
lcd_delay(43000);
/* Increment position index */
next_pos++;
}
while(*string);
}
/***********************************************************************************************************************
* Function name : lcd_delay
* Description : Implements LCD required delays.
* Arguments : nsecs -
* Number of nanoseconds to delay. RX600 has max clock of 100MHz which gives a cycle time of 10ns.
* This means that nothing under 100ns should be input. 100ns would be 10 cycles which is still
* being optimistic for getting in and out of this function.
* Return Value : none
***********************************************************************************************************************/
static void lcd_delay(volatile int32_t nsecs)
{
while (0 < nsecs)
{
/* Subtract off 10 cycles per iteration. This number was obtained when using the Renesas toolchain at
optimization level 2. The number to nanoseconds to subtract off below is calculated off of the ICLK speed. */
nsecs -= (int32_t)((100.0)*(100000000.0/(float)ICLK_HZ));
}
}
/***********************************************************************************************************************
* Function name : lcd_nibble_write
* Description : Writes data to display. Sends command to display.
* Arguments : value -
* The value to write
* data_or_ctrl -
* Whether to write data or control.
* 1 = DATA
* 0 = CONTROL
* Return Value : none
***********************************************************************************************************************/
static void lcd_nibble_write(uint8_t data_or_ctrl, uint8_t value)
{
/* Set Register Select pin high for Data */
if (data_or_ctrl == DATA_WR)
{
/* Data write. */
RS_PIN = 1;
}
else
{
/* Control write. */
RS_PIN = 0;
}
/* tsu1 delay */
lcd_delay(60);
/* EN enable chip (HIGH) */
E_PIN = 1;
/* Output the data */
PORT8.PODR.BYTE = (value << 4u);
/* tw delay */
lcd_delay(450);
/* Latch data by dropping E */
E_PIN = 0;
/* th2 delay */
lcd_delay(10);
/* tc delay */
lcd_delay(480);
}
/***********************************************************************************************************************
* Function name : lcd_write
* 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...
* lcd_display(LCD_LINE1 + 1, "Hello")
* Arguments : value -
* The value to write
* data_or_ctrl -
* Whether to write data or control.
* 1 = DATA
* 0 = CONTROL
* Return Value : none
***********************************************************************************************************************/
static void lcd_write(uint8_t data_or_ctrl, uint8_t value)
{
/* Write upper nibble first */
lcd_nibble_write(data_or_ctrl, (uint8_t)((value & 0xF0) >> 4));
/* Write lower nibble second */
lcd_nibble_write(data_or_ctrl, (uint8_t)(value & 0x0F));
}

View file

@ -0,0 +1,101 @@
/***********************************************************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No
* other uses are authorized. This software is owned by Renesas Electronics Corporation 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 ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES
* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO 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) 2012 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
/***********************************************************************************************************************
* File Name : lcd.h
* Device(s) : RX
* H/W Platform : RSKRX630
* Description : Provides variable and function declarations for lcd.c file
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 22.11.2011 1.00 First Release
***********************************************************************************************************************/
/* Multiple inclusion prevention macro */
#ifndef LCD_H
#define LCD_H
/***********************************************************************************************************************
Includes <System Includes> , "Project Includes"
***********************************************************************************************************************/
/* Defines standard integer variable types used in this file */
#include <stdint.h>
/***********************************************************************************************************************
Macro definitions
***********************************************************************************************************************/
/* RS register select pin */
#define RS_PIN PORTJ.PODR.BIT.B5
#define RS_PIN_DDR PORTJ.PDR.BIT.B5
/* Display enable pin */
#define E_PIN PORTF.PODR.BIT.B5
#define E_PIN_DDR PORTF.PDR.BIT.B5
/* Data write/read definition */
#define DATA_WR 1
/* Control write/read definition */
#define CTRL_WR 0
/* Maximum characters per line of LCD display. */
#define NUMB_CHARS_PER_LINE 8
/* Number of lines on the LCD display */
#define MAXIMUM_LINES 2
/* Character position of LCD line 1 */
#define LCD_LINE1 0
/* Character position of LCD line 2 */
#define LCD_LINE2 16
/* 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
/* Enable LCD display */
#define LCD_DISPLAY_ON 0x04
/* Enable both LCD lines */
#define LCD_TWO_LINE 0x08
/***********************************************************************************************************************
Exported global functions (to be accessed by other files)
***********************************************************************************************************************/
/* LCD initialisation function declaration */
void lcd_initialize (void);
/* Update display function declaration */
void lcd_display(uint8_t position, uint8_t const * string);
/* Clear LCD function delcaration */
void lcd_clear (void);
/* End of multiple inclusion prevention macro */
#endif

View file

@ -0,0 +1,118 @@
/***********************************************************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No
* other uses are authorized. This software is owned by Renesas Electronics Corporation 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 ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES
* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO 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) 2011 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
/***********************************************************************************************************************
* File Name : locking.c
* Description : This implements a locking mechanism that can be used by all code. The locking is done atomically so
* common resources can be accessed safely.
***********************************************************************************************************************/
/**********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 07.03.2012 1.00 First Release
***********************************************************************************************************************/
/***********************************************************************************************************************
Includes <System Includes> , "Project Includes"
***********************************************************************************************************************/
/* Fixed-size integer typedefs. */
#include <stdint.h>
/* bool support. */
#include <stdbool.h>
/* Has intrinsic support. Includes xchg() which is used in this code. */
#include <machine.h>
/* Includes board and MCU related header files. */
#include "platform.h"
/***********************************************************************************************************************
Macro definitions
***********************************************************************************************************************/
/***********************************************************************************************************************
Typedef definitions
***********************************************************************************************************************/
/***********************************************************************************************************************
Exported global variables (to be accessed by other files)
***********************************************************************************************************************/
/***********************************************************************************************************************
Private global variables and functions
***********************************************************************************************************************/
/***********************************************************************************************************************
* Function Name: R_BSP_Lock
* Description : Attempt to acquire the lock that has been sent in.
* Arguments : plock -
* Pointer to lock structure with lock to try and acquire.
* Return Value : true -
* Lock was acquired.
* false -
* Lock was not acquired.
***********************************************************************************************************************/
bool R_BSP_Lock(bsp_lock_t * plock)
{
bool ret = false;
/* Variable used in trying to acquire lock. Using the xchg instruction makes this atomic */
int32_t is_locked = true;
/* This example uses the RX MCU's atomic xchg() instruction. plock->lock is the lock we are trying to reserve.
The way this works is that 'is_locked' gets the value of the plock->lock and plock->lock gets the value of
'is_locked' which we just set to 'true'. Basically this is an atomic 'swap' command. If the lock had not yet been
reserved then its value would be 'false' and after the xchg() instruction finished 'is_locked' would have
'false'. If it had already been reserved then 'is_locked' would have 'true' after the xchg() instruction. Since
plock->lock was already 'true' and we just set it back to 'true' everything is ok. To see if we reserved the lock
we just need to check the value of 'is_locked' after this instruction finishes. */
/* Try to acquire semaphore to obtain lock */
xchg(&is_locked, &plock->lock);
/* Check to see if semaphore was successfully taken */
if (is_locked == false)
{
/* Lock obtained, return success. */
ret = true;
}
else
{
/* Lock was not obtained, another task already has it. */
}
return ret;
} /* End of function R_BSP_Lock() */
/***********************************************************************************************************************
* Function Name: R_BSP_Unlock
* Description : Release hold on lock.
* Arguments : plock -
* Pointer to lock structure with lock to release.
* Return Value : true -
* Lock was released.
* false -
* Lock was not released.
***********************************************************************************************************************/
bool R_BSP_Unlock(bsp_lock_t * plock)
{
/* Set lock back to unlocked. */
plock->lock = false;
return true;
} /* End of function R_BSP_Unlock() */

View file

@ -0,0 +1,63 @@
/***********************************************************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No
* other uses are authorized. This software is owned by Renesas Electronics Corporation 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 ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES
* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO 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) 2011 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
/***********************************************************************************************************************
* File Name : locking.h
* Description : This implements a locking mechanism that can be used by all code. The locking is done atomically so
* common resources can be accessed safely.
***********************************************************************************************************************/
/**********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 07.03.2012 1.00 First Release
***********************************************************************************************************************/
/***********************************************************************************************************************
Includes <System Includes> , "Project Includes"
***********************************************************************************************************************/
/* Fixed-size integer typedefs. */
#include <stdint.h>
/* bool support. */
#include <stdbool.h>
/***********************************************************************************************************************
Macro definitions
***********************************************************************************************************************/
/***********************************************************************************************************************
Typedef definitions
***********************************************************************************************************************/
typedef struct
{
/* The actual lock. int32_t is used because this is what the xchg() instruction takes as parameters. */
int32_t lock;
/* Could add a ID for locking and unlocking. In this could protect against any function being able to unlock. */
} bsp_lock_t;
/***********************************************************************************************************************
Exported global variables
***********************************************************************************************************************/
/***********************************************************************************************************************
Exported global functions (to be accessed by other files)
***********************************************************************************************************************/
bool R_BSP_Lock(bsp_lock_t * plock);
bool R_BSP_Unlock(bsp_lock_t * plock);

View file

@ -0,0 +1,54 @@
;-----------------------------------------------------------------------
;
; 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
.END

View file

@ -0,0 +1,332 @@
/***********************************************************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No
* other uses are authorized. This software is owned by Renesas Electronics Corporation 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 ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES
* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO 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) 2012 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
/***********************************************************************************************************************
* File Name : lowsrc.c
* Description : Functions to support stream I/O
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 26.10.2011 1.00 First Release
***********************************************************************************************************************/
/***********************************************************************************************************************
Includes <System Includes> , "Project Includes"
***********************************************************************************************************************/
#include <string.h>
#include <stdio.h>
#include <stddef.h>
/***********************************************************************************************************************
Macro definitions
***********************************************************************************************************************/
/*Number of I/O Stream*/
#define IOSTREAM 20
/* 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;
}

View file

@ -0,0 +1,59 @@
/***********************************************************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No
* other uses are authorized. This software is owned by Renesas Electronics Corporation 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 ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES
* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO 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) 2012 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
/***********************************************************************************************************************
* File Name : mcu_info.h
* Device(s) : RX
* H/W Platform : RSK+RX63N
* Description : Information about the MCU on this board.
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 28.11.2011 1.00 First Release
* : 13.03.2012 1.10 System clock speeds are now calculated from macros in r_bsp_config.h.
***********************************************************************************************************************/
#ifndef _MCU_INFO
#define _MCU_INFO
/* MCU that is used. */
#define MCU_RX63N (1)
/* Package. */
#define PACKAGE_LQFP176 (1)
/* Memory size of your MCU. */
#define ROM_SIZE_BYTES (1048576)
#define RAM_SIZE_BYTES (131072)
#define DF_SIZE_BYTES (32768)
/* System clock speed in Hz. */
#define ICLK_HZ (((XTAL_HZ/PLL_DIV) * PLL_MUL) / ICK_DIV)
/* Peripheral Module Clock A speed in Hz. Used for ETHERC and EDMAC. */
#define PCLKA_HZ (((XTAL_HZ/PLL_DIV) * PLL_MUL) / PCKA_DIV)
/* Peripheral Module Clock B speed in Hz. */
#define PCLKB_HZ (((XTAL_HZ/PLL_DIV) * PLL_MUL) / PCKB_DIV)
/* External bus clock speed in Hz. */
#define BCLK_HZ (((XTAL_HZ/PLL_DIV) * PLL_MUL) / BCK_DIV)
/* FlashIF clock speed in Hz. */
#define FCLK_HZ (((XTAL_HZ/PLL_DIV) * PLL_MUL) / FCK_DIV)
/* USB clock speed in Hz. */
#define UCLK_HZ (((XTAL_HZ/PLL_DIV) * PLL_MUL) / UCK_DIV)
#endif /* _MCU_INFO */

View file

@ -0,0 +1,54 @@
/***********************************************************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No
* other uses are authorized. This software is owned by Renesas Electronics Corporation 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 ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES
* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO 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) 2012 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
/***********************************************************************************************************************
* File Name : r_bsp.h
* H/W Platform : RSK+RX63N
* Description : Has the header files that should be included for this platform.
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 13.01.2012 1.00 First Release
* : 13.03.2012 1.10 Added locking.h and r_bsp_config.h #includes. Removed sbrk.h since heap size is not
* defined in r_bsp_config.h.
***********************************************************************************************************************/
#ifndef PLATFORM_BOARD_RSKRX63N
#define PLATFORM_BOARD_RSKRX63N
/* Make sure that no other platforms have already been defined. Do not touch this! */
#ifdef PLATFORM_DEFINED
#error "Error - Multiple platforms defined in platform.h!"
#else
#define PLATFORM_DEFINED
#endif
/***********************************************************************************************************************
INCLUDE APPROPRIATE MCU AND BOARD FILES
***********************************************************************************************************************/
#include "r_bsp_config.h"
#include ".\mcu\rx63n\iodefine.h"
#include ".\board\rskrx63n\rskrx63n.h"
#include ".\board\rskrx63n\mcu_info.h"
#include ".\board\rskrx63n\hwsetup.h"
#include ".\board\rskrx63n\lcd.h"
#include ".\board\rskrx63n\locking.h"
#endif /* PLATFORM_BOARD_RSKRX63N */

View file

@ -0,0 +1,409 @@
/***********************************************************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No
* other uses are authorized. This software is owned by Renesas Electronics Corporation 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 ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES
* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO 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) 2012 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
/***********************************************************************************************************************
* File Name : resetprg.c
* Device(s) : RX63x
* Description : Defines post-reset routines that are used to configure the MCU prior to the main program starting.
* This is were the program counter starts on power-up or reset.
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 26.10.2011 1.00 First Release
* : 13.03.2012 1.10 Stack sizes are now defined in r_bsp_config.h. Because of this the #include for
* stacksct.h was removed. Settings for SCKCR are now set in r_bsp_config.h and used here
* to setup clocks based on user settings.
***********************************************************************************************************************/
/***********************************************************************************************************************
Includes <System Includes> , "Project Includes"
***********************************************************************************************************************/
/* Defines machine level functions used in this file */
#include <machine.h>
/* Defines MCU configuration functions used in this file */
#include <_h_c_lib.h>
/* Defines standard variable types used in this file */
#include <stdbool.h>
#include <stdint.h>
/* This macro is here so that the stack will be declared here. This is used to prevent multiplication of stack size. */
#define BSP_DECLARE_STACK
/* Define the target platform */
#include "platform.h"
/***********************************************************************************************************************
Macro definitions
***********************************************************************************************************************/
#define PSW_init (0x00030000)
#define FPSW_init (0x00000100)
/***********************************************************************************************************************
Pre-processor Directives
***********************************************************************************************************************/
/* Declare the contents of the function 'Change_PSW_PM_to_UserMode' as
assembler to the compiler */
#pragma inline_asm Change_PSW_PM_to_UserMode
/* Set this as the entry point from a power-on reset */
#pragma entry PowerON_Reset_PC
/***********************************************************************************************************************
External function Prototypes
***********************************************************************************************************************/
/* Functions to setup I/O library */
extern void _INIT_IOLIB(void);
extern void _CLOSEALL(void);
/***********************************************************************************************************************
Private global variables and functions
***********************************************************************************************************************/
/* Power-on reset function declaration */
void PowerON_Reset_PC(void);
#if RUN_IN_USER_MODE==1
#if __RENESAS_VERSION__ < 0x01010000
/* MCU usermode switcher function declaration */
static void Change_PSW_PM_to_UserMode(void);
#endif
#endif
/* Main program function delcaration */
void main(void);
static void operating_frequency_set(void);
/***********************************************************************************************************************
* Function name: PowerON_Reset_PC
* Description : This function is the MCU's entry point from a power-on reset.
* The following steps are taken in the startup code:
* 1. The User Stack Pointer (USP) and Interrupt Stack Pointer (ISP) are both set immediately after entry
* to this function. The USP and ISP stack sizes are set in the file stacksct.h.
* Default sizes are USP=4K and ISP=1K.
* 2. The interrupt vector base register is set to point to the beginning of the relocatable interrupt
* vector table.
* 3. The MCU is setup for floating point operations by setting the initial value of the Floating Point
* Status Word (FPSW).
* 4. The MCU operating frequency is set by configuring the Clock Generation Circuit (CGC) in
* operating_frequency_set.
* 5. Calls are made to functions to setup the C runtime environment which involves initializing all
* initialed data, zeroing all uninitialized variables, and configuring STDIO if used
* (calls to _INITSCT and _INIT_IOLIB).
* 6. Board-specific hardware setup, including configuring I/O pins on the MCU, in hardware_setup.
* 7. Global interrupts are enabled by setting the I bit in the Program Status Word (PSW), and the stack
* is switched from the ISP to the USP. The initial Interrupt Priority Level is set to zero, enabling
* any interrupts with a priority greater than zero to be serviced.
* 8. The processor is optionally switched to user mode. To run in user mode, set the macro
* RUN_IN_USER_MODE above to a 1.
* 9. The bus error interrupt is enabled to catch any accesses to invalid or reserved areas of memory.
*
* Once this initialization is complete, the user's main() function is called. It should not return.
* Arguments : none
* Return value : none
***********************************************************************************************************************/
void PowerON_Reset_PC(void)
{
/* Stack pointers are setup prior to calling this function - see comments above */
/* Initialise the MCU processor word */
#if __RENESAS_VERSION__ >= 0x01010000
set_intb((void *)__sectop("C$VECT"));
#else
set_intb((unsigned long)__sectop("C$VECT"));
#endif
/* Initialize FPSW for floating-point operations */
#ifdef __ROZ
#define _ROUND 0x00000001 /* Let FPSW RMbits=01 (round to zero) */
#else
#define _ROUND 0x00000000 /* Let FPSW RMbits=00 (round to nearest) */
#endif
#ifdef __DOFF
#define _DENOM 0x00000100 /* Let FPSW DNbit=1 (denormal as zero) */
#else
#define _DENOM 0x00000000 /* Let FPSW DNbit=0 (denormal as is) */
#endif
set_fpsw(FPSW_init | _ROUND | _DENOM);
/* Switch to high-speed operation */
operating_frequency_set();
/* Initialize C runtime environment */
_INITSCT();
/* Comment this out if not using I/O lib */
_INIT_IOLIB();
/* Configure the MCU and YRDK hardware */
hardware_setup();
/* Change the MCU's usermode from supervisor to user */
nop();
set_psw(PSW_init);
#if RUN_IN_USER_MODE==1
/* Use chg_pmusr() intrinsic if possible. */
#if __RENESAS_VERSION__ >= 0x01010000
chg_pmusr() ;
#else
Change_PSW_PM_to_UserMode();
#endif
#endif
/* Enable the bus error interrupt to catch accesses to illegal/reserved areas of memory */
/* The ISR for this interrupt can be found in vecttbl.c in the function "bus_error_isr" */
/* Clear any pending interrupts */
IR(BSC,BUSERR) = 0;
/* Make this the highest priority interrupt (adjust as necessary for your application */
IPR(BSC,BUSERR) = 0x0F;
/* Enable the interrupt in the ICU*/
IEN(BSC,BUSERR) = 1;
/* Enable illegal address interrupt in the BSC */
BSC.BEREN.BIT.IGAEN = 1;
/* Call the main program function (should not return) */
main();
/* Comment this out if not using I/O lib - cleans up open files */
_CLOSEALL();
while(1)
{
/* Infinite loop. Put a breakpoint here if you want to catch an exit of main(). */
}
}
/***********************************************************************************************************************
* Function name: operating_frequency_set
* Description : Configures the clock settings for each of the device clocks
* Arguments : none
* Return value : none
***********************************************************************************************************************/
void operating_frequency_set(void)
{
/* Used for constructing value to write to SCKCR register. */
uint32_t temp_clock = 0;
/*
Clock Description Frequency
----------------------------------------
Input Clock Frequency............ 12 MHz
PLL frequency (x16).............. 192 MHz
Internal Clock Frequency......... 96 MHz
Peripheral Clock Frequency....... 48 MHz
USB Clock Frequency.............. 48 MHz
External Bus Clock Frequency..... 24 MHz */
volatile unsigned int i;
/* Protect off. */
SYSTEM.PRCR.WORD = 0xA50B;
/* Uncomment if not using sub-clock */
//SYSTEM.SOSCCR.BYTE = 0x01; /* stop sub-clock */
SYSTEM.SOSCCR.BYTE = 0x00; /* Enable sub-clock for RTC */
/* Wait 131,072 cycles * 12 MHz = 10.9 ms */
SYSTEM.MOSCWTCR.BYTE = 0x0D;
/* PLL wait is 4,194,304 cycles (default) * 192 MHz (12 MHz * 16) = 20.1 ms*/
SYSTEM.PLLWTCR.BYTE = 0x0F;
/* Set PLL Input Divisor. */
SYSTEM.PLLCR.BIT.PLIDIV = PLL_DIV >> 1;
/* Set PLL Multiplier. */
SYSTEM.PLLCR.BIT.STC = PLL_MUL - 1;
/* EXTAL ON */
SYSTEM.MOSCCR.BYTE = 0x00;
/* PLL ON */
SYSTEM.PLLCR2.BYTE = 0x00;
for(i = 0;i< 0x168;i++)
{
/* Wait over 12ms */
nop() ;
}
/* Figure out setting for FCK bits. */
#if FCK_DIV == 1
/* Do nothing since FCK bits should be 0. */
#elif FCK_DIV == 2
temp_clock |= 0x10000000;
#elif FCK_DIV == 4
temp_clock |= 0x20000000;
#elif FCK_DIV == 8
temp_clock |= 0x30000000;
#elif FCK_DIV == 16
temp_clock |= 0x40000000;
#elif FCK_DIV == 32
temp_clock |= 0x50000000;
#elif FCK_DIV == 64
temp_clock |= 0x60000000;
#else
#error "Error! Invalid setting for FCK_DIV in r_bsp_config.h"
#endif
/* Figure out setting for ICK bits. */
#if ICK_DIV == 1
/* Do nothing since ICK bits should be 0. */
#elif ICK_DIV == 2
temp_clock |= 0x01000000;
#elif ICK_DIV == 4
temp_clock |= 0x02000000;
#elif ICK_DIV == 8
temp_clock |= 0x03000000;
#elif ICK_DIV == 16
temp_clock |= 0x04000000;
#elif ICK_DIV == 32
temp_clock |= 0x05000000;
#elif ICK_DIV == 64
temp_clock |= 0x06000000;
#else
#error "Error! Invalid setting for ICK_DIV in r_bsp_config.h"
#endif
/* SDCLK Pin Output and BCLK Pin Output are disabled by default. */
temp_clock |= 0x00C00000;
/* Figure out setting for BCK bits. */
#if BCK_DIV == 1
/* Do nothing since BCK bits should be 0. */
#elif BCK_DIV == 2
temp_clock |= 0x00010000;
#elif BCK_DIV == 4
temp_clock |= 0x00020000;
#elif BCK_DIV == 8
temp_clock |= 0x00030000;
#elif BCK_DIV == 16
temp_clock |= 0x00040000;
#elif BCK_DIV == 32
temp_clock |= 0x00050000;
#elif BCK_DIV == 64
temp_clock |= 0x00060000;
#else
#error "Error! Invalid setting for BCK_DIV in r_bsp_config.h"
#endif
/* Figure out setting for PCKA bits. */
#if PCKA_DIV == 1
/* Do nothing since PCKA bits should be 0. */
#elif PCKA_DIV == 2
temp_clock |= 0x00001000;
#elif PCKA_DIV == 4
temp_clock |= 0x00002000;
#elif PCKA_DIV == 8
temp_clock |= 0x00003000;
#elif PCKA_DIV == 16
temp_clock |= 0x00004000;
#elif PCKA_DIV == 32
temp_clock |= 0x00005000;
#elif PCKA_DIV == 64
temp_clock |= 0x00006000;
#else
#error "Error! Invalid setting for PCKA_DIV in r_bsp_config.h"
#endif
/* Figure out setting for PCKB bits. */
#if PCKB_DIV == 1
/* Do nothing since PCKB bits should be 0. */
#elif PCKB_DIV == 2
temp_clock |= 0x00000100;
#elif PCKB_DIV == 4
temp_clock |= 0x00000200;
#elif PCKB_DIV == 8
temp_clock |= 0x00000300;
#elif PCKB_DIV == 16
temp_clock |= 0x00000400;
#elif PCKB_DIV == 32
temp_clock |= 0x00000500;
#elif PCKB_DIV == 64
temp_clock |= 0x00000600;
#else
#error "Error! Invalid setting for PCKB_DIV in r_bsp_config.h"
#endif
/* Bottom byte of SCKCR register must be set to 0x11 */
temp_clock |= 0x00000011;
/* Set SCKCR register. */
SYSTEM.SCKCR.LONG = temp_clock;
/* Re-init temp_clock to use to set SCKCR2. */
temp_clock = 0;
/* Figure out setting for IEBCK bits. */
#if IEBCK_DIV == 2
temp_clock |= 0x00000001;
#elif IEBCK_DIV == 4
temp_clock |= 0x00000002;
#elif IEBCK_DIV == 6
temp_clock |= 0x0000000C;
#elif IEBCK_DIV == 8
temp_clock |= 0x00000003;
#elif IEBCK_DIV == 16
temp_clock |= 0x00000004;
#elif IEBCK_DIV == 32
temp_clock |= 0x00000005;
#elif IEBCK_DIV == 64
temp_clock |= 0x00000006;
#else
#error "Error! Invalid setting for IEBCK_DIV in r_bsp_config.h"
#endif
/* Figure out setting for UCK bits. */
#if UCK_DIV == 3
temp_clock |= 0x00000020;
#elif UCK_DIV == 4
temp_clock |= 0x00000030;
#else
#error "Error! Invalid setting for UCK_DIV in r_bsp_config.h"
#endif
/* Set SCKCR2 register. */
SYSTEM.SCKCR2.WORD = (uint16_t)temp_clock;
/* Choose clock source. Default for r_bsp_config.h is PLL. */
SYSTEM.SCKCR3.WORD = ((uint16_t)CLOCK_SOURCE) << 8;
/* Protect on. */
SYSTEM.PRCR.WORD = 0xA500;
}
/***********************************************************************************************************************
* Function name: Change_PSW_PM_to_UserMode
* Description : Assembler function, used to change the MCU's usermode from supervisor to user.
* Arguments : none
* Return value : none
***********************************************************************************************************************/
#if RUN_IN_USER_MODE==1
#if __RENESAS_VERSION__ < 0x01010000
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
}
#endif
#endif

View file

@ -0,0 +1,65 @@
/***********************************************************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No
* other uses are authorized. This software is owned by Renesas Electronics Corporation 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 ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES
* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO 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) 2012 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
/***********************************************************************************************************************
* File Name : rskrx63n.h
* H/W Platform : RSK+RX63N
* Description : Board specific definitions for the RSKRX630.
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 28.11.2011 1.00 First Release
***********************************************************************************************************************/
#ifndef RSKRX63N_H
#define RSKRX63N_H
/* Local defines */
#define LED_ON (0)
#define LED_OFF (1)
#define SET_BIT_HIGH (1)
#define SET_BIT_LOW (0)
#define SET_BYTE_HIGH (0xFF)
#define SET_BYTE_LOW (0x00)
/* Switches */
#define SW_ACTIVE 0
#define SW1 PORT3.PIDR.BIT.B2
#define SW2 PORT0.PIDR.BIT.B0
#define SW3 PORT0.PIDR.BIT.B7
#define SW1_PDR PORT3.PDR.BIT.B2
#define SW2_PDR PORT0.PDR.BIT.B0
#define SW3_PDR PORT0.PDR.BIT.B7
#define SW1_PMR PORT3.PMR.BIT.B2
#define SW2_PMR PORT0.PMR.BIT.B0
#define SW3_PMR PORT0.PMR.BIT.B7
/* LEDs */
#define LED0 PORT0.PODR.BIT.B3
#define LED1 PORT0.PODR.BIT.B5
#define LED2 PORT1.PODR.BIT.B0
#define LED3 PORT1.PODR.BIT.B1
#define LED0_PDR PORT0.PDR.BIT.B3
#define LED1_PDR PORT0.PDR.BIT.B5
#define LED2_PDR PORT1.PDR.BIT.B0
#define LED3_PDR PORT1.PDR.BIT.B1
/* Slave select. */
#define FLASH_CS PORT3.PDR.BIT.B1 // SSLB0
#endif /* RSKRX63N_H */

View file

@ -0,0 +1,96 @@
/***********************************************************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No
* other uses are authorized. This software is owned by Renesas Electronics Corporation 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 ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES
* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO 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) 2012 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
/***********************************************************************************************************************
* File Name : sbrk.c
* Device(s) : RX
* Description : Configures the MCU heap memory. The size of the heap is defined by the macro HEAPSIZE below.
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 26.10.2011 1.00 First Release
* : 12.03.2012 1.10 Heap size is now defined in r_bsp_config.h, not sbrk.h.
***********************************************************************************************************************/
/***********************************************************************************************************************
Includes <System Includes> , "Project Includes"
***********************************************************************************************************************/
/* Provides standard definitions used in this file */
#include <stddef.h>
/* Defines standard input/output functions used in this file */
#include <stdio.h>
/* Defines standard variable types used in this file */
#include <stdint.h>
/* Used for getting HEAP_BYTES macro. */
#include "platform.h"
/***********************************************************************************************************************
Macro definitions
***********************************************************************************************************************/
/***********************************************************************************************************************
Function Prototypes
***********************************************************************************************************************/
/* Memory allocation function prototype declaration */
int8_t *sbrk(size_t size);
/***********************************************************************************************************************
Global Variables
***********************************************************************************************************************/
//const size_t _sbrk_size= /* Specifies the minimum unit of */
/* the defined heap area */
extern int8_t *_s1ptr;
union HEAP_TYPE
{
int32_t dummy; /* Dummy for 4-byte boundary */
int8_t heap[HEAP_BYTES]; /* Declaration of the area managed by sbrk*/
};
/* Declare memory heap area */
static union HEAP_TYPE heap_area;
/* End address allocated by sbrk */
static int8_t *brk=(int8_t *)&heap_area;
/***********************************************************************************************************************
* Function name: sbrk
* Description : This function configures MCU memory area allocation.
* Arguments : size -
* assigned area size
* Return value : Start address of allocated area (pass)
* -1 (failure)
***********************************************************************************************************************/
int8_t *sbrk(size_t size)
{
int8_t *p;
if (brk+size > heap_area.heap+HEAP_BYTES)
{
/* Empty area size */
p = (int8_t *)-1;
}
else
{
/* Area assignment */
p = brk;
/* End address update */
brk += size;
}
/* Return result */
return p;
}

View file

@ -0,0 +1,186 @@
/***********************************************************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No
* other uses are authorized. This software is owned by Renesas Electronics Corporation 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 ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES
* SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO 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) 2012 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
/***********************************************************************************************************************
* File Name : vecttbl.c
* Device(s) : RX
* Description : Definition of the fixed vector table
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 26.10.2011 1.00 First Release
* : 17.02.2012 1.10 Made function names compliant with CS v4.0
* : 13.03.2012 1.20 ID Code is now specified in r_bsp_config.h. It is still used here in Fixed_Vectors[].
***********************************************************************************************************************/
/***********************************************************************************************************************
Includes <System Includes> , "Project Includes"
***********************************************************************************************************************/
#include <stdint.h>
#include <machine.h>
#include "platform.h"
/***********************************************************************************************************************
* Function name: PowerON_Reset_PC
* Description : The reset vector points to this function. Code execution starts in this function after reset.
* Arguments : none
* Return value : none
***********************************************************************************************************************/
extern void PowerON_Reset_PC(void);
/***********************************************************************************************************************
* Function name: excep_supervisor_inst_isr
* Description : Supervisor Instruction Violation ISR
* Arguments : none
* Return Value : none
***********************************************************************************************************************/
#pragma interrupt (excep_supervisor_inst_isr)
void excep_supervisor_inst_isr(void)
{
/* Add your own code here to handle this exception */
nop();
}
/***********************************************************************************************************************
* Function name: excep_undefined_inst_isr
* Description : Undefined instruction exception ISR
* Arguments : none
* Return Value : none
***********************************************************************************************************************/
#pragma interrupt (excep_undefined_inst_isr)
void excep_undefined_inst_isr(void)
{
/* Add your own code here to handle this exception */
nop();
}
/***********************************************************************************************************************
* Function name: excep_floating_point_isr
* Description : Floating point exception ISR
* Arguments : none
* Return Value : none
***********************************************************************************************************************/
#pragma interrupt (excep_floating_point_isr)
void excep_floating_point_isr(void)
{
/* Add your own code here to handle this exception */
nop();
}
/***********************************************************************************************************************
* Function name: non_maskable_isr
* Description : Non-maskable interrupt ISR
* Arguments : none
* Return Value : none
***********************************************************************************************************************/
#pragma interrupt (non_maskable_isr)
void non_maskable_isr(void)
{
/* Add your own code here to handle this exception */
nop();
}
/***********************************************************************************************************************
* Function name: undefined_interrupt_source_isr
* Description : All undefined interrupt vectors point to this function.
* Set a breakpoint in this function to determine which source is creating unwanted interrupts.
* Arguments : none
* Return Value : none
***********************************************************************************************************************/
#pragma interrupt (undefined_interrupt_source_isr)
void undefined_interrupt_source_isr(void)
{
/* Add your own code here to handle this exception */
nop();
}
/***********************************************************************************************************************
* Function name: bus_error_isr
* Description : By default, this demo code enables the Bus Error Interrupt. This interrupt will fire if the user tries
* to access code or data from one of the reserved areas in the memory map, including the areas covered
* by disabled chip selects. A nop() statement is included here as a convenient place to set a breakpoint
* during debugging and development, and further handling should be added by the user for their
* application.
* Arguments : none
* Return value : none
***********************************************************************************************************************/
#pragma interrupt (bus_error_isr(vect=VECT(BSC,BUSERR)))
void bus_error_isr (void)
{
/*
To find the address that was accessed when the bus error occured, read the register BSC.BERSR2.WORD. The upper
13 bits of this register contain the upper 13-bits of the offending address (in 512K byte units)
*/
/* Add your own code here to handle this interrupt */
nop();
}
/***********************************************************************************************************************
* The following array fills in the fixed vector table and the code
* protecction ID bytes.
***********************************************************************************************************************/
#pragma section C FIXEDVECT
void* const Fixed_Vectors[] = {
/* 0xffffff90 through 0xffffff9f: Reserved area - must be all 0xFF */
(void *)0xFFFFFFFF, /* 0xffffff90 - Reserved */
(void *)0xFFFFFFFF, /* 0xffffff94 - Reserved */
(void *)0xFFFFFFFF, /* 0xffffff98 - Reserved */
/* The 32-bit area immediately below (0xffffff9c through 0xffffff9f) is a special area that allows the ROM to be
protected from reading or writing by a parallel programmer. Please refer to the HW manual for appropriate settings.
The default (all 0xff) places no restrictions and therefore allows reads and writes by a parallel programmer. */
(void *)0xFFFFFFFF, /* 0xffffff9C - ROM Code Protection */
/* The memory are immediately below (0xffffffa0 through 0xffffffaf) is a special area that allows the on-chip firmware
to be protected. See the section "ID Code Protection" in the HW manual for details on how to enable protection.
Setting the four long words below to non-0xFF values will enable protection. Do this only after carefully review
the HW manual */
/* 0xffffffA0 through 0xffffffaf: ID Code Protection. The ID code is specified using macros in r_bsp_config.h. */
(void *) ID_CODE_LONG_1, /* 0xffffffA0 - Control code and ID code */
(void *) ID_CODE_LONG_2, /* 0xffffffA4 - ID code (cont.) */
(void *) ID_CODE_LONG_3, /* 0xffffffA8 - ID code (cont.) */
(void *) ID_CODE_LONG_4, /* 0xffffffAC - ID code (cont.) */
/* 0xffffffB0 through 0xffffffcf: Reserved area */
(void *) 0xFFFFFFFF, /* 0xffffffB0 - Reserved */
(void *) 0xFFFFFFFF, /* 0xffffffB4 - Reserved */
(void *) 0xFFFFFFFF, /* 0xffffffB8 - Reserved */
(void *) 0xFFFFFFFF, /* 0xffffffBC - Reserved */
(void *) 0xFFFFFFFF, /* 0xffffffC0 - Reserved */
(void *) 0xFFFFFFFF, /* 0xffffffC4 - Reserved */
(void *) 0xFFFFFFFF, /* 0xffffffC8 - Reserved */
(void *) 0xFFFFFFFF, /* 0xffffffCC - Reserved */
/* Fixed vector table */
(void *) excep_supervisor_inst_isr, /* 0xffffffd0 Exception(Supervisor Instruction) */
(void *) undefined_interrupt_source_isr, /* 0xffffffd4 Reserved */
(void *) undefined_interrupt_source_isr, /* 0xffffffd8 Reserved */
(void *) excep_undefined_inst_isr, /* 0xffffffdc Exception(Undefined Instruction) */
(void *) undefined_interrupt_source_isr, /* 0xffffffe0 Reserved */
(void *) excep_floating_point_isr, /* 0xffffffe4 Exception(Floating Point) */
(void *) undefined_interrupt_source_isr, /* 0xffffffe8 Reserved */
(void *) undefined_interrupt_source_isr, /* 0xffffffec Reserved */
(void *) undefined_interrupt_source_isr, /* 0xfffffff0 Reserved */
(void *) undefined_interrupt_source_isr, /* 0xfffffff4 Reserved */
(void *) non_maskable_isr, /* 0xfffffff8 NMI */
(void *) PowerON_Reset_PC /* 0xfffffffc RESET */
};