mirror of https://github.com/ARMmbed/mbed-os.git
Add @param documentation for new event parameter
Add clear irq to attach() template function Call irq_handler for every interrupt setpull/20/head
parent
63b2b271d1
commit
a16dc72272
|
@ -162,6 +162,7 @@ public:
|
|||
* generated.
|
||||
*
|
||||
* @param fptr A pointer to a void function, or 0 to set as none
|
||||
* @param event Which can interrupt to attach the member function to (CAN::IRQ_RX, CAN::IRQ_TX, CAN::IRQ_ERROR, CAN::IRQ_OVERRUN, CAN::IRQ_WAKEUP, CAN::IRQ_PASSIVE, CAN::IRQ_ARB, CAN::IRQ_BUS, CAN::IRQ_READY) - Note that not every event is supported by all hardware
|
||||
*/
|
||||
void attach(void (*fptr)(void), can_irq_event event=IRQ_RX);
|
||||
|
||||
|
@ -170,13 +171,17 @@ public:
|
|||
*
|
||||
* @param tptr pointer to the object to call the member function on
|
||||
* @param mptr pointer to the member function to be called
|
||||
* @param event Which can interrupt to attach the member function to (CAN::IRQ_RX, CAN::IRQ_TX, CAN::IRQ_ERROR, CAN::IRQ_OVERRUN, CAN::IRQ_WAKEUP, CAN::IRQ_PASSIVE, CAN::IRQ_ARB, CAN::IRQ_BUS, CAN::IRQ_READY) - Note that not every event is supported by all hardware
|
||||
*/
|
||||
template<typename T>
|
||||
void attach(T* tptr, void (T::*mptr)(void), can_irq_event event=IRQ_RX) {
|
||||
if((mptr != NULL) && (tptr != NULL)) {
|
||||
_irq[type].attach(tptr, mptr);
|
||||
_irq[event].attach(tptr, mptr);
|
||||
can_irq_set(&_can, event, 1);
|
||||
}
|
||||
else {
|
||||
can_irq_set(&_can, event, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void _irq_handler(uint32_t id, can_irq_event event);
|
||||
|
|
|
@ -79,23 +79,25 @@ static inline void can_enable(can_t *obj) {
|
|||
}
|
||||
|
||||
static inline void can_irq(uint32_t icr, uint32_t index) {
|
||||
#warning TODO(@jorisa) Check that events not happen at same time
|
||||
can_irq_event event;
|
||||
switch (icr) {
|
||||
case (1 << 0): event = IRQ_RX; break;
|
||||
case (1 << 1): event = IRQ_TX; break;
|
||||
case (1 << 2): event = IRQ_ERROR; break;
|
||||
case (1 << 3): event = IRQ_OVERRUN; break;
|
||||
case (1 << 4): event = IRQ_WAKEUP; break;
|
||||
case (1 << 5): event = IRQ_PASSIVE; break;
|
||||
case (1 << 6): event = IRQ_ARB; break;
|
||||
case (1 << 7): event = IRQ_BUS; break;
|
||||
case (1 << 8): event = IRQ_READY; break;
|
||||
default: return;
|
||||
uint32_t i;
|
||||
|
||||
for(i = 0; i < 8; i++)
|
||||
{
|
||||
if((can_irq_ids[index] != 0) && (icr & (1 << i)))
|
||||
{
|
||||
switch (i) {
|
||||
case 0: irq_handler(can_irq_ids[index], IRQ_RX); break;
|
||||
case 1: irq_handler(can_irq_ids[index], IRQ_TX); break;
|
||||
case 2: irq_handler(can_irq_ids[index], IRQ_ERROR); break;
|
||||
case 3: irq_handler(can_irq_ids[index], IRQ_OVERRUN); break;
|
||||
case 4: irq_handler(can_irq_ids[index], IRQ_WAKEUP); break;
|
||||
case 5: irq_handler(can_irq_ids[index], IRQ_PASSIVE); break;
|
||||
case 6: irq_handler(can_irq_ids[index], IRQ_ARB); break;
|
||||
case 7: irq_handler(can_irq_ids[index], IRQ_BUS); break;
|
||||
case 8: irq_handler(can_irq_ids[index], IRQ_READY); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (can_irq_ids[index] != 0)
|
||||
irq_handler(can_irq_ids[index], event);
|
||||
}
|
||||
|
||||
// Have to check that the CAN block is active before reading the Interrupt
|
||||
|
|
Loading…
Reference in New Issue