some trivial fix

use less #[cfg] macro; reuse same variable
This commit is contained in:
eZio Pan 2023-12-30 12:01:08 +08:00
parent 24f569821c
commit 873ee06151
2 changed files with 9 additions and 10 deletions

View file

@ -177,15 +177,14 @@ where
let req = self.dma.request();
#[cfg(not(any(bdma, gpdma)))]
let dma_regs = self.dma.regs();
#[cfg(not(any(bdma, gpdma)))]
let isr_num = self.dma.num() / 4;
#[cfg(not(any(bdma, gpdma)))]
let isr_bit = self.dma.num() % 4;
#[cfg(not(any(bdma, gpdma)))]
let isr_reg = dma_regs.isr(isr_num);
#[cfg(not(any(bdma, gpdma)))]
let ifcr_reg = dma_regs.ifcr(isr_num);
let (isr_bit, isr_reg, ifcr_reg) = {
let dma_regs = self.dma.regs();
let isr_num = self.dma.num() / 4;
let isr_bit = self.dma.num() % 4;
let isr_reg = dma_regs.isr(isr_num);
let ifcr_reg = dma_regs.ifcr(isr_num);
(isr_bit, isr_reg, ifcr_reg)
};
#[cfg(not(any(bdma, gpdma)))]
// clean DMA FIFO error before a transfer

View file

@ -91,7 +91,7 @@ async fn main(_spawner: Spawner) {
loop {
for &color in color_list {
ws2812_pwm.gen_waveform(Channel::Ch1, color).await;
ws2812_pwm.gen_waveform(pwm_channel, color).await;
// ws2812 need at least 50 us low level input to confirm the input data and change it's state
Timer::after_micros(50).await;
// wait until ticker tick