1.01 ・ Additions and corrections made for support of libraries for the H8/36094, H8/36077,
H8/36109, and R8C/24 and 25
・ Unnecessary periods in Chapter 1, “Instruction,” deleted
・ Port P73 of H8 deleted
・ Channels A–D written in CreateInputCapture corrected to input captures A–D
・ Error in writing “seroal” corrected to “serial”
・ Erroneous description of RAPI_70_STATES corrected
・ Error in writing of timer channel names corrected
・ Error in writing of input capture mode corrected
・ Error in writing of output compare mode corrected
・ Erroneous description of RAPI_OVERFLOW_BIT15 corrected
・ Support for R8C UART1 clock synchronous mode
・ RAPI_COUNT_CLEAR added to first arguments for the R8C and H8/300H in
__CreateInputCapture and __CreateOutputCompare
・ “External signal” deleted from the timer RD count source for the R8C in
__CreateInputCapture and __CreateOutputCompare
・ Following statements added to the item for timer RD in __SetTimerRegister and
__GetTimerRegister
・ [15]: Timer RD output master enable register 1
・ [16]: Timer RD output master enable register 2
・ [17]: Timer RD output control register
・ Explanation for clearing H8/300H module added to the description of __Create...,
__Open..., and __BasicOpen...
・ Explanation for setting H8/300H module for standby added to the description of
__Destroy..., __Close..., and BasicClose...
・ Return value in __PollingSerialReceiving changed from Boolean to unsigned int, and
explanation of return value and example program changed
・ Return value in __PollingSerialSending changed from Boolean to unsigned int, and
explanation of return value and example program changed
・ Remarks regarding use of port B on H8/300H added to __ReadIOPort and
__ReadIOPortRegister
Summary
Date
07.02.16
Rev.1.01 2007.02.16
RJJ10J1643-0101
2
・ Description of third argument in __CreateInputCapture corrected
・ Wording “specified” unified to “specified”
・ RAPI_BOTH deleted from the description of timer B1 count edges of H8/300H in
__CreateEventCounter
・ RAPI_FTIOA and RAPI_FTIOB added to __CreatePulsePeriodMeasurementMode and
__CreatePulseWidthMeasurementMode
・ All occurrences of the word “Tiny” deleted
・ Description of second argument added to __GetPulsePeriodMeasurementMode,
__GetPulseWidthMeasurementMode, and __GetEventCounter
・ Description regarding timer V trigger of H8 in __CreateTimer, __CreateEventCounter,
and __CreatePulseWidthMeasurementMode corrected
・ Explanation of H8 interrupt settings and interrupt control register settings in
__SetSerialInterrupt corrected
・ Remarks on timer V of H8/300H in __EnableTimerRegister added
・ Specification of timer RA input pins of R8C in __CreatePulsePeriodMeasurementMode
and __CreatePulseWidthMeasurementMode as well as RAPI_TIOSEL_P1_7 and
RAPI_TIOSEL_P1_5 added
・ File name in program example corrected
・ Item “Reference” in __BasicSetSerialFormat deleted
・ __BasicSetSerialFormat added to “Reference” in __SetSerialFormat and
__SetSerialInterrupt
・ Error in writing of __CreateInput Capture and __CreateOutputCapture corrected
・ Explanation added to Section 2.1, “Overview”
・ Causes of clearing of timer W and timer RC counters in __CreateInputCapture deleted
・ RAPI_COMPARE_MATCH_A_STOP and RAPI_STOP added to the item for the R8C in
__CreateOutputCompare
・ Changed to RAPI_INT_LV_0 and RAPI_INT_LV_1 for H8/300H in __SetSerialInterrupt
・ Description relating to clock in __CreateTimer corrected
・ RAPI_TRC_FILTER and RAPI_TRD_FILTER added to filter specification for H8 in
__CreatePulsePeriodMeasurementMode and __CreatePulseWidthMeasurementMode
・ RAPI_TIMER_RD2 and RAPI_TIMER_RD3 added to timer RD of H8/36109
・ Description relating to timer V trigger input for H8/300H in __CreateTimer deleted
・ Description of pulse output function added to the item for R8C in
__CreateEventCounter
Description of timer RE usage added to items data3 and data5 for R8C in
・
__CreateOutputCompare
・ Filter function of timer RC and timer RD in __CreatePulsePeriodMeasurementMode,
__CreatePulseWidthMeasurementMode, and __CreateInputCapture corrected
・ Description that multiple defined values can be set for data1 in __EnableInterrupt
added
・ Description that RAPI_WITHOUT_SAMPLE_HOLD is specifiable in delay trigger
modes 0 and 1 of M16C in __CreateADC corrected
・ Description that RAPI_FOCOF is specifiable in repeat mode of R8C in __CreateADC
corrected
Rev.1.01 2007.02.16
RJJ10J1643-0101
3
・ RAPI_AN30, RAPI_AN31, RAPI_AN32, and RAPI_P9_GROUP added to the item for
data1 of M16C in __CreateADC
・ RAPI_AN30, RAPI_AN31, RAPI_AN32, and RAPI_P9_GROUP added to the item for
data1 of M16C in __EnableADC
・ Error in writing of H8/300H interrupt set values in __CreateOutputCompare corrected
・ Error in writing of timer RD and timer RD symbol name corrected
・ Description of gate function of M16C in __CreateEventCounter deleted
・ Description of H8/300H noise rejection function in __BasicSetSerialFormat added
・ Description of timer W input pins of H8/300H in
__CreatePulsePeriodMeasurementMode and __CreatePulseWidthMeasurementMode
deleted
Rev.1.01 2007.02.16
RJJ10J1643-0101
4
Table of Contents
Table of Contents ................................................................5
The Renesas Embedded Application Programming Interface (API) is a unified API for
the microcomputers made by Renesas Technology Corporation.
Rev.1.01 2007.02.16
RJJ10J1643-0101
8
2. Driver
2.1 Overview
The library described herein provides a peripheral facility control program (peripheral
driver) for microcomputers. Use of the Renesas API permits the peripheral driver to be
built into a user program.
Configuration of Renesas APIs is shown below.
File name Description
rapi_
xxx_yyy
(
xxx
= family name,
rapi_ad_
xxx
= family name,
(
rapi_io_port_
xxx
= family name,
(
rapi_sif_
xxx
= family name,
(
rapi_timer_
xxx
= family name,
(
Interrupt_
(
xxx
= family name,
rapi_io_
xxx
= family name,
(
.lib
xxx_yyy
xxx_yyy
xxx_yyy
xxx_yyy
xxx_yyy
xxx_yyy
.h
.h
.h
yyy
= series name)
yyy
= series name)
.h
yyy
= series name)
yyy
= series name)
.h
yyy
= series name)
.h
yyy
= series name)
yyy
= series name)
This is the Renesas API library file. To use
Renesas APIs, specify this file as input file
for the linker.
This is the header file for A/D converter
driver APIs. To use A/D converter driver
APIs, be sure to include this file.
This is the header file for I/O port driver
APIs. To use I/O port driver APIs, be sure
to include this file.
This is the header file for serial I/F driver
APIs. To use serial I/F driver APIs, be sure
to include this file.
This is the header file for timer driver
APIs. To use timer driver APIs, be sure to
include this file.
This is the interrupt function source file for
Renesas APIs. To use Renesas APIs that
use interrupts, add this file to the user
program.
This is the CPU control register definition
header file for Renesas APIs.
Rev.1.01 2007.02.16
RJJ10J1643-0101
9
2.2 Driver Features
The library described herein has the following features available as a peripheral driver.
(1) Serial I/O control feature
It comprises a serial interface driver, which sets or clears the conditions of serial
communication, as well as controls and manages the transmission/reception of
communication data.
(2) Timer control feature
It comprises a timer driver, which sets or clears the operating conditions of timers,
as well as controls the timer operation.
(3) I/O port control feature
It comprises an I/O port driver, which sets or clears the usage conditions of I/O ports, as
well as control data read/write operation.
(4) External interrupt control feature
It comprises an external interrupt driver, which sets or clears the usage conditions of
external interrupts, as well as controls interrupt operation.
(5) A/D converter control feature
It comprises an A/D converter driver, which sets or clears the usage conditions of A/D
converters, as well as controls A/D converter operation.
Rev.1.01 2007.02.16
RJJ10J1643-0101
10
2.3 Serial Interface Driver
The serial interface driver sets serial communication, clears settings, transmit/receives
data, and controls the status of serial communication.
There are two kinds of serial interface driver: a single-data transmission/reception API
and a multi-data transmission/reception API.
Rev.1.01 2007.02.16
RJJ10J1643-0101
11
2.4 Timer Driver
The timer driver sets the timer, clears timer settings, controls timer operation, and
acquires a counter value with respect to the following modes:
• Timer mode
• Event counter mode
• Pulse width modulation mode (PWM mode)
• Pulse period measurement mode
• Pulse width measurement mode
• Input capture mode
• Output compare mode
2.4.1 Timer Mode
In this mode, the timer counts the internally generated count source. When an
underflow or an overflow interrupt occurs, it calls a preset callback function.
2.4.2 Event Counter Mode
In this mode, the timer counts the external signal fed in from an input pin or an
overflow or underflow from other timer. When an underflow or an overflow interrupt
occurs, it calls a preset callback function.
2.4.3 Pulse Width Modulation Mode (PWM Mode)
In this mode, the timer outputs pulses in a given width successively. When an
underflow or an overflow interrupt occurs, it calls a preset callback function.
2.4.4 Pulse Period Measurement Mode
In this mode, the timer measures the pulse period of an external signal fed in from an
input pin. When an underflow or an overflow interrupt occurs, it calls a preset callback
function.
2.4.5 Pulse Width Measurement Mode
In this mode, the timer measures the pulse width of an external signal fed in from an
input pin. When an underflow or an overflow interrupt occurs, it calls a preset callback
function.
2.4.6 Input Capture Mode
In this mode, the timer latches the timer value upon an active signal edge or clock
pulse at an input pin, thereby generating an interrupt request. When an input capture
interrupt or an underflow or an overflow interrupt occurs, it calls a preset callback
function.
Rev.1.01 2007.02.16
RJJ10J1643-0101
12
2.4.7 Output Compare Mode
In this mode, the timer generates an interrupt request when the timer counter and a
comparison value match. When a compare match interrupt or an underflow or an
overflow interrupt occurs, it calls a preset callback function.
Rev.1.01 2007.02.16
RJJ10J1643-0101
13
2.5 I/O Port Driver
The I/O port driver sets the I/O port for input or output, writes data to the I/O port, and
reads data from the I/O port.
Rev.1.01 2007.02.16
RJJ10J1643-0101
14
2.6 External Interrupt Driver
The external interrupt driver sets external interrupts, controls external interrupts,
acquires the status of external interrupt flags, and clears external interrupt flags.
Rev.1.01 2007.02.16
RJJ10J1643-0101
15
2.7 A/D Converter Driver
_
_
_
_
_
The A/D converter driver sets the A/D converter, controls the A/D converter, clears
settings of the A/D converter, acquires the A/D converter value, acquires the status of the
A/D converter, and clears the status of the A/D converter.
[A/D converter driver usage example (single-shot mode)]
Here, a program example is shown for the A/D converter operating in single-shot mode
under the conditions given below.
CPU :R8C
Operating clock :fAD divided by 2
Resolution :10 bits
Analog input pin :AN0 pin
A/D conversion start condition :Software trigger
Sample-and-hold :Enabled
A program flow and a program example are shown below.
/* Check a flag bit of A/D converter interrupt */
do{
__GetADCStatus( &status );
} while( (*status & 0x0001) == 0 )
/* Get A/D convertered datas of A/D register */
__GetADC( &data );
/* Clear status of A/D convertered */
__ClearADCStatus( 0 );
}
}
CreateADC( RAPI_ONE_SHOT|RAPI_AN0|RAPI_FAD2|
Rev.1.01 2007.02.16
RJJ10J1643-0101
17
3. Standard Types
This section describes the standard types defined in the library. For details about the
set values, refer to the description of each API.
Standard type Description
Boolean
VoidF un cN ot if y
The Boolean type represents the enum-type data that indicates
whether successful (RAPI_TRUE (= 1)) or failed (RAPI_FALSE (=
0)).
The VoidFuncNotify type represents the type of the notification
function to be registered.
Rev.1.01 2007.02.16
RJJ10J1643-0101
18
4. Library Reference
4.1 API List by Peripheral Facility
The table below lists the Renesas Embedded APIs classified by peripheral facility.
NO Facility
classification
Single-data
1 __BasicOpenSerialDriver
serial I/O
2 __BasicCloseSerialDriver
3 __BasicSetSerialFormat
4 __BasicStartSerialReceiving
5 __BasicStartSerialSending
6 __BasicReceivingStatusRead
7 __BasicSendingStatusRead
8 __BasicStopSerialReceiving
9
Multi-data
10 __OpenSerialDriver
serial I/O
11 __CloseSerialDriver
12 __ConfigSerialDriverNotify
13 __SetSerialFormat
14 __SetSerialInterrupt
15 __StartSerialReceiving
16 __StartSerialSending
17 __StopSerialReceiving
18 __StopSerialSending
19 __PollingSerialReceiving
20
Timer
21 __CreateTimer
22 __EnableTimer
23 __DestroyTimer
24 __CreateEventCounter
25 __EnableEventCounter
26 __DestroyEventCounter
27 __GetEventCounter
28 __CreatePulseWidthModulationMode
29 __EnablePulseWidthModulationMode
30 __DestroyPulseWidthModulationMode
31 __CreatePulsePeriodMeasurementMode
32 __EnablePulsePeriodMeasurementMode
33 __DestroyPulsePeriodMeasurementMode
34
__BasicStopSerialSending
__PollingSerialSending
__GetPulsePeriodMeasurementMode
API API operation
Opens serial port
Closes serial port
Sets serial communication
Receives 1 data
Transmits 1 data
Reads receive status
Reads transmit status
Stops reception
Stops transmission
Opens serial port
Closes serial port
Registers notification function
Sets serial communication
Sets transmit/receive interrupt
Starts reception
Starts transmission
Stops reception
Stops transmission
Receives by polling
Transmits by polling
Sets timer mode
Controls timer mode operation
Clears timer mode setting
Sets event counter mode
Controls operation of event counter
mode
Clears setting of event counter
mode
Gets event counter mode counter
value
Sets pulse width modulation mode
Controls operation of pulse width
modulation mode
Clears setting of pulse width
modulation mode
Sets pulse period measurement
mode
Controls operation of pulse period
measurement mode
Clears setting of pulse width
measurement mode
Acquires measured value of pulse
period measurement mode
Rev.1.01 2007.02.16
RJJ10J1643-0101
19
35 __CreatePulseWidthMeasurementMode
36 __EnablePulseWidthMeasurementMode
Timer
37 __DestroyPulseWidthMeasurementMode
38 __GetPulseWidthMeasurementMode
39 __CreateInputCapture
40 __EnableInputCapture
41 __DestroyInputCapture
42 __GetInputCapture
43 __CreateOutputCompare
44 __EnableOutputCompare
45 __DestroyOutputCompare
46 __SetTimerRegister
47 __EnableTimerRegister
48 __ClearTimerRegister
49
I/O port
50 __SetIOPort
51 __ReadIOPort
52 __WriteIOPort
53 __SetIOPortRegister
54 __ReadIOPortRegister
55
External
56 __SetInterrupt
interrupt
57 __EnableInterrupt
58 __GetInterruptFlag
59
A/D converter
60 __CreateADC
61 __EnableADC
62 __DestroyADC
63 __GetADC
64 __GetADCAll
65 __GetADCStatus
66
__GetTimerRegister
__WriteIOPortRegister
__ClearInterruptFlag
__ClearADCStatusClears status of A/D converter
Sets pulse width measurement
mode
Controls operation of pulse width
measurement mode
Clears setting of pulse width
measurement mode
Acquires measured value of pulse
width measurement mode
Sets input capture mode
Controls operation of input capture
mode
Clears setting of input capture mode
Acquires counter value of input
capture mode
Sets output compare mode
Controls operation of output
compare mode
Clears setting of output compare
mode
Sets timer register
Controls operation of timer register
Clears timer register
Gets timer register value
Sets I/O port
Reads from I/O port
Writes to I/O port
Sets I/O port register
Reads from I/O port register
Writes to I/O port register
Sets external interrupt
Controls external interrupt
Gets flag status of external interrupt
Clears flag of external interrupt
Sets A/D converter
Controls operation of A/D converter
Discards settings of A/D converter
Gets A/D conversion value (register
specified)
Gets A/D conversion value (all
registers)
Gets status of A/D converter
Rev.1.01 2007.02.16
RJJ10J1643-0101
20
4.2 Description of Each API
This section describes each API and explains how to use them, showing a program
example for each.
The description of each API is divided into the following items.
• Synopsis
• Description
• Return value
• Functionality
• Reference
• Remark
• Program example
: Outlines the content of processing performed by the function. It
also shows the syntax of the function, followed by a brief
explanation of arguments.
: Describes the function and how to use it in detail.
: Explains the returned value of the function.
: Indicates the functional classification of the function.
: Indicates the related functions.
: Describes the precautions to be taken when using the API.
: Presents a program showing how to use the function.
Rev.1.01 2007.02.16
RJJ10J1643-0101
21
4.2.1 Serial I/O
__BasicOpenSerialDriver
Synopsis
Description
For data, the following values can be set.
(M16C)
(R8C)
(H8/300H)
Return value
Functionality
Reference
Remark
<Open a serial port>
Boolean __BasicOpenSerialDriver(unsigned long data)
data Setup data
Opens and initializes a specified serial port.
RAPI_COM1 UART0 RAPI_COM2 UART1
RAPI_COM3 UART2 RAPI_COM4 SI/O3
RAPI_COM5 SI/O4
RAPI_COM1 UART0 RAPI_COM2 UART1
RAPI_COM1 SCI3 channel 1 RAPI_COM2 SCI3 channel 2
RAPI_COM3 SCI3 channel 3
If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise,
RAPI_TRUE is returned.
Serial I/O
__BasicCloseSerialDriver
The specifiable serial ports differ with each CPU used.
•
If an undefined value is specified in the argument, operation of the API cannot be
•
guaranteed.
When used for the H8/300H, this API opens and initializes a specified serial port
•
when freeing it from module standby state.
Program example
#include ”rapi_sif_r8c_13.h”
void func( void )
{
/* Open serial driver */
return __BasicOpenSerialDriver( RAPI_COM1 );
}
Rev.1.01 2007.02.16
RJJ10J1643-0101
22
__BasicCloseSerialDriver
Synopsis
Description
(R8C)
(H8/300H)
<Close a serial port>
Boolean __BasicCloseSerialDriver(unsigned long data)
data Setup data
Closes a specified serial port. For data, the following values can be set.
(M16C)
RAPI_COM1 UART0 RAPI_COM2 UART1
RAPI_COM3 UART2 RAPI_COM4 SI/O3
RAPI_COM5 SI/O4
RAPI_COM1 UART0 RAPI_COM2 UART1
RAPI_COM1 SCI3 channel 1 RAPI_COM2 SCI3 channel 2
RAPI_COM3 SCI3 channel 3
Return value
Functionality
Reference
If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise,
RAPI_TRUE is returned.
Serial I/O
__BasicOpenSerialDriver
The specifiable serial ports differ with each CPU used.
Remark
•
If an undefined value is specified in the argument, operation of the API cannot be
•
guaranteed.
When used for the H8/300H, this API places a specified serial port into module
•
standby state after closing it.
Program example
#include ”rapi_sif_r8c_13.h”
void func( void )
{
/* Close serial driver */
return Rapi_BasicCloseSerialDriver( RAPI_COM1 );
}
Rev.1.01 2007.02.16
RJJ10J1643-0101
23
__BasicSetSerialFormat
Synopsis
Description
<Set serial communication>
Boolean __BasicSetSerialFormat(unsigned long data1, unsigned char data2)
data1 Setup data 1
data2 Setup data 2
Sets serial communication according to specified parameters.
[data1]
For data1, the following values can be set. To set multiple definition values at the same
time, use the symbol “|” to separate each specified value.
(M16C)
RAPI_COM1 UART0 RAPI_COM2 UART1
RAPI_COM3 UART2 RAPI_COM4 SI/O3
RAPI_COM5 SI/O4
For serial communication mode, the following values can be set.
(M16C) (UART0, UART1, UART2)
RAPI_SM_SYNC
RAPI_SM_ASYNC
(M16C)(SI/O3, SI/O4)
RAPI_SIO_SM_SYNC
For the data length format of clock asynchronous serial communication, the following
values can be set.
If the API is used in clock synchronous serial communication mode, do not set these
values.
(M16C) (UART0, UART1, UART2)
RAPI_BIT_7 Transfer data length 7 bitsRAPI_BIT_8 Transfer data length 8 bits
RAPI_BIT_9 Transfer data length 9 bits
For the clock source of serial communication, the following values can be set.
(M16C) (UART0, UART1, UART2)
RAPI_CKDIR_INT Internal clock is used as the clock source of serial communication.
RAPI_CKDIR_EXT External clock is used as the clock source of serial communication.
(M16C) (SI/O3, SI/O4)
RAPI_SIO_CKDIR_INTInternal clock is used as the clock source of serial communication.
RAPI_SIO_CKDIR_EXTExternal clock is used as the clock source of serial communication.
For the stop bit length of clock asynchronous serial communication, the following
values can be set.
If the API is used in clock synchronous serial communication mode, do not set these
values.
(M16C) (UART0, UART1, UART2)
RAPI_STPB_1 1 stop bit RAPI_STPB_2 2 stop bits
For the parity bit of clock asynchronous serial communication, the following values can
be set.
Clock synchronous serial communication mode
Clock asynchronous serial communication mode
Clock synchronous serial communication mode
Rev.1.01 2007.02.16
RJJ10J1643-0101
24
If the API is used in clock synchronous serial communication mode, do not set these
values.
(M16C) (UART0, UART1, UART2)
RAPI_PARITY_NONNo parity bit RAPI_PARITY_EVEN Even parity bit
RAPI_PARITY_ODDOdd parity bit
For the clock polarity of serial communication, the following values can be set.
If the API is used in clock asynchronous serial communication mode, do not set these
values.
(M16C) (UART0, UART1, UART2)
RAPI_DPOL_NON Polarity not invertedRAPI_DPOL_INV Polarity inverted
(M16C) (SI/O3, SI/O4)
RAPI_SIO_DPOL_NONPolarity not invertedRAPI_SIO_DPOL_INV Polarity inverted
For the count source of the built-in baud rate generator, the following values can be set.
(M16C) (UART0, UART1, UART2)
RAPI_BCSS_F1 f1SIO RAPI_BCSS_F2 f2SIO
RAPI_BCSS_F8 f8SIO RAPI_BCSS_F32 f32SIO
(M16C) (SI/O3, SI/O4)
RAPI_SIO_BCSS_F1f1SIO RAPI_SIO_BCSS_F2 f2SIO
RAPI_SIO_BCSS_F8f8SIO RAPI_SIO_BCSS_F32 f32SIO
For the _CTS/_RTS function, the following values can be set.
If the internal clock is selected for use in clock synchronous serial communication
mode, the _RTS function has no effect.
(M16C) (UART0, UART1, UART2)
RAPI_CTSRTS_DIS _CTS/_RTS functions are not used.
RAPI_CTS_SEL _CTS function is selected.
RAPI_RTS_SEL _RTS function is selected.
For the transfer format, the following values can be set.
If the data length selected for use in clock asynchronous serial communication mode is
7 or 9 bits long, do not set these values.
(M16C) (UART0, UART1, UART2)
RAPI_LSB_SEL LSB first RAPI_MSB_SEL MSB first
(M16C) (SI/O3, SI/O4)
RAPI_SIO_LSB_SEL LSB first RAPI_SIO_MSB_SEL MSB first
For serial data logic switchover, the following values can be set.
(M16C) (UART2)
RAPI_LOGIC_NO_REV
RAPI_LOGIC_REV The value written in the transmit buffer register is inverted before
(R8C)
RAPI_COM1 UART0 RAPI_COM2 UART1
For serial communication mode, the following values can be set.
The value written in the transmit buffer register does not have its
logic inverted.
being transmitted.
Rev.1.01 2007.02.16
RJJ10J1643-0101
25
(R8C) (UART0, UART1)
RAPI_SM_SYNC
RAPI_SM_ASYNC
For the data length format of clock asynchronous serial communication, the following
values can be set.
If the API is used in clock synchronous serial communication mode, do not set these
values.
(R8C) (UART0, UART1)
RAPI_BIT_7 Transfer data length 7 bitsRAPI_BIT_8 Transfer data length 8 bits
RAPI_BIT_9 Transfer data length 9 bits
For the clock source of serial communication, the following values can be set.
(R8C) (UART0, UART1)
RAPI_CKDIR_INT Internal clock is used as the clock source of serial communication.
RAPI_CKDIR_EXT External clock is used as the clock source of serial communication.
For the stop bit length of clock asynchronous serial communication, the following
values can be set.
If the API is used in clock synchronous serial communication mode, do not set these
values.
(R8C) (UART0, UART1)
RAPI_STPB_1 1 stop bit RAPI_STPB_2 2 stop bits
For the parity bit of clock asynchronous serial communication, the following values can
be set.
If the API is used in clock synchronous serial communication mode, do not set these
values.
(R8C) (UART0, UART1)
RAPI_PARITY_NON No parity bit RAPI_PARITY_EVEN Even parity bit
RAPI_PARITY_ODD Odd parity bit
For the clock polarity of serial communication, the following values can be set.
If the API is used in clock asynchronous serial communication mode, do not set these
values.
(R8C) (UART0, UART1)
RAPI_DPOL_NON Polarity not invertedRAPI_DPOL_INV Polarity inverted
For the count source of the built-in baud rate generator, the following values can be set.
(R8C) (UART0, UART1)
RAPI_BCSS_F1 f1SIO RAPI_BCSS_F8 f8SIO
RAPI_BCSS_F32 f32SIO
For the transfer format, the following values can be set.
If the data length selected for use in clock asynchronous serial communication mode is
7 or 9 bits long, do not set these values.
(R8C) (UART0, UART1)
RAPI_LSB_SEL LSB first RAPI_MSB_SEL MSB first
(H8/300H)
RAPI_COM1 SCI3 channel 1 RAPI_COM2 SCI3 channel 2
Clock synchronous serial communication mode
Clock asynchronous serial communication mode
Rev.1.01 2007.02.16
RJJ10J1643-0101
26
Return value
RAPI_COM3 SCI3 channel 3
For serial communication mode, the following values can be set.
The noise rejection function can be set to be turned on or turned off.
When used in clock synchronous serial communication mode, the noise rejection
function has no effect.
(H8/300H) (SCI3 channel 3)
RAPI_NOISE_CANCEL_ON Noise rejection function turned on
RAPI_NOISE_CANCEL_OFF Noise rejection function turned off
[data2]
Sets the divide-by-N value of a communication speed.
If serial communication was successfully set, RAPI_TRUE is returned; if settings failed,
RAPI_FALSE is returned.
Clock synchronous serial communication mode
Clock asynchronous serial communication mode
Rev.1.01 2007.02.16
RJJ10J1643-0101
27
Functionality
Remark
Program example
Serial I/O
The specifiable serial ports differ with each CPU used.
•
If an undefined value is specified in the first argument, operation of the API cannot
•
be guaranteed.
#include ”rapi_sif_r8c_13.h”
Boolean func( void )
{
/* Set the data of RAPI_COM1 to serial driver */
return _BasicSetSerialFormat(RAPI_COM1 | RAPI_SM_SYNC | RAPI_CKDIR_INT
|
RAPI_BCSS_F 1 | RAPI_DPOL_NON | RAPI_LSB_SEL,
20);
}
Rev.1.01 2007.02.16
RJJ10J1643-0101
28
__BasicStartSerialReceiving
Synopsis
Description
Return value
Functionality
Reference
Remark
<Receive 1 data>
Boolean __BasicStartSerialReceiving(unsigned long data)
data Setup data
Starts receiving 1 data of serial communication.
[data]
For data, the following values can be set.
(M16C)
RAPI_COM1 UART0 RAPI_COM2 UART1
RAPI_COM3 UART2 RAPI_COM4 SI/O3
RAPI_COM5 SI/O4
(R8C)
RAPI_COM1 UART0 RAPI_COM2 UART1
(H8/300H)
RAPI_COM1 SCI3 channel 1 RAPI_COM2 SCI3 channel 2
RAPI_COM3 SCI3 channel 3
If data reception in serial communication was successfully started, RAPI_TRUE is