Commit 3 RX100 low power demos.

This commit is contained in:
Richard Barry 2013-04-17 10:04:38 +00:00
parent 2b41be4cb9
commit 2bd7d0c1f5
112 changed files with 37911 additions and 0 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,149 @@
/***********************************************************************************************************************
* 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 : RSKRX210
* Description : Defines the initialization routines used each time the MCU is restarted.
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 08.11.2012 0.01 Beta 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"
#include "r_switches_config.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;
/* Unlock MPC registers to enable writing to them. */
MPC.PWPR.BIT.B0WI = 0 ; /* Unlock protection register */
MPC.PWPR.BIT.PFSWE = 1 ; /* Unlock MPC registers */
/* TXD1 is output. */
PORT1.PDR.BIT.B6 = 1;
PORT1.PMR.BIT.B6 = 1;
MPC.P16PFS.BYTE = 0x0A;
/* RXD1 is input. */
PORT1.PDR.BIT.B5 = 0;
PORT1.PMR.BIT.B5 = 1;
MPC.P15PFS.BYTE = 0x0A;
/* Configure the pin connected to the ADC Pot as an input */
PORT4.PDR.BIT.B4 = 0;
/* Protect off. */
SYSTEM.PRCR.WORD = 0xA50B;
/* Turn off module stop for the A2D converter. */
SYSTEM.MSTPCRA.BIT.MSTPA17 = 0;
/* Protect on. */
SYSTEM.PRCR.WORD = 0xA500;
/* Initialise the first button to generate an interrupt. */
R_SWITCHES_Init();
}
/***********************************************************************************************************************
* 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)
{
/* Enable triggers to start an ADC conversion. */
S12AD.ADCSR.BIT.TRGE = 1;
/* Only channel 4 is going to be used. */
S12AD.ADANSA.BIT.ANSA4 = 1;
}

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 : RSKRX111
* Description : Provides variable and function declarations for lcd.c file
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 08.11.2012 0.01 Beta 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. */
PORT4.PDR.BYTE |= 0x0F;
/* 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. RX111 has max clock of 32MHz which gives a cycle time of 31.3ns.
* This means that nothing under 313ns should be input. 313ns 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)((313.0)*(32000000.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 */
PORT4.PODR.BYTE = (value & 0x0F);
/* 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 : RSKRX111
* Description : Provides variable and function declarations for lcd.c file
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 08.11.2012 0.01 Beta 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 PORTC.PODR.BIT.B5
#define RS_PIN_DDR PORTC.PDR.BIT.B5
/* Display enable pin */
#define E_PIN PORTB.PODR.BIT.B1
#define E_PIN_DDR PORTB.PDR.BIT.B1
/* 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,53 @@
/***********************************************************************************************************************
* 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 : RSKRX111
* Description : Has the header files that should be included for this platform.
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 08.11.2012 0.01 Beta Release
***********************************************************************************************************************/
#ifndef PLATFORM_BOARD_RSKRX111
#define PLATFORM_BOARD_RSKRX111
/* 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\rx111\iodefine.h"
#include ".\mcu\rx111\mcu_info.h"
#include ".\board\rskrx111\rskrx111.h"
#include ".\board\rskrx111\hwsetup.h"
#include ".\board\rskrx111\lcd.h"
#include ".\board\rskrx111\locking.h"
#include ".\board\rskrx111\vecttbl.h"
#endif /* PLATFORM_BOARD_RSKRX111 */

View file

@ -0,0 +1,250 @@
/***********************************************************************************************************************
* 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_config_reference.c
* Device(s) : RX111
* Description : The file r_bsp_config.h is used to configure your BSP. r_bsp_config.h should be included
* somewhere in your package so that the r_bsp code has access to it. This file (r_bsp_config_reference.h)
* is just a reference file that the user can use to make their own r_bsp_config.h file.
************************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 07.11.2012 0.01 Beta Release
***********************************************************************************************************************/
#ifndef R_BSP_CONFIG_REF_HEADER_FILE
#define R_BSP_CONFIG_REF_HEADER_FILE
/***********************************************************************************************************************
Configuration Options
***********************************************************************************************************************/
/* Enter the product part number for your MCU. This information will be used to obtain information about your MCU such
as package and memory size.
To help parse this information, the part number will be defined using multiple macros.
R 5 F 51 11 5 A D FM
| | | | | | | | | Macro Name Description
| | | | | | | | |__MCU_PART_PACKAGE = Package type, number of pins, and pin pitch
| | | | | | | |____not used = Products with wide temperature range (D: -40 to 85C G: -40 to 105C)
| | | | | | |______not used = Blank
| | | | | |________MCU_PART_MEMORY_SIZE = ROM, RAM, and Data Flash Capacity
| | | | |___________MCU_PART_GROUP = Group name
| | | |______________MCU_PART_SERIES = Series name
| | |________________MCU_PART_MEMORY_TYPE = Type of memory (Flash)
| |__________________not used = Renesas MCU
|____________________not used = Renesas semiconductor product.
*/
/* Package type. Set the macro definition based on values below:
Character(s) = Value for macro = Package Type/Number of Pins/Pin Pitch
FM = 0x0 = LFQFP/64/0.50
FK = 0x1 = LQFP/64/0.80
LF = 0x2 = TFLGA/64/0.50
FL = 0x3 = LFQFP/48/0.50
NE = 0x4 = VQFN/48/0.50
NC = 0x5 = HWQFN/36/0.50
LM = 0x6 = WFLGA/36/0.50
SB = 0x7 = SSOP/36/0.80
*/
#define MCU_PART_PACKAGE (0x0)
/* ROM, RAM, and Data Flash Capacity.
Character(s) = Value for macro = ROM Size/Ram Size/Data Flash Size
5 = 0x5 = 128KB/16KB/8KB
4 = 0x4 = 96KB/16KB/8KB
3 = 0x3 = 64KB/10KB/8KB
1 = 0x1 = 32KB/10KB/8KB
J = 0x0 = 16KB/8KB/8KB
*/
#define MCU_PART_MEMORY_SIZE (0x5)
/* Group name.
Character(s) = Value for macro = Description
10 = 0x0 = RX110 Group
11 = 0x1 = RX111 Group
*/
#define MCU_PART_GROUP (0x1)
/* Series name.
Character(s) = Value for macro = Description
51 = 0x0 = RX100 Series
*/
#define MCU_PART_SERIES (0x0)
/* Memory type.
Character(s) = Value for macro = Description
F = 0x0 = Flash memory version
*/
#define MCU_PART_MEMORY_TYPE (0x0)
/* The 'BSP_DECLARE_STACK' macro is checked so that the stack is only declared in one place (resetprg.c). Every time a
'#pragma stacksize' is encountered, the stack size is increased. This prevents multiplication of stack size. */
#if defined(BSP_DECLARE_STACK)
/* User Stack size in bytes. The Renesas RX toolchain sets the stack size using the #pragma stacksize directive. */
#pragma stacksize su=0x400
/* Interrupt Stack size in bytes. The Renesas RX toolchain sets the stack size using the #pragma stacksize directive. */
#pragma stacksize si=0x100
#endif
/* Heap size in bytes. */
#define HEAP_BYTES (0x400)
/* After reset MCU will operate in Supervisor mode. To switch to User mode, set this macro to '1'. For more information
on the differences between these 2 modes see the CPU >> Processor Mode section of your MCU's hardware manual.
0 = Stay in Supervisor mode.
1 = Switch to User mode.
*/
#define RUN_IN_USER_MODE (0)
/* This macro lets other modules no if a RTOS is being used.
0 = RTOS is not used.
1 = RTOS is used.
*/
#define RTOS_USED (0)
/* Clock source select (CKSEL).
0 = Low Speed On-Chip Oscillator (LOCO)
1 = High Speed On-Chip Oscillator (HOCO)
2 = Main Clock Oscillator
3 = Sub-Clock Oscillator
4 = PLL Circuit
*/
#define CLOCK_SOURCE (4)
/* Clock configuration options.
The input clock frequency is specified and then the system clocks are set by specifying the multipliers used. The
multiplier settings are used to set the clock registers in resetprg.c. If a 16MHz clock is used and the
ICLK is 24MHz, PCLKB is 24MHz, FCLK is 24MHz, PCLKD is 24MHz, and CKO is 1MHz then the
settings would be:
XTAL_HZ = 16000000
PLL_DIV = 2
PLL_MUL = 6 (16MHz x 3 = 48MHz)
ICK_DIV = 2 : System Clock (ICLK) = (((XTAL_HZ/PLL_DIV) * PLL_MUL) / ICK_DIV) = 24MHz
PCKB_DIV = 2 : Peripheral Clock B (PCLKB) = (((XTAL_HZ/PLL_DIV) * PLL_MUL) / PCKB_DIV) = 24MHz
PCKD_DIV = 2 : Peripheral Clock D (PCLKD) = (((XTAL_HZ/PLL_DIV) * PLL_MUL) / PCKD_DIV) = 24MHz
FCK_DIV = 2 : Flash IF Clock (FCLK) = (((XTAL_HZ/PLL_DIV) * PLL_MUL) / FCK_DIV) = 24MHz
*/
/* XTAL - Input clock frequency in Hz */
#define XTAL_HZ (16000000)
/* PLL Input Frequency Divider Select (PLIDIV).
Available divisors = /1 (no division), /2, /4
*/
#define PLL_DIV (2)
/* PLL Frequency Multiplication Factor Select (STC).
Available multipliers = x6, x8
*/
#define PLL_MUL (6)
/* System Clock Divider (ICK).
Available divisors = /1 (no division), /2, /4, /8, /16, /32, /64
*/
#define ICK_DIV (2)
/* Peripheral Module Clock B Divider (PCKB).
Available divisors = /1 (no division), /2, /4, /8, /16, /32, /64
*/
#define PCKB_DIV (2)
/* Peripheral Module Clock D Divider (PCKD).
Available divisors = /1 (no division), /2, /4, /8, /16, /32, /64
*/
#define PCKD_DIV (2)
/* Flash IF Clock Divider (FCK).
Available divisors = /1 (no division), /2, /4, /8, /16, /32, /64
*/
#define FCK_DIV (2)
/* Below are callback functions that can be used for detecting MCU exceptions, undefined interrupt sources, and
bus errors. If the user wishes to be alerted of these events then they will need to define the macro as a
function to be called when the event occurs. For example, if the user wanted the function
excep_undefined_instr_isr() to be called when an undefined interrupt source ISR is triggered then they would
do the following:
#define UNDEFINED_INT_ISR_CALLBACK undefined_interrupt_cb
If the user does not wish to be alerted of these events then they should comment out the macros.
NOTE: When a callback function is called it will be called from within a ISR. This means that the function
will essentially be an interrupt and will hold off other interrupts that occur in the system while it
is executing. For this reason, it is recommended to keep these callback functions short as to not
decrease the real-time response of your system.
*/
/* Callback for Supervisor Instruction Violation Exception. */
//#define EXCEP_SUPERVISOR_ISR_CALLBACK supervisor_instr_cb
/* Callback for Undefined Instruction Exception. */
//#define EXCEP_UNDEFINED_INSTR_ISR_CALLBACK undefined_instr_cb
/* Callback for Non-maskable Interrupt. */
//#define NMI_ISR_CALLBACK nmi_cb
/* Callback for all undefined interrupt vectors. User can set a breakpoint in this function to determine which source
is creating unwanted interrupts. */
//#define UNDEFINED_INT_ISR_CALLBACK undefined_interrupt_cb
/* Callback for Bus Error Interrupt. */
//#define BUS_ERROR_ISR_CALLBACK bus_error_cb
/* The user has the option of separately choosing little or big endian for the User Application Area */
/* Endian mode for User Application.
0 = Big Endian
Else = Little Endian (Default)
*/
#define USER_APP_ENDIAN (1)
/* Configure WDT and IWDT settings.
OFS0 - Option Function Select Register 0
OFS0 - Option Function Select Register 0
b31: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=128 cycles, 1=512, 2=1024, 3=2048)
b1 IWDTSTRT - IWDT Start Mode Select - (0=auto-start after reset, 1=halt after reset)
b0 Reserved (set to 1) */
#define OFS0_REG_VALUE (0xFFFFFFFF) //Disable by default
/* Configure whether voltage detection 1 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:b4 STUPLVD1LVL - Startup Voltage Monitoring 1 Reset Detection Level Select
0 1 0 0: 3.10 V
0 1 0 1: 3.00 V
0 1 1 0: 2.90 V
0 1 1 1: 2.79 V
1 0 0 0: 2.68 V
1 0 0 1: 2.58 V
1 0 1 0: 2.48 V
1 0 1 1: 2.06 V
1 1 0 0: 1.96 V
1 1 0 1: 1.86 V
b3:b2 Reserved (set to 1)
b2 STUPLVD1REN - Startup Voltage Monitoring 1 Reset Enable (1=monitoring disabled)
b0 FASTSTUP - Power-On Fast Startup Time (1=normal; read only) */
#define OFS1_REG_VALUE (0xFFFFFFFF) //Disable by default
/* Initializes C input & output library functions.
0 = Disable I/O library initialization in resetprg.c. If you are not using stdio then use this value.
1 = Enable I/O library initialization in resetprg.c. This is default and needed if you are using stdio. */
#define IO_LIB_ENABLE (1)
#endif /* R_BSP_CONFIG_REF_HEADER_FILE */

