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.
Dependencies: CANnucleo mbed ppCANOpen
Application/source/Node_pin0808.cpp@10:ec59d628ebdc, 2016-03-19 (annotated)
- Committer:
- ptpaterson
- Date:
- Sat Mar 19 01:44:35 2016 +0000
- Revision:
- 10:ec59d628ebdc
Final Submission (probs)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ptpaterson | 10:ec59d628ebdc | 1 | /** |
ptpaterson | 10:ec59d628ebdc | 2 | ****************************************************************************** |
ptpaterson | 10:ec59d628ebdc | 3 | * @file |
ptpaterson | 10:ec59d628ebdc | 4 | * @author Paul Paterson |
ptpaterson | 10:ec59d628ebdc | 5 | * @version |
ptpaterson | 10:ec59d628ebdc | 6 | * @date 2015-12-14 |
ptpaterson | 10:ec59d628ebdc | 7 | * @brief CANOpen implementation library |
ptpaterson | 10:ec59d628ebdc | 8 | ****************************************************************************** |
ptpaterson | 10:ec59d628ebdc | 9 | * @attention |
ptpaterson | 10:ec59d628ebdc | 10 | * |
ptpaterson | 10:ec59d628ebdc | 11 | * <h2><center>© COPYRIGHT(c) 2015 Paul Paterson |
ptpaterson | 10:ec59d628ebdc | 12 | * |
ptpaterson | 10:ec59d628ebdc | 13 | * All rights reserved. |
ptpaterson | 10:ec59d628ebdc | 14 | |
ptpaterson | 10:ec59d628ebdc | 15 | This program is free software: you can redistribute it and/or modify |
ptpaterson | 10:ec59d628ebdc | 16 | it under the terms of the GNU General Public License as published by |
ptpaterson | 10:ec59d628ebdc | 17 | the Free Software Foundation, either version 3 of the License, or |
ptpaterson | 10:ec59d628ebdc | 18 | (at your option) any later version. |
ptpaterson | 10:ec59d628ebdc | 19 | |
ptpaterson | 10:ec59d628ebdc | 20 | This program is distributed in the hope that it will be useful, |
ptpaterson | 10:ec59d628ebdc | 21 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
ptpaterson | 10:ec59d628ebdc | 22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ptpaterson | 10:ec59d628ebdc | 23 | GNU General Public License for more details. |
ptpaterson | 10:ec59d628ebdc | 24 | |
ptpaterson | 10:ec59d628ebdc | 25 | You should have received a copy of the GNU General Public License |
ptpaterson | 10:ec59d628ebdc | 26 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
ptpaterson | 10:ec59d628ebdc | 27 | */ |
ptpaterson | 10:ec59d628ebdc | 28 | |
ptpaterson | 10:ec59d628ebdc | 29 | #include "Node_pin0808.h" |
ptpaterson | 10:ec59d628ebdc | 30 | #include "ServiceProvider.h" |
ptpaterson | 10:ec59d628ebdc | 31 | |
ptpaterson | 10:ec59d628ebdc | 32 | #include "stdio.h" |
ptpaterson | 10:ec59d628ebdc | 33 | #include "mbed.h" |
ptpaterson | 10:ec59d628ebdc | 34 | |
ptpaterson | 10:ec59d628ebdc | 35 | PortIn mbedInputs(PortB, 0x00FF); |
ptpaterson | 10:ec59d628ebdc | 36 | PortOut mbedOutputs(PortB, 0xFF00); |
ptpaterson | 10:ec59d628ebdc | 37 | |
ptpaterson | 10:ec59d628ebdc | 38 | namespace ppCANOpen |
ptpaterson | 10:ec59d628ebdc | 39 | { |
ptpaterson | 10:ec59d628ebdc | 40 | |
ptpaterson | 10:ec59d628ebdc | 41 | /****************************************************************************** |
ptpaterson | 10:ec59d628ebdc | 42 | * Constructor/Destructor |
ptpaterson | 10:ec59d628ebdc | 43 | ****************************************************************************** |
ptpaterson | 10:ec59d628ebdc | 44 | */ |
ptpaterson | 10:ec59d628ebdc | 45 | |
ptpaterson | 10:ec59d628ebdc | 46 | Node_pin0808::Node_pin0808 (int id, ServiceProvider * provider, int bLoop) |
ptpaterson | 10:ec59d628ebdc | 47 | : Node(id, provider, bLoop) |
ptpaterson | 10:ec59d628ebdc | 48 | { |
ptpaterson | 10:ec59d628ebdc | 49 | dictionary = new ObjectData[22]; |
ptpaterson | 10:ec59d628ebdc | 50 | |
ptpaterson | 10:ec59d628ebdc | 51 | |
ptpaterson | 10:ec59d628ebdc | 52 | /* Init values ***********************************************************/ |
ptpaterson | 10:ec59d628ebdc | 53 | memset(prevInputBuffers, 0, sizeof(prevInputBuffers)); |
ptpaterson | 10:ec59d628ebdc | 54 | memset(inputDebounce, 0, sizeof(inputDebounce)); |
ptpaterson | 10:ec59d628ebdc | 55 | |
ptpaterson | 10:ec59d628ebdc | 56 | memset(prevOutputBuffers,0, sizeof(prevOutputBuffers)); |
ptpaterson | 10:ec59d628ebdc | 57 | |
ptpaterson | 10:ec59d628ebdc | 58 | /* Init Object Dictionary ************************************************/ |
ptpaterson | 10:ec59d628ebdc | 59 | |
ptpaterson | 10:ec59d628ebdc | 60 | /* Communication Objects ================================================*/ |
ptpaterson | 10:ec59d628ebdc | 61 | |
ptpaterson | 10:ec59d628ebdc | 62 | /* SDO ------------------------------------------------------------------*/ |
ptpaterson | 10:ec59d628ebdc | 63 | /* index 0x1200 */ |
ptpaterson | 10:ec59d628ebdc | 64 | Obj1200_highestSubIndex = 2; |
ptpaterson | 10:ec59d628ebdc | 65 | Obj1200_ReceiveCobId = 0x600 + nodeId; |
ptpaterson | 10:ec59d628ebdc | 66 | Obj1200_TransmitCobId = 0x580 + nodeId; |
ptpaterson | 10:ec59d628ebdc | 67 | Obj1200_entries[0] = EntryData((void*)&Obj1200_highestSubIndex, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 68 | Obj1200_entries[1] = EntryData((void*)&Obj1200_ReceiveCobId, sizeof(uint32_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 69 | Obj1200_entries[2] = EntryData((void*)&Obj1200_TransmitCobId, sizeof(uint32_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 70 | Obj1200 = ObjectData(Obj1200_entries, 0x1200, sizeof(Obj1200_entries) / sizeof(Obj1200_entries[0])); |
ptpaterson | 10:ec59d628ebdc | 71 | |
ptpaterson | 10:ec59d628ebdc | 72 | /* RPDO -----------------------------------------------------------------*/ |
ptpaterson | 10:ec59d628ebdc | 73 | /* index 0x1400 */ |
ptpaterson | 10:ec59d628ebdc | 74 | Obj1400_highestSubIndex = 5; |
ptpaterson | 10:ec59d628ebdc | 75 | Obj1400_CobId = 0x200 + nodeId; |
ptpaterson | 10:ec59d628ebdc | 76 | Obj1400_TransmissionType = 1; |
ptpaterson | 10:ec59d628ebdc | 77 | Obj1400_InhibitTime = 0; |
ptpaterson | 10:ec59d628ebdc | 78 | Obj1400_CompatibilityEntry = 0; |
ptpaterson | 10:ec59d628ebdc | 79 | Obj1400_EventTimer = 0; |
ptpaterson | 10:ec59d628ebdc | 80 | Obj1400_entries[0] = EntryData((void*)&Obj1400_highestSubIndex, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 81 | Obj1400_entries[1] = EntryData((void*)&Obj1400_CobId, sizeof(uint32_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 82 | Obj1400_entries[2] = EntryData((void*)&Obj1400_TransmissionType, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 83 | Obj1400_entries[3] = EntryData((void*)&Obj1400_InhibitTime, sizeof(uint16_t), EntryData::TYPE_UINT16, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 84 | Obj1400_entries[4] = EntryData((void*)&Obj1400_CompatibilityEntry, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 85 | Obj1400_entries[5] = EntryData((void*)&Obj1400_EventTimer, sizeof(uint16_t), EntryData::TYPE_UINT16, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 86 | Obj1400 = ObjectData(Obj1400_entries, 0x1400, sizeof(Obj1400_entries) / sizeof(Obj1400_entries[0])); |
ptpaterson | 10:ec59d628ebdc | 87 | |
ptpaterson | 10:ec59d628ebdc | 88 | /* index 0x1401 */ |
ptpaterson | 10:ec59d628ebdc | 89 | Obj1401_highestSubIndex = 5; |
ptpaterson | 10:ec59d628ebdc | 90 | Obj1401_CobId = 0x300 + nodeId; |
ptpaterson | 10:ec59d628ebdc | 91 | Obj1401_TransmissionType = 1; |
ptpaterson | 10:ec59d628ebdc | 92 | Obj1401_InhibitTime = 0; |
ptpaterson | 10:ec59d628ebdc | 93 | Obj1401_CompatibilityEntry = 0; |
ptpaterson | 10:ec59d628ebdc | 94 | Obj1401_EventTimer = 0; |
ptpaterson | 10:ec59d628ebdc | 95 | Obj1401_entries[0] = EntryData((void*)&Obj1401_highestSubIndex, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 96 | Obj1401_entries[1] = EntryData((void*)&Obj1401_CobId, sizeof(uint32_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 97 | Obj1401_entries[2] = EntryData((void*)&Obj1401_TransmissionType, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 98 | Obj1401_entries[3] = EntryData((void*)&Obj1401_InhibitTime, sizeof(uint16_t), EntryData::TYPE_UINT16, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 99 | Obj1401_entries[4] = EntryData((void*)&Obj1401_CompatibilityEntry, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 100 | Obj1401_entries[5] = EntryData((void*)&Obj1401_EventTimer, sizeof(uint16_t), EntryData::TYPE_UINT16, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 101 | Obj1401 = ObjectData(Obj1401_entries, 0x1401, sizeof(Obj1401_entries) / sizeof(Obj1401_entries[0])); |
ptpaterson | 10:ec59d628ebdc | 102 | |
ptpaterson | 10:ec59d628ebdc | 103 | /* index 0x1402 */ |
ptpaterson | 10:ec59d628ebdc | 104 | Obj1402_highestSubIndex = 5; |
ptpaterson | 10:ec59d628ebdc | 105 | Obj1402_CobId = 0x400 + nodeId; |
ptpaterson | 10:ec59d628ebdc | 106 | Obj1402_TransmissionType = 1; |
ptpaterson | 10:ec59d628ebdc | 107 | Obj1402_InhibitTime = 0; |
ptpaterson | 10:ec59d628ebdc | 108 | Obj1402_CompatibilityEntry = 0; |
ptpaterson | 10:ec59d628ebdc | 109 | Obj1402_EventTimer = 0; |
ptpaterson | 10:ec59d628ebdc | 110 | Obj1402_entries[0] = EntryData((void*)&Obj1402_highestSubIndex, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 111 | Obj1402_entries[1] = EntryData((void*)&Obj1402_CobId, sizeof(uint32_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 112 | Obj1402_entries[2] = EntryData((void*)&Obj1402_TransmissionType, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 113 | Obj1402_entries[3] = EntryData((void*)&Obj1402_InhibitTime, sizeof(uint16_t), EntryData::TYPE_UINT16, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 114 | Obj1402_entries[4] = EntryData((void*)&Obj1402_CompatibilityEntry, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 115 | Obj1402_entries[5] = EntryData((void*)&Obj1402_EventTimer, sizeof(uint16_t), EntryData::TYPE_UINT16, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 116 | Obj1402 = ObjectData(Obj1402_entries, 0x1402, sizeof(Obj1402_entries) / sizeof(Obj1402_entries[0])); |
ptpaterson | 10:ec59d628ebdc | 117 | |
ptpaterson | 10:ec59d628ebdc | 118 | /* index 0x1403 */ |
ptpaterson | 10:ec59d628ebdc | 119 | Obj1403_highestSubIndex = 5; |
ptpaterson | 10:ec59d628ebdc | 120 | Obj1403_CobId = 0x181; |
ptpaterson | 10:ec59d628ebdc | 121 | Obj1403_TransmissionType = 1; |
ptpaterson | 10:ec59d628ebdc | 122 | Obj1403_InhibitTime = 0; |
ptpaterson | 10:ec59d628ebdc | 123 | Obj1403_CompatibilityEntry = 0; |
ptpaterson | 10:ec59d628ebdc | 124 | Obj1403_EventTimer = 0; |
ptpaterson | 10:ec59d628ebdc | 125 | Obj1403_entries[0] = EntryData((void*)&Obj1403_highestSubIndex, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 126 | Obj1403_entries[1] = EntryData((void*)&Obj1403_CobId, sizeof(uint32_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 127 | Obj1403_entries[2] = EntryData((void*)&Obj1403_TransmissionType, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 128 | Obj1403_entries[3] = EntryData((void*)&Obj1403_InhibitTime, sizeof(uint16_t), EntryData::TYPE_UINT16, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 129 | Obj1403_entries[4] = EntryData((void*)&Obj1403_CompatibilityEntry, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 130 | Obj1403_entries[5] = EntryData((void*)&Obj1403_EventTimer, sizeof(uint16_t), EntryData::TYPE_UINT16, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 131 | Obj1403 = ObjectData(Obj1403_entries, 0x1403, sizeof(Obj1403_entries) / sizeof(Obj1403_entries[0])); |
ptpaterson | 10:ec59d628ebdc | 132 | |
ptpaterson | 10:ec59d628ebdc | 133 | /* index 0x1600 */ |
ptpaterson | 10:ec59d628ebdc | 134 | Obj1600_highestSubIndex = 1; |
ptpaterson | 10:ec59d628ebdc | 135 | Obj1600_Map = 0x62000108; |
ptpaterson | 10:ec59d628ebdc | 136 | Obj1600_entries[0] = EntryData((void*)&Obj1600_highestSubIndex, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 137 | Obj1600_entries[1] = EntryData((void*)&Obj1600_Map, sizeof(uint32_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 138 | Obj1600 = ObjectData(Obj1600_entries, 0x1600, sizeof(Obj1600_entries) / sizeof(Obj1600_entries[0])); |
ptpaterson | 10:ec59d628ebdc | 139 | |
ptpaterson | 10:ec59d628ebdc | 140 | /* index 0x1601 */ |
ptpaterson | 10:ec59d628ebdc | 141 | Obj1601_highestSubIndex = 1; |
ptpaterson | 10:ec59d628ebdc | 142 | Obj1601_Map = 0x20010140; |
ptpaterson | 10:ec59d628ebdc | 143 | Obj1601_entries[0] = EntryData((void*)&Obj1601_highestSubIndex, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 144 | Obj1601_entries[1] = EntryData((void*)&Obj1601_Map, sizeof(uint32_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 145 | Obj1601 = ObjectData(Obj1601_entries, 0x1601, sizeof(Obj1601_entries) / sizeof(Obj1601_entries[0])); |
ptpaterson | 10:ec59d628ebdc | 146 | |
ptpaterson | 10:ec59d628ebdc | 147 | /* index 0x1602 */ |
ptpaterson | 10:ec59d628ebdc | 148 | Obj1602_highestSubIndex = 1; |
ptpaterson | 10:ec59d628ebdc | 149 | Obj1602_Map = 0x22000140; |
ptpaterson | 10:ec59d628ebdc | 150 | Obj1602_entries[0] = EntryData((void*)&Obj1602_highestSubIndex, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 151 | Obj1602_entries[1] = EntryData((void*)&Obj1602_Map, sizeof(uint32_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 152 | Obj1602 = ObjectData(Obj1602_entries, 0x1602, sizeof(Obj1602_entries) / sizeof(Obj1602_entries[0])); |
ptpaterson | 10:ec59d628ebdc | 153 | |
ptpaterson | 10:ec59d628ebdc | 154 | /* index 0x1603 */ |
ptpaterson | 10:ec59d628ebdc | 155 | Obj1603_highestSubIndex = 1; |
ptpaterson | 10:ec59d628ebdc | 156 | Obj1603_Map = 0x22000238; |
ptpaterson | 10:ec59d628ebdc | 157 | Obj1603_entries[0] = EntryData((void*)&Obj1603_highestSubIndex, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 158 | Obj1603_entries[1] = EntryData((void*)&Obj1603_Map, sizeof(uint32_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 159 | Obj1603 = ObjectData(Obj1603_entries, 0x1603, sizeof(Obj1603_entries) / sizeof(Obj1603_entries[0])); |
ptpaterson | 10:ec59d628ebdc | 160 | |
ptpaterson | 10:ec59d628ebdc | 161 | /* TPDO -----------------------------------------------------------------*/ |
ptpaterson | 10:ec59d628ebdc | 162 | /* index 0x1800 */ |
ptpaterson | 10:ec59d628ebdc | 163 | Obj1800_highestSubIndex = 5; |
ptpaterson | 10:ec59d628ebdc | 164 | Obj1800_CobId = 0x181; |
ptpaterson | 10:ec59d628ebdc | 165 | Obj1800_TransmissionType = 0xFE; /* event driven Manuf specific */ |
ptpaterson | 10:ec59d628ebdc | 166 | Obj1800_InhibitTime = 0; // TODO review if this is needed |
ptpaterson | 10:ec59d628ebdc | 167 | Obj1800_CompatibilityEntry = 0; |
ptpaterson | 10:ec59d628ebdc | 168 | Obj1800_EventTimer = 0; |
ptpaterson | 10:ec59d628ebdc | 169 | Obj1800_entries[0] = EntryData((void*)&Obj1800_highestSubIndex, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 170 | Obj1800_entries[1] = EntryData((void*)&Obj1800_CobId, sizeof(uint32_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 171 | Obj1800_entries[2] = EntryData((void*)&Obj1800_TransmissionType, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 172 | Obj1800_entries[3] = EntryData((void*)&Obj1800_InhibitTime, sizeof(uint16_t), EntryData::TYPE_UINT16, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 173 | Obj1800_entries[4] = EntryData((void*)&Obj1800_CompatibilityEntry, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 174 | Obj1800_entries[5] = EntryData((void*)&Obj1800_EventTimer, sizeof(uint16_t), EntryData::TYPE_UINT16, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 175 | Obj1800 = ObjectData(Obj1800_entries, 0x1800, sizeof(Obj1800_entries) / sizeof(Obj1800_entries[0])); |
ptpaterson | 10:ec59d628ebdc | 176 | |
ptpaterson | 10:ec59d628ebdc | 177 | /* index 0x1A00 */ |
ptpaterson | 10:ec59d628ebdc | 178 | Obj1A00_highestSubIndex = 5; |
ptpaterson | 10:ec59d628ebdc | 179 | Obj1A00_MapInput = 0x60000108; |
ptpaterson | 10:ec59d628ebdc | 180 | Obj1A00_MapVoid16 = 0x00000010; |
ptpaterson | 10:ec59d628ebdc | 181 | Obj1A00_MapChange = 0x21000108; |
ptpaterson | 10:ec59d628ebdc | 182 | Obj1A00_MapSourceId = 0x21000208; |
ptpaterson | 10:ec59d628ebdc | 183 | Obj1A00_entries[0] = EntryData((void*)&Obj1A00_highestSubIndex, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 184 | Obj1A00_entries[1] = EntryData((void*)&Obj1A00_MapInput, sizeof(uint8_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 185 | Obj1A00_entries[2] = EntryData((void*)&Obj1A00_MapVoid16, sizeof(uint16_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 186 | Obj1A00_entries[3] = EntryData((void*)&Obj1A00_MapChange, sizeof(uint8_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 187 | Obj1A00_entries[4] = EntryData((void*)&Obj1A00_MapVoid16, sizeof(uint16_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 188 | Obj1A00_entries[5] = EntryData((void*)&Obj1A00_MapSourceId, sizeof(uint8_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 189 | Obj1A00 = ObjectData(Obj1A00_entries, 0x1A00, sizeof(Obj1A00_entries) / sizeof(Obj1A00_entries[0])); |
ptpaterson | 10:ec59d628ebdc | 190 | |
ptpaterson | 10:ec59d628ebdc | 191 | |
ptpaterson | 10:ec59d628ebdc | 192 | /* Manufacturer Specific Objects ========================================*/ |
ptpaterson | 10:ec59d628ebdc | 193 | |
ptpaterson | 10:ec59d628ebdc | 194 | /* index 0x2001 : Pin Output Configurations */ |
ptpaterson | 10:ec59d628ebdc | 195 | Obj2001_highestSubIndex = 8; |
ptpaterson | 10:ec59d628ebdc | 196 | memset(&writeOutputConfig, 0, sizeof(writeOutputConfig)); |
ptpaterson | 10:ec59d628ebdc | 197 | memset(outputConfigs, 0, sizeof(outputConfigs)); |
ptpaterson | 10:ec59d628ebdc | 198 | outputConfigs[0].type = 0x08; |
ptpaterson | 10:ec59d628ebdc | 199 | memset(outputTimers, 0, sizeof(outputTimers)); |
ptpaterson | 10:ec59d628ebdc | 200 | Obj2001_entries[0] = EntryData((void*)&Obj2001_highestSubIndex, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 201 | Obj2001_entries[1] = EntryData((void*)&writeOutputConfig, sizeof(OutputConfiguration), EntryData::TYPE_UINT64, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 202 | Obj2001_entries[2] = EntryData((void*)&outputConfigs[0], sizeof(OutputConfiguration), EntryData::TYPE_UINT64, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 203 | Obj2001_entries[3] = EntryData((void*)&outputConfigs[1], sizeof(OutputConfiguration), EntryData::TYPE_UINT64, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 204 | Obj2001_entries[4] = EntryData((void*)&outputConfigs[2], sizeof(OutputConfiguration), EntryData::TYPE_UINT64, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 205 | Obj2001_entries[5] = EntryData((void*)&outputConfigs[3], sizeof(OutputConfiguration), EntryData::TYPE_UINT64, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 206 | Obj2001_entries[6] = EntryData((void*)&outputConfigs[4], sizeof(OutputConfiguration), EntryData::TYPE_UINT64, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 207 | Obj2001_entries[7] = EntryData((void*)&outputConfigs[5], sizeof(OutputConfiguration), EntryData::TYPE_UINT64, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 208 | Obj2001_entries[8] = EntryData((void*)&outputConfigs[6], sizeof(OutputConfiguration), EntryData::TYPE_UINT64, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 209 | Obj2001_entries[9] = EntryData((void*)&outputConfigs[7], sizeof(OutputConfiguration), EntryData::TYPE_UINT64, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 210 | Obj2001 = ObjectData(Obj2001_entries, 0x2001, sizeof(Obj2001_entries) / sizeof(Obj2001_entries[0])); |
ptpaterson | 10:ec59d628ebdc | 211 | |
ptpaterson | 10:ec59d628ebdc | 212 | /* index 0x2002 : Output Schedule Configuration */ |
ptpaterson | 10:ec59d628ebdc | 213 | Obj2002_highestSubIndex = 1; |
ptpaterson | 10:ec59d628ebdc | 214 | scheduleConfig = 0x01; |
ptpaterson | 10:ec59d628ebdc | 215 | schedules[0] = 0xFF00F0F0; |
ptpaterson | 10:ec59d628ebdc | 216 | Obj2002_entries[0] = EntryData((void*)&Obj2002_highestSubIndex, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 217 | Obj2002_entries[1] = EntryData((void*)&scheduleConfig, sizeof(uint32_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 218 | Obj2002_entries[2] = EntryData((void*)&schedules[0], sizeof(uint32_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 219 | Obj2002_entries[3] = EntryData((void*)&schedules[1], sizeof(uint32_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 220 | Obj2002_entries[4] = EntryData((void*)&schedules[2], sizeof(uint32_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 221 | Obj2002_entries[5] = EntryData((void*)&schedules[3], sizeof(uint32_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 222 | Obj2002_entries[6] = EntryData((void*)&schedules[4], sizeof(uint32_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 223 | Obj2002_entries[7] = EntryData((void*)&schedules[5], sizeof(uint32_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 224 | Obj2002_entries[8] = EntryData((void*)&schedules[6], sizeof(uint32_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 225 | Obj2002_entries[9] = EntryData((void*)&schedules[7], sizeof(uint32_t), EntryData::TYPE_UINT32, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 226 | Obj2002 = ObjectData(Obj2002_entries, 0x2002, sizeof(Obj2002_entries) / sizeof(Obj2002_entries[0])); |
ptpaterson | 10:ec59d628ebdc | 227 | |
ptpaterson | 10:ec59d628ebdc | 228 | /* Index 2100 */ |
ptpaterson | 10:ec59d628ebdc | 229 | Obj2100_highestSubIndex = 2; |
ptpaterson | 10:ec59d628ebdc | 230 | inputChangeMask[0] = 0; |
ptpaterson | 10:ec59d628ebdc | 231 | /* nodeId; */ |
ptpaterson | 10:ec59d628ebdc | 232 | Obj2100_entries[0] = EntryData((void*)&Obj2100_highestSubIndex, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 233 | Obj2100_entries[1] = EntryData((void*)&inputChangeMask[0], sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 234 | Obj2100_entries[2] = EntryData((void*)&nodeId, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 235 | Obj2100 = ObjectData(Obj2100_entries, 0x2100, sizeof(Obj2100_entries) / sizeof(Obj2100_entries[0])); |
ptpaterson | 10:ec59d628ebdc | 236 | |
ptpaterson | 10:ec59d628ebdc | 237 | /* Index 2200 */ |
ptpaterson | 10:ec59d628ebdc | 238 | Obj2200_highestSubIndex = 2; |
ptpaterson | 10:ec59d628ebdc | 239 | memset(&writeRule, 0, sizeof(AutotriggerRule)); |
ptpaterson | 10:ec59d628ebdc | 240 | memset(&autotriggerMessage, 0, sizeof(AutotriggerMessage)); |
ptpaterson | 10:ec59d628ebdc | 241 | memset(rules, 0, sizeof(rules)); |
ptpaterson | 10:ec59d628ebdc | 242 | Obj2200_entries[0] = EntryData((void*)&Obj2200_highestSubIndex, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 243 | Obj2200_entries[1] = EntryData((void*)&writeRule, sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 244 | Obj2200_entries[2] = EntryData((void*)&autotriggerMessage, sizeof(AutotriggerMessage), EntryData::TYPE_UINT32, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 245 | Obj2200_entries[3] = EntryData((void*)&rules[0], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 246 | Obj2200_entries[4] = EntryData((void*)&rules[1], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 247 | Obj2200_entries[5] = EntryData((void*)&rules[2], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 248 | Obj2200_entries[6] = EntryData((void*)&rules[3], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 249 | Obj2200_entries[7] = EntryData((void*)&rules[4], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 250 | Obj2200_entries[8] = EntryData((void*)&rules[5], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 251 | Obj2200_entries[9] = EntryData((void*)&rules[6], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 252 | Obj2200_entries[10] = EntryData((void*)&rules[7], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 253 | Obj2200_entries[11] = EntryData((void*)&rules[8], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 254 | Obj2200_entries[12] = EntryData((void*)&rules[9], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 255 | Obj2200_entries[13] = EntryData((void*)&rules[10], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 256 | Obj2200_entries[14] = EntryData((void*)&rules[11], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 257 | Obj2200_entries[15] = EntryData((void*)&rules[12], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 258 | Obj2200_entries[16] = EntryData((void*)&rules[13], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 259 | Obj2200_entries[17] = EntryData((void*)&rules[14], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 260 | Obj2200_entries[18] = EntryData((void*)&rules[15], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 261 | Obj2200_entries[19] = EntryData((void*)&rules[16], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 262 | Obj2200_entries[20] = EntryData((void*)&rules[17], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 263 | Obj2200_entries[21] = EntryData((void*)&rules[18], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 264 | Obj2200_entries[22] = EntryData((void*)&rules[19], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 265 | Obj2200_entries[23] = EntryData((void*)&rules[20], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 266 | Obj2200_entries[24] = EntryData((void*)&rules[21], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 267 | Obj2200_entries[25] = EntryData((void*)&rules[22], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 268 | Obj2200_entries[26] = EntryData((void*)&rules[23], sizeof(AutotriggerRule), EntryData::TYPE_UINT32, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 269 | Obj2200 = ObjectData(Obj2200_entries, 0x2200, sizeof(Obj2200_entries) / sizeof(Obj2200_entries[0])); |
ptpaterson | 10:ec59d628ebdc | 270 | |
ptpaterson | 10:ec59d628ebdc | 271 | /* Device Profile Specific Objects ======================================*/ |
ptpaterson | 10:ec59d628ebdc | 272 | |
ptpaterson | 10:ec59d628ebdc | 273 | /* Index 6000 */ |
ptpaterson | 10:ec59d628ebdc | 274 | Obj6000_highestSubIndex = 1; |
ptpaterson | 10:ec59d628ebdc | 275 | readInputBuffers[0] = 0; |
ptpaterson | 10:ec59d628ebdc | 276 | Obj6000_entries[0] = EntryData((void*)&Obj6000_highestSubIndex, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 277 | Obj6000_entries[1] = EntryData((void*)&readInputBuffers, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 278 | Obj6000 = ObjectData(Obj6000_entries, 0x6000, sizeof(Obj6000_entries) / sizeof(Obj6000_entries[0])); |
ptpaterson | 10:ec59d628ebdc | 279 | |
ptpaterson | 10:ec59d628ebdc | 280 | /* Index 6005 */ |
ptpaterson | 10:ec59d628ebdc | 281 | Obj6005_highestSubIndex = 1; |
ptpaterson | 10:ec59d628ebdc | 282 | bInputInterruptEnable = 0x01; |
ptpaterson | 10:ec59d628ebdc | 283 | Obj6005_entries[0] = EntryData((void*)&Obj6005_highestSubIndex, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 284 | Obj6005_entries[1] = EntryData((void*)&bInputInterruptEnable, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 285 | Obj6005 = ObjectData(Obj6005_entries, 0x6005, sizeof(Obj6005_entries) / sizeof(Obj6005_entries[0])); |
ptpaterson | 10:ec59d628ebdc | 286 | |
ptpaterson | 10:ec59d628ebdc | 287 | /* Index 6006 */ |
ptpaterson | 10:ec59d628ebdc | 288 | Obj6006_highestSubIndex = 1; |
ptpaterson | 10:ec59d628ebdc | 289 | inputInterruptMask[0] = 0xFF; |
ptpaterson | 10:ec59d628ebdc | 290 | Obj6006_entries[0] = EntryData((void*)&Obj6006_highestSubIndex, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 291 | Obj6006_entries[1] = EntryData((void*)&inputInterruptMask, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 292 | Obj6006 = ObjectData(Obj6006_entries, 0x6006, sizeof(Obj6006_entries) / sizeof(Obj6006_entries[0])); |
ptpaterson | 10:ec59d628ebdc | 293 | |
ptpaterson | 10:ec59d628ebdc | 294 | /* Index 6200 */ |
ptpaterson | 10:ec59d628ebdc | 295 | Obj6200_highestSubIndex = 1; |
ptpaterson | 10:ec59d628ebdc | 296 | writeOutputBuffers[0] = 0; |
ptpaterson | 10:ec59d628ebdc | 297 | Obj6200_entries[0] = EntryData((void*)&Obj6200_highestSubIndex, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READABLE); |
ptpaterson | 10:ec59d628ebdc | 298 | Obj6200_entries[1] = EntryData((void*)&writeOutputBuffers, sizeof(uint8_t), EntryData::TYPE_UINT8, EntryData::PROPERTY_READ_WRITEABLE); |
ptpaterson | 10:ec59d628ebdc | 299 | Obj6200 = ObjectData(Obj6200_entries, 0x6200, sizeof(Obj6200_entries) / sizeof(Obj6200_entries[0])); |
ptpaterson | 10:ec59d628ebdc | 300 | |
ptpaterson | 10:ec59d628ebdc | 301 | /* Set up the whole dictionary */ |
ptpaterson | 10:ec59d628ebdc | 302 | dictionary[0] = Obj1200; |
ptpaterson | 10:ec59d628ebdc | 303 | dictionary[1] = Obj1400; |
ptpaterson | 10:ec59d628ebdc | 304 | dictionary[2] = Obj1401; |
ptpaterson | 10:ec59d628ebdc | 305 | dictionary[3] = Obj1402; |
ptpaterson | 10:ec59d628ebdc | 306 | dictionary[4] = Obj1403; |
ptpaterson | 10:ec59d628ebdc | 307 | dictionary[5] = Obj1600; |
ptpaterson | 10:ec59d628ebdc | 308 | dictionary[6] = Obj1601; |
ptpaterson | 10:ec59d628ebdc | 309 | dictionary[7] = Obj1602; |
ptpaterson | 10:ec59d628ebdc | 310 | dictionary[8] = Obj1603; |
ptpaterson | 10:ec59d628ebdc | 311 | dictionary[10] = Obj1800; |
ptpaterson | 10:ec59d628ebdc | 312 | dictionary[11] = Obj1A00; |
ptpaterson | 10:ec59d628ebdc | 313 | dictionary[12] = Obj2001; |
ptpaterson | 10:ec59d628ebdc | 314 | dictionary[13] = Obj2002; |
ptpaterson | 10:ec59d628ebdc | 315 | dictionary[14] = Obj2100; |
ptpaterson | 10:ec59d628ebdc | 316 | dictionary[15] = Obj2200; |
ptpaterson | 10:ec59d628ebdc | 317 | dictionary[16] = Obj6000; |
ptpaterson | 10:ec59d628ebdc | 318 | dictionary[17] = Obj6005; |
ptpaterson | 10:ec59d628ebdc | 319 | dictionary[18] = Obj6006; |
ptpaterson | 10:ec59d628ebdc | 320 | dictionary[19] = Obj6200; |
ptpaterson | 10:ec59d628ebdc | 321 | |
ptpaterson | 10:ec59d628ebdc | 322 | } |
ptpaterson | 10:ec59d628ebdc | 323 | |
ptpaterson | 10:ec59d628ebdc | 324 | Node_pin0808::~Node_pin0808(void) |
ptpaterson | 10:ec59d628ebdc | 325 | { |
ptpaterson | 10:ec59d628ebdc | 326 | delete dictionary; |
ptpaterson | 10:ec59d628ebdc | 327 | } |
ptpaterson | 10:ec59d628ebdc | 328 | |
ptpaterson | 10:ec59d628ebdc | 329 | /****************************************************************************** |
ptpaterson | 10:ec59d628ebdc | 330 | * Application Run Implementation |
ptpaterson | 10:ec59d628ebdc | 331 | ****************************************************************************** |
ptpaterson | 10:ec59d628ebdc | 332 | */ |
ptpaterson | 10:ec59d628ebdc | 333 | |
ptpaterson | 10:ec59d628ebdc | 334 | void Node_pin0808::OnFixedUpdate (void) |
ptpaterson | 10:ec59d628ebdc | 335 | { |
ptpaterson | 10:ec59d628ebdc | 336 | /************************************************************************** |
ptpaterson | 10:ec59d628ebdc | 337 | * INPUTS |
ptpaterson | 10:ec59d628ebdc | 338 | ************************************************************************** |
ptpaterson | 10:ec59d628ebdc | 339 | */ |
ptpaterson | 10:ec59d628ebdc | 340 | |
ptpaterson | 10:ec59d628ebdc | 341 | uint8_t inputSample = ~(uint8_t)(mbedInputs.read()); |
ptpaterson | 10:ec59d628ebdc | 342 | |
ptpaterson | 10:ec59d628ebdc | 343 | uint8_t inputChange = readInputBuffers[0] ^ inputSample; |
ptpaterson | 10:ec59d628ebdc | 344 | |
ptpaterson | 10:ec59d628ebdc | 345 | /* Loop through all of the inputs */ |
ptpaterson | 10:ec59d628ebdc | 346 | for (int in = 0; in < 8; in++) { |
ptpaterson | 10:ec59d628ebdc | 347 | if (inputChange & (1 << in)) { |
ptpaterson | 10:ec59d628ebdc | 348 | |
ptpaterson | 10:ec59d628ebdc | 349 | inputDebounce[in] += (uint8_t)(timeSinceLastTick); |
ptpaterson | 10:ec59d628ebdc | 350 | if (inputDebounce[in] > DEBOUNCE_TIME) { |
ptpaterson | 10:ec59d628ebdc | 351 | readInputBuffers[0] &= ~(1 << in); |
ptpaterson | 10:ec59d628ebdc | 352 | readInputBuffers[0] |= (inputSample & (1 << in)); |
ptpaterson | 10:ec59d628ebdc | 353 | |
ptpaterson | 10:ec59d628ebdc | 354 | inputDebounce[in] = 0; |
ptpaterson | 10:ec59d628ebdc | 355 | } |
ptpaterson | 10:ec59d628ebdc | 356 | |
ptpaterson | 10:ec59d628ebdc | 357 | } else { |
ptpaterson | 10:ec59d628ebdc | 358 | inputDebounce[in] = 0; |
ptpaterson | 10:ec59d628ebdc | 359 | } |
ptpaterson | 10:ec59d628ebdc | 360 | } |
ptpaterson | 10:ec59d628ebdc | 361 | |
ptpaterson | 10:ec59d628ebdc | 362 | |
ptpaterson | 10:ec59d628ebdc | 363 | /************************************************************************** |
ptpaterson | 10:ec59d628ebdc | 364 | * OUTPUTS |
ptpaterson | 10:ec59d628ebdc | 365 | ************************************************************************** |
ptpaterson | 10:ec59d628ebdc | 366 | */ |
ptpaterson | 10:ec59d628ebdc | 367 | |
ptpaterson | 10:ec59d628ebdc | 368 | /* create a copy of the current outputs and edit as we go */ |
ptpaterson | 10:ec59d628ebdc | 369 | uint8_t newOutput = (uint8_t)(mbedOutputs >> 8); |
ptpaterson | 10:ec59d628ebdc | 370 | |
ptpaterson | 10:ec59d628ebdc | 371 | /* big operation, so let's only do it once! */ |
ptpaterson | 10:ec59d628ebdc | 372 | int scheduleIndexer = 1 << ((timeCurrentTick * 100) / 3125) % 32; |
ptpaterson | 10:ec59d628ebdc | 373 | |
ptpaterson | 10:ec59d628ebdc | 374 | /* Loop through all of the outputs */ |
ptpaterson | 10:ec59d628ebdc | 375 | for (int out = 0; out < 8; out++) { |
ptpaterson | 10:ec59d628ebdc | 376 | |
ptpaterson | 10:ec59d628ebdc | 377 | if (scheduleConfig & (1 << out)) { |
ptpaterson | 10:ec59d628ebdc | 378 | |
ptpaterson | 10:ec59d628ebdc | 379 | if (schedules[out] & scheduleIndexer) { |
ptpaterson | 10:ec59d628ebdc | 380 | writeOutputBuffers[0] |= (1 << out); |
ptpaterson | 10:ec59d628ebdc | 381 | } else { |
ptpaterson | 10:ec59d628ebdc | 382 | writeOutputBuffers[0] &= ~(1 << out); |
ptpaterson | 10:ec59d628ebdc | 383 | } |
ptpaterson | 10:ec59d628ebdc | 384 | } |
ptpaterson | 10:ec59d628ebdc | 385 | |
ptpaterson | 10:ec59d628ebdc | 386 | /* update GPIO's immediately only if new signal was given */ |
ptpaterson | 10:ec59d628ebdc | 387 | int outputBufferChanges = writeOutputBuffers[0] ^ prevOutputBuffers[0]; |
ptpaterson | 10:ec59d628ebdc | 388 | |
ptpaterson | 10:ec59d628ebdc | 389 | if (outputBufferChanges & (1 << out)) { |
ptpaterson | 10:ec59d628ebdc | 390 | if ((1 << out) & writeOutputBuffers[0]) { |
ptpaterson | 10:ec59d628ebdc | 391 | /* switched on */ |
ptpaterson | 10:ec59d628ebdc | 392 | newOutput |= (1 << out); |
ptpaterson | 10:ec59d628ebdc | 393 | |
ptpaterson | 10:ec59d628ebdc | 394 | /* reset timers */ |
ptpaterson | 10:ec59d628ebdc | 395 | if (outputConfigs[out].type) { |
ptpaterson | 10:ec59d628ebdc | 396 | outputTimers[out] = OutputConfiguration(outputConfigs[out]); |
ptpaterson | 10:ec59d628ebdc | 397 | } |
ptpaterson | 10:ec59d628ebdc | 398 | } else { |
ptpaterson | 10:ec59d628ebdc | 399 | /* switched off */ |
ptpaterson | 10:ec59d628ebdc | 400 | newOutput &= ~(1 << out); |
ptpaterson | 10:ec59d628ebdc | 401 | memset(&outputTimers[out], 0, sizeof(outputTimers[out])); |
ptpaterson | 10:ec59d628ebdc | 402 | } |
ptpaterson | 10:ec59d628ebdc | 403 | } |
ptpaterson | 10:ec59d628ebdc | 404 | |
ptpaterson | 10:ec59d628ebdc | 405 | /* if there is a pulse run down the timer */ |
ptpaterson | 10:ec59d628ebdc | 406 | if (outputTimers[out].type & 0x01) { |
ptpaterson | 10:ec59d628ebdc | 407 | |
ptpaterson | 10:ec59d628ebdc | 408 | if (outputTimers[out].pulse_ms >= timeSinceLastTick) { |
ptpaterson | 10:ec59d628ebdc | 409 | outputTimers[out].pulse_ms -= timeSinceLastTick; |
ptpaterson | 10:ec59d628ebdc | 410 | } else { |
ptpaterson | 10:ec59d628ebdc | 411 | /* time past would put timer below 0 */ |
ptpaterson | 10:ec59d628ebdc | 412 | outputTimers[out].pulse_ms = 0; |
ptpaterson | 10:ec59d628ebdc | 413 | } |
ptpaterson | 10:ec59d628ebdc | 414 | |
ptpaterson | 10:ec59d628ebdc | 415 | /* if time has run out */ |
ptpaterson | 10:ec59d628ebdc | 416 | if (0 == outputTimers[out].pulse_ms) { |
ptpaterson | 10:ec59d628ebdc | 417 | |
ptpaterson | 10:ec59d628ebdc | 418 | /* just turn off pulse */ |
ptpaterson | 10:ec59d628ebdc | 419 | outputTimers[out].type &= 0xFE; |
ptpaterson | 10:ec59d628ebdc | 420 | newOutput &= ~(1 << out); |
ptpaterson | 10:ec59d628ebdc | 421 | |
ptpaterson | 10:ec59d628ebdc | 422 | /* if there is a patter, then output buffer will stay on */ |
ptpaterson | 10:ec59d628ebdc | 423 | /* but if there is a pulsed-patter, then it should still turn off */ |
ptpaterson | 10:ec59d628ebdc | 424 | if (!(outputTimers[out].type & 0x02) || |
ptpaterson | 10:ec59d628ebdc | 425 | (outputTimers[out].type & (0x02 | 0x04))) { |
ptpaterson | 10:ec59d628ebdc | 426 | /* turn buffer off */ |
ptpaterson | 10:ec59d628ebdc | 427 | outputTimers[out].type = 0; |
ptpaterson | 10:ec59d628ebdc | 428 | writeOutputBuffers[0] &= ~(1 << out); |
ptpaterson | 10:ec59d628ebdc | 429 | } |
ptpaterson | 10:ec59d628ebdc | 430 | } |
ptpaterson | 10:ec59d628ebdc | 431 | } |
ptpaterson | 10:ec59d628ebdc | 432 | |
ptpaterson | 10:ec59d628ebdc | 433 | /* two ways to patter: |
ptpaterson | 10:ec59d628ebdc | 434 | * wait until after pulse (pulse-then-patter), |
ptpaterson | 10:ec59d628ebdc | 435 | * or config so pulse happens at same time (pulsed-patter) |
ptpaterson | 10:ec59d628ebdc | 436 | */ |
ptpaterson | 10:ec59d628ebdc | 437 | if (((outputTimers[out].type & 0x02) && !(outputTimers[out].type & 0x01)) || |
ptpaterson | 10:ec59d628ebdc | 438 | ((outputTimers[out].type & (0x02 | 0x04)) && (outputTimers[out].type & 0x01))) { |
ptpaterson | 10:ec59d628ebdc | 439 | |
ptpaterson | 10:ec59d628ebdc | 440 | /* if output is on, run down pwm_on, else tun down pwm_off */ |
ptpaterson | 10:ec59d628ebdc | 441 | uint8_t *pw_timer; |
ptpaterson | 10:ec59d628ebdc | 442 | if (newOutput & (1 << out)) { |
ptpaterson | 10:ec59d628ebdc | 443 | pw_timer = &outputTimers[out].pwm_on; |
ptpaterson | 10:ec59d628ebdc | 444 | } else { |
ptpaterson | 10:ec59d628ebdc | 445 | pw_timer = &outputTimers[out].pwm_off; |
ptpaterson | 10:ec59d628ebdc | 446 | } |
ptpaterson | 10:ec59d628ebdc | 447 | |
ptpaterson | 10:ec59d628ebdc | 448 | if (*pw_timer >= timeSinceLastTick) { |
ptpaterson | 10:ec59d628ebdc | 449 | *pw_timer -= timeSinceLastTick; |
ptpaterson | 10:ec59d628ebdc | 450 | } else { |
ptpaterson | 10:ec59d628ebdc | 451 | *pw_timer = 0; |
ptpaterson | 10:ec59d628ebdc | 452 | } |
ptpaterson | 10:ec59d628ebdc | 453 | |
ptpaterson | 10:ec59d628ebdc | 454 | if (*pw_timer == 0) { |
ptpaterson | 10:ec59d628ebdc | 455 | newOutput ^= (1 << out); |
ptpaterson | 10:ec59d628ebdc | 456 | |
ptpaterson | 10:ec59d628ebdc | 457 | outputTimers[out].pwm_on = outputConfigs[out].pwm_on; |
ptpaterson | 10:ec59d628ebdc | 458 | outputTimers[out].pwm_off = outputConfigs[out].pwm_off; |
ptpaterson | 10:ec59d628ebdc | 459 | } |
ptpaterson | 10:ec59d628ebdc | 460 | } |
ptpaterson | 10:ec59d628ebdc | 461 | |
ptpaterson | 10:ec59d628ebdc | 462 | |
ptpaterson | 10:ec59d628ebdc | 463 | } |
ptpaterson | 10:ec59d628ebdc | 464 | |
ptpaterson | 10:ec59d628ebdc | 465 | mbedOutputs = ((uint16_t)newOutput) << 8; |
ptpaterson | 10:ec59d628ebdc | 466 | |
ptpaterson | 10:ec59d628ebdc | 467 | prevOutputBuffers[0] = writeOutputBuffers[0]; |
ptpaterson | 10:ec59d628ebdc | 468 | } |
ptpaterson | 10:ec59d628ebdc | 469 | |
ptpaterson | 10:ec59d628ebdc | 470 | void Node_pin0808::OnUpdate (void) |
ptpaterson | 10:ec59d628ebdc | 471 | { |
ptpaterson | 10:ec59d628ebdc | 472 | /* Check for output configurations --------------------------------------*/ |
ptpaterson | 10:ec59d628ebdc | 473 | if (writeOutputConfig.writeData) { |
ptpaterson | 10:ec59d628ebdc | 474 | uint8_t out = (uint8_t)(writeOutputConfig.writeData); |
ptpaterson | 10:ec59d628ebdc | 475 | |
ptpaterson | 10:ec59d628ebdc | 476 | writeOutputConfig.writeData = 0; |
ptpaterson | 10:ec59d628ebdc | 477 | outputConfigs[out] = writeOutputConfig; |
ptpaterson | 10:ec59d628ebdc | 478 | |
ptpaterson | 10:ec59d628ebdc | 479 | memset(&writeOutputConfig, 0, sizeof(writeOutputConfig)); |
ptpaterson | 10:ec59d628ebdc | 480 | } |
ptpaterson | 10:ec59d628ebdc | 481 | |
ptpaterson | 10:ec59d628ebdc | 482 | |
ptpaterson | 10:ec59d628ebdc | 483 | /* Check for rule configurations ----------------------------------------*/ |
ptpaterson | 10:ec59d628ebdc | 484 | if (writeRule.sourceId) { |
ptpaterson | 10:ec59d628ebdc | 485 | printf(" Configuring Rules...\r\n"); |
ptpaterson | 10:ec59d628ebdc | 486 | if (writeRule.sourceId & 0x80) { |
ptpaterson | 10:ec59d628ebdc | 487 | /* write new rule*/ |
ptpaterson | 10:ec59d628ebdc | 488 | |
ptpaterson | 10:ec59d628ebdc | 489 | /* scan through array of rules for available (8th bit cleared) */ |
ptpaterson | 10:ec59d628ebdc | 490 | int ruleNum = 0; |
ptpaterson | 10:ec59d628ebdc | 491 | while (ruleNum < 24) { |
ptpaterson | 10:ec59d628ebdc | 492 | if (!(rules[ruleNum].sourceId & 0x80)) { |
ptpaterson | 10:ec59d628ebdc | 493 | |
ptpaterson | 10:ec59d628ebdc | 494 | rules[ruleNum] = writeRule; |
ptpaterson | 10:ec59d628ebdc | 495 | printf(" Rule added: #%d\r\n", ruleNum); |
ptpaterson | 10:ec59d628ebdc | 496 | ruleNum = 24; |
ptpaterson | 10:ec59d628ebdc | 497 | } else { |
ptpaterson | 10:ec59d628ebdc | 498 | ruleNum++; |
ptpaterson | 10:ec59d628ebdc | 499 | if (ruleNum == 24) { |
ptpaterson | 10:ec59d628ebdc | 500 | printf(" ERROR: Not enough rules available"); |
ptpaterson | 10:ec59d628ebdc | 501 | } |
ptpaterson | 10:ec59d628ebdc | 502 | } |
ptpaterson | 10:ec59d628ebdc | 503 | } |
ptpaterson | 10:ec59d628ebdc | 504 | |
ptpaterson | 10:ec59d628ebdc | 505 | } else { |
ptpaterson | 10:ec59d628ebdc | 506 | /* clear rules */ |
ptpaterson | 10:ec59d628ebdc | 507 | |
ptpaterson | 10:ec59d628ebdc | 508 | /* scan through array of rules matching input and disable */ |
ptpaterson | 10:ec59d628ebdc | 509 | for (int ruleNum = 0; ruleNum < 24; ruleNum++) { |
ptpaterson | 10:ec59d628ebdc | 510 | |
ptpaterson | 10:ec59d628ebdc | 511 | /* check if rule enabled and input num matches */ |
ptpaterson | 10:ec59d628ebdc | 512 | if ((rules[ruleNum].sourceId & 0x80) && |
ptpaterson | 10:ec59d628ebdc | 513 | ((rules[ruleNum].sourceId & 0x7F) == writeRule.sourceId) && |
ptpaterson | 10:ec59d628ebdc | 514 | ((rules[ruleNum].input & 0x1F) == (writeRule.input & 0x1F))) |
ptpaterson | 10:ec59d628ebdc | 515 | { |
ptpaterson | 10:ec59d628ebdc | 516 | memset(&rules[ruleNum], 0, sizeof(AutotriggerRule)); |
ptpaterson | 10:ec59d628ebdc | 517 | printf(" Rule removed: #%d\r\n", ruleNum); |
ptpaterson | 10:ec59d628ebdc | 518 | } |
ptpaterson | 10:ec59d628ebdc | 519 | |
ptpaterson | 10:ec59d628ebdc | 520 | } |
ptpaterson | 10:ec59d628ebdc | 521 | } |
ptpaterson | 10:ec59d628ebdc | 522 | |
ptpaterson | 10:ec59d628ebdc | 523 | memset(&writeRule, 0, sizeof(AutotriggerRule)); |
ptpaterson | 10:ec59d628ebdc | 524 | } |
ptpaterson | 10:ec59d628ebdc | 525 | |
ptpaterson | 10:ec59d628ebdc | 526 | /* check for input changes from other devices---------------------------*/ |
ptpaterson | 10:ec59d628ebdc | 527 | if (autotriggerMessage.sourceId) { |
ptpaterson | 10:ec59d628ebdc | 528 | |
ptpaterson | 10:ec59d628ebdc | 529 | printf(" detected change from node: %#04x\r\n", (autotriggerMessage.sourceId & 0x7F)); |
ptpaterson | 10:ec59d628ebdc | 530 | /* scan through array of rules matching inputs and direction */ |
ptpaterson | 10:ec59d628ebdc | 531 | for (int ruleNum = 0; ruleNum < 24; ruleNum++) { |
ptpaterson | 10:ec59d628ebdc | 532 | |
ptpaterson | 10:ec59d628ebdc | 533 | /* check if rule enabled and input num matches */ |
ptpaterson | 10:ec59d628ebdc | 534 | if ((rules[ruleNum].sourceId & 0x80) && /* rule is active AND */ |
ptpaterson | 10:ec59d628ebdc | 535 | (rules[ruleNum].sourceId == autotriggerMessage.sourceId) && /* rule source matches message source AND */ |
ptpaterson | 10:ec59d628ebdc | 536 | (autotriggerMessage.change[0] & (1 << (rules[ruleNum].input & 0x1F)))) /* change exists at input num */ |
ptpaterson | 10:ec59d628ebdc | 537 | { |
ptpaterson | 10:ec59d628ebdc | 538 | |
ptpaterson | 10:ec59d628ebdc | 539 | int ruleActivity = rules[ruleNum].input >> 5; |
ptpaterson | 10:ec59d628ebdc | 540 | int inputActivity = (autotriggerMessage.input[0] >> (rules[ruleNum].input & 0x1F)) & 1; |
ptpaterson | 10:ec59d628ebdc | 541 | |
ptpaterson | 10:ec59d628ebdc | 542 | printf(" id match: %#04x\r\n", ruleNum); |
ptpaterson | 10:ec59d628ebdc | 543 | printf(" ruleActivity: %#04x\r\n", ruleActivity); |
ptpaterson | 10:ec59d628ebdc | 544 | printf(" inputActivity: %#04x\r\n", inputActivity); |
ptpaterson | 10:ec59d628ebdc | 545 | |
ptpaterson | 10:ec59d628ebdc | 546 | if ((2 == ruleActivity) || (inputActivity == ruleActivity)) { |
ptpaterson | 10:ec59d628ebdc | 547 | |
ptpaterson | 10:ec59d628ebdc | 548 | printf(" activating Rule...\r\n"); |
ptpaterson | 10:ec59d628ebdc | 549 | printf(" setMask: %#10x\r\n", rules[ruleNum].setMask[0]); |
ptpaterson | 10:ec59d628ebdc | 550 | printf(" clearMask: %#10x\r\n", ~rules[ruleNum].clearMask[0]); |
ptpaterson | 10:ec59d628ebdc | 551 | |
ptpaterson | 10:ec59d628ebdc | 552 | writeOutputBuffers[0] |= rules[ruleNum].setMask[0]; |
ptpaterson | 10:ec59d628ebdc | 553 | //writeOutputBuffers[1] |= rules[ruleNum].setMask[1]; |
ptpaterson | 10:ec59d628ebdc | 554 | //writeOutputBuffers[2] |= rules[ruleNum].setMask[2]; |
ptpaterson | 10:ec59d628ebdc | 555 | |
ptpaterson | 10:ec59d628ebdc | 556 | writeOutputBuffers[0] &= ~rules[ruleNum].clearMask[0]; |
ptpaterson | 10:ec59d628ebdc | 557 | //writeOutputBuffers[1] &= ~rules[ruleNum].clearMask[1]; |
ptpaterson | 10:ec59d628ebdc | 558 | //writeOutputBuffers[2] &= ~rules[ruleNum].clearMask[2]; |
ptpaterson | 10:ec59d628ebdc | 559 | } |
ptpaterson | 10:ec59d628ebdc | 560 | } |
ptpaterson | 10:ec59d628ebdc | 561 | |
ptpaterson | 10:ec59d628ebdc | 562 | } |
ptpaterson | 10:ec59d628ebdc | 563 | |
ptpaterson | 10:ec59d628ebdc | 564 | memset(&autotriggerMessage, 0, sizeof(AutotriggerMessage)); |
ptpaterson | 10:ec59d628ebdc | 565 | } |
ptpaterson | 10:ec59d628ebdc | 566 | |
ptpaterson | 10:ec59d628ebdc | 567 | /* check for input changes from this device -----------------------------*/ |
ptpaterson | 10:ec59d628ebdc | 568 | /* update Index 2101-01 */ |
ptpaterson | 10:ec59d628ebdc | 569 | inputChangeMask[0] = readInputBuffers[0] ^ prevInputBuffers[0]; |
ptpaterson | 10:ec59d628ebdc | 570 | |
ptpaterson | 10:ec59d628ebdc | 571 | /* check for rules against this devices inputs */ |
ptpaterson | 10:ec59d628ebdc | 572 | if (inputChangeMask[0]) { |
ptpaterson | 10:ec59d628ebdc | 573 | /* scan through array of rules matching inputs and direction */ |
ptpaterson | 10:ec59d628ebdc | 574 | for (int ruleNum = 0; ruleNum < 24; ruleNum++) { |
ptpaterson | 10:ec59d628ebdc | 575 | |
ptpaterson | 10:ec59d628ebdc | 576 | /* check if rule enabled and input num matches */ |
ptpaterson | 10:ec59d628ebdc | 577 | if ((rules[ruleNum].sourceId & 0x80) && /* rule is active AND */ |
ptpaterson | 10:ec59d628ebdc | 578 | ((rules[ruleNum].sourceId & 0x7F) == nodeId) && /* rule source is this nodeId AND */ |
ptpaterson | 10:ec59d628ebdc | 579 | (inputChangeMask[0] & (1 << (rules[ruleNum].input & 0x1F)))) /* change exists at input num */ |
ptpaterson | 10:ec59d628ebdc | 580 | { |
ptpaterson | 10:ec59d628ebdc | 581 | |
ptpaterson | 10:ec59d628ebdc | 582 | int ruleActivity = rules[ruleNum].input >> 5; |
ptpaterson | 10:ec59d628ebdc | 583 | int inputActivity = (readInputBuffers[0] >> (rules[ruleNum].input & 0x1F)) & 1; |
ptpaterson | 10:ec59d628ebdc | 584 | |
ptpaterson | 10:ec59d628ebdc | 585 | if ((2 == ruleActivity) || (inputActivity == ruleActivity)) { |
ptpaterson | 10:ec59d628ebdc | 586 | writeOutputBuffers[0] |= rules[ruleNum].setMask[0]; |
ptpaterson | 10:ec59d628ebdc | 587 | //writeOutputBuffers[1] |= rules[ruleNum].setMask[1]; |
ptpaterson | 10:ec59d628ebdc | 588 | //writeOutputBuffers[2] |= rules[ruleNum].setMask[2]; |
ptpaterson | 10:ec59d628ebdc | 589 | |
ptpaterson | 10:ec59d628ebdc | 590 | writeOutputBuffers[0] &= ~rules[ruleNum].clearMask[0]; |
ptpaterson | 10:ec59d628ebdc | 591 | //writeOutputBuffers[1] &= ~rules[ruleNum].clearMask[1]; |
ptpaterson | 10:ec59d628ebdc | 592 | //writeOutputBuffers[2] &= ~rules[ruleNum].clearMask[2]; |
ptpaterson | 10:ec59d628ebdc | 593 | } |
ptpaterson | 10:ec59d628ebdc | 594 | } |
ptpaterson | 10:ec59d628ebdc | 595 | |
ptpaterson | 10:ec59d628ebdc | 596 | } |
ptpaterson | 10:ec59d628ebdc | 597 | } |
ptpaterson | 10:ec59d628ebdc | 598 | |
ptpaterson | 10:ec59d628ebdc | 599 | /* index 6005-01 configured to enable interrupt messages */ |
ptpaterson | 10:ec59d628ebdc | 600 | if (bInputInterruptEnable) { |
ptpaterson | 10:ec59d628ebdc | 601 | |
ptpaterson | 10:ec59d628ebdc | 602 | /* if change is within index 6006-01, interrupt mask */ |
ptpaterson | 10:ec59d628ebdc | 603 | if (inputChangeMask[0] & inputInterruptMask[0]) { |
ptpaterson | 10:ec59d628ebdc | 604 | |
ptpaterson | 10:ec59d628ebdc | 605 | /* send a message immediately */ |
ptpaterson | 10:ec59d628ebdc | 606 | PostTPDO(0x181); |
ptpaterson | 10:ec59d628ebdc | 607 | } |
ptpaterson | 10:ec59d628ebdc | 608 | |
ptpaterson | 10:ec59d628ebdc | 609 | } |
ptpaterson | 10:ec59d628ebdc | 610 | |
ptpaterson | 10:ec59d628ebdc | 611 | prevInputBuffers[0] = readInputBuffers[0]; |
ptpaterson | 10:ec59d628ebdc | 612 | } |
ptpaterson | 10:ec59d628ebdc | 613 | |
ptpaterson | 10:ec59d628ebdc | 614 | /****************************************************************************** |
ptpaterson | 10:ec59d628ebdc | 615 | * SYNC Implementation |
ptpaterson | 10:ec59d628ebdc | 616 | ****************************************************************************** |
ptpaterson | 10:ec59d628ebdc | 617 | */ |
ptpaterson | 10:ec59d628ebdc | 618 | |
ptpaterson | 10:ec59d628ebdc | 619 | void Node_pin0808::OnSync (uint8_t counter) |
ptpaterson | 10:ec59d628ebdc | 620 | { |
ptpaterson | 10:ec59d628ebdc | 621 | |
ptpaterson | 10:ec59d628ebdc | 622 | } |
ptpaterson | 10:ec59d628ebdc | 623 | |
ptpaterson | 10:ec59d628ebdc | 624 | /****************************************************************************** |
ptpaterson | 10:ec59d628ebdc | 625 | * NMT Control Implementation |
ptpaterson | 10:ec59d628ebdc | 626 | ****************************************************************************** |
ptpaterson | 10:ec59d628ebdc | 627 | */ |
ptpaterson | 10:ec59d628ebdc | 628 | |
ptpaterson | 10:ec59d628ebdc | 629 | void Node_pin0808::OnInitialize (void) |
ptpaterson | 10:ec59d628ebdc | 630 | { |
ptpaterson | 10:ec59d628ebdc | 631 | printf(" Node_pin0808::INITIALIZE!\r\n"); |
ptpaterson | 10:ec59d628ebdc | 632 | |
ptpaterson | 10:ec59d628ebdc | 633 | mbedOutputs = 0xFFFF; |
ptpaterson | 10:ec59d628ebdc | 634 | wait(1.0); |
ptpaterson | 10:ec59d628ebdc | 635 | mbedOutputs = 0; |
ptpaterson | 10:ec59d628ebdc | 636 | |
ptpaterson | 10:ec59d628ebdc | 637 | prevOutputBuffers[0] = 0; |
ptpaterson | 10:ec59d628ebdc | 638 | writeOutputBuffers[0] = 0; |
ptpaterson | 10:ec59d628ebdc | 639 | |
ptpaterson | 10:ec59d628ebdc | 640 | prevInputBuffers[0] = 0; |
ptpaterson | 10:ec59d628ebdc | 641 | readInputBuffers[0] = 0; |
ptpaterson | 10:ec59d628ebdc | 642 | } |
ptpaterson | 10:ec59d628ebdc | 643 | |
ptpaterson | 10:ec59d628ebdc | 644 | void Node_pin0808::OnPreoperational (void) |
ptpaterson | 10:ec59d628ebdc | 645 | { |
ptpaterson | 10:ec59d628ebdc | 646 | printf(" Node_pin0808::PRE-OPERATIONAL!\r\n"); |
ptpaterson | 10:ec59d628ebdc | 647 | } |
ptpaterson | 10:ec59d628ebdc | 648 | |
ptpaterson | 10:ec59d628ebdc | 649 | void Node_pin0808::OnOperational (void) |
ptpaterson | 10:ec59d628ebdc | 650 | { |
ptpaterson | 10:ec59d628ebdc | 651 | printf(" Node_pin0808::OPERATIONAL!\r\n"); |
ptpaterson | 10:ec59d628ebdc | 652 | |
ptpaterson | 10:ec59d628ebdc | 653 | mbedOutputs = (writeOutputBuffers[0] << 16); |
ptpaterson | 10:ec59d628ebdc | 654 | } |
ptpaterson | 10:ec59d628ebdc | 655 | |
ptpaterson | 10:ec59d628ebdc | 656 | void Node_pin0808::OnStopped (void) |
ptpaterson | 10:ec59d628ebdc | 657 | { |
ptpaterson | 10:ec59d628ebdc | 658 | printf(" Node_pin0808::STOPPED!\r\n"); |
ptpaterson | 10:ec59d628ebdc | 659 | |
ptpaterson | 10:ec59d628ebdc | 660 | mbedOutputs = 0; |
ptpaterson | 10:ec59d628ebdc | 661 | } |
ptpaterson | 10:ec59d628ebdc | 662 | |
ptpaterson | 10:ec59d628ebdc | 663 | /****************************************************************************** |
ptpaterson | 10:ec59d628ebdc | 664 | * Object Dictionary Handling |
ptpaterson | 10:ec59d628ebdc | 665 | ****************************************************************************** |
ptpaterson | 10:ec59d628ebdc | 666 | */ |
ptpaterson | 10:ec59d628ebdc | 667 | |
ptpaterson | 10:ec59d628ebdc | 668 | ObjectData * Node_pin0808::ScanIndex(IndexSize index) |
ptpaterson | 10:ec59d628ebdc | 669 | { |
ptpaterson | 10:ec59d628ebdc | 670 | ObjectData * result = 0; |
ptpaterson | 10:ec59d628ebdc | 671 | |
ptpaterson | 10:ec59d628ebdc | 672 | switch(index) { |
ptpaterson | 10:ec59d628ebdc | 673 | case 0x1200: result = &dictionary[0]; break; |
ptpaterson | 10:ec59d628ebdc | 674 | case 0x1400: result = &dictionary[1]; break; |
ptpaterson | 10:ec59d628ebdc | 675 | case 0x1401: result = &dictionary[2]; break; |
ptpaterson | 10:ec59d628ebdc | 676 | case 0x1402: result = &dictionary[3]; break; |
ptpaterson | 10:ec59d628ebdc | 677 | case 0x1403: result = &dictionary[4]; break; |
ptpaterson | 10:ec59d628ebdc | 678 | case 0x1600: result = &dictionary[5]; break; |
ptpaterson | 10:ec59d628ebdc | 679 | case 0x1601: result = &dictionary[6]; break; |
ptpaterson | 10:ec59d628ebdc | 680 | case 0x1602: result = &dictionary[7]; break; |
ptpaterson | 10:ec59d628ebdc | 681 | case 0x1603: result = &dictionary[8]; break; |
ptpaterson | 10:ec59d628ebdc | 682 | case 0x1800: result = &dictionary[10]; break; |
ptpaterson | 10:ec59d628ebdc | 683 | case 0x1A00: result = &dictionary[11]; break; |
ptpaterson | 10:ec59d628ebdc | 684 | case 0x2001: result = &dictionary[12]; break; |
ptpaterson | 10:ec59d628ebdc | 685 | case 0x2002: result = &dictionary[13]; break; |
ptpaterson | 10:ec59d628ebdc | 686 | case 0x2100: result = &dictionary[14]; break; |
ptpaterson | 10:ec59d628ebdc | 687 | case 0x2200: result = &dictionary[15]; break; |
ptpaterson | 10:ec59d628ebdc | 688 | case 0x6000: result = &dictionary[16]; break; |
ptpaterson | 10:ec59d628ebdc | 689 | case 0x6005: result = &dictionary[17]; break; |
ptpaterson | 10:ec59d628ebdc | 690 | case 0x6006: result = &dictionary[18]; break; |
ptpaterson | 10:ec59d628ebdc | 691 | case 0x6200: result = &dictionary[19]; break; |
ptpaterson | 10:ec59d628ebdc | 692 | default: |
ptpaterson | 10:ec59d628ebdc | 693 | // TODO add error handling |
ptpaterson | 10:ec59d628ebdc | 694 | break; |
ptpaterson | 10:ec59d628ebdc | 695 | } |
ptpaterson | 10:ec59d628ebdc | 696 | |
ptpaterson | 10:ec59d628ebdc | 697 | return result; |
ptpaterson | 10:ec59d628ebdc | 698 | } |
ptpaterson | 10:ec59d628ebdc | 699 | |
ptpaterson | 10:ec59d628ebdc | 700 | } /* namespace ppCANOpen */ |