Skip to content

Commit

Permalink
Further simplifiy and tune simul _MSC_VER run
Browse files Browse the repository at this point in the history
  • Loading branch information
ckormanyos committed Jan 31, 2025
1 parent afe0ca0 commit 8951352
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 2,517 deletions.
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 8951352

Please sign in to comment.