View file

@ -0,0 +1,416 @@
/***********************************************************************************************************************
* 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) : RX111
* 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
* : 08.11.2012 0.01 Beta Release
***********************************************************************************************************************/
/***********************************************************************************************************************
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)
/***********************************************************************************************************************
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);
static void clock_source_select(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
***********************************************************************************************************************/
#pragma section ResetPRG // output PowerON_Reset to PResetPRG section
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
#ifdef NMI_ISR_CALLBACK
/* Enable NMI interrupt if callback is configured in r_bsp_config.h */
ICU.NMIER.BIT.NMIEN = 1;
#endif
/* Switch to high-speed operation */
operating_frequency_set();
/* Initialize C runtime environment */
_INITSCT();
#if IO_LIB_ENABLE == 1
/* Comment this out if not using I/O lib */
_INIT_IOLIB();
#endif
/* 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();
#if IO_LIB_ENABLE == 1
/* Comment this out if not using I/O lib - cleans up open files */
_CLOSEALL();
#endif
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 and CKOCR registers. */
uint32_t temp_clock = 0;
/*
Clock Description Frequency
----------------------------------------
Input Clock Frequency............ 16 MHz
PLL frequency (x3)............... 48 MHz
Internal Clock Frequency......... 24 MHz
Peripheral Clock Frequency....... 24 MHz
Clock Out Frequency.............. 1 MHz */
volatile unsigned int i;
/* Protect off. */
SYSTEM.PRCR.WORD = 0xA50B;
/* Select the clock based upon user's choice. */
clock_source_select();
/* 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
/* 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
/* Figure out setting for PCKD bits. */
#if PCKD_DIV == 1
/* Do nothing since PCKD bits should be 0. */
#elif PCKD_DIV == 2
temp_clock |= 0x00000001;
#elif PCKD_DIV == 4
temp_clock |= 0x00000002;
#elif PCKD_DIV == 8
temp_clock |= 0x00000003;
#elif PCKD_DIV == 16
temp_clock |= 0x00000004;
#elif PCKD_DIV == 32
temp_clock |= 0x00000005;
#elif PCKD_DIV == 64
temp_clock |= 0x00000006;
#else
#error "Error! Invalid setting for PCKD_DIV in r_bsp_config.h"
#endif
/* Set SCKCR register. */
SYSTEM.SCKCR.LONG = 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: clock_source_select
* Description : Enables and disables clocks as chosen by the user. This function also implements the software delays
* needed for the clocks to stabilize.
* Arguments : none
* Return value : none
***********************************************************************************************************************/
static void clock_source_select (void)
{
/* Declared volatile for software delay purposes. */
volatile unsigned int i;
/* NOTE: AS OF VERSION 0.50 OF THE RX111 HARDWARE MANUAL, ALL OF THE CLOCK
* STABILIZATION TIMES ARE TBD. FOR NOW, WHERE EVER A WAIT COUNT REGISTER
* IS AVAILABLE, THE DELAY IS SET TO THE MAX NUMBER OF CYCLES. WHERE EVER
* DELAY LOOPS ARE PRESENT, THE VALUES FROM THE 63N ARE RE-USED. KEEP IN
* MIND THAT THE 63N RUNS ON A FASTER CRYSTAL.
*/
#if (CLOCK_SOURCE == 1)
/* HOCO is chosen. Start it operating. */
SYSTEM.HOCOCR.BYTE = 0x00;
/* The delay period needed is to make sure that the HOCO has stabilized.*/
for(i = 0; i< 28; i++) // tHOCOWT2 is TBD
{
nop() ;
}
#else
/* HOCO is not chosen. Stop the HOCO. */
SYSTEM.HOCOCR.BYTE = 0x01;
#endif
#if (CLOCK_SOURCE == 2)
/* Main clock oscillator is chosen. Start it operating. */
SYSTEM.MOSCWTCR.BYTE = 0x07; // Wait 65,536 cycles
/* Set the main clock to operating. */
SYSTEM.MOSCCR.BYTE = 0x00;
/* The delay period needed is to make sure that the main clock has stabilized. */
for(i = 0; i< 140; i++) // tMAINOSCWT is TBD
{
nop() ;
}
#endif
#if (CLOCK_SOURCE == 3)
/* Sub-clock oscillator is chosen. Start it operating. */
/* In section 9.8.4, there is a reference to a SOSCWTCR register, but there is no
* description for this register in the manual nor reference for it in iodefine.h. */
/* Set the sub-clock to operating. */
SYSTEM.SOSCCR.BYTE = 0x00;
/* The delay period needed is to make sure that the sub-clock has stabilized. */
for(i = 0; i< 30233; i++) // tSUBOSCWT0 is TBD
{
nop() ;
}
#else
/* Set the sub-clock to stopped. */
SYSTEM.SOSCCR.BYTE = 0x01;
#endif
#if (CLOCK_SOURCE == 4)
/* PLL is chosen. Start it operating. Must start main clock as well since PLL uses it. */
SYSTEM.MOSCWTCR.BYTE = 0x07; // Wait 65,536 cycles
/* Set the main clock to operating. */
SYSTEM.MOSCCR.BYTE = 0x00;
/* Set PLL Input Divisor. */
SYSTEM.PLLCR.BIT.PLIDIV = PLL_DIV >> 1;
/* Set PLL Multiplier. */
SYSTEM.PLLCR.BIT.STC = (PLL_MUL * 2) - 1;
/* Set the PLL to operating. */
SYSTEM.PLLCR2.BYTE = 0x00;
/* The delay period needed is to make sure that the main clock and PLL have stabilized. */
for(i = 0; i< 140; i++) // tPLLWT2 is TBD
{
nop() ;
}
#endif
/* LOCO is saved for last since it is what is running by default out of reset. This means you do not want to turn
it off until another clock has been enabled and is ready to use. */
#if (CLOCK_SOURCE == 0)
/* LOCO is chosen. This is the default out of reset. */
SYSTEM.LOCOCR.BYTE = 0x00;
#else
/* LOCO is not chosen and another clock has already been setup. Turn off the LOCO. */
SYSTEM.LOCOCR.BYTE = 0x01;
#endif
/* Make sure a valid clock was chosen. */
#if (CLOCK_SOURCE > 4) || (CLOCK_SOURCE < 0)
#error "ERROR - Valid clock source must be chosen in r_bsp_config.h using CLOCK_SOURCE macro."
#endif
}
/***********************************************************************************************************************
* 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,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) 2012 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
/***********************************************************************************************************************
* File Name : rskrx111.h
* H/W Platform : RSKRX111
* Description : Board specific definitions for the RSKRX111.
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 08.11.2012 0.01 Beta Release
***********************************************************************************************************************/
#ifndef RSKRX111_H
#define RSKRX111_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.B0
#define SW2 PORT3.PIDR.BIT.B1
#define SW3 PORTE.PIDR.BIT.B4
#define SW1_PDR PORT3.PDR.BIT.B0
#define SW2_PDR PORT3.PDR.BIT.B1
#define SW3_PDR PORTE.PDR.BIT.B4
#define SW1_PMR PORT3.PMR.BIT.B0
#define SW2_PMR PORT3.PMR.BIT.B1
#define SW3_PMR PORTE.PMR.BIT.B4
/* LEDs */
#define LED0 PORTB.PODR.BIT.B7
#define LED1 PORTA.PODR.BIT.B0
#define LED2 PORT5.PODR.BIT.B4
#define LED3 PORT1.PODR.BIT.B7
#define LED0_PDR PORTB.PDR.BIT.B7
#define LED1_PDR PORTA.PDR.BIT.B0
#define LED2_PDR PORT5.PDR.BIT.B4
#define LED3_PDR PORT1.PDR.BIT.B7
#endif /* RSKRX111_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,206 @@
/***********************************************************************************************************************
* 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) : RX11x
* Description : Definition of the fixed vector table and option setting memory.
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 08.11.2012 0.01 Beta Release
***********************************************************************************************************************/
/***********************************************************************************************************************
Includes <System Includes> , "Project Includes"
***********************************************************************************************************************/
/* Fixed size integers. */
#include <stdint.h>
/* Used for nop(). */
#include <machine.h>
/* BSP configuration. */
#include "platform.h"
#pragma section IntPRG
/***********************************************************************************************************************
* 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)
{
/* If the user defined a callback function in r_bsp_config.h then it will be called here. */
#if defined(EXCEP_SUPERVISOR_ISR_CALLBACK)
EXCEP_SUPERVISOR_ISR_CALLBACK();
/* If you do not put the MCU in Supervisor mode before returning then it will just execute the same violating
instruction again and come back in here. Since the PSW is restored from the stack when returning from the
exception, you would need to alter the saved PSW on the stack to change to Supervisor mode. We do not do this
here because the only 'safe' way to do this would be to write this function in assembly. Even then most users
would probably want to handle this someway instead of just going back to the application. */
#else
brk();
#endif
}
/***********************************************************************************************************************
* 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)
{
/* If the user defined a callback function in r_bsp_config.h then it will be called here. */
#if defined(EXCEP_UNDEFINED_INSTR_ISR_CALLBACK)
EXCEP_UNDEFINED_INSTR_ISR_CALLBACK();
#else
brk();
#endif
}
/***********************************************************************************************************************
* 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)
{
/* If the user defined a callback function in r_bsp_config.h then it will be called here. */
#if defined(NMI_ISR_CALLBACK)
NMI_ISR_CALLBACK();
/* Clear NMI flag. */
ICU.NMICLR.BIT.NMICLR = 1;
#else
brk();
#endif
}
/***********************************************************************************************************************
* 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)
{
/* If the user defined a callback function in r_bsp_config.h then it will be called here. */
#if defined(UNDEFINED_INT_ISR_CALLBACK)
UNDEFINED_INT_ISR_CALLBACK();
#else
brk();
#endif
}
/***********************************************************************************************************************
* 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)
{
/* Clear the bus error */
BSC.BERCLR.BIT.STSCLR = 1;
/*
To find the address that was accessed when the bus error occurred, 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)
*/
/* If the user defined a callback function in r_bsp_config.h then it will be called here. */
#if defined(BUS_ERROR_ISR_CALLBACK)
BUS_ERROR_ISR_CALLBACK();
#else
nop();
#endif
}
void Dummy( void )
{
brk();
}
/***********************************************************************************************************************
* The following array fills in the endian and option function select registers, and the fixed vector table
* bytes.
***********************************************************************************************************************/
#pragma section C FIXEDVECT
void (*const Fixed_Vectors[])(void) = {
//;0xffffffd0 Exception(Supervisor Instruction)
excep_supervisor_inst_isr,
//;0xffffffd4 Reserved
Dummy,
//;0xffffffd8 Reserved
Dummy,
//;0xffffffdc Exception(Undefined Instruction)
undefined_interrupt_source_isr,
//;0xffffffe0 Reserved
Dummy,
//;0xffffffe4 Reserved
Dummy,
//;0xffffffe8 Reserved
Dummy,
//;0xffffffec Reserved
Dummy,
//;0xfffffff0 Reserved
Dummy,
//;0xfffffff4 Reserved
Dummy,
//;0xfffffff8 NMI
non_maskable_isr,
//;0xfffffffc RESET
//;<<VECTOR DATA START (POWER ON RESET)>>
//;Power On Reset PC
PowerON_Reset_PC
//;<<VECTOR DATA END (POWER ON RESET)>>
};
#pragma address _MDEreg=0xffffff80 // MDE register (Single Chip Mode)
#ifdef __BIG
const unsigned long _MDEreg = 0xfffffff8; // big
#else
const unsigned long _MDEreg = 0xffffffff; // little
#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 : vecttbl.h
* Device(s) : RX111
* Description : Has function prototypes for exception callback functions.
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 08.11.2012 1.20 Beta Release.
***********************************************************************************************************************/
#ifndef VECTTBL_HEADER_INC
#define VECTTBL_HEADER_INC
/***********************************************************************************************************************
Includes <System Includes> , "Project Includes"
***********************************************************************************************************************/
/* Fixed size integers. */
#include <stdint.h>
/* Used for nop(). */
#include <machine.h>
/* BSP configuration. */
#include "platform.h"
/***********************************************************************************************************************
Exported global functions (to be accessed by other files)
***********************************************************************************************************************/
#if defined(EXCEP_SUPERVISOR_ISR_CALLBACK)
void EXCEP_SUPERVISOR_ISR_CALLBACK(void);
#endif
#if defined(EXCEP_UNDEFINED_INSTR_ISR_CALLBACK)
void EXCEP_UNDEFINED_INSTR_ISR_CALLBACK(void);
#endif
#if defined(NMI_ISR_CALLBACK)
void NMI_ISR_CALLBACK(void);
#endif
#if defined(UNDEFINED_INT_ISR_CALLBACK)
void UNDEFINED_INT_ISR_CALLBACK(void);
#endif
#if defined(BUS_ERROR_ISR_CALLBACK)
void BUS_ERROR_ISR_CALLBACK(void);
#endif
#endif /* VECTTBL_HEADER_INC */

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
* 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
* : 27.06.2012 1.10 Updated with new information to reflect udpated r_bsp structure.
***********************************************************************************************************************/
#ifndef PLATFORM_BOARD_USER
#define PLATFORM_BOARD_USER
/* 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
***********************************************************************************************************************/
/* This is a user defined board. Start off by:
1)Copy and rename one of the 'board' folders that most closely matches your system (same MCU Series and Group).
2)Substitute in your MCU Group for the *MCU Group* option in the #include below for mcu_info.h.
3)Copy the other #includes from the r_bsp.h in the 'board' folder that you copied earlier.
4)Configure the BSP for your board by modifying the r_bsp_config_reference.h.
5)Copy r_bsp_config_reference.h to your project directory and rename it r_bsp_config.h.
You can also add your own include files here as well. */
#include "r_bsp_config.h"
#include ".\mcu\*MCU Group*\mcu_info.h"
#endif /* PLATFORM_BOARD_USER */

