ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_sci_lin.c
Go to the documentation of this file.
1
33
34#include "ra8_sci_lin.h"
35
36#include <stdint.h>
37
38#include "ra8_attributes.h"
39#include "ra8_check.h"
40#include "ra8_err.h"
41#include "ra8_hw_err.h"
42#include "ra8_log.h"
43#include "ra8_sci.h"
44#include "ra8_sci_regs.h"
45
46static const char* s_tag = "LIN";
47
48/* =============================================================================
49 * File-local constants
50 * =============================================================================
51 */
52
71
83
92
93/* =============================================================================
94 * Internal helpers
95 * =============================================================================
96 */
97
124 uint32_t tcss,
125 uint16_t break_len)
126{
127 /* HUM Ch 38.2.5 "CCR0 : Common Control Register 0" p 2182 -- drop TE/RE
128 * before changing the operating mode. */
129 reg->CCR0 = 0U;
130
131 /* HUM Ch 38.2.8 "CCR3 : Common Control Register 3" p 2203 -- select
132 * Simple LIN (MOD = 110b), preserving LSBF / BPEN / CHR / STP set by
133 * ra8_sci_init. */
134 uint32_t ccr3 = reg->CCR3;
135 ccr3 &= ~(uint32_t)k_ra8_sci_ccr3_mask_mod;
137 reg->CCR3 = ccr3;
138
139 /* HUM Ch 38.2.14 "XCR0 : Simple LIN Control Register 0" p 2220 -- select
140 * the break-field timer clock (TCSS) and enable break-field logic (BFE);
141 * BFE gates the responder's break detector as well as commander output. */
142 reg->XCR0 = (tcss << k_ra8_sci_xcr0_shift_tcss) | (1U << k_ra8_sci_xcr0_bit_bfe);
143
144 /* HUM Ch 38.2.16 "XCR2 : Simple LIN Control Register 2" p 2224 -- break
145 * dominant time = (BFLW + 1) x timer clock. */
146 reg->XCR2 = ((uint32_t)break_len << k_ra8_sci_xcr2_shift_bflw);
147
148 /* HUM Ch 38.2.15 "XCR1 : Simple LIN Control Register 1" p 2223 -- a
149 * commander leaves the trigger / detection fields idle (TCST is pulsed per
150 * frame by ra8_sci_lin_send_break); a responder arms Start-Frame detection
151 * (SDST) and bit-rate measurement (BMEN) so an inbound break sets XSR0.BFDF
152 * (HUM Ch 38.11.2 "Simple LIN Start Frame Reception" p 2341). */
153 uint32_t xcr1 = 0U;
154 if (role == k_ra8_sci_lin_role_responder) {
155 xcr1 = (1U << k_ra8_sci_xcr1_bit_sdst) | (1U << k_ra8_sci_xcr1_bit_bmen);
156 }
157 reg->XCR1 = xcr1;
158
159 /* HUM Ch 38.2.5 "CCR0 : Common Control Register 0" p 2182 -- re-enable
160 * the transmitter and receiver. */
161 reg->CCR0 = (1U << k_ra8_sci_ccr0_bit_te) | (1U << k_ra8_sci_ccr0_bit_re);
162}
163
188{
189 /* HUM Ch 38.2.15 "XCR1 : Simple LIN Control Register 1" p 2223 -- TCST holds 1
190 * during break output and clears on completion. The ra8_fake_mmio host seam
191 * drives this real poll on the unit-test build (T1-01): default RAM (TCST
192 * clear) takes the success leg, a staged TCST runs the loop to its timeout. */
193 const uint32_t mask = (1U << k_ra8_sci_xcr1_bit_tcst);
195}
196
219RA8_INTERNAL static uint8_t internal_lin_fold_complement(uint16_t sum)
220{
221 for (uint8_t i = 0U; i < (uint8_t)k_ra8_sci_lin_fold_passes; ++i) {
222 const uint16_t low = (uint16_t)(sum & (uint16_t)k_ra8_sci_lin_byte_mask);
223 const uint16_t high = (uint16_t)(sum >> (uint16_t)k_ra8_sci_lin_byte_bits);
224 sum = (uint16_t)(low + high);
225 }
226 return (uint8_t)(~sum & (uint16_t)k_ra8_sci_lin_byte_mask);
227}
228
255RA8_INTERNAL static ra8_err_t internal_lin_tx_buf(uint8_t channel, const uint8_t* data, uint8_t len)
256{
257 RA8_CHECK_NULL_PTR(data, s_tag, "lin_tx_buf: data");
258 for (uint8_t i = 0U; i < len; ++i) {
259 const ra8_err_t err = ra8_sci_putc_polling(channel, data[i]);
260 RA8_RETURN_ON_ERROR(err, s_tag, "lin_tx_buf");
261 }
262 return k_ra8_ok;
263}
264
291RA8_INTERNAL static ra8_err_t internal_lin_rx_buf(uint8_t channel, uint8_t* buf, uint8_t len)
292{
293 RA8_CHECK_NULL_PTR(buf, s_tag, "lin_rx_buf: buf");
294 for (uint8_t i = 0U; i < len; ++i) {
295 const ra8_err_t err = ra8_sci_getc_polling(channel, &buf[i]);
296 RA8_RETURN_ON_ERROR(err, s_tag, "lin_rx_buf");
297 }
298 return k_ra8_ok;
299}
300
301/* =============================================================================
302 * Public API
303 * =============================================================================
304 */
305
306ra8_err_t ra8_sci_lin_init(uint8_t channel, const ra8_sci_lin_cfg_t* cfg)
307{
308 RA8_CHECK_NULL_PTR(cfg, s_tag, "lin_init: cfg");
309 volatile r_sci_regs_t* reg = ra8_sci(channel);
310 RA8_CHECK_NULL_PTR(reg, s_tag, "lin_init: channel out of range");
313 }
314 if (cfg->break_field_len > (uint16_t)k_ra8_sci_xcr2_bflw_max) {
316 }
319 }
322 }
323
324 const ra8_err_t base_err = ra8_sci_init(channel, &cfg->uart);
325 RA8_RETURN_ON_ERROR(base_err, s_tag, "lin_init: base uart");
326
327 internal_lin_program_mode(reg, cfg->role, (uint32_t)cfg->timer_clk, cfg->break_field_len);
328 ra8_log_info_val(s_tag, "lin_init channel", (uint32_t)channel);
329 return k_ra8_ok;
330}
331
333{
334 volatile r_sci_regs_t* reg = ra8_sci(channel);
335 RA8_CHECK_NULL_PTR(reg, s_tag, "lin_send_break: channel out of range");
336 /* HUM Ch 38.2.15 "XCR1 : Simple LIN Control Register 1" p 2223 -- writing
337 * 1 to TCST starts break-field output on TXD; the bit self-clears when the
338 * BFLW dominant time elapses. The other XCR1 fields stay idle in commander
339 * mode, so a full-word write is deterministic. */
340 reg->XCR1 = (1U << k_ra8_sci_xcr1_bit_tcst);
342}
343
344ra8_err_t ra8_sci_lin_send_header(uint8_t channel, uint8_t id)
345{
346 volatile const r_sci_regs_t* reg = ra8_sci(channel);
347 RA8_CHECK_NULL_PTR(reg, s_tag, "lin_send_header: channel out of range");
348 if (id > (uint8_t)k_ra8_sci_lin_id_max) {
350 }
351
352 const ra8_err_t brk_err = ra8_sci_lin_send_break(channel);
353 RA8_RETURN_ON_ERROR(brk_err, s_tag, "lin_send_header: break");
354
355 /* SYNC field: the fixed 0x55 byte the responders use to lock the bit
356 * rate, sent as an ordinary UART frame after the break. */
357 const ra8_err_t sync_err = ra8_sci_putc_polling(channel, (uint8_t)k_ra8_sci_lin_sync_byte);
358 RA8_RETURN_ON_ERROR(sync_err, s_tag, "lin_send_header: sync");
359
360 /* Protected identifier: 6-bit id with the two LIN parity bits. */
361 const uint8_t pid = ra8_sci_lin_pid(id);
362 const ra8_err_t pid_err = ra8_sci_putc_polling(channel, pid);
363 RA8_RETURN_ON_ERROR(pid_err, s_tag, "lin_send_header: pid");
364 return k_ra8_ok;
365}
366
367ra8_err_t ra8_sci_lin_break_detected(uint8_t channel, bool* out_detected)
368{
369 RA8_CHECK_NULL_PTR(out_detected, s_tag, "lin_break_detected: out_detected");
370 volatile const r_sci_regs_t* reg = ra8_sci(channel);
371 RA8_CHECK_NULL_PTR(reg, s_tag, "lin_break_detected: channel out of range");
372 /* HUM Ch 38.2.22 "XSR0 : Simple LIN Status Register 0" p 2235 -- BFDF is
373 * set once the Start-Frame detector sees a break field; read-only here. */
374 const uint32_t mask = (1U << k_ra8_sci_xsr0_bit_bfdf);
375 *out_detected = ((reg->XSR0 & mask) != 0U);
376 return k_ra8_ok;
377}
378
380{
381 volatile const r_sci_regs_t* reg = ra8_sci(channel);
382 RA8_CHECK_NULL_PTR(reg, s_tag, "lin_wait_break: channel out of range");
383 /* HUM Ch 38.2.22 "XSR0 : Simple LIN Status Register 0" p 2235 -- spin until
384 * BFDF = 1 (break field detected). The ra8_fake_mmio host seam drives this
385 * real poll on the unit-test build: a staged BFDF takes the success leg, an
386 * armed fail runs the loop to its timeout. */
387 const uint32_t mask = (1U << k_ra8_sci_xsr0_bit_bfdf);
389}
390
392{
393 volatile r_sci_regs_t* reg = ra8_sci(channel);
394 RA8_CHECK_NULL_PTR(reg, s_tag, "lin_clear_status: channel out of range");
395 /* HUM Ch 38.2.28 "XFCLR : Simple LIN Flag Clear Register" p 2240 -- writing
396 * the clear-all-LIN mask clears every W1C XSR0 latch (BFDF, AEDF, ...). */
397 reg->XFCLR = (uint32_t)k_ra8_sci_xfclr_default;
398 return k_ra8_ok;
399}
400
403 uint8_t pid,
404 const uint8_t* data,
405 uint8_t len)
406{
407 volatile const r_sci_regs_t* reg = ra8_sci(channel);
408 RA8_CHECK_NULL_PTR(reg, s_tag, "lin_send_response: channel out of range");
409 if (len == 0U) {
411 }
412 if (len > (uint8_t)k_ra8_sci_lin_data_max) {
414 }
415
416 /* Compute the checksum first: this also validates mode and the data / len
417 * pairing (NULL data with len > 0 -> k_ra8_err_null_ptr). */
418 uint8_t checksum = 0U;
419 const ra8_err_t cerr = ra8_sci_lin_checksum(mode, pid, data, len, &checksum);
420 RA8_RETURN_ON_ERROR(cerr, s_tag, "lin_send_response: checksum");
421
422 const ra8_err_t derr = internal_lin_tx_buf(channel, data, len);
423 RA8_RETURN_ON_ERROR(derr, s_tag, "lin_send_response: data");
424 return ra8_sci_putc_polling(channel, checksum);
425}
426
428ra8_sci_lin_read_response(uint8_t channel, uint8_t* out_data, uint8_t len, uint8_t* out_checksum)
429{
430 volatile const r_sci_regs_t* reg = ra8_sci(channel);
431 RA8_CHECK_NULL_PTR(reg, s_tag, "lin_read_response: channel out of range");
432 RA8_CHECK_NULL_PTR(out_data, s_tag, "lin_read_response: out_data");
433 RA8_CHECK_NULL_PTR(out_checksum, s_tag, "lin_read_response: out_checksum");
434 if (len == 0U) {
436 }
437 if (len > (uint8_t)k_ra8_sci_lin_data_max) {
439 }
440
441 const ra8_err_t derr = internal_lin_rx_buf(channel, out_data, len);
442 RA8_RETURN_ON_ERROR(derr, s_tag, "lin_read_response: data");
443 return ra8_sci_getc_polling(channel, out_checksum);
444}
445
446uint8_t ra8_sci_lin_pid(uint8_t id)
447{
448 /* Mask any caller bits above bit 5 so parity is computed over a legal
449 * 6-bit identifier (the public range check lives in send_header). */
450 const uint8_t id6 = (uint8_t)(id & (uint8_t)k_ra8_sci_lin_id_mask);
451 const uint8_t b0 = (uint8_t)((id6 >> k_ra8_sci_lin_id_bit0) & (uint8_t)k_ra8_sci_lin_bit_mask);
452 const uint8_t b1 = (uint8_t)((id6 >> k_ra8_sci_lin_id_bit1) & (uint8_t)k_ra8_sci_lin_bit_mask);
453 const uint8_t b2 = (uint8_t)((id6 >> k_ra8_sci_lin_id_bit2) & (uint8_t)k_ra8_sci_lin_bit_mask);
454 const uint8_t b3 = (uint8_t)((id6 >> k_ra8_sci_lin_id_bit3) & (uint8_t)k_ra8_sci_lin_bit_mask);
455 const uint8_t b4 = (uint8_t)((id6 >> k_ra8_sci_lin_id_bit4) & (uint8_t)k_ra8_sci_lin_bit_mask);
456 const uint8_t b5 = (uint8_t)((id6 >> k_ra8_sci_lin_id_bit5) & (uint8_t)k_ra8_sci_lin_bit_mask);
457 /* P0 = ID0 ^ ID1 ^ ID2 ^ ID4 (even parity over the LIN-specified set). */
458 const uint8_t p0 = (uint8_t)(b0 ^ b1 ^ b2 ^ b4);
459 /* P1 = NOT(ID1 ^ ID3 ^ ID4 ^ ID5) (odd parity over the LIN set). */
460 const uint8_t p1 = (uint8_t)((b1 ^ b3 ^ b4 ^ b5) ^ (uint8_t)k_ra8_sci_lin_bit_mask);
461 return (uint8_t)(id6 | (uint8_t)(p0 << k_ra8_sci_lin_pid_p0_shift) |
462 (uint8_t)(p1 << k_ra8_sci_lin_pid_p1_shift));
463}
464
466 uint8_t pid,
467 const uint8_t* data,
468 uint8_t len,
469 uint8_t* out_checksum)
470{
471 RA8_CHECK_NULL_PTR(out_checksum, s_tag, "lin_checksum: out_checksum");
472 if (data == nullptr) {
473 if (len != 0U) {
474 return k_ra8_err_null_ptr;
475 }
476 }
479 }
480
481 uint16_t sum = 0U;
482 /* Enhanced (LIN 2.x) folds the protected identifier into the sum;
483 * classic (LIN 1.x) sums the data bytes only. */
485 sum = (uint16_t)pid;
486 }
487 for (uint8_t i = 0U; i < len; ++i) {
488 sum = (uint16_t)(sum + (uint16_t)data[i]);
489 }
490 *out_checksum = internal_lin_fold_complement(sum);
491 return k_ra8_ok;
492}
493
494ra8_err_t ra8_sci_lin_check_header(uint8_t sync, uint8_t pid, uint8_t* out_id, bool* out_valid)
495{
496 RA8_CHECK_NULL_PTR(out_id, s_tag, "lin_check_header: out_id");
497 RA8_CHECK_NULL_PTR(out_valid, s_tag, "lin_check_header: out_valid");
498
499 const uint8_t id = (uint8_t)(pid & (uint8_t)k_ra8_sci_lin_id_mask);
500 *out_id = id;
501 /* A responder accepts the header only when the SYNC field is exactly 0x55
502 * AND the received PID matches the parity recomputed from its low 6 bits. */
503 const bool sync_ok = (sync == (uint8_t)k_ra8_sci_lin_sync_byte);
504 const bool pid_ok = (ra8_sci_lin_pid(id) == pid);
505 *out_valid = sync_ok && pid_ok;
506 return k_ra8_ok;
507}
508
510 uint8_t pid,
511 const uint8_t* data,
512 uint8_t len,
513 uint8_t received,
514 bool* out_valid)
515{
516 RA8_CHECK_NULL_PTR(out_valid, s_tag, "lin_check_response: out_valid");
517
518 /* Recompute the expected checksum; ra8_sci_lin_checksum validates mode and
519 * the data / len pairing, so a bad mode or NULL-with-len propagates here. */
520 uint8_t expected = 0U;
521 const ra8_err_t cerr = ra8_sci_lin_checksum(mode, pid, data, len, &expected);
522 RA8_RETURN_ON_ERROR(cerr, s_tag, "lin_check_response: checksum");
523
524 *out_valid = (expected == received);
525 return k_ra8_ok;
526}
static const char * s_tag
Logging / check tag.
Definition ra8_app.c:17
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_RETURN_ON_ERROR(err, tag, message)
Early return on error, propagating the code upward.
Definition ra8_check.h:184
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Definition ra8_check.h:243
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_arg
Invalid function argument.
Definition ra8_err.h:152
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
Definition ra8_err.h:478
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Bounded wait-flag primitives for RA8D2 HAL drivers.
static ra8_err_t ra8_hw_wait_flag_set32(volatile const uint32_t *reg, uint32_t mask, uint32_t budget)
Spin until (*reg & mask) != 0 or budget runs out.
Definition ra8_hw_err.h:309
@ k_ra8_hw_budget_long
RA8 hw budget long.
Definition ra8_hw_err.h:174
static ra8_err_t ra8_hw_wait_flag_clear32(volatile const uint32_t *reg, uint32_t mask, uint32_t budget)
Spin until (*reg & mask) == 0 or budget runs out.
Definition ra8_hw_err.h:351
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_info_val(tag, message, value)
RA8 log info val.
Definition ra8_log.h:366
Full-featured Serial Communications Interface driver.
ra8_err_t ra8_sci_init(uint8_t channel, const ra8_sci_cfg_t *cfg)
Initialise an SCI channel using the descriptor.
Definition ra8_sci.c:410
ra8_err_t ra8_sci_getc_polling(uint8_t channel, uint8_t *out_byte)
Poll-receive one byte (blocking, bounded spin).
Definition ra8_sci.c:496
ra8_err_t ra8_sci_putc_polling(uint8_t channel, uint8_t byte)
Poll-send one byte (blocking, bounded by ra8_hw_err spin budget).
Definition ra8_sci.c:476
uint8_t ra8_sci_lin_pid(uint8_t id)
Compute the LIN protected identifier (PID) from a frame id.
static uint8_t internal_lin_fold_complement(uint16_t sum)
Fold a LIN checksum accumulator and return its one's complement.
ra8_err_t ra8_sci_lin_read_response(uint8_t channel, uint8_t *out_data, uint8_t len, uint8_t *out_checksum)
Read a LIN response: len data bytes plus one checksum byte.
ra8_err_t ra8_sci_lin_clear_status(uint8_t channel)
Clear the Simple-LIN status latches (XSR0) via XFCLR.
ra8_err_t ra8_sci_lin_wait_break(uint8_t channel)
Block until the responder detects a break field (XSR0.BFDF set).
static ra8_err_t internal_lin_wait_break_done(volatile const r_sci_regs_t *reg)
Spin until the break-field timer (XCR1.TCST) self-clears.
ra8_err_t ra8_sci_lin_init(uint8_t channel, const ra8_sci_lin_cfg_t *cfg)
Configure an SCI_B channel for a LIN role (commander or responder).
static ra8_err_t internal_lin_rx_buf(uint8_t channel, uint8_t *buf, uint8_t len)
Poll-receive len bytes of a LIN response data field.
ra8_sci_lin_pid_shift_t
Bit positions used when packing / unpacking a LIN PID.
Definition ra8_sci_lin.c:61
@ k_ra8_sci_lin_id_bit2
Frame-id bit 2 position.
Definition ra8_sci_lin.c:64
@ k_ra8_sci_lin_pid_p0_shift
PID parity bit P0 position.
Definition ra8_sci_lin.c:68
@ k_ra8_sci_lin_id_bit0
Frame-id bit 0 position.
Definition ra8_sci_lin.c:62
@ k_ra8_sci_lin_id_bit3
Frame-id bit 3 position.
Definition ra8_sci_lin.c:65
@ k_ra8_sci_lin_pid_p1_shift
PID parity bit P1 position.
Definition ra8_sci_lin.c:69
@ k_ra8_sci_lin_id_bit1
Frame-id bit 1 position.
Definition ra8_sci_lin.c:63
@ k_ra8_sci_lin_id_bit4
Frame-id bit 4 position.
Definition ra8_sci_lin.c:66
@ k_ra8_sci_lin_id_bit5
Frame-id bit 5 position.
Definition ra8_sci_lin.c:67
static ra8_err_t internal_lin_tx_buf(uint8_t channel, const uint8_t *data, uint8_t len)
Poll-transmit len bytes of a LIN response data field.
ra8_err_t ra8_sci_lin_checksum(ra8_sci_lin_checksum_mode_t mode, uint8_t pid, const uint8_t *data, uint8_t len, uint8_t *out_checksum)
Compute a classic or enhanced LIN checksum over a data field.
ra8_err_t ra8_sci_lin_check_response(ra8_sci_lin_checksum_mode_t mode, uint8_t pid, const uint8_t *data, uint8_t len, uint8_t received, bool *out_valid)
Verify a received LIN response checksum against the data field.
ra8_err_t ra8_sci_lin_check_header(uint8_t sync, uint8_t pid, uint8_t *out_id, bool *out_valid)
Validate a received LIN header: SYNC byte + protected identifier.
ra8_err_t ra8_sci_lin_send_header(uint8_t channel, uint8_t id)
Transmit a full LIN header: break + SYNC (0x55) + PID.
ra8_sci_lin_const_t
Byte-level masks and protocol constants for the LIN math.
Definition ra8_sci_lin.c:76
@ k_ra8_sci_lin_id_mask
6-bit LIN frame-id mask.
Definition ra8_sci_lin.c:77
@ k_ra8_sci_lin_bit_mask
Single-bit extract / invert.
Definition ra8_sci_lin.c:78
@ k_ra8_sci_lin_fold_passes
Carry-fold passes for checksum.
Definition ra8_sci_lin.c:80
@ k_ra8_sci_lin_data_max
Max LIN response data bytes.
Definition ra8_sci_lin.c:81
@ k_ra8_sci_lin_sync_byte
LIN SYNC field byte (0x55).
Definition ra8_sci_lin.c:79
ra8_err_t ra8_sci_lin_break_detected(uint8_t channel, bool *out_detected)
Report whether the responder's break-field detector has fired.
ra8_err_t ra8_sci_lin_send_response(uint8_t channel, ra8_sci_lin_checksum_mode_t mode, uint8_t pid, const uint8_t *data, uint8_t len)
Publish a LIN response: data bytes followed by the checksum.
ra8_err_t ra8_sci_lin_send_break(uint8_t channel)
Emit a LIN break field on the channel's TXD line.
static void internal_lin_program_mode(volatile r_sci_regs_t *reg, ra8_sci_lin_role_t role, uint32_t tcss, uint16_t break_len)
Program the SCI_B mode + break-field timer/detector for a LIN role.
ra8_sci_lin_fold_const_t
16-bit masks used while folding the LIN checksum carry.
Definition ra8_sci_lin.c:88
@ k_ra8_sci_lin_byte_bits
Bits per byte (carry shift).
Definition ra8_sci_lin.c:90
@ k_ra8_sci_lin_byte_mask
Low-byte mask.
Definition ra8_sci_lin.c:89
LIN (Local Interconnect Network) commander + responder driver on SCI_B.
@ k_ra8_sci_lin_id_max
Highest legal 6-bit LIN frame id.
ra8_sci_lin_role_t
Selects whether the channel drives (commander) or detects (responder) the LIN frame header.
@ k_ra8_sci_lin_role_responder
Detect the header (subordinate node).
ra8_sci_lin_checksum_mode_t
Selector for the classic vs.
@ k_ra8_sci_lin_checksum_enhanced
LIN 2.x: sum of PID + data bytes.
@ k_ra8_sci_lin_clk_div4
Break timer clock = TCLK / 4.
@ k_ra8_sci_lin_clk_div64
Break timer clock = TCLK / 64.
SCI_B (Serial Communication Interface, B variant) register layoutfor the RA8D2.
static volatile r_sci_regs_t * ra8_sci(uint8_t channel)
Get pointer to SCI_B channel N (0..9).
@ k_ra8_sci_ccr3_mod_simple_lin
Simple LIN.
@ k_ra8_sci_ccr0_bit_re
Receive Enable.
@ k_ra8_sci_ccr0_bit_te
Transmit Enable.
@ k_ra8_sci_xcr2_shift_bflw
BFLW[15:0] Break Field length.
@ k_ra8_sci_xcr2_bflw_max
Highest legal BFLW (0xFFFF banned).
@ k_ra8_sci_ccr3_shift_mod
MOD[2:0] mode select.
@ k_ra8_sci_ccr3_mask_mod
MOD[18:16] in CCR3.
@ k_ra8_sci_xsr0_bit_bfdf
Break Field Detection Flag (1 = seen).
@ k_ra8_sci_xfclr_default
Clear every LIN W1C latch at once.
@ k_ra8_sci_xcr0_shift_tcss
TCSS[1:0] timer count clock source.
@ k_ra8_sci_xcr0_bit_bfe
Break Field Enable.
@ k_ra8_sci_xcr1_bit_bmen
Bit Rate Measurement Enable.
@ k_ra8_sci_xcr1_bit_sdst
Start Frame Detection Enable.
@ k_ra8_sci_xcr1_bit_tcst
Break Field Output Timer Count Start.
Per-channel SCI_B register window.
volatile uint32_t XCR1
+0x38 Simple LIN Control 1.
volatile uint32_t XFCLR
+0x78 Simple LIN Flag Clear.
volatile uint32_t XSR0
+0x5C Simple LIN Status 0.
volatile uint32_t CCR3
+0x14 Common Control 3.
volatile uint32_t CCR0
+0x08 Common Control 0.
volatile uint32_t XCR0
+0x34 Simple LIN Control 0.
volatile uint32_t XCR2
+0x3C Simple LIN Control 2.
Configuration descriptor for ra8_sci_lin_init.
ra8_sci_cfg_t uart
Base async-UART baud + framing.
ra8_sci_lin_role_t role
Commander (generate) or responder (detect) the frame header.
ra8_sci_lin_timer_clk_t timer_clk
Break-field timer clock (TCSS).
uint16_t break_field_len
XCR2.BFLW: dominant time = (break_field_len + 1) x timer clock.