Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tune up example chapter11_07 #590

Merged
merged 2 commits into from
Dec 14, 2024
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
7 changes: 4 additions & 3 deletions examples/chapter11_07/src/app/led/app_led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace
{
using app_led_timer_type = util::timer<std::uint32_t>;
using app_led_tick_type = typename app_led_timer_type::tick_type;

app_led_timer_type app_led_timer_background;
app_led_timer_type app_led_timer_toggle_led0;
Expand All @@ -34,7 +35,7 @@ void app_led_task_background(void*)
mcal::cpu::nop();
}

app_led_timer_background.start_interval(app_led_timer_type::milliseconds(50U));
app_led_timer_background.start_interval(app_led_timer_type::milliseconds(app_led_tick_type { UINT8_C(50) }));

mcal::led::led1().toggle();
}
Expand All @@ -43,7 +44,7 @@ void app_led_task_background(void*)
extern "C"
void app_led_task_toggle_led0(void*)
{
// This application task is intended to yield every 70ms. It has higher
// This application task is intended to yield every 125ms. It has higher
// priority than the background task. This task will, in fact, preemptively
// interrupt the lower-priority background task.

Expand All @@ -53,7 +54,7 @@ void app_led_task_toggle_led0(void*)

if(app_led_timer_toggle_led0.timeout())
{
app_led_timer_toggle_led0.start_interval(app_led_timer_type::seconds(1U));
app_led_timer_toggle_led0.start_interval(app_led_timer_type::seconds(app_led_tick_type { UINT8_C(1) }));

mcal::led::led0().toggle();
}
Expand Down
2 changes: 1 addition & 1 deletion examples/chapter11_07/src/sys/start/sys_start.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace
// Setup the task static resources including the
// task control block structures and task stacks.
OS_TASK_STATIC_RESOURCES(app_led_task_background, 512U);
OS_TASK_STATIC_RESOURCES(app_led_task_toggle_led0, 128U);
OS_TASK_STATIC_RESOURCES(app_led_task_toggle_led0, 32U);
}

#if defined(__AVR__)
Expand Down
8 changes: 4 additions & 4 deletions examples/chapter11_07/target/micros/avr/make/avr.ld
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ _rom_begin = 0x00000000;
_rom_end = 0x00007FFC;

/* The beginning and end (i.e., top) of the stack */
/* Set up a stack with a size of (1/4)K */
_stack_begin = 0x00800800;
/* Set up a the stack */
_stack_begin = 0x00800880;
_stack_end = 0x00800900 - 2;

/* The initial stack pointer (top of stack) is at the top of the 2K RAM */
__initial_stack_pointer = 0x00800900 - 2;

MEMORY
{
ROM(rx) : ORIGIN = 0, LENGTH = 32K - 4
RAM(rw!x) : ORIGIN = 0x00800100, LENGTH = 0x00000800 - 0x00000100
ROM(rx) : ORIGIN = 0, LENGTH = 32K
RAM(rw!x) : ORIGIN = 0x00800100, LENGTH = 0x00000800 - 0x00000080
}

SECTIONS
Expand Down
21 changes: 11 additions & 10 deletions examples/chapter11_07/target/micros/avr/startup/int_vect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#include <array>
#include <cstdint>
#include <FreeRTOS.h>
#include <mcal_cpu.h>

#include <FreeRTOS.h>
#include <array>
#include <cstddef>
#include <cstdint>

extern "C" void __my_startup () __attribute__((section(".startup"), used, noinline));
extern "C" void __vector_unused_irq() __attribute__((signal, used, externally_visible));
#if configUSE_PREEMPTION == 1
#if (defined(configUSE_PREEMPTION) && (configUSE_PREEMPTION == 1))
extern "C" void __vector_11 () __attribute__((signal, used, externally_visible, naked));
#else
extern "C" void __vector_11 () __attribute__((signal, used, externally_visible));
Expand All @@ -31,21 +32,21 @@ void __vector_unused_irq()

namespace
{
typedef struct struct_isr_type
typedef struct isr_type
{
typedef void(*function_type)();
using function_type = void(*)();

const std::uint8_t jmp[2]; // JMP instruction (0x940C): 0x0C = low byte, 0x94 = high byte.
const function_type func; // The interrupt service routine.
const std::uint8_t jmp[std::size_t { UINT8_C(2) }]; // JMP instruction (0x940C): 0x0C = low byte, 0x94 = high byte.
const function_type func; // The interrupt service routine.
}
isr_type;
}

extern "C"
const volatile std::array<isr_type, 26U> __isr_vector __attribute__((section(".isr_vector")));
const volatile std::array<isr_type, std::size_t { UINT8_C(26) }> __isr_vector __attribute__((section(".isr_vector")));

extern "C"
const volatile std::array<isr_type, 26U> __isr_vector =
const volatile std::array<isr_type, std::size_t { UINT8_C(26) }> __isr_vector =
{{
// addr. nr. interrupt source
{ { 0x0C, 0x94 }, __my_startup }, // 0x00, 0, reset
Expand Down
Loading