View file

@ -0,0 +1,112 @@
/***********************************************************************************************************************
* 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 : mcu_info.h
* Device(s) : RX111
* Description : Information about the MCU on this board (RSKRX111).
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 08.11.2012 0.01 Beta Release
***********************************************************************************************************************/
#ifndef _MCU_INFO
#define _MCU_INFO
/***********************************************************************************************************************
Includes <System Includes> , "Project Includes"
***********************************************************************************************************************/
/* Gets MCU configuration information. */
#include "r_bsp_config.h"
/***********************************************************************************************************************
Macro definitions
***********************************************************************************************************************/
/* MCU Series. */
#if MCU_PART_SERIES == 0x0
#define MCU_SERIES_RX100 (1)
#else
#error "ERROR - MCU_PART_SERIES - Unknown MCU Series chosen in r_bsp_config.h"
#endif
/* MCU Group name. */
#if MCU_PART_GROUP == 0x1
#define MCU_RX111 (1)
#define MCU_RX11x (1)
#else
#error "ERROR - MCU_PART_GROUP - Unknown MCU Group chosen in r_bsp_config.h"
#endif
/* Package. */
#if MCU_PART_PACKAGE == 0x0
#define PACKAGE_LFQFP64 (1)
#elif MCU_PART_PACKAGE == 0x1
#define PACKAGE_LQFP64 (1)
#elif MCU_PART_PACKAGE == 0x2
#define PACKAGE_TFLGA64 (1)
#elif MCU_PART_PACKAGE == 0x3
#define PACKAGE_LFQFP48 (1)
#elif MCU_PART_PACKAGE == 0x4
#define PACKAGE_VQFN48 (1)
#elif MCU_PART_PACKAGE == 0x5
#define PACKAGE_HWQFN36 (1)
#elif MCU_PART_PACKAGE == 0x6
#define PACKAGE_WFLGA36 (1)
#elif MCU_PART_PACKAGE == 0x7
#define PACKAGE_SSOP36 (1)
#else
#error "ERROR - MCU_PART_PACKAGE - Unknown package chosen in r_bsp_config.h"
#endif
/* Memory size of your MCU. */
#if MCU_PART_MEMORY_SIZE == 0x0 // "J" parts
#define ROM_SIZE_BYTES (16384)
#define RAM_SIZE_BYTES (8192)
#define DF_SIZE_BYTES (8192)
#elif MCU_PART_MEMORY_SIZE == 0x1
#define ROM_SIZE_BYTES (32768)
#define RAM_SIZE_BYTES (10240)
#define DF_SIZE_BYTES (8192)
#elif MCU_PART_MEMORY_SIZE == 0x3
#define ROM_SIZE_BYTES (65536)
#define RAM_SIZE_BYTES (10240)
#define DF_SIZE_BYTES (8192)
#elif MCU_PART_MEMORY_SIZE == 0x4
#define ROM_SIZE_BYTES (98304)
#define RAM_SIZE_BYTES (16384)
#define DF_SIZE_BYTES (8192)
#elif MCU_PART_MEMORY_SIZE == 0x5
#define ROM_SIZE_BYTES (131072)
#define RAM_SIZE_BYTES (16384)
#define DF_SIZE_BYTES (8192)
#else
#error "ERROR - MCU_PART_MEMORY_SIZE - Unknown memory size chosen in r_bsp_config.h"
#endif
/* System clock speed in Hz. */
#define ICLK_HZ (((XTAL_HZ/PLL_DIV) * PLL_MUL) / ICK_DIV)
/* Peripheral Module Clock B speed in Hz. */
#define PCLKB_HZ (((XTAL_HZ/PLL_DIV) * PLL_MUL) / PCKB_DIV)
/* Peripheral Module Clock D speed in Hz. */
#define PCLKD_HZ (((XTAL_HZ/PLL_DIV) * PLL_MUL) / PCKD_DIV)
/* FlashIF clock speed in Hz. */
#define FCLK_HZ (((XTAL_HZ/PLL_DIV) * PLL_MUL) / FCK_DIV)
#endif /* _MCU_INFO */

