mirror of
https://xff.cz/git/pinephone-keyboard/
synced 2024-11-09 22:15:42 +01:00
firmware: Fix compilation issue by moving timer code a bit higher
This commit is contained in:
parent
78b438a747
commit
f7c90f1f74
1 changed files with 38 additions and 38 deletions
|
@ -203,6 +203,44 @@ static void jmp_to_user_fw(void) __naked
|
|||
|
||||
#endif
|
||||
|
||||
// }}}
|
||||
// {{{ Timers/delays
|
||||
|
||||
// timers clock is 2 MHz so we need to wait for 2000 ticks to get delay of 1ms
|
||||
#define T0_SET_TIMEOUT(n) { \
|
||||
TL0 = 0x00; \
|
||||
TH0 = (0x10000u - n) >> 8; \
|
||||
TL0 = (0x10000u - n) & 0xff; \
|
||||
}
|
||||
|
||||
#define T1_SET_TIMEOUT(n) { \
|
||||
TL1 = 0x00; \
|
||||
TH1 = (0x10000u - n) >> 8; \
|
||||
TL1 = (0x10000u - n) & 0xff; \
|
||||
}
|
||||
|
||||
#define delay_us(n) { \
|
||||
TL0 = 0x00; \
|
||||
TF0 = 0; \
|
||||
TH0 = (0x10000u - 2 * n) >> 8; \
|
||||
TL0 = (0x10000u - 2 * n) & 0xff; \
|
||||
while (!TF0); \
|
||||
}
|
||||
|
||||
static volatile __bit run_timed_tasks = 0;
|
||||
|
||||
// we use this interrupt as a scheduling tick (wakeup from sleep)
|
||||
|
||||
void timer1_interrupt(void) __interrupt(IRQ_TIMER1) __using(1)
|
||||
{
|
||||
run_timed_tasks = 1;
|
||||
|
||||
// 20 ms
|
||||
T1_SET_TIMEOUT(40000);
|
||||
|
||||
TF1 = 0;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ Original USB bootloader integration
|
||||
|
||||
|
@ -280,44 +318,6 @@ static void usb_bootloader_jump(void) __naked
|
|||
__asm__("ljmp 0x0118");
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ Timers/delays
|
||||
|
||||
// timers clock is 2 MHz so we need to wait for 2000 ticks to get delay of 1ms
|
||||
#define T0_SET_TIMEOUT(n) { \
|
||||
TL0 = 0x00; \
|
||||
TH0 = (0x10000u - n) >> 8; \
|
||||
TL0 = (0x10000u - n) & 0xff; \
|
||||
}
|
||||
|
||||
#define T1_SET_TIMEOUT(n) { \
|
||||
TL1 = 0x00; \
|
||||
TH1 = (0x10000u - n) >> 8; \
|
||||
TL1 = (0x10000u - n) & 0xff; \
|
||||
}
|
||||
|
||||
#define delay_us(n) { \
|
||||
TL0 = 0x00; \
|
||||
TF0 = 0; \
|
||||
TH0 = (0x10000u - 2 * n) >> 8; \
|
||||
TL0 = (0x10000u - 2 * n) & 0xff; \
|
||||
while (!TF0); \
|
||||
}
|
||||
|
||||
static volatile __bit run_timed_tasks = 0;
|
||||
|
||||
// we use this interrupt as a scheduling tick (wakeup from sleep)
|
||||
|
||||
void timer1_interrupt(void) __interrupt(IRQ_TIMER1) __using(1)
|
||||
{
|
||||
run_timed_tasks = 1;
|
||||
|
||||
// 20 ms
|
||||
T1_SET_TIMEOUT(40000);
|
||||
|
||||
TF1 = 0;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ GPIO change interrupt
|
||||
|
||||
|
|
Loading…
Reference in a new issue