Resumen del contenido incluido en la página 1
Reference Manual
REC10B0002-0100
M16C/62P Group
Renesas Embedded
Application Programming Interface
Reference Manual
Rev.1.00
Revision Date: Nov.1, 2007
www.renesas.com
Resumen del contenido incluido en la página 2
Renesas Embedded Application Programming Interface Reference Manual 2 Rev.1.00 2007.11.1 REC10B0002-0100
Resumen del contenido incluido en la página 3
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..............................
Resumen del contenido incluido en la página 4
__DestroyTimer .......................................................... 43 __CreateEventCounter ..................................................... 44 __EnableEventCounter..................................................... 47 __DestroyEventCounter .................................................... 48 __GetEventCounter........................................................ 49 __CreatePulseWidthModulationMode ......................................... 50 __EnablePulseWidthModulationM
Resumen del contenido incluido en la página 5
1. Introduction The Renesas Embedded Application Programming Interface (API) is a unified API for the microcomputers made by Renesas Technology Corporation. 5 Rev.1.00 2007.11.1 REC10B0002-0100
Resumen del contenido incluido en la página 6
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. (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
Resumen del contenido incluido en la página 7
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. 7 Rev.1.00 2007.11.1 REC10B0002-0100
Resumen del contenido incluido en la página 8
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
Resumen del contenido incluido en la página 9
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. 9 Rev.1.00 2007.11.1 REC10B0002-0100
Resumen del contenido incluido en la página 10
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. 10 Rev.1.00 2007.11.1 REC10B0002-0100
Resumen del contenido incluido en la página 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. 11 Rev.1.00 2007.11.1 REC10B0002-0100
Resumen del contenido incluido en la página 12
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. 12 Rev.1.00 2007.11.1 REC10B0002-0100
Resumen del contenido incluido en la página 13
4. Library Reference 4.1 API List by Peripheral Facility The table below lists the Renesas Embedded APIs classified by peripheral facility. NO Facility API API operation classification Opens serial port Single-data 1 __BasicOpenSerialDriver serial I/O Closes serial port 2 __BasicCloseSerialDriver Sets serial communication 3 __BasicSetSerialFormat Receives 1 data 4 __BasicStartSerialReceiving Transmits 1 data 5 __BasicStartSerialSending Reads receive status 6 __BasicReceivingSt
Resumen del contenido incluido en la página 14
Sets pulse width measurement 35 __CreatePulseWidthMeasurementMode mode Controls operation of pulse width 36 __EnablePulseWidthMeasurementMode measurement mode Clears setting of pulse width 37 Timer __DestroyPulseWidthMeasurementMode measurement mode Acquires measured value of pulse 38 __GetPulseWidthMeasurementMode width measurement mode Sets timer register 39 __SetTimerRegister Controls operation of timer register 40 __EnableTimerRegister Clears timer register 41 __ClearTimerR
Resumen del contenido incluido en la página 15
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.
Resumen del contenido incluido en la página 16
4.2.1 Serial I/O __BasicOpenSerialDriver Synopsis Boolean __BasicOpenSerialDriver(unsigned long data) data Setup data Opens and initializes a specified serial port. Description 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 Return value If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned. Functionality S
Resumen del contenido incluido en la página 17
__BasicCloseSerialDriver Synopsis Boolean __BasicCloseSerialDriver(unsigned long data) data Setup data Closes a specified serial port. For data, the following values can be set. Description RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM4 SI/O3 RAPI_COM5 SI/O4 Return value If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned. Functionality Serial I/O Reference __Ba
Resumen del contenido incluido en la página 18
__BasicSetSerialFormat Synopsis Boolean __BasicSetSerialFormat(unsigned long data1, unsigned char data2) data1 Setup data 1 data2 Setup data 2 Description 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. RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM4 SI/O3
Resumen del contenido incluido en la página 19
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_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. (UART0, UART1, UART2) RAPI_DPOL_NON Polarity not invertedRAPI_DPOL_INV Polarity inverted
Resumen del contenido incluido en la página 20
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