View file

@ -0,0 +1,88 @@
/***********************************************************************************************************************
* 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 : platform.h
* Description : The user chooses which MCU and board they are developing for in this file. If the board you are using
* is not listed below, please add your own or use the default 'User Board'.
***********************************************************************************************************************/
/***********************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 30.11.2011 1.00 First Release
* : 13.01.2012 1.10 Moved from having platform defined using macro defintion, to having platform defined
* by choosing an include path. This makes this file simpler and cleans up the issue
* where HEW shows all header files for all platforms under 'Dependencies'.
* : 14.02.2012 1.20 Added RX210 BSP.
* : 18.04.2012 1.30 Updated to v0.70 of FIT S/W Spec and v0.20 of FIT r_bsp Spec. This includes adding
* locking.c and locking.h in board folders. Also, r_bsp can now be configured through
* r_bsp_config.h.
* : 26.06.2012 1.40 Added new options such as exception callbacks and the ability to choose your MCU using
* its part number in r_bsp_config.h. Moved mcu_info.h to the 'mcu' folder. Made an effort
* to remove any extra files that the user would need to touch. Removed the flash_options.c
* file and put its contents in vecttbl.c.
* : 17.07.2012 1.50 Fixed bug with exception callback function names. Added BCLK_OUTPUT and SDCLK_OUTPUT
* macro options in r_bsp_config.h. Added some extra code to handle exceptions in
* vecttbl.c. Added vecttbl.h so that user has prototypes for exception callbacks.
* : 08.11.2012 1.60 Added RX111 BSP
***********************************************************************************************************************/
#ifndef _PLATFORM_H_
#define _PLATFORM_H_
/***********************************************************************************************************************
DEFINE YOUR SYSTEM - UNCOMMENT THE INCLUDE PATH FOR THE PLATFORM YOU ARE USING.
***********************************************************************************************************************/
/* RSKRX610 */
//#include "./board/rskrx610/r_bsp.h"
/* RSKRX62N */
//#include "./board/rskrx62n/r_bsp.h"
/* RSKRX62T */
//#include "./board/rskrx62t/r_bsp.h"
/* RDKRX62N */
//#include "./board/rdkrx62n/r_bsp.h"
/* RSKRX630 */
//#include "./board/rskrx630/r_bsp.h"
/* RSKRX63N */
//#include "./board/rskrx63n/r_bsp.h"
/* RDKRX63N */
//#include "./board/rdkrx63n/r_bsp.h"
/* RSKRX210 */
//#include "./board/rskrx210/r_bsp.h"
/* RSKRX111 */
#include "./board/rskrx111/r_bsp.h"
/* User Board - Define your own board here. */
//#include "./board/user/r_bsp.h"
/***********************************************************************************************************************
MAKE SURE AT LEAST ONE PLATFORM WAS DEFINED - DO NOT EDIT BELOW THIS POINT
***********************************************************************************************************************/
#ifndef PLATFORM_DEFINED
#error "Error - No platform defined in platform.h!"
#endif
#endif /* _PLATFORM_H_ */

View file

