USB PD: Improve requesting fixed voltage function #137
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As for the USB PD sink functionality, the current implementation of the
usbpd_sink_set_request_fixed_voltage
function sets the value ofpdControl_g.cc_SetPDONum
to request the voltage specified in the argument.But the problem is that if the source side of the USB PD does not support the requested voltage, the current implementation sets the last index (excluding the PPS) of the PDO in
pdControl_g.cc_SetPDONum
.This is not a problem when requests the voltage supported by PD source, but means that unexpected voltage will be output when requests unsuppoted voltage by source.
For example, in the following cases:
usbpd_sink_set_request_fixed_voltage
function: 12V (unsupported in this case)The return value of the
usbpd_sink_set_request_fixed_voltage
function is void, so the developer cannot determine whether the request is possible.And also, they would not want to output the maximum voltage supported by the PD source when the specified voltage is unsupported.
Therefore, the implementation of the
usbpd_sink_set_request_fixed_voltage
function should be improved.bool
, and return false when an unsupported voltage is specified.