@@ -666,15 +666,16 @@ impl<SM: ValidStateMachine, State> StateMachine<SM, State> {
666666 // the 'PULL' has no effect, or the program will stall on the 'PULL' until data becomes
667667 // available in the FIFO.
668668
669- // TODO: encode at compile time once pio 0.3.0 is out
670- const OUT : InstructionOperands = InstructionOperands :: OUT {
669+ const OUT : u16 = InstructionOperands :: OUT {
671670 destination : pio:: OutDestination :: NULL ,
672671 bit_count : 32 ,
673- } ;
674- const PULL : InstructionOperands = InstructionOperands :: PULL {
672+ }
673+ . encode ( ) ;
674+ const PULL : u16 = InstructionOperands :: PULL {
675675 if_empty : false ,
676676 block : false ,
677- } ;
677+ }
678+ . encode ( ) ;
678679
679680 // Safety: all accesses to these registers are controlled by this instance
680681 unsafe {
@@ -687,8 +688,7 @@ impl<SM: ValidStateMachine, State> StateMachine<SM, State> {
687688 OUT
688689 } else {
689690 PULL
690- }
691- . encode ( ) ;
691+ } ;
692692
693693 // Safety: sm0_instr may be accessed from SM::exec_instruction.
694694 let mut saved_sideset_count = 0 ;
@@ -757,13 +757,12 @@ impl<SM: ValidStateMachine> StateMachine<SM, Stopped> {
757757 ///
758758 /// The iterator's item are pairs of `(pin_number, pin_state)`.
759759 pub fn set_pins ( & mut self , pins : impl IntoIterator < Item = ( u8 , PinState ) > ) {
760- // TODO: turn those three into const once pio 0.3.0 is released
761- let set_high_instr = InstructionOperands :: SET {
760+ const SET_HIGH_INSTR : u16 = InstructionOperands :: SET {
762761 destination : pio:: SetDestination :: PINS ,
763762 data : 1 ,
764763 }
765764 . encode ( ) ;
766- let set_low_instr = InstructionOperands :: SET {
765+ const SET_LOW_INSTR : u16 = InstructionOperands :: SET {
767766 destination : pio:: SetDestination :: PINS ,
768767 data : 0 ,
769768 }
@@ -789,9 +788,9 @@ impl<SM: ValidStateMachine> StateMachine<SM, Stopped> {
789788 for ( pin_num, pin_state) in pins {
790789 sm_pinctrl. write ( |w| w. set_base ( ) . bits ( pin_num) . set_count ( ) . bits ( 1 ) ) ;
791790 let instruction = if pin_state == PinState :: High {
792- set_high_instr
791+ SET_HIGH_INSTR
793792 } else {
794- set_low_instr
793+ SET_LOW_INSTR
795794 } ;
796795
797796 sm_instr. write ( |w| w. sm0_instr ( ) . bits ( instruction) )
@@ -809,13 +808,12 @@ impl<SM: ValidStateMachine> StateMachine<SM, Stopped> {
809808 ///
810809 /// The iterator's item are pairs of `(pin_number, pin_dir)`.
811810 pub fn set_pindirs ( & mut self , pindirs : impl IntoIterator < Item = ( u8 , PinDir ) > ) {
812- // TODO: turn those three into const once pio 0.3.0 is released
813- let set_output_instr = InstructionOperands :: SET {
811+ const SET_OUTPUT_INSTR : u16 = InstructionOperands :: SET {
814812 destination : pio:: SetDestination :: PINDIRS ,
815813 data : 1 ,
816814 }
817815 . encode ( ) ;
818- let set_input_instr = InstructionOperands :: SET {
816+ const SET_INPUT_INSTR : u16 = InstructionOperands :: SET {
819817 destination : pio:: SetDestination :: PINDIRS ,
820818 data : 0 ,
821819 }
@@ -841,9 +839,9 @@ impl<SM: ValidStateMachine> StateMachine<SM, Stopped> {
841839 for ( pin_num, pin_dir) in pindirs {
842840 sm_pinctrl. write ( |w| w. set_base ( ) . bits ( pin_num) . set_count ( ) . bits ( 1 ) ) ;
843841 let instruction = if pin_dir == PinDir :: Output {
844- set_output_instr
842+ SET_OUTPUT_INSTR
845843 } else {
846- set_input_instr
844+ SET_INPUT_INSTR
847845 } ;
848846
849847 sm_instr. write ( |w| w. sm0_instr ( ) . bits ( instruction) )
0 commit comments