+++ /dev/null
-/***********************************************************************/\r
-/* */\r
-/* FILE :dbsct.c */\r
-/* DATE :Wed, Aug 11, 2010 */\r
-/* DESCRIPTION :Setting of B,R Section */\r
-/* CPU TYPE :Other */\r
-/* */\r
-/* This file is generated by Renesas Project Generator (Ver.4.50). */\r
-/* NOTE:THIS IS A TYPICAL EXAMPLE. */\r
-/* */\r
-/***********************************************************************/\r
- \r
-\r
-/*********************************************************************\r
-*\r
-* Device : RX\r
-*\r
-* File Name : dbsct.c\r
-*\r
-* Abstract : Setting of B,R Section.\r
-*\r
-* History : 1.00 (2009-08-07)\r
-*\r
-* NOTE : THIS IS A TYPICAL EXAMPLE.\r
-*\r
-* Copyright(c) 2009 Renesas Technology Corp.\r
-* And Renesas Solutions Corp.,All Rights Reserved. \r
-*\r
-*********************************************************************/\r
-\r
-#include "typedefine.h"\r
-\r
-#pragma unpack\r
-\r
-#pragma section C C$DSEC\r
-extern const struct {\r
- _UBYTE *rom_s; /* Start address of the initialized data section in ROM */\r
- _UBYTE *rom_e; /* End address of the initialized data section in ROM */\r
- _UBYTE *ram_s; /* Start address of the initialized data section in RAM */\r
-} _DTBL[] = {\r
- { __sectop("D"), __secend("D"), __sectop("R") },\r
- { __sectop("D_2"), __secend("D_2"), __sectop("R_2") },\r
- { __sectop("D_1"), __secend("D_1"), __sectop("R_1") }\r
-};\r
-#pragma section C C$BSEC\r
-extern const struct {\r
- _UBYTE *b_s; /* Start address of non-initialized data section */\r
- _UBYTE *b_e; /* End address of non-initialized data section */\r
-} _BTBL[] = {\r
- { __sectop("B"), __secend("B") },\r
- { __sectop("B_2"), __secend("B_2") },\r
- { __sectop("B_1"), __secend("B_1") }\r
-};\r
-\r
-#pragma section\r
-\r
-/*\r
-** CTBL prevents excessive output of L1100 messages when linking.\r
-** Even if CTBL is deleted, the operation of the program does not change.\r
-*/\r
-_UBYTE * const _CTBL[] = {\r
- __sectop("C_1"), __sectop("C_2"), __sectop("C"),\r
- __sectop("W_1"), __sectop("W_2"), __sectop("W")\r
-};\r
-\r
-#pragma packoption\r
+++ /dev/null
-/******************************************************************************\r
-* DISCLAIMER\r
-\r
-* This software is supplied by Renesas Technology Corp. and is only \r
-* intended for use with Renesas products. No other uses are authorized.\r
-\r
-* This software is owned by Renesas Technology Corp. and is protected under \r
-* all applicable laws, including copyright laws.\r
-\r
-* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES\r
-* REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, \r
-* INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A \r
-* PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY \r
-* DISCLAIMED.\r
-\r
-* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS \r
-* TECHNOLOGY CORP. NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE \r
-* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES \r
-* FOR ANY REASON RELATED TO THE THIS SOFTWARE, EVEN IF RENESAS OR ITS \r
-* AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\r
-\r
-* Renesas reserves the right, without notice, to make changes to this \r
-* software and to discontinue the availability of this software. \r
-* By using this software, you agree to the additional terms and \r
-* conditions found by accessing the following link:\r
-* http://www.renesas.com/disclaimer\r
-******************************************************************************\r
-* Copyright (C) 2008. Renesas Technology Corp., All Rights Reserved.\r
-******************************************************************************* \r
-* File Name : hwsetup.c\r
-* Version : 1.00\r
-* Description : Power up hardware initializations\r
-******************************************************************************\r
-* History : DD.MM.YYYY Version Description\r
-* : 15.02.2010 1.00 First Release\r
-******************************************************************************/\r
-\r
-\r
-/******************************************************************************\r
-Includes <System Includes> , "Project Includes"\r
-******************************************************************************/\r
-#include <stdint.h>\r
-#include "iodefine.h"\r
-#include "r_ether.h"\r
-#include "rskrx63ndef.h"\r
-\r
-/******************************************************************************\r
-Typedef definitions\r
-******************************************************************************/\r
-\r
-/******************************************************************************\r
-Macro definitions\r
-******************************************************************************/\r
-\r
-/******************************************************************************\r
-Imported global variables and functions (from other files)\r
-******************************************************************************/\r
-\r
-/******************************************************************************\r
-Exported global variables and functions (to be accessed by other files)\r
-******************************************************************************/\r
-\r
-/******************************************************************************\r
-Private global variables and functions\r
-******************************************************************************/\r
-void io_set_cpg(void);\r
-void ConfigurePortPins(void);\r
-void EnablePeripheralModules(void);\r
-\r
-/******************************************************************************\r
-* Function Name: HardwareSetup\r
-* Description : This function does initial setting for CPG port pins used in\r
-* : the Demo including the MII pins of the Ethernet PHY connection.\r
-* Arguments : none\r
-* Return Value : none\r
-******************************************************************************/\r
-void HardwareSetup(void)\r
-{\r
- /* CPG setting */\r
- io_set_cpg();\r
-\r
- /* Setup the port pins */\r
- ConfigurePortPins();\r
-\r
- /* Enables peripherals */\r
- EnablePeripheralModules();\r
-\r
-#if INCLUDE_LCD == 1\r
- /* Initialize display */\r
- InitialiseDisplay();\r
-#endif\r
-}\r
-\r
-/******************************************************************************\r
-* Function Name: EnablePeripheralModules\r
-* Description : Enables Peripheral Modules before use\r
-* Arguments : none\r
-* Return Value : none\r
-******************************************************************************/\r
-void EnablePeripheralModules(void)\r
-{\r
- /* Module standby clear */\r
- SYSTEM.MSTPCRB.BIT.MSTPB15 = 0; /* EtherC, EDMAC */\r
- SYSTEM.MSTPCRA.BIT.MSTPA15 = 0; /* CMT0 */\r
-}\r
-\r
-/******************************************************************************\r
-* Function Name: ConfigurePortPins\r
-* Description : Configures port pins.\r
-* Arguments : none\r
-* Return Value : none\r
-******************************************************************************/\r
-void ConfigurePortPins(void)\r
-{\r
-/* Port pins default to inputs. To ensure safe initialisation set the pin states\r
-before changing the data direction registers. This will avoid any unintentional\r
-state changes on the external ports.\r
-Many peripheral modules will override the setting of the port registers. Ensure\r
-that the state is safe for external devices if the internal peripheral module is\r
-disabled or powered down. */\r
-#if(0) /* NOTE: ETHERNET PORT IS NOT YET CONFIGURED FOR THE RX63N. */\r
- /* ==== MII/RMII Pins setting ==== */\r
- /*--------------------------------------*/\r
- /* Port Function Control Register */\r
- /*--------------------------------------*/\r
-#if ETH_MODE_SEL == ETH_MII_MODE\r
- /* EE=1, PHYMODE=1, ENETE3=1, ENETE2=0, ENETE1=1, ENETE0=0 (Ethernet) */\r
- IOPORT.PFENET.BYTE = 0x9A;\r
-#endif /* ETH_MODE_SEL */\r
-#if ETH_MODE_SEL == ETH_RMII_MODE\r
- /* EE=1, PHYMODE=0, ENETE3=0, ENETE2=0, ENETE1=1, ENETE0=0 (Ethernet) */\r
- IOPORT.PFENET.BYTE = 0x82;\r
-#endif /* ETH_MODE_SEL */\r
- /*-------------------------------------------*/\r
- /* Input Buffer Control Register (ICR) */\r
- /*-------------------------------------------*/\r
-#if ETH_MODE_SEL == ETH_MII_MODE\r
- /* P54=1 Set ET_LINKSTA input */\r
- PORT5.ICR.BIT.B4 = 1;\r
- /* P71=1 Set ET_MDIO input */\r
- PORT7.ICR.BIT.B1 = 1;\r
- /* P74=1 Set ET_ERXD1 input */\r
- PORT7.ICR.BIT.B4 = 1;\r
- /* P75=1 Set ET_ERXD0 input */\r
- PORT7.ICR.BIT.B5 = 1;\r
- /* P76=1 Set ET_RX_CLK input */\r
- PORT7.ICR.BIT.B6 = 1;\r
- /* P77=1 Set ET_RX_ER input */\r
- PORT7.ICR.BIT.B7 = 1;\r
- /* P83=1 Set ET_CRS input */\r
- PORT8.ICR.BIT.B3 = 1;\r
- /* PC0=1 Set ET_ERXD3 input */\r
- PORTC.ICR.BIT.B0 = 1;\r
- /* PC1=1 Set ET_ERXD2 input */\r
- PORTC.ICR.BIT.B1 = 1;\r
- /* PC2=1 Set ET_RX_DV input */\r
- PORTC.ICR.BIT.B2 = 1;\r
- /* PC4=1 Set EX_TX_CLK input */\r
- PORTC.ICR.BIT.B4 = 1;\r
- /* PC7=1 Set ET_COL input */\r
- PORTC.ICR.BIT.B7 = 1;\r
-#endif /* ETH_MODE_SEL */\r
-#if ETH_MODE_SEL == ETH_RMII_MODE\r
- /* P54=1 Set ET_LINKSTA input */\r
- PORT5.ICR.BIT.B4 = 1;\r
- /* P71=1 Set ET_MDIO input */\r
- PORT7.ICR.BIT.B1 = 1;\r
- /* P74=1 Set RMII_RXD1 input */\r
- PORT7.ICR.BIT.B4 = 1;\r
- /* P75=1 Set RMII_RXD0 input */\r
- PORT7.ICR.BIT.B5 = 1;\r
- /* P76=1 Set REF50CLK input */\r
- PORT7.ICR.BIT.B6 = 1;\r
- /* P77=1 Set RMII_RX_ER input */\r
- PORT7.ICR.BIT.B7 = 1;\r
- /* P83=1 Set RMII_CRS_DV input */\r
- PORT8.ICR.BIT.B3 = 1;\r
-#endif /* ETH_MODE_SEL */\r
-#endif /* 0 */\r
- /* Configure LED 0-4 pin settings */\r
- PORT1.PODR.BIT.B4 = 1; \r
- PORT1.PODR.BIT.B5 = 1;\r
- PORT1.PODR.BIT.B6 = 1;\r
- PORT1.PODR.BIT.B7 = 1;\r
-\r
- PORT1.PDR.BIT.B4 = 1; \r
- PORT1.PDR.BIT.B5 = 1;\r
- PORT1.PDR.BIT.B6 = 1;\r
- PORT1.PDR.BIT.B7 = 1;\r
-\r
- \r
-\r
-\r
-#if INCLUDE_LCD == 1\r
- /* Set LCD pins as outputs */\r
- /* LCD-RS */\r
- PORTJ.PDR.BIT.B1 = 1;\r
- /* LCD-EN */\r
- PORTJ.PDR.BIT.B3 = 1;\r
- /*LCD-data */\r
- PORTH.PDR.BYTE = 0x0F;\r
-#endif\r
-}\r
-\r
-/******************************************************************************\r
-* Function Name: io_set_cpg\r
-* Description : Sets up operating speed\r
-* Arguments : none\r
-* Return Value : none\r
-******************************************************************************/\r
-void io_set_cpg(void)\r
-{\r
-unsigned long i;\r
- \r
- SYSTEM.PRCR.WORD = 0xA503; /* Access registers via PRCR */\r
-\r
- SYSTEM.SOSCCR.BYTE = 0x00; /* Sub-clock oscillator ON */\r
- \r
- SYSTEM.HOCOPCR.BYTE = 0x00; /* HOCO ON */\r
- \r
- SYSTEM.MOSCWTCR.BYTE = 0x0e; /* Main Clock Oscillator Wait Control Register */\r
- /* 262144 states */\r
-\r
- SYSTEM.PLLWTCR.BYTE = 0x0e; /* PLL Wait Control Register */\r
- /* 2097152 states */\r
- \r
- SYSTEM.MOSCCR.BYTE = 0x00; /* EXTAL ON */\r
-\r
- SYSTEM.PLLCR2.BYTE = 0x01; /* PLL OFF */\r
- SYSTEM.PLLCR.WORD = 0x0f00; /* x16 @PLL */\r
- /* Input to PLL = EXTAL */\r
- /* Therefore: */\r
- /* PLL = EXTAL */\r
- /* = 12 */\r
- /* PLL * 16 = 192MHz */ \r
-\r
- /* External oscillation input selection */\r
- SYSTEM.PLLCR2.BYTE = 0x00; /* PLL ON */\r
- \r
- for(i = 0; i<2500; i++) /* Wait for stabilisation of PLL and main clock */\r
- { /* = 20ms */\r
- /* (2500 x 1/125kHz = 20ms) */\r
- \r
- }\r
- \r
-/************************************************************************/\r
-/* */\r
-/* SYSTEM.SCKCR.BIT.PCKB = 2; ( b11: b8 ) PLL/4 = 48MHz */\r
-/* SYSTEM.SCKCR.BIT.PCKA = 2; ( b15:b12 ) PLL/4 = 48MHz */ \r
-/* SYSTEM.SCKCR.BIT.BCK = 2; ( b16:b19 ) PLL/4 = 48MHz */\r
-/* SYSTEM.SCKCR.BIT.PSTOP0 = 1; ( b22 ) SDCLK CLK OUT Disabled */\r
-/* SYSTEM.SCKCR.BIT.PSTOP1 = 1; ( b23 ) BUS CLK OUT Disabled */\r
-/* SYSTEM.SCKCR.BIT.ICK = 1; ( b24:b27 ) PLL/2 = 96MHz */\r
-/* SYSTEM.SCKCR.BIT.FCK = 2; ( b31:b28 ) PLL/3 = 48MHz */\r
-/* */\r
-/* SYSTEM.SCKCR2.BIT.UCK = 2; PLL/4 = 48MHz */\r
-/* SYSTEM.SCKCR2.BIT.IEBCK = 3; PLL/4 = 48MHz */\r
-/************************************************************************/\r
- \r
- SYSTEM.SCKCR.LONG = 0x21c22222; /* set these bits to the same a this bit */\r
-/* ||| | | */\r
-/* |++---------------+ | */\r
-/* | | */\r
-/* +-------------------------------------+ */\r
- \r
- SYSTEM.SCKCR2.WORD = 0x0033; \r
-\r
-\r
-// SYSTEM.SCKCR3.WORD = 0x0000; /* LOCO -> LOCO */\r
-// SYSTEM.SCKCR3.WORD = 0x0100; /* LOCO -> HOCO */\r
-// SYSTEM.SCKCR3.WORD = 0x0200; /* LOCO -> MAIN */\r
-// SYSTEM.SCKCR3.WORD = 0x0300; /* LOCO -> Sub-Clock */\r
- SYSTEM.SCKCR3.WORD = 0x0400; /* LOCO -> PLL */\r
-\r
-#if 1\r
- // Configure LED - I/O pins as Outputs\r
- // First set the Data Levels\r
- LED0 = 1; // LED0 : OFF =1, ON = 0\r
- LED1 = 1; // LED1 : OFF =1, ON = 0\r
- LED2 = 1; // LED2 : OFF =1, ON = 0\r
- LED3 = 1; // LED3 : OFF =1, ON = 0\r
-\r
- // Set Port Direction Registers\r
- LED0_PDR = 1; // LED0 : 1 = output\r
- LED1_PDR = 1; // LED1 : 1 = output\r
- LED2_PDR = 1; // LED2 : 1 = output\r
- LED3_PDR = 1; // LED3 : 1 = output\r
-#endif\r
- /* Gain access to the Port Function Select Registers */\r
- MPC.PWPR.BIT.B0WI = 0;\r
- MPC.PWPR.BIT.PFSWE = 1;\r
-}\r
-\r
+++ /dev/null
-/***********************************************************************/\r
-/* */\r
-/* FILE :intprg.c */\r
-/* DATE :Wed, Aug 11, 2010 */\r
-/* DESCRIPTION :Interrupt Program */\r
-/* CPU TYPE :Other */\r
-/* */\r
-/* This file is generated by Renesas Project Generator (Ver.4.50). */\r
-/* NOTE:THIS IS A TYPICAL EXAMPLE. */\r
-/* */\r
-/***********************************************************************/\r
- \r
-\r
-\r
-/*********************************************************************\r
-*\r
-* Device : RX/RX600\r
-*\r
-* File Name : intprg.c\r
-*\r
-* Abstract : Interrupt Program.\r
-*\r
-* History : 1.00 (2009-08-07)\r
-*\r
-* NOTE : THIS IS A TYPICAL EXAMPLE.\r
-*\r
-* Copyright(c) 2009 Renesas Technology Corp.\r
-* And Renesas Solutions Corp.,All Rights Reserved. \r
-*\r
-*********************************************************************/\r
-\r
-#include <machine.h>\r
-#include "vect.h"\r
-#pragma section IntPRG\r
-\r
-// Exception(Supervisor Instruction)\r
-void Excep_SuperVisorInst(void){/* brk(); */}\r
-\r
-// Exception(Undefined Instruction)\r
-void Excep_UndefinedInst(void){/* brk(); */}\r
-\r
-// Exception(Floating Point)\r
-void Excep_FloatingPoint(void){/* brk(); */}\r
-\r
-// NMI\r
-void NonMaskableInterrupt(void){/* brk(); */}\r
-\r
-// Dummy\r
-void Dummy(void){/* brk(); */}\r
-\r
-// BRK\r
-void Excep_BRK(void){ wait(); }\r
-\r
+++ /dev/null
-\r
-; Comment out the orginal code\r
- .IF 0 \r
-\r
-;------------------------------------------------------------------------\r
-; |\r
-; FILE :lowlvl.src |\r
-; DATE :Wed, Jun 16, 2010 |\r
-; DESCRIPTION :Program of Low level |\r
-; CPU TYPE :Other |\r
-; |\r
-; This file is generated by Renesas Project Generator (Ver.4.50). |\r
-; NOTE:THIS IS A TYPICAL EXAMPLE. |\r
-; |\r
-;------------------------------------------------------------------------\r
- \r
-\r
- .GLB _charput\r
- .GLB _charget\r
-\r
-SIM_IO .EQU 0h\r
-\r
- .SECTION P,CODE\r
-;-----------------------------------------------------------------------\r
-; _charput:\r
-;-----------------------------------------------------------------------\r
-_charput:\r
- MOV.L #IO_BUF,R2\r
- MOV.B R1,[R2]\r
- MOV.L #1220000h,R1\r
- MOV.L #PARM,R3\r
- MOV.L R2,[R3]\r
- MOV.L R3,R2\r
- MOV.L #SIM_IO,R3\r
- JSR R3\r
- RTS\r
-\r
-;-----------------------------------------------------------------------\r
-; _charget:\r
-;----------------------------------------------------------------------- \r
-_charget:\r
- MOV.L #1210000h,R1\r
- MOV.L #IO_BUF,R2\r
- MOV.L #PARM,R3\r
- MOV.L R2,[R3]\r
- MOV.L R3,R2\r
- MOV.L #SIM_IO,R3\r
- JSR R3\r
- MOV.L #IO_BUF,R2\r
- MOVU.B [R2],R1\r
- RTS\r
-\r
-;-----------------------------------------------------------------------\r
-; I/O Buffer\r
-;-----------------------------------------------------------------------\r
- .SECTION B,DATA,ALIGN=4\r
-PARM: .BLKL 1\r
- .SECTION B_1,DATA\r
-IO_BUF: .BLKB 1\r
-; .END ; Commented out for conditional assembly\r
-\r
-; Code below is for debug console\r
- .ELSE \r
-\r
-;-----------------------------------------------------------------------\r
-;\r
-; FILE :lowlvl.src\r
-; DATE :Wed, Jul 01, 2009\r
-; DESCRIPTION :Program of Low level\r
-; CPU TYPE :RX\r
-;\r
-;-----------------------------------------------------------------------\r
- .GLB _charput\r
- .GLB _charget\r
-\r
-FC2E0 .EQU 00084080h\r
-FE2C0 .EQU 00084090h\r
-DBGSTAT .EQU 000840C0h\r
-RXFL0EN .EQU 00001000h\r
-TXFL0EN .EQU 00000100h\r
-\r
- .SECTION P,CODE\r
-\r
-;-----------------------------------------------------------------------\r
-; _charput:\r
-;-----------------------------------------------------------------------\r
-_charput:\r
- .STACK _charput = 00000000h\r
-__C2ESTART: MOV.L #TXFL0EN,R3\r
- MOV.L #DBGSTAT,R4\r
-__TXLOOP: MOV.L [R4],R5\r
- AND R3,R5\r
- BNZ __TXLOOP\r
-__WRITEFC2E0: MOV.L #FC2E0,R2\r
- MOV.L R1,[R2]\r
-__CHARPUTEXIT: RTS\r
-\r
-;-----------------------------------------------------------------------\r
-; _charget:\r
-;-----------------------------------------------------------------------\r
-_charget:\r
- .STACK _charget = 00000000h\r
-__E2CSTART: MOV.L #RXFL0EN,R3\r
- MOV.L #DBGSTAT,R4\r
-__RXLOOP: MOV.L [R4],R5\r
- AND R3,R5\r
- BZ __RXLOOP\r
-__READFE2C0: MOV.L #FE2C0,R2\r
- MOV.L [R2],R1\r
-__CHARGETEXIT: RTS\r
-\r
-;-----------------------------------------------------------------------\r
-\r
-; End of conditional code\r
- .ENDIF \r
-\r
- .END\r
-\r
-\r
-\r
+++ /dev/null
-/***********************************************************************/\r
-/* */\r
-/* FILE :lowsrc.c */\r
-/* DATE :Wed, Jun 16, 2010 */\r
-/* DESCRIPTION :Program of I/O Stream */\r
-/* CPU TYPE :Other */\r
-/* */\r
-/* This file is generated by Renesas Project Generator (Ver.4.50). */\r
-/* NOTE:THIS IS A TYPICAL EXAMPLE. */\r
-/* */\r
-/***********************************************************************/\r
- \r
-\r
-\r
-/*********************************************************************\r
-*\r
-* Device : RX\r
-*\r
-* File Name : lowsrc.c\r
-*\r
-* Abstract : Program of I/O Stream.\r
-*\r
-* History : 1.00 (2009-08-07)\r
-*\r
-* NOTE : THIS IS A TYPICAL EXAMPLE.\r
-*\r
-* Copyright(c) 2009 Renesas Technology Corp.\r
-* And Renesas Solutions Corp.,All Rights Reserved. \r
-*\r
-*********************************************************************/\r
-\r
-#include <string.h>\r
-#include <stdio.h>\r
-#include <stddef.h>\r
-#include "lowsrc.h"\r
-\r
-/* file number */\r
-#define STDIN 0 /* Standard input (console) */\r
-#define STDOUT 1 /* Standard output (console) */\r
-#define STDERR 2 /* Standard error output (console) */\r
-\r
-#define FLMIN 0 /* Minimum file number */\r
-#define _MOPENR 0x1\r
-#define _MOPENW 0x2\r
-#define _MOPENA 0x4\r
-#define _MTRUNC 0x8\r
-#define _MCREAT 0x10\r
-#define _MBIN 0x20\r
-#define _MEXCL 0x40\r
-#define _MALBUF 0x40\r
-#define _MALFIL 0x80\r
-#define _MEOF 0x100\r
-#define _MERR 0x200\r
-#define _MLBF 0x400\r
-#define _MNBF 0x800\r
-#define _MREAD 0x1000\r
-#define _MWRITE 0x2000\r
-#define _MBYTE 0x4000\r
-#define _MWIDE 0x8000\r
-/* File Flags */\r
-#define O_RDONLY 0x0001 /* Read only */\r
-#define O_WRONLY 0x0002 /* Write only */\r
-#define O_RDWR 0x0004 /* Both read and Write */\r
-#define O_CREAT 0x0008 /* A file is created if it is not existed */\r
-#define O_TRUNC 0x0010 /* The file size is changed to 0 if it is existed. */\r
-#define O_APPEND 0x0020 /* The position is set for next reading/writing */\r
- /* 0: Top of the file 1: End of file */\r
-\r
-/* Special character code */\r
-#define CR 0x0d /* Carriage return */\r
-#define LF 0x0a /* Line feed */\r
-\r
-#if defined( __RX )\r
-const long _nfiles = IOSTREAM; /* The number of files for input/output files */\r
-#else\r
-const int _nfiles = IOSTREAM; /* The number of files for input/output files */\r
-#endif\r
-char flmod[IOSTREAM]; /* The location for the mode of opened file. */\r
-\r
-unsigned char sml_buf[IOSTREAM];\r
-\r
-#define FPATH_STDIN "C:\\stdin"\r
-#define FPATH_STDOUT "C:\\stdout"\r
-#define FPATH_STDERR "C:\\stderr"\r
-\r
-/* H8 Normal mode ,SH and RX */\r
-#if defined( __2000N__ ) || defined( __2600N__ ) || defined( __300HN__ ) || defined( _SH )\r
-/* Output one character to standard output */\r
-extern void charput(char);\r
-/* Input one character from standard input */\r
-extern char charget(void);\r
-/* Output one character to the file */\r
-extern char fcharput(char, unsigned char);\r
-/* Input one character from the file */\r
-extern char fcharget(char*, unsigned char);\r
-/* Open the file */\r
-extern char fileopen(char*, unsigned char, unsigned char*);\r
-/* Close the file */\r
-extern char fileclose(unsigned char);\r
-/* Move the file offset */\r
-extern char fpseek(unsigned char, long, unsigned char);\r
-/* Get the file offset */\r
-extern char fptell(unsigned char, long*);\r
-\r
-/* RX */\r
-#elif defined( __RX )\r
-/* Output one character to standard output */\r
-extern void charput(unsigned char);\r
-/* Input one character from standard input */\r
-extern unsigned char charget(void);\r
-\r
-/* H8 Advanced mode */\r
-#elif defined( __2000A__ ) || defined( __2600A__ ) || defined( __300HA__ ) || defined( __H8SXN__ ) || defined( __H8SXA__ ) || defined( __H8SXM__ ) || defined( __H8SXX__ )\r
-/* Output one character to standard output */\r
-extern void charput(char);\r
-/* Input one character from standard input */\r
-extern char charget(void);\r
-/* Output one character to the file */\r
-extern char fcharput(char, unsigned char);\r
-/* Input one character from the file */\r
-extern char fcharget(char*, unsigned char);\r
-/* Open the file */\r
-/* Specified as the number of register which stored paramter is 3 */\r
-extern char __regparam3 fileopen(char*, unsigned char, unsigned char*);\r
-/* Close the file */\r
-extern char fileclose(unsigned char);\r
-/* Move the file offset */\r
-extern char fpseek(unsigned char, long, unsigned char);\r
-/* Get the file offset */\r
-extern char fptell(unsigned char, long*);\r
-\r
-/* H8300 and H8300L */\r
-#elif defined( __300__ ) || defined( __300L__ )\r
-/* Output one character to standard output */\r
-extern void charput(char);\r
-/* Input one character from standard input */\r
-extern char charget(void);\r
-/* Output one character to the file */\r
-extern char fcharput(char, unsigned char);\r
-/* Input one character from the file */\r
-extern char fcharget(char*, unsigned char);\r
-/* Open the file */\r
-/* Specified as the number of register which stored paramter is 3 */\r
-extern char __regparam3 fileopen(char*, unsigned char, unsigned char*);\r
-/* Close the file */\r
-extern char fileclose(unsigned char);\r
-/* Move the file offset */\r
-/* Move the file offset */\r
-extern char __regparam3 fpseek(unsigned char, long, unsigned char);\r
-/* Get the file offset */\r
-extern char fptell(unsigned char, long*);\r
-#endif\r
-\r
-#include <stdio.h>\r
-FILE *_Files[IOSTREAM]; // structure for FILE\r
-char *env_list[] = { // Array for environment variables(**environ)\r
- "ENV1=temp01",\r
- "ENV2=temp02",\r
- "ENV9=end",\r
- '\0' // Terminal for environment variables\r
-};\r
-\r
-char **environ = env_list;\r
-\r
-/****************************************************************************/\r
-/* _INIT_IOLIB */\r
-/* Initialize C library Functions, if necessary. */\r
-/* Define USES_SIMIO on Assembler Option. */\r
-/****************************************************************************/\r
-void _INIT_IOLIB( void )\r
-{\r
- /* A file for standard input/output is opened or created. Each FILE */\r
- /* structure members are initialized by the library. Each _Buf member */\r
- /* in it is re-set the end of buffer pointer. */\r
-\r
- /* Standard Input File */\r
- if( freopen( FPATH_STDIN, "r", stdin ) == NULL )\r
- stdin->_Mode = 0xffff; /* Not allow the access if it fails to open */\r
- stdin->_Mode = _MOPENR; /* Read only attribute */\r
- stdin->_Mode |= _MNBF; /* Non-buffering for data */\r
- stdin->_Bend = stdin->_Buf + 1; /* Re-set pointer to the end of buffer */\r
-\r
- /* Standard Output File */\r
- if( freopen( FPATH_STDOUT, "w", stdout ) == NULL ) \r
- stdout->_Mode = 0xffff; /* Not allow the access if it fails to open */\r
- stdout->_Mode |= _MNBF; /* Non-buffering for data */\r
- stdout->_Bend = stdout->_Buf + 1;/* Re-set pointer to the end of buffer */\r
- \r
- /* Standard Error File */\r
- if( freopen( FPATH_STDERR, "w", stderr ) == NULL )\r
- stderr->_Mode = 0xffff; /* Not allow the access if it fails to open */\r
- stderr->_Mode |= _MNBF; /* Non-buffering for data */\r
- stderr->_Bend = stderr->_Buf + 1;/* Re-set pointer to the end of buffer */\r
-}\r
-\r
-/****************************************************************************/\r
-/* _CLOSEALL */\r
-/****************************************************************************/\r
-void _CLOSEALL( void )\r
-{\r
- long i;\r
-\r
- for( i=0; i < _nfiles; i++ )\r
- {\r
- /* Checks if the file is opened or not */\r
- if( _Files[i]->_Mode & (_MOPENR | _MOPENW | _MOPENA ) )\r
- fclose( _Files[i] ); /* Closes the file */\r
- }\r
-}\r
-\r
-/**************************************************************************/\r
-/* open:file open */\r
-/* Return value:File number (Pass) */\r
-/* -1 (Failure) */\r
-/**************************************************************************/\r
-#if defined( __RX )\r
-long open(const char *name, /* File name */\r
- long mode, /* Open mode */\r
- long flg) /* Open flag */\r
-#else\r
-int open(char *name, /* File name */\r
- int mode, /* Open mode */\r
- int flg) /* Open flag */\r
-#endif\r
-{\r
-\r
-\r
- if( strcmp( name, FPATH_STDIN ) == 0 ) /* Standard Input file? */\r
- {\r
- if( ( mode & O_RDONLY ) == 0 ) return -1;\r
- flmod[STDIN] = mode;\r
- return STDIN;\r
- }\r
- else if( strcmp( name, FPATH_STDOUT ) == 0 )/* Standard Output file? */\r
- {\r
- if( ( mode & O_WRONLY ) == 0 ) return -1;\r
- flmod[STDOUT] = mode;\r
- return STDOUT;\r
- }\r
- else if(strcmp(name, FPATH_STDERR ) == 0 ) /* Standard Error file? */\r
- {\r
- if( ( mode & O_WRONLY ) == 0 ) return -1;\r
- flmod[STDERR] = mode;\r
- return STDERR;\r
- }\r
- else return -1; /*Others */\r
-}\r
-\r
-#if defined( __RX )\r
-long close( long fileno )\r
-#else\r
-int close( int fileno )\r
-#endif\r
-{\r
- return 1;\r
-}\r
-\r
-/**************************************************************************/\r
-/* write:Data write */\r
-/* Return value:Number of write characters (Pass) */\r
-/* -1 (Failure) */\r
-/**************************************************************************/\r
-#if defined( __RX )\r
-long write(long fileno, /* File number */\r
- const unsigned char *buf, /* The address of destination buffer */\r
- long count) /* The number of chacter to write */\r
-#else\r
-int write(int fileno, /* File number */\r
- char *buf, /* The address of destination buffer */\r
- int count) /* The number of chacter to write */\r
-#endif\r
-{\r
- long i; /* A variable for counter */\r
- unsigned char c; /* An output character */\r
-\r
- /* Checking the mode of file , output each character */\r
- /* Checking the attribute for Write-Only, Read-Only or Read-Write */\r
- if(flmod[fileno]&O_WRONLY || flmod[fileno]&O_RDWR)\r
- {\r
- if( fileno == STDIN ) return -1; /* Standard Input */\r
- else if( (fileno == STDOUT) || (fileno == STDERR) ) \r
- /* Standard Error/output */\r
- {\r
- for( i = count; i > 0; --i )\r
- {\r
- c = *buf++;\r
- charput(c);\r
- }\r
- return count; /*Return the number of written characters */\r
- }\r
- else return -1; /* Incorrect file number */\r
- }\r
- else return -1; /* An error */\r
-}\r
-\r
-#if defined( __RX )\r
-long read( long fileno, unsigned char *buf, long count )\r
-#else\r
-int read( int fileno, char *buf, unsigned int count )\r
-#endif\r
-{\r
- long i;\r
-\r
- /* Checking the file mode with the file number, each character is input and stored the buffer */\r
-\r
- if((flmod[fileno]&_MOPENR) || (flmod[fileno]&O_RDWR)){\r
- for(i = count; i > 0; i--){\r
- *buf = charget();\r
- if(*buf==CR){ /* Replace the new line character */\r
- *buf = LF;\r
- }\r
- buf++;\r
- }\r
- return count;\r
- }\r
- else {\r
- return -1;\r
- }\r
-}\r
-\r
-#if defined( __RX )\r
-long lseek( long fileno, long offset, long base )\r
-#else\r
-long lseek( int fileno, long offset, int base )\r
-#endif\r
-{\r
- return -1L;\r
-}\r
-\r
+++ /dev/null
-/***********************************************************************/\r
-/* */\r
-/* FILE :resetprg.c */\r
-/* DATE :Wed, Aug 11, 2010 */\r
-/* DESCRIPTION :Reset Program */\r
-/* CPU TYPE :Other */\r
-/* */\r
-/* This file is generated by Renesas Project Generator (Ver.4.50). */\r
-/* NOTE:THIS IS A TYPICAL EXAMPLE. */\r
-/* */\r
-/***********************************************************************/\r
- \r
-\r
-\r
-/*********************************************************************\r
-*\r
-* Device : RX/RX600\r
-*\r
-* File Name : resetprg.c\r
-*\r
-* Abstract : Reset Program.\r
-*\r
-* History : 1.00 (2009-08-07)\r
-*\r
-* NOTE : THIS IS A TYPICAL EXAMPLE.\r
-*\r
-* Copyright(c) 2009 Renesas Technology Corp.\r
-* And Renesas Solutions Corp.,All Rights Reserved. \r
-*\r
-*********************************************************************/\r
-/* Types used in this file. */\r
-#include "typedefine.h"\r
-\r
-/* Defines machine level functions used in this file */
-#include <machine.h>\r
-\r
-/* Defines MCU configuration functions used in this file */
-#include <_h_c_lib.h>
-\r
-/* Hardware definitions" */
-#include "iodefine.h"\r
-\r
-/* Defines the size of the stack which configured in this file */
-#include "stacksct.h"
-\r
-#define PSW_init 0x00010000\r
-#define FPSW_init 0x00000100\r
-\r
-extern void HardwareSetup( void );\r
-\r
-#pragma section ResetPRG\r
-#pragma entry PowerON_Reset_PC\r
-\r
-/* It is ok to use stack variables here because "#pragma entry" is used, so the\r
-stack is setup in the compiler generated prologue. */\r
-void PowerON_Reset_PC(void)\r
-{ \r
-volatile unsigned int i;\r
-\r
- set_intb(__sectop("C$VECT"));\r
- set_fpsw(FPSW_init);\r
-\r
- /* MCU boots using the LOCO, so turn the speed up before setting up the C\r
- run-time environment.\r
-\r
- Clock Description Frequency\r
- ----------------------------------------\r
- Input Clock Frequency............ 12 MHz\r
- PLL frequency (x16).............. 192 MHz\r
- Internal Clock Frequency......... 96 MHz \r
- Peripheral Clock Frequency....... 48 MHz\r
- USB Clock Frequency.............. 48 MHz\r
- External Bus Clock Frequency..... 24 MHz */\r
-\r
- /* Protect off. */\r
- SYSTEM.PRCR.WORD = 0xA50B; \r
- \r
- /* Uncomment if not using sub-clock */\r
- //SYSTEM.SOSCCR.BYTE = 0x01; /* stop sub-clock */\r
- SYSTEM.SOSCCR.BYTE = 0x00; /* Enable sub-clock for RTC */\r
-\r
- /* Wait 131,072 cycles * 12 MHz = 10.9 ms */\r
- SYSTEM.MOSCWTCR.BYTE = 0x0D; \r
-\r
- /* PLL wait is 4,194,304 cycles (default) * 192 MHz (12 MHz * 16) = 20.1 ms*/\r
- SYSTEM.PLLWTCR.BYTE = 0x04; \r
-\r
- /* x16 @PLL */\r
- SYSTEM.PLLCR.WORD = 0x0F00; \r
-\r
- /* EXTAL ON */\r
- SYSTEM.MOSCCR.BYTE = 0x00; \r
-\r
- /* PLL ON */\r
- SYSTEM.PLLCR2.BYTE = 0x00; \r
-\r
- for(i = 0;i< 0x168;i++) \r
- {\r
- /* Wait over 12ms */\r
- nop() ;\r
- }\r
-\r
- /* Setup system clocks\r
- SCKCR - System Clock Control Register\r
- b31:b28 FCK[3:0] 0x02 = Flash clock: PLL/4 = (192 / 4) = 48 MHz\r
- b27:b24 ICK[3:0] 0x01 = System clock: PLL/2 = (192 / 2) = 96 MHz\r
- b23 PSTOP1 0x00 = BCLK pin output is enabled\r
- b19:b16 BCK[3:0] 0x03 = BCLK: PLL/8 = 24 MHz\r
- b11:b8 PCKB[3:0] 0x02 = Peripheral clock B: PLL/4 = 48 MHz\r
- */\r
- SYSTEM.SCKCR.LONG = 0x21031222; /* ICK=PLL/2,BCK,FCK,PCK=PLL/4 */\r
-\r
- /* Setup IEBUS and USB clocks\r
- SCKCR2 - System Clock Control Register 2 \r
- b7:b4 UCK[3:0] 0x03 = USB clock is PLL/4 = 48 MHz\r
- b3:b0 IEBCK[3:0] 0x01 = IE Bus clock is PLL/2 = 96 MHz\r
- */\r
- SYSTEM.SCKCR2.WORD = 0x0031;\r
-\r
- /* ICLK, PCLKB, FCLK, BCLK, IECLK, and USBCLK all come from PLL circuit */\r
- SYSTEM.SCKCR3.WORD = 0x0400; \r
-\r
- /* Protect on. */\r
- SYSTEM.PRCR.WORD = 0xA500;
-\r
- /* Initialize C runtime environment */
- _INITSCT();\r
-\r
- /* Setup the hardware for the RSK. */\r
- HardwareSetup();\r
- nop();\r
-\r
- /* Set Ubit and Ibit for PSW. */\r
- set_psw(PSW_init);\r
-\r
- /* Call the application code. */\r
- main();\r
-\r
- /* Main should not return. */\r
- brk();\r
-}\r
-\r
+++ /dev/null
-#include <stddef.h>\r
-#include <stdio.h>\r
-#define HEAPSIZE 0x400\r
-signed char *sbrk( size_t size );\r
-union HEAP_TYPE\r
-{\r
- signed long dummy;\r
- signed char heap[HEAPSIZE];\r
-};\r
-static union HEAP_TYPE heap_area;\r
-\r
-/* End address allocated by sbrk */\r
-static signed char *brk = ( signed char * ) &heap_area;\r
-signed char *sbrk( size_t size )\r
-{\r
- signed char *p;\r
- if( brk + size > heap_area.heap + HEAPSIZE )\r
- {\r
- p = ( signed char * ) - 1;\r
- }\r
- else\r
- {\r
- p = brk;\r
- brk += size;\r
- }\r
-\r
- return p;\r
-}\r
+++ /dev/null
-/***********************************************************************/\r
-/* */\r
-/* FILE :vecttbl.c */\r
-/* DATE :Wed, Aug 11, 2010 */\r
-/* DESCRIPTION :Initialize of Vector Table */\r
-/* CPU TYPE :Other */\r
-/* */\r
-/* This file is generated by Renesas Project Generator (Ver.4.50). */\r
-/* NOTE:THIS IS A TYPICAL EXAMPLE. */\r
-/* */\r
-/***********************************************************************/\r
- \r
-\r
-\r
-/*********************************************************************\r
-*\r
-* Device : RX/RX600\r
-*\r
-* File Name : vecttbl.c\r
-*\r
-* Abstract : Initialize of Vector Table.\r
-*\r
-* History : 1.00 (2009-08-07)\r
-*\r
-* NOTE : THIS IS A TYPICAL EXAMPLE.\r
-*\r
-* Copyright(c) 2009 Renesas Technology Corp.\r
-* And Renesas Solutions Corp.,All Rights Reserved. \r
-*\r
-*********************************************************************/\r
-\r
-#include "vect.h"\r
-\r
-#pragma section C FIXEDVECT\r
-\r
-void* const Fixed_Vectors[] = {\r
-//;0xffffffd0 Exception(Supervisor Instruction)\r
- (void*) Excep_SuperVisorInst,\r
-//;0xffffffd4 Reserved\r
- Dummy,\r
-//;0xffffffd8 Reserved\r
- Dummy,\r
-//;0xffffffdc Exception(Undefined Instruction)\r
- (void*) Excep_UndefinedInst,\r
-//;0xffffffe0 Reserved\r
- Dummy,\r
-//;0xffffffe4 Exception(Floating Point)\r
- (void*) Excep_FloatingPoint,\r
-//;0xffffffe8 Reserved\r
- Dummy,\r
-//;0xffffffec Reserved\r
- Dummy,\r
-//;0xfffffff0 Reserved\r
- Dummy,\r
-//;0xfffffff4 Reserved\r
- Dummy,\r
-//;0xfffffff8 NMI\r
- (void*) NonMaskableInterrupt,\r
-//;0xfffffffc RESET\r
-//;<<VECTOR DATA START (POWER ON RESET)>>\r
-//;Power On Reset PC\r
-PowerON_Reset_PC \r
-//;<<VECTOR DATA END (POWER ON RESET)>>\r
-};\r