library for C++ CANOpen implementation. mbed independant, but is easy to attach into with mbed.
Dependents: ppCANOpen_Example DISCO-F746NG_rtos_test
Example:
Import programppCANOpen_Example
I am no longer actively working on the ppCANOpen library, however, I want to publish this project so that anyone who wants to pick up any of the pieces can have a good example. This is a a project I was working on using the ppCANOpen library. It has a pretty in deep use of the object dictionary structure. And a number of functions to control high voltage pinball drivers, if you're into that sort of thing.
include/ObjectDictionary.h@5:22a337cdc0e3, 2016-02-13 (annotated)
- Committer:
- ptpaterson
- Date:
- Sat Feb 13 20:22:59 2016 +0000
- Revision:
- 5:22a337cdc0e3
- Parent:
- 4:2034b04c86d2
PDO receive complete
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ptpaterson | 2:c724ff3a4e4d | 1 | /** |
ptpaterson | 2:c724ff3a4e4d | 2 | ****************************************************************************** |
ptpaterson | 2:c724ff3a4e4d | 3 | * @file |
ptpaterson | 2:c724ff3a4e4d | 4 | * @author Paul Paterson |
ptpaterson | 2:c724ff3a4e4d | 5 | * @version |
ptpaterson | 2:c724ff3a4e4d | 6 | * @date 2015-12-14 |
ptpaterson | 2:c724ff3a4e4d | 7 | * @brief CANOpen implementation library |
ptpaterson | 2:c724ff3a4e4d | 8 | ****************************************************************************** |
ptpaterson | 2:c724ff3a4e4d | 9 | * @attention |
ptpaterson | 2:c724ff3a4e4d | 10 | * |
ptpaterson | 2:c724ff3a4e4d | 11 | * <h2><center>© COPYRIGHT(c) 2015 Paul Paterson |
ptpaterson | 2:c724ff3a4e4d | 12 | * |
ptpaterson | 2:c724ff3a4e4d | 13 | * All rights reserved. |
ptpaterson | 2:c724ff3a4e4d | 14 | |
ptpaterson | 2:c724ff3a4e4d | 15 | This program is free software: you can redistribute it and/or modify |
ptpaterson | 2:c724ff3a4e4d | 16 | it under the terms of the GNU General Public License as published by |
ptpaterson | 2:c724ff3a4e4d | 17 | the Free Software Foundation, either version 3 of the License, or |
ptpaterson | 2:c724ff3a4e4d | 18 | (at your option) any later version. |
ptpaterson | 2:c724ff3a4e4d | 19 | |
ptpaterson | 2:c724ff3a4e4d | 20 | This program is distributed in the hope that it will be useful, |
ptpaterson | 2:c724ff3a4e4d | 21 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
ptpaterson | 2:c724ff3a4e4d | 22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ptpaterson | 2:c724ff3a4e4d | 23 | GNU General Public License for more details. |
ptpaterson | 2:c724ff3a4e4d | 24 | |
ptpaterson | 2:c724ff3a4e4d | 25 | You should have received a copy of the GNU General Public License |
ptpaterson | 2:c724ff3a4e4d | 26 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
ptpaterson | 2:c724ff3a4e4d | 27 | */ |
ptpaterson | 2:c724ff3a4e4d | 28 | |
ptpaterson | 2:c724ff3a4e4d | 29 | #ifndef PPCAN_OBJECT_DICTIONARY_H |
ptpaterson | 2:c724ff3a4e4d | 30 | #define PPCAN_OBJECT_DICTIONARY_H |
ptpaterson | 2:c724ff3a4e4d | 31 | |
ptpaterson | 2:c724ff3a4e4d | 32 | #include <stdint.h> |
ptpaterson | 2:c724ff3a4e4d | 33 | |
ptpaterson | 2:c724ff3a4e4d | 34 | namespace ppCANOpen |
ptpaterson | 2:c724ff3a4e4d | 35 | { |
ptpaterson | 2:c724ff3a4e4d | 36 | |
ptpaterson | 5:22a337cdc0e3 | 37 | /** Data Type alias to provide context when defining the object library */ |
ptpaterson | 5:22a337cdc0e3 | 38 | typedef uint8_t DataType; |
ptpaterson | 5:22a337cdc0e3 | 39 | |
ptpaterson | 5:22a337cdc0e3 | 40 | /** Data Property alias to provide context when defining the object library */ |
ptpaterson | 5:22a337cdc0e3 | 41 | typedef uint8_t DataProperty; |
ptpaterson | 5:22a337cdc0e3 | 42 | |
ptpaterson | 5:22a337cdc0e3 | 43 | /** defines the data in a single entry of data (subindex) |
ptpaterson | 5:22a337cdc0e3 | 44 | */ |
ptpaterson | 5:22a337cdc0e3 | 45 | struct EntryData |
ptpaterson | 2:c724ff3a4e4d | 46 | { |
ptpaterson | 2:c724ff3a4e4d | 47 | /* Data value type constants ---------------------------------------------- |
ptpaterson | 2:c724ff3a4e4d | 48 | * Taken from the CANOpen Standard. they are part of the object dictionary |
ptpaterson | 2:c724ff3a4e4d | 49 | * at indices 0x0001 to 0x0023. Given to every Sub Index. |
ptpaterson | 2:c724ff3a4e4d | 50 | */ |
ptpaterson | 2:c724ff3a4e4d | 51 | |
ptpaterson | 2:c724ff3a4e4d | 52 | static const DataType TYPE_BOOLEAN = 0x01; |
ptpaterson | 2:c724ff3a4e4d | 53 | static const DataType TYPE_INT8 = 0x02; |
ptpaterson | 2:c724ff3a4e4d | 54 | static const DataType TYPE_INT16 = 0x03; |
ptpaterson | 2:c724ff3a4e4d | 55 | static const DataType TYPE_INT32 = 0x04; |
ptpaterson | 2:c724ff3a4e4d | 56 | static const DataType TYPE_UINT8 = 0x05; |
ptpaterson | 2:c724ff3a4e4d | 57 | static const DataType TYPE_UINT16 = 0x06; |
ptpaterson | 2:c724ff3a4e4d | 58 | static const DataType TYPE_UINT32 = 0x07; |
ptpaterson | 2:c724ff3a4e4d | 59 | static const DataType TYPE_REAL32 = 0x08; |
ptpaterson | 2:c724ff3a4e4d | 60 | static const DataType TYPE_VISIBLE_STRING = 0x09; |
ptpaterson | 2:c724ff3a4e4d | 61 | static const DataType TYPE_OCTET_STRING = 0x0A; |
ptpaterson | 2:c724ff3a4e4d | 62 | static const DataType TYPE_UNICODE_STRING = 0x0B; |
ptpaterson | 2:c724ff3a4e4d | 63 | static const DataType TYPE_TIME_OF_DAY = 0x0C; |
ptpaterson | 2:c724ff3a4e4d | 64 | static const DataType TYPE_TIME_DIFFERENCE = 0x0D; |
ptpaterson | 2:c724ff3a4e4d | 65 | /* RESERVED */ |
ptpaterson | 2:c724ff3a4e4d | 66 | static const DataType TYPE_DOMAIN = 0x0F; |
ptpaterson | 2:c724ff3a4e4d | 67 | static const DataType TYPE_INT24 = 0x10; |
ptpaterson | 2:c724ff3a4e4d | 68 | static const DataType TYPE_REAL64 = 0x11; |
ptpaterson | 2:c724ff3a4e4d | 69 | static const DataType TYPE_INT40 = 0x12; |
ptpaterson | 2:c724ff3a4e4d | 70 | static const DataType TYPE_INT48 = 0x13; |
ptpaterson | 2:c724ff3a4e4d | 71 | static const DataType TYPE_INT56 = 0x14; |
ptpaterson | 2:c724ff3a4e4d | 72 | static const DataType TYPE_INT64 = 0x15; |
ptpaterson | 2:c724ff3a4e4d | 73 | static const DataType TYPE_UINT24 = 0x16; |
ptpaterson | 2:c724ff3a4e4d | 74 | /* RESERVED */ |
ptpaterson | 2:c724ff3a4e4d | 75 | static const DataType TYPE_UINT40 = 0x18; |
ptpaterson | 2:c724ff3a4e4d | 76 | static const DataType TYPE_UINT48 = 0x19; |
ptpaterson | 2:c724ff3a4e4d | 77 | static const DataType TYPE_UINT56 = 0x1A; |
ptpaterson | 2:c724ff3a4e4d | 78 | static const DataType TYPE_UINT64 = 0x1B; |
ptpaterson | 2:c724ff3a4e4d | 79 | /* RESERVED */ |
ptpaterson | 2:c724ff3a4e4d | 80 | static const DataType TYPE_PDO_COMMUNICATION_PARAMETER = 0x20; |
ptpaterson | 2:c724ff3a4e4d | 81 | static const DataType TYPE_PDO_MAPPING = 0x21; |
ptpaterson | 2:c724ff3a4e4d | 82 | static const DataType TYPE_SDO_COMMUNICATION_PARAMETER = 0x22; |
ptpaterson | 2:c724ff3a4e4d | 83 | static const DataType TYPE_IDENTITY = 0x23; |
ptpaterson | 2:c724ff3a4e4d | 84 | |
ptpaterson | 2:c724ff3a4e4d | 85 | |
ptpaterson | 2:c724ff3a4e4d | 86 | /* Data properties constants ---------------------------------------------- |
ptpaterson | 2:c724ff3a4e4d | 87 | * Read/Write priveledges, save on powerdown, etc. |
ptpaterson | 2:c724ff3a4e4d | 88 | * Can be strung together into a mask. |
ptpaterson | 2:c724ff3a4e4d | 89 | */ |
ptpaterson | 2:c724ff3a4e4d | 90 | |
ptpaterson | 2:c724ff3a4e4d | 91 | static const DataProperty PROPERTY_READABLE = 0x01; |
ptpaterson | 2:c724ff3a4e4d | 92 | static const DataProperty PROPERTY_WRITEABLE = 0x02; |
ptpaterson | 2:c724ff3a4e4d | 93 | static const DataProperty PROPERTY_READ_WRITEABLE = 0x03; |
ptpaterson | 2:c724ff3a4e4d | 94 | /* static const uint8_t PROPERTY_STATIC = 0x04 *//* possible to save setting after powerdown */ |
ptpaterson | 2:c724ff3a4e4d | 95 | |
ptpaterson | 5:22a337cdc0e3 | 96 | /* EntryData data -------------------------------------------------------- |
ptpaterson | 2:c724ff3a4e4d | 97 | */ |
ptpaterson | 5:22a337cdc0e3 | 98 | |
ptpaterson | 5:22a337cdc0e3 | 99 | void *pData; |
ptpaterson | 5:22a337cdc0e3 | 100 | uint16_t size; |
ptpaterson | 5:22a337cdc0e3 | 101 | DataType type; |
ptpaterson | 5:22a337cdc0e3 | 102 | DataProperty properties; |
ptpaterson | 5:22a337cdc0e3 | 103 | |
ptpaterson | 5:22a337cdc0e3 | 104 | EntryData(){} |
ptpaterson | 5:22a337cdc0e3 | 105 | |
ptpaterson | 5:22a337cdc0e3 | 106 | EntryData(void *d, uint16_t s, DataType t, DataProperty p) |
ptpaterson | 5:22a337cdc0e3 | 107 | : pData(d), size(s), type(t), properties(p) |
ptpaterson | 5:22a337cdc0e3 | 108 | {} |
ptpaterson | 5:22a337cdc0e3 | 109 | }; |
ptpaterson | 2:c724ff3a4e4d | 110 | |
ptpaterson | 2:c724ff3a4e4d | 111 | |
ptpaterson | 5:22a337cdc0e3 | 112 | /** Index alias to provide context when defining the object library */ |
ptpaterson | 5:22a337cdc0e3 | 113 | typedef uint16_t IndexSize; |
ptpaterson | 5:22a337cdc0e3 | 114 | |
ptpaterson | 5:22a337cdc0e3 | 115 | /** Sub-Index alias to provide context when defining the object library */ |
ptpaterson | 5:22a337cdc0e3 | 116 | typedef uint8_t SubIndexSize; |
ptpaterson | 5:22a337cdc0e3 | 117 | |
ptpaterson | 5:22a337cdc0e3 | 118 | /** defines the data for a single index, including an array of subindices |
ptpaterson | 5:22a337cdc0e3 | 119 | */ |
ptpaterson | 5:22a337cdc0e3 | 120 | struct ObjectData |
ptpaterson | 5:22a337cdc0e3 | 121 | { |
ptpaterson | 5:22a337cdc0e3 | 122 | EntryData *entries; |
ptpaterson | 5:22a337cdc0e3 | 123 | IndexSize index; |
ptpaterson | 5:22a337cdc0e3 | 124 | SubIndexSize entryCount; |
ptpaterson | 2:c724ff3a4e4d | 125 | |
ptpaterson | 5:22a337cdc0e3 | 126 | ObjectData(){} |
ptpaterson | 2:c724ff3a4e4d | 127 | |
ptpaterson | 5:22a337cdc0e3 | 128 | ObjectData(EntryData *e, IndexSize i, SubIndexSize c) |
ptpaterson | 5:22a337cdc0e3 | 129 | : entries(e), index(i), entryCount(c) |
ptpaterson | 5:22a337cdc0e3 | 130 | {} |
ptpaterson | 2:c724ff3a4e4d | 131 | }; |
ptpaterson | 2:c724ff3a4e4d | 132 | |
ptpaterson | 2:c724ff3a4e4d | 133 | } /* namespace ppCANOpen */ |
ptpaterson | 2:c724ff3a4e4d | 134 | |
ptpaterson | 2:c724ff3a4e4d | 135 | #endif // PPCAN_OBJECT_DICTIONARY_H |