|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
LIN commander frame-driver HIL demo for EK-RA8D2 (SCI2 on Pmod1). More...
#include <stdint.h>#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_err.h"#include "ra8_gpio_constants.h"#include "ra8_isr.h"#include "ra8_port_constants.h"#include "ra8_port_utils.h"#include "ra8_sci_lin.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | lin_hil_config_t : uint32_t { k_lin_hil_console_baud = 115200U , k_lin_hil_lin_baud = 19200U , k_lin_hil_pclk_hz = 60000000U , k_lin_hil_period_ms = 500U } |
| Compile-time settings for the LIN commander demo. More... | |
| enum | lin_hil_frame_t : uint8_t { k_lin_hil_channel = 2U , k_lin_hil_id_count = 4U , k_lin_hil_data_len = 2U } |
| LIN channel + frame constants. More... | |
| enum | lin_hil_break_t : uint16_t { k_lin_hil_break_len = 0x00A0U } |
| Break-field length programmed into XCR2.BFLW. More... | |
| enum | lin_hil_id_t : uint8_t { k_lin_hil_id_0 = 0x01U , k_lin_hil_id_1 = 0x02U , k_lin_hil_id_2 = 0x11U , k_lin_hil_id_3 = 0x3CU } |
| The four rotating demo frame ids (arbitrary 6-bit LIN identifiers). More... | |
| enum | lin_hil_payload_byte_t : uint8_t { k_lin_hil_pay_0 = 0xA5U , k_lin_hil_pay_1 = 0x5AU } |
| The two-byte demo response payload bytes. More... | |
Functions | |
| static void | lin_hil_panic_halt (void) |
| Halt forever in WFI – used as a panic stop on init failure. | |
| static void | lin_hil_setup_or_halt (void) |
| Bring up CGC + SysTick + console + LED, route Pmod1, init LIN. | |
| static ra8_err_t | lin_hil_send_frame (uint8_t id) |
| Send one LIN frame: header + published data response. | |
| void | main (void) |
| Application entry. | |
Variables | |
| static const uint8_t | k_lin_hil_ids [k_lin_hil_id_count] |
| Rotating demo frame ids (arbitrary 6-bit LIN identifiers). | |
| static const uint8_t | k_lin_hil_payload [k_lin_hil_data_len] |
| Two-byte response payload published for every frame. | |
| static const uint8_t | k_lin_hil_banner [] = "lin_commander_hil: SCI2 LIN commander up\r\n" |
| Banner + per-frame markers (must remain 7-bit ASCII). | |
| static const uint8_t | k_lin_hil_frame_msg [] = "lin_commander_hil: frame sent\r\n" |
| static const uint8_t | k_lin_hil_fault_msg [] = "lin_commander_hil: LIN TX error\r\n" |
LIN commander frame-driver HIL demo for EK-RA8D2 (SCI2 on Pmod1).
Drives a Local Interconnect Network (LIN) commander on SCI2, whose TXD2 / RXD2 signals are broken out on the EK-RA8D2 Pmod1 header (J26, P801 = TXD2, P802 = RXD2). Once a period it emits one LIN frame – a header (break + SYNC 0x55 + protected identifier) followed by a published data response (payload bytes + enhanced checksum) – rotating through a small set of frame ids, and reports progress on the J-Link OB console (SCI8 @ 115200 8N1) while blinking LED1.
Sequence:
Definition in file main.c.
| enum lin_hil_break_t : uint16_t |
Break-field length programmed into XCR2.BFLW.
The dominant break time is (BFLW + 1) x (TCLK / 16) (div16 timer clock). This illustrative value yields a break comfortably longer than the 13-bit-time LIN minimum at the demo baud; tune it to the actual SCICLK when validating on the bench.
| Enumerator | |
|---|---|
| k_lin_hil_break_len | XCR2.BFLW break-field length. |
| enum lin_hil_config_t : uint32_t |
| enum lin_hil_frame_t : uint8_t |
| enum lin_hil_id_t : uint8_t |
| enum lin_hil_payload_byte_t : uint8_t |
|
static |
Halt forever in WFI – used as a panic stop on init failure.
Definition at line 126 of file main.c.
Referenced by lin_hil_setup_or_halt(), and main().
|
static |
Send one LIN frame: header + published data response.
Emits the break + SYNC + PID header for id and then publishes the demo payload with the enhanced (PID-folded) checksum, exercising the commander transmit path end-to-end.
| [in] | id | 6-bit LIN frame identifier to drive. |
| k_ra8_ok | Header + response clocked out. |
| other | Propagated from the LIN driver. |
Definition at line 216 of file main.c.
References k_lin_hil_channel, k_lin_hil_data_len, k_lin_hil_payload, k_ra8_ok, k_ra8_sci_lin_checksum_enhanced, ra8_sci_lin_pid(), ra8_sci_lin_send_header(), and ra8_sci_lin_send_response().
Referenced by main().
|
static |
Bring up CGC + SysTick + console + LED, route Pmod1, init LIN.
The LIN commander lives on SCI2; its TXD2 (P801) and RXD2 (P802) are routed to SCI async before ra8_sci_lin_init programs the Simple-LIN break-field timer. Any failure panic-halts so the fault is visible on a debugger.
Definition at line 146 of file main.c.
References k_lin_hil_break_len, k_lin_hil_channel, k_lin_hil_console_baud, k_lin_hil_lin_baud, k_lin_hil_pclk_hz, k_ra8_board_led1, k_ra8_board_pmod1_uart_rxd, k_ra8_board_pmod1_uart_txd, k_ra8_clock_id_cpuclk0, k_ra8_ok, k_ra8_psel_sci_async, k_ra8_sci_data_8, k_ra8_sci_lin_clk_div16, k_ra8_sci_lin_role_commander, k_ra8_sci_parity_none, k_ra8_sci_stop_1, lin_hil_panic_halt(), ra8_board_led_init(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_pfs_route_peripheral(), ra8_sci_lin_init(), and ra8_time_init().
Referenced by main().
| void main | ( | void | ) |
Application entry.
The application entry point Reset_Handler hands control to.
Brings up the LIN commander then drives frames.
Definition at line 239 of file main.c.
References k_lin_hil_banner, k_lin_hil_fault_msg, k_lin_hil_frame_msg, k_lin_hil_id_count, k_lin_hil_ids, k_lin_hil_period_ms, k_ra8_board_led1, k_ra8_ok, lin_hil_panic_halt(), lin_hil_send_frame(), lin_hil_setup_or_halt(), ra8_board_led_toggle(), ra8_board_uart_console_write(), ra8_delay_ms(), and ra8_isr_globals_enable().
|
static |
|
static |
|
static |
|
static |
Rotating demo frame ids (arbitrary 6-bit LIN identifiers).
Definition at line 101 of file main.c.
Referenced by main().
|
static |
Two-byte response payload published for every frame.
Definition at line 109 of file main.c.
Referenced by lin_hil_send_frame().