From b5f398261a0b7e374d4a60e354f7d678148f4e46 Mon Sep 17 00:00:00 2001 From: Mikhail Medvedev Date: Mon, 16 Sep 2024 12:54:13 +0300 Subject: [PATCH] Fix:incorrect reading of the DataFlash status register --- IMSProg_programmer/dialogsr.cpp | 22 +++++++++++++++++++++- IMSProg_programmer/dialogsr.h | 1 + IMSProg_programmer/dialogsr.ui | 6 +++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/IMSProg_programmer/dialogsr.cpp b/IMSProg_programmer/dialogsr.cpp index e6c9cec..1b4302c 100644 --- a/IMSProg_programmer/dialogsr.cpp +++ b/IMSProg_programmer/dialogsr.cpp @@ -44,7 +44,8 @@ void DialogSR::on_pushButton_read_clicked() if (stCH341 == 0) { SPI_CONTROLLER_Chip_Select_Low(); - SPI_CONTROLLER_Write_One_Byte(0x05); + if (currentChipType != 5) SPI_CONTROLLER_Write_One_Byte(0x05); + else SPI_CONTROLLER_Write_One_Byte(0xd7); retval = SPI_CONTROLLER_Read_NByte(buf,1,SPI_CONTROLLER_SPEED_SINGLE); qDebug() << "retval=" << retval; SPI_CONTROLLER_Chip_Select_High(); @@ -133,18 +134,37 @@ void DialogSR::setChipType(const uint chipType) case 3: ui->label_20->setText("/RDY"); ui->label_19->setText("WEN"); + ui->label_18->setText("BP0"); + ui->label_17->setText("BP1"); ui->label_13->setText("WPEN"); + ui->label_14->setText("X"); + ui->pushButton_write->setEnabled(true); break; case 4: ui->label_20->setText("WIP"); ui->label_19->setText("WEL"); + ui->label_18->setText("BP0"); + ui->label_17->setText("BP1"); ui->label_13->setText("SRWD"); + ui->label_14->setText("X"); + ui->pushButton_write->setEnabled(true); + break; + + case 5: + ui->label_20->setText("PAGE"); + ui->label_19->setText("WP"); + ui->label_18->setText("X"); + ui->label_17->setText("X"); + ui->label_13->setText("RDY"); + ui->label_14->setText("COMP"); + ui->pushButton_write->setEnabled(false); break; default: break; } + currentChipType = chipType; } void DialogSR::closeEvent(QCloseEvent* event) diff --git a/IMSProg_programmer/dialogsr.h b/IMSProg_programmer/dialogsr.h index c46bede..83eaf68 100644 --- a/IMSProg_programmer/dialogsr.h +++ b/IMSProg_programmer/dialogsr.h @@ -33,6 +33,7 @@ class DialogSR : public QDialog explicit DialogSR(QWidget *parent = nullptr); void setChipType(const uint chipType); void closeEvent(QCloseEvent* event); + uint currentChipType; ~DialogSR(); private slots: diff --git a/IMSProg_programmer/dialogsr.ui b/IMSProg_programmer/dialogsr.ui index 55f6a25..15046c1 100644 --- a/IMSProg_programmer/dialogsr.ui +++ b/IMSProg_programmer/dialogsr.ui @@ -561,7 +561,11 @@ background-color: rgb(120, 183, 140); border-radius: 20px; border: 2px solid #094065;border-radius:8px;font-weight:600; } -QPushButton::pressed{background-color: rgb(115, 210, 22);} +QPushButton::pressed{background-color: rgb(115, 210, 22);} +QPushButton:!enabled +{ + background-color:#ccc; +} Write