Skip to content

Commit

Permalink
Merge pull request #602 from ckormanyos/refactor_11_07
Browse files Browse the repository at this point in the history
Further simplifiy and tune simul _MSC_VER run
  • Loading branch information
ckormanyos authored Jan 31, 2025
2 parents 6ef81a3 + a15ca31 commit ce9eace
Show file tree
Hide file tree
Showing 14 changed files with 91 additions and 2,531 deletions.
9 changes: 3 additions & 6 deletions examples/chapter11_07/build.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

@rem
@rem Copyright Christopher Kormanyos 2014 - 2021.
@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)
Expand Down Expand Up @@ -84,10 +84,7 @@
@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 : timers.c to bin/timers.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/timers.c -o bin/timers.o

@echo.Compile : timers.c to bin/timers.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
Expand All @@ -109,7 +106,7 @@
@%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_07.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_07.map bin/app_led.o bin/mcal.o bin/mcal_gcc_cxx_completion.o bin/mcal_cpu.o bin/mcal_gpt.o bin/mcal_irq.o bin/mcal_led.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/timers.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_07.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_07.map bin/app_led.o bin/mcal.o bin/mcal_gcc_cxx_completion.o bin/mcal_cpu.o bin/mcal_gpt.o bin/mcal_irq.o bin/mcal_led.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_07.elf

@echo.
@echo.Extract : executable hex file : from bin/chapter11_07.elf
Expand Down
7 changes: 2 additions & 5 deletions examples/chapter11_07/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# Copyright Christopher Kormanyos 2014 - 2020.
# Copyright Christopher Kormanyos 2014 - 2025.
# Distributed under the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt
# or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand Down Expand Up @@ -103,9 +103,6 @@ $TOOL_PATH/$TOOL_PREFIX-g++ -x c $CFLAGS -Wno-int-to-pointer-cast -Wno-pointer-t
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 : timers.c to bin/timers.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/timers.c -o bin/timers.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

Expand All @@ -128,7 +125,7 @@ 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_07.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_07.map bin/app_led.o bin/mcal.o bin/mcal_gcc_cxx_completion.o bin/mcal_cpu.o bin/mcal_gpt.o bin/mcal_irq.o bin/mcal_led.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/timers.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_07.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_07.map bin/app_led.o bin/mcal.o bin/mcal_gcc_cxx_completion.o bin/mcal_cpu.o bin/mcal_gpt.o bin/mcal_irq.o bin/mcal_led.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_07.elf

echo
echo "Extract : executable hex file : from bin/chapter11_07.elf"
Expand Down
3 changes: 0 additions & 3 deletions examples/chapter11_07/chapter11_07.cppproj
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,6 @@
<Compile Include="src\os\FreeRTOS\Source\tasks.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="src\os\FreeRTOS\Source\timers.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="src\os\os_task.h">
<SubType>compile</SubType>
</Compile>
Expand Down
1 change: 0 additions & 1 deletion examples/chapter11_07/chapter11_07.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@
<ClCompile Include="src\os\FreeRTOS\Source\portable\MSVC-MingW\port.c" />
<ClCompile Include="src\os\FreeRTOS\Source\queue.c" />
<ClCompile Include="src\os\FreeRTOS\Source\tasks.c" />
<ClCompile Include="src\os\FreeRTOS\Source\timers.c" />
<ClCompile Include="src\sys\start\sys_start.cpp" />
<ClCompile Include="src\util\STD_LIBC\memory.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
Expand Down
3 changes: 0 additions & 3 deletions examples/chapter11_07/chapter11_07.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,6 @@
<ClCompile Include="src\os\FreeRTOS\Source\tasks.c">
<Filter>src\os\FreeRTOS\Source</Filter>
</ClCompile>
<ClCompile Include="src\os\FreeRTOS\Source\timers.c">
<Filter>src\os\FreeRTOS\Source</Filter>
</ClCompile>
<ClCompile Include="src\os\FreeRTOS\Source\portable\MSVC-MingW\port.c">
<Filter>src\os\FreeRTOS\Source\portable\MSVC-MingW</Filter>
</ClCompile>
Expand Down
26 changes: 22 additions & 4 deletions examples/chapter11_07/src/app/led/app_led.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2024.
// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -24,14 +24,32 @@ namespace
extern "C"
void app_led_task_background(void*)
{
// This background task runs perpetually without pause, break or yield.
// This task has lowest priority and will be interrupted by the task
// having higher priority.
// This background task runs perpetually without pause, break or yield
// (unless running on _MSC_VER, where there is a yield for task break).

// This task has lowest priority and will be interrupted by any other
// task having higher priority, such as the LED 1/2 Hz toggle task
// (i.e., app_led_timer_toggle_led0).

for(;;)
{
while((!app_led_timer_background.timeout()))
{
#if defined(_MSC_VER)
{
#if defined(__AVR__)
#error This code sequence is not intended fof __AVR__;
#endif

static unsigned prescaler { };

if(unsigned { ++prescaler % unsigned { UINT8_C(8) } } == unsigned { UINT8_C(0) })
{
OS_TASK_WAIT_YIELD(OS_TASK_MSEC(TickType_t { UINT8_C(3) }));
}
}
#endif

mcal::cpu::nop();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,3 @@ void vApplicationGetIdleTaskMemory(StaticTask_t** ppxIdleTaskTCBBuffer,
// the stack and so not exists after this function exits.
StaticTask_t xTimerTaskTCB;
StackType_t uxTimerTaskStack[configMINIMAL_STACK_SIZE];

// configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
// application must provide an implementation of vApplicationGetTimerTaskMemory()
// to provide the memory that is used by the Timer service task.
void vApplicationGetTimerTaskMemory(StaticTask_t** ppxTimerTaskTCBBuffer,
StackType_t** ppxTimerTaskStackBuffer,
uint32_t* pulTimerTaskStackSize)
{
// Pass out a pointer to the StaticTask_t structure in which the Timer
// task's state will be stored.
*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;

// Pass out the array that will be used as the Timer task's stack.
*ppxTimerTaskStackBuffer = uxTimerTaskStack;

// Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
// Note that, as the array is necessarily of type StackType_t,
// configMINIMAL_STACK_SIZE is specified in words, not bytes.
*pulTimerTaskStackSize = sizeof(uxTimerTaskStack) / sizeof(StackType_t);
}
Loading

0 comments on commit ce9eace

Please sign in to comment.