REC10B0002-0100 M16C/62P Group Renesas Embedded Application Programming Interface Reference Manual Reference Manual Rev.1.00 Revision Date: Nov.1, 2007 www.renesas.
Renesas Embedded Application Programming Interface Reference Manual Rev.1.00 2007.11.
Table of Contents Table of Contents ............................................................... 3 1. Introduction................................................................... 5 2. Driver ....................................................................... 6 2.1 Overview.................................................................. 6 2.2 Driver Features ............................................................. 6 2.3 Serial Interface Driver.................................................
__DestroyTimer .......................................................... 43 __CreateEventCounter ..................................................... 44 __EnableEventCounter ..................................................... 47 __DestroyEventCounter .................................................... 48 __GetEventCounter........................................................ 49 __CreatePulseWidthModulationMode ......................................... 50 __EnablePulseWidthModulationMode .............
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.
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.
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 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.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.
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.00 2007.11.
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.
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)). VoidFuncNotify The VoidFuncNotify type represents the type of the notification function to be registered. Rev.1.00 2007.11.
4. Library Reference 4.1 API List by Peripheral Facility The table below lists the Renesas Embedded APIs classified by peripheral facility.
38 __GetPulseWidthMeasurementMode 39 __SetTimerRegister 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 timer register 40 __EnableTimerRegister Controls operation of timer register 41 __ClearTimerRegister Clears timer register 42 __GetTimerRegister Gets timer register value __SetIOPort Sets I/O port 44 __ReadIOPort Reads from I/O port 45 __Write
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 : Outlines the content of processing performed by the function. It also shows the syntax of the function, followed by a brief explanation of arguments. • Description : Describes the function and how to use it in detail. • Return value : Explains the returned value of the function.
4.2.1 Serial I/O __BasicOpenSerialDriver Synopsis Boolean __BasicOpenSerialDriver(unsigned long data) data Description Setup data Opens and initializes a specified serial port. For data, the following values can be set. Return value RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM4 SI/O3 RAPI_COM5 SI/O4 If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned.
__BasicCloseSerialDriver Synopsis Boolean __BasicCloseSerialDriver(unsigned long data) data Description Return value Setup data Closes a specified serial port. For data, the following values can be set. RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM4 SI/O3 RAPI_COM5 SI/O4 If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned.
__BasicSetSerialFormat Synopsis Boolean __BasicSetSerialFormat(unsigned long data1, unsigned char data2) Description 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.
If the API is used in clock synchronous serial communication mode, do not set these values. (UART0, UART1, UART2) RAPI_PARITY_NON No parity bit RAPI_PARITY_ODD Odd parity bit RAPI_PARITY_EVEN Even 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.
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” Boolean func( void ) { /* Set the data of RAPI_COM1 to serial driver */ Return _BasicSetSerialFormat(RAPI_COM1 | RAPI_SM_SYNC | RAPI_CKDIR_INT | RAPI_BCSS_F1 | RAPI_DPOL_NON | RAPI_LSB_SEL, 20); } Rev.
__BasicStartSerialReceiving Synopsis Boolean __BasicStartSerialReceiving(unsigned long data) data Description Setup data Starts receiving 1 data of serial communication. [data] For data, the following values can be set. Return value RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM4 SI/O3 RAPI_COM5 SI/O4 If data reception in serial communication was successfully started, RAPI_TRUE is returned; if failed, RAPI_FALSE is returned.
__BasicStartSerialSending Synopsis Boolean _BasicStartSerialSending(unsigned long data1, unsigned int data2) Description data Setup data data Transmit data Starts sending 1 data of serial communication. For data1, the following values can be set. Return value RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM4 SI/O3 RAPI_COM5 SI/O4 If data transmission in serial communication was successfully started, RAPI_TRUE is returned; if failed, RAPI_FALSE is returned.
__BasicReceivingStatusRead Synopsis unsigned int __BasicReceivingStatusRead(unsigned long data) data Description Setup data Returns the receive status of serial communication. [data] For data, the following values can be set. Return value RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM4 SI/O3 RAPI_COM5 SI/O4 The receive status of serial communication is returned. The returned value is one of the following.
__BasicSendingStatusRead Synopsis Boolean __BasicSendingStatusRead(unsigned long data) data Description Setup data Returns the transmit status of serial communication. For data, the following values can be set. Return value RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM4 SI/O3 RAPI_COM5 SI/O4 If no data exists in the transmit buffer, RAPI_TRUE is returned; if data exists, RAPI_FALSE is returned.
__BasicStopSerialReceiving Synopsis Boolean Rapi_BasicStopSerialReceiving(unsigned long data) data Description Setup data Stops receiving data in serial communication [data] For data, the following values can be set. Return value RAPI_COM1 UART0 RAPI_COM3 UART2 RAPI_COM2 UART1 If data reception in serial communication was successfully stopped, RAPI_TRUE is returned; if failed, RAPI_FALSE is returned.
__BasicStopSerialSending Synopsis Boolean __BasicStopSerialSending(unsigned long data) data Description Setup data Stops transmitting data in serial communication. [data] For data, the following values can be set. Return value RAPI_COM1 UART0 RAPI_COM3 UART2 RAPI_COM2 UART1 If data transmission in serial communication was successfully stopped, RAPI_TRUE is returned; if failed, RAPI_FALSE is returned.
__OpenSerialDriver Synopsis Boolean __OpenSerialDriver(unsigned long data) data Description Setup data Opens and initializes a specified serial port. [data] For data, the following values can be set. Return value RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM4 SI/O3 RAPI_COM5 SI/O4 If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned.
__CloseSerialDriver Synopsis Boolean __CloseSerialDriver(unsigned long data) data Description Setup data Closes a specified serial port. [data] For data, the following values can be set. Return value RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM4 SI/O3 RAPI_COM5 SI/O4 If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned.
__ConfigSerialDriverNotify Synopsis Boolean __ConfigSerialDriverNotify(unsigned long data, VoidFuncNotify *func) Description data Setup data func Function pointer to be registered Registers the notification function necessary to get various transmit/receive information of serial communication. [data] For data, the following values can be set.
Return value If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned. Functionality Reference Remark Serial I/O __StartSerialReceiving, __StartSerialSending • If an undefined value is specified in the first argument, operation of the API cannot be guaranteed.
__SetSerialFormat Synopsis Boolean __SetSerialFormat(unsigned long data1, unsigned char data2) Description data1 Setup data 1 data2 Setup data 2 Sets serial communication according to specified parameters. For details about parameters, refer to the description of __BasicSetSerialFormat. Return value If serial communication was successfully set, RAPI_TRUE is returned; if settings failed, RAPI_FALSE is returned.
__SetSerialInterrupt Synopsis Boolean __SetSerialInterrupt(unsigned long data) data Description Setup data Sets serial interrupts according to specified parameters. [data] For data, the following values can be set. RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM4 SI/O3 RAPI_COM5 SI/O4 For interrupt settings, the following values can set.
Functionality Serial I/O 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( RAPI_COM1 | RAPI_INT_TX_LV_1 RAPI_INT_RX_LV_2 ); } Rev.1.00 2007.11.
__StartSerialReceiving Synopsis Boolean __StartSerialReceiving(unsigned long data, unsigned char wordNum, unsigned int *RcvDtBuf) Description data Setup data wordNum Number of words received RcvDtBuf Pointer to the buffer in which received data is stored 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 Boolean __StartSerialSending(unsigned long data, unsigned char wordNum, unsigned int *SndDtBuf) Description data Setup data wordNum Number of words transmitted SndDtBuf Pointer to the transmit data Starts transmission of serial communication and writes transmit data to the transmit buffer by a specified number of words.
__StopSerialReceiving Synopsis Boolean __StopSerialReceiving(unsigned long data) data Description Setup data Stops reception of serial communication. [data] For data, the following values can be set. Return value RAPI_COM1 UART0 RAPI_COM3 UART2 RAPI_COM2 UART1 If reception of serial communication was successfully stopped, RAPI_TRUE is returned; if failed, RAPI_FALSE is returned.
__StopSerialSending Synopsis Boolean __StopSerialSending(unsigned long data) data Description Setup data Stops transmission of serial communication. [data] For data, the following values can be set. Return value RAPI_COM1 UART0 RAPI_COM3 UART2 RAPI_COM2 UART1 If transmission of serial communication was successfully stopped, RAPI_TRUE is returned; if failed, RAPI_FALSE is returned.
__PollingSerialReceiving Synopsis Boolean __PollingSerialReceiving(unsigned long data) data Description Setup data 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 Boolean __PollingSerialSending(unsigned long data) data Description Setup data 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 Boolean __CreateTimer(unsigned long data1, unsigned int data2, unsigned int data3, unsigned int data4, void* func) data1 Setup data 1 data2 Setup data 2 data3 Setup data 3 data4 Setup data 4 func Callback function pointer (Specify 0 if no callback functions are set.) Description Sets a specified timer to timer mode. [data1] For data1, the following definition values can be set.
(Count source) Specify one from { RAPI_F1, RAPI_F2, RAPI_F8, RAPI_F32, RAPI_FC32 }. The default value is RAPI_F2. (Operating states set) Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The (Pulse output state) Specify one from { RAPI_PULSE_ON, RAPI_PULSE_OFF }. The default value is RAPI_TIMER_OFF. default value is RAPI_PULSE_OFF. (Gate facility) Specify one from { RAPI_GATE_L, RAPI_GATE_H }. If omitted, “No gate facility” is set.
__EnableTimer Synopsis Boolean __EnableTimer(unsigned long data) data Setup data Controls operation of the timer that is set to specified timer mode by starting or Description stopping it. [data] For data, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|” to separate each specified value. Return value RAPI_TIMER_A0 Selects timer A channel 0. RAPI_TIMER_A1 Selects timer A channel 1.
__DestroyTimer Synopsis Boolean __DestroyTimer(unsigned long data) data Setup data Discards settings of the timer that is set to specified timer mode. Description [data] For data, the following definition values can be set. RAPI_TIMER_A0 Selects timer A channel 0. RAPI_TIMER_A1 Selects timer A channel 1. RAPI_TIMER_A2 Selects timer A channel 2 RAPI_TIMER_A3 Selects timer A channel 3. RAPI_TIMER_A4 Selects timer A channel 4.
__CreateEventCounter Synopsis Boolean __CreateEventCounter(unsigned long data1, unsigned int data2, unsigned int data3, unsigned int data4, void* func) data1 Setup data 1 data2 Setup data 2 data3 Setup data 3 data4 Setup data 4 func Callback function pointer (Specify 0 if no callback functions are set.) Description Sets a specified timer to event counter mode. [data1] For data1, the following definition values can be set.
RAPI_UP_COUNT Selects up-count for the count operation. RAPI_DOWN_COUNT Selects down-count for the count operation. RAPI_UDF_REGISTER Selects the UDF register for the cause of up/down switching. RAPI_TAIOUT Selects the input signal at TAiOUT pin for the cause of up/down switching. RAPI_RISING Selects the rising edge of count source as active edge. RAPI_FALLING Selects the falling edge of count source as active edge.
[data4] Specify 0. Return value If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned. Functionality Reference Remark Timer (event counter mode) __EnableEventCounter, __DestroyEventCounter, __GetEventCounter • If an undefined value is specified in the first argument, operation of the API cannot be guaranteed. Program example #include "rapi_timer_m16c_62p.
__EnableEventCounter Synopsis Boolean __EnableEventCounter(unsigned long data) data Description Setup data 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 “|” to separate each specified value. RAPI_TIMER_A0 Selects timer A channel 0. RAPI_TIMER_A1 Selects timer A channel 1.
__DestroyEventCounter Synopsis Boolean __DestroyEventCounter(unsigned long data) data Description Setup data Discards settings of the timer that is set to specified timer mode. [data] For data, the following definition values can be set. Return value RAPI_TIMER_A0 Selects timer A channel 0. RAPI_TIMER_A1 Selects timer A channel 1. RAPI_TIMER_A2 Selects timer A channel 2. RAPI_TIMER_A3 Selects timer A channel 3. RAPI_TIMER_A4 Selects timer A channel 4.
__GetEventCounter Synopsis Boolean __GetEventCounter(unsigned long data1, unsigned int *data2) Description data1 Setup data 1 data2 Pointer to the buffer in which counter value is stored Gets the counter value of the timer that is set to specified event counter mode. [data1] For data, the following definition values can be set. Return value RAPI_TIMER_A0 Selects timer A channel 0. RAPI_TIMER_A1 Selects timer A channel 1.
__CreatePulseWidthModulationMode Synopsis Boolean __CreatePulseWidthModulationMode(unsigned long data1, unsigned int data2, unsigned int* data3, void* data4) data1 Setup data 1 data2 Setup data 2 data3 Setup data 3 func Callback function pointer (Specify 0 if no callback functions are set.) Description Sets a specified timer to pulse width modulation mode. [data1] For data1, the following definition values can be set.
RAPI_FALLING Selects the falling edge of TAiIN pin input signal as active edge. • Specifiable definition values when timer A is used (RAPI_TIMER_A0 to RAPI_TIMER_A4 specified) (Count source) Specify one from { RAPI_F1, RAPI_F2, RAPI_F32, RAPI_FC32 }. (Operating states set) Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The The default value is RAPI_F2. default value is RAPI_TIMER_OFF.
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, 5, p_tim, TimerIntFunc); } Rev.1.00 2007.11.
__EnablePulseWidthModulationMode Synopsis Boolean __EnablePulseWidthModulationMode(unsigned long data) data Description Setup data 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 “|” to separate each specified value. RAPI_TIMER_A0 Selects timer A channel 0.
__DestroyPulseWidthModulationMode Synopsis Boolean __DestroyPulseWidthModulationMode(unsigned long data) data Description Setup data Discards settings of the timer that is set to specified pulse width modulation mode. [data] For data, the following definition values can be set. Return value RAPI_TIMER_A0 Selects timer A channel 0. RAPI_TIMER_A1 Selects timer A channel 1. RAPI_TIMER_A2 Selects timer A channel 2.
__CreatePulsePeriodMeasurementMode Synopsis Boolean __CreatePulsePeriodMeasurementMode(unsigned long data1, unsigned int data2, unsigned int data3, unsigned int data4, void* func) data1 Setup data 1 data2 Setup data 2 data3 Setup data 3 data4 Setup data 4 func Callback function pointer (Specify 0 if no callback functions are set.) Description Sets a specified timer to pulse period measurement mode. [data1] For data1, the following definition values can be set.
[data3] Specify 0. [data4] Specify 0. Return value If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned. Functionality Reference Timer (pulse period measurement mode) __EnablePulsePeriodMeasurementMode, __DestroyPulsePeriodMeasurementMode, __GetPulsePeriodMeasurementMode 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.
__EnablePulsePeriodMeasurementMode Synopsis Boolean __EnablePulsePeriodMeasurementMode(unsigned long data) data Description Setup data 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 “|” to separate each specified value.
__DestroyPulsePeriodMeasurementMode Synopsis Boolean __DestroyPulsePeriodMeasurementMode(unsigned long data) data Description Setup data Discards settings of the timer that is set to specified pulse period measurement mode. [data] For data, the following definition values can be set. Return value RAPI_TIMER_B0 Uses timer B channel 0. RAPI_TIMER_B1 Uses timer B channel 1. RAPI_TIMER_B2 Uses timer B channel 2.
__GetPulsePeriodMeasurementMode Synopsis Boolean __GetPulsePeriodMeasurementMode(unsigned long data1, unsigned int *data2) Description data1 Setup data 1 data2 Pointer to the buffer in which counter value is stored 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. Return value RAPI_TIMER_B0 Uses timer B channel 0.
__CreatePulseWidthMeasurementMode Synopsis Boolean __CreatePulseWidthMeasurementMode(unsigned long data1, unsigned int data2, unsigned int data3, unsigned int data4, void* func) data1 Setup data 1 data2 Setup data 2 data3 Setup data 3 data4 Setup data 4 func Callback function pointer (Specify 0 if no callback functions are set.) Description Sets a specified timer to pulse with measurement mode. [data1] For data1, the following definition values can be set.
[data4] Specify 0. If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE Return value is returned. Timer (pulse width measurement mode) Functionality __EnablePulseWidthMeasurementMode, __DestroyPulseWidthMeasurementMode, Reference __GetPulseWidthMeasurementMode • If an undefined value is specified in the first argument, operation of the API cannot Remark be guaranteed. Program example #include "rapi_timer_m16c_62p.
__EnablePulseWidthMeasurementMode Synopsis Boolean __EnablePulseWidthMeasurementMode(unsigned long data) data Setup data Controls operation of the timer that is set to specified pulse width measurement mode. Description [data] For data, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|” to separate each specified value. RAPI_TIMER_B0 Selects timer B channel 0.
__DestroyPulseWidthMeasurementMode Synopsis Boolean __DestroyPulseWidthMeasurementMode(unsigned long data) data Description Setup data Discards settings of the timer that is set to specified pulse width measurement mode. [data] For data, the following definition values can be set. Return value RAPI_TIMER_B0 Uses timer B channel 0. RAPI_TIMER_B1 Uses timer B channel 1. RAPI_TIMER_B2 Uses timer B channel 2. RAPI_TIMER_B3 Uses timer B channel 3.
__GetPulseWidthMeasurementMode Synopsis Boolean __GetPulseWidthMeasurementMode(unsigned long data1, unsigned int *data2) Description data1 Setup data 1 data2 Pointer to the buffer in which counter value is stored 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. Return value RAPI_TIMER_B0 Uses timer B channel 0.
__SetTimerRegister Synopsis Boolean __SetTimerRegister(unsigned long data1, unsigned int *data2) Description data1 Setup data 1 data2 Pointer to the buffer in which register value is stored Sets the registers of a specified timer. [data1] For data, the following definition values can be set. RAPI_TIMER_A0 Selects timer A channel 0. RAPI_TIMER_A1 Selects timer A channel 1. RAPI_TIMER_A2 Selects timer A channel 2. RAPI_TIMER_A3 Selects timer A channel 3.
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 ); } Rev.1.00 2007.11.
__EnableTimerRegister Synopsis Boolean __EnableTimerRegister(unsigned long data) data Description Setup data 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 “|” to separate each specified value. Return value RAPI_TIMER_A0 Selects timer A channel 0. RAPI_TIMER_A1 Selects timer A channel 1.
__ClearTimerRegister Synopsis Boolean __ClearTimerRegister(unsigned long data) data Description Setup data Sets the timer register of a specified timer to its initial value after reset. [data] For data, the following definition values can be set. Return value RAPI_TIMER_A0 Selects timer A channel 0. RAPI_TIMER_A1 Selects timer A channel 1. RAPI_TIMER_A2 Selects timer A channel 2. RAPI_TIMER_A3 Selects timer A channel 3. RAPI_TIMER_A4 Selects timer A channel 4.
__GetTimerRegister Synopsis Boolean __GetTimerRegister(unsigned long data1, unsigned int *data2) Description data1 Setup data data2 Pointer to the buffer in which register value is stored Gets the counter value of a specified timer. [data] For data, the following definition values can be set. RAPI_TIMER_A0 Selects timer A channel 0. RAPI_TIMER_A1 Selects timer A channel 1. RAPI_TIMER_A2 Selects timer A channel 2. RAPI_TIMER_A3 Selects timer A channel 3.
Reference Remark __SetTimerRegister, __EnableTimerRegister, __ClearTimerRegister • 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 ); } Rev.1.00 2007.11.
4.2.3 I/O Port __SetIOPort Synopsis Boolean __SetIOPort(unsigned long data1, unsigned int data2) Description data1 Setup data 1 data2 Setup data 2 Sets the operating conditions of a specified I/O port. [data1] For data1, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|” to separate each specified value. Note, however, that multiple ports cannot be specified at the same time.
RAPI_PORT_7_2 Port P72 RAPI_PORT_7_3 Port P73 RAPI_PORT_7_4 Port P74 RAPI_PORT_7_5 Port P75 RAPI_PORT_7_6 Port P76 RAPI_PORT_7_7 Port P77 RAPI_PORT_8_0 Port P80 RAPI_PORT_8_1 Port P81 RAPI_PORT_8_2 Port P82 RAPI_PORT_8_3 Port P83 RAPI_PORT_8_4 Port P84 RAPI_PORT_8_5 Port P85 RAPI_PORT_8_6 Port P86 RAPI_PORT_8_7 Port P87 RAPI_PORT_9_0 Port P90 RAPI_PORT_9_1 Port P91 RAPI_PORT_9_2 Port P92 RAPI_PORT_9_3 Port P93 RAPI_PORT_9_4 Port P94 RAPI_PORT_9_5 Port P95 RAPI_PORT_9_
I/O port Functionality __ReadIOPort, __WriteIOPort, __SetIOPortRegister, __ReadIOPortRegister, Reference __WriteIOPortRegister • If an undefined value is specified in the first argument, operation of the API cannot Remark 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 ); } Rev.1.00 2007.11.
__ReadIOPort Synopsis Boolean __ReadIOPort(unsigned long data1, unsigned int *data2) Description data1 Setup data 1 data2 Pointer to the variable in which the value read from I/O port is stored. Gets the value of a specified I/O port. [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_9_6 Port P96 RAPI_PORT_9_7 Port P97 RAPI_PORT_10_0 Port P100 RAPI_PORT_10_1 Port P101 RAPI_PORT_10_2 Port P102 RAPI_PORT_10_3 Port P103 RAPI_PORT_10_4 Port P104 RAPI_PORT_10_5 Port P105 RAPI_PORT_10_6 Port P106 RAPI_PORT_10_7 Port P107 RAPI_PORT_11_0 Port P110 RAPI_PORT_11_1 Port P111 RAPI_PORT_11_2 Port P112 RAPI_PORT_11_3 Port P113 RAPI_PORT_11_4 Port P114 RAPI_PORT_11_5 Port P115 RAPI_PORT_11_6 Port P116 RAPI_PORT_11_7 Port P117 RAPI_PORT_12_0 Port P120 RAP
__WriteIOPort Synopsis Boolean __WriteIOPort(unsigned long data1, unsigned int data2) Description data1 Setup data 1 data2 Data to be written to I/O port Writes data to a specified I/O port. [data1] Specify an I/O port to which data is written. The definition values corresponding to each I/O port are listed below.
Return value RAPI_PORT_9_6 Port P96 RAPI_PORT_9_7 Port P97 RAPI_PORT_10_0 Port P100 RAPI_PORT_10_1 Port P101 RAPI_PORT_10_2 Port P102 RAPI_PORT_10_3 Port P103 RAPI_PORT_10_4 Port P104 RAPI_PORT_10_5 Port P105 RAPI_PORT_10_6 Port P106 RAPI_PORT_10_7 Port P107 RAPI_PORT_11_0 Port P110 RAPI_PORT_11_1 Port P111 RAPI_PORT_11_2 Port P112 RAPI_PORT_11_3 Port P113 RAPI_PORT_11_4 Port P114 RAPI_PORT_11_5 Port P115 RAPI_PORT_11_6 Port P116 RAPI_PORT_11_7 Port P117 RAPI_PORT_12_0
__SetIOPortRegister Synopsis Boolean __SetIOPortRegister(unsigned long data1, unsigned int data2, unsigned int data3, unsigned int data4) Description data1 Setup data 1 data2 Setup data 2 data3 Setup data 3 data4 Setup data 4 [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.
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.
__ReadIOPortRegister Synopsis Boolean __ReadIOPortRegister(unsigned long data1, unsigned int *data2) Description data1 Setup data 1 data2 Pointer to the variable in which the value read from I/O port register is stored. Gets the value of a specified I/O port from each relevant register. [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 Boolean __WriteIOPortRegister(unsigned long data1, unsigned int data2) Description data1 Setup data 1 data2 Data to be written to I/O port register Writes the value for a specified I/O port to each relevant register. [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 Boolean __SetInterrupt(unsigned long data1, unsigned int data2, void* func) data1 Setup data 1 data2 Setup data 2 func Callback function pointer (Specify 0 if no callback functions are set.) 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 “|” to separate each specified value.
Return value If the external interrupt specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned. Functionality Reference Remark External interrupt __EnableInterrupt, __GetInterruptFlag, __ClearInterruptFlag • If an undefined value is specified in the first argument, operation of the API cannot be guaranteed. Program example #include " rapi_interrupt_m16c_62p.
__EnableInterrupt Synopsis Boolean __EnableInterrupt(unsigned long data1, unsigned int data2) Description data1 Setup data 1 data2 Setup data 2 Changes the operating condition of a specified external interrupt. [data1] RAPI_INT0 Uses _INT0 interrupt. RAPI_INT1 Uses _INT1 interrupt. RAPI_INT2 Uses _INT2 interrupt. RAPI_INT3 Uses _INT3 interrupt. RAPI_INT4 Uses _INT4 interrupt. RAPI_INT5 Uses _INT5 interrupt. RAPI_KEY Uses key input interrupt.
__GetInterruptFlag Synopsis Boolean __GetInterruptFlag(unsigned long data1, unsigned int *data2)) Description data1 Setup data 1 data2 Pointer to the buffer in which the acquired flag data is stored Gets the value of interrupt request flag of a specified external interrupt. [data1] RAPI_INT0 Uses _INT0 interrupt. RAPI_INT1 Uses _INT1 interrupt. RAPI_INT2 Uses _INT2 interrupt. RAPI_INT3 Uses _INT3 interrupt. RAPI_INT4 Uses _INT4 interrupt.
__ClearInterruptFlag Synopsis Boolean __ClearInterruptFlag(unsigned long data) data Description Setup data Clears the interrupt request flag of a specified external interrupt. [data] Return value RAPI_INT0 Uses _INT0 interrupt. RAPI_INT1 Uses _INT1 interrupt. RAPI_INT2 Uses _INT2 interrupt. RAPI_INT3 Uses _INT3 interrupt. RAPI_INT4 Uses _INT4 interrupt. RAPI_INT5 Uses _INT5 interrupt. RAPI_KEY Uses key input interrupt.
4.2.5 A/D converter __CreateADC Synopsis Boolean __CreateADC(unsigned long data1, unsigned int data2, unsigned int data3, void* func) data1 Setup data 1 data2 Number of analog input pins used by A/D converter data3 Setup data 3 func Callback function pointer (Specify 0 if no callback functions are set.) Description Sets the A/D converter to specified mode and operating condition. [data1] For data1, the following definition values can be set.
RAPI_AN27 Uses AN27 pin for the analog input pin. RAPI_P0_GROUP Uses port P0 group for the analog input pin. RAPI_P10_GROUP Uses port P10 group for the analog input pin. RAPI_P2_GROUP Uses port P2 group for the analog input pin. RAPI_FAD Sets the AD converter’s operating frequency to fAD. RAPI_FAD2 Sets the AD converter’s operating frequency to fAD divided by 2. RAPI_FAD3 Sets the AD converter’s operating frequency to fAD divided by 3.
(Input pin) Specify one from { RAPI_AN0, RAPI_AN1, RAPI_AN2, RAPI_AN3, RAPI_AN4, RAPI_AN5, RAPI_AN6, RAPI_AN7, RAPI_AN00, RAPI_AN01, RAPI_AN02, RAPI_AN03, RAPI_AN04, RAPI_AN05, RAPI_AN06, RAPI_AN07, RAPI_AN20, RAPI_AN21, RAPI_AN22, RAPI_AN23, RAPI_AN24, RAPI_AN25, RAPI_AN26, RAPI_AN27, RAPI_INEX0, RAPI_ANEX1 }. The default is RAPI_AN0. (Operating Specify one from { RAPI_FAD, RAPI_FAD2, RAPI_FAD3, RAPI_FAD4, frequency) RAPI_FAD6, RAPI_FAD12 }. The default value is RAPI_FAD4.
(Operating Specify one from { RAPI_AD_ON, RAPI_AD_OFF }. The default value is states set) RAPI_AD_OFF. (Conversion Specify one from { RAPI_WITH_SAMPLE_HOLD, method) RAPI_WITHOUT_SAMPLE_HOLD }. The default value is RAPI_WITHOUT_SAMPLE_HOLD. (Trigger) Specify one from { RAPI_SOFTWARE_TRIGGER, RAPI_EXTERNAL_TRIGGER }. The default value is RAPI_SOFTWARE_TRIGGER. (External Specify one from { RAPI_ANEX_UNUSED, RAPI_EXTERNAL_OP_AMP }. Op-Amp The default value is RAPI_ANEX_UNUSED.
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 ); } Rev.1.00 2007.11.
__EnableADC Synopsis Boolean __EnableADC (unsigned long data1, unsigned int data2) Description data1 Setup data 1 data2 Number of analog input pins used by A/D converter Controls operation of the A/D converter by starting or stopping it. [data1] RAPI_AN0 Uses AN0 pin for the analog input pin. Selectable only when one-shot mode or repeat mode is used. RAPI_AN1 Uses AN1 pin for the analog input pin. Selectable only when one-shot mode or repeat mode is used.
RAPI_AN21 Uses AN21 pin for the analog input pin. Selectable only when one-shot mode or repeat mode is used. RAPI_AN22 Uses AN22 pin for the analog input pin. Selectable only when one-shot mode or repeat mode is used. RAPI_AN23 Uses AN23 pin for the analog input pin. Selectable only when one-shot mode or repeat mode is used. RAPI_AN24 Uses AN24 pin for the analog input pin. Selectable only when one-shot mode or repeat mode is used. RAPI_AN25 Uses AN25 pin for the analog input pin.
Program example #include "rapi_ad_m16c_62p.h" void func( void ) { /* Disable A/D converter */ __EnableADC( RAPI_AN0|RAPI_AD_OFF, 1 ); } Rev.1.00 2007.11.
__DestroyADC Synopsis Boolean __DestroyADC(void) Description Discards settings of a specified A/D converter. Return value If converter setting was successfully discarded, RAPI_TRUE is returned; if failed, RAPI_FALSE is returned. Functionality Reference A/D converter __CreateADC, __EnableADC, __GetADC, __GetADCAll Program example #include "rapi_ad_m16c_62p.h" void func( void ) { /* Destroy A/D converter */ __DestroyADC(); } Rev.1.00 2007.11.
__GetADC Synopsis Boolean __GetADC(unsigned long data1, unsigned int *data2) data1 Setup data 1 data2 Pointer to the buffer in which A/D converted value is stored. Gets the A/D converted value from a specified A/D register. Description For data1, the following values can be set. RAPI_AD0 Selects A/D register 0. RAPI_AD1 Selects A/D register 1. RAPI_AD2 Selects A/D register 2. RAPI_AD3 Selects A/D register 3. RAPI_AD4 Selects A/D register 4.
__GetADCAll Synopsis Boolean __GetADCAll(unsigned int *data) data Description Pointer to the buffer in which A/D converted value is stored. 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/62P Group Renesas Embedded Application Programming Interface Reference Manual Rev. 1.00 Issued: November 2007 Rev.1.00 2007.11.