User`s manual

RX62N Group, RX621 Group 5. Usage Examples
5. Usage Examples
This chapter shows programming examples for each driver in this library.
5.1. Interrupt control
Figure 5-1 shows an example of external interrupt use.
Pin IRQ0-A is used to detect a falling edge and generates an interrupt.
Pin IRQ1-B is used to detect a falling edge and is polled.
Pin IRQ2-A is used to detect a low-level signal and generates an interrupt. Further interrupts are prevented until
the signal has returned to the high level.
/* Peripheral driver function prototypes */
#include "r_pdl_intc.h"
#include "r_pdl_io_port.h"
/* RPDL device-specific definitions */
#include "r_pdl_definitions.h"
volatile uint8_t switch_sw1_pressed;
volatile uint8_t irq2_low;
/* Callback function prototypes */
void IRQ0Handler(void);
void IRQ0Handler(void);
static void ReEnableIRQ2(void);
void main(void)
{
uint8_t irq_status;
/* Set the CPU’s Interrupt Priority Level to 0 */
R_INTC_Write(
PDL_INTC_REG_IPL,
0
);
/* Configure the IRQ0 interrupt on pin IRQ0-A */
R_INTC_CreateExtInterrupt(
PDL_INTC_IRQ0,
PDL_INTC_FALLING | PDL_INTC_A,
IRQ0Handler,
7
);
/* Configure the IRQ1 interrupt on pin IRQ1-B */
R_INTC_CreateExtInterrupt(
PDL_INTC_IRQ1,
PDL_INTC_FALLING | PDL_INTC_B,
PDL_NO_FUNC,
0
);
/* Configure the IRQ2 interrupt on pin IRQ2-A */
R_INTC_CreateExtInterrupt(
PDL_INTC_IRQ2,
PDL_INTC_LOW | PDL_INTC_A,
IRQ2Handler,
7
);
irq2_low = false;
while(1)
{
R20UT0084EE0112 Rev.1.12 Page 5-1
July. 16, 2014