File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed
examples/usbpd_sink_request_voltage Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,10 @@ void loop() {
2020
2121 if (usbpd_sink_get_ready ())
2222 {
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+ }
2427 }
2528
2629// button, myIndex++
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ void usbpd_sink_clear_ready(void)
3838 pdControl_g .cc_USBPD_READY = 0 ;
3939}
4040
41- void usbpd_sink_set_request_fixed_voltage (Request_voltage_t requestVoltage )
41+ bool usbpd_sink_set_request_fixed_voltage (Request_voltage_t requestVoltage )
4242{
4343 uint16_t targetVoltage ;
4444 switch (requestVoltage )
@@ -73,11 +73,12 @@ void usbpd_sink_set_request_fixed_voltage(Request_voltage_t requestVoltage)
7373 if (pdControl_g .cc_FixedSourceCap [i ].Voltage == targetVoltage )
7474 {
7575 pdControl_g .cc_SetPDONum = i + 1 ;
76- return ;
76+ return true ;
7777 }
7878 }
79- pdControl_g .cc_SetPDONum = (pdControl_g .cc_SourcePDONum - pdControl_g .cc_SourcePPSNum );
8079
80+ // unsupported voltage
81+ return false;
8182}
8283
8384void timer3_init (uint16_t arr , uint16_t psc )
Original file line number Diff line number Diff line change 55extern "C" {
66#endif /* end of __cplusplus */
77
8+ #include <stdbool.h>
89#include "usbpd_def.h"
910
1011// Register Bit Definition
@@ -201,7 +202,7 @@ void usbpd_sink_process(void);
201202uint8_t usbpd_sink_get_ready (void );
202203void usbpd_sink_clear_ready (void );
203204
204- void usbpd_sink_set_request_fixed_voltage (Request_voltage_t requestVoltage );
205+ bool usbpd_sink_set_request_fixed_voltage (Request_voltage_t requestVoltage );
205206
206207
207208#ifdef __cplusplus
You can’t perform that action at this time.
0 commit comments