69 static volatile uint16_t enableWaitTimeOut;
75 enableWaitTimeOut = 0;
80 if(++enableWaitTimeOut > 999)
357 const uint16_t data = 0;
358 volatile uint16_t readWord;
359 static volatile uint16_t WaitTimeOut = 0;
381 if(++WaitTimeOut > 0xfffe)
621 Spi_8301_Vars->Ctrl_Reg_1.DRV8301_RESET | \
622 Spi_8301_Vars->Ctrl_Reg_1.PWM_MODE | \
623 Spi_8301_Vars->Ctrl_Reg_1.OC_MODE | \
624 Spi_8301_Vars->Ctrl_Reg_1.OC_ADJ_SET;
630 Spi_8301_Vars->Ctrl_Reg_2.GAIN | \
631 Spi_8301_Vars->Ctrl_Reg_2.DC_CAL_CH1p2 | \
632 Spi_8301_Vars->Ctrl_Reg_2.OC_TOFF;
635 Spi_8301_Vars->
SndCmd =
false;
688 Spi_8301_Vars->
RcvCmd =
false;
721 Spi_8301_Vars->
SndCmd =
false;
722 Spi_8301_Vars->
RcvCmd =
false;
Shunt amplifier number 1.
DRV8301_OcOffTimeMode_e OC_TOFF
DRV8301_FaultType_e DRV8301_getFaultType(DRV8301_Handle handle)
Gets the fault type.
#define DRV8301_CTRL1_OC_ADJ_SET_BITS
Defines the location of the OC_ADJ bits in the Control 1 register.
Defines the serial peripheral interface (SPI) object.
#define DRV8301_STATUS1_FETHC_OC_BITS
Defines the location of the FETLC_OC (FET High side, Phase C Over Current) bits in the Status 1 regis...
void DRV8301_setPwmMode(DRV8301_Handle handle, const DRV8301_PwmMode_e mode)
Sets the PWM mode.
DRV8301_DcCalMode_e
Enumeration for the DC calibration modes.
#define DRV8301_CTRL2_DC_CAL_2_BITS
Defines the location of the DC_CAL_2 bits in the Control 2 register.
bool enableTimeOut
the timeout flag for drv8301 enable
static void DRV8301_resetEnableTimeout(DRV8301_Handle handle)
Resets the enable timeout flag.
void DRV8301_readData(DRV8301_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars)
DRV8301_ShuntAmpNumber_e
Enumeration for the shunt amplifier number.
#define DRV8301_STATUS1_FETLB_OC_BITS
Defines the location of the FETLC_OC (FET Low side, Phase B Over Current) bits in the Status 1 regist...
DRV_SPI_8301_CTRL1_t_ Ctrl_Reg_1
void DRV8301_setSpiHandle(DRV8301_Handle handle, SPI_Handle spiHandle)
Sets the SPI handle in the DRV8301.
DRV8301_PeakCurrent_e DRV8301_getPeakCurrent(DRV8301_Handle handle)
Gets the peak current value.
uint16_t DRV8301_Word_t
Defines the DRV8301 Word type.
void DRV8301_setGpioNumber(DRV8301_Handle handle, GPIO_Number_e gpioNumber)
Sets the GPIO number in the DRV8301.
void GPIO_setHigh(GPIO_Handle gpioHandle, const GPIO_Number_e gpioNumber)
Sets the specified general purpose I/O (GPIO) signal high.
Defines the DRV8301 object.
DRV8301_DcCalMode_e DC_CAL_CH1p2
Shunt amplifier 1 connected to load via input pins.
DRV8301_VdsLevel_e OC_ADJ_SET
void DRV8301_writeSpi(DRV8301_Handle handle, const DRV8301_RegName_e regName, const uint16_t data)
Writes data to the DRV8301 register.
DRV8301_PwmMode_e
Enumeration for the PWM modes.
DRV8301_Handle DRV8301_init(void *pMemory, const size_t numBytes)
Initializes the DRV8301 object.
DRV8301_PwmMode_e PWM_MODE
void DRV8301_setOcMode(DRV8301_Handle handle, const DRV8301_OcMode_e mode)
Sets the over current mode.
void DRV8301_setDcCalMode(DRV8301_Handle handle, const DRV8301_ShuntAmpNumber_e ampNumber, const DRV8301_DcCalMode_e mode)
Sets the DC calibration mode.
Contains public interface to various functions related to the DRV8301 object.
DRV8301_OcTwMode_e
Enumeration for the Over Current, Temperature Warning modes.
void DRV8301_setPeakCurrent(DRV8301_Handle handle, const DRV8301_PeakCurrent_e peakCurrent)
Sets the peak current value.
#define DRV8301_CTRL2_OC_TOFF_BITS
Defines the location of the OC_TOFF bits in the Control 2 register.
DRV8301_ShuntAmpGain_e GAIN
DRV8301_Reset_e
Enumeration for the shunt amplifier gains.
#define DRV8301_CTRL1_OC_MODE_BITS
Defines the location of the OC_MODE bits in the Control 1 register.
Shunt amplifier number 2.
report both OT and OC at /OCTW pin
DRV8301_OcTwMode_e DRV8301_getOcTwMode(DRV8301_Handle handle)
Gets the over current, temperature warning mode.
static DRV8301_Word_t DRV8301_buildCtrlWord(const DRV8301_CtrlMode_e ctrlMode, const DRV8301_RegName_e regName, const uint16_t data)
Builds the control word.
SPI_FifoStatus_e SPI_getRxFifoStatus(SPI_Handle spiHandle)
Gets the serial peripheral interface (SPI) receive FIFO status.
DRV8301_ShuntAmpGain_e DRV8301_getShuntAmpGain(DRV8301_Handle handle)
Gets the shunt amplifier gain value.
#define DRV8301_STATUS2_GVDD_OV_BITS
Defines the location of the GVDD_OV (DRV8301 Vdd, Over Voltage) bits in the Status 2 register...
DRV8301_OcOffTimeMode_e
Enumeration for the Over Current Off Time modes.
DRV8301_RegName_e
Enumeration for the register names.
DRV8301_PwmMode_e DRV8301_getPwmMode(DRV8301_Handle handle)
Gets the PWM mode.
#define DRV8301_CTRL2_OCTW_SET_BITS
Defines the location of the OCTW_SET bits in the Control 2 register.
#define DRV8301_CTRL2_GAIN_BITS
Defines the location of the GAIN bits in the Control 2 register.
#define DRV8301_CTRL1_GATE_CURRENT_BITS
Defines the location of the GATE_CURRENT bits in the Control 1 register.
#define DRV8301_STATUS1_FETLC_OC_BITS
Defines the location of the FETLC_OC (FET Low side, Phase C Over Current) bits in the Status 1 regist...
void DRV8301_enable(DRV8301_Handle handle)
Enables the DRV8301.
#define DRV8301_STATUS1_FETHB_OC_BITS
Defines the location of the FETLC_OC (FET High side, Phase B Over Current) bits in the Status 1 regis...
#define DRV8301_STATUS2_ID_BITS
Defines the location of the Device ID bits in the Status 2 register.
DRV_SPI_8301_CTRL2_t_ Ctrl_Reg_2
uint16_t DRV8301_readSpi(DRV8301_Handle handle, const DRV8301_RegName_e regName)
Reads data from the DRV8301 register.
#define DRV8301_STATUS1_FETHA_OC_BITS
Defines the location of the FETLC_OC (FET High side, Phase A Over Current) bits in the Status 1 regis...
void DRV8301_reset(DRV8301_Handle handle)
Resets the DRV8301.
#define DRV8301_STATUS1_FAULT_BITS
Defines the location of the FAULT bits in the Status 1 register.
Defines the General Purpose I/O (GPIO) object.
GPIO_Handle gpioHandle
the gpio handle that is connected to the drv8301 enable pin
current limit when OC detected
#define DRV8301_CTRL1_PWM_MODE_BITS
Defines the location of the PWM_MODE bits in the Control 1 register.
DRV8301_DcCalMode_e DRV8301_getDcCalMode(DRV8301_Handle handle, const DRV8301_ShuntAmpNumber_e ampNumber)
Gets the DC calibration mode.
drv8301 driver peak current 0.25A
DRV8301_ShuntAmpGain_e
Enumeration for the shunt amplifier gains.
#define DRV8301_STATUS1_PVDD_UV_BITS
Defines the location of the PVDD_UV (Power supply Vdd, Under Voltage) bits in the Status 1 register...
static uint16_t SPI_readEmu(SPI_Handle spiHandle)
Reads data from the serial peripheral interface (SPI) during emulation.
#define DRV8301_STATUS1_GVDD_UV_BITS
Defines the location of the GVDD_UV (DRV8301 Vdd, Under Voltage) bits in the Status 1 register...
DRV8301_VdsLevel_e DRV8301_getOcLevel(DRV8301_Handle handle)
Gets the over current level.
DRV_SPI_8301_Stat2_t_ Stat_Reg_2
DRV8301_PeakCurrent_e DRV8301_CURRENT
void DRV8301_setGpioHandle(DRV8301_Handle handle, GPIO_Handle gpioHandle)
Sets the GPIO handle in the DRV8301.
void DRV8301_setupSpi(DRV8301_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars)
Initialize the interface to all 8301 SPI variables.
Denotes the fifo contains 2 words.
void SPI_enableRxFifo(SPI_Handle spiHandle)
Enables the serial peripheral interface (SPI) receive FIFO.
DRV8301_OcMode_e DRV8301_getOcMode(DRV8301_Handle handle)
Gets the over current mode.
SPI_Handle spiHandle
the handle for the serial peripheral interface
void DRV8301_setOcOffTimeMode(DRV8301_Handle handle, const DRV8301_OcOffTimeMode_e mode)
Sets the over current off time mode.
static void SPI_write(SPI_Handle spiHandle, const uint16_t data)
Writes data to the serial peripheral interface (SPI)
GPIO_Number_e gpioNumber
the gpio number that is connected to the drv8301 enable pin
DRV8301_VdsLevel_e
Enumeration for the Vds level for th over current adjustment.
DRV8301 Vdd Over Voltage fault.
DRV8301_PeakCurrent_e
Enumeration for the drv8301 peak current levels.
void DRV8301_setOcTwMode(DRV8301_Handle handle, const DRV8301_OcTwMode_e mode)
Sets the over current, temperature warning mode.
void DRV8301_writeData(DRV8301_Handle handle, DRV_SPI_8301_Vars_t *Spi_8301_Vars)
Interface to all 8301 SPI variables.
DRV8301_OcTwMode_e OCTW_SET
void DRV8301_setOcLevel(DRV8301_Handle handle, const DRV8301_VdsLevel_e VdsLevel)
Sets the over current level in terms of Vds.
struct _DRV8301_Obj_ * DRV8301_Handle
Defines the DRV8301 handle.
#define DRV8301_STATUS1_OTW_BITS
Defines the location of the OTW (Over Temperature Warning) bits in the Status 1 register.
static void DRV8301_resetRxTimeout(DRV8301_Handle handle)
Resets the RX fifo timeout flag.
Shunt amplifier 2 connected to load via input pins.
SPI_FifoStatus_e
Enumeration to define the serial peripheral interface (SPI) FIFO status.
void DRV8301_setShuntAmpGain(DRV8301_Handle handle, const DRV8301_ShuntAmpGain_e gain)
Sets the shunt amplifier gain value.
DRV_SPI_8301_Stat1_t_ Stat_Reg_1
DRV8301_Reset_e DRV8301_RESET
#define DRV8301_FAULT_TYPE_MASK
Defines the R/W mask.
DRV8301_FaultType_e
Enumeration for the fault types.
bool DRV8301_isReset(DRV8301_Handle handle)
Determines if DRV8301 is in reset.
#define DRV8301_CTRL2_DC_CAL_1_BITS
Defines the location of the DC_CAL_1 bits in the Control 2 register.
bool DRV8301_isFault(DRV8301_Handle handle)
Determines if DRV8301 fault has occurred.
bool RxTimeOut
the timeout flag for the RX fifo
void SPI_resetRxFifo(SPI_Handle spiHandle)
Resets the serial peripheral interface (SPI) receive FIFO.
#define DRV8301_DATA_MASK
Defines the data mask.
#define DRV8301_STATUS1_FETLA_OC_BITS
Defines the location of the FETLC_OC (FET Low side, Phase A Over Current) bits in the Status 1 regist...
#define DRV8301_STATUS1_OTSD_BITS
Defines the location of the OTSD (Over Temperature Shut Down) bits in the Status 1 register...
#define DRV8301_CTRL1_GATE_RESET_BITS
Defines the location of the GATE_RESET bits in the Control 1 register.
GPIO_Number_e
Enumeration to define the general purpose I/O (GPIO) numbers.
uint16_t DRV8301_getId(DRV8301_Handle handle)
Gets the device ID.
DRV8301_OcOffTimeMode_e DRV8301_getOcOffTimeMode(DRV8301_Handle handle)
Gets the over current off time mode.
DRV8301_OcMode_e
Enumeration for the Over Current modes.
Denotes the fifo is empty.