Browse Source

读取寄存器 OK

master
zhaohe 1 year ago
parent
commit
9baaf4adc2
  1. 1
      mainwindow.cpp
  2. 37
      src/camera_light_src_timing_controller/clst_controler.cpp

1
mainwindow.cpp

@ -174,6 +174,7 @@ void MainWindow::constructUI() {
* *
*******************************************************************************/
ui->RegAdd->setText("0x00000000");
connect(ui->regReadKey, &QPushButton::clicked, this, [=](bool check) { //
uint32_t addr = str2int(ui->RegAdd->text());
uint32_t value = 0;

37
src/camera_light_src_timing_controller/clst_controler.cpp

@ -9,6 +9,8 @@ using namespace clst;
#define TAG "CLSTControler"
#define PACKET_LEN(__packet) (sizeof(zaf_packet_header_t) + __packet->ndata * 4 + 3)
CLSTControler *CLSTControler::ins() {
static CLSTControler *ins = nullptr;
if (ins == nullptr) {
@ -20,7 +22,7 @@ CLSTControler *CLSTControler::ins() {
void CLSTControler::initialize(IDataChannel *channel) { //
m_channel = channel;
m_channel->regRxListener([this](uint8_t *data, size_t len) {
ZLOGI(TAG, "Rx1.....");
// ZLOGI(TAG, "Rx1.....");
{
lock_guard<mutex> lock(lock_);
if (len + m_rxlen > sizeof(m_rxcache)) {
@ -111,17 +113,19 @@ void CLSTControler::processRxPacket(zaf_packet_header_t *packet) {
// for (uint32_t i = 0; i < packet->ndata; i++) {
// ZLOGI(TAG, " data[%d]:%d", i, packet->data[i]);
// }
ZLOGI(TAG, "Rx.....");
// ZLOGI(TAG, "Rx.....");
uint32_t packetlen = sizeof(zaf_packet_header_t) + packet->ndata * 4 + 3;
if (m_raw_data_cb) {
m_raw_data_cb(kuart_raw_rx, (uint8_t *)packet, sizeof(zaf_packet_header_t) + packet->ndata * 4 + 3);
m_raw_data_cb(kuart_raw_rx, (uint8_t *)packet, packetlen);
}
if (packet->packet_type == kzaf_packet_type_receipt) {
lock_guard<mutex> lock(m_rxReceiptContext_lock);
if (m_rxReceiptContext.waittingForReceipt) {
if (m_rxReceiptContext.waittingIndex == packet->index) {
m_rxReceiptContext.receiptIsReady = true;
m_rxReceiptContext.receiptLen = packet->ndata;
memcpy(m_rxReceiptContext.receipt, packet->data, packet->ndata);
m_rxReceiptContext.receiptLen = PACKET_LEN(packet);
memcpy(m_rxReceiptContext.receipt, packet, PACKET_LEN(packet));
}
m_rxReceiptContext.waittingForReceipt = false;
}
@ -150,15 +154,15 @@ zaf_error_code_t CLSTControler::sendPacket(zaf_packet_header_t *packet, uint32_t
}
if (m_raw_data_cb) {
m_raw_data_cb(kuart_raw_tx, (uint8_t *)packet, sizeof(zaf_packet_header_t) + packet->ndata * 4 + 3);
m_raw_data_cb(kuart_raw_tx, (uint8_t *)packet, PACKET_LEN(packet));
}
ZLOGI(TAG, "Tx.....");
// ZLOGI(TAG, "Tx.....");
m_channel->send((uint8_t *)packet, len);
for (size_t i = 0; i < overtime; i++) {
{
lock_guard<mutex> lock(m_rxReceiptContext_lock);
ZLOGI(TAG, "wait for ready %d", m_rxReceiptContext.receiptIsReady);
// ZLOGI(TAG, "wait for ready %d", m_rxReceiptContext.receiptIsReady);
if (m_rxReceiptContext.receiptIsReady) {
if (rxpacket->data[0] != 0) {
return (zaf_error_code_t)rxpacket->data[0];
@ -238,10 +242,23 @@ zaf_error_code_t CLSTControler::reg_read(uint32_t regadd, uint32_t &regvalue, in
}
regvalue = rxpacket->data[1];
// ZLOGI(TAG, "RX packet");
// ZLOGI(TAG, " type :%d", rxpacket->packet_type);
// ZLOGI(TAG, " index :%d", rxpacket->index);
// ZLOGI(TAG, " cmd :%d", rxpacket->cmd);
// ZLOGI(TAG, " ndata :%d", rxpacket->ndata);
// for (uint32_t i = 0; i < rxpacket->ndata; i++) {
// ZLOGI(TAG, " data[%d]:%d", i, rxpacket->data[i]);
// }
// ZLOGI(TAG, "RX:%d", regvalue);
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::factoryReset() {
lock_guard<mutex> lock(m_tx_lock);
uint8_t txdata[128] = {0};
zaf_packet_header_t *txpacket = (zaf_packet_header_t *)txdata;
@ -268,6 +285,8 @@ zaf_error_code_t CLSTControler::factoryReset() {
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::reboot() {
lock_guard<mutex> lock(m_tx_lock);
uint8_t txdata[128] = {0};
zaf_packet_header_t *txpacket = (zaf_packet_header_t *)txdata;
@ -294,6 +313,8 @@ zaf_error_code_t CLSTControler::reboot() {
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::storageConfigs() {
lock_guard<mutex> lock(m_tx_lock);
uint8_t txdata[128] = {0};
zaf_packet_header_t *txpacket = (zaf_packet_header_t *)txdata;

Loading…
Cancel
Save