Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor IrLogic to see if we can get rid of memory issue #120

Merged
merged 1 commit into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions fw/Core/Hitcon/Logic/IrLogic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ void IrLogic::OnBufferReceived(uint8_t *buffer) {
for (size_t i = 0; i < IR_SERVICE_RX_BUFFER_PER_RUN &&
buffer_received_ctr < IR_SERVICE_RX_ON_BUFFER_SIZE;
i++, buffer_received_ctr++) {
my_assert(buffer_received_ctr < IR_SERVICE_RX_ON_BUFFER_SIZE);
uint8_t current_byte = buffer[buffer_received_ctr];
for (uint8_t j = 0; j < 8; j++) {
my_assert(buffer_received_ctr < IR_SERVICE_RX_ON_BUFFER_SIZE);
uint8_t is_on = (buffer[buffer_received_ctr] & (1 << j)) ? 1 : 0;
uint8_t is_on = current_byte & 0x01;
current_byte = current_byte >> 1;
switch (packet_state) {
case STATE_START:
packet_buf <<= 1;
Expand Down
7 changes: 5 additions & 2 deletions fw/Core/Hitcon/Logic/IrLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class IrLogic {
IrPacket rx_packet_ctrler;
IrPacket tx_packet;

// To split OnBufferReceived into pieces
size_t buffer_received_ctr;
// This variable is a mystery.
size_t dummy1 = 0xBAADF00D;

// Total periods collected for load factor computation.
size_t lf_total_period;
Expand All @@ -72,6 +72,9 @@ class IrLogic {
// Load factor after low pass filter.
// In Q15.16 fixed point.
uint32_t lowpass_loadfactor;

// To split OnBufferReceived into pieces
size_t buffer_received_ctr;
};

extern IrLogic irLogic;
Expand Down
Loading