48DigitalOut& tx_led = d1;
75 instance == CAN1 ? P0_0 : P0_4, instance == CAN1 ? P0_1 : P0_5)
76 ,
SR_(instance == CAN1 ? &LPC_CAN1->SR : &LPC_CAN2->SR)
92 volatile uint32_t*
SR_;
108 struct can_frame *can_frame;
112 taskENTER_CRITICAL();
118 CANMessage msg(can_frame->can_id, (
const char*)can_frame->data,
119 can_frame->can_dlc, can_frame->can_rtr ? CANRemote : CANData,
120 can_frame->can_eff ? CANExtended : CANStandard);
147 struct can_frame* can_frame;
150 can_frame->can_id = msg.id;
151 can_frame->can_rtr = msg.type == CANRemote ? 1 : 0;
152 can_frame->can_eff = msg.format == CANStandard ? 0 : 1;
153 can_frame->can_err = 0;
154 can_frame->can_dlc = msg.len;
155 memcpy(can_frame->data, msg.data, msg.len);
164#if defined(TARGET_LPC2368) || defined(TARGET_LPC1768)
168 struct can_frame *can_frame;
171 CANMessage msg(can_frame->can_id, (
const char*)can_frame->data,
173 can_frame->can_rtr ? CANRemote : CANData,
174 can_frame->can_eff ? CANExtended : CANStandard);
199#error you need to define how to figure out whether the transmit buffer is empty.
207#elif defined(TARGET_LPC2368)
212#error define how to yield on your CPU.
220MbedCanDriver can1(MbedCanDriver::CAN1,
"/dev/can1", config_can2_bitrate() ? config_can2_bitrate() : config_nmranet_can_bitrate());
Base class for a CAN device for the Arduino environment.
unsigned int overrunCount
overrun count
DeviceBuffer< struct can_frame > * txBuf
transmit buffer
DeviceBuffer< struct can_frame > * rxBuf
receive buffer
size_t advance(size_t items)
Add a number of items to the buffer by advancing the writeIndex.
void signal_condition()
Signal the wakeup condition.
size_t consume(size_t items)
Remove a number of items from the buffer by advancing the readIndex.
void signal_condition_from_isr()
Signal the wakeup condition from an ISR context.
size_t data_write_pointer(T **buf)
Get a reference to the current location in the buffer for write.
size_t data_read_pointer(T **buf)
Get a reference to the current location in the buffer for read.
CAN driver implementation using an mbed-supported CAN device.
void interrupt()
called after disabling the dev
Instance
Which hardware device to use.
void enable() override
function to enable device
MbedCanDriver(Instance instance, const char *dev, int frequency)
Constructor.
volatile uint32_t * SR_
Status register.
void flush_buffers() override
function to disable device
void tx_msg() OVERRIDE
Try and transmit a message.
void disable() override
function to enable device
char txPending_
Whether we have an output frame pending (1) or the output frame is free (0).
mbed::CAN mbedCan_
mBed CAN implementation object.
#define OVERRIDE
Function attribute for virtual functions declaring that this funciton is overriding a funciton that s...
MbedCanDriver can1(MbedCanDriver::CAN1, "/dev/can1", config_can2_bitrate() ? config_can2_bitrate() :config_nmranet_can_bitrate())
Other CAN driver instance.
MbedCanDriver can0(MbedCanDriver::CAN2, "/dev/can0", config_nmranet_can_bitrate())
The TCH baseboard for the mbed has CAN1 and CAN2 mixed up.