Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/real-time-cpp-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
strategy:
fail-fast: false
matrix:
example: [ chapter02_03, chapter02_03a, chapter03_02, chapter04_04, chapter04_04a, chapter06_01, chapter06_14, chapter09_07, chapter09_08, chapter09_08a, chapter10_08, chapter10_08a, chapter11_07, chapter12_04, chapter16_08, chapter17_03, chapter17_03a ]
example: [ chapter02_03, chapter02_03a, chapter03_02, chapter04_04, chapter04_04a, chapter06_01, chapter06_14, chapter09_07, chapter09_08, chapter09_08a, chapter10_08, chapter10_08a, chapter11_07, chapter11_07a, chapter12_04, chapter16_08, chapter17_03, chapter17_03a ]
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
strategy:
fail-fast: false
matrix:
example: [ chapter02_03, chapter02_03a, chapter03_02, chapter04_04, chapter04_04a, chapter06_01, chapter06_14, chapter09_07, chapter09_08, chapter09_08a, chapter10_08, chapter10_08a, chapter10_09, chapter11_07, chapter12_04, chapter17_03, chapter17_03a ]
example: [ chapter02_03, chapter02_03a, chapter03_02, chapter04_04, chapter04_04a, chapter06_01, chapter06_14, chapter09_07, chapter09_08, chapter09_08a, chapter10_08, chapter10_08a, chapter10_09, chapter11_07, chapter11_07a, chapter12_04, chapter17_03, chapter17_03a ]
steps:
- uses: actions/checkout@v4
with:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
*~
.vscode/
ref_app/.vs/
ref_app/ref_app.vcxproj.user
Expand Down
2 changes: 1 addition & 1 deletion examples/chapter09_08/src/app/led/app_led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ auto app::led::task_func() -> void
magenta_to_red
};

using app_led_rgb_timer_type = util::timer<std::uint16_t>;
using app_led_rgb_timer_type = util::timer<std::uint32_t>;

static app_led_rgb_timer_type app_led_rgb_timer { app_led_rgb_timer_type::milliseconds(UINT8_C(30)) };

Expand Down
2 changes: 1 addition & 1 deletion examples/chapter09_08a/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@set TOOL_PATH=%1
@set TOOL_PREFIX=%2

@set CFLAGS=-Wall -Wextra -Wpedantic -O2 -mmcu=atmega328p -fsigned-char -fno-exceptions
@set CFLAGS=-Wall -Wextra -Wpedantic -O2 -mmcu=atmega328p -fsigned-char -fno-exceptions -gdwarf-2
@set CPPFLAGS=-std=c++14 -fno-rtti -fstrict-enums -fno-use-cxa-atexit -fno-use-cxa-get-exception-ptr -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs
@set CINCLUDES=-Isrc/util/STL_C++XX_stdfloat -Isrc/util/STL -Isrc -Isrc/mcal/avr

Expand Down
2 changes: 1 addition & 1 deletion examples/chapter09_08a/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#
# If command
# /usr/bin/avr-g++
# installed, e.g. via command sudo apt-get install gcc-avr avr-libc
# installed, e.g. via command sudo apt-get install gcc-avr avr-libc
# then:
# ./build.sh
#
Expand Down
4 changes: 2 additions & 2 deletions examples/chapter09_08a/src/app/led/app_led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ auto app::led::task_func() -> void
// Toggle the monochrome user LED at 1/2 Hz.
mcal::led::led0().toggle();

// Start the next timer interval for the monochrome user LED.
// Start the next 1s timer interval for the monochrome user LED.
app_led_monochrome_timer.start_interval(app_led_monochrome_timer_type::seconds(1U));
}

Expand All @@ -54,7 +54,7 @@ auto app::led::task_func() -> void
magenta_to_red
};

using app_led_rgb_timer_type = util::timer<std::uint16_t>;
using app_led_rgb_timer_type = util::timer<std::uint32_t>;

static app_led_rgb_timer_type app_led_rgb_timer { app_led_rgb_timer_type::milliseconds(UINT8_C(30)) };