@ -0,0 +1,250 @@
/***********************************************************************************************************************
* 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_config_reference.c
* Device(s) : RX111
* Description : The file r_bsp_config.h is used to configure your BSP. r_bsp_config.h should be included
* somewhere in your package so that the r_bsp code has access to it. This file (r_bsp_config_reference.h)
* is just a reference file that the user can use to make their own r_bsp_config.h file.
************************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 07.11.2012 0.01 Beta Release
***********************************************************************************************************************/
#ifndef R_BSP_CONFIG_REF_HEADER_FILE
#define R_BSP_CONFIG_REF_HEADER_FILE
/***********************************************************************************************************************
Configuration Options
***********************************************************************************************************************/
/* Enter the product part number for your MCU. This information will be used to obtain information about your MCU such
as package and memory size.
To help parse this information, the part number will be defined using multiple macros.
R 5 F 51 11 5 A D FM
| | | | | | | | | Macro Name Description
| | | | | | | | |__MCU_PART_PACKAGE = Package type, number of pins, and pin pitch
| | | | | | | |____not used = Products with wide temperature range (D: -40 to 85C G: -40 to 105C)
| | | | | | |______not used = Blank
| | | | | |________MCU_PART_MEMORY_SIZE = ROM, RAM, and Data Flash Capacity
| | | | |___________MCU_PART_GROUP = Group name
| | | |______________MCU_PART_SERIES = Series name
| | |________________MCU_PART_MEMORY_TYPE = Type of memory (Flash)
| |__________________not used = Renesas MCU
|____________________not used = Renesas semiconductor product.
*/
/* Package type. Set the macro definition based on values below:
Character(s) = Value for macro = Package Type/Number of Pins/Pin Pitch
FM = 0x0 = LFQFP/64/0.50
FK = 0x1 = LQFP/64/0.80
LF = 0x2 = TFLGA/64/0.50
FL = 0x3 = LFQFP/48/0.50
NE = 0x4 = VQFN/48/0.50
NC = 0x5 = HWQFN/36/0.50
LM = 0x6 = WFLGA/36/0.50
SB = 0x7 = SSOP/36/0.80
*/
#define MCU_PART_PACKAGE (0x0)
/* ROM, RAM, and Data Flash Capacity.
Character(s) = Value for macro = ROM Size/Ram Size/Data Flash Size
5 = 0x5 = 128KB/16KB/8KB
4 = 0x4 = 96KB/16KB/8KB
3 = 0x3 = 64KB/10KB/8KB
1 = 0x1 = 32KB/10KB/8KB
J = 0x0 = 16KB/8KB/8KB
*/
#define MCU_PART_MEMORY_SIZE (0x5)
/* Group name.
Character(s) = Value for macro = Description
10 = 0x0 = RX110 Group
11 = 0x1 = RX111 Group
*/
#define MCU_PART_GROUP (0x1)
/* Series name.
Character(s) = Value for macro = Description
51 = 0x0 = RX100 Series
*/
#define MCU_PART_SERIES (0x0)
/* Memory type.
Character(s) = Value for macro = Description
F = 0x0 = Flash memory version
*/
#define MCU_PART_MEMORY_TYPE (0x0)
/* The 'BSP_DECLARE_STACK' macro is checked so that the stack is only declared in one place (resetprg.c). Every time a
'#pragma stacksize' is encountered, the stack size is increased. This prevents multiplication of stack size. */
#if defined(BSP_DECLARE_STACK)
/* User Stack size in bytes. The Renesas RX toolchain sets the stack size using the #pragma stacksize directive. */
#pragma stacksize su=0x400
/* Interrupt Stack size in bytes. The Renesas RX toolchain sets the stack size using the #pragma stacksize directive. */
#pragma stacksize si=0x100
#endif
/* Heap size in bytes. */
#define HEAP_BYTES (0x001)
/* After reset MCU will operate in Supervisor mode. To switch to User mode, set this macro to '1'. For more information
on the differences between these 2 modes see the CPU >> Processor Mode section of your MCU's hardware manual.
0 = Stay in Supervisor mode.
1 = Switch to User mode.
*/
#define RUN_IN_USER_MODE (0)
/* This macro lets other modules no if a RTOS is being used.
0 = RTOS is not used.
1 = RTOS is used.
*/
#define RTOS_USED (0)
/* Clock source select (CKSEL).
0 = Low Speed On-Chip Oscillator (LOCO)
1 = High Speed On-Chip Oscillator (HOCO)
2 = Main Clock Oscillator
3 = Sub-Clock Oscillator
4 = PLL Circuit
*/
#define CLOCK_SOURCE (4) // GI org 4
/* Clock configuration options.
The input clock frequency is specified and then the system clocks are set by specifying the multipliers used. The
multiplier settings are used to set the clock registers in resetprg.c. If a 16MHz clock is used and the
ICLK is 24MHz, PCLKB is 24MHz, FCLK is 24MHz, PCLKD is 24MHz, and CKO is 1MHz then the
settings would be:
XTAL_HZ = 16000000
PLL_DIV = 2
PLL_MUL = 6 (16MHz x 3 = 48MHz)
ICK_DIV = 2 : System Clock (ICLK) = (((XTAL_HZ/PLL_DIV) * PLL_MUL) / ICK_DIV) = 24MHz
PCKB_DIV = 2 : Peripheral Clock B (PCLKB) = (((XTAL_HZ/PLL_DIV) * PLL_MUL) / PCKB_DIV) = 24MHz
PCKD_DIV = 2 : Peripheral Clock D (PCLKD) = (((XTAL_HZ/PLL_DIV) * PLL_MUL) / PCKD_DIV) = 24MHz
FCK_DIV = 2 : Flash IF Clock (FCLK) = (((XTAL_HZ/PLL_DIV) * PLL_MUL) / FCK_DIV) = 24MHz
*/
/* XTAL - Input clock frequency in Hz */
#define XTAL_HZ (16000000)
/* PLL Input Frequency Divider Select (PLIDIV).
Available divisors = /1 (no division), /2, /4
*/
#define PLL_DIV (2) // GI org 2
/* PLL Frequency Multiplication Factor Select (STC).
Available multipliers = x6, x8
*/
#define PLL_MUL (6) // GI org 6
/* System Clock Divider (ICK).
Available divisors = /1 (no division), /2, /4, /8, /16, /32, /64
*/
#define ICK_DIV (2) // NOTE: ICLK CANNOT BE SLOWER THAN PCLK!
/* Peripheral Module Clock B Divider (PCKB).
Available divisors = /1 (no division), /2, /4, /8, /16, /32, /64
*/
#define PCKB_DIV (2) // GI org 2
/* Peripheral Module Clock D Divider (PCKD).
Available divisors = /1 (no division), /2, /4, /8, /16, /32, /64
*/
#define PCKD_DIV (2)
/* Flash IF Clock Divider (FCK).
Available divisors = /1 (no division), /2, /4, /8, /16, /32, /64
*/
#define FCK_DIV (2)
/* Below are callback functions that can be used for detecting MCU exceptions, undefined interrupt sources, and
bus errors. If the user wishes to be alerted of these events then they will need to define the macro as a
function to be called when the event occurs. For example, if the user wanted the function
excep_undefined_instr_isr() to be called when an undefined interrupt source ISR is triggered then they would
do the following:
#define UNDEFINED_INT_ISR_CALLBACK undefined_interrupt_cb
If the user does not wish to be alerted of these events then they should comment out the macros.
NOTE: When a callback function is called it will be called from within a ISR. This means that the function
will essentially be an interrupt and will hold off other interrupts that occur in the system while it
is executing. For this reason, it is recommended to keep these callback functions short as to not
decrease the real-time response of your system.
*/
/* Callback for Supervisor Instruction Violation Exception. */
//#define EXCEP_SUPERVISOR_ISR_CALLBACK supervisor_instr_cb
/* Callback for Undefined Instruction Exception. */
//#define EXCEP_UNDEFINED_INSTR_ISR_CALLBACK undefined_instr_cb
/* Callback for Non-maskable Interrupt. */
//#define NMI_ISR_CALLBACK nmi_cb
/* Callback for all undefined interrupt vectors. User can set a breakpoint in this function to determine which source
is creating unwanted interrupts. */
//#define UNDEFINED_INT_ISR_CALLBACK undefined_interrupt_cb
/* Callback for Bus Error Interrupt. */
//#define BUS_ERROR_ISR_CALLBACK bus_error_cb
/* The user has the option of separately choosing little or big endian for the User Application Area */
/* Endian mode for User Application.
0 = Big Endian
Else = Little Endian (Default)
*/
#define USER_APP_ENDIAN (1)
/* Configure WDT and IWDT settings.
OFS0 - Option Function Select Register 0
OFS0 - Option Function Select Register 0
b31: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=128 cycles, 1=512, 2=1024, 3=2048)
b1 IWDTSTRT - IWDT Start Mode Select - (0=auto-start after reset, 1=halt after reset)
b0 Reserved (set to 1) */
#define OFS0_REG_VALUE (0xFFFFFFFF) //Disable by default
/* Configure whether voltage detection 1 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:b4 STUPLVD1LVL - Startup Voltage Monitoring 1 Reset Detection Level Select
0 1 0 0: 3.10 V
0 1 0 1: 3.00 V
0 1 1 0: 2.90 V
0 1 1 1: 2.79 V
1 0 0 0: 2.68 V
1 0 0 1: 2.58 V
1 0 1 0: 2.48 V
1 0 1 1: 2.06 V
1 1 0 0: 1.96 V
1 1 0 1: 1.86 V
b3:b2 Reserved (set to 1)
b2 STUPLVD1REN - Startup Voltage Monitoring 1 Reset Enable (1=monitoring disabled)
b0 FASTSTUP - Power-On Fast Startup Time (1=normal; read only) */
#define OFS1_REG_VALUE (0xFFFFFFFF) //Disable by default
/* Initializes C input & output library functions.
0 = Disable I/O library initialization in resetprg.c. If you are not using stdio then use this value.
1 = Enable I/O library initialization in resetprg.c. This is default and needed if you are using stdio. */
#define IO_LIB_ENABLE (0)
#endif /* R_BSP_CONFIG_REF_HEADER_FILE */

