重写下面代码:int set_freq_div(timer_handle_t handle, uint32_t divnum) { uint32_t reg; timer_priv_t *timer_priv = handle; switch (timer_priv->timeridx) { case 1: reg = readl(timer_priv->base + TIMER_CCR_CONTROL_C1); reg = (reg & 0xffffffe1) | (divnum << 1); writel(reg, timer_priv->base + TIMER_CCR_CONTROL_C1); break; case 2: reg = readl(timer_priv->base + TIMER_CCR_CONTROL_C2); reg = (reg & 0xffffffe1) | (divnum << 1); writel(reg, timer_priv->base + TIMER_CCR_CONTROL_C2); break; case 3: reg = readl(timer_priv->base + TIMER_CCR_CONTROL_C3); reg = (reg & 0xffffffe1) | (divnum << 1); writel(reg, timer_priv->base + TIMER_CCR_CONTROL_C3); break; default: return -1; } // printf("SET DIV FREQ SUCCESS!\n"); return 0; }
时间: 2023-03-05 09:53:36 浏览: 153
& 0xfffff800) 0x000007ff; reg |= divnum; writel(reg, timer_priv->base + TIMER_CCR_CONTROL_C1); break; case 2: reg = readl(timer_priv->base + TIMER_CCR_CONTROL_C2); reg = (reg & 0xfffff800) 0x000007ff; reg |= divnum; writel(reg, timer_priv->base + TIMER_CCR_CONTROL_C2); break; } return 0; }uint32_t reg;
timer_priv_t *timer_priv = handle;if (timer_priv->timeridx == 1) {
reg = readl(timer_priv->base + TIMER_CCR_CONTROL_C1);
reg = (reg & 0xfffff800) | divnum;
writel(reg, timer_priv->base + TIMER_CCR_CONTROL_C1);
} else if (timer_priv->timeridx == 2) {
reg = readl(timer_priv->base + TIMER_CCR_CONTROL_C2);
reg = (reg & 0xfffff800) | divnum;
writel(reg, timer_priv->base + TIMER_CCR_CONTROL_C2);
}return 0;
阅读全文