From 19f06fb3a2c4dfa32aa852d0639dc8be916583b1 Mon Sep 17 00:00:00 2001 From: joevt Date: Fri, 26 Apr 2024 18:12:06 -0700 Subject: [PATCH] escc: Init or reset values in constructor. Constructor should set all values to something so they are not random. --- devices/serial/escc.cpp | 6 +++++- devices/serial/escc.h | 10 +++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/devices/serial/escc.cpp b/devices/serial/escc.cpp index 0f8e778..eebaeac 100644 --- a/devices/serial/escc.cpp +++ b/devices/serial/escc.cpp @@ -60,13 +60,15 @@ EsccController::EsccController() ); this->ch_b->attach_backend(CHARIO_BE_NULL); - this->reg_ptr = WR0; // or RR0 + this->master_int_cntrl = 0; + this->reset(); } void EsccController::reset() { this->master_int_cntrl &= ~(WR9_NO_VECTOR | WR9_VECTOR_INCLUDES_STATUS); this->master_int_cntrl |= WR9_FORCE_HARDWARE_RESET; + this->reg_ptr = WR0; // or RR0 this->ch_a->reset(true); this->ch_b->reset(true); @@ -209,6 +211,8 @@ void EsccChannel::reset(bool hw_reset) We use hex values here instead of enums to more easily compare with the z85c30 data sheet. */ + + this->write_regs[WR0] = 0; this->write_regs[WR1] &= 0x24; this->write_regs[WR3] &= 0xFE; this->write_regs[WR4] |= 0x04; diff --git a/devices/serial/escc.h b/devices/serial/escc.h index 05fd21e..21d6cb4 100644 --- a/devices/serial/escc.h +++ b/devices/serial/escc.h @@ -134,9 +134,9 @@ private: DmaBidirChannel* dma_ch[2]; std::string name; - uint8_t read_regs[16]; - uint8_t write_regs[16]; - uint8_t wr7_enh; + uint8_t read_regs[16] = {}; + uint8_t write_regs[16] = {}; + uint8_t wr7_enh = 0; uint8_t dpll_active; DpllMode dpll_mode; uint8_t dpll_clock_src; @@ -177,8 +177,8 @@ private: int reg_ptr; // register pointer for reading/writing (same for both channels) - uint8_t master_int_cntrl; - uint8_t int_vec; + uint8_t master_int_cntrl = 0; + uint8_t int_vec = 0; }; #endif // ESCC_H