mbed library sources, include can_api for nucleo-f091rc
Dependents: CanNucleoF0_example
Fork of mbed-src by
Diff: common/CAN.cpp
- Revision:
- 637:909ea77f86f8
- Parent:
- 636:03b10be137bf
- Child:
- 644:612d6aa9e717
--- a/common/CAN.cpp Mon Dec 14 06:28:46 2015 +0000 +++ b/common/CAN.cpp Mon Dec 14 15:51:51 2015 +0000 @@ -21,55 +21,53 @@ namespace mbed { -Can::Can(PinName rd, PinName td) : _can(), _irq() { +CAN::CAN(PinName rd, PinName td) : _can(), _irq() { can_init(&_can, rd, td); - can_irq_init(&_can, (&Can::_irq_handler), (uint32_t)this); + can_irq_init(&_can, (&CAN::_irq_handler), (uint32_t)this); } -Can::~Can() { +CAN::~CAN() { can_irq_free(&_can); can_free(&_can); } -void Can::dummy(void){} - -int Can::frequency(int f) { +int CAN::frequency(int f) { return can_frequency(&_can, f); } -int Can::write(CANMessage msg) { +int CAN::write(CANMessage msg) { return can_write(&_can, msg, 0); } -int Can::read(CANMessage &msg, int handle) { +int CAN::read(CANMessage &msg, int handle) { return can_read(&_can, &msg, handle); } -void Can::reset() { +void CAN::reset() { can_reset(&_can); } -unsigned char Can::rderror() { +unsigned char CAN::rderror() { return can_rderror(&_can); } -unsigned char Can::tderror() { +unsigned char CAN::tderror() { return can_tderror(&_can); } -void Can::monitor(bool silent) { +void CAN::monitor(bool silent) { can_monitor(&_can, (silent) ? 1 : 0); } -int Can::mode(Mode mode) { +int CAN::mode(Mode mode) { return can_mode(&_can, (CanMode)mode); } -int Can::filter(unsigned int id, unsigned int mask, CANFormat format, int handle) { +int CAN::filter(unsigned int id, unsigned int mask, CANFormat format, int handle) { return can_filter(&_can, id, mask, format, handle); } -void Can::attach(void (*fptr)(void), IrqType type) { +void CAN::attach(void (*fptr)(void), IrqType type) { if (fptr) { _irq[(CanIrqType)type].attach(fptr); can_irq_set(&_can, (CanIrqType)type, 1); @@ -78,12 +76,9 @@ } } -void Can::_irq_handler(uint32_t id, CanIrqType type) { - Can *handler = (Can*)id; - if (handler->_irq[type] != NULL) - { - handler->_irq[type].call(); - } +void CAN::_irq_handler(uint32_t id, CanIrqType type) { + CAN *handler = (CAN*)id; + handler->_irq[type].call(); } } // namespace mbed