canbus: Rename canserial_send() to canbus_send()

Rename canserial_send() to canbus_send() and canserial_set_filter() to
canbus_set_filter().  This makes it more clear where the code should
reside.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2022-12-14 14:25:21 -05:00
parent 52a6bed24e
commit d40ebdab06
5 changed files with 13 additions and 15 deletions

View File

@ -6,19 +6,19 @@
#include "autoconf.h" // CONFIG_CANBUS_FREQUENCY
#include "canbus.h" // canhw_send
#include "canserial.h" // canserial_send
#include "canserial.h" // canserial_notify_tx
#include "command.h" // DECL_CONSTANT
DECL_CONSTANT("CANBUS_FREQUENCY", CONFIG_CANBUS_FREQUENCY);
int
canserial_send(struct canbus_msg *msg)
canbus_send(struct canbus_msg *msg)
{
return canhw_send(msg);
}
void
canserial_set_filter(uint32_t id)
canbus_set_filter(uint32_t id)
{
canhw_set_filter(id);
}

View File

@ -22,6 +22,8 @@ int canhw_send(struct canbus_msg *msg);
void canhw_set_filter(uint32_t id);
// canbus.c
int canbus_send(struct canbus_msg *msg);
void canbus_set_filter(uint32_t id);
void canbus_notify_tx(void);
void canbus_process_data(struct canbus_msg *msg);

View File

@ -10,7 +10,7 @@
#include "board/io.h" // readb
#include "board/irq.h" // irq_save
#include "board/misc.h" // console_sendf
#include "canbus.h" // canbus_set_uuid
#include "canbus.h" // canbus_send
#include "canserial.h" // canserial_notify_tx
#include "command.h" // DECL_CONSTANT
#include "fasthash.h" // fasthash64
@ -68,7 +68,7 @@ canserial_tx_task(void)
break;
msg.dlc = now;
memcpy(msg.data, &CanData.transmit_buf[tpos], now);
int ret = canserial_send(&msg);
int ret = canbus_send(&msg);
if (ret <= 0)
break;
tpos += now;
@ -152,7 +152,7 @@ can_process_query_unassigned(struct canbus_msg *msg)
send.data[7] = CANBUS_CMD_SET_KLIPPER_NODEID;
// Send with retry
for (;;) {
int ret = canserial_send(&send);
int ret = canbus_send(&send);
if (ret >= 0)
return;
}
@ -162,7 +162,7 @@ static void
can_id_conflict(void)
{
CanData.assigned_id = 0;
canserial_set_filter(CanData.assigned_id);
canbus_set_filter(CanData.assigned_id);
shutdown("Another CAN node assigned this ID");
}
@ -175,7 +175,7 @@ can_process_set_klipper_nodeid(struct canbus_msg *msg)
if (can_check_uuid(msg)) {
if (newid != CanData.assigned_id) {
CanData.assigned_id = newid;
canserial_set_filter(CanData.assigned_id);
canbus_set_filter(CanData.assigned_id);
}
} else if (newid == CanData.assigned_id) {
can_id_conflict();

View File

@ -6,13 +6,9 @@
#define CANBUS_ID_ADMIN 0x3f0
#define CANBUS_ID_ADMIN_RESP 0x3f1
// callbacks provided by board specific code
struct canbus_msg;
int canserial_send(struct canbus_msg *msg);
void canserial_set_filter(uint32_t id);
// canserial.c
void canserial_notify_tx(void);
struct canbus_msg;
int canserial_process_data(struct canbus_msg *msg);
void canserial_set_uuid(uint8_t *raw_uuid, uint32_t raw_uuid_len);

View File

@ -254,7 +254,7 @@ usbcan_task(void)
DECL_TASK(usbcan_task);
int
canserial_send(struct canbus_msg *msg)
canbus_send(struct canbus_msg *msg)
{
int ret = drain_hw_queue();
if (ret < 0)
@ -270,7 +270,7 @@ retry_later:
}
void
canserial_set_filter(uint32_t id)
canbus_set_filter(uint32_t id)
{
UsbCan.assigned_id = id;
}