LCOV - code coverage report
Current view: top level - backend/devices/parallel - flash28f.cpp (source / functions) Hit Total Coverage
Test: "6f9243f" Lines: 64 66 97.0 %
Date: 2024-02-24 14:58:06 Functions: 20 20 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // ---------------------------------------------------------------------------
       2             : // USB EPROM/Flash Programmer
       3             : //
       4             : // Copyright (2024) Robson Martins
       5             : //
       6             : // This work is licensed under a Creative Commons Attribution-NonCommercial-
       7             : // ShareAlike 4.0 International License.
       8             : // ---------------------------------------------------------------------------
       9             : /**
      10             :  * @ingroup Software
      11             :  * @file backend/devices/parallel/flash28f.cpp
      12             :  * @brief Implementation of the Parallel Flash 28F.
      13             :  *
      14             :  * @author Robson Martins (https://www.robsonmartins.com)
      15             :  */
      16             : // ---------------------------------------------------------------------------
      17             : 
      18             : #include <QLoggingCategory>
      19             : #include "flash28f.hpp"
      20             : 
      21             : // ---------------------------------------------------------------------------
      22             : // Logging
      23             : 
      24          98 : Q_LOGGING_CATEGORY(deviceParFlash28F, "device.parallel.flash28f")
      25             : 
      26             : #define DEBUG qCDebug(deviceParFlash28F)
      27             : #define INFO qCInfo(deviceParFlash28F)
      28             : #define WARNING qCWarning(deviceParFlash28F)
      29             : #define CRITICAL qCCritical(deviceParFlash28F)
      30             : #define FATAL qCFatal(deviceParFlash28F)
      31             : 
      32             : // ---------------------------------------------------------------------------
      33             : 
      34           6 : Flash28F::Flash28F(QObject *parent) : ParDevice(parent) {
      35           6 :     info_.name = "Flash 28F";
      36           6 :     info_.capability.hasRead = true;
      37           6 :     info_.capability.hasProgram = true;
      38           6 :     info_.capability.hasVerify = true;
      39           6 :     info_.capability.hasBlankCheck = true;
      40           6 :     info_.capability.hasVDD = true;
      41           6 :     info_.capability.hasVPP = true;
      42           6 :     info_.capability.hasErase = true;
      43           6 :     info_.capability.hasGetId = true;
      44           6 :     vddRd_ = 5.0f;
      45           6 :     vddWr_ = 5.0f;
      46           6 :     vpp_ = 12.0f;
      47           6 :     vee_ = 12.0f;
      48           6 :     size_ = 2048;
      49           6 :     twp_ = 20;
      50           6 :     twc_ = 30;
      51           6 :     maxAttemptsProg_ = 3;
      52           6 :     flags_.progWithVpp = true;
      53           6 :     algo_ = kCmdDeviceAlgorithmFlash28F;
      54          12 :     DEBUG << info_.toString();
      55           6 : }
      56             : 
      57           7 : Flash28F::~Flash28F() {}
      58             : 
      59          36 : bool Flash28F::eraseDevice() {
      60          72 :     DEBUG << "Erasing data...";
      61             :     // Create a zeroes (0x00) buffer
      62          36 :     QByteArray data = QByteArray(size_, (char)0x00);
      63             :     // program entire device with 0x00
      64          36 :     if (!programDevice(data)) {
      65           0 :         WARNING << "Erase error";
      66           0 :         return false;
      67             :     }
      68             :     // call default erase routine
      69          36 :     return ParDevice::eraseDevice();
      70          36 : }
      71             : 
      72             : // ---------------------------------------------------------------------------
      73             : 
      74           1 : FlashSST28SF::FlashSST28SF(QObject *parent) : Flash28F(parent) {
      75           1 :     info_.capability.hasVPP = false;
      76           1 :     twp_ = 7;
      77           1 :     twc_ = 50;
      78           1 :     flags_.progWithVpp = false;
      79           1 :     algo_ = kCmdDeviceAlgorithmFlashSST28SF;
      80           2 :     DEBUG << info_.toString();
      81           1 : }
      82             : 
      83           2 : FlashSST28SF::~FlashSST28SF() {}
      84             : 
      85             : // ---------------------------------------------------------------------------
      86             : 
      87           1 : FlashAm28F::FlashAm28F(QObject *parent) : Flash28F(parent) {
      88           1 :     twp_ = 20;
      89           1 :     twc_ = 30;
      90           1 :     algo_ = kCmdDeviceAlgorithmFlashAm28F;
      91           2 :     DEBUG << info_.toString();
      92           1 : }
      93             : 
      94           2 : FlashAm28F::~FlashAm28F() {}
      95             : 
      96             : // ---------------------------------------------------------------------------
      97             : 
      98           3 : FlashI28F::FlashI28F(QObject *parent) : Flash28F(parent) {
      99           3 :     twp_ = 3;
     100           3 :     twc_ = 20;
     101           3 :     algo_ = kCmdDeviceAlgorithmFlashI28F;
     102           6 :     DEBUG << info_.toString();
     103           3 : }
     104             : 
     105           4 : FlashI28F::~FlashI28F() {}
     106             : 
     107             : // ---------------------------------------------------------------------------
     108             : 
     109           1 : FlashSharpI28F::FlashSharpI28F(QObject *parent) : FlashI28F(parent) {
     110           1 :     info_.capability.hasVPP = false;
     111           1 :     flags_.progWithVpp = false;
     112           2 :     DEBUG << info_.toString();
     113           1 : }
     114             : 
     115           2 : FlashSharpI28F::~FlashSharpI28F() {}
     116             : 
     117             : // ---------------------------------------------------------------------------
     118             : 
     119           1 : FlashI28F16Bit::FlashI28F16Bit(QObject *parent) : FlashI28F(parent) {
     120           1 :     flags_.is16bit = true;
     121           2 :     DEBUG << info_.toString();
     122           1 : }
     123             : 
     124           2 : FlashI28F16Bit::~FlashI28F16Bit() {}

Generated by: LCOV version 1.14