Page 1
On April 1 , 2010, NEC Electronics Corporation merged with Renesas Technology Corporation, and Renesas Electronics Corporation took over all the business of both companies. Therefore, although the old company name remains in this document, it is a valid Renesas Electronics document. We appreciate your understanding.
Page 2
Renesas Electronics. Renesas Electronics shall not be in any way liable for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for an application categorized as “Specific”...
1. Introduction The Renesas Embedded Application Programming Interface (API) is a unified API for the microcomputers made by Renesas Technology Corporation. Rev.1.00 2007.11.1 REC10B0002-0100...
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. 2.2 Driver Features The library described herein has the following features available as a peripheral driver.
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.00 2007.11.1 REC10B0002-0100...
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) •...
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.00 2007.11.1 REC10B0002-0100...
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. Rev.1.00 2007.11.1 REC10B0002-0100...
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 The Boolean type represents the enum-type data that indicates whether successful (RAPI_TRUE (= 1)) or failed (RAPI_FALSE (= 0)).
4. Library Reference 4.1 API List by Peripheral Facility The table below lists the Renesas Embedded APIs classified by peripheral facility. Facility classification Single-data __BasicOpenSerialDriver serial I/O __BasicCloseSerialDriver __BasicSetSerialFormat __BasicStartSerialReceiving __BasicStartSerialSending __BasicReceivingStatusRead __BasicSendingStatusRead __BasicStopSerialReceiving __BasicStopSerialSending Multi-data __OpenSerialDriver serial I/O __CloseSerialDriver...
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. Outlines the content of processing performed by the function. It •...
4.2.1 Serial I/O __BasicOpenSerialDriver Synopsis <Open a serial port> Boolean __BasicOpenSerialDriver(unsigned long data) data Description Opens and initializes a specified serial port. For data, the following values can be set. RAPI_COM1 RAPI_COM3 RAPI_COM5 Return value If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned.
__BasicCloseSerialDriver Synopsis <Close a serial port> Boolean __BasicCloseSerialDriver(unsigned long data) data Description Closes a specified serial port. For data, the following values can be set. RAPI_COM1 RAPI_COM3 RAPI_COM5 Return value If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned.
__BasicSetSerialFormat Synopsis <Set serial communication> Boolean __BasicSetSerialFormat(unsigned long data1, unsigned char data2) data1 data2 Sets serial communication according to specified parameters. Description [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. RAPI_COM1 RAPI_COM3 RAPI_COM5...
Page 21
If the API is used in clock synchronous serial communication mode, do not set these values. (UART0, UART1, UART2) RAPI_PARITY_NON RAPI_PARITY_ODD 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.
Page 22
If serial communication was successfully set, RAPI_TRUE is returned; if settings failed, RAPI_FALSE is returned. Functionality Serial I/O Reference • Remark If an undefined value is specified in the first argument, operation of the API cannot be guaranteed. Program example #include ”rapi_sif_m16c_62p”...
__BasicStartSerialReceiving Synopsis <Receive 1 data> Boolean __BasicStartSerialReceiving(unsigned long data) data Description Starts receiving 1 data of serial communication. [data] For data, the following values can be set. RAPI_COM1 RAPI_COM3 RAPI_COM5 If data reception in serial communication was successfully started, RAPI_TRUE is Return value returned;...
__BasicStartSerialSending Synopsis <Transmit 1 data> Boolean _BasicStartSerialSending(unsigned long data1, unsigned int data2) data data Starts sending 1 data of serial communication. Description For data1, the following values can be set. RAPI_COM1 RAPI_COM3 RAPI_COM5 If data transmission in serial communication was successfully started, RAPI_TRUE is Return value returned;...
__BasicReceivingStatusRead Synopsis <Read receive status> unsigned int __BasicReceivingStatusRead(unsigned long data) data Description Returns the receive status of serial communication. [data] For data, the following values can be set. RAPI_COM1 RAPI_COM3 RAPI_COM5 The receive status of serial communication is returned. The returned value is one of Return value the following.
__BasicSendingStatusRead Synopsis <Read transmit status> Boolean __BasicSendingStatusRead(unsigned long data) data Description Returns the transmit status of serial communication. For data, the following values can be set. RAPI_COM1 RAPI_COM3 RAPI_COM5 Return value If no data exists in the transmit buffer, RAPI_TRUE is returned; if data exists, RAPI_FALSE is returned.
__BasicStopSerialReceiving Synopsis <Stop reception> Boolean Rapi_BasicStopSerialReceiving(unsigned long data) data Description Stops receiving data in serial communication [data] For data, the following values can be set. RAPI_COM1 RAPI_COM3 Return value If data reception in serial communication was successfully stopped, RAPI_TRUE is returned;...
__BasicStopSerialSending Synopsis <Stop transmission> Boolean __BasicStopSerialSending(unsigned long data) data Description Stops transmitting data in serial communication. [data] For data, the following values can be set. RAPI_COM1 RAPI_COM3 Return value If data transmission in serial communication was successfully stopped, RAPI_TRUE is returned;...
__OpenSerialDriver Synopsis <Open a serial port> Boolean __OpenSerialDriver(unsigned long data) data Description Opens and initializes a specified serial port. [data] For data, the following values can be set. RAPI_COM1 RAPI_COM3 RAPI_COM5 If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise, Return value RAPI_TRUE is returned.
__CloseSerialDriver Synopsis <Close a serial port> Boolean __CloseSerialDriver(unsigned long data) data Description Closes a specified serial port. [data] For data, the following values can be set. RAPI_COM1 RAPI_COM3 RAPI_COM5 If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise, Return value RAPI_TRUE is returned.
__ConfigSerialDriverNotify Synopsis <Register a notification function> Boolean __ConfigSerialDriverNotify(unsigned long data, VoidFuncNotify *func) data func Registers the notification function necessary to get various transmit/receive information Description of serial communication. [data] For data, the following values can be set. RAPI_COM1 RAPI_COM3 RAPI_COM5 [func] The function to be registered in func must be supplied to the serial I/O driver by the user.
Page 32
Return value If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned. Functionality Serial I/O Reference __StartSerialReceiving, • If an undefined value is specified in the first argument, operation of the API cannot Remark be guaranteed. Program example #include ”rapi_sif_m16c_62p”...
__SetSerialFormat Synopsis <Set serial communication> Boolean __SetSerialFormat(unsigned long data1, unsigned char data2) data1 data2 Sets serial communication according to specified parameters. Description For details about parameters, refer to the description of __BasicSetSerialFormat. If serial communication was successfully set, RAPI_TRUE is returned; if settings failed, Return value RAPI_FALSE is returned.
__SetSerialInterrupt Synopsis <Set serial interrupts> Boolean __SetSerialInterrupt(unsigned long data) data Description Sets serial interrupts according to specified parameters. [data] For data, the following values can be set. RAPI_COM1 RAPI_COM3 RAPI_COM5 For interrupt settings, the following values can set. (UART0, UART1, UART2) RAPI_INT_TX_DIS RAPI_INT_TX_LV_1 RAPI_INT_TX_LV_2...
Page 35
Serial I/O Functionality Reference • Remark If an undefined value is specified in the argument, operation of the API cannot be guaranteed. Program example #include ”rapi_sif_m16c_62p” Boolean func( void ) /* Set interrupt of RAPI_COM1 to serial driver */ return __SetSerialInterrupt( Rev.1.00 2007.11.1...
__StartSerialReceiving Synopsis <Start reception> Boolean __StartSerialReceiving(unsigned long data, unsigned char wordNum, unsigned int *RcvDtBuf) data wordNum RcvDtBuf Description Starts reception of serial communication and gets received data by a specified number of words. When acquisition of received data is complete, this API calls a notification function (if a notification function is registered).
__StartSerialSending Synopsis <Start transmission> Boolean __StartSerialSending(unsigned long data, unsigned char wordNum, unsigned int *SndDtBuf) data wordNum SndDtBuf Description Starts transmission of serial communication and writes transmit data to the transmit buffer by a specified number of words. When transmission of all transmit data is complete, this API calls a notification function (if a notification function is registered).
__StopSerialReceiving Synopsis <Stop reception> Boolean __StopSerialReceiving(unsigned long data) data Description Stops reception of serial communication. [data] For data, the following values can be set. RAPI_COM1 RAPI_COM3 Return value If reception of serial communication was successfully stopped, RAPI_TRUE is returned; if failed, RAPI_FALSE is returned. Functionality Serial I/O __StartSerialReceiving...
__StopSerialSending Synopsis <Stop transmission> Boolean __StopSerialSending(unsigned long data) data Description Stops transmission of serial communication. [data] For data, the following values can be set. RAPI_COM1 RAPI_COM3 Return value If transmission of serial communication was successfully stopped, RAPI_TRUE is returned; if failed, RAPI_FALSE is returned. Functionality Serial I/O __StartSerialReceiving...
__PollingSerialReceiving Synopsis <Polling reception> Boolean __PollingSerialReceiving(unsigned long data) data Description Performs reception of serial communication by polling. This API gets received data by an amount specified by __StartSerialReceiving. When acquisition of received data is complete, it calls a notification function (if a notification function is registered). [data] For data, the following values can be set.
__PollingSerialSending Synopsis <Polling transmission> Boolean __PollingSerialSending(unsigned long data) data Description Performs transmission of serial communication by polling. This API sends transmit data by an amount specified by __StartSerialSending from the transmit data buffer specified by __StartSerialSending. When transmission of all transmit data is complete, it calls a notification function (if a notification function is registered).
4.2.2 Timer __CreateTimer Synopsis <Set timer mode> Boolean __CreateTimer(unsigned long data1, unsigned int data2, unsigned int data3, unsigned int data4, void* func) data1 data2 data3 data4 func Description Sets a specified timer to timer mode. [data1] For data1, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
Page 43
(Count source) (Operating states set) (Pulse output state) (Gate facility) • Specifiable definition values when timer B is used (RAPI_TIMER_B0 to RAPI_TIMER_B5 specified) (Count source) (Operating states set) [data2] Specify the interrupt priority level (0–7) to be set in the interrupt control register. [data3] Specify the value to be set in the timer register in 16 bits.
__EnableTimer Synopsis <Control operation of timer mode> Boolean __EnableTimer(unsigned long data) data Description Controls operation of the timer that is set to specified timer mode by starting or stopping it. [data] For data, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
__DestroyTimer Synopsis <Discard settings of timer mode> Boolean __DestroyTimer(unsigned long data) data Description Discards settings of the timer that is set to specified timer mode. [data] For data, the following definition values can be set. RAPI_TIMER_A0 RAPI_TIMER_A1 RAPI_TIMER_A2 RAPI_TIMER_A3 RAPI_TIMER_A4 RAPI_TIMER_B0 RAPI_TIMER_B1 RAPI_TIMER_B2...
__CreateEventCounter Synopsis <Set event counter mode> Boolean __CreateEventCounter(unsigned long data1, unsigned int data2, unsigned int data3, unsigned int data4, void* func) data1 data2 data3 data4 func Description Sets a specified timer to event counter mode. [data1] For data1, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
Page 47
RAPI_UP_COUNT RAPI_DOWN_COUNT RAPI_UDF_REGISTER RAPI_TAIOUT RAPI_RISING RAPI_FALLING RAPI_BOTH • Specifiable definition values when timer A is used (RAPI_TIMER_A0 to RAPI_TIMER_A4 specified) (Count source) (Operating states set) (Pulse output facility) (Gate facility) (Count type) (Count direction) (Count direction switching) (Count edge) • Specifiable definition values when timer B is used (RAPI_TIMER_B0 to RAPI_TIMER_B4 specified) (Count source) (Operating...
Page 48
[data4] Specify 0. Return value If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned. Functionality Timer (event counter mode) __EnableEventCounter, __DestroyEventCounter, Reference • Remark If an undefined value is specified in the first argument, operation of the API cannot be guaranteed.
__EnableEventCounter Synopsis <Control operation of event counter mode> Boolean __EnableEventCounter(unsigned long data) data Description Controls operation of the timer that is set to specified timer mode by starting or stopping it. [data] For data, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
__DestroyEventCounter Synopsis <Discard settings of event counter mode> Boolean __DestroyEventCounter(unsigned long data) data Description Discards settings of the timer that is set to specified timer mode. [data] For data, the following definition values can be set. RAPI_TIMER_A0 RAPI_TIMER_A1 RAPI_TIMER_A2 RAPI_TIMER_A3 RAPI_TIMER_A4 RAPI_TIMER_B0 RAPI_TIMER_B1...
__GetEventCounter Synopsis <Get event counter mode counter value> Boolean __GetEventCounter(unsigned long data1, unsigned int *data2) data1 data2 Gets the counter value of the timer that is set to specified event counter mode. Description [data1] For data, the following definition values can be set. RAPI_TIMER_A0 RAPI_TIMER_A1 RAPI_TIMER_A2...
__CreatePulseWidthModulationMode Synopsis <Set pulse width modulation mode> Boolean __CreatePulseWidthModulationMode(unsigned long data1, unsigned int data2, unsigned int* data3, void* data4) data1 data2 data3 func Description Sets a specified timer to pulse width modulation mode. [data1] For data1, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
Page 53
RAPI_FALLING • Specifiable definition values when timer A is used (RAPI_TIMER_A0 to RAPI_TIMER_A4 specified) (Count source) (Operating states set) Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The (Count start condition) Specify one from { RAPI_TG_TAIS, RAPI_TG_TAIIN, (Pulse output facility) (Modulator) pin input) [data2] Specify the interrupt priority level (0–7) to be set in the interrupt control register.
Page 54
void func( void ) unsigned int p_tim[] = {0xAA, 0xBB, 0xCC}; /* Set up timer A3 as pulse width modulation mode */ __CreatePulseWidthModulationMode( RAPI_TIMER_A3|RAPI_TIMER_ON|RAPI_F8, Rev.1.00 2007.11.1 REC10B0002-0100 5, p_tim, TimerIntFunc);...
__EnablePulseWidthModulationMode Synopsis <Control operation of pulse width modulation mode> Boolean __EnablePulseWidthModulationMode(unsigned long data) data Description Controls operation of the timer that is set to specified pulse width modulation mode by starting or stopping it. [data] For data, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
__DestroyPulseWidthModulationMode Synopsis <Discard settings of pulse width modulation mode> Boolean __DestroyPulseWidthModulationMode(unsigned long data) data Description Discards settings of the timer that is set to specified pulse width modulation mode. [data] For data, the following definition values can be set. RAPI_TIMER_A0 RAPI_TIMER_A1 RAPI_TIMER_A2 RAPI_TIMER_A3...
__CreatePulsePeriodMeasurementMode Synopsis <Set pulse period measurement mode> Boolean __CreatePulsePeriodMeasurementMode(unsigned long data1, unsigned int data2, unsigned int data3, unsigned int data4, void* func) data1 data2 data3 data4 func Description Sets a specified timer to pulse period measurement mode. [data1] For data1, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
Page 58
[data3] Specify 0. [data4] Specify 0. If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, Return value RAPI_TRUE is returned. Functionality Timer (pulse period measurement mode) Reference __EnablePulsePeriodMeasurementMode, __DestroyPulsePeriodMeasurementMode, __GetPulsePeriodMeasurementMode • Remark If an undefined value is specified in the first argument, operation of the API cannot be guaranteed.
__EnablePulsePeriodMeasurementMode Synopsis <Control operation of pulse period measurement mode> Boolean __EnablePulsePeriodMeasurementMode(unsigned long data) data Description Controls operation of the timer that is set to specified pulse period measurement mode by starting or stopping it. [data] For data, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
__DestroyPulsePeriodMeasurementMode Synopsis <Discard settings of pulse period measurement mode> Boolean __DestroyPulsePeriodMeasurementMode(unsigned long data) data Description Discards settings of the timer that is set to specified pulse period measurement mode. [data] For data, the following definition values can be set. RAPI_TIMER_B0 RAPI_TIMER_B1 RAPI_TIMER_B2 RAPI_TIMER_B3...
__GetPulsePeriodMeasurementMode Synopsis <Get measured value in pulse period measurement mode> Boolean __GetPulsePeriodMeasurementMode(unsigned long data1, unsigned int *data2) data1 data2 Description Gets the counter value of the timer that is set to specified pulse period measurement mode. [data1] For data, the following definition values can be set. RAPI_TIMER_B0 RAPI_TIMER_B1 RAPI_TIMER_B2...
__CreatePulseWidthMeasurementMode Synopsis <Set pulse width measurement mode> Boolean __CreatePulseWidthMeasurementMode(unsigned long data1, unsigned int data2, unsigned int data3, unsigned int data4, void* func) data1 data2 data3 data4 func Description Sets a specified timer to pulse with measurement mode. [data1] For data1, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
Page 63
[data4] Specify 0. Return value If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned. Functionality Timer (pulse width measurement mode) Reference __EnablePulseWidthMeasurementMode, __DestroyPulseWidthMeasurementMode, __GetPulseWidthMeasurementMode • Remark If an undefined value is specified in the first argument, operation of the API cannot be guaranteed.
__EnablePulseWidthMeasurementMode Synopsis <Control operation of pulse width measurement mode> Boolean __EnablePulseWidthMeasurementMode(unsigned long data) data Description Controls operation of the timer that is set to specified pulse width measurement mode. [data] For data, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
__DestroyPulseWidthMeasurementMode Synopsis <Discard settings of pulse width measurement mode> Boolean __DestroyPulseWidthMeasurementMode(unsigned long data) data Description Discards settings of the timer that is set to specified pulse width measurement mode. [data] For data, the following definition values can be set. RAPI_TIMER_B0 RAPI_TIMER_B1 RAPI_TIMER_B2 RAPI_TIMER_B3...
__GetPulseWidthMeasurementMode Synopsis <Get measured value in pulse width measurement mode> Boolean __GetPulseWidthMeasurementMode(unsigned long data1, unsigned int *data2) data1 data2 Description Gets the counter value of the timer that is set to specified pulse width measurement mode. [data1] For data, the following definition values can be set. RAPI_TIMER_B0 RAPI_TIMER_B1 RAPI_TIMER_B2...
__SetTimerRegister Synopsis <Set timer register> Boolean __SetTimerRegister(unsigned long data1, unsigned int *data2) data1 data2 Description Sets the registers of a specified timer. [data1] For data, the following definition values can be set. RAPI_TIMER_A0 RAPI_TIMER_A1 RAPI_TIMER_A2 RAPI_TIMER_A3 RAPI_TIMER_A4 RAPI_TIMER_B0 RAPI_TIMER_B1 RAPI_TIMER_B2 [data2] The content of a pointer to the buffer in which the register value is stored must be specified as described below.
Page 68
If an undefined value is specified in the first argument, operation of the API cannot be guaranteed. • The specifiable timers differ with each CPU used. Program example #include " rapi_timer_m16c_62p.h" void func( void ) unsigned char data[] = {0,0,0,0,0,0,0}; /* Set up timer A0 register */ __SetTimerRegister( RAPI_TIMER_A0, data );...
__EnableTimerRegister Synopsis <Control operation of timer register> Boolean __EnableTimerRegister(unsigned long data) data Description Controls operation of a specified timer by starting or stopping it. [data] For data, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
__ClearTimerRegister Synopsis <Clear timer register> Boolean __ClearTimerRegister(unsigned long data) data Description Sets the timer register of a specified timer to its initial value after reset. [data] For data, the following definition values can be set. RAPI_TIMER_A0 RAPI_TIMER_A1 RAPI_TIMER_A2 RAPI_TIMER_A3 RAPI_TIMER_A4 RAPI_TIMER_B0 RAPI_TIMER_B1 RAPI_TIMER_B2...
__GetTimerRegister Synopsis <Get timer register value> Boolean __GetTimerRegister(unsigned long data1, unsigned int *data2) data1 data2 Gets the counter value of a specified timer. Description [data] For data, the following definition values can be set. RAPI_TIMER_A0 RAPI_TIMER_A1 RAPI_TIMER_A2 RAPI_TIMER_A3 RAPI_TIMER_A4 RAPI_TIMER_B0 RAPI_TIMER_B1 RAPI_TIMER_B2 RAPI_TIMER_B3...
Page 72
Reference __SetTimerRegister, __EnableTimerRegister, • Remark If an undefined value is specified in the first argument, operation of the API cannot be guaranteed. Program example #include " rapi_timer_m16c_62p.h" void func( void ) unsigned int data[7]; /* Get the value of timer A3 registers */ __GetTimerRegister( RAPI_TIMER_A3, data );...
4.2.3 I/O Port __SetIOPort Synopsis <Set I/O port> Boolean __SetIOPort(unsigned long data1, unsigned int data2) data1 data2 Sets the operating conditions of a specified I/O port. Description [data1] For data1, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
Page 74
RAPI_PORT_7_2 RAPI_PORT_7_4 RAPI_PORT_7_6 RAPI_PORT_8_0 RAPI_PORT_8_2 RAPI_PORT_8_4 RAPI_PORT_8_6 RAPI_PORT_9_0 RAPI_PORT_9_2 RAPI_PORT_9_4 RAPI_PORT_9_6 RAPI_PORT_10_0 RAPI_PORT_10_2 RAPI_PORT_10_4 RAPI_PORT_10_6 RAPI_PORT_11_0 RAPI_PORT_11_2 RAPI_PORT_11_4 RAPI_PORT_11_6 RAPI_PORT_12_0 RAPI_PORT_12_2 RAPI_PORT_12_4 RAPI_PORT_12_6 RAPI_PORT_13_0 RAPI_PORT_13_2 RAPI_PORT_13_4 RAPI_PORT_13_6 RAPI_PORT_14_0 The definition values related to port settings are described below. RAPI_PORT_INPUT RAPI_PORT_OUTPUT RAPI_PULLED_HIGH RAPI_NOT_PULLED _HIGH...
Page 75
Functionality I/O port Reference __ReadIOPort, __WriteIOPort, __SetIOPortRegister, __ReadIOPortRegister, __WriteIOPortRegister • Remark If an undefined value is specified in the first argument, operation of the API cannot be guaranteed. Program example #include " rapi_io_port_m16c_62p.h" void func( void ) /* Set up port P03 as input port */ __SetIOPort(RAPI_PORT_0_3| RAPI_PORT_INPUT| RAPI_PULLED_HIGH, 0 );...
__ReadIOPort Synopsis <Read from I/O port> Boolean __ReadIOPort(unsigned long data1, unsigned int *data2) data1 data2 Gets the value of a specified I/O port. Description [data1] Specify an I/O port from which data is read. The definition values corresponding to each I/O port are listed below. RAPI_PORT_0_0 RAPI_PORT_0_2 RAPI_PORT_0_4...
Page 77
RAPI_PORT_9_6 RAPI_PORT_10_0 RAPI_PORT_10_2 RAPI_PORT_10_4 RAPI_PORT_10_6 RAPI_PORT_11_0 RAPI_PORT_11_2 RAPI_PORT_11_4 RAPI_PORT_11_6 RAPI_PORT_12_0 RAPI_PORT_12_2 RAPI_PORT_12_4 RAPI_PORT_12_6 RAPI_PORT_13_0 RAPI_PORT_13_2 RAPI_PORT_13_4 RAPI_PORT_13_6 RAPI_PORT_14_0 Return value If the I/O port specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned. Functionality I/O port __SetIOPort, __WriteIOPort, __SetIOPortRegister, __ReadIOPortRegister, Reference __WriteIOPortRegister •...
__WriteIOPort Synopsis <Write to I/O port> Boolean __WriteIOPort(unsigned long data1, unsigned int data2) data1 data2 Writes data to a specified I/O port. Description [data1] Specify an I/O port to which data is written. The definition values corresponding to each I/O port are listed below. RAPI_PORT_0_0 RAPI_PORT_0_2 RAPI_PORT_0_4...
Page 79
RAPI_PORT_9_6 RAPI_PORT_10_0 RAPI_PORT_10_2 RAPI_PORT_10_4 RAPI_PORT_10_6 RAPI_PORT_11_0 RAPI_PORT_11_2 RAPI_PORT_11_4 RAPI_PORT_11_6 RAPI_PORT_12_0 RAPI_PORT_12_2 RAPI_PORT_12_4 RAPI_PORT_12_6 RAPI_PORT_13_0 RAPI_PORT_13_2 RAPI_PORT_13_4 RAPI_PORT_13_6 RAPI_PORT_14_0 Return value If the I/O port specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned. Functionality I/O port __SetIOPort, __ReadIOPort, __SetIOPortRegister, __ReadIOPortRegister, Reference __WriteIOPortRegister •...
__SetIOPortRegister Synopsis <Set I/O port register> Boolean __SetIOPortRegister(unsigned long data1, unsigned int data2, unsigned int data3, unsigned int data4) data1 data2 data3 data4 Description [data1] Set the operating condition of a specified I/O port in each relevant register. The definition values corresponding to each I/O port register are listed below. RAPI_PORT_0 RAPI_PORT_2 RAPI_PORT_4...
Page 81
If an undefined value is specified in the first argument, operation of the API cannot be guaranteed. Program example #include " rapi_io_port_m16c_62p.h" void func( void ) /* Set inputs/outputs of port P1 register */ __SetIOPortRegister(RAPI_PORT_1, 0xAA, 0, 0 ); Rev.1.00 2007.11.1 REC10B0002-0100...
__ReadIOPortRegister Synopsis <Read from I/O port register> Boolean __ReadIOPortRegister(unsigned long data1, unsigned int *data2) data1 data2 Gets the value of a specified I/O port from each relevant register. Description [data1] Specify an I/O port register from which data is read. The definition values corresponding to each I/O port register are listed below.
__WriteIOPortRegister Synopsis <Write to I/O port register> Boolean __WriteIOPortRegister(unsigned long data1, unsigned int data2) data1 data2 Writes the value for a specified I/O port to each relevant register. Description [data1] Specify an I/O port register to which data is written. The definition values corresponding to each I/O port register are listed below.
4.2.4 External interrupt __SetInterrupt Synopsis <Set external interrupt> Boolean __SetInterrupt(unsigned long data1, unsigned int data2, void* func) data1 data2 func Description Sets a specified external interrupt. [data1] For data1, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
Page 85
Return value If the external interrupt specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned. Functionality External interrupt Reference __EnableInterrupt, __GetInterruptFlag, • If an undefined value is specified in the first argument, operation of the API cannot Remark be guaranteed. Program example #include "...
__EnableInterrupt Synopsis <Control external interrupt> Boolean __EnableInterrupt(unsigned long data1, unsigned int data2) data1 data2 Changes the operating condition of a specified external interrupt. Description [data1] RAPI_INT0 RAPI_INT1 RAPI_INT2 RAPI_INT3 RAPI_INT4 RAPI_INT5 RAPI_KEY [data2] Specify the interrupt priority level (0–7) to be set in the interrupt control register. If the external interrupt specification is incorrect, RAPI_FALSE is returned;...
__GetInterruptFlag Synopsis <Get the status of external interrupt flag> Boolean __GetInterruptFlag(unsigned long data1, unsigned int *data2)) data1 data2 Gets the value of interrupt request flag of a specified external interrupt. Description [data1] RAPI_INT0 RAPI_INT1 RAPI_INT2 RAPI_INT3 RAPI_INT4 RAPI_INT5 RAPI_KEY [data2] Value of interrupt request flag (0: Interrupt not requested;...
__ClearInterruptFlag Synopsis <Clear external interrupt flag> Boolean __ClearInterruptFlag(unsigned long data) data Description Clears the interrupt request flag of a specified external interrupt. [data] RAPI_INT0 RAPI_INT1 RAPI_INT2 RAPI_INT3 RAPI_INT4 RAPI_INT5 RAPI_KEY Return value If the external interrupt specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned.
4.2.5 A/D converter __CreateADC Synopsis <Set A/D converter> Boolean __CreateADC(unsigned long data1, unsigned int data2, unsigned int data3, void* func) data1 data2 data3 func Description Sets the A/D converter to specified mode and operating condition. [data1] For data1, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
Page 90
RAPI_AN27 RAPI_P0_GROUP RAPI_P10_GROUP RAPI_P2_GROUP RAPI_FAD RAPI_FAD2 RAPI_FAD3 RAPI_FAD4 RAPI_FAD6 RAPI_FAD12 RAPI_10BIT RAPI_8BIT RAPI_AD_ON RAPI_AD_OFF RAPI_WITH_SAMPLE_HOLD RAPI_WITHOUT_SAMPLE_ HOLD RAPI_SOFTWARE_TRIGGER RAPI_EXTERNAL_TRIGGER RAPI_ANEX_UNUSED RAPI_ANEX0 RAPI_ANEX1 RAPI_EXTERNAL_OP_AMP • Specifiable definition values when one-shot mode is used (RAPI_ONE_SHOT specified) (Input pin) (Operating frequency) (Resolution) (Operating states set) (Conversion method)
Page 91
(Input pin) (Operating frequency) (Resolution) (Operating states set) (Conversion method) (Trigger) (External Op-Amp Connection) • Specifiable definition values when single sweep mode is used (RAPI_SINGLE_SWEEP specified) (Input pin) (Operating frequency) (Resolution) (Operating states set) (Conversion method) (Trigger) (External Op-Amp Connection) •...
Page 92
(Operating states set) (Conversion method) (Trigger) (External Op-Amp Connection) • Specifiable definition values when repeat sweep mode 1 is used (RAPI_REPEAT_SWEEP1 specified) (Input pin) (Operating frequency) (Resolution) (Operating states set) (Conversion method) (Trigger) (External Op-Amp Connection) [data2] The set value differs with the A/D conversion mode used. One-shot mode Repeat mode Single sweep mode...
Page 93
• Remark If an undefined value is specified in the first argument, operation of the API cannot be guaranteed. Program example #include " rapi_ad_m16c_62p.h" void AdIntFunc( void ){} void func( void ) /* Set up A/D converter as one short mode */ __CreateADC( RAPI_ONE_SHOT|RAPI_AN2|RAPI_FAD2| RAPI_WITH_SAMPLE_HOLD | RAPI_EXTERNAL_TRIGGER |RAPI_AD_ON|RAPI_10BIT| RAPI_ANEX_UNUSED, 1, 5, AdIntFunc );...
__DestroyADC Synopsis <Discard settings of A/D converter> Boolean __DestroyADC(void) Description Discards settings of a specified A/D converter. If converter setting was successfully discarded, RAPI_TRUE is returned; if failed, Return value RAPI_FALSE is returned. A/D converter Functionality Reference __CreateADC, __EnableADC, __GetADC, Program example #include "rapi_ad_m16c_62p.h"...
__GetADC Synopsis <Get A/D converted value (register specified)> Boolean __GetADC(unsigned long data1, unsigned int *data2) data1 data2 Gets the A/D converted value from a specified A/D register. Description For data1, the following values can be set. RAPI_AD0 RAPI_AD1 RAPI_AD2 RAPI_AD3 RAPI_AD4 RAPI_AD5 RAPI_AD6...
__GetADCAll Synopsis <Get A/D converted value (all registers)> Boolean __GetADCAll(unsigned int *data) data Description Gets the A/D converted value from all A/D registers. The A/D registers from which A/D converted values are acquired are listed below. [M16C] (16 bytes) Return value If A/D converted values were successfully acquired, RAPI_TRUE is returned;...
Page 100
M16C/62P Group Renesas Embedded Application Programming Interface Reference Manual 1753, Shimonumabe, Nakahara-ku, Kawasaki-shi, Kanagawa 211-8668 Japan REC10B0002-0100...