etisserant@0: /* greg@561: This file is part of CanFestival, a library implementing CanOpen Stack. etisserant@0: etisserant@0: Copyright (C): Edouard TISSERANT and Francis DUPIN etisserant@0: etisserant@0: See COPYING file for copyrights details. etisserant@0: etisserant@0: This library is free software; you can redistribute it and/or etisserant@0: modify it under the terms of the GNU Lesser General Public etisserant@0: License as published by the Free Software Foundation; either etisserant@0: version 2.1 of the License, or (at your option) any later version. etisserant@0: etisserant@0: This library is distributed in the hope that it will be useful, etisserant@0: but WITHOUT ANY WARRANTY; without even the implied warranty of etisserant@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU etisserant@0: Lesser General Public License for more details. etisserant@0: etisserant@0: You should have received a copy of the GNU Lesser General Public etisserant@0: License along with this library; if not, write to the Free Software etisserant@0: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA etisserant@0: */ etisserant@0: etisserant@0: #ifndef __can_driver_h__ etisserant@0: #define __can_driver_h__ etisserant@0: etisserant@0: struct struct_s_BOARD; etisserant@0: etisserant@0: typedef struct struct_s_BOARD s_BOARD; etisserant@0: etisserant@145: #include "applicfg.h" etisserant@0: #include "can.h" etisserant@0: greg@561: /** greg@561: * @brief The CAN board configuration greg@528: * @ingroup can greg@528: */ greg@561: greg@561: //struct struct_s_BOARD { greg@561: // char busname[100]; /**< The bus name on which the CAN board is connected */ greg@561: // char baudrate[4]; /**< The board baudrate */ greg@561: //}; greg@561: etisserant@0: struct struct_s_BOARD { greg@561: char * busname; /**< The bus name on which the CAN board is connected */ greg@561: char * baudrate; /**< The board baudrate */ etisserant@0: }; etisserant@0: etisserant@145: #ifndef DLL_CALL Edouard@774: #if !defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) Edouard@774: #define LIBAPI etisserant@145: #define DLL_CALL(funcname) funcname##_driver edouard@629: #else hacking@728: #define LIBAPI __stdcall edouard@629: //Windows was missing the definition of the calling convention hacking@728: #define DLL_CALL(funcname) LIBAPI funcname##_driver etisserant@0: #endif hacking@644: #endif //DLL_CALL etisserant@145: hacking@728: #define LIBPUBLIC hacking@728: etisserant@145: #ifndef FCT_PTR_INIT etisserant@145: #define FCT_PTR_INIT etisserant@145: #endif etisserant@145: etisserant@145: etisserant@145: UNS8 DLL_CALL(canReceive)(CAN_HANDLE, Message *)FCT_PTR_INIT; edouard@631: UNS8 DLL_CALL(canSend)(CAN_HANDLE, Message const *)FCT_PTR_INIT; etisserant@145: CAN_HANDLE DLL_CALL(canOpen)(s_BOARD *)FCT_PTR_INIT; etisserant@145: int DLL_CALL(canClose)(CAN_HANDLE)FCT_PTR_INIT; groke6@384: UNS8 DLL_CALL(canChangeBaudRate)(CAN_HANDLE, char *)FCT_PTR_INIT; etisserant@145: etisserant@341: #if defined DEBUG_MSG_CONSOLE_ON || defined NEED_PRINT_MESSAGE etisserant@301: #include "def.h" etisserant@301: etisserant@391: #define _P(fc) case fc: MSG(#fc" ");break; etisserant@301: edouard@631: static inline void print_message(Message const *m) etisserant@301: { etisserant@301: int i; luis@319: UNS8 fc; etisserant@391: MSG("id:%02x ", m->cob_id & 0x7F); etisserant@365: fc = m->cob_id >> 7; etisserant@301: switch(fc) etisserant@301: { greg@561: case SYNC: etisserant@365: if(m->cob_id == 0x080) etisserant@391: MSG("SYNC "); etisserant@314: else etisserant@391: MSG("EMCY "); etisserant@314: break; groke6@381: #ifdef CO_ENABLE_LSS groke6@381: case LSS: groke6@381: if(m->cob_id == 0x7E5) etisserant@391: MSG("MLSS "); groke6@381: else etisserant@391: MSG("SLSS "); groke6@381: break; groke6@381: #endif etisserant@301: _P(TIME_STAMP) etisserant@301: _P(PDO1tx) etisserant@301: _P(PDO1rx) etisserant@301: _P(PDO2tx) etisserant@301: _P(PDO2rx) etisserant@301: _P(PDO3tx) etisserant@301: _P(PDO3rx) etisserant@301: _P(PDO4tx) etisserant@301: _P(PDO4rx) etisserant@301: _P(SDOtx) etisserant@301: _P(SDOrx) etisserant@301: _P(NODE_GUARD) etisserant@301: _P(NMT) etisserant@301: } etisserant@301: if( fc == SDOtx) etisserant@301: { etisserant@301: switch(m->data[0] >> 5) etisserant@301: { etisserant@301: /* scs: server command specifier */ etisserant@301: _P(UPLOAD_SEGMENT_RESPONSE) etisserant@301: _P(DOWNLOAD_SEGMENT_RESPONSE) etisserant@301: _P(INITIATE_DOWNLOAD_RESPONSE) etisserant@301: _P(INITIATE_UPLOAD_RESPONSE) etisserant@301: _P(ABORT_TRANSFER_REQUEST) etisserant@301: } etisserant@301: }else if( fc == SDOrx) etisserant@301: { etisserant@301: switch(m->data[0] >> 5) etisserant@301: { etisserant@301: /* ccs: client command specifier */ etisserant@301: _P(DOWNLOAD_SEGMENT_REQUEST) etisserant@301: _P(INITIATE_DOWNLOAD_REQUEST) etisserant@301: _P(INITIATE_UPLOAD_REQUEST) etisserant@301: _P(UPLOAD_SEGMENT_REQUEST) etisserant@301: _P(ABORT_TRANSFER_REQUEST) etisserant@301: } etisserant@301: } etisserant@391: MSG(" rtr:%d", m->rtr); etisserant@391: MSG(" len:%d", m->len); etisserant@301: for (i = 0 ; i < m->len ; i++) etisserant@391: MSG(" %02x", m->data[i]); etisserant@391: MSG("\n"); etisserant@301: } etisserant@301: etisserant@145: #endif etisserant@301: etisserant@301: #endif