stm32/f1/can: Add loopback/silent vars to init function.
Also: add helper function for mailbox checking
This commit is contained in:
parent
4e4496f70d
commit
4b86c28141
2 changed files with 17 additions and 4 deletions
|
@ -619,7 +619,8 @@ BEGIN_DECLS
|
|||
|
||||
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);
|
||||
|
||||
void can_filter_init(u32 canport, u32 nr, bool scale_32bit, bool id_list_mode,
|
||||
u32 fr1, u32 fr2, u32 fifo, bool enable);
|
||||
|
@ -640,7 +641,7 @@ void can_receive(u32 canport, u8 fifo, bool release, u32 *id, bool *ext,
|
|||
bool *rtr, u32 *fmi, u8 *length, u8 *data);
|
||||
|
||||
void can_fifo_release(u32 canport, u8 fifo);
|
||||
|
||||
bool can_available_mailbox(u32 canport);
|
||||
END_DECLS
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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". */
|
||||
|
|
Loading…
Reference in a new issue