library for C++ CANOpen implementation. mbed independant, but is easy to attach into with mbed.

Dependents:   ppCANOpen_Example DISCO-F746NG_rtos_test

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ObjectDictionary.h Source File

ObjectDictionary.h

Go to the documentation of this file.
00001 /**
00002  ******************************************************************************
00003  * @file
00004  * @author  Paul Paterson
00005  * @version
00006  * @date    2015-12-14
00007  * @brief   CANOpen implementation library
00008  ******************************************************************************
00009  * @attention
00010  *
00011  * <h2><center>&copy; COPYRIGHT(c) 2015 Paul Paterson
00012  *
00013  * All rights reserved.
00014 
00015  This program is free software: you can redistribute it and/or modify
00016  it under the terms of the GNU General Public License as published by
00017  the Free Software Foundation, either version 3 of the License, or
00018  (at your option) any later version.
00019 
00020  This program is distributed in the hope that it will be useful,
00021  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  GNU General Public License for more details.
00024 
00025  You should have received a copy of the GNU General Public License
00026  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00027  */
00028 
00029 #ifndef PPCAN_OBJECT_DICTIONARY_H
00030 #define PPCAN_OBJECT_DICTIONARY_H
00031 
00032 #include <stdint.h>
00033 
00034 namespace ppCANOpen
00035 {
00036 
00037 /** Data Type alias to provide context when defining the object library */
00038 typedef uint8_t DataType;
00039 
00040 /** Data Property alias to provide context when defining the object library */
00041 typedef uint8_t DataProperty;
00042 
00043 /** defines the data in a single entry of data (subindex)
00044  */
00045 struct EntryData
00046 {
00047     /* Data value type constants ----------------------------------------------
00048      * Taken from the CANOpen Standard.  they are part of the object dictionary
00049      * at indices 0x0001 to 0x0023.  Given to every Sub Index.
00050      */
00051      
00052     static const DataType TYPE_BOOLEAN                     = 0x01;
00053     static const DataType TYPE_INT8                        = 0x02;
00054     static const DataType TYPE_INT16                       = 0x03;
00055     static const DataType TYPE_INT32                       = 0x04;
00056     static const DataType TYPE_UINT8                       = 0x05;
00057     static const DataType TYPE_UINT16                      = 0x06;
00058     static const DataType TYPE_UINT32                      = 0x07;
00059     static const DataType TYPE_REAL32                      = 0x08;
00060     static const DataType TYPE_VISIBLE_STRING              = 0x09;
00061     static const DataType TYPE_OCTET_STRING                = 0x0A;
00062     static const DataType TYPE_UNICODE_STRING              = 0x0B;
00063     static const DataType TYPE_TIME_OF_DAY                 = 0x0C;
00064     static const DataType TYPE_TIME_DIFFERENCE             = 0x0D;
00065     /* RESERVED */
00066     static const DataType TYPE_DOMAIN                      = 0x0F;
00067     static const DataType TYPE_INT24                       = 0x10;
00068     static const DataType TYPE_REAL64                      = 0x11;
00069     static const DataType TYPE_INT40                       = 0x12;
00070     static const DataType TYPE_INT48                       = 0x13;
00071     static const DataType TYPE_INT56                       = 0x14;
00072     static const DataType TYPE_INT64                       = 0x15;
00073     static const DataType TYPE_UINT24                      = 0x16;
00074     /* RESERVED */
00075     static const DataType TYPE_UINT40                      = 0x18;
00076     static const DataType TYPE_UINT48                      = 0x19;
00077     static const DataType TYPE_UINT56                      = 0x1A;
00078     static const DataType TYPE_UINT64                      = 0x1B;
00079     /* RESERVED */
00080     static const DataType TYPE_PDO_COMMUNICATION_PARAMETER = 0x20;
00081     static const DataType TYPE_PDO_MAPPING                 = 0x21;
00082     static const DataType TYPE_SDO_COMMUNICATION_PARAMETER = 0x22;
00083     static const DataType TYPE_IDENTITY                    = 0x23;
00084 
00085 
00086     /* Data properties constants ----------------------------------------------  
00087      * Read/Write priveledges, save on powerdown, etc.
00088      * Can be strung together into a mask.
00089      */
00090      
00091     static const DataProperty PROPERTY_READABLE         = 0x01;
00092     static const DataProperty PROPERTY_WRITEABLE        = 0x02;
00093     static const DataProperty PROPERTY_READ_WRITEABLE   = 0x03;
00094     /* static const uint8_t PROPERTY_STATIC                = 0x04 *//* possible to save setting after powerdown */
00095     
00096     /* EntryData data --------------------------------------------------------
00097      */
00098     
00099     void           *pData;
00100     uint16_t        size;
00101     DataType        type;
00102     DataProperty    properties;
00103     
00104     EntryData(){}
00105     
00106     EntryData(void *d, uint16_t s, DataType t, DataProperty p)
00107     : pData(d), size(s), type(t), properties(p)
00108     {}
00109 };
00110 
00111 
00112 /** Index alias to provide context when defining the object library */
00113 typedef uint16_t IndexSize;
00114 
00115 /** Sub-Index alias to provide context when defining the object library */
00116 typedef uint8_t SubIndexSize;
00117 
00118 /** defines the data for a single index, including an array of subindices
00119  */
00120 struct ObjectData
00121 {                
00122     EntryData       *entries;
00123     IndexSize        index;
00124     SubIndexSize     entryCount;
00125     
00126     ObjectData(){}
00127     
00128     ObjectData(EntryData *e, IndexSize i, SubIndexSize c)
00129     : entries(e), index(i), entryCount(c)
00130     {}
00131 };
00132 
00133 } /* namespace ppCANOpen */
00134 
00135 #endif // PPCAN_OBJECT_DICTIONARY_H