Can_open_masternode

Dependencies:   mbed

Committer:
sam_grove
Date:
Wed Sep 26 05:39:07 2012 +0000
Revision:
6:ec29c552a054
Parent:
0:9dd7c6129683
Some lingering changes that I dont remember... er

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 6:ec29c552a054 1 /*
sam_grove 6:ec29c552a054 2 This file is part of CanFestival, a library implementing CanOpen Stack.
sam_grove 6:ec29c552a054 3
sam_grove 6:ec29c552a054 4 Copyright (C): Edouard TISSERANT and Francis DUPIN
sam_grove 6:ec29c552a054 5
sam_grove 6:ec29c552a054 6 See COPYING file for copyrights details.
sam_grove 6:ec29c552a054 7
sam_grove 6:ec29c552a054 8 This library is free software; you can redistribute it and/or
sam_grove 6:ec29c552a054 9 modify it under the terms of the GNU Lesser General Public
sam_grove 6:ec29c552a054 10 License as published by the Free Software Foundation; either
sam_grove 6:ec29c552a054 11 version 2.1 of the License, or (at your option) any later version.
sam_grove 6:ec29c552a054 12
sam_grove 6:ec29c552a054 13 This library is distributed in the hope that it will be useful,
sam_grove 6:ec29c552a054 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
sam_grove 6:ec29c552a054 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
sam_grove 6:ec29c552a054 16 Lesser General Public License for more details.
sam_grove 6:ec29c552a054 17
sam_grove 6:ec29c552a054 18 You should have received a copy of the GNU Lesser General Public
sam_grove 6:ec29c552a054 19 License along with this library; if not, write to the Free Software
sam_grove 6:ec29c552a054 20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
sam_grove 6:ec29c552a054 21 */
sam_grove 6:ec29c552a054 22
sam_grove 6:ec29c552a054 23 #ifndef __can_driver_h__
sam_grove 6:ec29c552a054 24 #define __can_driver_h__
sam_grove 6:ec29c552a054 25
sam_grove 6:ec29c552a054 26 struct struct_s_BOARD;
sam_grove 6:ec29c552a054 27
sam_grove 6:ec29c552a054 28 typedef struct struct_s_BOARD s_BOARD;
sam_grove 6:ec29c552a054 29
sam_grove 6:ec29c552a054 30 #include "applicfg.h"
sam_grove 6:ec29c552a054 31 #include "canopen_can.h"
sam_grove 6:ec29c552a054 32
sam_grove 6:ec29c552a054 33 /**
sam_grove 6:ec29c552a054 34 * @brief The CAN board configuration
sam_grove 6:ec29c552a054 35 * @ingroup can
sam_grove 6:ec29c552a054 36 */
sam_grove 6:ec29c552a054 37
sam_grove 6:ec29c552a054 38 //struct struct_s_BOARD {
sam_grove 6:ec29c552a054 39 // char busname[100]; /**< The bus name on which the CAN board is connected */
sam_grove 6:ec29c552a054 40 // char baudrate[4]; /**< The board baudrate */
sam_grove 6:ec29c552a054 41 //};
sam_grove 6:ec29c552a054 42
sam_grove 6:ec29c552a054 43 struct struct_s_BOARD {
sam_grove 6:ec29c552a054 44 char * busname; /**< The bus name on which the CAN board is connected */
sam_grove 6:ec29c552a054 45 char * baudrate; /**< The board baudrate */
sam_grove 6:ec29c552a054 46 };
sam_grove 6:ec29c552a054 47
sam_grove 6:ec29c552a054 48 #ifndef DLL_CALL
sam_grove 6:ec29c552a054 49 #if !defined(WIN32) || defined(__CYGWIN__)
sam_grove 6:ec29c552a054 50 #define DLL_CALL(funcname) funcname##_driver
sam_grove 6:ec29c552a054 51 #else
sam_grove 6:ec29c552a054 52 //Windows was missing the definition of the calling convention
sam_grove 6:ec29c552a054 53 #define DLL_CALL(funcname) __stdcall funcname##_driver
sam_grove 6:ec29c552a054 54 #endif
sam_grove 6:ec29c552a054 55 #endif //DLL_CALL
sam_grove 6:ec29c552a054 56
sam_grove 6:ec29c552a054 57 #ifndef FCT_PTR_INIT
sam_grove 6:ec29c552a054 58 #define FCT_PTR_INIT
sam_grove 6:ec29c552a054 59 #endif
sam_grove 6:ec29c552a054 60
sam_grove 6:ec29c552a054 61
sam_grove 6:ec29c552a054 62 UNS8 DLL_CALL(canReceive)(CAN_HANDLE, Message *)FCT_PTR_INIT;
sam_grove 6:ec29c552a054 63 UNS8 DLL_CALL(canSend)(CAN_HANDLE, Message const *)FCT_PTR_INIT;
sam_grove 6:ec29c552a054 64 CAN_HANDLE DLL_CALL(canOpen)(s_BOARD *)FCT_PTR_INIT;
sam_grove 6:ec29c552a054 65 int DLL_CALL(canClose)(CAN_HANDLE)FCT_PTR_INIT;
sam_grove 6:ec29c552a054 66 UNS8 DLL_CALL(canChangeBaudRate)(CAN_HANDLE, char *)FCT_PTR_INIT;
sam_grove 6:ec29c552a054 67
sam_grove 6:ec29c552a054 68 #if defined DEBUG_MSG_CONSOLE_ON || defined NEED_PRINT_MESSAGE
sam_grove 6:ec29c552a054 69 #include "def.h"
sam_grove 6:ec29c552a054 70
sam_grove 6:ec29c552a054 71 #define _P(fc) case fc: MSG(#fc" ");break;
sam_grove 6:ec29c552a054 72
sam_grove 6:ec29c552a054 73 static inline void print_message(Message const *m)
sam_grove 6:ec29c552a054 74 {
sam_grove 6:ec29c552a054 75 int i;
sam_grove 6:ec29c552a054 76 UNS8 fc;
sam_grove 6:ec29c552a054 77 MSG("id:%02x ", m->cob_id & 0x7F);
sam_grove 6:ec29c552a054 78 fc = m->cob_id >> 7;
sam_grove 6:ec29c552a054 79 switch(fc)
sam_grove 6:ec29c552a054 80 {
sam_grove 6:ec29c552a054 81 case SYNC:
sam_grove 6:ec29c552a054 82 if(m->cob_id == 0x080)
sam_grove 6:ec29c552a054 83 MSG("SYNC ");
sam_grove 6:ec29c552a054 84 else
sam_grove 6:ec29c552a054 85 MSG("EMCY ");
sam_grove 6:ec29c552a054 86 break;
sam_grove 6:ec29c552a054 87 #ifdef CO_ENABLE_LSS
sam_grove 6:ec29c552a054 88 case LSS:
sam_grove 6:ec29c552a054 89 if(m->cob_id == 0x7E5)
sam_grove 6:ec29c552a054 90 MSG("MLSS ");
sam_grove 6:ec29c552a054 91 else
sam_grove 6:ec29c552a054 92 MSG("SLSS ");
sam_grove 6:ec29c552a054 93 break;
sam_grove 6:ec29c552a054 94 #endif
sam_grove 6:ec29c552a054 95 _P(TIME_STAMP)
sam_grove 6:ec29c552a054 96 _P(PDO1tx)
sam_grove 6:ec29c552a054 97 _P(PDO1rx)
sam_grove 6:ec29c552a054 98 _P(PDO2tx)
sam_grove 6:ec29c552a054 99 _P(PDO2rx)
sam_grove 6:ec29c552a054 100 _P(PDO3tx)
sam_grove 6:ec29c552a054 101 _P(PDO3rx)
sam_grove 6:ec29c552a054 102 _P(PDO4tx)
sam_grove 6:ec29c552a054 103 _P(PDO4rx)
sam_grove 6:ec29c552a054 104 _P(SDOtx)
sam_grove 6:ec29c552a054 105 _P(SDOrx)
sam_grove 6:ec29c552a054 106 _P(NODE_GUARD)
sam_grove 6:ec29c552a054 107 _P(NMT)
sam_grove 6:ec29c552a054 108 }
sam_grove 6:ec29c552a054 109 if( fc == SDOtx)
sam_grove 6:ec29c552a054 110 {
sam_grove 6:ec29c552a054 111 switch(m->data[0] >> 5)
sam_grove 6:ec29c552a054 112 {
sam_grove 6:ec29c552a054 113 /* scs: server command specifier */
sam_grove 6:ec29c552a054 114 _P(UPLOAD_SEGMENT_RESPONSE)
sam_grove 6:ec29c552a054 115 _P(DOWNLOAD_SEGMENT_RESPONSE)
sam_grove 6:ec29c552a054 116 _P(INITIATE_DOWNLOAD_RESPONSE)
sam_grove 6:ec29c552a054 117 _P(INITIATE_UPLOAD_RESPONSE)
sam_grove 6:ec29c552a054 118 _P(ABORT_TRANSFER_REQUEST)
sam_grove 6:ec29c552a054 119 }
sam_grove 6:ec29c552a054 120 }else if( fc == SDOrx)
sam_grove 6:ec29c552a054 121 {
sam_grove 6:ec29c552a054 122 switch(m->data[0] >> 5)
sam_grove 6:ec29c552a054 123 {
sam_grove 6:ec29c552a054 124 /* ccs: client command specifier */
sam_grove 6:ec29c552a054 125 _P(DOWNLOAD_SEGMENT_REQUEST)
sam_grove 6:ec29c552a054 126 _P(INITIATE_DOWNLOAD_REQUEST)
sam_grove 6:ec29c552a054 127 _P(INITIATE_UPLOAD_REQUEST)
sam_grove 6:ec29c552a054 128 _P(UPLOAD_SEGMENT_REQUEST)
sam_grove 6:ec29c552a054 129 _P(ABORT_TRANSFER_REQUEST)
sam_grove 6:ec29c552a054 130 }
sam_grove 6:ec29c552a054 131 }
sam_grove 6:ec29c552a054 132 MSG(" rtr:%d", m->rtr);
sam_grove 6:ec29c552a054 133 MSG(" len:%d", m->len);
sam_grove 6:ec29c552a054 134 for (i = 0 ; i < m->len ; i++)
sam_grove 6:ec29c552a054 135 MSG(" %02x", m->data[i]);
sam_grove 6:ec29c552a054 136 MSG("\n");
sam_grove 6:ec29c552a054 137 }
sam_grove 6:ec29c552a054 138
sam_grove 6:ec29c552a054 139 #endif
sam_grove 6:ec29c552a054 140
sam_grove 6:ec29c552a054 141 #endif