@@ -61,8 +61,8 @@ modm::platform::SpiMaster{{ id }}_Dma<DmaChannelRx, DmaChannelTx>::transmit(T da
6161 // there are only two states encoded into 1 bit (LSB of state):
6262 // 1. waiting to start, and
6363 // 2. waiting to finish.
64- // LSB != Bit0 ?
65- if ( !( state & Bit0) )
64+
65+ if (! state.all(SpiBase::LowByte) )
6666 {
6767 // disable DMA for single transfer
6868 SpiHal{{ id }}::disableInterrupt(SpiBase::Interrupt::TxDmaEnable |
@@ -76,7 +76,7 @@ modm::platform::SpiMaster{{ id }}_Dma<DmaChannelRx, DmaChannelTx>::transmit(T da
7676 SpiHal{{ id }}::write(data);
7777
7878 // set LSB = Bit0
79- state |= Bit0 ;
79+ state.set(SpiBase::LowByte) ;
8080 }
8181
8282 if (!SpiHal{{ id }}::isReceiveRegisterNotEmpty())
@@ -85,7 +85,7 @@ modm::platform::SpiMaster{{ id }}_Dma<DmaChannelRx, DmaChannelTx>::transmit(T da
8585 SpiHal{{ id }}::read(data);
8686
8787 // transfer finished
88- state &= ~Bit0 ;
88+ state.reset(SpiBase::LowByte) ;
8989 return {modm::rf::Stop, data};
9090}
9191
@@ -101,12 +101,11 @@ modm::platform::SpiMaster{{ id }}_Dma<DmaChannelRx, DmaChannelTx>::transmit(cons
101101 // 1. initialize index, and
102102 // 2. wait for transfer to finish.
103103
104- // we are only interested in Bit1
105- switch(state & Bit1)
104+ switch(int(state.all(SpiBase::Idle)))
106105 {
107106 case 0:
108107 // we will only visit this state once
109- state |= Bit1 ;
108+ state.set(SpiBase::Idle) ;
110109 dmaError = false;
111110
112111 SpiHal{{ id }}::enableInterrupt(SpiBase::Interrupt::TxDmaEnable |
@@ -145,8 +144,8 @@ modm::platform::SpiMaster{{ id }}_Dma<DmaChannelRx, DmaChannelTx>::transmit(cons
145144
146145 SpiHal{{ id }}::disableInterrupt(SpiBase::Interrupt::TxDmaEnable |
147146 SpiBase::Interrupt::RxDmaEnable);
148- // clear the state
149- state &= ~Bit1 ;
147+
148+ state.reset(SpiBase::Idle) ;
150149 return {modm::rf::Stop};
151150 }
152151}
@@ -164,11 +163,11 @@ modm::platform::SpiMaster{{ id }}_Dma<DmaChannelRx, DmaChannelTx>::transmit(cons
164163 // 2. wait for transfer to finish.
165164
166165 // we are only interested in Bit1
167- switch(state & Bit1 )
166+ switch(int( state.all(SpiBase::Idle)) )
168167 {
169168 case 0:
170169 // we will only visit this state once
171- state |= Bit1 ;
170+ state.set(SpiBase::Idle) ;
172171 dmaError = false;
173172
174173 SpiHal{{ id }}::enableInterrupt(SpiBase::Interrupt::TxDmaEnable |
@@ -219,8 +218,8 @@ modm::platform::SpiMaster{{ id }}_Dma<DmaChannelRx, DmaChannelTx>::transmit(cons
219218
220219 SpiHal{{ id }}::disableInterrupt(SpiBase::Interrupt::TxDmaEnable |
221220 SpiBase::Interrupt::RxDmaEnable);
222- // clear the state
223- state &= ~Bit1 ;
221+
222+ state.reset(SpiBase::Idle) ;
224223 return {modm::rf::Stop};
225224 }
226225}
0 commit comments