Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-dev by
Diff: targets/hal/TARGET_STM/TARGET_STM32F4/can_api.c
- Revision:
- 129:8a86d1aafce0
- Parent:
- 125:e632577a484c
--- a/targets/hal/TARGET_STM/TARGET_STM32F4/can_api.c	Fri May 13 16:00:11 2016 +0100
+++ b/targets/hal/TARGET_STM/TARGET_STM32F4/can_api.c	Mon May 16 12:00:12 2016 +0100
@@ -42,7 +42,7 @@
         obj->index = 0;
     } else {
         __HAL_RCC_CAN2_CLK_ENABLE();
-        obj->index = 0;
+        obj->index = 1;
     }
 
     // Configure the CAN pins
@@ -75,6 +75,9 @@
 
     filter_number = (obj->can == CAN_1) ? 0 : 14;
 
+    // Set initial CAN frequency to 100kb/s
+    can_frequency(obj, 100000);
+
     can_filter(obj, 0, 0, CANStandard, filter_number);
 }
 
@@ -177,7 +180,7 @@
 
 int can_frequency(can_t *obj, int f) 
 {
-    int pclk ; //= PeripheralClock;
+    int pclk = HAL_RCC_GetPCLK1Freq();
     int btr = can_speed(pclk, (unsigned int)f, 1);
     CAN_TypeDef *can = (CAN_TypeDef *)(obj->can);
 
    