mikroSDK Reference Manual
hal_can.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** Copyright (C) 2024 MikroElektronika d.o.o.
4** Contact: https://www.mikroe.com/contact
5**
6** This file is part of the mikroSDK package
7**
8** Commercial License Usage
9**
10** Licensees holding valid commercial NECTO compilers AI licenses may use this
11** file in accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The MikroElektronika Company.
14** For licensing terms and conditions see
15** https://www.mikroe.com/legal/software-license-agreement.
16** For further information use the contact form at
17** https://www.mikroe.com/contact.
18**
19**
20** GNU Lesser General Public License Usage
21**
22** Alternatively, this file may be used for
23** non-commercial projects under the terms of the GNU Lesser
24** General Public License version 3 as published by the Free Software
25** Foundation: https://www.gnu.org/licenses/lgpl-3.0.html.
26**
27** The above copyright notice and this permission notice shall be
28** included in all copies or substantial portions of the Software.
29**
30** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31** OF MERCHANTABILITY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
32** TO THE WARRANTIES FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
33** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
34** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
35** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
36** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37**
38****************************************************************************/
44#ifndef _HAL_CAN_H_
45#define _HAL_CAN_H_
46
47#ifdef __cplusplus
48extern "C"{
49#endif
50
51#include "hal_target.h"
52
60typedef struct
61{
62 handle_t *hal_can_handle;
63 handle_t *drv_can_handle;
66
77
100
111
120
129
138
147
186
195
309
342
359
371typedef struct
372{
373 union {
374 struct {
375 uint16_t std_id;
376 uint16_t ext_id;
377 };
378 uint32_t id;
379 };
382 uint8_t data_len;
383 uint8_t message_data[8];
385
397typedef struct
398{
399 hal_can_message_t message; /* CAN message structure. */
401
413typedef struct
414{
415 hal_can_message_t message; /* CAN message structure. */
416 uint8_t rx_fifo_number; /* Receive FIFO number. */
418
464
499
531err_t hal_can_open( handle_t *handle, bool hal_obj_open_state );
532
566err_t hal_can_init( handle_t *handle, hal_can_config_t *config, hal_can_filter_config_t *filter_config );
567
602err_t hal_can_set_filter( handle_t *handle, hal_can_config_t *config, hal_can_filter_config_t *filter_config );
603
638err_t hal_can_set_frequency( handle_t *handle, hal_can_config_t *config, hal_can_filter_config_t *filter_config );
639
660err_t hal_can_get_frequency( handle_t *handle );
661
695err_t hal_can_set_mode( handle_t *handle, hal_can_config_t *config, hal_can_filter_config_t *filter_config );
696
717err_t hal_can_get_mode( handle_t *handle );
718
765err_t hal_can_transmit( handle_t *handle, hal_can_transmit_message_struct *transmit_message );
766
786void hal_can_transmission_stop( handle_t *handle );
787
820err_t hal_can_receive( handle_t *handle, hal_can_receive_message_struct *receive_message );
821
846err_t hal_can_close( handle_t *handle );
847
848
849 // halcangroup
850 // halgroup
851 // pergroup
852
853#ifdef __cplusplus
854}
855#endif
856
857#endif // _HAL_CAN_H_
858// ------------------------------------------------------------------------- END
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_set_frequency(handle_t *handle, hal_can_config_t *config, hal_can_filter_config_t *filter_config)
Set CAN module frequency.
void hal_can_configure_default(hal_can_config_t *config)
Configure CAN HAL configuration structure.
err_t hal_can_init(handle_t *handle, hal_can_config_t *config, hal_can_filter_config_t *filter_config)
Initialize CAN module.
void hal_can_filter_configure_default(hal_can_filter_config_t *filter_config)
Configure CAN HAL filter configuration structure.
err_t hal_can_get_frequency(handle_t *handle)
Get CAN module frequency.
void hal_can_transmission_stop(handle_t *handle)
Stop transmit operation.
err_t hal_can_transmit(handle_t *handle, hal_can_transmit_message_struct *transmit_message)
Transmit data to the first free TX mailbox.
err_t hal_can_close(handle_t *handle)
Close CAN HAL object.
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_open(handle_t *handle, bool hal_obj_open_state)
Open the CAN HAL object.
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.
hal_can_frame_type_t
Definition hal_can.h:125
@ HAL_CAN_FRAME_TYPE_RTR
Definition hal_can.h:127
@ HAL_CAN_FRAME_TYPE_DATA
Definition hal_can.h:126
hal_can_err_t
Definition hal_can.h:71
@ HAL_CAN_SUCCESS
Definition hal_can.h:72
@ HAL_CAN_ERROR
Definition hal_can.h:75
@ HAL_CAN_WRONG_PINS
Definition hal_can.h:73
@ HAL_CAN_MODULE_ERROR
Definition hal_can.h:74
hal_can_filter_mode_t
Definition hal_can.h:134
@ HAL_CAN_FILTER_MODE_IDMASK
Definition hal_can.h:135
@ HAL_CAN_FILTER_MODE_IDLIST
Definition hal_can.h:136
hal_can_state_t
Definition hal_can.h:105
@ HAL_CAN_STATE_LISTENING
Definition hal_can.h:108
@ HAL_CAN_STATE_ERROR
Definition hal_can.h:109
@ HAL_CAN_STATE_READY
Definition hal_can.h:107
@ HAL_CAN_STATE_RESET
Definition hal_can.h:106
hal_can_filter_activation_t
Definition hal_can.h:191
@ HAL_CAN_FILTER_DISABLE
Definition hal_can.h:192
@ HAL_CAN_FILTER_ENABLE
Definition hal_can.h:193
hal_can_filter_fifo_t
Definition hal_can.h:152
@ HAL_CAN_FILTER_FIFO16
Definition hal_can.h:169
@ HAL_CAN_FILTER_FIFO30
Definition hal_can.h:183
@ HAL_CAN_FILTER_FIFO13
Definition hal_can.h:166
@ HAL_CAN_FILTER_FIFO4
Definition hal_can.h:157
@ HAL_CAN_FILTER_FIFO14
Definition hal_can.h:167
@ HAL_CAN_FILTER_FIFO15
Definition hal_can.h:168
@ HAL_CAN_FILTER_FIFO7
Definition hal_can.h:160
@ HAL_CAN_FILTER_FIFO19
Definition hal_can.h:172
@ HAL_CAN_FILTER_FIFO21
Definition hal_can.h:174
@ HAL_CAN_FILTER_FIFO23
Definition hal_can.h:176
@ HAL_CAN_FILTER_FIFO26
Definition hal_can.h:179
@ HAL_CAN_FILTER_FIFO18
Definition hal_can.h:171
@ HAL_CAN_FILTER_FIFO27
Definition hal_can.h:180
@ HAL_CAN_FILTER_FIFO31
Definition hal_can.h:184
@ HAL_CAN_FILTER_FIFO8
Definition hal_can.h:161
@ HAL_CAN_FILTER_FIFO24
Definition hal_can.h:177
@ HAL_CAN_FILTER_FIFO10
Definition hal_can.h:163
@ HAL_CAN_FILTER_FIFO25
Definition hal_can.h:178
@ HAL_CAN_FILTER_FIFO9
Definition hal_can.h:162
@ HAL_CAN_FILTER_FIFO6
Definition hal_can.h:159
@ HAL_CAN_FILTER_FIFO1
Definition hal_can.h:154
@ HAL_CAN_FILTER_FIFO29
Definition hal_can.h:182
@ HAL_CAN_FILTER_FIFO17
Definition hal_can.h:170
@ HAL_CAN_FILTER_FIFO12
Definition hal_can.h:165
@ HAL_CAN_FILTER_FIFO2
Definition hal_can.h:155
@ HAL_CAN_FILTER_FIFO3
Definition hal_can.h:156
@ HAL_CAN_FILTER_FIFO5
Definition hal_can.h:158
@ HAL_CAN_FILTER_FIFO20
Definition hal_can.h:173
@ HAL_CAN_FILTER_FIFO22
Definition hal_can.h:175
@ HAL_CAN_FILTER_FIFO11
Definition hal_can.h:164
@ HAL_CAN_FILTER_FIFO28
Definition hal_can.h:181
@ HAL_CAN_FILTER_FIFO0
Definition hal_can.h:153
hal_can_frame_format_t
Definition hal_can.h:116
@ HAL_CAN_FRAME_FORMAT_STANDARD_11BITS
Definition hal_can.h:117
@ HAL_CAN_FRAME_FORMAT_EXTENDED_29BITS
Definition hal_can.h:118
hal_can_filter_scale_t
Definition hal_can.h:143
@ HAL_CAN_FILTER_SCALE_32BIT
Definition hal_can.h:145
@ HAL_CAN_FILTER_SCALE_16BIT
Definition hal_can.h:144
hal_can_mode_t
Definition hal_can.h:82
@ HAL_CAN_MODE_STOP
Definition hal_can.h:93
@ HAL_CAN_MODE_LISTENALL
Definition hal_can.h:96
@ HAL_CAN_MODE_DOZE
Definition hal_can.h:92
@ HAL_CAN_MODE_LOOPBACK
Definition hal_can.h:85
@ HAL_CAN_MODE_CONFIGURATION
Definition hal_can.h:98
@ HAL_CAN_MODE_DISABLE
Definition hal_can.h:86
@ HAL_CAN_MODE_NORMAL
Definition hal_can.h:84
@ HAL_CAN_MODE_FREEZE
Definition hal_can.h:94
@ HAL_CAN_MODE_LOOPBACK_SILENT
Definition hal_can.h:89
@ HAL_CAN_MODE_LISTENONLY
Definition hal_can.h:91
@ HAL_CAN_MODE_SILENT
Definition hal_can.h:88
HAL target macros and typedefs.
int32_t err_t
Definition hal_target.h:64
hal_ll_pin_name_t hal_pin_name_t
Definition hal_target.h:60
CAN HAL init configuration structure.
Definition hal_can.h:336
hal_pin_name_t tx_pin
Definition hal_can.h:337
hal_pin_name_t rx_pin
Definition hal_can.h:338
hal_can_mode_t mode
Definition hal_can.h:339
uint32_t frequency
Definition hal_can.h:340
CAN HAL filter init configuration structure.
Definition hal_can.h:287
uint32_t can_filter_id
Definition hal_can.h:293
hal_can_filter_scale_t can_filter_scale
Definition hal_can.h:306
uint16_t can_filter_id_low
Definition hal_can.h:290
hal_can_filter_mode_t can_filter_mode
Definition hal_can.h:305
hal_can_filter_fifo_t can_filter_fifo
Definition hal_can.h:307
uint16_t can_filter_mask_id_low
Definition hal_can.h:297
uint32_t can_filter_mask_id
Definition hal_can.h:300
uint16_t can_filter_id_high
Definition hal_can.h:291
hal_can_filter_activation_t can_filter_enable
Definition hal_can.h:304
uint16_t can_filter_mask_id_high
Definition hal_can.h:298
uint8_t can_filter_bank
Definition hal_can.h:302
Definition hal_can.h:61
bool init_state
Definition hal_can.h:64
handle_t * hal_can_handle
Definition hal_can.h:62
handle_t * drv_can_handle
Definition hal_can.h:63
CAN HAL message structure.
Definition hal_can.h:372
uint16_t std_id
Definition hal_can.h:375
uint8_t data_len
Definition hal_can.h:382
uint16_t ext_id
Definition hal_can.h:376
hal_can_frame_format_t frame_format
Definition hal_can.h:380
hal_can_frame_type_t frame_type
Definition hal_can.h:381
CAN HAL receive message structure.
Definition hal_can.h:414
CAN HAL context structure.
Definition hal_can.h:354
handle_t handle
Definition hal_can.h:355
hal_can_filter_config_t filter_config
Definition hal_can.h:357
hal_can_config_t config
Definition hal_can.h:356
CAN HAL transmit message structure.
Definition hal_can.h:398