From 62c15a9fdaecb085fd2e1e00333a06353f97cc43 Mon Sep 17 00:00:00 2001 From: Christopher Kormanyos Date: Sun, 14 Jan 2024 12:19:52 +0100 Subject: [PATCH] Upgrade architecture and language standard C23 --- build/Makefile | 2 +- src/app/app_hello.c | 6 ------ src/app/app_lcd_util.c | 4 +--- src/app/app_lcd_util.h | 1 - src/app/app_led.c | 5 ----- src/app/app_main.c | 3 ++- src/mcal/mcal_gpt.c | 2 -- src/os/os.c | 20 ++++---------------- src/os/os.h | 1 - 9 files changed, 8 insertions(+), 36 deletions(-) diff --git a/build/Makefile b/build/Makefile index daeaa4e..e63b831 100644 --- a/build/Makefile +++ b/build/Makefile @@ -93,7 +93,7 @@ AFLAGS := -p \ CFLAGS := --Werror \ - --std-c17 \ + --std-c23 \ -mz80 \ --no-std-crt0 \ --code-loc 0x9D9B \ diff --git a/src/app/app_hello.c b/src/app/app_hello.c index 62b7dd9..84b88e5 100644 --- a/src/app/app_hello.c +++ b/src/app/app_hello.c @@ -3,16 +3,10 @@ // Distributed under The Unlicense // -#include - #include static bool app_hello_is_hello; -void app_hello_init(void) -{ -} - void app_hello_task(void) { app_lcd_util_row((uint8_t) UINT8_C(3)); diff --git a/src/app/app_lcd_util.c b/src/app/app_lcd_util.c index 1dcb6fb..39048bb 100644 --- a/src/app/app_lcd_util.c +++ b/src/app/app_lcd_util.c @@ -5,15 +5,13 @@ #include -#define NULL_PTR (void*) 0 - static void app_lcd_util_putc(char c) ATTRIBUTE_NAKED; void app_lcd_util_puts(const char* p_str) { char c; - while((p_str != NULL_PTR) && ((c = *p_str) != '\0')) + while((p_str != nullptr) && ((c = *p_str) != '\0')) { app_lcd_util_putc(c); diff --git a/src/app/app_lcd_util.h b/src/app/app_lcd_util.h index 754ad74..8777581 100644 --- a/src/app/app_lcd_util.h +++ b/src/app/app_lcd_util.h @@ -6,7 +6,6 @@ #ifndef APP_LCD_UTIL_2024_01_07_H #define APP_LCD_UTIL_2024_01_07_H - #include #include #include diff --git a/src/app/app_led.c b/src/app/app_led.c index 8952c5b..10241fb 100644 --- a/src/app/app_led.c +++ b/src/app/app_led.c @@ -7,11 +7,6 @@ static bool app_led_is_on; -void app_led_init(void) -{ - app_lcd_util_init(); -} - void app_led_task(void) { app_lcd_util_row((uint8_t) UINT8_C(2)); diff --git a/src/app/app_main.c b/src/app/app_main.c index a387005..a09b9c8 100644 --- a/src/app/app_main.c +++ b/src/app/app_main.c @@ -3,6 +3,7 @@ // Distributed under The Unlicense // +#include #include #include #include @@ -11,7 +12,7 @@ void main(void) { mcal_gpt_init(); - os_init(); + app_lcd_util_init(); os_schedule(); diff --git a/src/mcal/mcal_gpt.c b/src/mcal/mcal_gpt.c index 28ae823..ea1cf0b 100644 --- a/src/mcal/mcal_gpt.c +++ b/src/mcal/mcal_gpt.c @@ -3,8 +3,6 @@ // Distributed under The Unlicense // -#include - #include #include diff --git a/src/os/os.c b/src/os/os.c index bbde7f8..16d53c3 100644 --- a/src/os/os.c +++ b/src/os/os.c @@ -3,7 +3,6 @@ // Distributed under The Unlicense // -#include #include #include @@ -15,38 +14,27 @@ typedef void(*os_function_type)(void); typedef struct os_task_control_block { - os_function_type p_init; os_function_type p_func; uint8_t cycle; uint8_t timer; } os_task_control_block; -#define OS_COUNTOF(a) ((size_t) (sizeof(a) / sizeof((a)[(size_t) 0U]))) +#define OS_COUNTOF(a) ((size_t) (sizeof(a) / sizeof((a)[(size_t) UINT8_C(0)]))) #define OS_TIMER_TIMEOUT(T) (bool) (((uint8_t) ((uint8_t) (mcal_gpt_get_time_elapsed() - (T)) & (uint8_t) UINT8_C(0x80)) == (uint8_t) UINT8_C(0)) ? true : false) -extern void app_led_init (void); extern void app_led_task (void); -extern void app_hello_init(void); extern void app_hello_task(void); static bool os_wants_exit(void) ATTRIBUTE_NAKED; -static os_task_control_block os_task_list[2U] = +static os_task_control_block os_task_list[(size_t) UINT8_C(2)] = { - { app_led_init, app_led_task, (uint8_t) UINT8_C(1), (uint8_t) UINT8_C(0) }, - { app_hello_init, app_hello_task, (uint8_t) UINT8_C(3), (uint8_t) UINT8_C(0) } + { app_led_task, (uint8_t) UINT8_C(1), (uint8_t) UINT8_C(0) }, + { app_hello_task, (uint8_t) UINT8_C(3), (uint8_t) UINT8_C(0) } }; -void os_init(void) -{ - for(uint8_t task_index = (uint8_t) UINT8_C(0); task_index < (uint8_t) OS_COUNTOF(os_task_list); ++task_index) - { - os_task_list[task_index].p_init(); - } -} - void os_schedule(void) { while(!os_wants_exit()) diff --git a/src/os/os.h b/src/os/os.h index 687ecd6..4c2bfcc 100644 --- a/src/os/os.h +++ b/src/os/os.h @@ -6,7 +6,6 @@ #ifndef OS_2024_01_09_H #define OS_2024_01_09_H - void os_init (void); void os_schedule(void); #endif // OS_2024_01_09_H