# can_legacy

Legacy internal CAN controller

Author | William Welch Copyright © 2009, all rights reserved.
Adapted-by |
Compiler | 2.4

Description

     The early 18C/F family had an internal CAN controller that was
    very similar to the MCP2515.  More recent devices have an ECAN controller which
    has many enhanced features, but defaults on power-up to a 'legacy' mode.

Dependencies

No dependency found

## Summary

### Global variables/contants

### Procedures

- `can_set_rxb1_filter5(byte in sidh, byte in sidl, byte in eidh, byte in eidl)`
- `can_encode_std_id(dword in out can_id)`
- `can_encode_rtr_id(dword in out can_id)`
- `can_encode_ext_id(dword in out can_id)`
- `can_set_rxb1_filter3(byte in sidh, byte in sidl, byte in eidh, byte in eidl)`
- `can_set_rxb0_filter0(byte in sidh, byte in sidl, byte in eidh, byte in eidl)`
- `can_reset()`
- `can_set_rxb0_filter1(byte in sidh, byte in sidl, byte in eidh, byte in eidl)`
- `can_set_rxb0_mask(byte in sidh, byte in sidl, byte in eidh, byte in eidl)`
- `can_set_config(byte in p1, byte in p2, byte in p3)`
- `can_set_rxb1_filter4(byte in sidh, byte in sidl, byte in eidh, byte in eidl)`
- `can_set_rxb1_mask(byte in sidh, byte in sidl, byte in eidh, byte in eidl)`
- `can_set_rxb1_filter2(byte in sidh, byte in sidl, byte in eidh, byte in eidl)`

### Functions

- `can_send(byte in buf_no, dword in can_id, byte in buf[8], byte in len) return bit`
- `can_is_ext_id(dword in can_id) return bit`
- `can_is_rtr_id(dword in can_id) return bit`
- `can_is_error_id(dword in can_id) return bit`
- `can_is_std_id(dword in can_id) return bit`
- `can_receive(byte in buf_no, dword out can_id, byte out buf[8], byte out len) return bit`

## API details

### Global variables/contants

### Procedures

- `can_set_rxb1_filter5(byte in sidh, byte in sidl, byte in eidh, byte in eidl)`

      set RXB1 acceptance filter #5

- `can_encode_std_id(dword in out can_id)`

  No documentation found

- `can_encode_rtr_id(dword in out can_id)`

  No documentation found

- `can_encode_ext_id(dword in out can_id)`

  No documentation found

- `can_set_rxb1_filter3(byte in sidh, byte in sidl, byte in eidh, byte in eidl)`

      set RXB1 acceptance filter #3

- `can_set_rxb0_filter0(byte in sidh, byte in sidl, byte in eidh, byte in eidl)`

      set RXB0 acceptance filter #0

- `can_reset()`

  No documentation found

- `can_set_rxb0_filter1(byte in sidh, byte in sidl, byte in eidh, byte in eidl)`

      set RXB0 acceptance filter #1

- `can_set_rxb0_mask(byte in sidh, byte in sidl, byte in eidh, byte in eidl)`

      set RX acceptance mask for buffer RXB0
      N.B. calling with 0,0,0,0 will pass all messages

- `can_set_config(byte in p1, byte in p2, byte in p3)`

      set bit-rate and related can bus configuration.
      see datasheet for details.
      N.B. The chip must already be in 'configuration mode'.

- `can_set_rxb1_filter4(byte in sidh, byte in sidl, byte in eidh, byte in eidl)`

      set RXB1 acceptance filter #4

- `can_set_rxb1_mask(byte in sidh, byte in sidl, byte in eidh, byte in eidl)`

      set RX acceptance mask for buffer RXB1
      N.B. calling with 0,0,0,0 will pass all messages

- `can_set_rxb1_filter2(byte in sidh, byte in sidl, byte in eidh, byte in eidl)`

      set RXB1 acceptance filter #2

### Functions

- `can_send(byte in buf_no, dword in can_id, byte in buf[8], byte in len) return bit`

      send CAN frame
      Non-blocking -- function returns immediately if buffer is busy (in-use)
      FIXME. this is ugly code

- `can_is_ext_id(dword in can_id) return bit`

  No documentation found

- `can_is_rtr_id(dword in can_id) return bit`

  No documentation found

- `can_is_error_id(dword in can_id) return bit`

      FIXME: will we ever need this?

- `can_is_std_id(dword in can_id) return bit`

  No documentation found

- `can_receive(byte in buf_no, dword out can_id, byte out buf[8], byte out len) return bit`

      receive CAN frame, sets can_id flag bits as to standard/extended, error, and remote.
      Non-blocking -- function returns immediately if no message is available.
      FIXME. this is ugly code

## Related samples

Here are the list of samples which use this library:

18f2585 | 18f2585_can_serial_hw.jal
18f2585 | 18f2585_canid4_serial_adapter.jal
18f2585 | 18f2585_can_serial_adapter.jal
18f2585 | 18f2585_can_monitor.jal
18f2585 | 18f2585_canid4_monitor.jal
18f4585 | 18f4585_canid4_monitor.jal