mirror of https://github.com/ARMmbed/mbed-os.git
Add an mbed API that allows the initialization of the CAN at the correct
CAN bus frequencypull/4165/head
parent
5ebe295364
commit
f740d2f3bc
|
|
@ -34,6 +34,17 @@ CAN::CAN(PinName rd, PinName td) : _can(), _irq() {
|
|||
can_irq_init(&_can, (&CAN::_irq_handler), (uint32_t)this);
|
||||
}
|
||||
|
||||
CAN::CAN(PinName rd, PinName td, int f) : _can(), _irq() {
|
||||
// No lock needed in constructor
|
||||
|
||||
for (int i = 0; i < sizeof _irq / sizeof _irq[0]; i++) {
|
||||
_irq[i].attach(donothing);
|
||||
}
|
||||
|
||||
can_init_freq(&_can, rd, td, f);
|
||||
can_irq_init(&_can, (&CAN::_irq_handler), (uint32_t)this);
|
||||
}
|
||||
|
||||
CAN::~CAN() {
|
||||
// No lock needed in destructor
|
||||
can_irq_free(&_can);
|
||||
|
|
|
|||
|
|
@ -111,6 +111,15 @@ public:
|
|||
* @endcode
|
||||
*/
|
||||
CAN(PinName rd, PinName td);
|
||||
|
||||
/** Initialize CAN interface and set the frequency
|
||||
*
|
||||
* @param rd the rd pin
|
||||
* @param td the td pin
|
||||
* @param f the bus frequency in hertz
|
||||
*/
|
||||
CAN(PinName rd, PinName td, int f);
|
||||
|
||||
virtual ~CAN();
|
||||
|
||||
/** Set the frequency of the CAN interface
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ typedef void (*can_irq_handler)(uint32_t id, CanIrqType type);
|
|||
typedef struct can_s can_t;
|
||||
|
||||
void can_init (can_t *obj, PinName rd, PinName td);
|
||||
void can_init_freq (can_t *obj, PinName rd, PinName td, int hz);
|
||||
void can_free (can_t *obj);
|
||||
int can_frequency (can_t *obj, int hz);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue