.. include:: Hardware: CAN Controller JF0815 =============================== .. topic:: See also * :doc:`/trainings/material/soup/linux/hardware/can/index` * More specifically: :ref:`can-vcan` .. topic:: Trainer's note .. code-block:: console :caption: Add ``my-can`` VCAN interface # modprobe vcan # ip link add dev my-can type vcan # ip link set my-can up .. code-block:: console :caption: Sniff ``my-can`` $ candump my-can ... .. code-block:: console :caption: Send frame 0x25, payload "12345" (dlc 5) $ cansend my-can 25#3132333435 Software Paradigm ----------------- * Driver is a bare wrapper around bare hardware * Sending * User registers ISR for **IRQ#1001** * Drops CAN frame into device buffer * Kick controller (set flag in some device register) * ISR called when frame transmitted (|longrightarrow| ready for next transmission) * Receiving * User registers ISR for **IRQ#1002** * ISR called when device buffer contains received frame Driver Interface ---------------- .. literalinclude:: code/can-jf0815-hw.h :caption: :download:`code/can-jf0815-hw.h` :language: c++ Sample Send Program ------------------- .. literalinclude:: code/can-jf0815-xmit.cpp :caption: :download:`code/can-jf0815-xmit.cpp` :language: c++ Sample Receive Program ---------------------- .. literalinclude:: code/can-jf0815-recv.cpp :caption: :download:`code/can-jf0815-recv.cpp` :language: c++