Skip to content

Commit

Permalink
bugfix ccconf (write EEPROM fixed)
Browse files Browse the repository at this point in the history
  • Loading branch information
habeIchVergessen committed Aug 30, 2017
1 parent 3c24bd5 commit 3794e58
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
13 changes: 10 additions & 3 deletions SIGNALESP/SIGNALESP.ino
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define FIFO_LENGTH 200
#define DEBUG 1
#define _DEBUG_DEV_SERIAL
#define _CC1101_DEBUG_CONFIG


#define ETHERNET_PRINT
Expand Down Expand Up @@ -247,13 +248,14 @@ void loop() {
if (!command_available) { cmdstring = ""; }
blinkLED = true;
}

if (fifousage < FiFo.count())
fifousage = FiFo.count();
while (FiFo.count()>0) { //Puffer auslesen und an Dekoder uebergeben
while (FiFo.count()>0) { //Puffer auslesen und an Dekoder uebergeben
aktVal = FiFo.dequeue();
state = musterDec.decode(&aktVal);
if (state) blinkLED = true; //LED blinken, wenn Meldung dekodiert
if (FiFo.count()<120) yield();
// if (FiFo.count()<120) yield();
}

#ifdef _DEBUG_DEV_SERIAL
Expand All @@ -265,6 +267,9 @@ void loop() {
case 'c':
Serial.println("marc: 0x" + String(cc1101::currentMode(), HEX));
Serial.println("fifo: " + String(FiFo.count()) + ", max. " + String(fifousage));
#ifdef _CC1101_DEBUG_CONFIG
cc1101::dumpConfigRegister();
#endif
break;
case 'd':
dumpEEPROM();
Expand Down Expand Up @@ -648,7 +653,8 @@ void HandleCommand()
else if (isHexadecimalDigit(cmdstring.charAt(1)) && isHexadecimalDigit(cmdstring.charAt(2)) && isHexadecimalDigit(cmdstring.charAt(3)) && isHexadecimalDigit(cmdstring.charAt(4))) {
reg = cmdstringPos2int(1);
val = cmdstringPos2int(3);
EEPROM.write(reg, val);
EEPROM.write(reg+1, val); // scheinbar hat sich hier etwas um 1 Byte verschoben
EEPROM.commit();
if (hasCC1101) {
cc1101::writeCCreg(reg, val);
}
Expand Down Expand Up @@ -684,6 +690,7 @@ void HandleCommand()
}
else if (cmdstring.charAt(0) == cmd_ccFactoryReset && hasCC1101) {
cc1101::ccFactoryReset();
EEPROM.commit();
cc1101::CCinit();
}
#endif
Expand Down
21 changes: 21 additions & 0 deletions SIGNALESP/cc1101.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ namespace cc1101 {
0x00, // 28 RCCTRL0
};

// prototypes
#ifdef _CC1101_DEBUG_CONFIG
void dumpConfigRegister();
#endif

byte hex2int(byte hex) { // convert a hexdigit to int // Todo: printf oder scanf nutzen
if (hex >= '0' && hex <= '9') hex = hex - '0';
else if (hex >= 'a' && hex <= 'f') hex = hex - 'a' + 10;
Expand Down Expand Up @@ -392,6 +397,7 @@ namespace cc1101 {
EEPROM.write(EE_CC1100_PA + i, 0);
}
}
EEPROM.commit();
MSG_PRINTLN("ccFactoryReset done");
}

Expand Down Expand Up @@ -513,6 +519,9 @@ namespace cc1101 {
DBG_PRINTLN("POR Done");
delay(10);

#ifdef _CC1101_DEBUG_CONFIG
dumpConfigRegister();
#endif
cc1101_Select();

sendSPI(CC1100_WRITE_BURST);
Expand All @@ -528,6 +537,18 @@ namespace cc1101 {
setReceiveMode();
}

#ifdef _CC1101_DEBUG_CONFIG
void dumpConfigRegister() {
Serial.printf("\ndump config register:\n");
for (byte i=0; i<0x28; i++) {
Serial.printf("%02X ", readReg(i, CC1101_CONFIG));
if (i % 16 == 15)
Serial.printf("\n");
}
Serial.printf("\n");
}
#endif

bool regCheck()
{

Expand Down
13 changes: 6 additions & 7 deletions src/_micro-api/libraries/signalDecoder/src/signalDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ void SignalDetectorClass::processMessage()
MSG_WRITE(patternLow);
MSG_WRITE(highByte(patternInt) | B10000000);
MSG_PRINT(SERIAL_DELIMITER);
yield();
}

uint8_t n;
Expand Down Expand Up @@ -366,7 +365,6 @@ void SignalDetectorClass::processMessage()
MSG_PRINT(message[i]);
}

yield();
MSG_PRINT(SERIAL_DELIMITER);
MSG_PRINT("CP="); MSG_PRINT(clock); MSG_PRINT(SERIAL_DELIMITER); // ClockPulse
MSG_PRINT("SP="); MSG_PRINT(sync); MSG_PRINT(SERIAL_DELIMITER); // SyncPulse
Expand All @@ -389,6 +387,7 @@ void SignalDetectorClass::processMessage()

MSG_PRINT(MSG_END);
MSG_PRINT("\n");
yield();

success = true;

Expand Down Expand Up @@ -482,7 +481,7 @@ void SignalDetectorClass::processMessage()
MSG_PRINT("O");
MSG_PRINT(SERIAL_DELIMITER);
}
MSG_PRINTLN(MSG_END);
MSG_PRINTLN(MSG_END); yield();
#endif
MSG_PRINT(MSG_START);
MSG_PRINT("MC");
Expand All @@ -498,6 +497,7 @@ void SignalDetectorClass::processMessage()
MSG_PRINT("R="); MSG_PRINT(rssiValue); MSG_PRINT(SERIAL_DELIMITER); // Signal Level (RSSI)
MSG_PRINT(MSG_END);
MSG_PRINT("\n");
yield();

