@@ -30,6 +30,13 @@ class TPS2HB35BQ {
3030 TPS2HB35BQ (io::GPIO & en1, io::GPIO & en2, io::GPIO & latch, io::GPIO & diagEn, io::GPIO & diagSelect1,
3131 io::GPIO & diagSelect2, io::ADC & senseOut, uint32_t rsns = 330 );
3232
33+ /* *
34+ * diagMode::OFF: Sets diagnostics pin low, along with both diag select pins.
35+ * diagMode::FAULT_STATUS: Get the fault status of the power switch
36+ * diagMode::CH1CURRENT: Get the channel 1 current of the power switch
37+ * diagMode::CH2CURRENT: Get the channel 2 current of the power switch
38+ * diagMode::TEMP: Get the temperature of the power switch
39+ */
3340 enum DiagMode {
3441 OFF = 0x00 ,
3542 FAULT_STATUS = 0x01 ,
@@ -38,38 +45,48 @@ class TPS2HB35BQ {
3845 TEMP = 0x04
3946 };
4047
48+ /* *
49+ * Sets the latch mode for the power switches
50+ */
4151 enum LatchMode {
4252 LATCHED = 0x00 , // If there is a fault the power switch will shut off and stay off
4353 AUTO_RETRY = 0x01 // If there is a fault the power switch will shut off and try to turn back on until there is
4454 // no longer a fault
4555 };
4656
57+ /* *
58+ * Sets the power switch channel output to high or low.
59+ *
60+ * @param powerSwitchOneEnabled State of power switch channel 1
61+ * @param powerSwitchTwoEnabled State of power switch channel 2
62+ */
4763 void setPowerSwitchStates (bool powerSwitchOneEnabled, bool powerSwitchTwoEnabled);
4864
4965 /* *
50- * Get the current of the power switch
51- * A fault is detected if the current is somewhere between 4 and 5.3 mA
66+ * Get the current of the power switch.
67+ * A fault is detected if the current is somewhere between 4 and 5.3 mA.
5268 *
69+ * @param channelSelect The channel to sense the current from
5370 * @return The current of the power switch in milli amps
5471 */
5572 uint32_t getCurrentAndFault (uint8_t channelSelect);
5673
5774 /* *
5875 * Get the temperature of the power switch.
5976 *
60- * @return The temperature of the power switch in Celsius
77+ * @return The temperature of the power switch in millicelcius
6178 */
6279 int32_t getTemperature ();
6380
6481 /* *
65- * Set the latch mode of the power switch
82+ * Set the latch mode of the power switch.
6683 *
6784 * @param mode The latch mode to set
6885 */
6986 void setLatch (LatchMode mode);
7087
7188 /* *
72- * Set the limits for the power switches
89+ * Set the limits for the power switches at which they shut down.
7390 *
7491 * @param ohms The resistance value of the sense resistor
7592 * @param ratio The current sense ratio
@@ -78,14 +95,6 @@ class TPS2HB35BQ {
7895 */
7996 void setLimits (uint32_t ohms, uint32_t ratio, uint32_t milliamps, int32_t millicelsius);
8097
81- /* *
82- * diagMode::OFF: Sets diagnostics pin low, along with both diag select pins.
83- * diagMode::FAULT_STATUS: Get the fault status of the power switch
84- * diagMode::CH1CURRENT: Get the channel 1 current of the power switch
85- * diagMode::CH2CURRENT: Get the channel 2 current of the power switch
86- * diagMode::TEMP: Get the temperature of the power switch
87- */
88-
8998private:
9099 io::GPIO & en1;
91100 io::GPIO & en2;
@@ -95,14 +104,16 @@ class TPS2HB35BQ {
95104 io::GPIO & diagSelect2;
96105 io::ADC & senseOut;
97106
98- uint32_t counts = 0 ; // ADC Counts
99- uint32_t adcVoltage = 3300 ; // ADC Voltage
100- uint32_t rsns = 360 ; // Resistor that sets the current limit
101- uint32_t kcl = 140 ; // Current Limit Ratio
102- uint32_t icl = 9000 ; // Current Limit Value in milliamps
103- int32_t TemperatureLimit = 135000 ; // Temperature Limit of 135 C in millicelsius
104- uint32_t dIsnst = 11 ; // Coefficient 0.011 mA/C in microamps
105- uint32_t resistanceOnJunctionTemp = 25000 ; // 25 C in millicelsius
107+ uint32_t counts = 0 ; // ADC Counts
108+ uint32_t rsns = 360 ; // Resistor that sets the current limit
109+ uint32_t kcl = 140 ; // Current Limit Ratio
110+ uint32_t icl = 9000 ; // Current Limit Value in milliamps
111+ int32_t TemperatureLimit = 135000 ; // Temperature Limit of 135 C in millicelsius
112+
113+ static constexpr uint32_t adcVoltage = 3300 ; // ADC Voltage
114+ static constexpr uint32_t dIsnst = 11 ; // Coefficient 0.011 mA/C in microamps
115+ static constexpr uint32_t resistanceOnJunctionTemp = 25000 ; // 25 C in millicelsius
116+ static constexpr uint32_t adcResolution = 4096 ; // 25 C in millicelsius
106117
107118 /* *
108119 * Controls the diagnostic enable pin
@@ -114,7 +125,7 @@ class TPS2HB35BQ {
114125 /* *
115126 * Read the sense out of the power switch
116127 *
117- * @param senseOut The sense out value
128+ * @return senseOut The sense out value
118129 */
119130 uint32_t readSenseOut ();
120131
0 commit comments