• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #warning driver/can.h is deprecated, please use driver/twai.h instead
22 
23 #include "hal/can_types.h"
24 #include "driver/twai.h"
25 
26 /* ---------------------------- Compatibility ------------------------------- */
27 
28 #define CAN_GENERAL_CONFIG_DEFAULT(tx_io_num, rx_io_num, op_mode)   TWAI_GENERAL_CONFIG_DEFAULT(tx_io_num, rx_io_num, op_mode)
29 
30 #define CAN_ALERT_TX_IDLE               TWAI_ALERT_TX_IDLE
31 #define CAN_ALERT_TX_SUCCESS            TWAI_ALERT_TX_SUCCESS
32 #define CAN_ALERT_BELOW_ERR_WARN        TWAI_ALERT_BELOW_ERR_WARN
33 #define CAN_ALERT_ERR_ACTIVE            TWAI_ALERT_ERR_ACTIVE
34 #define CAN_ALERT_RECOVERY_IN_PROGRESS  TWAI_ALERT_RECOVERY_IN_PROGRESS
35 #define CAN_ALERT_BUS_RECOVERED         TWAI_ALERT_BUS_RECOVERED
36 #define CAN_ALERT_ARB_LOST              TWAI_ALERT_ARB_LOST
37 #define CAN_ALERT_ABOVE_ERR_WARN        TWAI_ALERT_ABOVE_ERR_WARN
38 #define CAN_ALERT_BUS_ERROR             TWAI_ALERT_BUS_ERROR
39 #define CAN_ALERT_TX_FAILED             TWAI_ALERT_TX_FAILED
40 #define CAN_ALERT_RX_QUEUE_FULL         TWAI_ALERT_RX_QUEUE_FULL
41 #define CAN_ALERT_ERR_PASS              TWAI_ALERT_ERR_PASS
42 #define CAN_ALERT_BUS_OFF               TWAI_ALERT_BUS_OFF
43 #define CAN_ALERT_ALL                   TWAI_ALERT_ALL
44 #define CAN_ALERT_NONE                  TWAI_ALERT_NONE
45 #define CAN_ALERT_AND_LOG               TWAI_ALERT_AND_LOG
46 
47 #define CAN_IO_UNUSED                   TWAI_IO_UNUSED
48 
49 #define CAN_STATE_STOPPED               TWAI_STATE_STOPPED
50 #define CAN_STATE_RUNNING               TWAI_STATE_RUNNING
51 #define CAN_STATE_BUS_OFF               TWAI_STATE_BUS_OFF
52 #define CAN_STATE_RECOVERING            TWAI_STATE_RECOVERING
53 
54 typedef twai_state_t                    can_state_t;
55 typedef twai_general_config_t           can_general_config_t;
56 typedef twai_status_info_t              can_status_info_t;
57 
58 
59 #define can_driver_install(g_config, t_config, f_config)        twai_driver_install(g_config, t_config, f_config)
60 #define can_driver_uninstall()                                  twai_driver_uninstall()
61 #define can_start()                                             twai_start()
62 #define can_stop()                                              twai_stop()
63 #define can_transmit(message, ticks_to_wait)                    twai_transmit(message, ticks_to_wait)
64 #define can_receive(message, ticks_to_wait)                     twai_receive(message, ticks_to_wait)
65 #define can_read_alerts(alerts, ticks_to_wait)                  twai_read_alerts(alerts, ticks_to_wait)
66 #define can_reconfigure_alerts(alerts_enabled, current_alerts)  twai_reconfigure_alerts(alerts_enabled, current_alerts)
67 #define can_initiate_recovery()                                 twai_initiate_recovery()
68 #define can_get_status_info(status_info)                        twai_get_status_info(status_info)
69 #define can_clear_transmit_queue()                              twai_clear_transmit_queue()
70 #define can_clear_receive_queue()                               twai_clear_receive_queue()
71 
72 #ifdef __cplusplus
73 }
74 #endif
75