#ifdef DEBUGDECODE
DBG_PRINTLN("");
Expand Down Expand Up @@ -596,7 +596,7 @@ void SignalDetectorClass::processMessage()
if (m_overflow) {
MSG_PRINT("O"); MSG_PRINT(SERIAL_DELIMITER);
}
MSG_PRINT(MSG_END); MSG_PRINT("\n");
MSG_PRINT(MSG_END); MSG_PRINT("\n"); yield();

m_truncated = false;
success = true;
Expand Down Expand Up @@ -1030,7 +1030,7 @@ void ManchesterpatternDecoder::printMessageHexStr()
sprintf(hexStr, "%01X", getMCByte(idx) & 0xF);
MSG_PRINT(hexStr);
}
yield();
// yield();
}


Expand Down Expand Up @@ -1060,7 +1060,7 @@ void ManchesterpatternDecoder::printMessagePulseStr()
MSG_PRINT("LH="); MSG_PRINT(pdec->pattern[longhigh]); MSG_PRINT(SERIAL_DELIMITER);
MSG_PRINT("SL="); MSG_PRINT(pdec->pattern[shortlow]); MSG_PRINT(SERIAL_DELIMITER);
MSG_PRINT("SH="); MSG_PRINT(pdec->pattern[shorthigh]); MSG_PRINT(SERIAL_DELIMITER);
yield();
// yield();
}

/** @brief (one liner)
Expand Down Expand Up @@ -1319,7 +1319,6 @@ const bool ManchesterpatternDecoder::doDecode() {
}
//MSG_PRINT(" S MC ");
i++;
yield();
}
pdec->mend = i - (ht ? 0 : 1); // keep short in buffer;

Expand Down

0 comments on commit 3794e58

Please sign in to comment.