eLua Project

  • Site
  • Downloads
  • Doc
  • Wiki
  • Builder
  • Tracker
  • Repos

eLua Doc

  • Introduction
  • Status
    • Supported platforms
    • Modules per platform table
    • Modules overview status
    • Roadmap
  • Generic info
    • Using eLua
      • Over UART
      • Over TCP/IP
      • On PC
      • The shell
      • Linenoise
      • Cross-compiling
      • LuaRPC
      • The serial multiplexer
    • Code examples
    • FAQ
    • eLua file systems
      • Read-Only FS in MCU Flash
      • R/W FAT FS in SD/MMC Cards
      • Remote file system (RFS)
      • Write once file system (WOFS)
    • eLua interrupt handlers
      • In Lua
      • In C
    • Building eLua
      • Building eLua in Linux
      • Building eLua in Windows
  • eLua internals
    • Overview
      • eLua's Architecture
      • Common code
      • Interface architecture
      • Booting eLua
      • Platforms and ports
      • Adding a new port
      • Implementing interrupts
        • Interrupt list
    • Platform interface
      • ADC
        • Overview
        • Functions
      • CAN
        • Overview
        • Data structures
          • CAN ID types
        • Functions
      • CPU
        • Overview
        • Functions
      • Ethernet
        • Overview
        • Functions
      • Flash
        • Overview
        • Functions
      • I2C
        • Overview
        • Data structures
          • I2C speed
          • I2C transfer direction
        • Functions
      • Low-level
        • Overview
        • Data structures
          • Status codes
        • Functions
      • PIO
        • Overview
        • Data structures
          • PIO operations
          • PIO data type
        • Functions
      • PWM
        • Overview
        • Data structures
          • PWM operations
        • Functions
      • SPI
        • Overview
        • Data structures
          • Chip select
          • SPI mode
          • SPI data type
        • Functions
      • Timers
        • Overview
        • Data structures
          • Timer data type
          • Timer operations
        • Functions
        • Virtual timers
        • The system timer
      • UART
        • Overview
        • Data structures
          • UART parity
          • UART stop bits
          • Virtual UART IDs
          • Flow control type
        • Functions
    • More information
      • Consoles and terminals
      • TCP/IP in eLua
      • LTR (Lua Tiny RAM) in eLua
      • EGC (Emergency GC) in eLua
      • Booting on a PC
      • Booting from a PenDrive
      • Using OpenOCD
      • eLua toolchains
      • Building toolchains
        • ARM7 and ARM9
        • ARM Cortex-M3
        • i386
      • eLua coding style
  • Reference Manual
    • Generic modules
      • adc
        • Overview
        • Functions
      • bit
        • Overview
        • Functions
      • can
        • Overview
        • Data structures
          • CAN ID types
        • Functions
      • cpu
        • Overview
        • Data structures
          • CPU constants
        • Functions
      • elua
        • Overview
        • Functions
      • i2c
        • Overview
        • Functions
      • net
        • Overview
        • Data structures
          • Error codes
        • Functions
      • pack
        • Overview
        • Functions
      • pd
        • Overview
        • Functions
      • pio
        • Overview
        • Functions
      • pwm
        • Overview
        • Functions
      • rpc
        • Overview
        • Functions
      • spi
        • Overview
        • Functions
      • term
        • Overview
        • Functions
      • tmr
        • Overview
        • Functions
      • uart
        • Overview
        • Data structures
          • UART constants
        • Functions
    • Platform modules
      • lm3s
        • disp
          • Overview
          • Functions
      • str9
        • pio
          • Overview
          • Functions
      • mbed
        • pio
          • Overview
          • Functions
      • mizar32
        • lcd
          • Overview
          • Functions
        • rtc
          • Overview
          • Functions

eLua reference manual - CAN module

Overview

This module contains functions for accessing the CAN interfaces of the eLua CPU

Data structures, constants and types

// eLua CAN ID types
enum
{
  ELUA_CAN_ID_STD = 0,      // exported as can.ID_STD
  ELUA_CAN_ID_EXT,          // exported as can.ID_EXT
};

These are the CAN identifier types supported by eLua. Standard identifiers are 11 bits in length, extended identifiers are 29 bits.

Functions

can.setup can.send can.recv

clock = can.setup( id, clock )

Setup the CAN interface

Arguments:

  • id - the ID of the CAN interface.
  • clock - the clock of the CAN interface.

Returns: The actual clock set on the CAN interface. Depending on the hardware, this might have a different value than the clock parameter.

can.send( id, canid, canidtype, message )

Send message over the CAN bus.

Arguments:

  • id - the ID of the CAN interface.
  • canid - CAN identifier number.
  • canidtype - identifier type as defined here.
  • message - message in string format, 8 or fewer bytes.

Returns: nothing.

canid, canidtype, message = can.recv( id )

Receive CAN bus message.

Arguments: id - the ID of the CAN interface.

Returns:

  • canid - CAN identifier number.
  • canidtype - identifier type as defined here.
  • message - message in string format, 8 or fewer bytes.


© 2011 eLua Project. All rights reserved.