mirror of
https://github.com/apache/nuttx.git
synced 2026-05-19 03:03:37 +08:00
drivers/can: ctucanfd the first round of fixes - mainly for char dev
Corrected CAN FD messages sending in character driver mode. Assign CAN FD format flag in reception of CAN FD messages. Corrected some defines mismatches. The code has been tested in QEMU qemu-system-x86_64 -m 2G -enable-kvm -smp 1 \ -cpu host,+pcid,+x2apic,+tsc-deadline,+xsave,+rdrand \ -kernel nuttx/nuttx \ -nographic -serial mon:stdio \ -object can-bus,id=canbus0-bus \ -object can-host-socketcan,if=can0,canbus=canbus0-bus,id=canbus0-socketcan \ -device ctucan_pci,canbus0=canbus0-bus,canbus1=canbus0-bus The overall state of this third party CTU CAN FD driver in NuttX is far from ideal. It would worth to consult and follow more closely our Linux kernel driver and even better RTEMS CAN/CAN FD stack design https://canbus.pages.fel.cvut.cz/#cancan-fd-subsystem-and-drivers-for-rtems Signed-off-by: Pavel Pisa <pisa@fel.cvut.cz>
This commit is contained in:
committed by
Mateusz Szafoni
parent
61f0c97193
commit
46c3f354b3
@@ -626,7 +626,7 @@ static int ctucanfd_chrdev_send(FAR struct can_dev_s *dev,
|
||||
|
||||
fmt.s.rtr = msg->cm_hdr.ch_rtr;
|
||||
|
||||
#ifdef CONFIG_NET_CAN_EXTID
|
||||
#ifdef CONFIG_CAN_EXTID
|
||||
if (msg->cm_hdr.ch_extid)
|
||||
{
|
||||
fmt.s.ide = 1;
|
||||
@@ -639,6 +639,15 @@ static int ctucanfd_chrdev_send(FAR struct can_dev_s *dev,
|
||||
id.s.id = msg->cm_hdr.ch_id;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CAN_FD
|
||||
|
||||
/* Set CAN FD specific flags */
|
||||
|
||||
fmt.s.brs = msg->cm_hdr.ch_brs;
|
||||
fmt.s.esi_rsv = msg->cm_hdr.ch_esi;
|
||||
fmt.s.fdf = msg->cm_hdr.ch_edl;
|
||||
#endif
|
||||
|
||||
/* Write frame */
|
||||
|
||||
ctucanfd_putreg(priv, offset + CTUCANFD_TXBUF_FMT, fmt.u32);
|
||||
@@ -800,7 +809,7 @@ static void ctucanfd_chardev_receive(FAR struct ctucanfd_can_s *priv)
|
||||
|
||||
#ifdef CONFIG_CAN_FD
|
||||
hdr.ch_esi = frame.fmt.esi_rsv;
|
||||
hdr.ch_edl = 0;
|
||||
hdr.ch_edl = frame.fmt.fdf;
|
||||
hdr.ch_brs = frame.fmt.brs;
|
||||
#else
|
||||
if (frame.fmt.fdf)
|
||||
@@ -1808,6 +1817,7 @@ static int ctucanfd_probe(FAR struct pci_device_s *dev)
|
||||
if (!priv->bar0_base)
|
||||
{
|
||||
pcierr("Not found BAR0\n");
|
||||
ret = -ENODEV;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
@@ -1823,6 +1833,7 @@ static int ctucanfd_probe(FAR struct pci_device_s *dev)
|
||||
if (!priv->canfd_base)
|
||||
{
|
||||
pcierr("Not found CANFD bar\n");
|
||||
ret = -ENODEV;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
@@ -1922,11 +1933,11 @@ errout:
|
||||
{
|
||||
if (priv->devs[i].pcidev)
|
||||
{
|
||||
#ifdef CONFIG_CAN_KVASER_SOCKET
|
||||
#ifdef CONFIG_CAN_CTUCANFD_SOCKET
|
||||
netdev_unregister(&priv->devs[i].dev);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CAN_KVASER_CHARDEV
|
||||
#ifdef CONFIG_CAN_CTUCANFD_CHARDEV
|
||||
unregister_driver(devpath);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user