Expand Down
2 changes: 1 addition & 1 deletion examples/chapter09_08b/src/app/led/app_led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ auto app::led::task_func() -> void
magenta_to_red
};

using app_led_rgb_timer_type = util::timer<std::uint16_t>;
using app_led_rgb_timer_type = util::timer<std::uint32_t>;

static app_led_rgb_timer_type app_led_rgb_timer { app_led_rgb_timer_type::milliseconds(UINT8_C(30)) };

Expand Down
4 changes: 4 additions & 0 deletions examples/chapter10_08a/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,15 @@ read/write operations on the driver level.
| 47 | BYTE_NOT | GND |
| 48 | A16 | Port Expander GPB_4 |

### 2MB Setup

The hardware setup with the $2~\text{MByte}$ SRAM brick
is pictured in the image below.

![](./images/board10_08a_2MB.jpg)

### 1MB Setup

The hardware setup with the $1~\text{MByte}$ SRAM brick
is pictured in the image below.

Expand Down
2 changes: 1 addition & 1 deletion examples/chapter11_07/src/app/led/app_led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void app_led_task_toggle_led0(void*)
mcal::led::led0().toggle();
}

// This application task is programmed to yield every 125ms.
// This application task is programmed to cyclically yield for 125ms.

OS_TASK_WAIT_YIELD(TickType_t { UINT8_C(125) });
}
Expand Down
4 changes: 2 additions & 2 deletions examples/chapter11_07/src/sys/start/sys_start.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#include <os/os_task.h>

#if defined(__AVR__)
extern "C" int main(void) __attribute__((used, noinline));
auto main(void) -> int __attribute__((used, noinline));
#endif

