Skip to content

Commit 2c8aead

Browse files
committed
refactor(src/machine/nrf52xxx/spi): set default in switch/case
Signed-off-by: Paul Schroeder <milkpirate@users.noreply.github.com>
1 parent f6f779b commit 2c8aead

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/machine/machine_nrf52xxx.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,17 +228,12 @@ func (spi SPI) Configure(config SPIConfig) error {
228228
// Disable bus to configure it
229229
spi.Bus.ENABLE.Set(nrf.SPIM_ENABLE_ENABLE_Disabled)
230230

231-
// Pick a default frequency.
232-
if config.Frequency == 0 {
233-
config.Frequency = 4000000 // 4MHz
234-
}
235-
236231
// set frequency
237232
var freq uint32
238233
switch {
239234
case config.Frequency >= 8000000:
240235
freq = nrf.SPIM_FREQUENCY_FREQUENCY_M8
241-
case config.Frequency >= 4000000:
236+
case config.Frequency >= 4000000, 0: // default
242237
freq = nrf.SPIM_FREQUENCY_FREQUENCY_M4
243238
case config.Frequency >= 2000000:
244239
freq = nrf.SPIM_FREQUENCY_FREQUENCY_M2

0 commit comments

Comments
 (0)