View file

@ -0,0 +1,100 @@
r_bsp Package
=============
Document Number
---------------
N/A
Version
-------
v1.60
Overview
--------
The r_bsp package provides a foundation for code to be built on top of. It provides startup code, iodefines, and MCU
information for different boards. There are 2 folders that make up the r_bsp package. The 'mcu' folder has iodefine
files and a file named 'mcu_info.h' for each MCU group. The 'mcu_info.h' file has information about the MCU on the board
and is configured based on the information given in r_bsp_config.h. The information in 'mcu_info.h' is used to help
configure Renesas middleware that uses the r_bsp package. The 'board' folder has a folder with startup code for each
supported board. Which MCU and board is chosen is decided by the settings in 'platform.h'. The user can choose which
board they are using by uncommenting the include path that applies to their board. For example, if you are using the
RSK+RX62N then you would uncomment the #include "./board/rskrx62n/r_bsp.h" include path. Users are encouraged to add
their own boards to the 'board' directory. BSPs are configured by using the r_bsp_config.h file. Each board will have a
reference configuration file named r_bsp_config_reference.h. The user should copy this file to their project, rename it
to r_bsp_config.h, and use the options inside the file to configure the BSP for their project.
Features
--------
* Provides foundation to build code on top of.
* Provides MCU startup code.
* Provides SFR access through iodefine.h
* Stores details of MCU in 'mcu_info.h' to help configure Renesas middleware.
* Easily configure BSP through r_bsp_config.h.
* Choose MCU easily by inputting part number details in r_bsp_config.h.
* Provides callbacks for MCU exceptions and the bus error interrupt.
Limitations
-----------
N/A
Peripherals Used Directly
-------------------------
N/A
Required Packages
-----------------
* r_glyph [required if you want to use LCD for RDK boards]
* r_rspi_rx [required if you want to use LCD for RDK boards]
How to add to your project
--------------------------
* Copy the r_bsp folder to your project.
* Add an include path to the 'r_bsp' directory.
* Add all of the source files for your board from the 'r_bsp\board\--YOUR_BOARD--' directory to your project.
* Uncomment the include path for your board in 'platform.h' which is located in the 'r_bsp' directory.
* Copy the file r_bsp_config_reference.h from the 'r_bsp\board\--YOUR_BOARD--' directory and copy it to your project's
source code directory. Rename the file r_bsp_config.h.
* Open r_bsp_config.h and use the macros to configure the BSP for your project.
File Structure
--------------
r_bsp
| platform.h (choose which board is being used)
| readme.txt
|
+---board (contains supported boards)
| +---rdkrx62n (contains BSP source and header files)
| |
| +---rdkrx63n
| |
| +---rskrx111
| |
| +---rskrx210
| |
| +---rskrx610
| |
| +---rskrx62n
| |
| +---rskrx62t
| |
| +---rskrx630
| |
| +---rskrx63n
| |
| \---user
|
\---mcu
+---rx111 (contains common files to this MCU group, e.g. iodefine.h)
|
+---rx210
|
+---rx610
|
+---rx62n
|
+---rx62t
|
+---rx630
|
\---rx63n

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) 2011 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
/***********************************************************************************************************************
* File Name : r_switches_config.c
* Description : Configures the switches code
************************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 17.01.2012 1.00 First Release
* : 17.02.2012 1.10 Added RSKRX210 support.
* : 08.03.2012 1.20 Added GetVersion() function (though it's really a macro).
* : 04.06.2012 1.30 Code can now be interrupt or poll driven.
***********************************************************************************************************************/
#ifndef SWITCHES_CONFIG_HEADER_FILE
#define SWITCHES_CONFIG_HEADER_FILE
/***********************************************************************************************************************
Configuration Options
***********************************************************************************************************************/
/* This macro sets whether interrupts or polling is used for detecting switch presses. The benefit of using interrupts
is that no extra processing is used for polling and the use of a system timer tick is not a requirement. The downside
of using interrupts is that callback functions are called from within an interrupt so if your ISR is long then it can
degrade the real-time response of your system. The benefit of polling is that functions are called at the application
level and debouncing is supported. The downside to polling is that your system must call the R_SWITCHES_Update() on a
regular basis which requires extra processing.
0 = Use interrupts
1 = Use polling
*/
#define SWITCHES_DETECTION_MODE (0)
/* The definition for these macros should be the name of the function that you want called when a switch is
pressed. It is very important that the user recognize that this function will be called from the interrupt service
routine. This means that code inside of the function should be kept short to ensure it does not hold up the rest of
the system.
Example: If SW1_CALLBACK_FUNCTION is defined to be sw1_callback then the sw1_callback function will be called when
switch 1 is pressed.
*/
#define SW1_CALLBACK_FUNCTION (vButtonInterruptCallback)
#define SW2_CALLBACK_FUNCTION (vButtonInterruptCallback)
#define SW3_CALLBACK_FUNCTION (vButtonInterruptCallback)
#endif /* SWITCHES_CONFIG_HEADER_FILE */

View file

@ -0,0 +1,74 @@
/***********************************************************************************************************************
* 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 : r_switches_if.h
* Description : Functions for using switches with callback functions.
************************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 17.01.2012 1.00 First Release
* : 17.02.2012 1.10 Added RSKRX210 support.
* : 08.03.2012 1.20 Added GetVersion() function (though it's really a macro).
* : 04.06.2012 1.30 Code can now be interrupt or poll driven.
***********************************************************************************************************************/
#ifndef SWITCHES_API_HEADER_FILE
#define SWITCHES_API_HEADER_FILE
/***********************************************************************************************************************
Includes <System Includes> , "Project Includes"
***********************************************************************************************************************/
/* Fixed width integer support. */
#include <stdint.h>
/* bool support */
#include <stdbool.h>
/* Used for configuring the code */
#include "r_switches_config.h"
/***********************************************************************************************************************
Macro definitions
***********************************************************************************************************************/
/* Version Number of API. */
#define SWITCHES_VERSION_MAJOR (1)
#define SWITCHES_VERSION_MINOR (0)
/* The process of getting the version number is done through the macro below. The version number is encoded where the
top 2 bytes are the major version number and the bottom 2 bytes are the minor version number. For example,
Version 4.25 would be returned as 0x00040019. */
#define R_SWITCHES_GetVersion() ((((uint32_t)SWITCHES_VERSION_MAJOR) << 16) | (uint32_t)SWITCHES_VERSION_MINOR)
/***********************************************************************************************************************
Public Functions
***********************************************************************************************************************/
void R_SWITCHES_Init(uint32_t detection_hz, uint32_t debounce_counts);
void R_SWITCHES_Update(void);
/* Callback prototypes. */
#if defined(SW1_CALLBACK_FUNCTION)
void SW1_CALLBACK_FUNCTION(void);
#endif
#if defined(SW2_CALLBACK_FUNCTION)
void SW2_CALLBACK_FUNCTION(void);
#endif
#if defined(SW3_CALLBACK_FUNCTION)
void SW3_CALLBACK_FUNCTION(void);
#endif
#endif /* SWITCHES_API_HEADER_FILE */

View file

