|
TTK4155 Lab Node 1
Term project in the NTNU course TTK4155 Embedded and Industrial Computer Systems Design
|
Data Structures | |
| struct | can_msg |
| Represents a simple CAN message with an address, data count, and a single byte of data. More... | |
| struct | can_device |
| Represents a CAN device, storing the SPI slave controlling the MCP2515. More... | |
| struct | CAN_frame |
| Represents a full CAN frame for sending/receiving. More... | |
Macros | |
| #define | CAN_ID_ERROR 0x01 |
| #define | CAN_ID_GAMEOVER 0x02 |
| #define | CAN_ID_GAMESTART 0x03 |
| #define | CAN_ID_JOYPOS 0x04 |
| #define | CAN_ID_RESET 0x05 |
| #define | CAN_ID_READY 0x06 |
| #define | CAN_ID_SCORE 0x07 |
| #define | CAN_ID_DEFAULT 0x08 |
| #define | CAN_RXQ_SIZE 8 |
Functions | |
| int8_t | can_init (struct can_device *dev) |
| Initialize a CAN device. | |
| int8_t | can_write (struct can_device *dev, struct CAN_frame msg) |
| Write a CAN frame to the MCP2515 transmit buffer. | |
| int8_t | can_read_rx0 (struct can_device *dev, struct CAN_frame *out) |
| Read a message from RX buffer 0. | |
| int8_t | can_read_rx1 (struct can_device *dev, struct CAN_frame *out) |
| Read a message from RX buffer 1. | |
| int | can_rxq_add (struct CAN_frame *msg) |
| Add a CAN frame to the internal receive queue. | |
| int | can_rxq_pull (struct CAN_frame *out) |
| Pull a CAN frame from the internal receive queue. | |
| int8_t | can_reset (struct can_device *dev, uint8_t address, struct CAN_frame data_frame) |
| int8_t | MCP2515_init (struct can_device *dev) |
| int8_t | MCP2515_read (struct can_device *dev, uint8_t rx_buf_num, uint8_t *out) |
| int8_t | MCP2515_write (struct can_device *dev, uint8_t addr, uint8_t data) |
| int8_t | MCP2515_request_to_send (struct can_device *dev, uint8_t tx_buf_num) |
| int8_t | MCP2515_bit_modify (struct can_device *dev, uint8_t reg, uint8_t mask, uint8_t set_val) |
| int8_t | MCP2515_reset (struct can_device *dev) |
| int8_t | MCP2515_read_status (struct can_device *dev, uint8_t *out) |
| #define CAN_ID_ERROR 0x01 |
| #define CAN_ID_GAMEOVER 0x02 |
| #define CAN_ID_GAMESTART 0x03 |
| #define CAN_ID_JOYPOS 0x04 |
| #define CAN_ID_RESET 0x05 |
| #define CAN_RXQ_SIZE 8 |
#include <can.h>
Definition at line 27 of file can.h.
Referenced by can_rxq_add(), and can_rxq_pull().
| int8_t can_init | ( | struct can_device * | dev | ) |
#include <can.h>
Initialize a CAN device.
Configures MCP2515 and sets up AVR external interrupt for CAN receive events.
| dev | Pointer to the CAN device structure. |
Definition at line 22 of file can.c.
Referenced by main().
| int8_t can_read_rx0 | ( | struct can_device * | dev, |
| struct CAN_frame * | out ) |
#include <can.h>
Read a message from RX buffer 0.
Extracts identifier, data length, and payload from the MCP2515 RXB0 buffer.
| dev | Pointer to the CAN device. |
| out | Pointer to CAN_frame to store the received message. |
Definition at line 95 of file can.c.
Referenced by ISR().
| int8_t can_read_rx1 | ( | struct can_device * | dev, |
| struct CAN_frame * | out ) |
#include <can.h>
Read a message from RX buffer 1.
Extracts identifier, data length, and payload from the MCP2515 RXB1 buffer.
| dev | Pointer to the CAN device. |
| out | Pointer to CAN_frame to store the received message. |
Definition at line 127 of file can.c.
Referenced by ISR().
| int8_t can_reset | ( | struct can_device * | dev, |
| uint8_t | address, | ||
| struct CAN_frame | data_frame ) |
#include <can.h>
| int can_rxq_add | ( | struct CAN_frame * | msg | ) |
#include <can.h>
Add a CAN frame to the internal receive queue.
Used by interrupt routines to buffer incoming messages.
| msg | Pointer to the CAN_frame to enqueue. |
Definition at line 159 of file can.c.
Referenced by ISR().
| int can_rxq_pull | ( | struct CAN_frame * | out | ) |
#include <can.h>
Pull a CAN frame from the internal receive queue.
| out | Pointer to the CAN_frame to fill with dequeued data. |
Definition at line 171 of file can.c.
Referenced by process_can_frame().
| int8_t can_write | ( | struct can_device * | dev, |
| struct CAN_frame | msg ) |
#include <can.h>
Write a CAN frame to the MCP2515 transmit buffer.
Handles standard and extended IDs and requests the controller to send the message.
| dev | Pointer to the CAN device structure. |
| msg | The CAN frame to send. |
Definition at line 49 of file can.c.
Referenced by tx_error(), tx_gamestart(), tx_joy_btn(), and tx_reset().
| int8_t MCP2515_bit_modify | ( | struct can_device * | dev, |
| uint8_t | reg, | ||
| uint8_t | mask, | ||
| uint8_t | set_val ) |
#include <can.h>
Definition at line 379 of file can.c.
Referenced by can_read_rx0(), can_read_rx1(), and MCP2515_init().
| int8_t MCP2515_init | ( | struct can_device * | dev | ) |
#include <can.h>
Definition at line 217 of file can.c.
Referenced by can_init().
| int8_t MCP2515_read | ( | struct can_device * | dev, |
| uint8_t | rx_buf_num, | ||
| uint8_t * | out ) |
#include <can.h>
Definition at line 354 of file can.c.
Referenced by can_read_rx0(), can_read_rx1(), can_write(), ISR(), and MCP2515_init().
| int8_t MCP2515_read_status | ( | struct can_device * | dev, |
| uint8_t * | out ) |
| int8_t MCP2515_request_to_send | ( | struct can_device * | dev, |
| uint8_t | tx_buf_num ) |
| int8_t MCP2515_reset | ( | struct can_device * | dev | ) |
#include <can.h>
Definition at line 390 of file can.c.
Referenced by MCP2515_init().
| int8_t MCP2515_write | ( | struct can_device * | dev, |
| uint8_t | addr, | ||
| uint8_t | data ) |
#include <can.h>
Definition at line 318 of file can.c.
Referenced by can_write(), ISR(), and MCP2515_init().