From 5fd891ecc06e005cdabf136f9e970677599e0494 Mon Sep 17 00:00:00 2001 From: Ondrej Jirman Date: Mon, 2 Aug 2021 11:53:31 +0200 Subject: [PATCH] firmware: Guard the timer manipulation macro argument --- firmware/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/firmware/main.c b/firmware/main.c index d029d42..c5cbda1 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -212,21 +212,21 @@ static void jmp_to_user_fw(void) __naked // 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; \ + TH0 = (0x10000u - (n)) >> 8; \ + TL0 = (0x10000u - (n)) & 0xff; \ } #define T1_SET_TIMEOUT(n) { \ TL1 = 0x00; \ - TH1 = (0x10000u - n) >> 8; \ - TL1 = (0x10000u - n) & 0xff; \ + 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; \ + TH0 = (0x10000u - 2 * (n)) >> 8; \ + TL0 = (0x10000u - 2 * (n)) & 0xff; \ while (!TF0); \ }