00001 /*This file is prepared for Doxygen automatic documentation generation.*/ 00018 /* Copyright (c) 2009 Atmel Corporation. All rights reserved. 00019 * 00020 * Redistribution and use in source and binary forms, with or without 00021 * modification, are permitted provided that the following conditions are met: 00022 * 00023 * 1. Redistributions of source code must retain the above copyright notice, this 00024 * list of conditions and the following disclaimer. 00025 * 00026 * 2. Redistributions in binary form must reproduce the above copyright notice, 00027 * this list of conditions and the following disclaimer in the documentation 00028 * and/or other materials provided with the distribution. 00029 * 00030 * 3. The name of Atmel may not be used to endorse or promote products derived 00031 * from this software without specific prior written permission. 00032 * 00033 * 4. This software may only be redistributed and used in connection with an Atmel 00034 * AVR product. 00035 * 00036 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 00037 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00038 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 00039 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 00040 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00041 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00042 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00043 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00044 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00045 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 00046 * 00047 */ 00048 #ifndef _CAN_H_ 00049 #define _CAN_H_ 00050 00051 //_____ I N C L U D E S ________________________________________________________ 00052 #include "conf_can.h" 00053 #include "canif.h" 00054 #include "compiler.h" 00055 #include "preprocessor.h" 00056 //_____ D E F I N I T I O N S __________________________________________________ 00057 00058 // ---------- 00060 #define CAN_CMD_REFUSED 0xFF 00061 // ---------- 00063 #define CAN_CMD_ACCEPTED 0x00 00064 // ---------- 00066 #define CAN_STATUS_COMPLETED 0x00 00067 // ---------- 00069 #define CAN_STATUS_NOT_COMPLETED 0x01 00070 // ---------- 00072 #define CAN_STATUS_ERROR 0x02 00073 // ---------- 00075 #define CAN_STATUS_WAKEUP 0x03 00076 // ---------- 00078 #define CAN_STATUS_BUSOFF 0x04 00079 // ---------- 00081 #define CAN_MOB_NOT_ALLOCATED 0xFF 00082 // ---------- 00084 #define CAN_DATA_FRAME 0 00086 #define CAN_REMOTE_FRAME 1 00087 00088 typedef struct{ 00089 U8 handle; 00090 can_msg_t *can_msg; 00091 U8 dlc; 00092 U8 req_type; 00093 U8 status; 00094 }can_mob_t; 00095 //_____ D E C L A R A T I O N S ________________________________________________ 00096 00097 00105 extern U8 can_init( U8 ch, 00106 U32 can_msg_ram_add, 00107 U8 operating_mode, 00108 void (*can_msg_callback) (U8,U8)); 00109 00114 extern U8 can_mob_alloc(U8 ch); 00115 00121 extern U8 can_mob_free(U8 ch,U8 handle); 00122 00131 extern U8 can_tx( U8 ch, 00132 U8 handle, 00133 U8 dlc, 00134 U8 req_type, 00135 const can_msg_t *can_msg); 00136 00144 extern U8 can_rx( U8 ch, 00145 U8 handle, 00146 U8 req_type, 00147 const can_msg_t *can_msg); 00148 00149 00155 extern Union64 can_get_mob_data( U8 ch , 00156 U8 handle); 00157 00163 extern U8 can_get_mob_dlc( U8 ch , 00164 U8 handle); 00165 00171 extern U32 can_get_mob_id( U8 ch , 00172 U8 handle); 00173 00179 extern U8 can_mob_get_status( U8 ch, 00180 U8 handle); 00181 //______________________________________________________________________________ 00182 00183 #endif // _CAN_H_