User`s manual

RX62N Group, RX621 Group 5. Usage Examples
5.15. Serial Peripheral Interface
5.15.1. Using one slave (1)
This is an example of Serial Peripheral Interface usage where one SPI master communicates with one SPI
slave.
The RSK evaluation board is used to connect the two SPI channels together.
Figure 5-35 shows how four 32-bit words are transmitted and received simultaneously by the master and slave.
The received data is then checked to confirm that the transfer was successful.
/* Peripheral driver function prototypes */
#include "r_pdl_cgc.h"
#include "r_pdl_spi.h"
/* PDL device-specific definitions */
#include "r_pdl_definitions.h"
void spi_slave_callback(void);
volatile bool slave_transfer_complete;
#define SLAVE_CHANNEL 0
#define MASTER_CHANNEL 1
void main(void)
{
const uint32_t master_0_tx_data[4] = \
{
0x00000001,
0x98765432,
0xABCDEF34,
0x12345678
};
uint32_t master_0_rx_data[4] = \
{
0x00000000,
0x00000000,
0x00000000,
0x00000000
};
const uint32_t slave_0_tx_data[4] = \
{
0x32323232,
0x3456789A,
0xDEADBEEF,
RSPCKB-A
MOSIB-A
MISOB-A
SSLB1-A
SSLA0-A
MISOA-A
MOSIA-A
RSPCKA-A
RX62N MCU
SPI channel 1
(master)
SPI channel 0
(slave)
R20UT0084EE0112 Rev.1.12 Page 5-62
July. 16, 2014