mikroSDK Reference Manual
|
CAN Driver API Reference. More...
Functions list | |
void | can_configure_default (can_config_t *config) |
Configure CAN Driver configuration structure. More... | |
void | can_filter_configure_default (can_filter_config_t *filter_config) |
Configure CAN Driver filter configuration structure. More... | |
err_t | can_open (can_t *obj, can_config_t *config) |
Open the CAN driver object. More... | |
err_t | can_init (can_t *obj) |
Initialize CAN module. More... | |
err_t | can_set_filter (can_t *obj, can_filter_config_t *filter_config) |
Initialize CAN module filter. More... | |
err_t | can_set_frequency (can_t *obj, uint32_t frequency) |
Set CAN module frequency. More... | |
err_t | can_get_frequency (can_t *obj) |
Get CAN module frequency. More... | |
err_t | can_set_mode (can_t *obj, can_mode_t mode) |
Set CAN module mode. More... | |
err_t | can_get_mode (can_t *obj) |
Get CAN module mode. More... | |
err_t | can_transmit (can_t *obj, can_transmit_message_struct *transmit_message) |
Transmit data to the first free TX mailbox. More... | |
void | can_transmission_stop (can_t *obj) |
Stop transmit operation. More... | |
err_t | can_receive (can_t *obj, can_receive_message_struct *receive_message) |
Get data from the RX FIFO. More... | |
err_t | can_close (can_t *obj) |
Close CAN driver object. More... | |
The CAN driver provides standard CAN functionality.
void can_configure_default | ( | can_config_t * | config | ) |
Configures can_config_t structure to default initialization values. Take into consideration that this is just structure variable initial values setting. Values need to be redefined by user.
[in,out] | config | configure CAN driver configuration structure. See can_config_t structure definition for detailed explanation. |
Default values:
Function | Default value |
---|---|
Tx pin | 0xFFFFFFFF (invalid pin) |
Rx pin | 0xFFFFFFFF (invalid pin) |
Mode | CAN_MODE_NORMAL |
Frequency | 500000 |
Example
void can_filter_configure_default | ( | can_filter_config_t * | filter_config | ) |
Configures can_filter_config_t structure to default initialization values. Take into consideration that this is just structure variable initial values setting. Values need to be redefined by user.
[in,out] | filter_config | configure CAN driver filter configuration structure. See can_filter_config_t structure definition for detailed explanation. |
Default values:
Function | Default value |
---|---|
ID high | 0x0000 |
ID low | 0x0000 |
ID mask high | 0x0000 |
ID mask low | 0x0000 |
Filter mode | CAN_FILTER_MODE_IDMASK |
Filter scale | CAN_FILTER_SCALE_16BIT |
Filter enable | CAN_FILTER_DISABLE |
Filter FIFO | CAN_FILTER_FIFO0 |
Filter bank | 0 |
Example
err_t can_open | ( | can_t * | obj, |
can_config_t * | config | ||
) |
Opens the CAN driver object on selected pins. Allocates memory and pins for specified object.
[in,out] | obj | CAN driver object. See can_t structure definition for detailed explanation. |
[in] | config | CAN driver configuration settings. See can_config_t structure definition for detailed explanation. |
config
structure has been adequately populated beforehand. See can_configure_default definition for detailed explanation. Example
Sets CAN module parameters.
[in] | obj | CAN driver object. See can_t structure definition for detailed explanation. |
Example
err_t can_set_filter | ( | can_t * | obj, |
can_filter_config_t * | filter_config | ||
) |
Sets CAN module filter parameters.
[in] | obj | CAN driver object. See can_t structure definition for detailed explanation. |
[in] | filter_config | CAN filter config structure. See can_filter_config_t structure definition for detailed explanation. |
can_filter_config_t
structure has been adequately filled out. Example
Sets CAN module frequency to frequency
value if possible. Frequency must be set to exact amount as requested, otherwise error is returned.
[in] | obj | CAN driver object. See can_t structure definition for detailed explanation. |
[in] | frequency | Specified CAN transmission rate. |
Example
Gets the currently configured CAN frequency.
[in] | obj | CAN driver object. See can_t structure definition for detailed explanation. |
Example
err_t can_set_mode | ( | can_t * | obj, |
can_mode_t | mode | ||
) |
Sets CAN module mode to mode
if possible.
[in] | obj | CAN driver object. See can_t structure definition for detailed explanation. |
[in] | mode | Specified CAN mode. See can_mode_t definition for detailed explanation. |
Example
Gets the currently configured CAN mode.
[in] | obj | CAN driver object. See can_t structure definition for detailed explanation. |
Example
err_t can_transmit | ( | can_t * | obj, |
can_transmit_message_struct * | transmit_message | ||
) |
Function sets parameters from the transmit message structure in the appropriate registers and then sends out the data.
[in] | obj | CAN driver object. See can_t structure definition for detailed explanation. |
[in] | transmit_message | Structure containing necessary information about the message being transmitted. See #can_message_struct structure definition for detailed explanation. |
Example
void can_transmission_stop | ( | can_t * | obj | ) |
Function accesses hardware transmit registers, finds the transmit mailbox that has message transmission request in progress and stops data transmission.
[in] | obj | CAN driver object. |
Example
err_t can_receive | ( | can_t * | obj, |
can_receive_message_struct * | receive_message | ||
) |
Function stores previously transmitted data into the rx_data in receive_message structure.
[in] | obj | CAN driver object. See can_t structure definition for detailed explanation. |
[in] | receive_message | Structure designed to store received information and data retrieved from the CAN registers. See #can_message_struct structure definition for detailed explanation. |
Example
De-allocates hardware resources for specific driver object and de-initializes the module on a hardware level, resets pin AF to default values, clears all buffers used by object and disables module clock for lower power consumption.
[in,out] | obj | CAN driver object. See can_t structure definition for detailed explanation. |
Example