Add can_t->index to struct and set it during can_init

pull/20/head
Joris Aerts 2013-07-30 15:17:40 -07:00
parent a9f0d9a3f7
commit 51bfe267f4
2 changed files with 9 additions and 1 deletions

View File

@ -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
@ -167,6 +169,11 @@ 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);

View File

@ -59,6 +59,7 @@ struct dac_s {
struct can_s {
LPC_CAN_TypeDef *dev;
int index;
};
struct i2c_s {