User`s manual
RX62N Group, RX621 Group 5. Usage Examples
5.2. I/O Port
Figure 5-2 shows examples of I/O port configuration, reading and writing.
/* Peripheral driver function prototypes */
#include "r_pdl_io_port.h"
#include "r_pdl_pfc.h"
/* RPDL device-specific definitions */
#include "r_pdl_definitions.h"
void main(void)
{
uint8_t result;
uint8_t direction;
uint8_t output;
/* Configure port 4 as an input */
R_IO_PORT_Set(
PDL_IO_PORT_4,
PDL_IO_PORT_INPUT | PDL_IO_PORT_INPUT_BUFFER_ON
);
/* Configure port pin P21 as an open-drain output */
R_IO_PORT_Set(
PDL_IO_PORT_2_1,
PDL_IO_PORT_OUTPUT | PDL_IO_PORT_OPEN_DRAIN
);
/* Write 0x44 to register PFC2 */
R_PFC_Write(
2,
0x44
);
/* Read the value of all the pins on port 4 */
R_IO_PORT_Read(
PDL_IO_PORT_4,
&result
);
/* Set pin P21 to output high */
R_IO_PORT_Write(
PDL_IO_PORT_2_1,
1
);
/* Invert pin P21 */
R_IO_PORT_Modify(
PDL_IO_PORT_2_1,
PDL_IO_PORT_XOR,
1
);
/* And the value on port 4 with 55h */
R_IO_PORT_Modify(
PDL_IO_PORT_4,
PDL_IO_PORT_AND,
0x55
);
/* Read the output type for port PC */
R_IO_PORT_ReadControl(
PDL_IO_PORT_1,
PDL_IO_PORT_TYPE,
&output
);
R20UT0084EE0112 Rev.1.12 Page 5-3
July. 16, 2014