|
|
@ -273,4 +273,53 @@ void ZFPGACommander::RegInfo_Reset() { |
|
|
|
for (auto &it : m_reginfoMap) { |
|
|
|
it.second.dirty = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void ZFPGACommander::readFPGAVersion(Version &version) { |
|
|
|
uint32_t version32; |
|
|
|
readReg(kreg_fpga_version, version32, 100); |
|
|
|
} |
|
|
|
void ZFPGACommander::readStm32Version(Version &version) { |
|
|
|
uint32_t version32; |
|
|
|
readReg(kreg_software_version, version32, 100); |
|
|
|
} |
|
|
|
|
|
|
|
bool ZFPGACommander::ping() { |
|
|
|
try { |
|
|
|
Version version; |
|
|
|
readStm32Version(version); |
|
|
|
} catch (const std::exception &e) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
void ZFPGACommander::callcmd(uint32_t cmd, uint32_t delayms) { |
|
|
|
lock_guard<mutex> lock(m_tx_lock); |
|
|
|
|
|
|
|
uint8_t txdata[128] = {0}; |
|
|
|
|
|
|
|
zaf_packet_header_t *txpacket = (zaf_packet_header_t *)txdata; |
|
|
|
// zaf_packet_header_t *rxpacket = (zaf_packet_header_t *)&m_rxReceiptContext.receipt[0];
|
|
|
|
|
|
|
|
txpacket->packet_header = PACKET_HEADER; |
|
|
|
txpacket->packet_type = kzaf_packet_type_cmd; |
|
|
|
txpacket->index = ++txindex; |
|
|
|
txpacket->cmd = cmd; |
|
|
|
txpacket->ndata = 0; |
|
|
|
|
|
|
|
uint32_t txpacklen = PACKET_LEN(txpacket); |
|
|
|
uint8_t checksum = 0; |
|
|
|
for (uint32_t i = 2; i < txpacklen - 3; i++) { |
|
|
|
checksum += txdata[i]; |
|
|
|
} |
|
|
|
txdata[txpacklen - 3] = checksum; |
|
|
|
txdata[txpacklen - 2] = PACKET_TAIL & 0xFF; |
|
|
|
txdata[txpacklen - 1] = (PACKET_TAIL >> 8) & 0xFF; |
|
|
|
|
|
|
|
sendPacket(txpacket, txpacklen, delayms); |
|
|
|
} |
|
|
|
|
|
|
|
void ZFPGACommander::factoryReset() { callcmd(kzaf_cmd_factory_reset, 1500); } |
|
|
|
void ZFPGACommander::reboot() { callcmd(kzaf_cmd_reboot, 100); } |
|
|
|
void ZFPGACommander::storageConfigs() { callcmd(kzaf_cmd_storage_cfg, 1500); } |