diff --git a/devices/viacuda.cpp b/devices/viacuda.cpp index 4fc4f13..6ceed67 100644 --- a/devices/viacuda.cpp +++ b/devices/viacuda.cpp @@ -65,7 +65,7 @@ void ViaCuda::init() this->treq = 1; this->in_count = 0; this->out_count = 0; - + this->poll_rate = 11; } uint8_t ViaCuda::read(int reg) @@ -337,17 +337,14 @@ void ViaCuda::process_adb_command(uint8_t cmd_byte, int data_count) void ViaCuda::pseudo_command(int cmd, int data_count) { switch (cmd) { - case CUDA_START_STOP_AUTO_POLL: - response_header(CUDA_PKT_PSEUDO, 0); - if (this->pram_obj->read_byte(this->in_buf[2])) { - if (this->via_regs[VIA_B] & 0x8) { - LOG_F(INFO, "Auto-polling started \n"); - this->via_regs[VIA_ACR] |= 0x10; - this->via_regs[VIA_SR] |= CUDA_PKT_PSEUDO; - this->via_regs[VIA_B] &= ~0x20; - } + case CUDA_START_STOP_AUTOPOLL: + if (this->in_buf[2]) { + LOG_F(INFO, "Cuda: autopoll started, rate: %dms", this->poll_rate); } - + else { + LOG_F(INFO, "Cuda: autopoll stopped"); + } + response_header(CUDA_PKT_PSEUDO, 0); break; case CUDA_READ_PRAM: response_header(CUDA_PKT_PSEUDO, 0); @@ -357,14 +354,15 @@ void ViaCuda::pseudo_command(int cmd, int data_count) response_header(CUDA_PKT_PSEUDO, 0); this->pram_obj->write_byte(this->in_buf[2], this->in_buf[3]); break; - case CUDA_SET_AUTO_RATE: + case CUDA_SET_AUTOPOLL_RATE: + this->poll_rate = this->in_buf[2]; + LOG_F(INFO, "Cuda: autopoll rate set to: %d", this->poll_rate); response_header(CUDA_PKT_PSEUDO, 0); - this->pram_obj->write_byte(this->in_buf[2], this->in_buf[3]); - LOG_F(INFO, "Auto Rate set to: %d \n", this->in_buf[3]); break; - case CUDA_GET_AUTO_RATE: + case CUDA_GET_AUTOPOLL_RATE: response_header(CUDA_PKT_PSEUDO, 0); - this->pram_obj->read_byte(this->in_buf[2]); + this->out_buf[3] = this->poll_rate; + this->out_count++; break; case CUDA_READ_WRITE_I2C: response_header(CUDA_PKT_PSEUDO, 0); diff --git a/devices/viacuda.h b/devices/viacuda.h index 36d8133..68d5b59 100644 --- a/devices/viacuda.h +++ b/devices/viacuda.h @@ -88,11 +88,11 @@ enum { /** Cuda pseudo commands. */ enum { - CUDA_START_STOP_AUTO_POLL = 0x01, /* start/stop device auto-polling */ + CUDA_START_STOP_AUTOPOLL = 0x01, /* start/stop device auto-polling */ CUDA_READ_PRAM = 0x07, /* read parameter RAM */ CUDA_WRITE_PRAM = 0x0C, /* write parameter RAM */ - CUDA_SET_AUTO_RATE = 0x14, /* set auto-polling rate */ - CUDA_GET_AUTO_RATE = 0x16, /* get auto-polling rate */ + CUDA_SET_AUTOPOLL_RATE = 0x14, /* set auto-polling rate */ + CUDA_GET_AUTOPOLL_RATE = 0x16, /* get auto-polling rate */ CUDA_READ_WRITE_I2C = 0x22, /* read/write I2C device */ CUDA_COMB_FMT_I2C = 0x25, /* combined format I2C transaction */ CUDA_OUT_PB0 = 0x26, /* output one bit to Cuda's PB0 line */ @@ -132,6 +132,7 @@ private: uint8_t out_buf[16]; int32_t out_count; int32_t out_pos; + uint8_t poll_rate; bool is_open_ended; uint8_t curr_i2c_addr;