![]() |
#include <string.h>
#include "comm_can.h"
#include "ch.h"
#include "hal.h"
#include "datatypes.h"
#include "buffer.h"
#include "mcpwm.h"
#include "timeout.h"
#include "commands.h"
#include "app.h"
#include "crc.h"
#include "packet.h"
Macros | |
#define | CANDx CAND1 |
#define | RX_FRAMES_SIZE 100 |
#define | RX_BUFFER_SIZE PACKET_MAX_PL_LEN |
Functions | |
void | comm_can_init (void) |
void | comm_can_transmit (uint32_t id, uint8_t *data, uint8_t len) |
void | comm_can_send_buffer (uint8_t controller_id, uint8_t *data, unsigned int len, bool send) |
void | comm_can_set_duty (uint8_t controller_id, float duty) |
void | comm_can_set_current (uint8_t controller_id, float current) |
void | comm_can_set_current_brake (uint8_t controller_id, float current) |
void | comm_can_set_rpm (uint8_t controller_id, float rpm) |
void | comm_can_set_pos (uint8_t controller_id, float pos) |
can_status_msg * | comm_can_get_status_msg_index (int index) |
can_status_msg * | comm_can_get_status_msg_id (int id) |
#define CANDx CAND1 |
#define RX_BUFFER_SIZE PACKET_MAX_PL_LEN |
#define RX_FRAMES_SIZE 100 |
can_status_msg* comm_can_get_status_msg_id | ( | int | id | ) |
Get status message by id.
id | Id of the controller that sent the status message. |
can_status_msg* comm_can_get_status_msg_index | ( | int | index | ) |
Get status message by index.
index | Index in the array |
void comm_can_init | ( | void | ) |
void comm_can_send_buffer | ( | uint8_t | controller_id, |
uint8_t * | data, | ||
unsigned int | len, | ||
bool | send | ||
) |
Send a buffer up to RX_BUFFER_SIZE bytes as fragments. If the buffer is 6 bytes or less it will be sent in a single CAN frame, otherwise it will be split into several frames.
controller_id | The controller id to send to. |
data | The payload. |
len | The payload length. |
send | If true, this packet will be passed to the send function of commands. Otherwise, it will be passed to the process function. |
void comm_can_set_current | ( | uint8_t | controller_id, |
float | current | ||
) |
void comm_can_set_current_brake | ( | uint8_t | controller_id, |
float | current | ||
) |
void comm_can_set_duty | ( | uint8_t | controller_id, |
float | duty | ||
) |
void comm_can_set_pos | ( | uint8_t | controller_id, |
float | pos | ||
) |
void comm_can_set_rpm | ( | uint8_t | controller_id, |
float | rpm | ||
) |
void comm_can_transmit | ( | uint32_t | id, |
uint8_t * | data, | ||
uint8_t | len | ||
) |