canbus: Rename canbus_send() to canhw_send()
Rename canbus_send() to canhw_send() and rename canbus_set_filter() to canhw_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:
parent
e16a693b1e
commit
52a6bed24e
|
@ -85,7 +85,7 @@ static struct fdcan_msg_ram MSG_RAM;
|
||||||
|
|
||||||
// Transmit a packet
|
// Transmit a packet
|
||||||
int
|
int
|
||||||
canbus_send(struct canbus_msg *msg)
|
canhw_send(struct canbus_msg *msg)
|
||||||
{
|
{
|
||||||
uint32_t txfqs = CANx->TXFQS.reg;
|
uint32_t txfqs = CANx->TXFQS.reg;
|
||||||
if (txfqs & CAN_TXFQS_TFQF)
|
if (txfqs & CAN_TXFQS_TFQF)
|
||||||
|
@ -120,7 +120,7 @@ can_filter(uint32_t index, uint32_t id)
|
||||||
|
|
||||||
// Setup the receive packet filter
|
// Setup the receive packet filter
|
||||||
void
|
void
|
||||||
canbus_set_filter(uint32_t id)
|
canhw_set_filter(uint32_t id)
|
||||||
{
|
{
|
||||||
if (!CONFIG_CANBUS_FILTER)
|
if (!CONFIG_CANBUS_FILTER)
|
||||||
return;
|
return;
|
||||||
|
@ -283,7 +283,7 @@ can_init(void)
|
||||||
CANx->CCCR.reg &= ~CAN_CCCR_INIT;
|
CANx->CCCR.reg &= ~CAN_CCCR_INIT;
|
||||||
|
|
||||||
/*##-2- Configure the CAN Filter #######################################*/
|
/*##-2- Configure the CAN Filter #######################################*/
|
||||||
canbus_set_filter(0);
|
canhw_set_filter(0);
|
||||||
|
|
||||||
/*##-3- Configure Interrupts #################################*/
|
/*##-3- Configure Interrupts #################################*/
|
||||||
armcm_enable_irq(CAN_IRQHandler, CANx_IRQn, 1);
|
armcm_enable_irq(CAN_IRQHandler, CANx_IRQn, 1);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
// This file may be distributed under the terms of the GNU GPLv3 license.
|
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
|
|
||||||
#include "autoconf.h" // CONFIG_CANBUS_FREQUENCY
|
#include "autoconf.h" // CONFIG_CANBUS_FREQUENCY
|
||||||
#include "canbus.h" // canbus_send
|
#include "canbus.h" // canhw_send
|
||||||
#include "canserial.h" // canserial_send
|
#include "canserial.h" // canserial_send
|
||||||
#include "command.h" // DECL_CONSTANT
|
#include "command.h" // DECL_CONSTANT
|
||||||
|
|
||||||
|
@ -14,13 +14,13 @@ DECL_CONSTANT("CANBUS_FREQUENCY", CONFIG_CANBUS_FREQUENCY);
|
||||||
int
|
int
|
||||||
canserial_send(struct canbus_msg *msg)
|
canserial_send(struct canbus_msg *msg)
|
||||||
{
|
{
|
||||||
return canbus_send(msg);
|
return canhw_send(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
canserial_set_filter(uint32_t id)
|
canserial_set_filter(uint32_t id)
|
||||||
{
|
{
|
||||||
canbus_set_filter(id);
|
canhw_set_filter(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -18,8 +18,8 @@ struct canbus_msg {
|
||||||
#define CANMSG_DATA_LEN(msg) ((msg)->dlc > 8 ? 8 : (msg)->dlc)
|
#define CANMSG_DATA_LEN(msg) ((msg)->dlc > 8 ? 8 : (msg)->dlc)
|
||||||
|
|
||||||
// callbacks provided by board specific code
|
// callbacks provided by board specific code
|
||||||
int canbus_send(struct canbus_msg *msg);
|
int canhw_send(struct canbus_msg *msg);
|
||||||
void canbus_set_filter(uint32_t id);
|
void canhw_set_filter(uint32_t id);
|
||||||
|
|
||||||
// canbus.c
|
// canbus.c
|
||||||
void canbus_notify_tx(void);
|
void canbus_notify_tx(void);
|
||||||
|
|
|
@ -205,7 +205,7 @@ usbcan_task(void)
|
||||||
msg.data32[0] = gs->data32[0];
|
msg.data32[0] = gs->data32[0];
|
||||||
msg.data32[1] = gs->data32[1];
|
msg.data32[1] = gs->data32[1];
|
||||||
if (host_status & HS_TX_HW) {
|
if (host_status & HS_TX_HW) {
|
||||||
ret = canbus_send(&msg);
|
ret = canhw_send(&msg);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return;
|
return;
|
||||||
UsbCan.host_status = host_status = host_status & ~HS_TX_HW;
|
UsbCan.host_status = host_status = host_status & ~HS_TX_HW;
|
||||||
|
|
|
@ -26,7 +26,7 @@ static struct can2040 cbus;
|
||||||
|
|
||||||
// Transmit a packet
|
// Transmit a packet
|
||||||
int
|
int
|
||||||
canbus_send(struct canbus_msg *msg)
|
canhw_send(struct canbus_msg *msg)
|
||||||
{
|
{
|
||||||
int ret = can2040_transmit(&cbus, (void*)msg);
|
int ret = can2040_transmit(&cbus, (void*)msg);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -36,7 +36,7 @@ canbus_send(struct canbus_msg *msg)
|
||||||
|
|
||||||
// Setup the receive packet filter
|
// Setup the receive packet filter
|
||||||
void
|
void
|
||||||
canbus_set_filter(uint32_t id)
|
canhw_set_filter(uint32_t id)
|
||||||
{
|
{
|
||||||
// Filter not implemented (and not necessary)
|
// Filter not implemented (and not necessary)
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@
|
||||||
|
|
||||||
// Transmit a packet
|
// Transmit a packet
|
||||||
int
|
int
|
||||||
canbus_send(struct canbus_msg *msg)
|
canhw_send(struct canbus_msg *msg)
|
||||||
{
|
{
|
||||||
uint32_t tsr = SOC_CAN->TSR;
|
uint32_t tsr = SOC_CAN->TSR;
|
||||||
if (!(tsr & (CAN_TSR_TME0|CAN_TSR_TME1|CAN_TSR_TME2))) {
|
if (!(tsr & (CAN_TSR_TME0|CAN_TSR_TME1|CAN_TSR_TME2))) {
|
||||||
|
@ -129,7 +129,7 @@ canbus_send(struct canbus_msg *msg)
|
||||||
|
|
||||||
// Setup the receive packet filter
|
// Setup the receive packet filter
|
||||||
void
|
void
|
||||||
canbus_set_filter(uint32_t id)
|
canhw_set_filter(uint32_t id)
|
||||||
{
|
{
|
||||||
/* Select the start slave bank */
|
/* Select the start slave bank */
|
||||||
SOC_CAN->FMR |= CAN_FMR_FINIT;
|
SOC_CAN->FMR |= CAN_FMR_FINIT;
|
||||||
|
@ -268,7 +268,7 @@ can_init(void)
|
||||||
;
|
;
|
||||||
|
|
||||||
/*##-2- Configure the CAN Filter #######################################*/
|
/*##-2- Configure the CAN Filter #######################################*/
|
||||||
canbus_set_filter(0);
|
canhw_set_filter(0);
|
||||||
|
|
||||||
/*##-3- Configure Interrupts #################################*/
|
/*##-3- Configure Interrupts #################################*/
|
||||||
armcm_enable_irq(CAN_IRQHandler, CAN_RX0_IRQn, 0);
|
armcm_enable_irq(CAN_IRQHandler, CAN_RX0_IRQn, 0);
|
||||||
|
|
|
@ -101,7 +101,7 @@ struct fdcan_ram_layout {
|
||||||
|
|
||||||
// Transmit a packet
|
// Transmit a packet
|
||||||
int
|
int
|
||||||
canbus_send(struct canbus_msg *msg)
|
canhw_send(struct canbus_msg *msg)
|
||||||
{
|
{
|
||||||
uint32_t txfqs = SOC_CAN->TXFQS;
|
uint32_t txfqs = SOC_CAN->TXFQS;
|
||||||
if (txfqs & FDCAN_TXFQS_TFQF)
|
if (txfqs & FDCAN_TXFQS_TFQF)
|
||||||
|
@ -136,7 +136,7 @@ can_filter(uint32_t index, uint32_t id)
|
||||||
|
|
||||||
// Setup the receive packet filter
|
// Setup the receive packet filter
|
||||||
void
|
void
|
||||||
canbus_set_filter(uint32_t id)
|
canhw_set_filter(uint32_t id)
|
||||||
{
|
{
|
||||||
if (!CONFIG_CANBUS_FILTER)
|
if (!CONFIG_CANBUS_FILTER)
|
||||||
return;
|
return;
|
||||||
|
@ -299,7 +299,7 @@ can_init(void)
|
||||||
SOC_CAN->CCCR &= ~FDCAN_CCCR_INIT;
|
SOC_CAN->CCCR &= ~FDCAN_CCCR_INIT;
|
||||||
|
|
||||||
/*##-2- Configure the CAN Filter #######################################*/
|
/*##-2- Configure the CAN Filter #######################################*/
|
||||||
canbus_set_filter(0);
|
canhw_set_filter(0);
|
||||||
|
|
||||||
/*##-3- Configure Interrupts #################################*/
|
/*##-3- Configure Interrupts #################################*/
|
||||||
armcm_enable_irq(CAN_IRQHandler, CAN_IT0_IRQn, 1);
|
armcm_enable_irq(CAN_IRQHandler, CAN_IT0_IRQn, 1);
|
||||||
|
|
Loading…
Reference in New Issue