File tree 3 files changed +10
-5
lines changed
examples/usbpd_sink_request_voltage
3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,10 @@ void loop() {
20
20
21
21
if (usbpd_sink_get_ready ())
22
22
{
23
- usbpd_sink_set_request_fixed_voltage (setVoltage);
23
+ if (usbpd_sink_set_request_fixed_voltage (setVoltage) == false )
24
+ {
25
+ Serial.printf (" unsupported voltage\r\n " );
26
+ }
24
27
}
25
28
26
29
// button, myIndex++
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ void usbpd_sink_clear_ready(void)
38
38
pdControl_g .cc_USBPD_READY = 0 ;
39
39
}
40
40
41
- void usbpd_sink_set_request_fixed_voltage (Request_voltage_t requestVoltage )
41
+ bool usbpd_sink_set_request_fixed_voltage (Request_voltage_t requestVoltage )
42
42
{
43
43
uint16_t targetVoltage ;
44
44
switch (requestVoltage )
@@ -73,11 +73,12 @@ void usbpd_sink_set_request_fixed_voltage(Request_voltage_t requestVoltage)
73
73
if (pdControl_g .cc_FixedSourceCap [i ].Voltage == targetVoltage )
74
74
{
75
75
pdControl_g .cc_SetPDONum = i + 1 ;
76
- return ;
76
+ return true ;
77
77
}
78
78
}
79
- pdControl_g .cc_SetPDONum = (pdControl_g .cc_SourcePDONum - pdControl_g .cc_SourcePPSNum );
80
79
80
+ // unsupported voltage
81
+ return false;
81
82
}
82
83
83
84
void timer3_init (uint16_t arr , uint16_t psc )
Original file line number Diff line number Diff line change 5
5
extern "C" {
6
6
#endif /* end of __cplusplus */
7
7
8
+ #include <stdbool.h>
8
9
#include "usbpd_def.h"
9
10
10
11
// Register Bit Definition
@@ -201,7 +202,7 @@ void usbpd_sink_process(void);
201
202
uint8_t usbpd_sink_get_ready (void );
202
203
void usbpd_sink_clear_ready (void );
203
204
204
- void usbpd_sink_set_request_fixed_voltage (Request_voltage_t requestVoltage );
205
+ bool usbpd_sink_set_request_fixed_voltage (Request_voltage_t requestVoltage );
205
206
206
207
207
208
#ifdef __cplusplus
You can’t perform that action at this time.
0 commit comments