Skip to content

Commit

Permalink
Added suport for C23
Browse files Browse the repository at this point in the history
  • Loading branch information
dzid26 committed Jul 17, 2024
1 parent 2fbd343 commit 1a0e7b8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ RELS = $(addprefix $(ODIR)/,$(notdir $(EXTRASRCS:.c=.rel)))
RELS_DEBUG = $(addprefix $(ODIR_DEBUG)/,$(notdir $(EXTRASRCS:.c=.rel)))

override INCLUDES += -I$(IDIR) -I.
override CFLAGS += -m$(PLATFORM) -D$(DEVICE) -Ddouble=float --std-c99 --nolospre --opt-code-speed --peep-asm --peep-file peep.txt
override CFLAGS += -m$(PLATFORM) -D$(DEVICE) -Ddouble=float --std-c23 --nolospre --opt-code-speed --peep-asm --peep-file peep.txt
override DEBUG_FLAGS += --out-fmt-elf --debug -D TIME_DEBUG
LIBS =

Expand Down
2 changes: 1 addition & 1 deletion src/ebike_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static uint32_t ui32_odometer_compensation_mm = ZERO_ODOMETER_COMPENSATION;
static uint8_t ui8_adc_throttle_assist = 0;
volatile uint8_t ui8_throttle_adc_in = 0;
static uint8_t ui8_throttle_mode_array[2] = {THROTTLE_MODE,STREET_MODE_THROTTLE_MODE};
volatile bool pedals_torque_loaded = false;
volatile uint8_t pedals_torque_loaded = 0U;

// cruise control
static uint8_t ui8_cruise_threshold_speed_x10_array[2] = {CRUISE_OFFROAD_THRESHOLD_SPEED_X10,CRUISE_STREET_THRESHOLD_SPEED_X10};
Expand Down
3 changes: 1 addition & 2 deletions src/ebike_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#define EBIKE_APP_H_

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

// startup boost mode
#define CADENCE 0
Expand All @@ -22,7 +21,7 @@ extern volatile uint8_t ui8_system_state;


// pedals are loaded
extern volatile bool pedals_torque_loaded;
extern volatile uint8_t pedals_torque_loaded;

//throttle is enabled and applied
extern volatile uint8_t ui8_throttle_adc_in;
Expand Down
4 changes: 4 additions & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,4 +500,8 @@ HALL_COUNTER_OFFSET_UP: 29 -> 44

#define AVAIABLE_FOR_FUTURE_USE 0 // EEPROM



static_assert(MOTOR_TYPE == 0 || MOTOR_TYPE == 1);

#endif // _MAIN_H_
6 changes: 3 additions & 3 deletions tests/load_c_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#define __asm__(x)
#define __trap
"""
compiler_args = ["-std=c99", "-Wall", "-Wextra"]
compiler_args = ["-std=c23", "-Wall", "-Wextra"]
linker_args = []
custom_parser = '' # actually don't use sdcpp as the cdef stdint definitions should match x86 platform

Expand Down Expand Up @@ -117,7 +117,7 @@ def visit_Typedef(self, n, *args):
def generate_cdef(module_name, src_file):
# exceptions needed on some platforms (mingw)
skip_extensions = ["__attribute__(x)=", "__extension__=", "__MINGW_EXTENSION="]
skip_std_includes = ["_INC_STDIO", "_INC_STDDEF", "__STDDEF_H__", "_MATH_H_", "_INC_CORECRT",]
skip_std_includes = ["_INC_STDIO", "_INC_STDDEF", "__STDDEF_H__", "_MATH_H_", "_INC_CORECRT", "static_assert(x)="]
undef_macros = []
std_include = []
if shutil.which(custom_parser):
Expand All @@ -126,7 +126,7 @@ def generate_cdef(module_name, src_file):
else:
print("Parsing with 'cpp'")
cpp_path = 'cpp'
cpp_args = ["-xc"]
cpp_args = ["-xc", "-std=c2x"]

idirs = [r'-I' + d for d in include_dirs + std_include]
ddefs = [r'-D' + d for d in define_macros + skip_std_includes + skip_extensions]
Expand Down

0 comments on commit 1a0e7b8

Please sign in to comment.