|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The XL2515 over SPI (Serial Peripheral Interface): the part of the CAN (Controller Area Network) driver that touches hardware. More...
Go to the source code of this file.
Functions | |
| bool | xl2515_init (uint32_t bitrate) |
Reset, set the bit timing for bitrate, and enter normal mode. | |
| bool | xl2515_send (const link_can_frame_t *f) |
| Queue one frame in TXB0 and request transmission. | |
| bool | xl2515_recv (link_can_frame_t *f, uint32_t *refused) |
| Take one frame from whichever receive buffer has one. | |
| void | xl2515_errors (uint8_t *tx_errors, uint8_t *rx_errors, uint8_t *flags) |
| The controller's own error counters, for the bring-up report. | |
| bool | xl2515_take_overflow (void) |
| True if a frame arrived with both receive buffers full since the last call. | |
The XL2515 over SPI (Serial Peripheral Interface): the part of the CAN (Controller Area Network) driver that touches hardware.
Everything that can be computed rather than poked (the bit timing, the identifier's layout across four registers, the register map) lives in shared/can with tests. This file holds chip-select edges and the register writes in the order the datasheet gives them.
SPDX-License-Identifier: MIT
| void xl2515_errors | ( | uint8_t * | tx_errors, |
| uint8_t * | rx_errors, | ||
| uint8_t * | flags ) |
The controller's own error counters, for the bring-up report.
Either pointer may be NULL.
| tx_errors | Receives the transmit error counter (TEC). May be NULL. |
| rx_errors | Receives the receive error counter (REC). May be NULL. |
| flags | Receives the error flags register (EFLG). May be NULL. |
| bool xl2515_init | ( | uint32_t | bitrate | ) |
Reset, set the bit timing for bitrate, and enter normal mode.
False if the part does not answer. The datasheet guarantees configuration mode after a reset, so a CANSTAT that says otherwise means nothing is listening on the SPI bus: an SPI wiring fault, not a CAN wiring fault.
| bitrate | CAN bit rate in bit/s. |
bitrate. | bool xl2515_recv | ( | link_can_frame_t * | f, |
| uint32_t * | refused ) |
Take one frame from whichever receive buffer has one.
A buffer holding a frame this link does not carry is consumed, adds 1 to refused (modulo 2^32, NULL counts nothing) and the other buffer is tried. False if none holds a valid frame.
| f | Receives the frame. |
| refused | Counts the frames this link does not carry. NULL counts nothing. |
| bool xl2515_send | ( | const link_can_frame_t * | f | ) |
Queue one frame in TXB0 and request transmission.
False if the buffer is still busy with the previous one.
| f | The frame to send. NULL is refused, and so is a DLC above 8. |
| bool xl2515_take_overflow | ( | void | ) |
True if a frame arrived with both receive buffers full since the last call.
The flags are sticky and the MCU (microcontroller unit) clears them, which makes this the one record of a frame lost with nothing wrong on the wire: it arrived, it was correct, and there was nowhere to put it. Reading clears them, so the answer covers the time since the last call.