|
|
@@ -11,6 +11,7 @@ Format: command + ((slot_id) + data (optional))
|
|
|
bool controller_SetCommandRequest(uint8_t const TARGET_ADDRESS, uint8_t command, uint8_t *data, uint8_t data_len){
|
|
|
//Set the command in the tx buffer
|
|
|
tx_packet.txBuffer[0] = command;
|
|
|
+ printf("[MCU] SET Command:: 0x%02X\n", tx_packet.txBuffer[0]);
|
|
|
if(data != NULL && data_len > 0){
|
|
|
for(uint8_t i=0; i<data_len; i++){
|
|
|
tx_packet.txBuffer[i+1] = data[i];
|
|
|
@@ -18,7 +19,7 @@ bool controller_SetCommandRequest(uint8_t const TARGET_ADDRESS, uint8_t command,
|
|
|
}
|
|
|
tx_packet.txLen = data_len + 1; // +1 for command
|
|
|
//return i2c_hal.write(TARGET_ADDRESS);
|
|
|
- return i2c_mock_interface.write(TARGET_ADDRESS);
|
|
|
+ return i2c_mock_interface.write(TARGET_ADDRESS); //Testing:: mock test: comment it out in Production
|
|
|
}
|
|
|
|
|
|
//Generic Function to send data to the target controller using I2C:
|
|
|
@@ -26,7 +27,7 @@ bool controller_SetCommandRequest(uint8_t const TARGET_ADDRESS, uint8_t command,
|
|
|
bool controller_GetCommandRequest(uint8_t const TARGET_ADDRESS, uint8_t command, uint8_t slot_id, uint8_t *data, uint8_t data_len){
|
|
|
//Set the command in the tx buffer in bit masked format to the target
|
|
|
tx_packet.txBuffer[0] = command| (slot_id<<4); //shift slot_id to the left by 4 bits
|
|
|
- printf("[MCU] Bitmasked Command:: 0x%02X\n", tx_packet.txBuffer[0]);
|
|
|
+ printf("[MCU] GET Bitmasked Command:: 0x%02X\n", tx_packet.txBuffer[0]);
|
|
|
//Conditional check to check if the data is not null and data length is greater than 0
|
|
|
if(data != NULL && data_len > 0){
|
|
|
//when data is sent along with the command, copying the data to the tx buffer
|
|
|
@@ -39,7 +40,7 @@ bool controller_GetCommandRequest(uint8_t const TARGET_ADDRESS, uint8_t command,
|
|
|
/*if(!i2c_hal.read(TARGET_ADDRESS)){
|
|
|
return false;
|
|
|
}*/
|
|
|
- bool result= i2c_mock_interface.read(TARGET_ADDRESS);
|
|
|
+ bool result= i2c_mock_interface.read(TARGET_ADDRESS); //Testing:: mock test: Comment it out in Production
|
|
|
if(result){
|
|
|
printf("[I2C] Successfully read %d bytes from target 0x%02X\n", data_len, TARGET_ADDRESS);
|
|
|
return true;
|