Skip to content

Commit

Permalink
Upgrade architecture and language standard C23
Browse files Browse the repository at this point in the history
  • Loading branch information
ckormanyos committed Jan 14, 2024
1 parent fb2fc4c commit 62c15a9
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 36 deletions.
2 changes: 1 addition & 1 deletion build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ AFLAGS := -p \


CFLAGS := --Werror \
--std-c17 \
--std-c23 \
-mz80 \
--no-std-crt0 \
--code-loc 0x9D9B \
Expand Down
6 changes: 0 additions & 6 deletions src/app/app_hello.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@
// Distributed under The Unlicense
//

#include <stdbool.h>

#include <app/app_lcd_util.h>

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));
Expand Down
4 changes: 1 addition & 3 deletions src/app/app_lcd_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@

#include <app/app_lcd_util.h>

#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);

Expand Down
1 change: 0 additions & 1 deletion src/app/app_lcd_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#ifndef APP_LCD_UTIL_2024_01_07_H
#define APP_LCD_UTIL_2024_01_07_H

#include <stdbool.h>
#include <stdint.h>

#include <startup/asm_util.h>
Expand Down
5 changes: 0 additions & 5 deletions src/app/app_led.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
3 changes: 2 additions & 1 deletion src/app/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Distributed under The Unlicense
//

#include <app/app_lcd_util.h>
#include <mcal/mcal_gpt.h>
#include <os/os.h>
#include <startup/asm_util.h>
Expand All @@ -11,7 +12,7 @@ void main(void)
{
mcal_gpt_init();

os_init();
app_lcd_util_init();

os_schedule();

Expand Down
2 changes: 0 additions & 2 deletions src/mcal/mcal_gpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// Distributed under The Unlicense
//

#include <stdbool.h>

#include <startup/asm_util.h>
#include <mcal/mcal_gpt.h>

Expand Down
20 changes: 4 additions & 16 deletions src/os/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Distributed under The Unlicense
//

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Expand All @@ -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())
Expand Down
1 change: 0 additions & 1 deletion src/os/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 62c15a9

Please sign in to comment.