From b984f62dfd6b2652e7165b69cc1bba3e8c467811 Mon Sep 17 00:00:00 2001 From: phdlee Date: Tue, 17 Jul 2018 20:13:06 +0900 Subject: [PATCH] Add I2C Scan, Change DSP Meter I2C --- ubitx_20/cat_libs.ino | 31 +++++++++++++++++++++++++++---- ubitx_20/ubitx.h | 3 ++- ubitx_20/ubitx_20.ino | 9 +++++++++ ubitx_20/ubitx_eemap.h | 5 ++++- ubitx_20/ubitx_lcd_nextion.ino | 2 +- ubitx_20/ubitx_si5351.ino | 3 ++- 6 files changed, 45 insertions(+), 8 deletions(-) diff --git a/ubitx_20/cat_libs.ino b/ubitx_20/cat_libs.ino index 3e71855..608af79 100644 --- a/ubitx_20/cat_libs.ino +++ b/ubitx_20/cat_libs.ino @@ -252,12 +252,35 @@ void ReadEEPRom() //for remove warnings. Serial.write(0x02); //STX checkSum = 0x02; - for (uint16_t i = 0; i < eepromReadLength; i++) + //I2C Scanner + //Magic Key Start 59414, Length : 48583 + //if (eepromStartIndex == 59414 && eepromReadLength == 48583) + if (CAT_BUFF[0] == 0x16 && CAT_BUFF[1] == 0xe8) { - read1Byte = EEPROM.read(eepromStartIndex + i); - checkSum += read1Byte; - Serial.write(read1Byte); + for (uint8_t i = 1; i < 127; i++) + { + Wire.beginTransmission(i); + read1Byte = Wire.endTransmission(); + if (read1Byte == 0) + { + Serial.write(i); + } + else + { + Serial.write(0); + } + } } + else + { + for (uint16_t i = 0; i < eepromReadLength; i++) + { + read1Byte = EEPROM.read(eepromStartIndex + i); + checkSum += read1Byte; + Serial.write(read1Byte); + } + } + Serial.write(checkSum); Serial.write(ACK); } diff --git a/ubitx_20/ubitx.h b/ubitx_20/ubitx.h index fe31e85..0c7f3e2 100644 --- a/ubitx_20/ubitx.h +++ b/ubitx_20/ubitx.h @@ -30,7 +30,6 @@ //#define UBITX_DISPLAY_LCD2004P //24 x 04 LCD (Parallel) //#define UBITX_DISPLAY_LCD2004I //I2C type 24 x 04 LCD #define UBITX_DISPLAY_NEXTION //NEXTION LCD -//#define UBITX_CONTROL_MCU //CONTROL MCU //#define UBITX_DISPLAY_NEXTION_SAFE //Only EEProm Write 770~775 #define I2C_LCD_MASTER_ADDRESS_DEFAULT 0x27 //0x27 //DEFAULT, if Set I2C Address by uBITX Manager, read from EEProm @@ -161,6 +160,8 @@ extern byte I2C_LCD_SECOND_ADDRESS; //only using Dual LCD Mode #define FKEY_TYPE_MAX 0x1F +extern uint8_t SI5351BX_ADDR; //change typical -> variable at Version 1.097, address read from eeprom, default value is 0x60 + //EEProm Address : 63 extern unsigned long frequency; extern byte WsprMSGCount; extern byte sMeterLevels[9]; diff --git a/ubitx_20/ubitx_20.ino b/ubitx_20/ubitx_20.ino index 0281112..06f8d2d 100644 --- a/ubitx_20/ubitx_20.ino +++ b/ubitx_20/ubitx_20.ino @@ -958,6 +958,15 @@ void initSettings(){ if (EEPROM.read(VERSION_ADDRESS) != FIRMWARE_VERSION_NUM) EEPROM.write(VERSION_ADDRESS, FIRMWARE_VERSION_NUM); + //SI5351 I2C Address + //I2C_ADDR_SI5351 + SI5351BX_ADDR = EEPROM.read(I2C_ADDR_SI5351); + if (SI5351BX_ADDR < 0x10 || SI5351BX_ADDR > 0xF0) + { + SI5351BX_ADDR = 0x60; + } + + //Backup Calibration Setting from Factory Setup //Check Factory Setting Backup Y/N if (EEPROM.read(FACTORY_BACKUP_YN) != 0x13) { diff --git a/ubitx_20/ubitx_eemap.h b/ubitx_20/ubitx_eemap.h index 0e15e2b..cc37111 100644 --- a/ubitx_20/ubitx_eemap.h +++ b/ubitx_20/ubitx_eemap.h @@ -35,10 +35,13 @@ //============================================================================== // The spare space available in the original firmware #1 -// Address : 32 ~ 63 +// Address : 32 ~ 62 //============================================================================== #define RESERVE_FOR_FACTORY1 32 +//SI5351 I2C Address (Version 1.097) +#define I2C_ADDR_SI5351 63 + //============================================================================== // The spare space available in the original firmware #2 // (Enabled if the EEProm address is insufficient) diff --git a/ubitx_20/ubitx_lcd_nextion.ino b/ubitx_20/ubitx_lcd_nextion.ino index 1ed8436..2fc746f 100644 --- a/ubitx_20/ubitx_lcd_nextion.ino +++ b/ubitx_20/ubitx_lcd_nextion.ino @@ -63,7 +63,7 @@ void LCD_Init(void) #define USE_I2CSMETER //S-Meter Address -#define I2CMETER_ADDR 0x6A +#define I2CMETER_ADDR 0x58 //VALUE TYPE============================================ //Signal #define I2CMETER_CALCS 0x59 //Calculated Signal Meter diff --git a/ubitx_20/ubitx_si5351.ino b/ubitx_20/ubitx_si5351.ino index 2708b36..049cf0b 100644 --- a/ubitx_20/ubitx_si5351.ino +++ b/ubitx_20/ubitx_si5351.ino @@ -47,7 +47,8 @@ #define BB1(x) ((uint8_t)(x>>8)) #define BB2(x) ((uint8_t)(x>>16)) -#define SI5351BX_ADDR 0x60 // I2C address of Si5351 (typical) +//#define SI5351BX_ADDR 0x60 // I2C address of Si5351 (typical) +uint8_t SI5351BX_ADDR; // I2C address of Si5351 (variable from Version 1.097) #define SI5351BX_XTALPF 2 // 1:6pf 2:8pf 3:10pf // If using 27mhz crystal, set XTAL=27000000, MSA=33. Then vco=891mhz