Skip to content

Commit

Permalink
Merge pull request #470 from openxc/sq-major-fix
Browse files Browse the repository at this point in the history
refactor major code smells defined in sonarqube.
  • Loading branch information
pjt0620 committed Jan 6, 2021
2 parents 953e027 + 7d7f1cd commit 439c910
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 126 deletions.
12 changes: 9 additions & 3 deletions src/platform/pic32/blueNRG.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,22 @@ static int16_t SPI_Write(uint8_t* data1, uint8_t* data2, uint16_t Nb_bytes1, uin
SPI_SendRecieve(STBTLE_SPICHANNEL, header_master, header_slave, 5);

if(header_slave[0] != 0x02){
result = -1;
goto failed; // BlueNRG not awake.
result = -1;
// Release CS line
SPI_CS_SetHigh(STBTLE_SPICHANNEL);

return result;// BlueNRG not awake.
}

rx_bytes = header_slave[1];

if(rx_bytes < Nb_bytes1)
{
result = -2;
goto failed; // underflow
// Release CS line
SPI_CS_SetHigh(STBTLE_SPICHANNEL);

return result;// underflow.
}

SPI_SendRecieve(STBTLE_SPICHANNEL, data1, NULL, Nb_bytes1);
Expand Down
Loading

0 comments on commit 439c910

Please sign in to comment.