mirror of
https://github.com/andreili/klipper.git
synced 2025-08-24 03:44:06 +02:00
lcd_st7920: Make sure nsecs_to_ticks() is always inlined
It is a compile-time calculation that needs to be inlined to work. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
cb6828ec34
commit
56d3f4e64c
@ -22,19 +22,19 @@ struct st7920 {
|
|||||||
* Transmit functions
|
* Transmit functions
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
static uint32_t
|
static __always_inline uint32_t
|
||||||
nsecs_to_ticks(uint32_t ns)
|
nsecs_to_ticks(uint32_t ns)
|
||||||
{
|
{
|
||||||
return timer_from_us(ns * 1000) / 1000000;
|
return timer_from_us(ns * 1000) / 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static void
|
||||||
ndelay(uint32_t nsecs)
|
ndelay(uint32_t ticks)
|
||||||
{
|
{
|
||||||
if (CONFIG_MACH_AVR)
|
if (CONFIG_MACH_AVR)
|
||||||
// Slower MCUs don't require a delay
|
// Slower MCUs don't require a delay
|
||||||
return;
|
return;
|
||||||
uint32_t end = timer_read_time() + nsecs_to_ticks(nsecs);
|
uint32_t end = timer_read_time() + ticks;
|
||||||
while (timer_is_before(timer_read_time(), end))
|
while (timer_is_before(timer_read_time(), end))
|
||||||
irq_poll();
|
irq_poll();
|
||||||
}
|
}
|
||||||
@ -53,9 +53,9 @@ st7920_xmit_byte(struct st7920 *s, uint8_t data)
|
|||||||
gpio_out_toggle(sid);
|
gpio_out_toggle(sid);
|
||||||
data = ~data;
|
data = ~data;
|
||||||
}
|
}
|
||||||
ndelay(200);
|
ndelay(nsecs_to_ticks(200));
|
||||||
gpio_out_toggle(sclk);
|
gpio_out_toggle(sclk);
|
||||||
ndelay(200);
|
ndelay(nsecs_to_ticks(200));
|
||||||
data <<= 1;
|
data <<= 1;
|
||||||
gpio_out_toggle(sclk);
|
gpio_out_toggle(sclk);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user