1
1
/* mbed Microcontroller Library
2
- * Copyright (c) 2006-2017 ARM Limited
2
+ * Copyright (c) 2019 ToolSense
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
24
24
#include "pinmap_function.h"
25
25
#include "PeripheralPins.h"
26
26
#include "mbed_assert.h"
27
- #include "can_device.h"
28
27
#include "em_cmu.h"
29
28
#include "em_can.h"
30
29
@@ -48,12 +47,16 @@ void can_init_freq(can_t *obj, PinName rd, PinName td, int hz)
48
47
49
48
CMU_Clock_TypeDef cmuClock_number ;
50
49
switch ((CANName )obj -> instance ) {
50
+ #ifdef CAN0
51
51
case CAN_0 :
52
52
cmuClock_number = cmuClock_CAN0 ;
53
53
break ;
54
+ #endif
55
+ #ifdef CAN1
54
56
case CAN_1 :
55
57
cmuClock_number = cmuClock_CAN1 ;
56
58
break ;
59
+ #endif
57
60
}
58
61
59
62
MBED_ASSERT ((unsigned int )rd != NC );
@@ -106,12 +109,16 @@ void can_irq_init(can_t *obj, can_irq_handler handler, uint32_t id)
106
109
int index = 0 ;
107
110
108
111
switch ((CANName )obj -> instance ) {
112
+ #ifdef CAN0
109
113
case CAN_0 :
110
114
index = 0 ;
111
115
break ;
116
+ #endif
117
+ #ifdef CAN1
112
118
case CAN_1 :
113
119
index = 1 ;
114
120
break ;
121
+ #endif
115
122
}
116
123
117
124
irq_handler = handler ;
@@ -124,12 +131,16 @@ void can_irq_free(can_t *obj)
124
131
CAN_MessageIntClear (obj -> instance , 0xFFFFFFFF );
125
132
126
133
switch ((CANName )obj -> instance ) {
134
+ #ifdef CAN0
127
135
case CAN_0 :
128
136
NVIC_DisableIRQ (CAN0_IRQn );
129
137
break ;
138
+ #endif
139
+ #ifdef CAN1
130
140
case CAN_1 :
131
141
NVIC_DisableIRQ (CAN1_IRQn );
132
142
break ;
143
+ #endif
133
144
}
134
145
}
135
146
@@ -149,6 +160,7 @@ int can_frequency(can_t *obj, int f)
149
160
CanInit .phaseBufferSegment1 ,
150
161
CanInit .phaseBufferSegment2 ,
151
162
CanInit .synchronisationJumpWidth );
163
+ return 0 ;
152
164
}
153
165
154
166
int can_write (can_t * obj , CAN_Message msg , int cc )
@@ -179,6 +191,8 @@ int can_read(can_t *obj, CAN_Message *msg, int handle)
179
191
if (CAN_HasNewdata (obj -> instance )) {
180
192
181
193
receiver .msgNum = 2 ;
194
+ receiver .extended = false;
195
+ receiver .extendedMask = false;
182
196
183
197
CAN_ReadMessage (obj -> instance , CAN_RX_IF , & receiver );
184
198
@@ -259,14 +273,18 @@ void can_irq_set(can_t *obj, CanIrqType type, uint32_t enable)
259
273
}
260
274
261
275
switch ((CANName )obj -> instance ) {
276
+ #ifdef CAN0
262
277
case CAN_0 :
263
278
NVIC_SetVector (CAN0_IRQn , CAN0_IRQHandler );
264
279
NVIC_EnableIRQ (CAN0_IRQn );
265
280
break ;
281
+ #endif
282
+ #ifdef CAN1
266
283
case CAN_1 :
267
284
NVIC_SetVector (CAN1_IRQn , CAN1_IRQHandler );
268
285
NVIC_EnableIRQ (CAN1_IRQn );
269
286
break ;
287
+ #endif
270
288
}
271
289
}
272
290
@@ -286,16 +304,19 @@ static void can_irq(CANName name, int id)
286
304
}
287
305
}
288
306
307
+ #ifdef CAN0
289
308
void CAN0_IRQHandler (void )
290
309
{
291
310
can_irq (CAN_0 , 0 );
292
311
}
312
+ #endif
293
313
314
+ #ifdef CAN1
294
315
void CAN1_IRQHandler (void )
295
316
{
296
317
can_irq (CAN_1 , 1 );
297
318
}
298
-
319
+ #endif
299
320
300
321
const PinMap * can_rd_pinmap ()
301
322
{
@@ -307,4 +328,4 @@ const PinMap *can_td_pinmap()
307
328
return PinMap_CAN_RX ;
308
329
}
309
330
310
- #endif // DEVICE_CAN
331
+ #endif //DEVICE_CAN
0 commit comments