@@ -163,12 +163,23 @@ static void _can_init_freq_direct(can_t *obj, const can_pinmap_t *pinmap, int hz
163
163
obj -> CanHandle .Init .DataSyncJumpWidth = 0x1 ; // Not used - only in FDCAN
164
164
obj -> CanHandle .Init .DataTimeSeg1 = 0x1 ; // Not used - only in FDCAN
165
165
obj -> CanHandle .Init .DataTimeSeg2 = 0x1 ; // Not used - only in FDCAN
166
- #ifndef TARGET_STM32G4
166
+ #ifdef TARGET_STM32H7
167
+ /* Message RAM offset is only supported in STM32H7 platforms of supported FDCAN platforms */
167
168
obj -> CanHandle .Init .MessageRAMOffset = 0 ;
169
+
170
+ /* The number of Standard and Extended ID filters are initialized to the maximum possile extent
171
+ * for STM32H7 platforms
172
+ */
173
+ obj -> CanHandle .Init .StdFiltersNbr = 128 ; // to be aligned with the handle parameter in can_filter
174
+ obj -> CanHandle .Init .ExtFiltersNbr = 128 ; // to be aligned with the handle parameter in can_filter
175
+ #else
176
+ /* The number of Standard and Extended ID filters are initialized to the maximum possile extent
177
+ * for STM32G0x1, STM32G4 and STM32L5 platforms
178
+ */
179
+ obj -> CanHandle .Init .StdFiltersNbr = 28 ; // to be aligned with the handle parameter in can_filter
180
+ obj -> CanHandle .Init .ExtFiltersNbr = 8 ; // to be aligned with the handle parameter in can_filter
168
181
#endif
169
- obj -> CanHandle .Init .StdFiltersNbr = 1 ; // to be aligned with the handle parameter in can_filter
170
- obj -> CanHandle .Init .ExtFiltersNbr = 1 ; // to be aligned with the handle parameter in can_filter
171
- #ifndef TARGET_STM32G4
182
+ #ifdef TARGET_STM32H7
172
183
obj -> CanHandle .Init .RxFifo0ElmtsNbr = 8 ;
173
184
obj -> CanHandle .Init .RxFifo0ElmtSize = FDCAN_DATA_BYTES_8 ;
174
185
obj -> CanHandle .Init .RxFifo1ElmtsNbr = 0 ;
@@ -180,7 +191,7 @@ static void _can_init_freq_direct(can_t *obj, const can_pinmap_t *pinmap, int hz
180
191
obj -> CanHandle .Init .TxFifoQueueElmtsNbr = 3 ;
181
192
#endif
182
193
obj -> CanHandle .Init .TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION ;
183
- #ifndef TARGET_STM32G4
194
+ #ifdef TARGET_STM32H7
184
195
obj -> CanHandle .Init .TxElmtSize = FDCAN_DATA_BYTES_8 ;
185
196
#endif
186
197
can_internal_init (obj );
@@ -331,20 +342,16 @@ int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t
331
342
{
332
343
FDCAN_FilterTypeDef sFilterConfig = {0 };
333
344
334
- if (handle != 0 ) { // message filter handle is not supported for STM controllers
335
- return 0 ;
336
- }
337
-
338
345
if (format == CANStandard ) {
339
346
sFilterConfig .IdType = FDCAN_STANDARD_ID ;
340
- sFilterConfig .FilterIndex = 0 ;
347
+ sFilterConfig .FilterIndex = handle ;
341
348
sFilterConfig .FilterType = FDCAN_FILTER_MASK ;
342
349
sFilterConfig .FilterConfig = FDCAN_FILTER_TO_RXFIFO0 ;
343
350
sFilterConfig .FilterID1 = id ;
344
351
sFilterConfig .FilterID2 = mask ;
345
352
} else if (format == CANExtended ) {
346
353
sFilterConfig .IdType = FDCAN_EXTENDED_ID ;
347
- sFilterConfig .FilterIndex = 0 ;
354
+ sFilterConfig .FilterIndex = handle ;
348
355
sFilterConfig .FilterType = FDCAN_FILTER_MASK ;
349
356
sFilterConfig .FilterConfig = FDCAN_FILTER_TO_RXFIFO0 ;
350
357
sFilterConfig .FilterID1 = id ;
0 commit comments