@ -0,0 +1,83 @@
PLEASE REFER TO THE APPLICATION NOTE FOR THIS MIDDLEWARE FOR MORE INFORMATION
Switches
========
Document Number
---------------
N/A
Version
-------
v1.40
Overview
--------
Configures port pins for switches and calls user defined function on switch press. Switch presses can be detected using
IRQ interrupts or by polling. The benefit of using interrupts is that no extra processing is used for polling and the
use of a system timer tick is not a requirement. The downside of using interrupts is that callback functions are called
from within an interrupt so if your ISR is long then it can degrade the real-time response of your system. The benefit
of polling is that functions are called at the application level and debouncing is supported. The downside to polling is
that your system must call the R_SWITCHES_Update() on a regular basis which requires extra processing.
Features
--------
* Call one function to setup switches.
* Define function to call when switch is pressed.
* Can be configured to be interrupt or poll driven.
Supported MCUs
--------------
* RX610 Group
* RX621, RX62N Group
* RX62T Group
* RX630 Group
* RX631, RX63N Group
* RX210 Group
* RX111 Group
Boards Tested On
----------------
* RSKRX610
* RSK+RX62N
* RSKRX62T
* RDKRX62N
* RSKRX630
* RSKRX63N
* RDKRX63N
* RSKRX111
Limitations
-----------
* None
Peripherals Used Directly
-------------------------
* None
Required Packages
-----------------
* None
How to add to your project
--------------------------
* Add src\r_switches.c to your project.
* Add an include path to the 'r_switches' directory.
* Add an include path to the 'r_switches\src' directory.
* Configure middleware through r_switches_config.h.
* Add a #include for r_switches_if.h to files that need to use this package.
Toolchain(s) Used
-----------------
* Renesas RX v1.02
File Structure
--------------
r_switches
| readme.txt
| r_switches_config.h
| r_switches_if.h
|
\---src
r_switches.c

View file

