From c4314b35efe14fd0c1c57c8c3577431b380e323e Mon Sep 17 00:00:00 2001 From: Victor Mignot Date: Tue, 29 Jul 2025 08:39:33 +0200 Subject: use c99 instead of c23 --- Makefile | 2 +- README.md | 4 ++-- src/clock.c | 12 ++++++------ src/clock.h | 2 +- src/main.c | 1 - 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 8576e6f..053c357 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ ARCH = arm-none-eabi CC = $(ARCH)-gcc -CFLAGS = -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -std=c23 -g -O0 -ffreestanding -Wpedantic -Wall -Wextra -Werror +CFLAGS = -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -std=c99 -g -O0 -ffreestanding -Wpedantic -Wall -Wextra -Werror LDFLAGS = -Tlink.ld -nostdlib SRCDIR = src diff --git a/README.md b/README.md index 9ee6690..5d98261 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ As such, it is by no way intended to be daily-driven by anyone. Moreover, I don't even recommend to flash it on any other hardware than the PineTime dev kit wired to a STLink-V2 interface. -nanji is written in C23. -However, at the time I write this, GCC does not fully support the C23 standard (and as such, can't rely on all new features). +nanji is written in C99 for to be buildable with most compilers. +Moreover, as much as I would like to use C23, its new features are still not all implemented by GCC for the `arm-none-eabi` target. ## Building and flashing diff --git a/src/clock.c b/src/clock.c index 5603693..328ad52 100644 --- a/src/clock.c +++ b/src/clock.c @@ -44,18 +44,18 @@ enum clock_registers { TRACECONFIG = 0x55c, }; -static bool init_hfclk() { +static int init_hfclk() { /* We just assert that the source clock is running with the CPU internal clock * as source */ u32 hfclk_status = READ_CLK_REG(HFCLKSTAT); - int clk_src = hfclk_status & 0x1; - bool clk_running = (hfclk_status >> 16) & 0x1; + u32 clk_src = hfclk_status & 0x1; + u32 clk_running = (hfclk_status >> 16) & 0x1; return (clk_src == HFINT) && clk_running; } -static bool init_lfclk() { - bool clk_started = false; +static int init_lfclk() { + int clk_started = 0; enum lfclk_src src = LFRC; /* LFCLK use the LFRC clock by default, so it should be ready @@ -74,6 +74,6 @@ static bool init_lfclk() { return src == LFRC; } -bool init_clock() { +int init_clock() { return init_hfclk() && init_lfclk(); } diff --git a/src/clock.h b/src/clock.h index 30cfb44..8c5d1f0 100644 --- a/src/clock.h +++ b/src/clock.h @@ -5,6 +5,6 @@ * Init the nrf52832 CLOCK device and ensure that clock sources are correctly * selected. */ -bool init_clock(); +int init_clock(); #endif diff --git a/src/main.c b/src/main.c index 02c20f8..aab0723 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,5 @@ #include "clock.h" -[[noreturn]] void main() { init_clock(); -- cgit v1.2.3