summaryrefslogtreecommitdiff
path: root/Src/main-hs.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/main-hs.c')
-rw-r--r--Src/main-hs.c23
1 files changed, 16 insertions, 7 deletions
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;