1 // Copyright 2015-2019 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 hal/can_types.h is deprecated, please use hal/twai_types.h instead 22 23 #include "hal/twai_types.h" 24 25 /* ---------------------------- Compatibility ------------------------------- */ 26 27 #define CAN_EXTD_ID_MASK TWAI_EXTD_ID_MASK 28 #define CAN_STD_ID_MASK TWAI_STD_ID_MASK 29 #define CAN_FRAME_MAX_DLC TWAI_FRAME_MAX_DLC 30 #define CAN_FRAME_EXTD_ID_LEN_BYTES TWAI_FRAME_EXTD_ID_LEN_BYTES 31 #define CAN_FRAME_STD_ID_LEN_BYTES TWAI_FRAME_STD_ID_LEN_BYTES 32 #define CAN_ERR_PASS_THRESH TWAI_ERR_PASS_THRESH 33 34 #define CAN_MSG_FLAG_NONE TWAI_MSG_FLAG_NONE 35 #define CAN_MSG_FLAG_EXTD TWAI_MSG_FLAG_EXTD 36 #define CAN_MSG_FLAG_RTR TWAI_MSG_FLAG_RTR 37 #define CAN_MSG_FLAG_SS TWAI_MSG_FLAG_SS 38 #define CAN_MSG_FLAG_SELF TWAI_MSG_FLAG_SELF 39 #define CAN_MSG_FLAG_DLC_NON_COMP TWAI_MSG_FLAG_DLC_NON_COMP 40 41 #if (SOC_TWAI_BRP_MAX > 128) || (CONFIG_ESP32_REV_MIN >= 2) 42 #define CAN_TIMING_CONFIG_12_5KBITS() TWAI_TIMING_CONFIG_12_5KBITS() 43 #define CAN_TIMING_CONFIG_16KBITS() TWAI_TIMING_CONFIG_16KBITS() 44 #define CAN_TIMING_CONFIG_20KBITS() TWAI_TIMING_CONFIG_20KBITS() 45 #endif 46 #define CAN_TIMING_CONFIG_25KBITS() TWAI_TIMING_CONFIG_25KBITS() 47 #define CAN_TIMING_CONFIG_50KBITS() TWAI_TIMING_CONFIG_50KBITS() 48 #define CAN_TIMING_CONFIG_100KBITS() TWAI_TIMING_CONFIG_100KBITS() 49 #define CAN_TIMING_CONFIG_125KBITS() TWAI_TIMING_CONFIG_125KBITS() 50 #define CAN_TIMING_CONFIG_250KBITS() TWAI_TIMING_CONFIG_250KBITS() 51 #define CAN_TIMING_CONFIG_500KBITS() TWAI_TIMING_CONFIG_500KBITS() 52 #define CAN_TIMING_CONFIG_800KBITS() TWAI_TIMING_CONFIG_800KBITS() 53 #define CAN_TIMING_CONFIG_1MBITS() TWAI_TIMING_CONFIG_1MBITS() 54 55 #define CAN_FILTER_CONFIG_ACCEPT_ALL() TWAI_FILTER_CONFIG_ACCEPT_ALL() 56 57 typedef twai_mode_t can_mode_t; 58 #define CAN_MODE_NORMAL TWAI_MODE_NORMAL 59 #define CAN_MODE_NO_ACK TWAI_MODE_NO_ACK 60 #define CAN_MODE_LISTEN_ONLY TWAI_MODE_LISTEN_ONLY 61 62 typedef twai_message_t can_message_t; 63 typedef twai_timing_config_t can_timing_config_t; 64 typedef twai_filter_config_t can_filter_config_t; 65 66 #ifdef __cplusplus 67 } 68 #endif 69