aboutsummaryrefslogtreecommitdiff
path: root/lib/stm32/f1
diff options
context:
space:
mode:
authorJeff Ciesielski2012-10-19 16:27:17 -0700
committerJeff Ciesielski2012-10-19 16:27:17 -0700
commit4b86c281410aa330a1640e4211ae9da476dd0f56 (patch)
tree2f0fa6e5a3801fe2beff629c622bd3b6a4704bea /lib/stm32/f1
parent4e4496f70d00fe24b2c5d594d6500f537eeb6478 (diff)
stm32/f1/can: Add loopback/silent vars to init function.
Also: add helper function for mailbox checking
Diffstat (limited to 'lib/stm32/f1')
-rw-r--r--lib/stm32/f1/can.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/stm32/f1/can.c b/lib/stm32/f1/can.c
index fc7e0e7..46d0e65 100644
--- a/lib/stm32/f1/can.c
+++ b/lib/stm32/f1/can.c
@@ -32,7 +32,8 @@ void can_reset(u32 canport)
}
int can_init(u32 canport, bool ttcm, bool abom, bool awum, bool nart,
- bool rflm, bool txfp, u32 sjw, u32 ts1, u32 ts2, u32 brp)
+ bool rflm, bool txfp, u32 sjw, u32 ts1, u32 ts2, u32 brp,
+ bool loopback, bool silent)
{
u32 wait_ack = 0x00000000;
u32 can_msr_inak_timeout = 0x0000FFFF;
@@ -85,8 +86,19 @@ int can_init(u32 canport, bool ttcm, bool abom, bool awum, bool nart,
else
CAN_MCR(canport) &= ~CAN_MCR_TXFP;
+ if (silent)
+ CAN_BTR(canport) |= (CAN_BTR_SILM);
+ else
+ CAN_BTR(canport) &= !(CAN_BTR_SILM);
+
+ if (loopback)
+ CAN_BTR(canport) |= (CAN_BTR_LBKM);
+ else
+ CAN_BTR(canport) &= !(CAN_BTR_LBKM);
+
+
/* Set bit timings. */
- CAN_BTR(canport) = sjw | ts2 | ts1 |
+ CAN_BTR(canport) |= sjw | ts2 | ts1 |
(u32)(CAN_BTR_BRP_MASK & (brp - 1));
/* Request initialization "leave". */