Other Parts Discussed in Thread: DRV8301,
For an instance the following code snippet doesn't work as expected, the return value will always be default enum/0.
DRV8301_ShuntAmpGain_e DRV8301_getShuntAmpGain(DRV8301_Handle handle)
{
uint16_t data;
// read data
data = DRV8301_readSpi(handle,DRV8301_RegName_Control_2);
// clear the bits
data &= (~DRV8301_CTRL2_GAIN_BITS);
return((DRV8301_ShuntAmpGain_e)data);
}--> data &= (~DRV8301_.............);
The above line makes the "data" contain value excluding the interested bit field(s) and on return, the data will be '0'.
Similar such bug can be pointed out in various other functions within the file.