-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c0fe4a7
commit 13938de
Showing
44 changed files
with
3,114 additions
and
1,175 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
// --------------------------------------------------------------------------- | ||
// USB EPROM/Flash Programmer | ||
// | ||
// Copyright (2024) Robson Martins | ||
// | ||
// This work is licensed under a Creative Commons Attribution-NonCommercial- | ||
// ShareAlike 4.0 International License. | ||
// --------------------------------------------------------------------------- | ||
/** | ||
* @ingroup Firmware | ||
* @file modules/devcmd.hpp | ||
* @brief Header of the Device Commands. | ||
* | ||
* @author Robson Martins (https://www.robsonmartins.com) | ||
*/ | ||
// --------------------------------------------------------------------------- | ||
|
||
#ifndef MODULES_DEVCMD_HPP_ | ||
#define MODULES_DEVCMD_HPP_ | ||
|
||
// --------------------------------------------------------------------------- | ||
|
||
#include <cstdint> | ||
|
||
// --------------------------------------------------------------------------- | ||
|
||
/** @brief Defines a command to send to a device. */ | ||
typedef struct TDeviceCommand { | ||
/** @brief Address. */ | ||
uint32_t addr; | ||
/** @brief Data value. */ | ||
uint16_t data; | ||
} TDeviceCommand; | ||
|
||
// --------------------------------------------------------------------------- | ||
|
||
/** @brief Represents Any Address. */ | ||
#define ANY_ADDRESS static_cast<uint32_t>(-1) | ||
|
||
// --------------------------------------------------------------------------- | ||
// EPROM 27 | ||
// --------------------------------------------------------------------------- | ||
|
||
/** @brief EPROM 27E: Erase pulse duration, in milliseconds. */ | ||
constexpr uint32_t kDeviceErasePulseDuration27E = 100; | ||
|
||
// --------------------------------------------------------------------------- | ||
// EEPROM 28C | ||
// --------------------------------------------------------------------------- | ||
|
||
// clang-format off | ||
|
||
/** @brief Command sequence to Unprotect an EEPROM 28C/X28 64 | ||
(ST/Atmel/Xicor). */ | ||
constexpr TDeviceCommand kDeviceCmdUnprotect28C64[] = { | ||
{0x1555, 0xAA}, {0x0AAA, 0x55}, {0x1555, 0x80}, | ||
{0x1555, 0xAA}, {0x0AAA, 0x55}, {0x1555, 0x20} | ||
}; | ||
|
||
/** @brief Command sequence to Protect an EEPROM 28C/X28 64 | ||
(ST/Atmel/Xicor). */ | ||
constexpr TDeviceCommand kDeviceCmdProtect28C64[] = { | ||
{0x1555, 0xAA}, {0x0AAA, 0x55}, {0x1555, 0xA0} | ||
}; | ||
|
||
/** @brief Command sequence to Unprotect an EEPROM 28C/X28 256 | ||
(ST/Atmel/Xicor). */ | ||
constexpr TDeviceCommand kDeviceCmdUnprotect28C256[] = { | ||
{0x5555, 0xAA}, {0x2AAA, 0x55}, {0x5555, 0x80}, | ||
{0x5555, 0xAA}, {0x2AAA, 0x55}, {0x5555, 0x20} | ||
}; | ||
|
||
/** @brief Command sequence to Protect an EEPROM 28C/X28 256 | ||
(ST/Atmel/Xicor). */ | ||
constexpr TDeviceCommand kDeviceCmdProtect28C256[] = { | ||
{0x5555, 0xAA}, {0x2AAA, 0x55}, {0x5555, 0xA0} | ||
}; | ||
|
||
// clang-format on | ||
|
||
// --------------------------------------------------------------------------- | ||
// Flash 28F | ||
// --------------------------------------------------------------------------- | ||
|
||
/** @brief Flash 28F: Erase delay, in milliseconds. */ | ||
constexpr uint32_t kDeviceEraseDelay28F = 10; | ||
|
||
// clang-format off | ||
|
||
/** @brief Command sequence to Read a Flash 28F. */ | ||
constexpr TDeviceCommand kDeviceCmdRead28F[] = { | ||
{ANY_ADDRESS, 0x00} | ||
}; | ||
|
||
/** @brief Command sequence to Write a Flash 28F. */ | ||
constexpr TDeviceCommand kDeviceCmdWrite28F[] = { | ||
{ANY_ADDRESS, 0x40} | ||
}; | ||
|
||
/** @brief Command sequence to Verify a Flash 28F. */ | ||
constexpr TDeviceCommand kDeviceCmdVerify28F[] = { | ||
{ANY_ADDRESS, 0xC0} | ||
}; | ||
|
||
/** @brief Command sequence to Erase a Flash 28F. */ | ||
constexpr TDeviceCommand kDeviceCmdErase28F[] = { | ||
{ANY_ADDRESS, 0x20}, {ANY_ADDRESS, 0x20} | ||
}; | ||
|
||
/** @brief Command sequence to GetID a Flash 28F. */ | ||
constexpr TDeviceCommand kDeviceCmdGetId28F[] = { | ||
{0x00, 0x90} | ||
}; | ||
|
||
// clang-format on | ||
|
||
// --------------------------------------------------------------------------- | ||
// Flash SST28SF | ||
// --------------------------------------------------------------------------- | ||
|
||
// clang-format off | ||
|
||
/** @brief Command sequence to Read a Flash SST28SF. */ | ||
constexpr TDeviceCommand kDeviceCmdReadSST28SF[] = { | ||
{ANY_ADDRESS, 0xFF} | ||
}; | ||
|
||
/** @brief Command sequence to Write a Flash SST28SF. */ | ||
constexpr TDeviceCommand kDeviceCmdWriteSST28SF[] = { | ||
{ANY_ADDRESS, 0x10} | ||
}; | ||
|
||
/** @brief Command sequence to Erase a Flash SST28SF. | ||
* @details This erase a sector (256), not the full device. */ | ||
constexpr TDeviceCommand kDeviceCmdEraseSST28SF[] = { | ||
{ANY_ADDRESS, 0x20}, {ANY_ADDRESS, 0xD0} | ||
}; | ||
|
||
/** @brief Command sequence to GetID a Flash SST28SF. */ | ||
constexpr TDeviceCommand kDeviceCmdGetIdSST28SF[] = { | ||
{0x00, 0x90} | ||
}; | ||
|
||
// clang-format on | ||
|
||
// --------------------------------------------------------------------------- | ||
// Flash Am28F(A) | ||
// --------------------------------------------------------------------------- | ||
|
||
// clang-format off | ||
|
||
/** @brief Command sequence to Read a Flash Am28F(A). */ | ||
constexpr TDeviceCommand kDeviceCmdReadAm28F[] = { | ||
{ANY_ADDRESS, 0x00} | ||
}; | ||
|
||
/** @brief Command sequence to Write a Flash Am28F(A). */ | ||
constexpr TDeviceCommand kDeviceCmdWriteAm28F[] = { | ||
{ANY_ADDRESS, 0x10} | ||
}; | ||
|
||
/** @brief Command sequence to Erase a Flash Am28F(A). */ | ||
constexpr TDeviceCommand kDeviceCmdEraseAm28F[] = { | ||
{ANY_ADDRESS, 0x30}, {ANY_ADDRESS, 0x30} | ||
}; | ||
|
||
/** @brief Command sequence to GetID a Flash Am28F(A). */ | ||
constexpr TDeviceCommand kDeviceCmdGetIdAm28F[] = { | ||
{0x00, 0x90} | ||
}; | ||
|
||
// clang-format on | ||
|
||
// --------------------------------------------------------------------------- | ||
// Flash i28F | ||
// --------------------------------------------------------------------------- | ||
|
||
/** @brief Flash i28F Status Byte OK. */ | ||
constexpr uint8_t kDeviceStatusByteOkI28F = 0x80; | ||
|
||
// clang-format off | ||
|
||
/** @brief Command sequence to Read a Flash i28F. */ | ||
constexpr TDeviceCommand kDeviceCmdReadI28F[] = { | ||
{ANY_ADDRESS, 0xFF} | ||
}; | ||
|
||
/** @brief Command sequence to Write a Flash i28F. */ | ||
constexpr TDeviceCommand kDeviceCmdWriteI28F[] = { | ||
{ANY_ADDRESS, 0x40} | ||
}; | ||
|
||
/** @brief Command sequence to Erase a Flash i28F. | ||
* @details This erase a block (n bytes), not the full device. */ | ||
constexpr TDeviceCommand kDeviceCmdEraseI28F[] = { | ||
{ANY_ADDRESS, 0x20}, {ANY_ADDRESS, 0xD0} | ||
}; | ||
|
||
/** @brief Command sequence to GetID a Flash i28F. */ | ||
constexpr TDeviceCommand kDeviceCmdGetIdI28F[] = { | ||
{0x00, 0x90} | ||
}; | ||
|
||
// clang-format on | ||
|
||
// --------------------------------------------------------------------------- | ||
|
||
#endif // MODULES_DEVCMD_HPP_ |
Oops, something went wrong.