mirror of https://github.com/ARMmbed/mbed-os.git
Add can_t->index to struct and set it during can_init
parent
a9f0d9a3f7
commit
51bfe267f4
|
@ -22,6 +22,8 @@
|
|||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#define CAN_NUM 2
|
||||
|
||||
/* Acceptance filter mode in AFMR register */
|
||||
#define ACCF_OFF 0x01
|
||||
#define ACCF_BYPASS 0x02
|
||||
|
@ -166,7 +168,12 @@ void can_init(can_t *obj, PinName rd, PinName td) {
|
|||
|
||||
pinmap_pinout(rd, PinMap_CAN_RD);
|
||||
pinmap_pinout(td, PinMap_CAN_TD);
|
||||
|
||||
|
||||
switch ((int)obj->dev) {
|
||||
case CAN_1: obj->index = 0; break;
|
||||
case CAN_2: obj->index = 1; break;
|
||||
}
|
||||
|
||||
can_reset(obj);
|
||||
obj->dev->IER = 0; // Disable Interrupts
|
||||
can_frequency(obj, 100000);
|
||||
|
|
|
@ -59,6 +59,7 @@ struct dac_s {
|
|||
|
||||
struct can_s {
|
||||
LPC_CAN_TypeDef *dev;
|
||||
int index;
|
||||
};
|
||||
|
||||
struct i2c_s {
|
||||
|
|
Loading…
Reference in New Issue