|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Eclipse ThreadX CANFD heartbeat / RX-logger demo for RA8D2. More...
#include <stdint.h>#include "ra8_attributes.h"#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_canfd.h"#include "ra8_cgc.h"#include "ra8_err.h"#include "ra8_isr.h"#include "ra8_port_constants.h"#include "ra8_port_utils.h"#include "tx_api.h"Go to the source code of this file.
Enumerations | |
| enum | canfd_marker_t : uint8_t { k_canfd_marker_0 = 0xA5U , k_canfd_marker_1 = 0x5AU , k_canfd_marker_2 = 0x12U , k_canfd_marker_3 = 0x34U , k_canfd_marker_4 = 0x56U , k_canfd_marker_5 = 0x78U , k_canfd_marker_6 = 0x9AU } |
| Stack size, in bytes, for each CANFD demo thread. More... | |
| enum | canfd_stack_t : uint16_t { k_canfd_thread_stack_bytes = 1024U } |
| enum | canfd_priority_t : uint8_t { k_canfd_thread_priority = 4U } |
| Thread priorities. More... | |
| enum | canfd_period_t : uint16_t { k_canfd_heartbeat_ticks = 500U , k_canfd_rx_poll_ticks = 50U , k_canfd_heartbeat_id = 0x123U , k_canfd_heartbeat_dlc = 8U } |
| Period and identifier values used by the heartbeat thread. More... | |
| enum | canfd_link_t : uint32_t { k_canfd_demo_channel = 0U , k_canfd_demo_bitrate = 500000U } |
| CAN-FD channel + bit-rate constants shared by both threads. More... | |
Functions | |
| static void | internal_thread_tx_entry (ULONG thread_input) |
| Heartbeat TX thread: send a CAN-FD frame each period. | |
| static void | internal_thread_rx_entry (ULONG thread_input) |
| RX polling thread: drain the loopback-mirrored frame. | |
| void | tx_application_define (void *first_unused_memory) |
| ThreadX application init – creates the TX and RX threads. | |
| void | main (void) |
| Application entry: GPIO bring-up then ThreadX dispatch. | |
Variables | |
| static uint8_t | s_thread_tx_stack [k_canfd_thread_stack_bytes] |
| static uint8_t | s_thread_rx_stack [k_canfd_thread_stack_bytes] |
| static TX_THREAD | s_thread_tx |
| static TX_THREAD | s_thread_rx |
| volatile uint32_t | g_threadx_canfd_match = 0U |
| HIL success counter – one increment per successful CAN-FD transmit (TX thread) or per accepted RX frame (RX thread). | |
| volatile uint32_t | g_threadx_canfd_mismatch = 0U |
| HIL failure counter – one increment per TX or RX error. | |
Eclipse ThreadX CANFD heartbeat / RX-logger demo for RA8D2.
Two ThreadX threads cooperate over the EK-RA8D2's CANFD0 channel:
The demo exists to prove the ra8_canfd HAL driver wires up cleanly under ThreadX – it is intentionally minimal and does not try to be a full CAN stack. Both threads use static stacks so the binary stays compatible with NASA Power of 10 Rule 3 (no dynamic allocation).
| Name | Priority | Period |
|---|---|---|
| canfd_tx | 4 | 500 ms |
| canfd_rx | 4 | 50 ms (poll loop) |
Definition in file main.c.
| enum canfd_link_t : uint32_t |
| enum canfd_marker_t : uint8_t |
| enum canfd_period_t : uint16_t |
| enum canfd_priority_t : uint8_t |
| enum canfd_stack_t : uint16_t |
|
static |
RX polling thread: drain the loopback-mirrored frame.
Polls ra8_canfd_receive each k_canfd_rx_poll_ticks. On a hit (k_ra8_ok), toggles LED2 and bumps g_threadx_canfd_match. No-data returns are expected between TX bursts and never increment either counter; only genuine HW errors advance the mismatch counter.
| [in] | thread_input | ThreadX cookie – unused. |
Definition at line 215 of file main.c.
References g_threadx_canfd_match, g_threadx_canfd_mismatch, k_canfd_demo_channel, k_canfd_rx_poll_ticks, k_ra8_board_led2, k_ra8_err_no_data, k_ra8_ok, ra8_board_led_toggle(), ra8_canfd_receive(), RA8_INTERNAL, and tx_thread_sleep.
Referenced by tx_application_define().
|
static |
Heartbeat TX thread: send a CAN-FD frame each period.
Builds an 8-byte frame at k_canfd_heartbeat_id and calls ra8_canfd_transmit. The chip is in internal-loopback mode (set in tx_application_define) so the frame appears on the RX FIFO for internal_thread_rx_entry to consume.
| [in] | thread_input | ThreadX cookie – unused. |
Definition at line 160 of file main.c.
References g_threadx_canfd_match, g_threadx_canfd_mismatch, k_canfd_demo_channel, k_canfd_heartbeat_dlc, k_canfd_heartbeat_id, k_canfd_heartbeat_ticks, k_canfd_marker_0, k_canfd_marker_1, k_canfd_marker_2, k_canfd_marker_3, k_canfd_marker_4, k_canfd_marker_5, k_canfd_marker_6, k_ra8_board_led1, k_ra8_ok, ra8_board_led_toggle(), ra8_canfd_transmit(), RA8_INTERNAL, and tx_thread_sleep.
Referenced by tx_application_define().
| void main | ( | void | ) |
Application entry: GPIO bring-up then ThreadX dispatch.
The application entry point Reset_Handler hands control to.
Definition at line 290 of file main.c.
References k_canfd_demo_bitrate, k_canfd_demo_channel, k_ra8_board_led1, k_ra8_board_led2, k_ra8_ctms_self_test_1, k_ra8_ok, ra8_board_led_init(), ra8_canfd_init(), ra8_canfd_set_bitrate(), ra8_canfd_set_test_mode(), ra8_cgc_init(), and ra8_isr_globals_enable().
| void tx_application_define | ( | void * | first_unused_memory | ) |
ThreadX application init – creates the TX and RX threads.
| [in] | first_unused_memory | Unused (we use static stacks). |
Definition at line 241 of file main.c.
References internal_thread_rx_entry(), internal_thread_tx_entry(), k_canfd_thread_priority, k_canfd_thread_stack_bytes, s_thread_rx, s_thread_rx_stack, s_thread_tx, s_thread_tx_stack, TX_AUTO_START, TX_NO_TIME_SLICE, TX_SUCCESS, and tx_thread_create.
| volatile uint32_t g_threadx_canfd_match = 0U |
HIL success counter – one increment per successful CAN-FD transmit (TX thread) or per accepted RX frame (RX thread).
Read externally by scripts/hil/jlink_memprobe.sh via SWD. The probe asserts this counter advances by >= HIL_PROBE_MIN_ADVANCE over the sample window, proving real CAN-FD frames are flowing on the internal-loopback path under ThreadX.
Definition at line 121 of file main.c.
Referenced by internal_thread_rx_entry(), and internal_thread_tx_entry().
| volatile uint32_t g_threadx_canfd_mismatch = 0U |
HIL failure counter – one increment per TX or RX error.
Read externally as HIL_PROBE_FAILURE_SYMBOL. Any non-zero reading means a CAN-FD primitive returned non-ok; the gate fails the run.
Definition at line 134 of file main.c.
Referenced by internal_thread_rx_entry(), and internal_thread_tx_entry().
|
static |
Definition at line 105 of file main.c.
Referenced by tx_application_define().
|
static |
Definition at line 103 of file main.c.
Referenced by tx_application_define().
|
static |
Definition at line 104 of file main.c.
Referenced by tx_application_define().
|
static |
Definition at line 102 of file main.c.
Referenced by tx_application_define().