ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_c6link_pump.c
Go to the documentation of this file.
1
30
31#include <stdint.h>
32
33#include "ra8_attributes.h"
34#include "ra8_c6link.h"
35#include "ra8_c6link_internal.h"
36
54{
55 for (uint16_t waited = 0U; waited < (uint16_t)k_ra8_c6link_hs_wait_ms;
56 waited = (uint16_t)(waited + (uint16_t)k_ra8_c6link_hs_poll_ms)) {
57 if (link->transport.handshake_active(link->transport.ctx)) {
58 return true;
59 }
61 }
62 return false;
63}
64
82{
83 ra8_c6link_rx_view_t view = {};
85
86 switch (cls) {
88 stats->idle++;
89 return false;
91 stats->malformed++;
92 return false;
94 stats->bad_checksum++;
95 return false;
97 default:
98 break;
99 }
100
101 stats->data++;
102 return priv_c6link_dispatch(link, &view);
103}
104
106 uint16_t max_transactions,
107 ra8_c6link_stats_t* stats)
108{
109 if ((link == nullptr) || (stats == nullptr)) {
110 return k_ra8_err_null_ptr;
111 }
112 link->stats = stats;
113 uint16_t misses = 0U;
114 ra8_err_t verdict = k_ra8_ok;
115
116 for (uint16_t i = 0U; i < max_transactions; i++) {
118 stats->hs_timeouts++;
119 misses++;
120 if (misses >= (uint16_t)k_ra8_c6link_hs_giveup) {
121 break;
122 }
123 continue;
124 }
125 misses = 0U;
126
127 if (link->tx_len != 0U) {
128 priv_c6link_frame_seal(link->tx, link->tx_if, 0U, link->tx_len);
129 link->tx_len = 0U;
130 } else {
132 }
133
134 const ra8_err_t moved = link->transport.transfer(link->transport.ctx,
135 link->tx,
136 link->rx,
137 (uint16_t)k_ra8_c6link_frame_bytes);
138 if (moved != k_ra8_ok) {
139 verdict = k_ra8_err_spi_error;
140 break;
141 }
142 stats->transfers++;
143
144 if (internal_c6link_pump_receive(link, stats)) {
145 break;
146 }
147 link->transport.delay_ms(link->transport.ctx, (uint16_t)k_ra8_c6link_gap_ms);
148 }
149
150 link->stats = nullptr;
151 if (verdict != k_ra8_ok) {
152 return verdict;
153 }
154 return (stats->transfers == 0U) ? k_ra8_err_hw_timeout : k_ra8_ok;
155}
Annotation-attribute framework macros for ra8-firmware.
#define RA8_PRIV
Module-private helper: shared across TUs but only inside one library.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
@ k_ra8_err_spi_error
SPI transfer failed (bus fault, mode fault, overrun, ...).
Definition ra8_err.h:405
@ k_ra8_err_hw_timeout
Hardware timed out waiting for a flag or handshake.
Definition ra8_err.h:304
@ 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