Skip to content

Commit

Permalink
enable pd comms
Browse files Browse the repository at this point in the history
enable pd comms to add pd supply capabilities to power.SupplyCapabilities(), limit the maximum voltage requested to 5V and cap current request to max input current.
  • Loading branch information
ChrisDick committed Jul 16, 2024
1 parent 17b9261 commit e54ca01
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion drivers/tildagon_power/fusb302b/fusb302b_pd.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ uint8_t fusbpd_select_pdo( pd_state_t* state )
if (
( state->pdos[i].fixed.pdo_type == PD_FIXED_SUPPLY )
&& ( voltage > highest_voltage )
&& ( voltage < 14000 )
&& ( voltage <= 5000U )
)
{
highest_voltage = voltage;
Expand Down
13 changes: 8 additions & 5 deletions drivers/tildagon_power/tildagon_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,7 @@ void device_unattached_handler( event_t event )
determine_input_current_limit( &usb_in );
if ( ( usb_in.fusb.input_current_limit >= 1500 ) && ( device_pd_state == NOT_STARTED ) )
{
//todo enable device pd
//fusb_setup_pd( &usb_in.fusb );
fusb_setup_pd( &usb_in.fusb );
device_pd_state = WAITING;
}
fusb_mask_interrupt_bclevel( &usb_in.fusb, 1 );
Expand All @@ -334,8 +333,7 @@ void device_attached_handler( event_t event )
determine_input_current_limit( &usb_in );
if ( ( usb_in.fusb.input_current_limit >= 1500 ) && ( device_pd_state == NOT_STARTED ) )
{
//todo enable device pd
//fusb_setup_pd( &usb_in.fusb );
fusb_setup_pd( &usb_in.fusb );
device_pd_state = WAITING;
}
fusb_mask_interrupt_bclevel( &usb_in.fusb, 1 );
Expand Down Expand Up @@ -365,7 +363,12 @@ void device_pd_machine ( event_t event )
if ( usb_in.pd.last_rx_data_msg_type == PD_DATA_SOURCE_CAPABILITIES )
{
uint8_t index = fusbpd_select_pdo( &usb_in.pd );
fusbpd_request_power( &usb_in.pd, index, usb_in.pd.pdos[index].fixed.max_current * 10, usb_in.pd.pdos[index].fixed.max_current * 10 );
uint32_t current = usb_in.pd.pdos[index].fixed.max_current * 10;
if ( current > 3250 )
{
current = 3250;
}
fusbpd_request_power( &usb_in.pd, index, current, current );
fusb_send( &usb_in.fusb, usb_in.pd.tx_buffer, usb_in.pd.message_length );
usb_in.pd.last_rx_data_msg_type = PD_DATA_DO_NOT_USE;
device_pd_state = POWER_REQUESTED;
Expand Down

0 comments on commit e54ca01

Please sign in to comment.