11use core:: array:: from_fn;
2- use core:: cell:: RefCell ;
32use core:: iter:: zip;
43
54use :: tps6699x:: registers:: field_sets:: IntEventBus1 ;
@@ -17,7 +16,7 @@ use embedded_usb_pd::type_c::Current as TypecCurrent;
1716use embedded_usb_pd:: { Error , PdError , PortId as LocalPortId } ;
1817use tps6699x:: asynchronous:: embassy as tps6699x;
1918
20- use crate :: ControllerWrapper ;
19+ use crate :: wrapper :: { Controller , ControllerWrapper } ;
2120
2221pub struct Tps6699x < ' a , M : RawMutex , B : I2c > {
2322 port_events : [ PortEventKind ; MAX_CONTROLLER_PORTS ] ,
@@ -33,7 +32,7 @@ impl<'a, M: RawMutex, B: I2c> Tps6699x<'a, M, B> {
3332 }
3433}
3534
36- impl < ' a , M : RawMutex , B : I2c > crate :: Controller for Tps6699x < ' a , M , B > {
35+ impl < ' a , M : RawMutex , B : I2c > Controller for Tps6699x < ' a , M , B > {
3736 type BusError = B :: Error ;
3837
3938 /// Wait for an event on any port
@@ -158,11 +157,11 @@ pub fn tps66994<'a, M: RawMutex, B: I2c>(
158157 port_ids : [ GlobalPortId ; TPS66994_NUM_PORTS ] ,
159158 power_ids : [ policy:: DeviceId ; TPS66994_NUM_PORTS ] ,
160159) -> Result < ControllerWrapper < TPS66994_NUM_PORTS , Tps6699x < ' a , M , B > > , PdError > {
161- Ok ( ControllerWrapper {
162- pd_controller : controller:: Device :: new ( controller_id, port_ids. as_slice ( ) ) ?,
163- power : from_fn ( |i| policy:: device:: Device :: new ( power_ids[ i] ) ) ,
164- controller : RefCell :: new ( Tps6699x :: new ( controller) ) ,
165- } )
160+ Ok ( ControllerWrapper :: new (
161+ controller:: Device :: new ( controller_id, port_ids. as_slice ( ) ) ?,
162+ from_fn ( |i| policy:: device:: Device :: new ( power_ids[ i] ) ) ,
163+ Tps6699x :: new ( controller) ,
164+ ) )
166165}
167166
168167/// Create a new TPS66993 controller wrapper
@@ -172,9 +171,9 @@ pub fn tps66993<'a, M: RawMutex, B: I2c>(
172171 port_ids : [ GlobalPortId ; TPS66993_NUM_PORTS ] ,
173172 power_ids : [ policy:: DeviceId ; TPS66993_NUM_PORTS ] ,
174173) -> Result < ControllerWrapper < TPS66993_NUM_PORTS , Tps6699x < ' a , M , B > > , PdError > {
175- Ok ( ControllerWrapper {
176- pd_controller : controller:: Device :: new ( controller_id, port_ids. as_slice ( ) ) ?,
177- power : from_fn ( |i| policy:: device:: Device :: new ( power_ids[ i] ) ) ,
178- controller : RefCell :: new ( Tps6699x :: new ( controller) ) ,
179- } )
174+ Ok ( ControllerWrapper :: new (
175+ controller:: Device :: new ( controller_id, port_ids. as_slice ( ) ) ?,
176+ from_fn ( |i| policy:: device:: Device :: new ( power_ids[ i] ) ) ,
177+ Tps6699x :: new ( controller) ,
178+ ) )
180179}
0 commit comments