@@ -165,7 +165,7 @@ func (i2c I2C) start(address uint8, write bool) {
165
165
avr .TWCR .Set ((avr .TWCR_TWINT | avr .TWCR_TWSTA | avr .TWCR_TWEN ))
166
166
167
167
// Wait till start condition is transmitted.
168
- for ( avr .TWCR .Get () & avr .TWCR_TWINT ) == 0 {
168
+ for ! avr .TWCR .HasBits ( avr .TWCR_TWINT ) {
169
169
}
170
170
171
171
// Write 7-bit shifted peripheral address.
@@ -182,7 +182,7 @@ func (i2c I2C) stop() {
182
182
avr .TWCR .Set (avr .TWCR_TWEN | avr .TWCR_TWINT | avr .TWCR_TWSTO )
183
183
184
184
// Wait for stop condition to be executed on bus.
185
- for ( avr .TWCR .Get () & avr .TWCR_TWSTO ) == 0 {
185
+ for ! avr .TWCR .HasBits ( avr .TWCR_TWSTO ) {
186
186
}
187
187
}
188
188
@@ -195,7 +195,7 @@ func (i2c I2C) writeByte(data byte) {
195
195
avr .TWCR .Set (avr .TWCR_TWEN | avr .TWCR_TWINT )
196
196
197
197
// Wait till data is transmitted.
198
- for ( avr .TWCR .Get () & avr .TWCR_TWINT ) == 0 {
198
+ for ! avr .TWCR .HasBits ( avr .TWCR_TWINT ) {
199
199
}
200
200
}
201
201
@@ -205,7 +205,7 @@ func (i2c I2C) readByte() byte {
205
205
avr .TWCR .Set (avr .TWCR_TWEN | avr .TWCR_TWINT | avr .TWCR_TWEA )
206
206
207
207
// Wait till read request is transmitted.
208
- for ( avr .TWCR .Get () & avr .TWCR_TWINT ) == 0 {
208
+ for ! avr .TWCR .HasBits ( avr .TWCR_TWINT ) {
209
209
}
210
210
211
211
return byte (avr .TWDR .Get ())
@@ -239,7 +239,7 @@ func (uart UART) Configure(config UARTConfig) {
239
239
// WriteByte writes a byte of data to the UART.
240
240
func (uart UART ) WriteByte (c byte ) error {
241
241
// Wait until UART buffer is not busy.
242
- for ( avr .UCSR0A .Get () & avr .UCSR0A_UDRE0 ) == 0 {
242
+ for ! avr .UCSR0A .HasBits ( avr .UCSR0A_UDRE0 ) {
243
243
}
244
244
avr .UDR0 .Set (c ) // send char
245
245
return nil
@@ -251,7 +251,7 @@ func handleUSART_RX() {
251
251
data := avr .UDR0 .Get ()
252
252
253
253
// Ensure no error.
254
- if ( avr .UCSR0A .Get () & ( avr .UCSR0A_FE0 | avr .UCSR0A_DOR0 | avr .UCSR0A_UPE0 )) == 0 {
254
+ if ! avr .UCSR0A .HasBits ( avr .UCSR0A_FE0 | avr .UCSR0A_DOR0 | avr .UCSR0A_UPE0 ) {
255
255
// Put data from UDR register into buffer.
256
256
UART0 .Receive (byte (data ))
257
257
}
0 commit comments