From 9e1ef601e05f3396e40d9a0f1620d64df37fdd74 Mon Sep 17 00:00:00 2001 From: Christopher Kormanyos Date: Thu, 11 Jan 2024 22:16:13 +0100 Subject: [PATCH] Simplify implementations --- build/Makefile | 5 +++-- src/app/app_hello.c | 31 +++++-------------------------- src/app/app_lcd_util.c | 18 ++++++------------ src/app/app_lcd_util.h | 7 ++++--- src/app/app_led.c | 29 +++++------------------------ 5 files changed, 23 insertions(+), 67 deletions(-) diff --git a/build/Makefile b/build/Makefile index ce28a66..5ce721d 100644 --- a/build/Makefile +++ b/build/Makefile @@ -129,7 +129,7 @@ version: ##############################################################################80 # file lists/paths -# VPATH is required for GNUmake to find the C and assembly source files +# VPATH is used by GNUmake to find the C and assembly source files. ##############################################################################80 SUFFIX_OBJ := rel @@ -147,7 +147,7 @@ VPATH := $(sort $(dir $(FILES_PRJ)) $(PATH_OBJ)) ##############################################################################80 -# compile/link/hex-manip rules +# compile/link ##############################################################################80 $(PATH_BIN)/refapp.ihx : $(FILES_OBJ) @@ -188,6 +188,7 @@ clean: ##############################################################################80 # pattern rules +# Delete default suffixes with .SUFFIXES. We do not use implicit rules. ##############################################################################80 .SUFFIXES: diff --git a/src/app/app_hello.c b/src/app/app_hello.c index b593f14..62b7dd9 100644 --- a/src/app/app_hello.c +++ b/src/app/app_hello.c @@ -7,41 +7,20 @@ #include -static void app_hello_hello(void); -static void app_hello_world(void); -static void app_hello_clear(void); - static bool app_hello_is_hello; - void app_hello_init(void) { } void app_hello_task(void) { - app_hello_clear(); + app_lcd_util_row((uint8_t) UINT8_C(3)); + app_lcd_util_col((uint8_t) UINT8_C(6)); + app_lcd_util_puts(" "); + app_lcd_util_col((uint8_t) UINT8_C(6)); - (!app_hello_is_hello) ? app_hello_hello() : app_hello_world(); + (!app_hello_is_hello) ? app_lcd_util_puts("hello") : app_lcd_util_puts("world"); app_hello_is_hello = (bool) (!app_hello_is_hello); } - -static void app_hello_hello(void) -{ - app_lcd_util_home2(); - app_lcd_util_puts("hello"); -} - -static void app_hello_world(void) -{ - app_lcd_util_home2(); - app_lcd_util_puts("world"); -} - -static void app_hello_clear(void) -{ - app_lcd_util_home2(); - app_lcd_util_puts(" "); -} - diff --git a/src/app/app_lcd_util.c b/src/app/app_lcd_util.c index 56bf74d..ead0129 100644 --- a/src/app/app_lcd_util.c +++ b/src/app/app_lcd_util.c @@ -21,24 +21,18 @@ void app_lcd_util_puts(const char* p_str) } } -void app_lcd_util_home1(void) ATTRIBUTE_NAKED +void app_lcd_util_row(const char row) ATTRIBUTE_NAKED { - __asm__("ld b,#0x02\n"); - __asm__("ld a,b\n"); + (void) row; + __asm__("ld (#0x844B), a\n"); - __asm__("ld b,#0x06\n"); - __asm__("ld a,b\n"); - __asm__("ld (#0x844C), a\n"); __asm__("ret\n"); } -void app_lcd_util_home2(void) ATTRIBUTE_NAKED +void app_lcd_util_col(const char col) ATTRIBUTE_NAKED { - __asm__("ld b,#0x03\n"); - __asm__("ld a,b\n"); - __asm__("ld (#0x844B), a\n"); - __asm__("ld b,#0x06\n"); - __asm__("ld a,b\n"); + (void) col; + __asm__("ld (#0x844C), a\n"); __asm__("ret\n"); } diff --git a/src/app/app_lcd_util.h b/src/app/app_lcd_util.h index 826c77c..3bdb697 100644 --- a/src/app/app_lcd_util.h +++ b/src/app/app_lcd_util.h @@ -26,8 +26,9 @@ void app_lcd_util_puts(const char* p_str); - void app_lcd_util_home1(void) ATTRIBUTE_NAKED; - void app_lcd_util_home2(void) ATTRIBUTE_NAKED; - void app_lcd_util_init (void) ATTRIBUTE_NAKED; + void app_lcd_util_row(const char row) ATTRIBUTE_NAKED; + void app_lcd_util_col(const char col) ATTRIBUTE_NAKED; + + void app_lcd_util_init(void) ATTRIBUTE_NAKED; #endif // APP_LED_UTIL_2024_01_07_H diff --git a/src/app/app_led.c b/src/app/app_led.c index 5cb1490..8952c5b 100644 --- a/src/app/app_led.c +++ b/src/app/app_led.c @@ -5,10 +5,6 @@ #include -static void app_led_on (void); -static void app_led_off(void); -static void app_led_clr(void); - static bool app_led_is_on; void app_led_init(void) @@ -18,27 +14,12 @@ void app_led_init(void) void app_led_task(void) { - app_led_clr(); + app_lcd_util_row((uint8_t) UINT8_C(2)); + app_lcd_util_col((uint8_t) UINT8_C(6)); + app_lcd_util_puts(" "); + app_lcd_util_col((uint8_t) UINT8_C(6)); - (!app_led_is_on) ? app_led_on() : app_led_off(); + (!app_led_is_on) ? app_lcd_util_puts("ON ") : app_lcd_util_puts("OFF"); app_led_is_on = (bool) (!app_led_is_on); } - -static void app_led_on(void) -{ - app_lcd_util_home1(); - app_lcd_util_puts("ON "); -} - -static void app_led_off(void) -{ - app_lcd_util_home1(); - app_lcd_util_puts("OFF"); -} - -static void app_led_clr(void) -{ - app_lcd_util_home1(); - app_lcd_util_puts(" "); -}