ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_i2c_peripheral.c
Go to the documentation of this file.
1
56
57#include <stdint.h>
58
59#include "ra8_attributes.h"
60#include "ra8_check.h"
61#include "ra8_err.h"
62#include "ra8_i2c.h"
63#include "ra8_i2c_internal.h"
64#include "ra8_i2c_regs.h"
65
70typedef enum : uint32_t {
75
93
94/* =============================================================================
95 * Pure decision predicates (TU-external for MC/DC -- see ra8_i2c_internal.h).
96 * =============================================================================
97 */
98
99bool priv_ra8_i2c_internal_peripheral_poll_done(uint8_t icsr1, uint8_t icsr2)
100{
101 return ((icsr1 & (uint8_t)k_ra8_i2c_msk_icsr1_match) != 0U) ||
102 ((icsr2 & (uint8_t)k_ra8_i2c_msk_icsr2_stop) != 0U);
103}
104
106 uint32_t received,
107 uint32_t capacity)
108{
109 return ((icsr2 & (uint8_t)k_ra8_i2c_msk_icsr2_stop) == 0U) && (received < capacity);
110}
111
113{
114 return ((icsr2 & (uint8_t)k_ra8_i2c_msk_icsr2_nackf) != 0U) ||
115 ((icsr2 & (uint8_t)k_ra8_i2c_msk_icsr2_tend) != 0U);
116}
117
118bool priv_ra8_i2c_internal_peripheral_tx_continue(uint8_t icsr2, uint32_t sent, uint32_t len)
119{
120 return ((icsr2 & (uint8_t)k_ra8_i2c_msk_icsr2_nackf) == 0U) && (sent < len);
121}
122
123/* =============================================================================
124 * Local helpers.
125 * =============================================================================
126 */
127
152 uint8_t iccr2)
153{
154 if ((icsr1 & (uint8_t)k_ra8_i2c_msk_icsr1_match) == 0U) {
156 }
157 if ((iccr2 & (uint8_t)k_ra8_i2c_msk_iccr2_trs) != 0U) {
159 }
161}
162
186 uint8_t mask)
187{
188 for (uint32_t i = 0U; i < (uint32_t)k_ra8_i2c_peripheral_poll_limit; i++) {
189 /* HUM Ch 39.2.10 "ICSR2 : I2C Bus Status Register 2" p 2384 */
190 if ((reg->ICSR2 & mask) != 0U) {
191 return k_ra8_ok;
192 }
193 }
195}
196
217RA8_INTERNAL static void
218internal_i2c_target_set_addr(volatile r_i2c_regs_t* reg, uint8_t slot, uint8_t addr_7b)
219{
220 const uint8_t sarl = (uint8_t)((uint32_t)addr_7b << (uint32_t)k_ra8_i2c_peripheral_addr_shift);
221 switch (slot) {
222 case (uint8_t)k_ra8_i2c_peripheral_slot_0:
223 /* HUM Ch 39.2.13 "SARLy : own-address register Ly" p 2390 */
224 reg->SARL0 = sarl;
225 /* HUM Ch 39.2.14 "SARUy : own-address register Uy" p 2391 */
227 break;
228 case (uint8_t)k_ra8_i2c_peripheral_slot_1:
229 /* HUM Ch 39.2.13 "SARLy : own-address register Ly" p 2390 */
230 reg->SARL1 = sarl;
231 /* HUM Ch 39.2.14 "SARUy : own-address register Uy" p 2391 */
233 break;
234 default:
235 /* HUM Ch 39.2.13 "SARLy : own-address register Ly" p 2390 */
236 reg->SARL2 = sarl;
237 /* HUM Ch 39.2.14 "SARUy : own-address register Uy" p 2391 */
239 break;
240 }
241}
242
264RA8_INTERNAL static uint8_t internal_i2c_target_icser_mask(uint8_t slot, bool general_call)
265{
266 uint8_t mask = (uint8_t)((uint32_t)k_ra8_i2c_msk_icser_sar0e << (uint32_t)slot);
267 if (general_call) {
268 mask |= (uint8_t)k_ra8_i2c_msk_icser_gcae;
269 }
270 return mask;
271}
272
275 uint8_t* buf,
276 uint32_t capacity,
277 uint32_t* out_count)
278{
279 uint32_t count = 0U;
280 ra8_err_t err = k_ra8_ok;
281 for (uint32_t i = 0U; i <= capacity; i++) {
283 reg,
284 (uint8_t)((uint8_t)k_ra8_i2c_msk_icsr2_rdrf | (uint8_t)k_ra8_i2c_msk_icsr2_stop));
285 if (err != k_ra8_ok) {
286 break;
287 }
288 /* HUM Ch 39.2.10 "ICSR2 : I2C Bus Status Register 2" p 2384 */
289 const uint8_t icsr2 = reg->ICSR2;
290 if (!priv_ra8_i2c_internal_peripheral_rx_continue(icsr2, count, capacity)) {
291 /* STOP detected or buffer full: drain a final pending byte if room. */
292 if (((icsr2 & (uint8_t)k_ra8_i2c_msk_icsr2_rdrf) != 0U) && (count < capacity)) {
293 /* HUM Ch 39.2.18 "ICDRR : I2C Bus Receive Data Register" p 2393 */
294 buf[count] = reg->ICDRR;
295 count++;
296 }
297 break;
298 }
299 if ((icsr2 & (uint8_t)k_ra8_i2c_msk_icsr2_rdrf) != 0U) {
300 /* HUM Ch 39.2.18 "ICDRR : I2C Bus Receive Data Register" p 2393 */
301 buf[count] = reg->ICDRR;
302 count++;
303 }
304 }
305 *out_count = count;
306 return err;
307}
308
333 const uint8_t* data,
334 uint32_t len,
335 uint32_t* out_sent)
336{
337 uint32_t sent = 0U;
338 for (uint32_t i = 0U; i <= len; i++) {
339 /* Step 3 (peripheral transmit): wait for TDRE before each byte.
340 * HUM Ch 39.3.5 "Peripheral Transmit Operation" p 2405 */
342 break;
343 }
344 /* HUM Ch 39.2.10 "ICSR2 : I2C Bus Status Register 2" p 2384 */
345 const uint8_t icsr2 = reg->ICSR2;
346 if (!priv_ra8_i2c_internal_peripheral_tx_continue(icsr2, sent, len)) {
347 break;
348 }
349 /* HUM Ch 39.2.17 "ICDRT : I2C Bus Transmit Data Register" p 2393 */
350 reg->ICDRT = data[sent];
351 sent++;
352 }
353 *out_sent = sent;
354}
355
379{
380 /* Step 4: wait for the controller's TEND or NACK to mark frame end. */
382 reg,
383 (uint8_t)((uint8_t)k_ra8_i2c_msk_icsr2_tend | (uint8_t)k_ra8_i2c_msk_icsr2_nackf));
384 /* HUM Ch 39.2.10 "ICSR2 : I2C Bus Status Register 2" p 2384 */
385 const bool ended = priv_ra8_i2c_internal_peripheral_tx_done(reg->ICSR2);
386
387 /* Step 5: dummy-read ICDRR to release SCL.
388 * HUM Ch 39.2.18 "ICDRR : I2C Bus Receive Data Register" p 2393 */
389 (void)reg->ICDRR;
390
391 /* Step 7: clear NACKF and STOP (W0C) for the next transfer.
392 * HUM Ch 39.2.10 "ICSR2 : I2C Bus Status Register 2 -- W0C" p 2384 */
393 reg->ICSR2 = (uint8_t)(reg->ICSR2 & (uint8_t)~(uint8_t)((uint8_t)k_ra8_i2c_msk_icsr2_nackf |
394 (uint8_t)k_ra8_i2c_msk_icsr2_stop));
395 return ended;
396}
397
398/* =============================================================================
399 * Public target-role API.
400 * =============================================================================
401 */
402
404{
405 volatile r_i2c_regs_t* reg = ra8_i2c_regs(channel);
406 RA8_CHECK_NULL_PTR(reg, g_i2c_tag, "i2c_target_init: channel");
407 RA8_CHECK_NULL_PTR(cfg, g_i2c_tag, "i2c_target_init: cfg");
408 if (cfg->own_addr_7b > (uint8_t)k_ra8_i2c_peripheral_addr_7b_max) {
410 }
411 if ((uint8_t)cfg->slot > (uint8_t)k_ra8_i2c_peripheral_slot_max) {
413 }
414
415 const uint8_t slot = (uint8_t)cfg->slot;
417
418 /* HUM Ch 39.2.7 "ICSER : I2C Bus Status Enable Register" p 2380 */
420
421 if (cfg->clock_stretch) {
422 /* HUM Ch 39.2.5 "ICMR3 : I2C Bus Mode Register 3 -- WAIT" p 2376 */
423 reg->ICMR3 = (uint8_t)(reg->ICMR3 | (uint8_t)k_ra8_i2c_msk_icmr3_wait);
424 }
425
426 if (cfg->irq_enable) {
427 /* HUM Ch 39.2.8 "ICIER : I2C Bus Interrupt Enable Register" p 2381 */
428 reg->ICIER = (uint8_t)(reg->ICIER | (uint8_t)k_ra8_i2c_peripheral_icier_arm);
429 }
430
431 s_i2c_state[channel].peripheral_active = true;
432 return k_ra8_ok;
433}
434
436{
437 volatile r_i2c_regs_t* reg = ra8_i2c_regs(channel);
438 if (reg == nullptr) {
440 }
441 if (!s_i2c_state[channel].peripheral_active) {
443 }
444 /* HUM Ch 39.2.7 "ICSER : I2C Bus Status Enable Register" p 2380 */
445 reg->ICSER = 0U;
446 /* HUM Ch 39.2.5 "ICMR3 : I2C Bus Mode Register 3 -- WAIT" p 2376 */
447 reg->ICMR3 = (uint8_t)(reg->ICMR3 & (uint8_t)~(uint8_t)k_ra8_i2c_msk_icmr3_wait);
448 /* HUM Ch 39.2.8 "ICIER : I2C Bus Interrupt Enable Register" p 2381 */
449 reg->ICIER = (uint8_t)(reg->ICIER & (uint8_t)~(uint8_t)k_ra8_i2c_peripheral_icier_arm);
450 s_i2c_state[channel].peripheral_active = false;
451 return k_ra8_ok;
452}
453
455{
456 volatile const r_i2c_regs_t* reg = ra8_i2c_regs(channel);
457 RA8_CHECK_NULL_PTR(reg, g_i2c_tag, "i2c_target_poll: channel");
458 RA8_CHECK_NULL_PTR(out_event, g_i2c_tag, "i2c_target_poll: out_event");
460 if (!s_i2c_state[channel].peripheral_active) {
462 }
463
464 for (uint32_t i = 0U; i < (uint32_t)k_ra8_i2c_peripheral_poll_limit; i++) {
465 /* HUM Ch 39.2.9 "ICSR1 : I2C Bus Status Register 1" p 2382 */
466 const uint8_t icsr1 = reg->ICSR1;
467 /* HUM Ch 39.2.10 "ICSR2 : I2C Bus Status Register 2" p 2384 */
468 const uint8_t icsr2 = reg->ICSR2;
470 break;
471 }
472 }
473
474 /* HUM Ch 39.2.9 "ICSR1 : I2C Bus Status Register 1" p 2382 */
475 const uint8_t icsr1 = reg->ICSR1;
476 /* HUM Ch 39.2.2 "ICCR2 : I2C Bus Control Register 2 -- TRS" p 2371 */
477 const uint8_t iccr2 = reg->ICCR2;
478 *out_event = internal_i2c_target_classify(icsr1, iccr2);
479 return k_ra8_ok;
480}
481
483ra8_i2c_peripheral_receive(uint8_t channel, uint8_t* buf, uint32_t capacity, uint32_t* out_received)
484{
485 volatile r_i2c_regs_t* reg = ra8_i2c_regs(channel);
486 RA8_CHECK_NULL_PTR(reg, g_i2c_tag, "i2c_target_receive: channel");
487 RA8_CHECK_NULL_PTR(buf, g_i2c_tag, "i2c_target_receive: buf");
488 RA8_CHECK_NULL_PTR(out_received, g_i2c_tag, "i2c_target_receive: out_received");
489 *out_received = 0U;
490 if (capacity == 0U) {
492 }
493 if (!s_i2c_state[channel].peripheral_active) {
495 }
496
497 /* Step 3 (peripheral receive): the address-phase RDRF, then dummy-read
498 * ICDRR to discard the matched address byte and clear RDRF.
499 * HUM Ch 39.3.6 "Peripheral Receive Operation" p 2408 */
501 if (err != k_ra8_ok) {
502 return err;
503 }
504 /* HUM Ch 39.2.18 "ICDRR : I2C Bus Receive Data Register" p 2393 */
505 (void)reg->ICDRR;
506
507 /* Steps 4-5: drain data bytes until STOP or the buffer fills. */
508 uint32_t count = 0U;
509 err = priv_ra8_i2c_internal_target_drain_rx(reg, buf, capacity, &count);
510
511 /* Step 6: clear the STOP flag (W0C) for the next transfer.
512 * HUM Ch 39.2.10 "ICSR2 : I2C Bus Status Register 2 -- STOP W0C" p 2384 */
513 reg->ICSR2 = (uint8_t)(reg->ICSR2 & (uint8_t)~(uint8_t)k_ra8_i2c_msk_icsr2_stop);
514 *out_received = count;
515 return (count == 0U) ? err : k_ra8_ok;
516}
517
519ra8_i2c_peripheral_transmit(uint8_t channel, const uint8_t* data, uint32_t len, uint32_t* out_sent)
520{
521 volatile r_i2c_regs_t* reg = ra8_i2c_regs(channel);
522 RA8_CHECK_NULL_PTR(reg, g_i2c_tag, "i2c_target_transmit: channel");
523 RA8_CHECK_NULL_PTR(data, g_i2c_tag, "i2c_target_transmit: data");
524 RA8_CHECK_NULL_PTR(out_sent, g_i2c_tag, "i2c_target_transmit: out_sent");
525 *out_sent = 0U;
526 if (len == 0U) {
528 }
529 if (!s_i2c_state[channel].peripheral_active) {
531 }
532
533 /* Step 3: push data bytes to ICDRT until NACK or every byte is queued. */
534 uint32_t sent = 0U;
535 internal_i2c_target_fill_tx(reg, data, len, &sent);
536
537 /* Steps 4-7: confirm the controller ended the read, release SCL, clear
538 * NACKF / STOP. ``ended`` is k_ra8_ok-equivalent: the end-of-frame poll only
539 * times out (ended == false) when no TEND / NACK ever arrives, which is the
540 * single failure mode for both an empty and a non-empty transmit. */
541 const bool ended = internal_i2c_target_finish_tx(reg);
542 *out_sent = sent;
543 return ended ? k_ra8_ok : k_ra8_err_hw_timeout;
544}
545
546/* =============================================================================
547 * Event dispatch -- attached-callback path (RIIC ISR or poll loop).
548 * =============================================================================
549 */
550
581internal_i2c_dispatch_event(uint8_t icsr1, uint8_t icsr2, uint8_t iccr2)
582{
584 if (match != k_ra8_i2c_peripheral_event_none) {
585 return match;
586 }
587 if ((icsr2 & (uint8_t)k_ra8_i2c_msk_icsr2_stop) != 0U) {
589 }
591}
592
595{
596 if ((uint16_t)channel >= (uint16_t)k_ra8_i2c_channel_count) {
598 }
599 s_i2c_state[channel].peripheral_handler = fn;
600 s_i2c_state[channel].peripheral_ctx = ctx;
601 return k_ra8_ok;
602}
603
605void ra8_i2c_peripheral_dispatch(uint8_t channel)
606{
607 volatile const r_i2c_regs_t* reg = ra8_i2c_regs(channel);
608 if (reg == nullptr) {
609 return;
610 }
611 if (!s_i2c_state[channel].peripheral_active) {
612 return;
613 }
614 const ra8_i2c_peripheral_event_fn_t fn = s_i2c_state[channel].peripheral_handler;
615 if (fn == nullptr) {
616 return;
617 }
618
619 /* HUM Ch 39.2.9 "ICSR1 : I2C Bus Status Register 1" p 2382 */
620 const uint8_t icsr1 = reg->ICSR1;
621 /* HUM Ch 39.2.10 "ICSR2 : I2C Bus Status Register 2" p 2384 */
622 const uint8_t icsr2 = reg->ICSR2;
623 /* HUM Ch 39.2.2 "ICCR2 : I2C Bus Control Register 2 -- TRS" p 2371 */
624 const uint8_t iccr2 = reg->ICCR2;
625
626 const ra8_i2c_peripheral_event_t event = internal_i2c_dispatch_event(icsr1, icsr2, iccr2);
627 if (event != k_ra8_i2c_peripheral_event_none) {
628 fn(s_i2c_state[channel].peripheral_ctx, event);
629 }
630}
Annotation-attribute framework macros for ra8-firmware.
#define RA8_ISR_SAFE
The function is callable from interrupt context.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#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_err_hw_timeout
Hardware timed out waiting for a flag or handshake.
Definition ra8_err.h:304
@ k_ra8_err_not_initialized
Module not initialized – _init() not yet called successfully.
Definition ra8_err.h:235
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
ra8_i2c_state_t s_i2c_state[k_ra8_i2c_channel_count]
Per-channel state table indexed by channel.
Definition ra8_i2c.c:132
const char *const g_i2c_tag
Log tag for this driver, shared with ra8_i2c_config.c.
Definition ra8_i2c.c:65
I2C Bus Interface (IIC) controller driver – polling mode.
@ k_ra8_i2c_peripheral_slot_0
Own-address slot 0 (SARL0/SARU0).
Definition ra8_i2c.h:411
@ k_ra8_i2c_peripheral_slot_1
Own-address slot 1 (SARL1/SARU1).
Definition ra8_i2c.h:412
void(* ra8_i2c_peripheral_event_fn_t)(void *ctx, ra8_i2c_peripheral_event_t event)
Address-match callback fired by ra8_i2c_peripheral_dispatch.
Definition ra8_i2c.h:462
ra8_i2c_peripheral_event_t
Outcome of ra8_i2c_peripheral_poll / ra8_i2c_peripheral_dispatch.
Definition ra8_i2c.h:431
@ k_ra8_i2c_peripheral_event_none
No own-address match observed.
Definition ra8_i2c.h:432
@ k_ra8_i2c_peripheral_event_write
Controller WRITE: call receive next.
Definition ra8_i2c.h:433
@ k_ra8_i2c_peripheral_event_read
Controller READ: call transmit next.
Definition ra8_i2c.h:434
@ k_ra8_i2c_peripheral_event_stop
STOP ended the transaction (idle).
Definition ra8_i2c.h:435
Test-access surface for ra8_i2c internal helpers (MC/DC).
static ra8_i2c_peripheral_event_t internal_i2c_dispatch_event(uint8_t icsr1, uint8_t icsr2, uint8_t iccr2)
Classify an own-address / STOP status snapshot into a dispatch event.
static uint8_t internal_i2c_target_icser_mask(uint8_t slot, bool general_call)
Build the ICSER enable mask for one own-address slot.
ra8_err_t ra8_i2c_peripheral_transmit(uint8_t channel, const uint8_t *data, uint32_t len, uint32_t *out_sent)
Answer a controller-read transaction from data (target transmit).
ra8_err_t ra8_i2c_peripheral_init(uint8_t channel, const ra8_i2c_peripheral_cfg_t *cfg)
Arm an IIC channel to answer as an I2C target (peripheral).
static void internal_i2c_target_fill_tx(volatile r_i2c_regs_t *reg, const uint8_t *data, uint32_t len, uint32_t *out_sent)
Push controller-read data bytes from data into ICDRT.
static ra8_err_t internal_i2c_target_wait(volatile const r_i2c_regs_t *reg, uint8_t mask)
Wait (bounded) for a flag in ICSR2 to set.
bool priv_ra8_i2c_internal_peripheral_tx_continue(uint8_t icsr2, uint32_t sent, uint32_t len)
Transmit-loop predicate: keep sending while no NACK and data remains.
static ra8_i2c_peripheral_event_t internal_i2c_target_classify(uint8_t icsr1, uint8_t iccr2)
Classify a latched address-match snapshot into a poll event.
bool priv_ra8_i2c_internal_peripheral_poll_done(uint8_t icsr1, uint8_t icsr2)
Poll-exit predicate: an own-address match or a STOP was observed.
bool priv_ra8_i2c_internal_peripheral_rx_continue(uint8_t icsr2, uint32_t received, uint32_t capacity)
Receive-loop predicate: keep draining while no STOP and room remains.
static bool internal_i2c_target_finish_tx(volatile r_i2c_regs_t *reg)
Close a target-transmit frame: wait for end, release SCL, clear flags.
ra8_err_t ra8_i2c_peripheral_poll(uint8_t channel, ra8_i2c_peripheral_event_t *out_event)
Wait (bounded) for a controller to address this target.
ra8_err_t priv_ra8_i2c_internal_target_drain_rx(volatile r_i2c_regs_t *reg, uint8_t *buf, uint32_t capacity, uint32_t *out_count)
Implementation of priv_ra8_i2c_internal_target_drain_rx() – trailing-byte ICDRR drain.
static void internal_i2c_target_set_addr(volatile r_i2c_regs_t *reg, uint8_t slot, uint8_t addr_7b)
Programme a 7-bit own address into the SARLy/SARUy pair for a slot.
bool priv_ra8_i2c_internal_peripheral_tx_done(uint8_t icsr2)
Transmit-completion predicate: the controller ended the read.
ra8_err_t ra8_i2c_peripheral_deinit(uint8_t channel)
Disarm own-address matching, returning the channel to controller use.
void ra8_i2c_peripheral_dispatch(uint8_t channel)
Snapshot the latched target status and fire the attached callback.
ra8_i2c_peripheral_limits_t
Spin budgets and validation bounds for the target plane.
@ k_ra8_i2c_peripheral_poll_limit
Generic spin budget for status-flag polls, matching the controller plane: ~200k iterations keeps the ...
ra8_err_t ra8_i2c_peripheral_receive(uint8_t channel, uint8_t *buf, uint32_t capacity, uint32_t *out_received)
Drain a controller-write transaction into buf (target receive).
ra8_i2c_peripheral_const_t
Addressing constants for the target plane.
@ k_ra8_i2c_peripheral_addr_7b_max
Largest valid 7-bit own address.
@ k_ra8_i2c_peripheral_slot_max
Highest own-address comparator slot.
@ k_ra8_i2c_peripheral_saru_7bit
SARUy value for the 7-bit address format (FS = 0, SVA[1:0] = 0).
@ k_ra8_i2c_peripheral_icier_arm
ICIER target-interrupt arm mask: RIE (RXI, bit 5) | TIE (TXI, bit 7) | SPIE (STOP,...
@ k_ra8_i2c_peripheral_addr_shift
Shift to place a 7-bit own address into SARLy.SVA[6:0] (bits [7:1]).
ra8_err_t ra8_i2c_peripheral_attach_handler(uint8_t channel, ra8_i2c_peripheral_event_fn_t fn, void *ctx)
Attach (or detach) the address-match callback for a channel.
I2C Bus Interface (IIC) register layout for the Renesas RA8D2.
@ k_ra8_i2c_sarl_sva_pos
7-bit own address / 10-bit low SVA[6:0].
@ k_ra8_i2c_msk_iccr2_trs
HUM 39.2.2 ICCR2.TRS, p 2371.
@ k_ra8_i2c_msk_icsr2_nackf
HUM 39.2.10 ICSR2.NACKF, p 2384.
@ k_ra8_i2c_msk_icsr2_tdre
HUM 39.2.10 ICSR2.TDRE, p 2384.
@ k_ra8_i2c_msk_icmr3_wait
HUM 39.2.5 ICMR3.WAIT, p 2376.
@ k_ra8_i2c_msk_icsr2_stop
HUM 39.2.10 ICSR2.STOP, p 2384.
@ k_ra8_i2c_msk_icsr2_tend
HUM 39.2.10 ICSR2.TEND, p 2384.
@ k_ra8_i2c_msk_icsr2_rdrf
HUM 39.2.10 ICSR2.RDRF, p 2384.
@ k_ra8_i2c_channel_count
HUM Ch 39.1, p 2367 (3 channels).
@ k_ra8_i2c_icier_rie_pos
Receive data full interrupt enable.
@ k_ra8_i2c_icier_spie_pos
Stop condition interrupt enable.
@ k_ra8_i2c_icier_tie_pos
Transmit data empty interrupt enable.
static volatile r_i2c_regs_t * ra8_i2c_regs(uint8_t channel)
Get a pointer to the IIC channel channel register block.
@ k_ra8_i2c_msk_icser_gcae
HUM 39.2.7 ICSER.GCAE, p 2380.
@ k_ra8_i2c_msk_icsr1_match
Union AAS0|AAS1|AAS2|GCA: any own-address/general-call match.
@ k_ra8_i2c_msk_icser_sar0e
HUM 39.2.7 ICSER.SAR0E, p 2380.
Memory-mapped register block for one IIC channel.
volatile uint8_t ICCR2
+0x01 Bus Control Register 2 (HUM 39.2.2, p 2371).
volatile uint8_t ICIER
+0x07 Bus Interrupt Enable (HUM 39.2.8, p 2381).
volatile uint8_t SARU0
+0x0B Peripheral Address U0 (HUM 39.2.14, p 2391).
volatile uint8_t ICSER
+0x06 Bus Status Enable (HUM 39.2.7, p 2380).
volatile uint8_t ICDRT
+0x12 Transmit Data Register (HUM 39.2.17, p 2393).
volatile uint8_t ICDRR
+0x13 Receive Data Register (HUM 39.2.18, p 2393).
volatile uint8_t ICSR1
+0x08 Bus Status Register 1 (HUM 39.2.9, p 2382).
volatile uint8_t SARL2
+0x0E Peripheral Address L2 (HUM 39.2.13, p 2390).
volatile uint8_t SARL1
+0x0C Peripheral Address L1 (HUM 39.2.13, p 2390).
volatile uint8_t SARU1
+0x0D Peripheral Address U1 (HUM 39.2.14, p 2391).
volatile uint8_t SARU2
+0x0F Peripheral Address U2 (HUM 39.2.14, p 2391).
volatile uint8_t SARL0
+0x0A Peripheral Address L0 (HUM 39.2.13, p 2390).
volatile uint8_t ICMR3
+0x04 Bus Mode Register 3 (HUM 39.2.5, p 2376).
volatile uint8_t ICSR2
+0x09 Bus Status Register 2 (HUM 39.2.10, p 2384).
Configuration descriptor for ra8_i2c_peripheral_init.
Definition ra8_i2c.h:482
ra8_i2c_peripheral_slot_t slot
Own-address comparator slot.
Definition ra8_i2c.h:484
uint8_t own_addr_7b
7-bit own address to answer on.
Definition ra8_i2c.h:483
bool general_call
Also answer the general-call addr.
Definition ra8_i2c.h:485
bool irq_enable
Arm ICIER RIE / TIE / SPIE.
Definition ra8_i2c.h:487
bool clock_stretch
Arm ICMR3.WAIT clock stretching.
Definition ra8_i2c.h:486