Home
RX Family - Renesas Electronics
Contents
1. Add rule to channel 0 Route filtered messages to receive mailbox 2 err R CAN AddRxRule CAN CH0 amp filter CAN BOX RXMBX 2 Special Notes Rules cannot be entered after entering communications mode RO1AN2805EU0100 Rev 1 00 Page 23 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology 3 6 R CAN Control This function handles special operations and mode changes Format cean err c R CAN Comeol cem Cmo i cul UMED 1c euer p Parameters cmd Specifies which command to run typedef enum e can cmd CAN CMD ABORT TX argument transmit mailbox id CAN CMD RESET TIMESTAMP CAN CMD SET MODE COMM start normal bus communications CAN CMD SET MODE TST STANDARD CAN CMD SET MODE TST LISTEN CAN CMD SET MODE TST EXT LOOPBACK CAN CMD SET MODE TST INT LOOPBACK CAN CMD END ENUM can cmd t argl Argument which is specific to command Most commands do not require an argument For the command CAN_CMD_ABORT_TX the argument is a transmit mailbox id see Section 2 10 1 Return Values CAN_SUCCESS Successful CAN ERR INVALID ARG An invalid argument was provided CAN ERR ILLEGAL MODE Changing to requested mode is illegal from current mode Properties Prototyped in file r rscan rx if h Description This function is used for resetting the timestamp counter aborting transmiss
2. R CAN SendMsg Loads a message into a transmit mailbox or FIFO for transmission R CAN GetMsg Fetches a message from a receive mailbox or FIFO R CAN GetHistoryEntry Fetches a log entry from a transmit history FIFO R CAN GetStatusMask Returns a 32 bit mask based upon the status requested Bit defines have the form CAN MASK xxx R CAN GetCountFIFO Returns the number of messages in a FIFO R CAN GetCountErr Returns the number of transmit or receive errors R CAN Control Handles special operations and mode changes R CAN CloseQ Removes power to the CAN peripheral and disables the associated interrupts R CAN GetVersion Returns the driver version number RO1AN2805EU0100 Rev 1 00 May 20 2015 Page 14 of 37 RENESAS RX Family RSCAN Module Using Firmware Integration Technology 3 2 R CAN Open This function initializes the driver s internal structures and all of the receive mailboxes Format can err ic R CAN Opem cam Cto c O eg void const p callback Cam clo evt event void j args 7 Parameters pcfg Pointer to configuration structure The element type definitions are provided in Section 2 10 1 typedef struct st can cfg can timestamp src t ts source can timestamp div t ts divisor can cfg t p callback Optional pointer to main callback function Must be present if interrupts are enabled in r rscan rx co
3. This program requires the connection of a CAN device such as a sniffer capable of receiving and sending messages The program spins in a loop sending then receiving one message at a time The messages received must have an ID of 0x60 0x6F and contain at least 4 bytes of data The baud rate is set to 500Kbps This program can run using either mailboxes without interrupts or FIFOs with interrupts The desired operation is configured by changing the value of USE FIFOS in main c to 0 for mailboxes or 1 for FIFOs RO1AN2805EU0100 Rev 1 00 Page 36 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology 5 Website and Support Renesas Electronics Website http www renesas com Inquiries http www renesas com inquiry All trademarks and registered trademarks are the property of their respective owners RO1AN2805EU0100 Rev 1 00 Page 37 of 37 May 20 2015 RENESAS Revision Record Description Rev Date Page Summary 1 00 May 20 2015 Initial release General Precautions in the Handling of MPU MCU Products The following usage notes are applicable to all MPU MCU products from Renesas For detailed usage notes on the products covered by this document refer to the relevant sections of the document as well as any technical updates that have been issued for the products 1 Handling of Unused Pins Handle unused pins in accordance with the directions given under Handling of Unused Pin
4. Parameters chan Channel to apply rule to always 0 p_filter Pointer to rule information typedef struct st_can filter bool t check ide uint8 t ide bool t check rtr uint8 t rtr uint32 t id uint32 t id mask uint8 t min dlc uintl6 t label 12 bit label can filter t dst box Destination box receive mailbox or receive FIFO to route message to see Section 2 10 1 Return Values CAN SUCCESS Successful CAN ERR ILLEGAL MODE Not in global reset mode results from call to Open CAN ERR CH NO INIT Channel not initialized yet CAN ERR INVALID ARG An invalid argument was provided CAN ERR MAX RULES Max rules already present as defined in r rscan rx config h 128 channel or 320 total Properties Prototyped in file r_rscan_rx_if h Description This function is used to add a receive rule to a channel There are two parts to this The first part is specifying a filter as to which fields to inspect on received messages The second part is to specify a destination to route the message to if it passes the filter test A 1 in the id_mask field indicates that the corresponding bit in a received message ID will be checked against the bit in the id field in this filter see Examples The abel field in the rule is optional It is associated with each message that passes the filter This may serve as a quick identification of a message when it is fetched from a receive box mailbox or
5. 0x0800 define CAN MASK ERR RECESSIVE BIT 0x1000 define CAN MASK ERR DOMINANT BIT 0x2000 define CAN MASK ERR ACK DELIMITER 0x4000 2 10 11 R CAN GetCountErr Data Types typedef enum e can count RO1AN2805EU0100 Rev 1 00 May 20 2015 RENESAS Page 11 of 37 RX Family RSCAN Module Using Firmware Integration Technology CAN COUNT RX ERR CAN COUNT TX ERR CAN COUNT END ENUM can count t 2 10 12 R CAN Control Data Types typedef enum e can cmd CAN CMD ABORT TX argument transmit mailbox id CAN CMD RESET TIMESTAMP CAN CMD SET MODE COMM start normal bus communications CAN CMD SET MODE TST STANDARD G AG ip iS h iO ip popi STUNT G ANG ipoh MO p GESP ISI JOOYOUPSVACITSC CAN CMD SET MODE TST INT LOOPBACK CAN CMD END ENUM J can Gmel Aro 2 11 Return Values API function return values This enum is found in r_rscan_rx_if h along with the API function declarations EMSC enum can ems i CAN APT error codes CAN SUCCESS 0 CAN ERR OPENED Call to Open already made CAN FRR NOT OPENED Call to Open not yet made CAN ERR INIT DONE Call to InitChan already made for channel CAN ERR CH NO INIT Channel not initialized CAN ERR INVALID ARG Invalid argument passed to function CAN
6. CAN COUNT RX ERR CAN COUNT TX ERR CAN STAT END ENUM can count t chan Specifies which channel to return error count for must be 0 p_err Pointer to returned error code CAN_SUCCESS Successful CAN ERR INVALID ARG An invalid argument was provided Return Values The number of errors detected Properties Prototyped in file r rscan rx if h Description This function returns the number of receive or transmit errors on a channel based upon the count type requested Reentrant Yes Example ULES ic TESRCIONE p lesse p Gam Guo t erip Get the number of errors detected rxcnt R CAN GetCountErr CAN COUNT RX ERR CAN CHO amp err teene R CAN Get ountmrr CAN COUNT T ERR CAN CHO cerr y Special Notes This use of this function is optional It can be used to detect the health of the network and how close the network is to entering the Error Passive state 128 errors or Bus Off state 255 errors R01AN2805EU0100 Rev 1 00 Page 33 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology 3 13 R_CAN Close This function removes clock from the CAN peripheral and disables the associated interrupts Format void R CAN Close void Parameters None Return Values None Properties Prototyped in file r rscan rx if h Description This function halts all existing communications disables all interrupts if any and shuts down the peripher
7. Interrupt Configuration jw Mcp man Galllioagik iimtexrut Sources exe set to l im i racon ix couwrig m Cain CEG T CONE LCE Gaim err it uer Configure timestamp and Open driver Contig iz res awo STE CAN TIMESTAMY SINC BALE PCLK config timestamp div CAN TIMESTAMP DIV 1024 err R CAN jom comeing MyCallback p Sample callback function vord MiyCalLliogicis cam clo eyt t ese VoL Je args uri 52 E mask eum Guex 5 err ie event CAN EYT RXEIFO THRESHOLD mask R CAN GetStatusMask CAN STAT FIFO THRESHOLD NULL amp err check RXFIFOs in use if mask amp CAN MASK RXFIFO 1 read messages lse if event CAN EVT GLOBAL ERR mask R CAN GetStatusMask CAN STAT GLOBAL ERR NULL amp err if mask amp CAN MASK ERR DLC 5 hamclle DLE error if mask amp CAN MASK ERR FIFO OVFL mask R CAN GecSicactisMask CAN STAT PIFO OVEL NUL Grr check the RXFIFOs GWFIFO and HIST FIFOs in use if mask amp CAN MASK HIST FIFO Ingimclle error Special Notes None RO1AN2805EU0100 Rev 1 00 Page 16 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology 33 R CAN InitChan This function sets the bit rate clock for the channel and initializes all of the transmit mailboxes Format Geum err ie R CAN Mimilie Cimetim wines it Eha Cewa lo
8. REVISION RECOM PR T Lm 38 General Precautions in the Handling of MPU MCU Products essen 39 RO1AN2805EU0100 Rev 1 00 Page 3 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology 1 Overview This driver is compatible with the RSCAN driver provided with the RZ A1 Although the RSCAN peripheral on the RX231 is single channel the API remains the same A static configuration of mailboxes and FIFOs boxes is hardcoded as is done with the RZ A1 but much fewer resources are available for use All mailboxes are one message deep There are 4 transmit mailboxes and 4 receive mailboxes The transmit mailboxes can optionally be configured for interrupt operation whereas the receive mailboxes cannot The transmit mailboxes do not accept a message for transmit until the previous message has been sent The receive mailboxes always contain the most recent message received overwriting the previous contents without an error condition being generated There is no hardware interrupt option available The transmit and receive FIFOs are 4 messages deep FIFOs are used for the sending and receiving of messages just like a mailbox These can optionally be configured to be interrupt driven Setting a receive FIFO to interrupt on every message received would behave similar to a receive mailbox with interrupt support There is a special FIFO called the Transmit History FIFO and this FIFO is 8 entries deep Th
9. FIFO using R CAN GetMsg Q Reentrant No Example 1 Match a range of messages eum ix Ihesu w silter canlerrit GTE fe ecu ilro 7 Till or Check ide TENES check the IDE field in message RO1AN2805EU0100 Rev 1 00 Page 22 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology filter ide 0 PP O Tr HID filter check rir FALSE do moc check tche RTR field im message itle jue Of value does not matter here not checking filter id 0x040 message ID filter id mask Ox7F0 messages with IDs of 0x040 0x04F are accepted ilter min Clie 4p message data must be at least four bytes long filter label 0x800 arbitrary label applied to msgs of this type Add rule to channel 0 Route filtered messages to receive mailbox 3 err R CAN AddRxRule CAN CHO amp filter CAN BOX RXMBX 3 Example 2 Exact match for message eum wallieer w iile Comer r ti err Sep isle Z Fill or check ide TRUE check the IDE field la message ilter ide Oz ff Xi H ID Tiller check rtr FALSE co not check the RIR field in message filter rte 0p value does not matter here not checking rilcersid 0x040 message ID filcer id mask 0x7FF ID must match 0x040 exactly iile swa gie 65 message data must be at least six bytes long filter label 0x700 arbitrary label applied to msgs of this type
10. Sjw 1 4 can louiiente tp Sample settings for 500kbps define CAN RSK 27MHZ PCLKB 500KBPS PRESCALER 3 define CAN RSK 27MHZ PCLKB 500KBPS TSEGI 5 define CAN RSK 27MHZ PCLKB 500KBPS TSEG2 3 define CAN RSK 27MHZ PCLKB 500KBPS SJW 1 define CAN RSK 32MHZ PCLKB 500KBPS PRESCALER 2 define CAN RSK 32MHZ PCLKB 500KBPS TSEGI 11 define CAN RSK 32MHZ PCLKB 500KBPS TSEG2 4 define CAN RSK 32MHZ PCLKB 500KBPS SJW 4 alternate settings define CAN RSK 8MHZ XTAL 500KBPS PRESCALER 1 ti 2 define CAN RSK 8MHZ XTAL 500KBPS TSEG1 10 8 define CAN RSK 8MHZ XTAL 500KBPS TSEG2 5 M 2 define CAN RSK 8MHZ XTAL 500KBPS SJW 1 i 2 10 5 R CAN ContigFIFO Data Types typedef enum e can fifo threshold NOTE History FIFO can only have a P itueesmole eof 1 or 12 CAN FIFO THRESHOLD 2 3 4 8 of 4 CAN FIFO THRESHOLD 3 B 6 8 of 4 CAN FIFO THRESHOLD 6 Sy History FIFO Only CAN FIFO THRESHOLD FULL 7 LABSVAS of 4 RO1AN2805EU0100 Rev 1 00 Page 9 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology CAN FIFO THRESHO CAN FIFO THRESHOLD j ceam Lro thresholol ty 1 6 every messag END ENUM D D 2 10 6 R CAN AddRxRule Data Types typedef erruct st can Tiltrer loxoxodL ic emel cle uint8 t iglep IGGL jc Check gu uinte E Terg im MS id boumie 32 id mask vime E min elep uintl6 t tabel If 12 b Jewel can filter tz 2 10 7 R_CAN_Send
11. a reset only release the reset line after the operating clock signal has become stable When switching the clock signal during program execution wait until the target clock signal has stabilized When the clock signal is generated with an external resonator or from an external oscillator during a reset ensure that the reset line is only released after full stabilization of the clock signal Moreover when switching to a clock signal produced with an external resonator or by an external oscillator while program execution is in progress wait until the target clock signal is stable 5 Differences between Products Before changing from one product to another i e to a product with a different part number confirm that the change will not lead to problems The characteristics of an MPU or MCU in the same group but having a different part number may differ in terms of the internal memory capacity layout pattern and other factors which can affect the ranges of electrical characteristics such as characteristic values operating margins immunity to noise and amount of radiated noise When changing to a product with a different part number implement a system evaluation test for the given product Notice 1 Descriptions of circuits software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples You are fully responsible for the inco
12. if FIFOs are not used Format can err R CAN ClexsirineyE LEO Cam D0 t it ALIE BI Cam siro ele silo w ilm can box t txmbx Parameters fifo_id Box id for FIFO see Section 2 10 1 threshold Number of messages needed in FIFO to set interrupt flag see Section 2 10 5 Note that the only valid thresholds for the History FIFOs is 1 or 6 entries All others may use 1 2 3 or full 4 txmbx Box id for associated transmit mailbox for transmit FIFOs only This argument is ignored for receive and history FIFOs Return Values CAN_SUCCESS Successful CAN ERR ILLEGAL MODE Not in global reset mode results from call to Open CAN ERR CH NO INIT Channel not initialized yet CAN ERR INVALID ARG An invalid argument was provided CAN ERR MAX ONE GWFIFO Can only configure one gateway FIFO Properties Prototyped in file r rscan rx if h Description FIFO usage is optional This function is used to activate a FIFO Transmit and receive FIFOs are 4 entries deep history FIFO is 8 deep The transmit FIFO must have associated with it a standard transmit mailbox The number of the mailbox determines the priority of the FIFO when transmitting mailbox 0 highest priority mailbox 3 lowest Reentrant Yes for different FIFOs Example RX FIFO Cg eie qm eio Set interrupt flag on every message received on RX FIFO 0 5 Jueces OCCUES ibi CAN CHG INT RPO MRRESHOLD le Set CO I inm Corin Interrupt Calls
13. 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology Special Notes None RO1AN2805EU0100 Rev 1 00 Page 31 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology 3 141 R CAN GetCountFIFO This function returns the number of items in a FIFO Format whUme32 R CAN Gjew CiowenelE ILE Cam lox ie 90s 1l Eum Quer dq je uem Parameters box id Specifies which FIFO to check see Section 2 10 1 p_err Pointer to returned error code CAN_SUCCESS Successful CAN_ERR_INVALID_ARG An invalid argument was provided Return Values Number of items in the FIFO Properties Prototyped in file r rscan rx if h Description This function returns the number of items in the FIFO specified by box id This function is not required for normal operations Reentrant Yes Example ane 32 ie Cin p Gam Guo i5 ice Determine the number of messages in the History FIFO for channel 1 Cne IR CAN CoeCoumel lO CAN BOX CHL HIST IIO Gerry Special Notes All FIFO usage is optional RO1AN2805EU0100 Rev 1 00 Page 32 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology 3 12 R CAN GetCountErr Returns the number of transmit or receive errors Format whimn32 ic R CAN epi mie can Coumt E 349 QL chani comcs NOSIS i Parameters type Specifies which status to return typedef enum e can count
14. AM 20 bytes RAM 20 bytes Table 2 ROM and RAM code size 2 10 API Data Types This section details the data types that are used with the driver s API functions 2 10 1 Box IDs mailboxes and FIFOs typedef enum e can box CAN BOX NON Ei lI S unused parameter value CAN BOX CHO TXMBX CAN BOX CHO TXMBX CAN BOX CHO TXMBX CAN BOX CHO TXMBX LG TXMBX F FLG TXMBX F F LG TXMBX CAO JS CORON ae LG TXMBX CAN BOX RXMBX 0 LG RXMBX LG RXMBX LG RXMBX LG RXMBX CAN BOX RXMBX 1 zi CAN BOX RXMBX 2 CAN CAN BOX RXMBX 4 gt Q P CAN BOX RXFIFO 0 CAN PLG FIFO CAN MASK RXEIFO 0 CAN BOX RXFIFO 1 CAN PLG PIFO CAN MASK RPO 1 CAN BOX TXFIFO CAN FLG FIFO CAN MASK CHO TXFIFO 0 CAN BOX HIST FIFO CAN PLG PIFO CAN MASK CHO HISE PITRO g Can loox icp 2 10 2 R_CAN_Open Data Types typedeit comer mss e Se TT Sre CAN TIMESTAMP SRC HALF PCLK CAN TIMESTAMP SRC CANMCLK CAN TIMESTAMP SRC_END ENUM can cimesicemo Sre p 0 jm obtained from EXTAL pin typedef enum e can timestamp div CAN TIMESTAM CAN TIMESTAM CAN TIMESTAM CAN TIMESTAM CAN TIMESTAM CAN TIMESTAM CAN TIMESTAM CAN TIMESTAM CAN TIMESTAM CAN TIMESTAM CAN TIMESTAM CAN TIMESTAM CAN TIMESTAM CAN TIMESTAM CA
15. ERR MISSING CALLBACK Callback func not provided and ints requested CAN ERR MAX RULES Ii Max configured rules already present CAN ERR BOX FULL f f Weeinsimic wacuilloexoss or PIKO is Tull CAN ERR BOX EMPTY Xen imei Ieee Or EME ORS 3ELILIE CAN ERR ILLEGAL MODE Not in proper mode for request j Can eri icp 2 12 Adding the Module to Your Project For detailed explanation of how to add a FIT Module to your project see document RO1AN1723EU Adding FIT Modules to Projects In general a FIT Module may be added in 3 ways 1 Using e2studio File New Renesas FIT Module This adds the module and project include paths 2 Using e2studio File Import General Archive File from the project context menu 3 Unzipping the zip file into the project directory directly from Windows When using methods 2or 3 the include paths must be manually added to the project This is done in e2studio from the project context menu by selecting Properties gt C C Build gt Settings and selecting Compiler gt Source in the ToolSettings tab The green sign in the box to the right is used to pop a dialog box to add the include paths In that box click on the Workspace button and select the directories needed from the project tree structure displayed The directories needed for this module are e S workspace loc ProjName J r rscan rx e S workspace loc ProjName J r rscan rx src RO1AN2805EU0100 Rev 1 00 Page 12 of 37 May 20 2015
16. ESHOLD Setting to O disables interrupt when the HIST FIFO threshold is reached Setting to 1 enables interrupt Requires FIFO to be initialized via R CAN ConfigFIFO CAN EVT TRANSMIT is passed to the channel callback function CAN CFG INT MBX TX COMPLETE Setting to O disables interrupt when the mailbox completes transmission Setting to 1 enables interrupt CAN EVT TRANSMIT is passed to the channel callback function RO1AN2805EU0100 Rev 1 00 May 20 2015 Page 6 of 37 RENESAS RX Family RSCAN Module Using Firmware Integration Technology CAN CFG INT MBX TX ABORTED 0 Setting to O disables interrupt when the mailbox transmit is aborted Setting to 1 enables interrupt CAN_EVT_ TRANSMIT is passed to the channel callback function CAN CFG INT BUS ERROR 0 Setting to O disables interrupt when a bus error is detected Setting to 1 enables interrupt CAN EVT CHANNEL ERR is passed to the channel callback function CAN CFG INT ERR WARNING 0 Setting to O disables interrupt when an error warning is detected Setting to 1 enables interrupt CAN EVT CHANNEL ERR is passed to the channel callback function CAN CFG INT ERR PASSIVE l Setting to 0 disables interrupt when an error passive is detected Setting to 1 enables interrupt CAN EVT CHANNEL ERR is passed to the channel callback function CAN CFG INT BUS OFF ENTRY 1 Setting to 0 disables interrupt when a Bus Of
17. Msg Data Types typedei Siew Sic Can Sem bonne ic idep vinee t Terp nints E id uint8 t Ceg uint8 t data 8 bool iE one shot no retries on error txmbx only bool t log history true if want to log uint8 t label 8 bit label for History FIFO can txmsg t 2 10 8 R CAN GetMsg Data Types ityjeeclei rus CEN moc bam 1c ider Baines T TEG uint3I2 E id uint8 t lip uinte E data 8 inclo t label ff 12 bit label from receive rule nimele E timestamp j Can meg T 2 10 9 R_CAN_GetHistoryEntry Data Types eee erruct st can NisStory ramo oe Dos rq box which sent message uint8 t Habel associated 8 bit label j can lasicomy Ep 2 10 10 R CAN GetStatusMask Data Types RO1AN2805EU0100 Rev 1 00 Page 10 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology typedef enum S can star CAN CAN CAN CAN CAN CAN CAN CAN CAN STAT STAT FIFO EMPTY STAT FIFO THRESHOLD STAT FIFO OVFL RXMBX FULL STAT GLOBA STAT ERR CH TXMBX SE SUAT CH TXMBX AB _ STAT ESTATE j Can grat ice CH ERROR END ENUM NEG ORTI Eri louLite ses Gites p error Dit iS ading bits reset after bits reset after lguLite reger
18. N TIMESTAM DIV 1 DIV 2 DIV 4 DIV_8 DIV 16 DIV 32 DIV 64 biy 128 DIV 256 DIV 512 Diy 1024 10 Diy 2048 11 Diy 4096 12 UP 8192 13 DIV 163804 14 OO e py x des 9 N i S amp Re l ho nol ang TU ine mgl m ang ino ine leh UU eaa TU ng R01AN2805EU0100 Rev 1 00 Page 8 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology CAN TIMESTAMP DIY 32768 ILS CAN TIMESTAMP DIV END ENUM Cam timestemo chow Ep ity pecler erruct St Cam Ci CAM tCimesteamo STe E CUMS ICSD SEC can timestemo Cliw t timestamp div j Cam cue icp 2 10 3 Callback function events typedeit enim e can clo evt callback function events Main Callback Events CAN EVT RXFIFO THRESHOLD RX FIFO threshold CAN EVT GLOBAL ERR RX or Hist FIFO overflow or DLC error Channel Callback Events CAN EVT TRANSMIT mbx tx complete or aborted tx or history FIFO threshold CAN EVT CHANNEL ERR Cam cl evt t 2 10 4 R_CAN_InitChan Data Types typeert cien gne Can onu care vincie t puescelerp 1 1024 uint8 t tsegl 4 16 uint8 t tseg2 f 2 8 Uum E
19. RENESAS RX Family RSCAN Module Using Firmware Integration Technology e S workspace loc ProjNamej r config Regardless of the method used to add the FIT Module and include paths to your project it is necessary to configure the module for your application Options available for configuration may be found and edited in e WX config rscan rx config h A reference copy not for editing containing the default values for this file is stored in e r_rscan_rx ref r_rscan_rx_config_reference h Any application file which calls a module s API function should include the interface file r_rscan_rx_if h and configuration file r rscan rx config h This file contains the API function declarations and all structures and enumerations necessary to use the module RO1AN2805EU0100 Rev 1 00 Page 13 of 37 May 20 2015 RENESAS RX Family 3 API Functions RSCAN Module Using Firmware Integration Technology 3 1 Summary The following functions are included in this design Function Description R CAN Open Initializes the driver s internal structures and all of the receive mailboxes R CAN InitChan Sets the bit rate clock for the channel and initializes all of the transmit mailboxes R CAN ConfigFIFO Initializes a FIFO for usage This function should not be called if FIFOs are not used R CAN AddRxRuleO Adds a receive rule to a channel Specifies receive message filter and destination routing
20. aSENCES AS APPLICATION NOTE i R01AN2805EU0100 rs r aniy Rev 1 00 RSCAN Module Using Firmware Integration Technology May 20 2015 Introduction This document describes the API for the RSCAN driver for the RX231 Message transfers can be done using 1 message deep mailboxes 4 message deep FIFOs or any combination thereof NOTE When developing an application with the RSKRX231 and the E1 emulator and the E1 emulator is powering the target board be sure that it is supplying 5 0V and not 3 3V specified in Debug Configuration or the RSCAN will not operate properly Target Device The following is a list of devices that are currently supported by this API e RX231 Group When using this application note with other Renesas MCUS careful evaluation is recommended after making modifications to comply with the alternate MCU Related Documents e Firmware Integration Technology User s Manual RO1ANI1833EU e Board Support Package Firmware Integration Technology Module RO1 AN1685EU e Adding Firmware Integration Technology Modules to Projects ROLAN1723EU e Adding Firmware Integration Technology Modules to CubeSuite Projects ROLAN1826EJ RO1AN2805EU0100 Rev 1 00 Page 1 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology Contents Vi QVEIVIOW e E EE E E 4 2 API normato TRA AEEA 5 21 Hardware Hequilremerits eid ette ereatec erede neaei eaa arai a ERR e BEER E eade 5 2 2 Hardware R
21. al Reentrant Yes but no need to ever call more than once Example J CONN J eoee 2 Special Notes None RO1AN2805EU0100 Rev 1 00 Page 34 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology 3 14 R CAN GetVersion This function returns the driver version number at runtime Format uno R CAN er We os L Om wionLel 2 Parameters None Return Values Version number Properties Prototyped in file r rscan_rx_if h Description Returns the version of this module The version number is encoded such that the top two bytes are the major version number and the bottom two bytes are the minor version number RO1AN2805EU0100 Rev 1 00 Page 35 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology 4 Demo Project Demo projects are complete stand alone programs They include function main that utilizes the module and its dependent modules e g r bsp The standard naming convention for the demo project is module demo board where module is the peripheral acronym e g s12ad cmt sci and the board is the standard RSK e g rskrx231 For example rscan FIT module demo project for RSKRX231 will be named as rscan demo rskrx231 Similarly the exported zip file will be module demo board zip For the same example the zipped export import file will be named as rscan demo rskrx231 zip 4 1 rscan demo rskrx231
22. ameters box_id Receive box id mailbox or FIFO see Section 2 10 1 p_rxmsg Pointer to message buffer to load typedef struct st_can_rxmsg uint8 t ide uint8 t rtr uint32 t id uint8 t dlc uint8 t data 8 uintl6 t label 12 bit label from receive rule uintl16 t timestamp can rxmsg t Return Values CAN SUCCESS Successful CAN ERR CH NO INIT Channel not initialized yet CAN ERR INVALID ARG An invalid argument was provided CAN ERR BOX EMPTY No message available to fetch Properties Prototyped in file r rscan rx if h Description This function loads the message from a receive mailbox or FIFO into the message buffer provided If there are no messages in the box this function does not block and returns a CAN ERR BOX EMPTY Reentrant Yes for different boxes Example can rxmsg t rxmsg eum uen qn NH Wait for message to appear in receive mailbox 3 while R CAN GetMsg CAN BOX RXMBX 3 amp rxmsg CAN ERR BOX EMPTY rxmsg contains message Special Notes None RO1AN2805EU0100 Rev 1 00 Page 28 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology 3 9 R CAN GetHistoryEntry This function fetches a log entry from a transmit history FIFO Format can err t R CAN Cerhigtorymmcry Cem box ic box id Cam MiScomy it pg eux Parameters box id Transmit history FIFO see Section 2 10 1 p rxmsg P
23. arcar HH HH set after reading ading ading ading at the same time Hj 97 Returned mask values multiple bits may be set CAN STAT CH TXMBX SENT CAN STAT CH TXMBX ABORTI define CAN MASK TXMBX 0 0x0001 define CAN MASK TXMBX 1 0x0002 define CAN MASK TXMBX 2 0x0004 define CAN MASK TXMBX 3 0x0008 CAN STAT RXMBX FULL define CAN MASK RXMBX 0 0x0001 define CAN MASK RXMBX 1 0x0002 define CAN MASK RXMBX 2 0x0004 define CAN MASK RXMBX 3 0x0008 CAN STAT FIFO EMPTY CAN STAT FIFO THRESHOLD CAN STAT FIFO OVFL define CAN MASK RXFIFO 0 0x00000001 define CAN MASK RXFIFO 1 0x00000002 define CAN MASK TXFIFO 0x00000100 define CAN MASK HIST FIFO 0x00800000 CAN STAT GLOBAL ERR define CAN MASK ERR DLC 0x0001 define CAN MASK ERR RX OVFL 0x0002 define CAN MASK ERR HIST OVFL 0x0004 define CAN MASK ERR FIFO OVFL 0x0006 CAN STAT CH ERROR define CAN MASK ERR PROTOCOL 0x0001 define CAN MASK ERR WARNING 0x0002 define CAN MASK ERR PASSIVE 0x0004 define CAN MASK ERR BUS OFF ENTRY 0x0008 define CAN MASK ERR BUS OFF EXIT 0x0010 define CAN MASK ERR OVERLOAD 0x0020 define CAN MASK ERR DOMINANT LOCK 0x0040 define CAN MASK ERR ARB LOST 0x0080 define CAN MASK ERR STUFF 0x0100 define CAN MASK ERR FORM 0x0200 define CAN MASK ERR ACK 0x0400 define CAN MASK ERR CRC
24. atus to return typedef enum e can stat CAN STAT FIFO EMPTY CAN STAT FIFO THRESHOLD CAN STAT FIFO OVFL bits reset after reading CAN STAT RXMBX FULL CAN STAT GLOBAL ERR DLC error bit is reset after reading CAN STAT CH TXMBX SENT bits reset after reading CAN STAT CH TXMBX ABORTED bits reset after reading CAN STAT CH ERROR bits reset after reading CAN STAT END ENUM can stat t chan Specifies which channel to return status for must be 0 Applies only to CAN STAT CH xxx requests p_err Pointer to returned error code CAN_SUCCESS Successful CAN ERR INVALID ARG An invalid argument was provided Return Values 32 bit box or error mask whose bit definitions have the form CAN MASK xxx and are defined in Section 2 10 10 Properties Prototyped in file r rscan rx if h Description This function returns a mask based upon the status type requested All bit masks have the form CAN MASK xxx see Section 2 10 10 Reentrant Yes Example Gain err t iie can_rxmsg_t rxmsg Wait for a message to come in on any receive mailbox while R CAN GetStatusMask CAN STAT RXMBX FULL 0 amp err 0 j Ene bi Ece ee iverna ibon 3 abe KEW air R CAN GetStatusMask CAN STAT RXMBX FULL 0 amp err amp CAN MASK RXMBX 3 get message R CAN GetMsg CAN BOX RXMBX 3 amp rxmsg RO1AN2805EU0100 Rev 1 00 Page 30 of 37 May 20
25. d applications for each Renesas Electronics product depends on the product s quality grade as indicated below Standard Computers office equipment communications equipment test and measurement equipment audio and visual equipment home electronic appliances machine tools personal electronic equipment and industrial robots etc High Quality Transportation equipment automobiles trains ships etc traffic control systems anti disaster systems anti crime systems and safety equipment etc Renesas Electronics products are neither intended nor authorized for use in products or systems that may pose a direct threat to human life or bodily injury artificial life support devices or systems surgical implantations etc or may cause serious property damages nuclear reactor control systems military equipment etc You must check the quality grade of each Renesas Electronics product before using it in a particular application You may not use any Renesas Electronics product for any application for which it is not intended 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 which the product is not intended by Renesas Electronics 6 You should use the Renesas Electronics products described in this document within the range specified by Renesas Electronics especially with respect to the maximum rating operating supply voltage rang
26. d in the r rscan rx config h file Default values for p baud are provided in r rscan rx if h See sections 36 10 2 36 10 3 in the RX231 Hardware User s Manual for calculating Tq bit rate values If interrupts are enabled in r rscan rx config h for TX mailboxes TX FIFOs History FIFOs or bus errors a callback function must be provided here Otherwise NULL is entered Reentrant Yes for different channels Example Polling Configuration RO1AN2805EU0100 Rev 1 00 Page 17 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology All channel interrupt sources are set to 0 in r rscan rx config h can bitrate ic baud Gaim err it E Z Die talla Clgmnael J Z baud prescaler CAN RSK 8MHZ XTAL 500KBPS PRESCALER baud tsegl CAN RSK 8MHZ XTAL 500KBPS TSEGI baud tseg2 CAN RSK 8MHZ XTAL 500KBPS TSEG2 baud sjw CAN RSK 8MHZ XTAL 500KBPS SJW err R CAN InitChan CAN CHO amp baud NULL Example Interrupt Configuration ise Cline interrupt SOURCES are SSE tO i im r rocan xx Ont l Cam bitrate baud cam err ig emr Initialize channel 1 baud prescaler CAN RSK 8MHZ XTAL 500KBPS PRESCALER boudi c eo CAIN INS SIME xcd IOS SIG D baud tseg2 CAN RSK 8MHZ XTAL 500KPS TSEG2 baud sjw CAN RSK 8MHZ XTAL 500KPS SJW err R CAN InitChan CAN CHO amp baud MyChanCallback Sample callbac
27. e movement power voltage range heat radiation characteristics installation and other product characteristics Renesas Electronics shall have no liability for malfunctions or damages arising out of the use of Renesas Electronics products beyond such specified ranges 7 Although Renesas Electronics endeavors to improve the quality and reliability of its products semiconductor products have specific characteristics such as the occurrence of failure at a certain rate and malfunctions under certain use conditions Further Renesas Electronics products are not subject to radiation resistance design Please be sure to implement safety measures to guard them against the possibility of physical injury and injury or damage caused by fire in the event of the failure of a Renesas Electronics product such as safety design for hardware and software including but not limited to redundancy fire control and malfunction prevention appropriate treatment for aging degradation or any other appropriate measures Because the evaluation of microcomputer software alone is very difficult please evaluate the safety of the final products or systems manufactured by you 8 Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility of each Renesas Electronics product Please use Renesas Electronics products in compliance with all applicable laws and regulations that regulate the inclusion or use of controlled substa
28. e History FIFO logs all messages tagged in an R CAN SendMsg call in the order they are sent Note that any FIFO usage is optional and are not required for normal operation The RSCAN hardware processes all messages transmitted on the bus but uses Receive Rules to determine which messages to keep and which to ignore A Receive Rule consists of two parts The first part performs filtering on different parts of the message to see if the message should be kept The second part specifies which box receive mailbox or receive FIFO to route the message to After the hardware routes a message to a box the function R CAN GetMsg is used to read a message from the box There are two types of interrupts available global interrupts and channel interrupts The global interrupts indicate when a receive FIFO has received a message as well as when a global error occurs These interrupts are enabled in the r rscan rx config h file The driver detects the interrupt and calls a user callback function specified in R CAN Open to process the particular event s The channel interrupts handle several transmit conditions as well as channel errors These interrupts are also enabled in the r rscan rx config h file The driver detects the interrupt and calls a user callback function specified in R CAN InitChan to process the particular event s By default the following interrupts are enabled RX TX or History FIFO threshold reached RX TX or History FIFO
29. each received message will fix at 1 destination could be up to 3 Different methods of Bus Off recovery will be ISO11898 1 compliant Forcible return from Bus Off Selection of protocol error flag accumulation vs first occurrence will hard code to accumulative for all channels 2 5 Supported Toolchains This driver is tested and working with the following toolchains e Renesas RXC v2 02 2 6 Header Files All API calls and their supporting interface definitions are located in r rscan rx if h Build time configuration options are set in the file r rscan rx config h the default values are defined in the file r rscan rx config reference h Both of these files should be included by the user s application 2 7 Integer Types This project uses ANSI C99 Exact width integer types in order to make the code clearer and more portable These types are defined in stdint h RO1AN2805EU0100 Rev 1 00 Page 5 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology 2 8 Configuration Overview Static configuration options for this driver are set by the user via the file r rscan rx config h Configuration options in r_rscan_rx_config h Equate Default Value Description CAN_CFG PARAM CHECKING ENABLE 1 Setting to 0 removes parameter checking from the code Setting to includes parameter checking in the code CAN CFG CLOCK SOURCE If this e
30. esource Requirements U U enne nennen enne nnne nennen nein 5 2 9 Software Redgulremierits cot irpo rea aaa Rae AAA Fer Dente tua bete oa qusqapas dal 5 PE NIMIRUM 5 2 5 Supported TOOICHAINS 1 ect rt ttt tet ecu ein en ede eara ga Pene ut Ev dac 5 AIME Sod 5 2 7 mMteger PT 5 2 8 Configuration Overview ssesssssssssssssseseeee entente intret en resiste sn srnr entes nnns inni s sn nennen nnns 6 2 9 Code 7 2 10 API Data Typo Sesan AESAAT E SAE EA 8 2 10 1 Box IDs mailboxes and FIFOSs n nn 8 2 10 2 FR CAN Open Data Typ8Sx uuu a a a aa iaaa 8 2 10 3 Callback function events U ennemi nnn en rennen nnns nnn tennent 9 2 10 4 R CAN InitChan Data Types a sensn nene rene 9 2 10 5 R CAN ConfigFIFO Data Types nennen nennen nnns n nennen nene 9 2 10 6 R CAN AaddRxRule Data Types sssssssssseseseeeeneeeen nennen nennen nnne 10 2 10 7 R CAN SendMsg Data Types sisstin iaaa aaae aaea aaraa aa aE nnns ettet innen 10 2 10 8 R CAN GetMsg Data Types neren nentes nnns nentes 10 2 10 9 R CAN GetHistoryEntry Data Types nennen terrens 10 2 10 10 R CAN GetStatusMask Data Types L 10 2 10 11 R CAN GetCountErr Data Types L n u 11 2 10 12 R CAN G
31. f error is detected Setting to 1 enables interrupt CAN EVT CHANNEL ERR is passed to the channel callback function CAN CFG INT BUS OFF RECOVERY 1 Setting to 0 disables interrupt when a Bus Off recovery is detected Setting to 1 enables interrupt CAN EVT CHANNEL ERR is passed to the channel callback function CAN CFG INT OVERLOAD FRAME TX 0 Setting to O disables interrupt when an overload is detected Setting to 1 enables interrupt CAN EVT CHANNEL ERR is passed to the channel callback function CAN CFG INT BUS LOCK 0 Setting to O disables interrupt when a bus lock is detected Setting to 1 enables interrupt CAN EVT CHANNEL ERR is passed to the channel callback function CAN CFG INT ARB LOST 0 Setting to O disables interrupt when arbitration loss is detected Setting to 1 enables interrupt CAN EVT CHANNEL ERR is passed to the channel callback function Table 1 Info about the configuration 2 9 Code Size The code size is based upon optimization level 2 for the RXC Toolchain These code sizes include all interrupt handlers configured active or not as well as all FIFO support code ROM and RAM code sizes With Parameter Checking Without Parameter Checking RX231 ROM 8127 bytes code ROM 4330 bytes code RO1AN2805EU0100 Rev 1 00 May 20 2015 Page 7 of 37 RENESAS RX Family RSCAN Module Using Firmware Integration Technology R
32. ion of mailbox messages and changing the CAN mode The following sequence of function calls is used to setup the CAN R CAN Open R CAN InitChan R CAN ConfigFIFO do for 0 or more FIFOS R CAN AddRxRule do for 1 16 rules Once the CAN is setup the peripheral should enter normal communications mode or a test mode R CAN Control Use CAN CMD SET MODE COMM or CAN CMD SET MODE TST xxx Note If a Bus Off condition is detected on a channel the channel enters Halt Mode and all communications cease They cannot resume until after a Bus Off Recovery condition is detected and the application calls R CAN Control CAN CMD SET MODE COMM Reentrant Yes Example Enter Normal Communications Mode Gam Guo t sgp RO1AN2805EU0100 Rev 1 00 Page 24 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology ern R CAN Control CAN CUD SET MODD COMM Oy Example Abort Transmit Can ert 5 erip Abort transmit on mailbox 6 on channel 1 err R CAN Control CAN CMD ABORT TX CAN BOX CHO TXMBX 6 Special Notes Summary of different test modes e Standard Test Mode Allows for CRC testing e Listen only Mode Used for detecting communication speed Cannot call R CAN SendMsg in this mode e Internal Loopback Mode Messages sent on a channel are handled as received messages and processed on that same channel Here the CAN tra
33. k function template void MyChanCallback uint8 t chan can clo ewe event void jp mute wint e mask com cr tT err iE event CAN EVT TRANSMIT I macki GN Ger sss CAN na GETESTET em MM RS je echeck transmit madliooxas ium use if mask amp CAN MASK TXMBX 3 fs glo eruti mask R CAN GetStatusMask CAN STAT CH TXMBX ABORT rs iD Gaei ecer p check transmit mailboxes in use if mask amp CAN MASK TXMBX 0 fe CO Stuti mask R CAN GetStatusMask CAN STAT FIFO THRESHOLD NULL amp err f Chek itwansimlic ew bisicomy IUIS sm use if mask amp CAN MASK TXFIFO RO1AN2805EU0100 Rev 1 00 Page 18 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology load next batch of messages for transmit lse if event CAN EVT CHANNEL ERR mask R ANM oe umum l CAN STAI CH BRAROR Cheni amp err je check incdiyicual errors ii desiree 7 if mask amp CAN MASK ERR BUS OFF ENTRY gt heandle error if mask amp CAN MASK ERR BUS OFF EXIT handle recovery Special Notes None RO1AN2805EU0100 Rev 1 00 Page 19 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology 34 R CAN ConfigFIFO This function initializes a FIFO for usage This function should not be called
34. l 86 21 2226 0888 Fax 86 21 2226 0999 Renesas Electronics Hong Kong Limited Unit 1601 1611 16 F Tower 2 Grand Century Place 193 Prince Edward Road West Mongkok Kowloon Hong Kong Tel 852 2265 6688 Fax 852 2886 9022 Renesas Electronics Taiwan Co Ltd 13F No 363 Fu Shing North Road Taipei 10543 Taiwan Tel 886 2 8175 9600 Fax 886 2 8175 9670 Renesas Electronics Singapore Pte Ltd 80 Bendemeer Road Unit 406 02 Hyflux Innovation Centre Singapore 339949 Tel 65 6213 0200 Fax 65 6213 0300 Renesas Electronics Malaysia Sdn Bhd Unit 1207 Block B Menara Amcorp Amcorp Trade Centre No 18 Jln Persiaran Barat 46050 Petaling Jaya Selangor Darul Ehsan Malaysia Tel 60 3 7955 9390 Fax 60 3 7955 9510 Renesas Electronics India Pvt Ltd No 777C 100 Feet Road HALII Stage Indiranagar Bangalore India Tel 91 80 67208700 Fax 91 80 67208777 Renesas Electronics Korea Co Ltd 12F 234 Teheran ro Gangnam Gu Seoul 135 080 Korea Tel 82 2 558 3737 Fax 82 2 558 5141 2015 Renesas Electronics Corporation All rights reserved Colophon 5 0
35. main callback function with CAN BVT RXFIFO THRESHOLD By err R CAN ConfigFIFO CAN BOX RXFIFO 0 CAN FIFO THRESHOLD 1 CAN BOX NONE unused field her Example TX FIFO canierrie eio S ASSOCIAES iran 3S wiitla OX PIO 0 om cloeunueel i RO1AN2805EU0100 Rev 1 00 Page 20 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology Set interrupt flag when 2 messages remain in FIFO 5 mi eiespjou OCCUES ib CAN CHG INT TEXOSIUSU MRIRESHOLD le Set CO dL ium mi eo interrot Calle channel Callback icwincicsem wan CAIN VIE CEEQNSISIMUTE Ein err R CAN ConfigFIFO CAN BOX TXFIFO CAN FIFO THRESHOLD 2 CNN G lt Ch ule 3 p Example History FIFO Cem Quee C Quee x SSG tareshole to G cor history IO JDaeexexewsiE OCCUWIES Iie CANN CHE NDD GOES PIO ESUSUESUBKOUE D is Sei GO Con las Interrupt calls channel callback function with CAN EVT TRANSMIT 5 err R CAN ConfigFIFO CAN BOX HIST FIFO CAN FIFO THRESHOLD 6 CAN BOX NONE unused field her Special Notes None RO1AN2805EU0100 Rev 1 00 Page 21 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology 35 R CAN AddRxRule This function adds a receive rule to a channel Specifies receive message filter and destination routing Format Cum err t R CAN Zxelolssdewwdbe nane t chan Cam iles t qo ilb can box t dsit box
36. nces including without limitation the EU RoHS Directive Renesas Electronics assumes no liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations 9 Renesas Electronics products and technology may not be used for or incorporated into any products or systems whose manufacture use or sale is prohibited under any applicable domestic or foreign laws or regulations You should not use Renesas Electronics products or technology described in this document for any purpose relating to military applications or use by the military including but not limited to the development of weapons of mass destruction When exporting the Renesas Electronics products or technology described in this document you should comply with the applicable export control laws and regulations and follow the procedures required by such laws and regulations 10 It is the responsibility of the buyer or distributor of Renesas Electronics products who distributes disposes of or otherwise places the product with a third party to notify such third party in advance of the contents and conditions set forth in this document Renesas Electronics assumes no responsibility for any losses incurred by you or third parties as a result of unauthorized use of Renesas Electronics products 11 This document may not be reproduced or duplicated in any form in whole or in part without prior written consent of Renesas Electronics 12 Please contact a Re
37. nesas Electronics sales office if you have any questions regarding the information contained in this document or Renesas Electronics products or if you have any other inquiries Note 1 Renesas Electronics as used in this document means Renesas Electronics Corporation and also includes its majority owned subsidiaries Note 2 Renesas Electronics product s means any product developed or manufactured by or for Renesas Electronics 44 NE SAS SALES OFFICES Renesas Electronics Corporation http www renesas com Refer to http www renesas com for the latest and detailed information Renesas Electronics America Inc 2801 Scott Boulevard Santa Clara CA 95050 2549 U S A Tel 1 408 588 6000 Fax 1 408 588 6130 Renesas Electronics Canada Limited 9251 Yonge Street Suite 8309 Richmond Hill Ontario Canada L4C 9T3 Tel 1 905 237 2004 Renesas Electronics Europe Limited Dukes Meadow Millboard Road Bourne End Buckinghamshire SL8 5FH U K Tel 44 1628 585 100 Fax 44 1628 585 900 Renesas Electronics Europe GmbH Arcadiastrasse 10 40472 D sseldorf Germany Tel 49 211 6503 0 Fax 49 211 6503 1327 Renesas Electronics China Co Ltd Room 1709 Quantum Plaza No 27 ZhiChunLu Haidian District Beijing 100191 P R China Tel 86 10 8235 1155 Fax 86 10 8235 7679 Renesas Electronics Shanghai Co Ltd Unit 301 Tower A Central Towers 555 Langao Road Putuo District Shanghai P R China 200333 Te
38. nfig h for RX FIFOs or global errors event First parameter for callback function Specifies the interrupt source see Section 2 10 3 p args Second parameter for callback function unused Return Values CAN SUCCESS Successful CAN ERR OPENED Call to Open already made CAN ERR INVALID ARG An element of the p cfg structure contains an invalid value CAN ERR MISSING CALLBACK A callback function was not provided and a main callback interrupt is enabled in config h Properties Prototyped in file r rscan rx if h Description This function initializes the driver s internal structures applies clock to the peripheral and sets the Global and Channel Modes to Reset The timestamp is configured as per the p cfg argument and all receive mailboxes are initialized If interrupts are enabled in r rscan rx config h for receive FIFO thresholds or DLC or FIFO overflow errors a callback function must be provided here Otherwise NULL is entered Reentrant No Example Polling Configuration fe PLI moin callback interrupt sources are set io O i r recan rz Conii m wy cam Cig ic COE L P Gain err E enti Configure timestamp and Open driver CONE LG o timestamp sire CAN TIMESTAMP SRC HALF PCLK config timestamp div CAN TIMESTAMP DIV 1024 RO1AN2805EU0100 Rev 1 00 Page 15 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology err R CAN Open amp config NULL Example
39. nsceiver is bypassed e External Loopback Mode Same as Internal Loopback mode only the transceiver is used RO1AN2805EU0100 Rev 1 00 Page 25 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology 3 7 R CAN SendMsg This function loads a message into a transmit mailbox or FIFO for transmission Format cean err EMT mase ammo o box id Cain iExenmeo t jo Weg pg Parameters box id Transmit box id mailbox or FIFO see Section 2 10 1 p msg Pointer to message to send typedef struct st can txmsg uint8 t ide uint8 t rtr uint32 t id uint8 t dlc uint8 t data 8 bool t one shot no retries on error txmbx only bool t log history true if want to log uint8 t label 8 bit label for History FIFO can txmsg t Return Values CAN SUCCESS Successful CAN ERR INVALID ARG An invalid argument was provided CAN ERR BOX FULL Transmit mailbox or FIFO is full CAN ERR ILLEGAL MODE Cannot send message in current mode Properties Prototyped in file r rscan rx if h Description This function places a message into a 1 message deep transmit mailbox or 4 message deep transmit FIFO If there is already a message waiting to send in the mailbox or 4 messages already exist in the FIFO CAN ERR BOX FULL is returned immediately If the box id is for a transmit mailbox and interrupts are not enabled CAN CFG INT MBX TX COMPLETE is 0 this function blocks until
40. ointer to entry buffer to load typedef struct st can history can box t box id box which sent message uint8 t label associated 8 bit label can history t Return Values CAN SUCCESS Successful CAN ERR INVALID ARG An invalid argument was provided CAN ERR BOX EMPTY No entry available to fetch Properties Prototyped in file r rscan rx if h Description An entry is added to the history FIFO each time an R CAN SendMsg0 is called with the log history in the argument structure is set to TRUE This function loads a log entry from a transmit history FIFO into the entry buffer provided If there are no entries in the FIFO this function does not block and returns a CAN ERR BOX EMPTY The use of this feature is not required for normal operations Reentrant Yes for different boxes Example can nhigtory entry Gain err E o Process all entries in transmit history FIFO while R CAN GetMsg CAN BOX HIST FIFO amp entry CAN SUCCESS process entries here Special Notes None RO1AN2805EU0100 Rev 1 00 Page 29 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology 3 10 R CAN GetStatusMask This function returns a 32 bit mask based upon the status requested Bit defines have the form CAN MASK xxx Format whUmc32 ic R CAN GerstatueMesk can Stet wise uint8 t chan eum ues dE p err Parameters type Specifies which st
41. ontrol Data TypeS uu cte tte dc tee E E reati dto nnda 12 ARMIGER 12 2 12 Adding the Module to Your Project I eren ene nnnm en nnne 12 3 JAPLFUNCHIONS M l el ea ee nea ee ee ce a ee Vd ee eet 14 ON SUNN ANY soa u T E 14 3 2 Ee Open m 15 3 9 R o7 MN eT ua a aa ua fencers 17 34 Nemesis 20 23 5 R OAN AddBxRule uy u u asua kaka qata kantaq spa aha eaae ai E rr dab Po caede be d e dadas 22 29 0 ROGAN Gontrol ied aea td eds e debug addas cedi des tee hawataq akawa dde uda 24 3 7 R CAN SendMSg E 26 NEMORE 28 3 9 R CAN GetHistoryEntry I Nuu u au en Saa aAa sassa tnr entren nnns 29 g 10 R CAN GetStatusMasK tenete ttt er en c tine tun Coe n utin o nune ene XE nag xu duae 30 2 11 R CAN GetCountF EQO uuu ieuads icit eat tone Rev dete edet nerd edd o aab ed et un fuae o tuv edid ln eaae eta 32 3 12 R_CAN GetGountErr u EDT 33 8S R CAN ClOSE M 34 3 14 R GAN GelVersion a u u Suku apu a ARE aia aa ea EE aA Ea AR eea 35 4 Domo Probi eaaa uu T Ra 36 4 1 TSCA demo rSKkrx23 T sciet tenta ea un Pru Cen tcu aa nu aaa Rr D V a a b ERR 36 5 Website and Support iiie tin oder dais elated cda ed iacu dies Er e RUE omen a ab Led Lade ese ane ak ada 37 RO1AN2805EU0100 Rev 1 00 Page 2 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology
42. overflow occurred Channel entered Error Passive state Channel entered Bus Off state Channel recovered from Bus Off state The following sequence of function calls is used to setup the CAN R CAN Open R CAN InitChan do for 1 5 channels R CAN ConfigFIFO do for 0 or more FIFOS R CAN AddRxRule do for 1 320 rules Once the CAN is setup the peripheral should enter normal communications mode or a test mode R CAN Control Use CAN CMD SET MODE COMM or CAN CMD SET MODE TST xxx RO1AN2805EU0100 Rev 1 00 Page 4 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology 2 API Information This Driver API follows the Renesas API naming standards 2 1 Hardware Requirements This driver utilizes the RSCAN peripheral 2 2 Hardware Resource Requirements In addition to the RSCAN peripheral the driver requires e Two pins allocated for the CAN channel 2 3 Software Requirements This driver is dependent upon e r bsp v2 90 2 4 Limitations Not all features of the peripheral are utilized These include Configurable depth transmit and receive FIFOs all fixed at 4 instead of configurable 1 to 16 Transmit by message ID priority will be done by mailbox number 0 being highest priority Transmit FIFO interval transmission Transmit mirroring Filter on mirrored messages DLC substitution Multiple destinations for
43. quate is 0 the CAN clock source is 1 2 the peripheral clock speed clkc If this equate is 1 the source is the external CAN CLOCK clk_xincan CAN CFG INT PRIORITY Priority level for all CAN interrupts 0 31 CAN CFG INT RXFIFO THRESHOLD Setting to O disables interrupt when an RXFIFO threshold is reached Setting to 1 enables interrupt Requires FIFO to be initialized via R CAN ConfigFIFO CAN EVT RXFIFO THRESHOLD is passed to the main callback function CAN CFG INT DLC ERR Setting to O disables interrupt when a DLC error is detected Setting to 1 enables interrupt CAN EVT GLOBAL ERR is passed to the main callback function CAN CFG INT FIFO OVFL Setting to O disables interrupt when a TX GW or RX FIFO overflows Setting to 1 enables interrupt Requires FIFO to be initialized via R CAN ConfigFIFO CAN EVT GLOBAL ERR is passed to the main callback function CAN CFG INT HIST FIFO OVFL Setting to O disables interrupt when a History FIFO overflows Setting to 1 enables interrupt Requires FIFO to be initialized via R CAN ConfigFIFO CAN EVT GLOBAL ERR is passed to the main callback function CAN CFG INT TXFIFO THRESHOLD Setting to O disables interrupt when a TXFIFO threshold is reached Setting to 1 enables interrupt Requires FIFO to be initializes via R CAN ConfigFIFO CAN EVT TRANSMIT is passed to the channel callback function CAN CFG INT HIST FIFO THR
44. rporation of these circuits software and information in the design of your equipment Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from the use of these circuits software or information 2 Renesas Electronics has used reasonable care in preparing the information included in this document but Renesas Electronics does not warrant that such information is error free Renesas Electronics assumes no liability whatsoever for any damages incurred by you resulting from errors in or omissions from the information included herein 3 Renesas Electronics does not assume any liability for infringement of patents copyrights or other intellectual property rights of third parties by or arising from the use of Renesas Electronics products or technical information described in this document No license express implied or otherwise is granted hereby under any patents copyrights or other intellectual property rights of Renesas Electronics or others 4 You should not alter modify copy or otherwise misappropriate any Renesas Electronics product whether in whole or in part Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from such alteration modification copy or otherwise misappropriation of Renesas Electronics product 5 Renesas Electronics products are classified according to the following two quality grades Standard and High Quality The recommende
45. s in the manual The input pins of CMOS products are generally in the high impedance state In operation with an unused pin in the open circuit state extra electromagnetic noise is induced in the vicinity of LSI an associated shoot through current flows internally and malfunctions occur due to the false recognition of the pin state as an input signal become possible Unused pins should be handled as described under Handling of Unused Pins in the manual 2 Processing at Power on The state of the product is undefined at the moment when power is supplied The states of internal circuits in the LSI are indeterminate and the states of register settings and pins are undefined at the moment when power is supplied In a finished product where the reset signal is applied to the external reset pin the states of pins are not guaranteed from the moment when power is supplied until the reset process is completed In a similar way the states of pins in a product that is reset by an on chip power on reset function are not guaranteed from the moment when power is supplied until the power reaches the level at which resetting has been specified 3 Prohibition of Access to Reserved Addresses Access to reserved addresses is prohibited The reserved addresses are provided for the possible future expansion of functions Do not access these addresses the correct operation of LSI is not guaranteed if they are accessed 4 Clock Signals After applying
46. siesesnee c o bewe void const Chcallisack winte w chan can Co evt event void p arge s Parameters chan Channel to initialize 0 is only valid value p_baud Pointer to bit rate structure See Table 21 6 in the Hardware User s Manual for limitations on bit rate based upon the clock frequency and number of channels used See Section 21 10 1 2 for bit time settings typedef struct st_can bitrate uint16 t prescaler uint8 t tsegl uint8 t tseg2 uint8 t Sjw can bitrate t p_chcallback Optional pointer to channel callback function Must be present if interrupts are enabled in r_rscan_rx_config h for TX mailboxes TX FIFOs History FIFOs or bus errors channel First parameter for channel callback function Specifies the channel interrupt occurred on always 0 event Second parameter for channel callback function Specifies the interrupt source see Section 2 10 3 p args Third parameter for callback function unused Return Values CAN SUCCESS Successful CAN ERR ILLEGAL MODE Not in global reset mode results from call to Open CAN ERR INVALID ARG An invalid argument was provided CAN ERR MISSING CALLBACK A callback function was not provided and a channel interrupt is enabled in config h Properties Prototyped in file r rscan rx if h Description This function initializes all of the channel s transmit mailboxes sets the bit rate and enables interrupt sources for the channel as specifie
47. the message is sent If interrupts are enabled or the message is for a transmit FIFO the function will return immediately after loading the message into the transmit registers Reentrant Yes for different boxes Example can txmsg t txmsg cankerrit err Setup message txmsg ide 0 f f TD tiela ig l1 lonug txmsg rtr 0 local message txmsg id 0x022 destination ID cise cle 57 data length sameer Cera Q m f gaa txmsg data 1 e exmsordarail2 Im IL p pasas eewcels3 YL RO1AN2805EU0100 Rev 1 00 Page 26 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology txmsg data 4 o txmsg one shot false do normal retries on error txmsg log history false f f CO not log in History PLEO txmsg label 0 label ignored because not logging message Place message in transmit mailbox 2 If transmit complete interrupt is not enabled the function returns 5 after the message has been sent assuming no error occurred ir err R CAN SendMsg CAN BOX CHO TXMBX 2 amp txmsg Special Notes None RO1AN2805EU0100 Rev 1 00 Page 27 of 37 May 20 2015 RENESAS RX Family RSCAN Module Using Firmware Integration Technology 3 8 R CAN GetMsg This function fetches a message from a receive mailbox or FIFO Format can err t R CAN Cerise Cam lox box id comam E Ours x lt mS Gp 2 Par
Download Pdf Manuals
Related Search
Related Contents
取扱説明書 - 株式会社中日電子 Linksys IWIRELESS-N WRT160N User's Manual Super Vision at Ultra Low Light SHC-745 User Guide Copyright © All rights reserved.
Failed to retrieve file