Skip to content

Commit

Permalink
Revert "Improve debug environment (#130)" (#149)
Browse files Browse the repository at this point in the history
This reverts commit 06e76d2.
  • Loading branch information
dmohns authored Dec 20, 2023
1 parent 74e2c56 commit 5d4ed2b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 39 deletions.
16 changes: 8 additions & 8 deletions firmware/src/SAM_UART.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ unsigned short ATM90E26_UART::AFECHIP(unsigned char RW, unsigned char address,
output = (MSByte << 8) | LSByte; // join MSB and LSB;
return output;
}
Serial2.println("Read failed");
Serial.println("Read failed");
delay(20); // Delay from failed transaction
return 0xFFFF;
}
Expand All @@ -45,7 +45,7 @@ unsigned short ATM90E26_UART::AFECHIP(unsigned char RW, unsigned char address,
else {
byte atm90_chksum = ATM_UART->read();
if (atm90_chksum != host_chksum) {
Serial2.println("Write failed");
Serial.println("Write failed");
delay(20); // Delay from failed transaction
}
}
Expand Down Expand Up @@ -148,8 +148,8 @@ void ATM90E26_UART::SET_register_values() {
// See pg 31 of datasheet.
AFECHIP(0, CSOne, 0x327C); // Write CSOne, as self calculated

Serial2.print("Checksum 1:");
Serial2.println(
Serial.print("Checksum 1:");
Serial.println(
AFECHIP(1, CSOne, 0x0000),
HEX); // Checksum 1. Needs to be calculated based off the above values.

Expand Down Expand Up @@ -178,8 +178,8 @@ void ATM90E26_UART::SET_register_values() {
0, CSTwo,
0x993B); // mt50, 0x13B5 Write CSTwo 0x6BB9, as self calculated 0x7F75

Serial2.print("Checksum 2:");
Serial2.println(
Serial.print("Checksum 2:");
Serial.println(
AFECHIP(1, CSTwo, 0x0000),
HEX); // Checksum 2. Needs to be calculated based off the above values.

Expand All @@ -190,10 +190,10 @@ void ATM90E26_UART::SET_register_values() {
systemstatus = FETCH_SysStatus();
if (systemstatus & 0xC000) {
// checksum 1 error
Serial2.println("Checksum 1 Error!!");
Serial.println("Checksum 1 Error!!");
}
if (systemstatus & 0x3000) {
// checksum 2 error
Serial2.println("Checksum 2 Error!!");
Serial.println("Checksum 2 Error!!");
}
}
48 changes: 17 additions & 31 deletions firmware/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,8 @@ void setup() {
pinMode(red_led, OUTPUT);
pinMode(green_led, OUTPUT);

Serial2.begin(115200);
Serial2.print("Device Powered! \n");
digitalWrite(buzzer, HIGH);

// Display Intro Screen.
Serial2.print("Setting up LCD... \n");
lcd.createChar(0, fe1);
lcd.createChar(1, fe2);
lcd.createChar(2, fe3);
Expand All @@ -69,8 +65,6 @@ void setup() {
lcd.setCursor(0, 1);
lcd.print(" FIRST ELECTRIC ");

delay(2000);

lcd.clear();
lcd.setCursor(7, 0);
lcd.write(byte(0));
Expand All @@ -81,23 +75,25 @@ void setup() {
lcd.setCursor(8, 1);
lcd.write(byte(3));

Serial2.print("LCD Setup complete! \n");

ATM90E26.begin(9600);
AFE_chip.SET_register_values();
delay(1000);
digitalWrite(buzzer, LOW);

// Begin Device Initialization.
lcd.setCursor(0, 0);
lcd.print(" SYSTEM BOOTING ");
lcd.setCursor(0, 1);
lcd.print(" #------------# ");

// Configure GSM modem.
Serial2.println("Initializing modem...");
Serial2.begin(115200);
Serial2.print("working");
Serial1.begin(115200);
delay(3000);
Serial1.write("AT+IPR=9600\r\n");
Serial1.end();
Serial1.begin(9600);

lcd.setCursor(0, 0);
lcd.print(" SYSTEM BOOTING ");
lcd.setCursor(0, 1);
lcd.print(" ## ");

Serial2.println("Initializing modem...");
modem.restart();
String modemInfo = modem.getModemInfo();
lcd.setCursor(0, 0);
Expand All @@ -114,25 +110,17 @@ void setup() {
delay(2000);
lcd.clear();

// Configure RTC
while (rtc.begin() == false) {
if (!rtc.begin()) {
lcd.print("Couldn't find RTC");
delay(2000);
while (1)
;
}
if (!rtc.isrunning()) {
lcd.print("RTC is NOT running!");
delay(2000);
}
initializeTime();

// Configure AFE
Serial2.print("Setting up AFE... \n");
ATM90E26.begin(9600);
AFE_chip.SET_register_values();
delay(1000);
Serial2.print("AFE Setup Complete! \n");

// Get Meter AFE checksum
lcd.setCursor(0, 0);
lcd.print("CSOne : ");
lcd.setCursor(8, 0);
Expand All @@ -142,9 +130,9 @@ void setup() {
lcd.print("CSTwo : ");
lcd.setCursor(8, 1);
lcd.print(AFE_chip.FETCH_MeterCSTwo());
delay(3000);
delay(1000);

// Configure EEPROM
// rtc eeprom
// mem.writeLong(credit_eeprom_location, 200);
// mem.writeLong(eeprom_location_cnt, token_eeprom_location);
// delay(20);
Expand Down Expand Up @@ -190,8 +178,6 @@ void setup() {
LoadActivationVariables(); // We load the activation variableS
break;
}

Serial2.println("Setup Complete! \n");
}

void loop() {
Expand Down

0 comments on commit 5d4ed2b

Please sign in to comment.