First Commit

Dependencies:   mbed Crypto_light mbed-rtos

Spin it 2 win it

Committer:
andrebharath
Date:
Tue Mar 20 15:00:09 2018 +0000
Revision:
18:05e5d280a082
Parent:
17:80159ace5ddf
Child:
19:526fd700e1b3
Fixes to PWM

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TrebleStick 0:88c3d6c8a4eb 1 #include "mbed.h"
andrebharath 3:2e32d7974962 2 #include "Crypto_light/hash/SHA256.h"
andrebharath 3:2e32d7974962 3 #include "mbed-rtos/rtos/rtos.h"
TrebleStick 0:88c3d6c8a4eb 4
TrebleStick 0:88c3d6c8a4eb 5 //Photointerrupter input pins
TrebleStick 0:88c3d6c8a4eb 6 #define I1pin D2
TrebleStick 0:88c3d6c8a4eb 7 #define I2pin D11
TrebleStick 0:88c3d6c8a4eb 8 #define I3pin D12
andrebharath 9:ecef1e8cbe3d 9
TrebleStick 0:88c3d6c8a4eb 10 //Incremental encoder input pins
TrebleStick 0:88c3d6c8a4eb 11 #define CHA D7
TrebleStick 12:1b2e2540e4e1 12 #define CHB D8
andrebharath 9:ecef1e8cbe3d 13
TrebleStick 0:88c3d6c8a4eb 14 //Motor Drive output pins //Mask in output byte
TrebleStick 0:88c3d6c8a4eb 15 #define L1Lpin D4 //0x01
TrebleStick 0:88c3d6c8a4eb 16 #define L1Hpin D5 //0x02
TrebleStick 0:88c3d6c8a4eb 17 #define L2Lpin D3 //0x04
TrebleStick 0:88c3d6c8a4eb 18 #define L2Hpin D6 //0x08
TrebleStick 0:88c3d6c8a4eb 19 #define L3Lpin D9 //0x10
TrebleStick 0:88c3d6c8a4eb 20 #define L3Hpin D10 //0x20
TrebleStick 0:88c3d6c8a4eb 21
andrebharath 9:ecef1e8cbe3d 22 #define CHAR_ARR_SIZE 18 //Max length of input codes
andrebharath 17:80159ace5ddf 23 #define MAX_PWM_PERIOD 2000
andrebharath 18:05e5d280a082 24 #define MAX_TORQUE 1000
andrebharath 3:2e32d7974962 25
TrebleStick 0:88c3d6c8a4eb 26 //Mapping from sequential drive states to motor phase outputs
TrebleStick 0:88c3d6c8a4eb 27 /*
TrebleStick 0:88c3d6c8a4eb 28 State L1 L2 L3
TrebleStick 0:88c3d6c8a4eb 29 0 H - L
TrebleStick 0:88c3d6c8a4eb 30 1 - H L
TrebleStick 0:88c3d6c8a4eb 31 2 L H -
TrebleStick 0:88c3d6c8a4eb 32 3 L - H
TrebleStick 0:88c3d6c8a4eb 33 4 - L H
TrebleStick 0:88c3d6c8a4eb 34 5 H L -
TrebleStick 0:88c3d6c8a4eb 35 6 - - -
TrebleStick 0:88c3d6c8a4eb 36 7 - - -
TrebleStick 0:88c3d6c8a4eb 37 */
TrebleStick 0:88c3d6c8a4eb 38 //Drive state to output table
TrebleStick 0:88c3d6c8a4eb 39 const int8_t driveTable[] = {0x12,0x18,0x09,0x21,0x24,0x06,0x00,0x00};
andrebharath 9:ecef1e8cbe3d 40
TrebleStick 0:88c3d6c8a4eb 41 //Mapping from interrupter inputs to sequential rotor states. 0x00 and 0x07 are not valid
TrebleStick 12:1b2e2540e4e1 42 const int8_t stateMap[] = {0x07,0x05,0x03,0x04,0x01,0x00,0x02,0x07};
TrebleStick 0:88c3d6c8a4eb 43 //const int8_t stateMap[] = {0x07,0x01,0x03,0x02,0x05,0x00,0x04,0x07}; //Alternative if phase order of input or drive is reversed
andrebharath 9:ecef1e8cbe3d 44
TrebleStick 0:88c3d6c8a4eb 45 //Phase lead to make motor spin
TrebleStick 0:88c3d6c8a4eb 46 const int8_t lead = 2; //2 for forwards, -2 for backwards
andrebharath 9:ecef1e8cbe3d 47
andrebharath 9:ecef1e8cbe3d 48 //Rotor offset at motor state 0
andrebharath 18:05e5d280a082 49 volatile int8_t orState = 0;
andrebharath 9:ecef1e8cbe3d 50
andrebharath 17:80159ace5ddf 51 //Set initial torque of 1000
andrebharath 18:05e5d280a082 52 volatile uint32_t torque = 1000;
andrebharath 17:80159ace5ddf 53
andrebharath 9:ecef1e8cbe3d 54
TrebleStick 12:1b2e2540e4e1 55 enum MSG {MSG_RESET, MSG_HASHCOUNT, MSG_NONCE_OK,
andrebharath 17:80159ace5ddf 56 MSG_OVERFLOW, MSG_ROT_PEN, MSG_MAX_SPD, MSG_NEW_KEY, MSG_INP_ERR,
andrebharath 17:80159ace5ddf 57 MSG_TEST, MSG_TORQUE};
andrebharath 9:ecef1e8cbe3d 58
andrebharath 3:2e32d7974962 59 //Instantiate the serial port
andrebharath 9:ecef1e8cbe3d 60 RawSerial pc(SERIAL_TX, SERIAL_RX);
andrebharath 9:ecef1e8cbe3d 61
andrebharath 9:ecef1e8cbe3d 62 //Status LED
andrebharath 9:ecef1e8cbe3d 63 DigitalOut led1(LED1);
andrebharath 9:ecef1e8cbe3d 64
andrebharath 9:ecef1e8cbe3d 65 //Photointerrupter inputs
andrebharath 9:ecef1e8cbe3d 66 InterruptIn I1(I1pin);
andrebharath 9:ecef1e8cbe3d 67 InterruptIn I2(I2pin);
andrebharath 9:ecef1e8cbe3d 68 InterruptIn I3(I3pin);
andrebharath 9:ecef1e8cbe3d 69
andrebharath 9:ecef1e8cbe3d 70 //Motor Drive outputs
andrebharath 17:80159ace5ddf 71 PwmOut L1L(L1Lpin);
andrebharath 9:ecef1e8cbe3d 72 DigitalOut L1H(L1Hpin);
andrebharath 17:80159ace5ddf 73 PwmOut L2L(L2Lpin);
andrebharath 9:ecef1e8cbe3d 74 DigitalOut L2H(L2Hpin);
andrebharath 17:80159ace5ddf 75 PwmOut L3L(L3Lpin);
andrebharath 9:ecef1e8cbe3d 76 DigitalOut L3H(L3Hpin);
andrebharath 9:ecef1e8cbe3d 77
TrebleStick 0:88c3d6c8a4eb 78
andrebharath 3:2e32d7974962 79
andrebharath 3:2e32d7974962 80 typedef struct {
andrebharath 3:2e32d7974962 81 uint8_t code;
TrebleStick 15:bd303ab8a21f 82 int32_t data;
andrebharath 3:2e32d7974962 83 } message_t ;
andrebharath 3:2e32d7974962 84
andrebharath 3:2e32d7974962 85 Mail<message_t,16> outMessages;
andrebharath 3:2e32d7974962 86
TrebleStick 12:1b2e2540e4e1 87
TrebleStick 15:bd303ab8a21f 88 void putMessage(uint8_t code, int32_t data) {//uint64_t
TrebleStick 12:1b2e2540e4e1 89 message_t *pMessage = outMessages.alloc();
TrebleStick 12:1b2e2540e4e1 90 pMessage->code = code;
TrebleStick 12:1b2e2540e4e1 91 pMessage->data = data;
TrebleStick 12:1b2e2540e4e1 92 outMessages.put(pMessage);
TrebleStick 12:1b2e2540e4e1 93 }
TrebleStick 12:1b2e2540e4e1 94
andrebharath 3:2e32d7974962 95 Thread commOutT;
andrebharath 3:2e32d7974962 96
TrebleStick 12:1b2e2540e4e1 97 void commOutFn() {
andrebharath 3:2e32d7974962 98 while(1) {
andrebharath 3:2e32d7974962 99 osEvent newEvent = outMessages.get();
andrebharath 3:2e32d7974962 100 message_t *pMessage = (message_t*)newEvent.value.p;
TrebleStick 15:bd303ab8a21f 101 pc.printf("Message: [%d], data: 0x%08x\r\n",
andrebharath 3:2e32d7974962 102 pMessage->code,pMessage->data);
andrebharath 3:2e32d7974962 103 outMessages.free(pMessage);
andrebharath 3:2e32d7974962 104 }
andrebharath 3:2e32d7974962 105 }
andrebharath 3:2e32d7974962 106
andrebharath 9:ecef1e8cbe3d 107
andrebharath 9:ecef1e8cbe3d 108
TrebleStick 14:66746291017c 109 //Global varible for the Bitcoin Key,maxspeed and rotations_pending
TrebleStick 12:1b2e2540e4e1 110 volatile uint64_t newKey = 0; //check initialise value? ****
TrebleStick 14:66746291017c 111 volatile float maxspeed = 0, rotations_pending = 0;
TrebleStick 14:66746291017c 112 //mutex variables
TrebleStick 14:66746291017c 113 Mutex newKey_mutex;
TrebleStick 14:66746291017c 114 Mutex maxspeed_mutex;
TrebleStick 14:66746291017c 115 Mutex rotations_pending_mutex;
andrebharath 9:ecef1e8cbe3d 116
andrebharath 9:ecef1e8cbe3d 117 //Instantiate a Queue to buffer incoming characters
andrebharath 9:ecef1e8cbe3d 118 Queue<void, 8> inCharQ;
andrebharath 9:ecef1e8cbe3d 119 //serial port ISR to receive each incoming byte and place into queue
andrebharath 9:ecef1e8cbe3d 120 void serialISR() {
andrebharath 9:ecef1e8cbe3d 121 uint8_t newChar = pc.getc();
andrebharath 9:ecef1e8cbe3d 122 inCharQ.put((void*)newChar);
andrebharath 9:ecef1e8cbe3d 123 }
andrebharath 9:ecef1e8cbe3d 124
andrebharath 9:ecef1e8cbe3d 125
andrebharath 9:ecef1e8cbe3d 126
andrebharath 9:ecef1e8cbe3d 127
andrebharath 9:ecef1e8cbe3d 128 Thread decodeT;
andrebharath 9:ecef1e8cbe3d 129
TrebleStick 14:66746291017c 130 void setNewCmd(char s[CHAR_ARR_SIZE])
TrebleStick 14:66746291017c 131 {
TrebleStick 14:66746291017c 132 uint64_t newKey_;
andrebharath 17:80159ace5ddf 133 uint32_t torque_;
TrebleStick 14:66746291017c 134 float maxspeed_, rotations_pending_;
TrebleStick 14:66746291017c 135 //R
TrebleStick 14:66746291017c 136 if (sscanf(s, "R%f", &rotations_pending_)) {
andrebharath 17:80159ace5ddf 137 rotations_pending_mutex.lock();
andrebharath 17:80159ace5ddf 138 rotations_pending = rotations_pending_;
andrebharath 17:80159ace5ddf 139 rotations_pending_mutex.unlock();
andrebharath 17:80159ace5ddf 140 putMessage(MSG_ROT_PEN, rotations_pending);
TrebleStick 14:66746291017c 141 //V
TrebleStick 14:66746291017c 142 } else if (sscanf(s, "V%f", &maxspeed_)) {
andrebharath 17:80159ace5ddf 143 maxspeed_mutex.lock();
andrebharath 17:80159ace5ddf 144 maxspeed = maxspeed_;
andrebharath 17:80159ace5ddf 145 maxspeed_mutex.unlock();
andrebharath 17:80159ace5ddf 146 putMessage(MSG_MAX_SPD, maxspeed);
TrebleStick 14:66746291017c 147 //K
TrebleStick 14:66746291017c 148 } else if (sscanf(s, "K%llx", &newKey_)) {
andrebharath 17:80159ace5ddf 149 newKey_mutex.lock();
andrebharath 17:80159ace5ddf 150 newKey = newKey_;
andrebharath 17:80159ace5ddf 151 newKey_mutex.unlock();
andrebharath 17:80159ace5ddf 152 putMessage(MSG_NEW_KEY, newKey);
andrebharath 17:80159ace5ddf 153 } else if (sscanf(s, "T%u", &torque_)) {
andrebharath 17:80159ace5ddf 154 torque = torque_;
andrebharath 17:80159ace5ddf 155 putMessage(MSG_TORQUE, torque);
TrebleStick 14:66746291017c 156 //ERROR
TrebleStick 14:66746291017c 157 } else
TrebleStick 14:66746291017c 158 putMessage(MSG_INP_ERR, 0x404);
TrebleStick 14:66746291017c 159 }
TrebleStick 12:1b2e2540e4e1 160
andrebharath 9:ecef1e8cbe3d 161
andrebharath 9:ecef1e8cbe3d 162
andrebharath 9:ecef1e8cbe3d 163 void decodeFn() {
andrebharath 9:ecef1e8cbe3d 164 pc.attach(&serialISR);
andrebharath 9:ecef1e8cbe3d 165 char charSeq[CHAR_ARR_SIZE] = "";
andrebharath 9:ecef1e8cbe3d 166 uint8_t bufPos = 0;
andrebharath 9:ecef1e8cbe3d 167 while(1) {
TrebleStick 12:1b2e2540e4e1 168
andrebharath 9:ecef1e8cbe3d 169 if(bufPos >= CHAR_ARR_SIZE) {
andrebharath 9:ecef1e8cbe3d 170 putMessage(MSG_OVERFLOW, bufPos);
TrebleStick 12:1b2e2540e4e1 171 bufPos = 0;
andrebharath 9:ecef1e8cbe3d 172 }
TrebleStick 13:ecccfc611025 173 else{
TrebleStick 12:1b2e2540e4e1 174
TrebleStick 13:ecccfc611025 175 osEvent newEvent = inCharQ.get();
TrebleStick 13:ecccfc611025 176 uint8_t newChar = (uint8_t)newEvent.value.p;
TrebleStick 12:1b2e2540e4e1 177
TrebleStick 13:ecccfc611025 178 if(newChar == '\r' || newChar == '\n') {
TrebleStick 13:ecccfc611025 179 charSeq[bufPos] = '\0';
TrebleStick 13:ecccfc611025 180 bufPos = 0;
TrebleStick 13:ecccfc611025 181 setNewCmd(charSeq);
TrebleStick 13:ecccfc611025 182 }
TrebleStick 13:ecccfc611025 183 else {
TrebleStick 13:ecccfc611025 184 charSeq[bufPos] = newChar;
TrebleStick 13:ecccfc611025 185 bufPos++;
TrebleStick 13:ecccfc611025 186 }
TrebleStick 12:1b2e2540e4e1 187 }
andrebharath 9:ecef1e8cbe3d 188 }
andrebharath 9:ecef1e8cbe3d 189 }
andrebharath 9:ecef1e8cbe3d 190
andrebharath 9:ecef1e8cbe3d 191
andrebharath 9:ecef1e8cbe3d 192
andrebharath 9:ecef1e8cbe3d 193
andrebharath 9:ecef1e8cbe3d 194
andrebharath 3:2e32d7974962 195 volatile uint16_t hashcount = 0;
TrebleStick 0:88c3d6c8a4eb 196
andrebharath 9:ecef1e8cbe3d 197 void do_hashcount() {
TrebleStick 15:bd303ab8a21f 198 //putMessage(MSG_HASHCOUNT, hashcount);
andrebharath 3:2e32d7974962 199 hashcount = 0;
andrebharath 3:2e32d7974962 200 }
andrebharath 9:ecef1e8cbe3d 201
andrebharath 9:ecef1e8cbe3d 202
TrebleStick 0:88c3d6c8a4eb 203 //Set a given drive state
andrebharath 17:80159ace5ddf 204 void motorOut(int8_t driveState, uint32_t t){
TrebleStick 12:1b2e2540e4e1 205
TrebleStick 0:88c3d6c8a4eb 206 //Lookup the output byte from the drive state.
TrebleStick 0:88c3d6c8a4eb 207 int8_t driveOut = driveTable[driveState & 0x07];
TrebleStick 12:1b2e2540e4e1 208
TrebleStick 0:88c3d6c8a4eb 209 //Turn off first
andrebharath 17:80159ace5ddf 210 if (~driveOut & 0x01) L1L.pulsewidth_us(0);
TrebleStick 0:88c3d6c8a4eb 211 if (~driveOut & 0x02) L1H = 1;
andrebharath 17:80159ace5ddf 212 if (~driveOut & 0x04) L2L.pulsewidth_us(0);
TrebleStick 0:88c3d6c8a4eb 213 if (~driveOut & 0x08) L2H = 1;
andrebharath 17:80159ace5ddf 214 if (~driveOut & 0x10) L3L.pulsewidth_us(0);
TrebleStick 0:88c3d6c8a4eb 215 if (~driveOut & 0x20) L3H = 1;
TrebleStick 12:1b2e2540e4e1 216
TrebleStick 0:88c3d6c8a4eb 217 //Then turn on
andrebharath 17:80159ace5ddf 218 if (driveOut & 0x01) L1L.pulsewidth_us(t);
TrebleStick 0:88c3d6c8a4eb 219 if (driveOut & 0x02) L1H = 0;
andrebharath 17:80159ace5ddf 220 if (driveOut & 0x04) L2L.pulsewidth_us(t);
TrebleStick 0:88c3d6c8a4eb 221 if (driveOut & 0x08) L2H = 0;
andrebharath 17:80159ace5ddf 222 if (driveOut & 0x10) L3L.pulsewidth_us(t);
TrebleStick 0:88c3d6c8a4eb 223 if (driveOut & 0x20) L3H = 0;
andrebharath 17:80159ace5ddf 224 }
TrebleStick 12:1b2e2540e4e1 225
andrebharath 9:ecef1e8cbe3d 226 //Convert photointerrupter inputs to a rotor state
andrebharath 9:ecef1e8cbe3d 227 inline int8_t readRotorState(){
TrebleStick 0:88c3d6c8a4eb 228 return stateMap[I1 + 2*I2 + 4*I3];
andrebharath 17:80159ace5ddf 229 }
andrebharath 9:ecef1e8cbe3d 230
TrebleStick 12:1b2e2540e4e1 231 //Basic synchronisation routine
andrebharath 9:ecef1e8cbe3d 232 int8_t motorHome() {
TrebleStick 0:88c3d6c8a4eb 233 //Put the motor in drive state 0 and wait for it to stabilise
andrebharath 18:05e5d280a082 234 motorOut(0, MAX_TORQUE);
andrebharath 3:2e32d7974962 235 wait(2.0);
TrebleStick 12:1b2e2540e4e1 236
TrebleStick 0:88c3d6c8a4eb 237 //Get the rotor state
TrebleStick 0:88c3d6c8a4eb 238 return readRotorState();
TrebleStick 0:88c3d6c8a4eb 239 }
andrebharath 3:2e32d7974962 240
andrebharath 3:2e32d7974962 241 void photointerrupter_isr()
andrebharath 3:2e32d7974962 242 {
andrebharath 3:2e32d7974962 243 int8_t intState = readRotorState();
andrebharath 17:80159ace5ddf 244 motorOut((intState-orState+lead+6)%6, torque); //+6 to make sure the remainder is positive
andrebharath 3:2e32d7974962 245 }
andrebharath 9:ecef1e8cbe3d 246
TrebleStick 12:1b2e2540e4e1 247
TrebleStick 0:88c3d6c8a4eb 248 //Main
andrebharath 9:ecef1e8cbe3d 249 int main() {
TrebleStick 12:1b2e2540e4e1 250
andrebharath 9:ecef1e8cbe3d 251 putMessage(MSG_RESET, 0);
andrebharath 9:ecef1e8cbe3d 252
TrebleStick 12:1b2e2540e4e1 253
andrebharath 9:ecef1e8cbe3d 254 commOutT.start(&commOutFn);
TrebleStick 12:1b2e2540e4e1 255
TrebleStick 12:1b2e2540e4e1 256 decodeT.start(&decodeFn);
TrebleStick 12:1b2e2540e4e1 257
andrebharath 9:ecef1e8cbe3d 258 // pc.printf("Hello\n\r");
TrebleStick 12:1b2e2540e4e1 259
andrebharath 9:ecef1e8cbe3d 260 //Run the motor synchronisation
andrebharath 9:ecef1e8cbe3d 261 orState = motorHome();
andrebharath 9:ecef1e8cbe3d 262 // pc.printf("Rotor origin: %x\n\r",orState);
andrebharath 9:ecef1e8cbe3d 263 //orState is subtracted from future rotor state inputs to align rotor and motor states
TrebleStick 12:1b2e2540e4e1 264
andrebharath 3:2e32d7974962 265 I1.rise(&photointerrupter_isr);
andrebharath 3:2e32d7974962 266 I2.rise(&photointerrupter_isr);
andrebharath 3:2e32d7974962 267 I3.rise(&photointerrupter_isr);
TrebleStick 12:1b2e2540e4e1 268
andrebharath 3:2e32d7974962 269 I1.fall(&photointerrupter_isr);
andrebharath 3:2e32d7974962 270 I2.fall(&photointerrupter_isr);
andrebharath 3:2e32d7974962 271 I3.fall(&photointerrupter_isr);
TrebleStick 12:1b2e2540e4e1 272
andrebharath 18:05e5d280a082 273
andrebharath 18:05e5d280a082 274 L1L.period_us(MAX_PWM_PERIOD);
andrebharath 18:05e5d280a082 275 L2L.period_us(MAX_PWM_PERIOD);
andrebharath 18:05e5d280a082 276 L3L.period_us(MAX_PWM_PERIOD);
andrebharath 18:05e5d280a082 277
andrebharath 9:ecef1e8cbe3d 278 //Calling the ISR once starts the motor movement
andrebharath 9:ecef1e8cbe3d 279 photointerrupter_isr();
andrebharath 17:80159ace5ddf 280
andrebharath 17:80159ace5ddf 281
TrebleStick 12:1b2e2540e4e1 282
andrebharath 9:ecef1e8cbe3d 283 SHA256 sha256;
TrebleStick 12:1b2e2540e4e1 284
andrebharath 3:2e32d7974962 285 uint8_t sequence[] = {0x45,0x6D,0x62,0x65,0x64,0x64,0x65,0x64,
andrebharath 3:2e32d7974962 286 0x20,0x53,0x79,0x73,0x74,0x65,0x6D,0x73,
andrebharath 3:2e32d7974962 287 0x20,0x61,0x72,0x65,0x20,0x66,0x75,0x6E,
andrebharath 3:2e32d7974962 288 0x20,0x61,0x6E,0x64,0x20,0x64,0x6F,0x20,
andrebharath 3:2e32d7974962 289 0x61,0x77,0x65,0x73,0x6F,0x6D,0x65,0x20,
andrebharath 3:2e32d7974962 290 0x74,0x68,0x69,0x6E,0x67,0x73,0x21,0x20,
andrebharath 3:2e32d7974962 291 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
andrebharath 3:2e32d7974962 292 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
andrebharath 3:2e32d7974962 293 uint64_t* key = (uint64_t*)((int)sequence + 48);
andrebharath 3:2e32d7974962 294 uint64_t* nonce = (uint64_t*)((int)sequence + 56);
andrebharath 3:2e32d7974962 295 uint8_t hash[32];
TrebleStick 12:1b2e2540e4e1 296
andrebharath 9:ecef1e8cbe3d 297 Ticker hashcounter;
andrebharath 9:ecef1e8cbe3d 298 hashcounter.attach(&do_hashcount, 1.0);
TrebleStick 12:1b2e2540e4e1 299
TrebleStick 0:88c3d6c8a4eb 300 //Poll the rotor state and set the motor outputs accordingly to spin the motor
TrebleStick 0:88c3d6c8a4eb 301 while (1) {
TrebleStick 12:1b2e2540e4e1 302
andrebharath 9:ecef1e8cbe3d 303 *key = newKey;
TrebleStick 12:1b2e2540e4e1 304
TrebleStick 14:66746291017c 305
TrebleStick 14:66746291017c 306
TrebleStick 12:1b2e2540e4e1 307
andrebharath 9:ecef1e8cbe3d 308 sha256.computeHash(hash, sequence, 64);
TrebleStick 12:1b2e2540e4e1 309
andrebharath 3:2e32d7974962 310 if (hash[0] == 0 && hash[1] == 0) {
TrebleStick 15:bd303ab8a21f 311 //putMessage(MSG_NONCE_OK, *nonce);
andrebharath 3:2e32d7974962 312 }
andrebharath 3:2e32d7974962 313
andrebharath 3:2e32d7974962 314 (*nonce)++;
andrebharath 3:2e32d7974962 315 hashcount++;
TrebleStick 0:88c3d6c8a4eb 316 }
TrebleStick 0:88c3d6c8a4eb 317 }
andrebharath 9:ecef1e8cbe3d 318
TrebleStick 12:1b2e2540e4e1 319
TrebleStick 12:1b2e2540e4e1 320 // K12345678\r
TrebleStick 12:1b2e2540e4e1 321 // K12345678