@ -0,0 +1,483 @@
/***********************************************************************************************************************
* 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 : r_switches.c
* Description : Functions for using switches with callback functions.
************************************************************************************************************************
* History : DD.MM.YYYY Version Description
* : 17.01.2012 1.00 First Release
* : 17.02.2012 1.10 Added RSKRX210 support.
* : 08.03.2012 1.20 Added GetVersion() function (though it's really a macro).
* : 04.06.2012 1.30 Code can now be interrupt or poll driven.
* : 07.11.2012 1.40 Added support for RSKRX111
***********************************************************************************************************************/
/***********************************************************************************************************************
Includes <System Includes> , "Project Includes"
***********************************************************************************************************************/
/* Board and MCU support. */
#include "platform.h"
/* Switches prototypes. */
#include "r_switches_if.h"
/* Scheduler includes. */
#include "FreeRTOS.h"
/***********************************************************************************************************************
Macro definitions
***********************************************************************************************************************/
/* This helps reduce the amount of unique code for each supported board. */
#define X_IRQ( x ) XX_IRQ( x )
#define XX_IRQ( x ) _ICU_IRQ##x
/* These macros define which IRQ pins are used for the switches. Note that these defintions cannot have parentheses
around them. */
#if defined(PLATFORM_BOARD_RDKRX63N)
#define SW1_IRQ_NUMBER 8
#define SW2_IRQ_NUMBER 9
#define SW3_IRQ_NUMBER 12
#elif defined(PLATFORM_BOARD_RSKRX63N)
#define SW1_IRQ_NUMBER 2
#define SW2_IRQ_NUMBER 8
#define SW3_IRQ_NUMBER 15
#elif defined(PLATFORM_BOARD_RSKRX630)
#define SW1_IRQ_NUMBER 2
#define SW2_IRQ_NUMBER 12
#define SW3_IRQ_NUMBER 15
#elif defined(PLATFORM_BOARD_RSKRX62N)
#define SW1_IRQ_NUMBER 8
#define SW2_IRQ_NUMBER 9
#define SW3_IRQ_NUMBER 15
#elif defined(PLATFORM_BOARD_RDKRX62N)
#define SW1_IRQ_NUMBER 8
#define SW2_IRQ_NUMBER 9
#define SW3_IRQ_NUMBER 10
#elif defined(PLATFORM_BOARD_RSKRX62T)
#define SW1_IRQ_NUMBER 0
#define SW2_IRQ_NUMBER 1
#define SW3_IRQ_NUMBER 3
#elif defined(PLATFORM_BOARD_RSKRX610)
#define SW1_IRQ_NUMBER 8
#define SW2_IRQ_NUMBER 9
#define SW3_IRQ_NUMBER 3
#elif defined(PLATFORM_BOARD_RSKRX210)
#define SW1_IRQ_NUMBER 1
#define SW2_IRQ_NUMBER 3
#define SW3_IRQ_NUMBER 4
#elif defined(PLATFORM_BOARD_RSKRX111)
#define SW1_IRQ_NUMBER 0
#define SW2_IRQ_NUMBER 1
#define SW3_IRQ_NUMBER 4
#endif
/* Number of switches on this board. */
#define SWITCHES_NUM (3)
/***********************************************************************************************************************
Typedef definitions
***********************************************************************************************************************/
typedef struct
{
bool active;
int32_t debounce_cnt;
} switch_t;
/***********************************************************************************************************************
Private global variables and functions
***********************************************************************************************************************/
#if SWITCHES_DETECTION_MODE == 1
/* Update Hz */
static uint32_t g_sw_debounce_cnts;
/* Used for debounce. */
switch_t g_switches[SWITCHES_NUM];
#endif
/***********************************************************************************************************************
* Function Name: R_SWITCHES_Init
* Description : Initializes pins to be input and interrupt on switch presses.
* Arguments : detection_hz -
* The times per second that the user will call R_SWITCHES_Update(). NOTE: this is only when using
* polling mode. If you are using interrupt mode, then this argument will be ignored.
* debouce_counts -
* The number of times to check the port value before accepting the change. The slower the rate at
* which R_SWITCHES_Update() will likely lower this number.
* Return Value : none
***********************************************************************************************************************/
void R_SWITCHES_Init (uint32_t detection_hz, uint32_t debounce_counts)
{
uint32_t i;
/* The SW#_XXX defintions are common macros amongst different boards. To see the definitions for these macros
see the board defintion file. For example, this file for the RSKRX63N is rskrx63n.h. */
#if defined(MCU_RX62N) || defined(MCU_RX62T) || defined(MCU_RX621) || defined(MCU_RX610)
/* Make switch pins inputs. */
SW1_DDR = 0;
SW2_DDR = 0;
SW3_DDR = 0;
/* Enable input buffer control registers. */
SW1_ICR = 1;
SW2_ICR = 1;
SW3_ICR = 1;
#elif defined(MCU_RX63N) || defined(MCU_RX630) || defined(MCU_RX631) || defined(MCU_RX210) || defined(MCU_RX111)
/* Unlock protection register */
MPC.PWPR.BIT.B0WI = 0 ;
/* Unlock MPC registers */
MPC.PWPR.BIT.PFSWE = 1 ;
/* Make switch pins 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;
#endif
#if SWITCHES_DETECTION_MODE == 0
#if defined(PLATFORM_BOARD_RDKRX63N)
/* The switches on the RDKRX63N are connected to the following pins/IRQ's
Switch Port IRQ
------ ---- ----
SW1 P4.0 IRQ8
SW2 P4.1 IRQ9
SW3 P4.4 IRQ12
*/
MPC.P40PFS.BYTE = 0x40; /* P40 is used as IRQ pin */
MPC.P41PFS.BYTE = 0x40; /* P40 is used as IRQ pin */
MPC.P44PFS.BYTE = 0x40; /* P40 is used as IRQ pin */
#elif defined(PLATFORM_BOARD_RSKRX63N)
/* The switches on the RSKRX63N are connected to the following pins/IRQ's
Switch Port IRQ
------ ---- ----
SW1 P3.2 IRQ2
SW2 P0.0 IRQ8
SW3 P0.7 IRQ15
*/
MPC.P32PFS.BYTE = 0x40; /* P32 is used as IRQ pin */
MPC.P00PFS.BYTE = 0x40; /* P00 is used as IRQ pin */
MPC.P07PFS.BYTE = 0x40; /* P07 is used as IRQ pin */
#elif defined(PLATFORM_BOARD_RSKRX630)
/* The switches on the RSKRX630 are connected to the following pins/IRQ's
Switch Port IRQ
------ ---- ----
SW1 P3.2 IRQ2
SW2 P4.4 IRQ12
SW3 P0.7 IRQ15
*/
MPC.P32PFS.BYTE = 0x40; /* P32 is used as IRQ pin */
MPC.P44PFS.BYTE = 0x40; /* P44 is used as IRQ pin */
MPC.P07PFS.BYTE = 0x40; /* P07 is used as IRQ pin */
#elif defined(PLATFORM_BOARD_RSKRX62N)
/* The switches on the RSKRX62N are connected to the following pins/IRQ's
Switch Port IRQ
------ ---- ----
SW1 P0.0 IRQ8-A
SW2 P0.1 IRQ9-A
SW3 P0.7 IRQ15-A
*/
IOPORT.PF8IRQ.BIT.ITS8 = 0; /* IRQ8-A pin is used. */
IOPORT.PF8IRQ.BIT.ITS9 = 0; /* IRQ9-A pin is used. */
IOPORT.PF8IRQ.BIT.ITS15 = 0; /* IRQ15-A pin is used. */
#elif defined(PLATFORM_BOARD_RDKRX62N)
/* The switches on the RDKRX62N are connected to the following pins/IRQ's
Switch Port IRQ
------ ---- ----
SW1 P4.0 IRQ8
SW2 P4.1 IRQ9
SW3 P4.2 IRQ10
*/
/* Nothing else needed to do here since RDK has 100-pin package and there are no alternate pins to choose. */
#elif defined(PLATFORM_BOARD_RSKRX62T)
/* The switches on the RSKRX62T are connected to the following pins/IRQ's
Switch Port IRQ
------ ---- ----
SW1 PE.5 IRQ0-B
SW2 PE.4 IRQ1-B
SW3 PB.4 IRQ3
*/
IOPORT.PF8IRQ.BIT.ITS0 = 1; /* IRQ0-B pin is used. */
IOPORT.PF8IRQ.BIT.ITS1 = 1; /* IRQ1-B pin is used. */
/* IRQ3 is only on 1 pin. */
#elif defined(PLATFORM_BOARD_RSKRX610)
/* The switches on the RSKRX610 are connected to the following pins/IRQ's
Switch Port IRQ
------ ---- ----
SW1 P0.0 IRQ8-A
SW2 P0.1 IRQ9-A
SW3 P1.3 IRQ3-B
*/
IOPORT.PFCR8.BIT.ITS8 = 0; /* IRQ8-A pin is used. */
IOPORT.PFCR8.BIT.ITS9 = 0; /* IRQ9-A pin is used. */
IOPORT.PFCR9.BIT.ITS3 = 1; /* IRQ3-B pin is used. */
/* Enable IRQ detection. */
ICU.IRQER[SW1_IRQ_NUMBER].BIT.IRQEN = 1;
ICU.IRQER[SW2_IRQ_NUMBER].BIT.IRQEN = 1;
ICU.IRQER[SW3_IRQ_NUMBER].BIT.IRQEN = 1;
#elif defined(PLATFORM_BOARD_RSKRX210)
/* The switches on the RSKRX210 are connected to the following pins/IRQ's
Switch Port IRQ
------ ---- ----
SW1 P3.1 IRQ1
SW2 P3.3 IRQ3
SW3 P3.4 IRQ4
*/
MPC.P31PFS.BYTE = 0x40; /* P31 is used as IRQ pin */
MPC.P33PFS.BYTE = 0x40; /* P33 is used as IRQ pin */
MPC.P34PFS.BYTE = 0x40; /* P34 is used as IRQ pin */
#elif defined(PLATFORM_BOARD_RSKRX111)
/* The switches on the RSKRX210 are connected to the following pins/IRQ's
Switch Port IRQ
------ ---- ----
SW1 P3.0 IRQ0
SW2 P3.1 IRQ1
SW3 PE.4 IRQ4
*/
MPC.P30PFS.BYTE = 0x40; /* P30 is used as IRQ pin */
MPC.P31PFS.BYTE = 0x40; /* P31 is used as IRQ pin */
MPC.PE4PFS.BYTE = 0x40; /* PE4 is used as IRQ pin */
#endif
/* Set IRQ type (falling edge) */
ICU.IRQCR[SW1_IRQ_NUMBER].BIT.IRQMD = 0x01;
ICU.IRQCR[SW2_IRQ_NUMBER].BIT.IRQMD = 0x01;
ICU.IRQCR[SW3_IRQ_NUMBER].BIT.IRQMD = 0x01;
/* Set interrupt priorities which muse be below
configMAX_SYSCALL_INTERRUPT_PRIORITY. */
_IPR( X_IRQ(SW1_IRQ_NUMBER) ) = configKERNEL_INTERRUPT_PRIORITY;
_IPR( X_IRQ(SW2_IRQ_NUMBER) ) = configKERNEL_INTERRUPT_PRIORITY;
_IPR( X_IRQ(SW3_IRQ_NUMBER) ) = configKERNEL_INTERRUPT_PRIORITY;
/* Clear any pending interrupts */
_IR( X_IRQ(SW1_IRQ_NUMBER) ) = 0;
_IR( X_IRQ(SW2_IRQ_NUMBER) ) = 0;
_IR( X_IRQ(SW3_IRQ_NUMBER) ) = 0;
/* Enable the interrupts */
_IEN( X_IRQ(SW1_IRQ_NUMBER) ) = 1;
_IEN( X_IRQ(SW2_IRQ_NUMBER) ) = 1;
_IEN( X_IRQ(SW3_IRQ_NUMBER) ) = 1;
#else
/* This is based upon having 3 counts at 10Hz. */
g_sw_debounce_cnts = debounce_counts;
/* Init debounce structures. */
for (i = 0; i < SWITCHES_NUM; i++)
{
g_switches[i].active = false;
g_switches[i].debounce_cnt = 0;
}
#endif /* SWITCHES_DETECTION_MODE */
}
/* Only define interrupts in interrupt detection mode. */
#if SWITCHES_DETECTION_MODE == 0
#if defined(SW1_CALLBACK_FUNCTION)
/***********************************************************************************************************************
* Function name: sw1_isr
* Description : Sample ISR for switch 1 input (must do hardware setup first!)
* Arguments : none
* Return value : none
***********************************************************************************************************************/
#pragma interrupt (sw1_isr (vect=_VECT(X_IRQ(SW1_IRQ_NUMBER))))
static void sw1_isr (void)
{
/* TODO: Add some debouncing! */
/* Call callback function. */
SW1_CALLBACK_FUNCTION();
}
#endif /* SW1_CALLBACK_FUNCTION */
#if defined(SW2_CALLBACK_FUNCTION)
/***********************************************************************************************************************
* Function name: sw2_isr
* Description : Sample ISR for switch 2 input (must do hardware setup first!)
* Arguments : none
* Return value : none
***********************************************************************************************************************/
#pragma interrupt (sw2_isr (vect=_VECT(X_IRQ(SW2_IRQ_NUMBER))))
static void sw2_isr (void)
{
/* TODO: Add some debouncing! */
/* Call callback function. */
SW2_CALLBACK_FUNCTION();
}
#endif /* SW2_CALLBACK_FUNCTION */
#if defined(SW3_CALLBACK_FUNCTION)
/***********************************************************************************************************************
* Function name: sw3_isr
* Description : Sample ISR for switch 3 input (must do hardware setup first!)
* Arguments : none
* Return value : none
***********************************************************************************************************************/
#pragma interrupt (sw3_isr (vect=_VECT(X_IRQ(SW3_IRQ_NUMBER))))
static void sw3_isr (void)
{
/* TODO: Add some debouncing! */
/* Call callback function. */
SW3_CALLBACK_FUNCTION();
}
#endif /* SW3_CALLBACK_FUNCTION */
#endif
/* If using polling then the user must call the update function. */
/***********************************************************************************************************************
* Function name: R_SWITCHES_Update
* Description : Polls switches and calls callback functions as needed. If you are using IRQ mode then this function
* is not needed and can be removed if desired. It is left in so that code will not fail when switching
* between polling or IRQ mode.
* Arguments : none
* Return value : none
***********************************************************************************************************************/
void R_SWITCHES_Update (void)
{
#if SWITCHES_DETECTION_MODE == 1
/* This code is only needed for polling mode. */
/* Check switch 1. */
if (SW1 == SW_ACTIVE)
{
if (g_switches[0].active != true)
{
if (++g_switches[0].debounce_cnt >= g_sw_debounce_cnts)
{
/* Set this to true so we only call the callback function once per press. */
g_switches[0].active = true;
/* Call callback function. */
SW1_CALLBACK_FUNCTION();
}
}
}
else
{
if (0 == g_switches[0].debounce_cnt)
{
g_switches[0].active = false;
}
else
{
g_switches[0].debounce_cnt--;
}
}
/* Check switch 2. */
if (SW2 == SW_ACTIVE)
{
if (g_switches[1].active != true)
{
if (++g_switches[1].debounce_cnt >= g_sw_debounce_cnts)
{
/* Set this to true so we only call the callback function once per press. */
g_switches[1].active = true;
/* Call callback function. */
SW2_CALLBACK_FUNCTION();
}
}
}
else
{
if (0 == g_switches[1].debounce_cnt)
{
g_switches[1].active = false;
}
else
{
g_switches[1].debounce_cnt--;
}
}
/* Check switch 3. */
if (SW3 == SW_ACTIVE)
{
if (g_switches[2].active != true)
{
if (++g_switches[2].debounce_cnt >= g_sw_debounce_cnts)
{
/* Set this to true so we only call the callback function once per press. */
g_switches[2].active = true;
/* Call callback function. */
SW3_CALLBACK_FUNCTION();
}
}
}
else
{
if (0 == g_switches[2].debounce_cnt)
{
g_switches[2].active = false;
}
else
{
g_switches[2].debounce_cnt--;
}
}
#endif /* SWITCHES_DETECTION_MODE */
}