From 1a0a307dd7ee985a0a2577b1bc9a93c262eb075a Mon Sep 17 00:00:00 2001 From: Aditya Naik Date: Tue, 7 Apr 2020 03:02:30 -0400 Subject: Debug/testing block corrections --- Inc/config.h | 6 +++--- Src/main-hs.c | 23 ++++++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Inc/config.h b/Inc/config.h index cfd2817..059c0d3 100644 --- a/Inc/config.h +++ b/Inc/config.h @@ -1,6 +1,6 @@ /* Enable debug mode */ -/* #define DEBUG_ENABLE 1 */ +#define DEBUG_ENABLE 1 -/* Enable testing mode with granualar status notifications */ -/* #define TESTING_ENABLE 1 */ +/* Enable testing mode */ +#define TESTING_ENABLE 1 diff --git a/Src/main-hs.c b/Src/main-hs.c index 460148d..626cb5c 100644 --- a/Src/main-hs.c +++ b/Src/main-hs.c @@ -299,19 +299,28 @@ bool encode_subscription_callback(pb_ostream_t *ostream, const pb_field_t *field int handshake(uint32_t i2c_addr) { - uint32_t dev_idx = GET_IDX_FROM_ADDR(i2c_addr); + /* Handshake variables */ + uint8_t hs_sts = IDLE; - uint8_t debug_buf[128], term[] = "\r\n"; uint8_t *MDR_req_buf, *MDR_ACK_buf, *MDR_CTS_buf, *MDR_buf; uint32_t AF_error_counter = 0; - size_t MDR_req_size, MDR_CTS_size; + uint32_t dev_idx = GET_IDX_FROM_ADDR(i2c_addr); + uint32_t MDR_len = 0; m2s_MDR_request MDR_req_message; s2m_MDR_req_ACK MDR_ACK; m2s_MDR_res_CTS MDR_CTS; s2m_MDR_response MDR_res_message; - uint32_t MDR_len = 0; + + +#if defined(TESTING_ENABLE) || defined(DEBUG_ENABLE) + uint8_t debug_buf[128]; +#endif +#ifdef TESTING_ENABLE + uint8_t term[] = "\r\n"; + size_t MDR_req_size, MDR_CTS_size; +#endif while (hs_sts != HS_FAILED && hs_sts != HS_REGISTERED) { switch (hs_sts) { @@ -329,8 +338,8 @@ int handshake(uint32_t i2c_addr) #endif } else { - MDR_req_size = MDR_req_stream.bytes_written; #ifdef TESTING_ENABLE + MDR_req_size = MDR_req_stream.bytes_written; goto __HS_IDLE_TESTING; __HS_IDLE_TESTING_END: __asm__("nop"); @@ -409,8 +418,8 @@ int handshake(uint32_t i2c_addr) #endif } else { - MDR_CTS_size = MDR_CTS_ostream.bytes_written; #ifdef TESTING_ENABLE + MDR_CTS_size = MDR_CTS_ostream.bytes_written; goto __HS_MDR_CTS_TESTING; __HS_MDR_CTS_TESTING_END: __asm__("nop"); @@ -422,7 +431,7 @@ int handshake(uint32_t i2c_addr) goto __HS_CTS_I2C_ERROR; __HS_CTS_I2C_ERROR_END: __asm__("nop"); -#endif DEBUG_ENABLE +#endif } else { hs_sts = HS_MDR_MDR; -- cgit v1.2.3