User`s manual
RX62N Group, RX621 Group 5. Usage Examples
5.15.3. Master operation with multiple slaves
This is an example of Serial Peripheral Interface usage where one SPI master communicates with four SPI
slaves. Each slave requires different data bit lengths.
Figure 5-37 shows how data of appropriate bit lengths is transferred to each SPI slave.
Commands 0 to 3 are executed in sequence, with each command asserting the appropriate SSL pin.
/* Peripheral driver function prototypes */
#include "r_pdl_cgc.h"
#include "r_pdl_spi.h"
/* PDL device-specific definitions */
#include "r_pdl_definitions.h"
#define MASTER_CHANNEL 1
void main(void)
{
const uint32_t master_tx_data[4] = \
{
0x000000A4, /* 8-bit data */
0x00000132, /* 9-bit data */
0x00007F34, /* 15-bit data */
0x00345678 /* 24-bit data */
};
uint32_t master_rx_data[4] = \
{
0x00000000,
0x00000000,
RSPCKB-A
MOSIB-A
MISOB-A
SSLB0-A
SSLB1-A
SSLB2-A
SSLB3-A
Master
SPI channel 1
Slave 0
(8-bit data words)
RSPCK
MOSI
MISO
SSL
Slave 1
(9-bit data words)
RSPCK
MOSI
MISO
SSL
Slave 2
(15-bit data words)
RSPCK
MOSI
MISO
SSL
Slave 3
(24-bit data words)
RSPCK
MOSI
MISO
SSL
R20UT0084EE0112 Rev.1.12 Page 5-68
July. 16, 2014