diff options
| author | Ján Sučan <sucanjan@fit.cvut.cz> | 2017-05-10 15:13:29 +0200 |
|---|---|---|
| committer | Ján Sučan <sucanjan@fit.cvut.cz> | 2017-05-10 15:13:29 +0200 |
| commit | 02e24f0f533fe904c3a5275c4060c10c38d7c17a (patch) | |
| tree | 19d05c60e3d6a6782c4712de960a8f6705054063 /McuSt10f269 | |
Uvodny commit, subory su rovnake ako na CD prilozenom k vytlacenemu texu bakalarskej prace, naviac je pridany len subor LICENCIA
Diffstat (limited to 'McuSt10f269')
| -rwxr-xr-x | McuSt10f269/CMakeLists.txt | 26 | ||||
| -rwxr-xr-x | McuSt10f269/McuSt10f269.cpp | 102 | ||||
| -rwxr-xr-x | McuSt10f269/McuSt10f269.hpp | 25 |
3 files changed, 153 insertions, 0 deletions
diff --git a/McuSt10f269/CMakeLists.txt b/McuSt10f269/CMakeLists.txt new file mode 100755 index 0000000..b67a62f --- /dev/null +++ b/McuSt10f269/CMakeLists.txt @@ -0,0 +1,26 @@ +# Path to firmware binary files for ST10F269 +set (FwSt10f269Prefix ${FwPrefix}) +set(FwSt10f269 + ${FwSt10f269Prefix}/st10f269/Objects/st10f269.bin + ) + +# Generate firmware header files +include_directories (${CMAKE_CURRENT_BINARY_DIR}) + +generate_headers_from_binaries ( + "$<TARGET_FILE:xd>" + FwSt10f269 + "${FwSt10f269}" + "${CMAKE_CURRENT_BINARY_DIR}" +) + +add_library (McuSt10f269 STATIC + McuSt10f269.cpp + ${CMAKE_CURRENT_BINARY_DIR}/fw_st10f269.hpp +) + +set_target_properties (McuSt10f269 PROPERTIES + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF +) diff --git a/McuSt10f269/McuSt10f269.cpp b/McuSt10f269/McuSt10f269.cpp new file mode 100755 index 0000000..99c578d --- /dev/null +++ b/McuSt10f269/McuSt10f269.cpp @@ -0,0 +1,102 @@ +#include "Logger.hpp" +#include "McuSt10f269.hpp" +#include "fw_st10f269.hpp" + +using FwSt10f269::fw_st10f269; +using FwSt10f269::fw_st10f269_length; + +#define ST10F269_FLASH_SIZE (256 * 1024) +#define ST10F269_IDMANUF 0x0401 +#define ST10F269_IDCHIP 0x10D0 +#define ST10F269_ERASE_TIMEOUT 15000 // Ms + +#define RET_ERASE_ERROR 0x030 +#define RET_WRITE_ERROR 0x031 + +bool +CMcuSt10f269::hasThisId(uint16_t idmanuf, uint16_t idchip) +{ + // Mask out revision bits 3 - 0 from idchip value + return ((idmanuf == ST10F269_IDMANUF) + && ((idchip & 0xfff0) == ST10F269_IDCHIP)); +} + +CMcuSt10f269::CMcuSt10f269() +{ + mBlockSizes.push_back(16); + mBlockSizes.push_back(8); + mBlockSizes.push_back(8); + mBlockSizes.push_back(32); + mBlockSizes.push_back(64); + mBlockSizes.push_back(64); + mBlockSizes.push_back(64); +} + +CMcuSt10f269::~CMcuSt10f269() +{ + ; +} + +string +CMcuSt10f269::getName() +{ + return string("ST10F269"); +} + +uint8_t * +CMcuSt10f269::getFirmware() +{ + return fw_st10f269; +} + +int +CMcuSt10f269::getFirmwareLength() +{ + return fw_st10f269_length; +} + +const list<uint32_t> +CMcuSt10f269::getBlockSizes() +{ + return mBlockSizes; +} + +uint32_t +CMcuSt10f269::getFlashSize() +{ + return ST10F269_FLASH_SIZE; +} + +int +CMcuSt10f269::getEraseTimeout() +{ + return ST10F269_ERASE_TIMEOUT; +} + +string +CMcuSt10f269::getMessageForRetCode(uint16_t ret) +{ + string s; + + switch (ret) { + case RET_ERASE_ERROR: + s = "Error while erasing memory"; + break; + case RET_WRITE_ERROR: + s = "Error while writing memory"; + break; + default: + s = ""; + break; + } + + return s; +} + +const list<uint16_t> +CMcuSt10f269::getConfigData(float mcuFrequency) +{ + list<uint16_t> ret; + ret.push_back(0x00); // Any byte value + return ret; +} diff --git a/McuSt10f269/McuSt10f269.hpp b/McuSt10f269/McuSt10f269.hpp new file mode 100755 index 0000000..01063d6 --- /dev/null +++ b/McuSt10f269/McuSt10f269.hpp @@ -0,0 +1,25 @@ +#ifndef MCU_ST10F269_HPP +#define MCU_ST10F269_HPP + +#include "McuSpecifics.hpp" + +class CMcuSt10f269 : public IMcuSpecifics { +private: + list<uint32_t> mBlockSizes; +public: + static bool hasThisId(uint16_t idmanuf, uint16_t idchip); + + CMcuSt10f269(); + ~CMcuSt10f269(); + + string getName(); + uint8_t *getFirmware(); + int getFirmwareLength(); + const list<uint32_t> getBlockSizes(); + uint32_t getFlashSize(); + int getEraseTimeout(); + string getMessageForRetCode(uint16_t ret); + const list<uint16_t> getConfigData(float mcuFrequency); +}; + +#endif |
