Hi,
I’m going through the driver code in drv8301.c and I’m noticing rather serious bugs. I can’t help but thinking this code was developed in India: Copious amount of unnecessary use of the article ‘the’ in comments, useless comments explaining the C statement below but not the intend, and unawareness of when and when not to escape line endings:
drvDataNew = Spi_8301_Vars->Ctrl_Reg_2.OCTW_SET |
Spi_8301_Vars->Ctrl_Reg_2.GAIN |
Spi_8301_Vars->Ctrl_Reg_2.DC_CAL_CH1p2 |
Spi_8301_Vars->Ctrl_Reg_2.OC_TOFF;
But what is far worse, is that it is largely untested code. This function cannot work:
DRV8301_VdsLevel_e DRV8301_getOcLevel(DRV8301_Handle handle)
{
uint16_t data;
// read data
data = DRV8301_readSpi(handle,DRV8301_RegName_Control_1);
// clear the bits
data &= (~DRV8301_CTRL1_OC_ADJ_SET_BITS);
return((DRV8301_VdsLevel_e)data);
} // end of DRV8301_getOcLevel() function
It clears the bits requested, and it even says so in the comments! Its clearly a copy-paste error from the setter functions and obviously never tested.
These functions show the same defect:
DRV8301_OcMode_e DRV8301_getOcMode(DRV8301_Handle handle)
DRV8301_OcOffTimeMode_e DRV8301_getOcOffTimeMode(DRV8301_Handle handle)
DRV8301_OcTwMode_e DRV8301_getOcTwMode(DRV8301_Handle handle)
DRV8301_PeakCurrent_e DRV8301_getPeakCurrent(DRV8301_Handle handle)
DRV8301_PwmMode_e DRV8301_getPwmMode(DRV8301_Handle handle)
DRV8301_ShuntAmpGain_e DRV8301_getShuntAmpGain(DRV8301_Handle handle)
Does anybody know where this driver originates from? And are there any other externally borrowed parts I should be aware of?
Cheers!