mikroSDK Reference Manual
|
CAN Hardware Abstraction Layer API Reference. More...
Functions list | |
void | hal_can_configure_default (hal_can_config_t *config) |
Configure CAN HAL configuration structure. | |
void | hal_can_filter_configure_default (hal_can_filter_config_t *filter_config) |
Configure CAN HAL filter configuration structure. | |
err_t | hal_can_open (handle_t *handle, bool hal_obj_open_state) |
Open the CAN HAL object. | |
err_t | hal_can_init (handle_t *handle, hal_can_config_t *config, hal_can_filter_config_t *filter_config) |
Initialize CAN module. | |
err_t | hal_can_set_filter (handle_t *handle, hal_can_config_t *config, hal_can_filter_config_t *filter_config) |
Initialize CAN module filter. | |
err_t | hal_can_set_frequency (handle_t *handle, hal_can_config_t *config, hal_can_filter_config_t *filter_config) |
Set CAN module frequency. | |
err_t | hal_can_get_frequency (handle_t *handle) |
Get CAN module frequency. | |
err_t | hal_can_set_mode (handle_t *handle, hal_can_config_t *config, hal_can_filter_config_t *filter_config) |
Set CAN module mode. | |
err_t | hal_can_get_mode (handle_t *handle) |
Get CAN module mode. | |
err_t | hal_can_transmit (handle_t *handle, hal_can_transmit_message_struct *transmit_message) |
Transmit data to the first free TX mailbox. | |
void | hal_can_transmission_stop (handle_t *handle) |
Stop transmit operation. | |
err_t | hal_can_receive (handle_t *handle, hal_can_receive_message_struct *receive_message) |
Get data from the RX FIFO. | |
err_t | hal_can_close (handle_t *handle) |
Close CAN HAL object. | |
err_t hal_can_close | ( | handle_t * | handle | ) |
De-allocates hardware resources for specific HAL 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 HAL object. See hal_can_t structure definition for detailed explanation. |
Example
void hal_can_configure_default | ( | hal_can_config_t * | config | ) |
Configures hal_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 HAL configuration structure. See hal_can_config_t structure definition for detailed explanation. |
Default values:
Function | Default value |
---|---|
Tx pin | 0xFFFFFFFF (invalid pin) |
Rx pin | 0xFFFFFFFF (invalid pin) |
Mode | HAL_CAN_MODE_NORMAL |
Frequency | 500000 |
Example
void hal_can_filter_configure_default | ( | hal_can_filter_config_t * | filter_config | ) |
Configures hal_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 HAL filter configuration structure. See hal_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 | HAL_CAN_FILTER_MODE_IDMASK |
Filter scale | HAL_CAN_FILTER_SCALE_16BIT |
Filter enable | HAL_CAN_FILTER_DISABLE |
Filter FIFO | HAL_CAN_FILTER_FIFO0 |
Filter bank | 0 |
Example
err_t hal_can_get_frequency | ( | handle_t * | handle | ) |
Gets the currently configured CAN frequency.
[in] | obj | CAN HAL object. See hal_can_t structure definition for detailed explanation. |
Example
err_t hal_can_get_mode | ( | handle_t * | handle | ) |
Gets the currently configured CAN mode.
[in] | obj | CAN HAL object. See hal_can_t structure definition for detailed explanation. |
Example
err_t hal_can_init | ( | handle_t * | handle, |
hal_can_config_t * | config, | ||
hal_can_filter_config_t * | filter_config ) |
Sets CAN module parameters.
[in] | obj | CAN HAL object. See hal_can_t structure definition for detailed explanation. |
[in] | config | CAN config structure. See hal_can_config_t structure definition for detailed explanation. |
[in] | filter_config | CAN filter config structure. See hal_can_filter_config_t structure definition for detailed explanation. |
Example
err_t hal_can_open | ( | handle_t * | handle, |
bool | hal_obj_open_state ) |
Opens the CAN HAL object on selected pins. Allocates memory and pins for specified object.
[in,out] | obj | CAN HAL object. See hal_can_t structure definition for detailed explanation. |
[in] | hal_obj_open_state | CAN state, is it open or not. |
Example
err_t hal_can_receive | ( | handle_t * | handle, |
hal_can_receive_message_struct * | receive_message ) |
Function stores previously transmitted data into the rx_data in receive_message structure.
[in] | obj | CAN HAL object. See hal_can_t structure definition for detailed explanation. |
[in] | receive_message | Structure designed to store received information and data retrieved from the CAN registers. See #hal_can_message_struct structure definition for detailed explanation. |
Example
err_t hal_can_set_filter | ( | handle_t * | handle, |
hal_can_config_t * | config, | ||
hal_can_filter_config_t * | filter_config ) |
Sets CAN module filter parameters.
[in] | obj | CAN HAL object. See hal_can_t structure definition for detailed explanation. |
[in] | config | CAN config structure. See hal_can_config_t structure definition for detailed explanation. |
[in] | filter_config | CAN filter config structure. See hal_can_filter_config_t structure definition for detailed explanation. |
hal_can_filter_config_t
structure has been adequately filled out. Example
err_t hal_can_set_frequency | ( | handle_t * | handle, |
hal_can_config_t * | config, | ||
hal_can_filter_config_t * | filter_config ) |
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 HAL object. See hal_can_t structure definition for detailed explanation. |
[in] | config | CAN config structure. See hal_can_config_t structure definition for detailed explanation. |
[in] | filter_config | CAN filter config structure. See hal_can_filter_config_t structure definition for detailed explanation. |
Example
err_t hal_can_set_mode | ( | handle_t * | handle, |
hal_can_config_t * | config, | ||
hal_can_filter_config_t * | filter_config ) |
Sets CAN module mode to mode
if possible.
[in] | obj | CAN HAL object. See hal_can_t structure definition for detailed explanation. |
[in] | config | CAN config structure. See hal_can_config_t structure definition for detailed explanation. |
[in] | filter_config | CAN filter config structure. See hal_can_filter_config_t structure definition for detailed explanation. |
Example
void hal_can_transmission_stop | ( | handle_t * | handle | ) |
Function accesses hardware transmit registers, finds the transmit mailbox that has message transmission request in progress and stops data transmission.
[in] | obj | CAN HAL object. |
Example
err_t hal_can_transmit | ( | handle_t * | handle, |
hal_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 HAL object. See hal_can_t structure definition for detailed explanation. |
[in] | transmit_message | Structure containing necessary information about the message being transmitted. See #hal_can_message_struct structure definition for detailed explanation. |
Example