STM32F10x library
Macros | Functions
can.c File Reference

CAN bus routines. More...

#include <stm32f10x.h>
#include <stm32f10x_can.h>

Macros

#define CAN_RX_INT
 

Functions

void can_rx_callback (CanRxMsg *msg)
 Extern. Implement to receive CAN messages. More...
 
uint8_t can_filter (uint32_t id, uint32_t msk)
 Add a filter to CAN reception logic. ID bits masked with 1 have to match. More...
 
void can_init (uint16_t br, uint8_t md)
 Init CAN. More...
 
void can_shutdown (void)
 Deinit CAN.
 
uint8_t can_tx (CanTxMsg *msg)
 Transmit CAN message. More...
 
uint8_t can_rx (CanRxMsg *msg)
 Receive CAN message. More...
 

Detailed Description

CAN bus routines.

Author
Matej Kogovsek (matej.nosp@m.@ham.nosp@m.radio.nosp@m..si)
Note
This file is part of mat-stm32f1-lib

Macro Definition Documentation

#define CAN_RX_INT

If defined, implement can_rx_callback(CanRxMsg*) to receive messages (preferred). If not defined, call can_rx(CanRxMsg*) periodically.

Function Documentation

uint8_t can_filter ( uint32_t  id,
uint32_t  msk 
)

Add a filter to CAN reception logic. ID bits masked with 1 have to match.

Parameters
[in]idFilter ID bits
[in]mskFilter mask bits
Returns
Number of filters defined (max 13) on success, 0 otherwise.
void can_init ( uint16_t  br,
uint8_t  md 
)

Init CAN.

Parameters
[in]brBaudrate (possible values defined in header), F_CPU dependent
[in]mdMode (CAN_Mode_Normal, CAN_Mode_Silent, CAN_Mode_LoopBack)
uint8_t can_rx ( CanRxMsg *  msg)

Receive CAN message.

Use only if CAN_RX_INT not defined. Call periodically.

Parameters
[out]msgPointer to caller allocated CanRxMsg
Returns
True on success, false otherwise.
void can_rx_callback ( CanRxMsg *  msg)

Extern. Implement to receive CAN messages.

The function is called by an interrupt when CAN_RX_INT is defined.

Parameters
[in]msgPointer to interrupt local variable. Copy to keep after callback exits.
uint8_t can_tx ( CanTxMsg *  msg)

Transmit CAN message.

Parameters
[in]msgMessage to transmit
Returns
True on success, false otherwise.