extern "C" int main(void)
auto main(void) -> int
{
// Initialize the microcontroller abstraction layer.
mcal::init();
Expand Down
2 changes: 1 addition & 1 deletion examples/chapter11_07/target/micros/avr/make/avr_flags.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# ------------------------------------------------------------------------------

ifneq ($(MAKE),make)
GCC_VERSION = 14.2.0
GCC_VERSION = 15.1.0
endif
GCC_TARGET = avr
GCC_PREFIX = avr
Expand Down
2 changes: 1 addition & 1 deletion examples/chapter11_07/target/micros/avr/startup/crt0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace crt

extern "C" void __my_startup() __attribute__((section(".startup"), used, noinline));

extern "C" int main(void) __attribute__((used, noinline));
extern auto main(void) -> int __attribute__((used, noinline));

void __my_startup()
{
Expand Down
147 changes: 147 additions & 0 deletions examples/chapter11_07a/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@

@rem
@rem Copyright Christopher Kormanyos 2014 - 2025.
@rem Distributed under the Boost Software License,
@rem Version 1.0. (See accompanying file LICENSE_1_0.txt
@rem or copy at http://www.boost.org/LICENSE_1_0.txt)
@rem


@rem
@rem Usage:
@rem build.bat directory_of_gcc_bin prefix_of_avr_gcc

@rem Usage example A,
@rem cd "C:\Users\ckorm\Documents\Ks\uC_Software\Boards\real-time-cpp\examples\chapter11_07a"
@rem build.bat "C:\Users\ckorm\Documents\Ks\uC_Software\Boards\real-time-cpp\examples\chapter11_07a\tools\Util\msys64\usr\local\gcc-15.1.0-avr\bin" avr

@rem Usage example A1 (use a relative tool path),
@rem cd "C:\Users\ckorm\Documents\Ks\uC_Software\Boards\real-time-cpp\examples\chapter11_07a"
@rem build.bat ".\tools\Util\msys64\usr\local\gcc-15.1.0-avr\bin" avr

@rem Usage example B,
@rem cd "C:\Users\ckorm\Documents\Ks\uC_Software\Boards\real-time-cpp\examples\chapter11_07a"
@rem build.bat "C:\Program Files (x86)\gcc-15.1.0-avr\bin" avr


@set TOOL_PATH=%1
@set TOOL_PREFIX=%2

@set CFLAGS=-C -Wall -Wextra -Wpedantic -O2 -mmcu=atmega328p -fsigned-char -fno-exceptions -gdwarf-2
@set CPPFLAGS=-std=c++14 -fno-rtti -fstrict-enums -fno-use-cxa-atexit -fno-use-cxa-get-exception-ptr -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs
@set CINCLUDES=-Isrc/os/FreeRTOS/Source/include/cfg/GCC-ATMega328 -Isrc/os/FreeRTOS/Source/portable/GCC-ATMega328 -Isrc/os/FreeRTOS/Source/include -Isrc/util/STL -Isrc/mcal/avr -Isrc/app -Isrc

@echo.
@echo.Building with : build.bat
@echo.Using tool path : %TOOL_PATH%
@echo.Using tool prefix : %TOOL_PREFIX%
@echo.Create bin directory : bin\
@if not exist bin mkdir bin
@echo.Clean bin directory : bin\*.o bin\chapter11_07a*.*
@if exist bin\*.o del /Q bin\*.o
@if exist bin\chapter11_07a*.* del /Q bin\chapter11_07a*.*
@echo.

@echo.Compile : app_led.cpp to bin/app_led.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c src/app/led/app_led.cpp -o bin/app_led.o

@echo.Compile : pi_spigot.cpp to bin/pi_spigot.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c src/app/pi_spigot/pi_spigot.cpp -o bin/pi_spigot.o

@echo.Compile : pi_spigot_callback.cpp to bin/pi_spigot_callback.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c src/app/pi_spigot/pi_spigot_callback.cpp -o bin/pi_spigot_callback.o

@echo.Compile : mcal.cpp to bin/mcal.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c src/mcal/mcal.cpp -o bin/mcal.o

@echo.Compile : mcal_gcc_cxx_completion.cpp to bin/mcal_gcc_cxx_completion.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c src/mcal/mcal_gcc_cxx_completion.cpp -o bin/mcal_gcc_cxx_completion.o

@echo.Compile : mcal_cpu.cpp to bin/mcal_cpu.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c src/mcal/avr/mcal_cpu.cpp -o bin/mcal_cpu.o

@echo.Compile : mcal_dev.cpp to bin/mcal_dev.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c src/mcal/avr/mcal_dev.cpp -o bin/mcal_dev.o

@echo.Compile : mcal_gpt.cpp to bin/mcal_gpt.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c src/mcal/avr/mcal_gpt.cpp -o bin/mcal_gpt.o

@echo.Compile : mcal_irq.cpp to bin/mcal_irq.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c src/mcal/avr/mcal_irq.cpp -o bin/mcal_irq.o

@echo.Compile : mcal_lcd.cpp to bin/mcal_lcd.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c src/mcal/avr/mcal_lcd.cpp -o bin/mcal_lcd.o

@echo.Compile : mcal_led.cpp to bin/mcal_led.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c src/mcal/avr/mcal_led.cpp -o bin/mcal_led.o

@echo.Compile : mcal_memory_sram.cpp to bin/mcal_memory_sram.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c src/mcal/avr/mcal_memory_sram.cpp -o bin/mcal_memory_sram.o

@echo.Compile : mcal_osc.cpp to bin/mcal_osc.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c src/mcal/avr/mcal_osc.cpp -o bin/mcal_osc.o

@echo.Compile : mcal_port.cpp to bin/mcal_port.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c src/mcal/avr/mcal_port.cpp -o bin/mcal_port.o

@echo.Compile : mcal_wdg.cpp to bin/mcal_wdg.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c src/mcal/avr/mcal_wdg.cpp -o bin/mcal_wdg.o

@echo.Compile : event_groups.c to bin/event_groups.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c %CFLAGS% -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast %CINCLUDES% -c src/os/FreeRTOS/Source/event_groups.c -o bin/event_groups.o

@echo.Compile : list.c to bin/list.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c %CFLAGS% -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast %CINCLUDES% -c src/os/FreeRTOS/Source/list.c -o bin/list.o

@echo.Compile : queue.c to bin/queue.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c %CFLAGS% -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast %CINCLUDES% -c src/os/FreeRTOS/Source/queue.c -o bin/queue.o

@echo.Compile : tasks.c to bin/tasks.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c %CFLAGS% -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast %CINCLUDES% -c src/os/FreeRTOS/Source/tasks.c -o bin/tasks.o

@echo.Compile : application.c to bin/application.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c %CFLAGS% -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast %CINCLUDES% -c src/os/FreeRTOS/Source/application/application.c -o bin/application.o

@echo.Compile : port.cpp to bin/port.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c src/os/FreeRTOS/Source/portable/GCC-ATMega328/port.cpp -o bin/port.o

@echo.Compile : sys_start.cpp to bin/sys_start.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c src/sys/start/sys_start.cpp -o bin/sys_start.o

@echo.Compile : crt0.cpp to bin/crt0.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c target/micros/avr/startup/crt0.cpp -o bin/crt0.o

@echo.Compile : crt0_init_ram.cpp to bin/crt0_init_ram.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c target/micros/avr/startup/crt0_init_ram.cpp -o bin/crt0_init_ram.o

@echo.Compile : crt1.cpp to bin/crt1.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c target/micros/avr/startup/crt1.cpp -o bin/crt1.o

@echo.Compile : int_vect.cpp to bin/int_vect.o
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x c++ %CFLAGS% %CPPFLAGS% %CINCLUDES% -c target/micros/avr/startup/int_vect.cpp -o bin/int_vect.o

@echo.Link : objects to bin/chapter11_07a.elf
@%TOOL_PATH%\%TOOL_PREFIX%-g++ -x none -mrelax -nostartfiles %CFLAGS% %CPPFLAGS% %CINCLUDES% -Wl,--gc-sections -Wl,-Ttarget/micros/avr/make/avr.ld,-Map,bin/chapter11_07a.map bin/app_led.o bin/pi_spigot.o bin/pi_spigot_callback.o bin/mcal.o bin/mcal_gcc_cxx_completion.o bin/mcal_cpu.o bin/mcal_dev.o bin/mcal_gpt.o bin/mcal_irq.o bin/mcal_lcd.o bin/mcal_led.o bin/mcal_memory_sram.o bin/mcal_osc.o bin/mcal_port.o bin/mcal_wdg.o bin/event_groups.o bin/list.o bin/queue.o bin/tasks.o bin/application.o bin/port.o bin/sys_start.o bin/crt0.o bin/crt0_init_ram.o bin/crt1.o bin/int_vect.o -o bin/chapter11_07a.elf

@echo.
@echo.Extract : executable hex file : from bin/chapter11_07a.elf
@%TOOL_PATH%\%TOOL_PREFIX%-objcopy -O ihex bin/chapter11_07a.elf bin/chapter11_07a.hex

@echo.Extract : assembly list file : from bin/chapter11_07a.elf
@%TOOL_PATH%\%TOOL_PREFIX%-objdump --disassemble bin/chapter11_07a.elf > bin/chapter11_07a.lss

@echo.Extract : size information : from bin/chapter11_07a.elf
@%TOOL_PATH%\%TOOL_PREFIX%-size -A -t bin/chapter11_07a.elf > bin\chapter11_07a_size.txt

@echo.Extract : name information : from bin/chapter11_07a.elf
@%TOOL_PATH%\%TOOL_PREFIX%-nm --numeric-sort --print-size bin/chapter11_07a.elf > bin\chapter11_07a_nm.txt

@echo.Extract : demangled names : from bin/chapter11_07a.elf
@%TOOL_PATH%\%TOOL_PREFIX%-nm --numeric-sort --print-size bin/chapter11_07a.elf | %TOOL_PATH%\%TOOL_PREFIX%-c++filt > bin\chapter11_07a_cppfilt.txt

dir .\bin\chapter11_07a.elf .\bin\chapter11_07a.hex

if not exist .\bin\chapter11_07a.elf exit 1
if not exist .\bin\chapter11_07a.hex exit 1

rem exit 0
Loading
Loading