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