From ba54ff20eff042b635337543cfde730fe484b303 Mon Sep 17 00:00:00 2001 From: "Sebastian H. Gabrielli" Date: Sun, 28 Apr 2024 20:12:24 +0200 Subject: [PATCH] Fix master slave naming and remove dead code --- prosjekt.X/i2c.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/prosjekt.X/i2c.c b/prosjekt.X/i2c.c index aff2ac4..716618b 100644 --- a/prosjekt.X/i2c.c +++ b/prosjekt.X/i2c.c @@ -8,9 +8,7 @@ // read request volatile bool last_action_write = false; -volatile uint8_t i2c_recv[I2C_RECV_BUF_SIZE] = { - 0}; // Arbitrary length array to hold the received - // data, longer than max expected command +volatile uint8_t i2c_recv[I2C_RECV_BUF_SIZE] = {0}; volatile uint8_t i2c_recv_len = 0; void init_i2c(void) { @@ -73,22 +71,12 @@ void i2c_stop_handler() { // Parse the received command data parse_command(i2c_recv, i2c_recv_len); + // If the received command is a write only command we want to route it now. if (i2c_recv[0] == CLEAR_BULK_FAN_SPEED || i2c_recv[0] == WRITE_CONFIG) { route_command(0); } } - /* Write only commands need to be routed now - switch (i2c_recv[0]) { - WRITE_CONFIG: - CLEAR_BULK_FAN_SPEED: - route_command(0); - break; - default: - break; - } - */ - // Reset the buffer for future transmissions i2c_reset_recv(); } @@ -103,16 +91,14 @@ ISR(TWI0_TWIS_vect) { uint8_t data = 0; if (((TWI0.SSTATUS & TWI_DIR_bm) >> TWI_DIR_bp) == 0) { - // Data write Master -> Slave + // Data write Controller -> Target data = TWI0.SDATA; // Send the data to the write handler i2c_write_handler(data); } else { - // Data read Master <- Slave + // Data read Controller <- Target i2c_read_handler(); - // data = TWI0.SDATA; - // TWI0.SDATA = 1; } // Acknowledge having received