/***************************************************************************** * Copyright (C) 2016, Huada Semiconductor Co., Ltd All rights reserved. * * This software is owned and published by: * Huada Semiconductor Co.,Ltd ("HDSC"). * * BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND * BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. * * This software contains source code for use with HDSC * components. This software is licensed by HDSC to be adapted only * for use in systems utilizing HDSC components. HDSC shall not be * responsible for misuse or illegal use of this software for devices not * supported herein. HDSC is providing this software "AS IS" and will * not be responsible for issues arising from incorrect user implementation * of the software. * * Disclaimer: * HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, * REGARDING THE SOFTWARE (INCLUDING ANY ACCOMPANYING WRITTEN MATERIALS), * ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, * WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED * WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED * WARRANTY OF NONINFRINGEMENT. * HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, * NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, * LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR * INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, * SAVINGS OR PROFITS, * EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR * INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED * FROM, THE SOFTWARE. * * This software may be replicated in part or whole for the licensed use, * with the restriction that this Disclaimer and Copyright notice must be * included with each copy of this software, whether used in part or whole, * at all times. */ /******************************************************************************/ /** \file can.h ** ** A detailed description is available at ** @link CanGroup CAN description @endlink ** ** - 2018-11-27 1.0 Lux First version for Device Driver Library of CAN ** ******************************************************************************/ #ifndef __CAN_H__ #define __CAN_H__ /******************************************************************************* * Include files ******************************************************************************/ #include "ddl.h" /* C binding of definitions if building with C++ compiler */ #ifdef __cplusplus extern "C" { #endif /** ******************************************************************************* ** \defgroup CanGroup Controller Area Network(CAN) ** ******************************************************************************/ //@{ /******************************************************************************* * Global type definitions ('typedef') ******************************************************************************/ /** ******************************************************************************* ** \brief CAN 错误类型. ******************************************************************************/ typedef enum { NO_ERROR = 0U, ///< 无错误 BIT_ERROR = 1U, ///< 位错误 FORM_ERROR = 2U, ///< 形式错误 STUFF_ERROR = 3U, ///< 填充错误 ACK_ERROR = 4U, ///< 应答错误 CRC_ERROR = 5U, ///< CRC错误 UNKOWN_ERROR = 6U, ///< 未知错误 }en_can_error_t; /** ******************************************************************************* ** \brief CAN传输缓冲器选择. (TCMD) ******************************************************************************/ typedef enum { CanPTBSel = 0U, ///< 主缓冲器选择 CanSTBSel = 1U, ///< 副缓冲器选择 }en_can_buffer_sel_t; /** ******************************************************************************* ** \brief CAN 警告限定.(AFWL) ******************************************************************************/ typedef struct stc_can_warning_limit { uint8_t CanWarningLimitVal; ///< 接收缓冲器将满限定 uint8_t CanErrorWarningLimitVal; ///< 错误警告限定 }stc_can_warning_limit_t; /** ******************************************************************************* ** \brief 筛选器类型.(ACF) ******************************************************************************/ typedef enum en_can_acf_format_en { CanStdFrames = 0x02u, ///< 仅接受标准帧 CanExtFrames = 0x03u, ///< 仅接受扩展帧 CanAllFrames = 0x00u, ///< 接收标准帧和扩展帧 }en_can_acf_format_en_t; /** ******************************************************************************* ** \brief 筛选器组使能. (ACFEN) ******************************************************************************/ typedef enum en_can_filter_sel { CanFilterSel1 = 0u, ///< 筛选器组1使能 CanFilterSel2 = 1u, ///< 筛选器组2使能 CanFilterSel3 = 2u, ///< 筛选器组3使能 CanFilterSel4 = 3u, ///< 筛选器组4使能 CanFilterSel5 = 4u, ///< 筛选器组5使能 CanFilterSel6 = 5u, ///< 筛选器组6使能 CanFilterSel7 = 6u, ///< 筛选器组7使能 CanFilterSel8 = 7u, ///< 筛选器组8使能 }en_can_filter_sel_t; /** ******************************************************************************* ** \brief CAN 收发中断使能.(IE) ******************************************************************************/ typedef enum { //<