Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
can_driver.h
00001 /* 00002 This file is part of CanFestival, a library implementing CanOpen Stack. 00003 00004 Copyright (C): Edouard TISSERANT and Francis DUPIN 00005 00006 See COPYING file for copyrights details. 00007 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Lesser General Public 00010 License as published by the Free Software Foundation; either 00011 version 2.1 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Lesser General Public License for more details. 00017 00018 You should have received a copy of the GNU Lesser General Public 00019 License along with this library; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 */ 00022 00023 #ifndef __can_driver_h__ 00024 #define __can_driver_h__ 00025 00026 struct struct_s_BOARD; 00027 00028 typedef struct struct_s_BOARD s_BOARD; 00029 00030 #include "applicfg.h" 00031 #include "can.h" 00032 00033 /** 00034 * @brief The CAN board configuration 00035 * @ingroup can 00036 */ 00037 00038 //struct struct_s_BOARD { 00039 // char busname[100]; /**< The bus name on which the CAN board is connected */ 00040 // char baudrate[4]; /**< The board baudrate */ 00041 //}; 00042 00043 struct struct_s_BOARD { 00044 char * busname; /**< The bus name on which the CAN board is connected */ 00045 char * baudrate; /**< The board baudrate */ 00046 }; 00047 00048 #ifndef DLL_CALL 00049 #if !defined(WIN32) || defined(__CYGWIN__) 00050 #define DLL_CALL(funcname) funcname##_driver 00051 #else 00052 //Windows was missing the definition of the calling convention 00053 #define DLL_CALL(funcname) __stdcall funcname##_driver 00054 #endif 00055 #endif //DLL_CALL 00056 00057 #ifndef FCT_PTR_INIT 00058 #define FCT_PTR_INIT 00059 #endif 00060 00061 00062 UNS8 DLL_CALL(canReceive)(CAN_HANDLE, Message *)FCT_PTR_INIT; 00063 UNS8 DLL_CALL(canSend)(CAN_HANDLE, Message const *)FCT_PTR_INIT; 00064 CAN_HANDLE DLL_CALL(canOpen)(s_BOARD *)FCT_PTR_INIT; 00065 int DLL_CALL(canClose)(CAN_HANDLE)FCT_PTR_INIT; 00066 UNS8 DLL_CALL(canChangeBaudRate)(CAN_HANDLE, char *)FCT_PTR_INIT; 00067 00068 #if defined DEBUG_MSG_CONSOLE_ON || defined NEED_PRINT_MESSAGE 00069 #include "def.h" 00070 00071 #define _P(fc) case fc: MSG(#fc" ");break; 00072 00073 static inline void print_message(Message const *m) 00074 { 00075 int i; 00076 UNS8 fc; 00077 MSG("id:%02x ", m->cob_id & 0x7F); 00078 fc = m->cob_id >> 7; 00079 switch(fc) 00080 { 00081 case SYNC: 00082 if(m->cob_id == 0x080) 00083 MSG("SYNC "); 00084 else 00085 MSG("EMCY "); 00086 break; 00087 #ifdef CO_ENABLE_LSS 00088 case LSS: 00089 if(m->cob_id == 0x7E5) 00090 MSG("MLSS "); 00091 else 00092 MSG("SLSS "); 00093 break; 00094 #endif 00095 _P(TIME_STAMP) 00096 _P(PDO1tx) 00097 _P(PDO1rx) 00098 _P(PDO2tx) 00099 _P(PDO2rx) 00100 _P(PDO3tx) 00101 _P(PDO3rx) 00102 _P(PDO4tx) 00103 _P(PDO4rx) 00104 _P(SDOtx) 00105 _P(SDOrx) 00106 _P(NODE_GUARD) 00107 _P(NMT) 00108 } 00109 if( fc == SDOtx) 00110 { 00111 switch(m->data[0] >> 5) 00112 { 00113 /* scs: server command specifier */ 00114 _P(UPLOAD_SEGMENT_RESPONSE) 00115 _P(DOWNLOAD_SEGMENT_RESPONSE) 00116 _P(INITIATE_DOWNLOAD_RESPONSE) 00117 _P(INITIATE_UPLOAD_RESPONSE) 00118 _P(ABORT_TRANSFER_REQUEST) 00119 } 00120 }else if( fc == SDOrx) 00121 { 00122 switch(m->data[0] >> 5) 00123 { 00124 /* ccs: client command specifier */ 00125 _P(DOWNLOAD_SEGMENT_REQUEST) 00126 _P(INITIATE_DOWNLOAD_REQUEST) 00127 _P(INITIATE_UPLOAD_REQUEST) 00128 _P(UPLOAD_SEGMENT_REQUEST) 00129 _P(ABORT_TRANSFER_REQUEST) 00130 } 00131 } 00132 MSG(" rtr:%d", m->rtr); 00133 MSG(" len:%d", m->len); 00134 for (i = 0 ; i < m->len ; i++) 00135 MSG(" %02x", m->data[i]); 00136 MSG("\n"); 00137 } 00138 00139 #endif 00140 00141 #endif
Generated on Tue Jul 12 2022 17:11:51 by
1.7.2