#include "can-jf0815-hw.h"

#include <why-time.h>
#include <why-irq.h>

#include <print>

int main()
{
    Why::init();

    CAN_JF0815_HW can("my-can");

    Why::IRQ::connect(CAN_JF0815_HW::IRQ_RECV_READY, [&can](int irqnum){
        auto frame = can.commit_recv();
        std::println("ID {}, dlc {}, data {}", frame.id, frame.dlc, std::string((const char*)frame.data, frame.dlc));
    });

    Why::pause();

    return 0;
}
