mikroSDK Reference Manual
drv_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 _DRV_CAN_H_
45#define _DRV_CAN_H_
46
47#ifdef __cplusplus
48extern "C"{
49#endif
50
51#include "drv_name.h"
52#include "hal_can.h"
53
57typedef enum
58{
60 CAN_ERROR = (-1)
62
66typedef enum
67{
68 /* Universal Modes. */
72 /* STM32 and RISC-V Modes. */
75 /* NXP Modes. */
80 /* dsPIC Modes.*/
82 /* PIC/PIC32 Modes. */
85
96
105
114
123
132
171
180
294
327
344
356typedef struct
357{
358 union {
359 struct {
360 uint16_t std_id;
361 uint16_t ext_id;
362 };
363 uint32_t id;
364 };
367 uint8_t data_len;
368 uint8_t message_data[8];
370
382typedef struct
383{
384 can_message_t message; /* CAN message structure. */
386
398typedef struct
399{
400 can_message_t message; /* CAN message structure. */
401 uint8_t rx_fifo_number; /* Receive FIFO number. */
403
452
487
524
549
580
606err_t can_set_frequency( can_t *obj, uint32_t frequency );
607
629
656
678
726
747
781
807
808 // drvcangroup
809 // drvgroup
810 // pergroup
811
812#ifdef __cplusplus
813}
814#endif
815
816#endif // _DRV_CAN_H_
817// ------------------------------------------------------------------------- END
can_filter_fifo_t
Definition drv_can.h:137
@ CAN_FILTER_FIFO29
Definition drv_can.h:167
@ CAN_FILTER_FIFO25
Definition drv_can.h:163
@ CAN_FILTER_FIFO10
Definition drv_can.h:148
@ CAN_FILTER_FIFO20
Definition drv_can.h:158
@ CAN_FILTER_FIFO15
Definition drv_can.h:153
@ CAN_FILTER_FIFO6
Definition drv_can.h:144
@ CAN_FILTER_FIFO28
Definition drv_can.h:166
@ CAN_FILTER_FIFO26
Definition drv_can.h:164
@ CAN_FILTER_FIFO13
Definition drv_can.h:151
@ CAN_FILTER_FIFO14
Definition drv_can.h:152
@ CAN_FILTER_FIFO21
Definition drv_can.h:159
@ CAN_FILTER_FIFO7
Definition drv_can.h:145
@ CAN_FILTER_FIFO24
Definition drv_can.h:162
@ CAN_FILTER_FIFO31
Definition drv_can.h:169
@ CAN_FILTER_FIFO18
Definition drv_can.h:156
@ CAN_FILTER_FIFO3
Definition drv_can.h:141
@ CAN_FILTER_FIFO12
Definition drv_can.h:150
@ CAN_FILTER_FIFO8
Definition drv_can.h:146
@ CAN_FILTER_FIFO11
Definition drv_can.h:149
@ CAN_FILTER_FIFO2
Definition drv_can.h:140
@ CAN_FILTER_FIFO19
Definition drv_can.h:157
@ CAN_FILTER_FIFO5
Definition drv_can.h:143
@ CAN_FILTER_FIFO17
Definition drv_can.h:155
@ CAN_FILTER_FIFO16
Definition drv_can.h:154
@ CAN_FILTER_FIFO23
Definition drv_can.h:161
@ CAN_FILTER_FIFO0
Definition drv_can.h:138
@ CAN_FILTER_FIFO4
Definition drv_can.h:142
@ CAN_FILTER_FIFO9
Definition drv_can.h:147
@ CAN_FILTER_FIFO27
Definition drv_can.h:165
@ CAN_FILTER_FIFO1
Definition drv_can.h:139
@ CAN_FILTER_FIFO30
Definition drv_can.h:168
@ CAN_FILTER_FIFO22
Definition drv_can.h:160
can_filter_activation_t
Definition drv_can.h:176
@ CAN_FILTER_DISABLE
Definition drv_can.h:177
@ CAN_FILTER_ENABLE
Definition drv_can.h:178
can_state_t
Definition drv_can.h:90
@ CAN_STATE_READY
Definition drv_can.h:92
@ CAN_STATE_RESET
Definition drv_can.h:91
@ CAN_STATE_ERROR
Definition drv_can.h:94
@ CAN_STATE_LISTENING
Definition drv_can.h:93
can_filter_scale_t
Definition drv_can.h:128
@ CAN_FILTER_SCALE_32BIT
Definition drv_can.h:130
@ CAN_FILTER_SCALE_16BIT
Definition drv_can.h:129
can_err_t
Definition drv_can.h:58
@ CAN_ERROR
Definition drv_can.h:60
@ CAN_SUCCESS
Definition drv_can.h:59
can_frame_format_t
Definition drv_can.h:101
@ CAN_FRAME_FORMAT_STANDARD_11BITS
Definition drv_can.h:102
@ CAN_FRAME_FORMAT_EXTENDED_29BITS
Definition drv_can.h:103
can_frame_type_t
Definition drv_can.h:110
@ CAN_FRAME_TYPE_DATA
Definition drv_can.h:111
@ CAN_FRAME_TYPE_RTR
Definition drv_can.h:112
can_mode_t
Definition drv_can.h:67
@ CAN_MODE_STOP
Definition drv_can.h:78
@ CAN_MODE_DISABLE
Definition drv_can.h:71
@ CAN_MODE_LISTENONLY
Definition drv_can.h:76
@ CAN_MODE_CONFIGURATION
Definition drv_can.h:83
@ CAN_MODE_NORMAL
Definition drv_can.h:69
@ CAN_MODE_SILENT
Definition drv_can.h:73
@ CAN_MODE_FREEZE
Definition drv_can.h:79
@ CAN_MODE_DOZE
Definition drv_can.h:77
@ CAN_MODE_LOOPBACK_SILENT
Definition drv_can.h:74
@ CAN_MODE_LISTENALL
Definition drv_can.h:81
@ CAN_MODE_LOOPBACK
Definition drv_can.h:70
can_filter_mode_t
Definition drv_can.h:119
@ CAN_FILTER_MODE_IDLIST
Definition drv_can.h:121
@ CAN_FILTER_MODE_IDMASK
Definition drv_can.h:120
Pin and port name type definitions.
hal_pin_name_t pin_name_t
Definition drv_name.h:74
err_t can_set_mode(can_t *obj, can_mode_t mode)
Set CAN module mode.
err_t can_get_frequency(can_t *obj)
Get CAN module frequency.
err_t can_open(can_t *obj, can_config_t *config)
Open the CAN driver object.
err_t can_close(can_t *obj)
Close CAN driver object.
err_t can_receive(can_t *obj, can_receive_message_struct *receive_message)
Get data from the RX FIFO.
void can_filter_configure_default(can_filter_config_t *filter_config)
Configure CAN Driver filter configuration structure.
err_t can_set_frequency(can_t *obj, uint32_t frequency)
Set CAN module frequency.
err_t can_get_mode(can_t *obj)
Get CAN module mode.
err_t can_set_filter(can_t *obj, can_filter_config_t *filter_config)
Initialize CAN module filter.
err_t can_init(can_t *obj)
Initialize CAN module.
void can_transmission_stop(can_t *obj)
Stop transmit operation.
err_t can_transmit(can_t *obj, can_transmit_message_struct *transmit_message)
Transmit data to the first free TX mailbox.
void can_configure_default(can_config_t *config)
Configure CAN Driver configuration structure.
API for CAN HAL level.
int32_t err_t
Definition hal_target.h:64
CAN init configuration structure.
Definition drv_can.h:321
pin_name_t rx_pin
Definition drv_can.h:323
can_mode_t mode
Definition drv_can.h:324
uint32_t frequency
Definition drv_can.h:325
pin_name_t tx_pin
Definition drv_can.h:322
CAN filter init configuration structure.
Definition drv_can.h:272
can_filter_activation_t can_filter_enable
Definition drv_can.h:289
uint8_t can_filter_bank
Definition drv_can.h:287
can_filter_mode_t can_filter_mode
Definition drv_can.h:290
uint16_t can_filter_mask_id_high
Definition drv_can.h:283
uint16_t can_filter_mask_id_low
Definition drv_can.h:282
uint16_t can_filter_id_high
Definition drv_can.h:276
can_filter_scale_t can_filter_scale
Definition drv_can.h:291
can_filter_fifo_t can_filter_fifo
Definition drv_can.h:292
uint32_t can_filter_mask_id
Definition drv_can.h:285
uint16_t can_filter_id_low
Definition drv_can.h:275
uint32_t can_filter_id
Definition drv_can.h:278
CAN driver message structure.
Definition drv_can.h:357
can_frame_type_t frame_type
Definition drv_can.h:366
uint8_t data_len
Definition drv_can.h:367
uint16_t std_id
Definition drv_can.h:360
uint16_t ext_id
Definition drv_can.h:361
can_frame_format_t frame_format
Definition drv_can.h:365
CAN driver receive message structure.
Definition drv_can.h:399
CAN driver context structure.
Definition drv_can.h:339
can_filter_config_t filter_config
Definition drv_can.h:342
handle_t handle
Definition drv_can.h:340
can_config_t config
Definition drv_can.h:341
CAN driver transmit message structure.
Definition drv_can.h:383