ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_mipi_dsi_dispatch.c
Go to the documentation of this file.
1
37
38#include <stddef.h>
39#include <stdint.h>
40#include <string.h>
41
42#include "ra8_attributes.h"
43#include "ra8_check.h"
44#include "ra8_err.h"
45#include "ra8_log.h"
46#include "ra8_mipi_dsi.h"
48#include "ra8_mipi_dsi_regs.h"
49#include "ra8_mstp.h"
50
65static const char* s_tag = "MIPI_DSI";
66
82static void internal_ra8_mipi_dsi_decode_rx(uint32_t raw, ra8_mipi_dsi_rx_result_t* out_result)
83{
84 out_result->data[0] = (uint8_t)(raw & k_ra8_mipi_dsi_rxrss_data0_mask);
85 out_result->data[1] =
86 (uint8_t)((raw & k_ra8_mipi_dsi_rxrss_data1_mask) >> (uint32_t)k_rxrss_data1_shift);
87 out_result->cmd_id =
89 out_result->virtual_channel =
91 out_result->long_packet = ((raw & k_ra8_mipi_dsi_rxrss_fmt) != 0U);
92 out_result->rx_success = ((raw & k_ra8_mipi_dsi_rxrss_rxsuc) != 0U);
93 out_result->rx_fatal_error = ((raw & k_ra8_mipi_dsi_rxrss_rxferr) != 0U);
94 out_result->rx_fail = ((raw & k_ra8_mipi_dsi_rxrss_rxfail) != 0U);
95 out_result->rx_packet_data_fail = ((raw & k_ra8_mipi_dsi_rxrss_rxpfail) != 0U);
96 out_result->rx_correctable_error = ((raw & k_ra8_mipi_dsi_rxrss_rxcerr) != 0U);
97 out_result->rx_ack_and_error = ((raw & k_ra8_mipi_dsi_rxrss_rxake) != 0U);
98 out_result->info_overwritten = ((raw & k_ra8_mipi_dsi_rxrss_infoow) != 0U);
99}
100
101/* =============================================================================
102 * Video mode
103 * =============================================================================
104 */
105
107{
108 RA8_CHECK_NULL_PTR(vcfg, s_tag, "vcfg must not be nullptr");
109 if ((uint32_t)vcfg->virtual_channel > (uint32_t)k_ra8_mipi_dsi_vc3) {
111 }
112
113 volatile r_mipi_dsi_regs_t* reg = ra8_mipi_dsi();
114
115 /* HUM Ch 65.2 "VMSET1R : Video Mode Setting 1", p 3892 */
116 reg->VMSET1R = (((uint32_t)vcfg->video_mode_delay) << k_ra8_mipi_dsi_vmset1_dly_shift) &
118
119 /* HUM Ch 65.2 "VMPPSETR : Video Mode Pixel Packet Setting", p 3896 */
120 uint32_t vmpp =
122 vmpp |= (((uint32_t)vcfg->virtual_channel) << k_ra8_mipi_dsi_vmpp_vc_shift) &
124 if (vcfg->sync_pulse) {
126 }
127 reg->VMPPSETR = vmpp;
128
129 /* HUM Ch 65.2 "VMVSSETR : Video Mode Vertical Sync Setting", p 3897 */
130 uint32_t vmvs = (((uint32_t)vcfg->vertical_sync_lines) & k_ra8_mipi_dsi_vmvs_vsa_mask);
131 vmvs |= (((uint32_t)vcfg->vertical_active_lines) << k_ra8_mipi_dsi_vmvs_vact_shift) &
133 if (vcfg->vsync_active_high) {
135 }
136 reg->VMVSSETR = vmvs;
137
138 /* HUM Ch 65.2 "VMVPSETR : Video Mode Vertical Porch Setting", p 3898 */
139 uint32_t vmvp = ((uint32_t)vcfg->vertical_back_porch) & k_ra8_mipi_dsi_vmvp_vbp_mask;
140 vmvp |= (((uint32_t)vcfg->vertical_front_porch) << k_ra8_mipi_dsi_vmvp_vfp_shift) &
142 reg->VMVPSETR = vmvp;
143
144 /* HUM Ch 65.2 "VMHSSETR : Video Mode Horizontal Sync Setting", p 3899 */
145 uint32_t vmhs = ((uint32_t)vcfg->horizontal_sync_lines) & k_ra8_mipi_dsi_vmhs_hsa_mask;
146 vmhs |= (((uint32_t)vcfg->horizontal_active_pixels) << k_ra8_mipi_dsi_vmhs_hact_shift) &
148 if (vcfg->hsync_active_high) {
150 }
151 reg->VMHSSETR = vmhs;
152
153 /* HUM Ch 65.2 "VMHPSETR : Video Mode Horizontal Porch Setting", p 3899 */
154 uint32_t vmhp = ((uint32_t)vcfg->horizontal_back_porch) & k_ra8_mipi_dsi_vmhp_hbp_mask;
155 vmhp |= (((uint32_t)vcfg->horizontal_front_porch) << k_ra8_mipi_dsi_vmhp_hfp_shift) &
157 reg->VMHPSETR = vmhp;
158
159 return k_ra8_ok;
160}
161
163{
164 RA8_CHECK_NULL_PTR(vcfg, s_tag, "vcfg must not be nullptr");
165 volatile r_mipi_dsi_regs_t* reg = ra8_mipi_dsi();
166 uint32_t vmset = k_ra8_mipi_dsi_vmset0_vstart;
167 if (vcfg->hsa_no_lp) {
169 }
170 if (vcfg->hbp_no_lp) {
172 }
173 if (vcfg->hfp_no_lp) {
175 }
176 /* HUM Ch 65.2 "VMSET0R : Video Mode Setting 0", p 3891 */
177 reg->VMSET0R = vmset;
178 /* HUM Ch 65.2 "VMSR : Video Mode Status Register", p 3893 */
182}
183
185{
186 volatile r_mipi_dsi_regs_t* reg = ra8_mipi_dsi();
187 /* HUM Ch 65.2 "VMSET0R : Video Mode Setting 0", p 3891 */
189 /* HUM Ch 65.2 "VMSR : Video Mode Status Register", p 3893 */
193 if (err == k_ra8_ok) {
194 /* HUM Ch 65.2 "VMSCR : Video Mode Status Clear", p 3894 */
196 }
197 return err;
198}
199
200/* =============================================================================
201 * Status / IRQ
202 * =============================================================================
203 */
204
205[[nodiscard]] ra8_err_t ra8_mipi_dsi_get_status(uint32_t* out_mask)
206{
207 RA8_CHECK_NULL_PTR(out_mask, s_tag, "out_mask must not be nullptr");
208 /* HUM Ch 65.2 "ISR : Interrupt Status Register", p 3840 */
209 *out_mask = ra8_mipi_dsi()->ISR;
210 return k_ra8_ok;
211}
212
214{
215 RA8_CHECK_NULL_PTR(out_status, s_tag, "out_status must not be nullptr");
216 /* HUM Ch 65.2 "LINKSR : Link Status Register", p 3842 */
217 const uint32_t v = ra8_mipi_dsi()->LINKSR;
218 out_status->sequence_ch0_running = ((v & k_ra8_mipi_dsi_link_sq0run) != 0U);
219 out_status->sequence_ch1_running = ((v & k_ra8_mipi_dsi_link_sq1run) != 0U);
220 out_status->video_running = ((v & k_ra8_mipi_dsi_link_vrun) != 0U);
221 out_status->hs_busy = ((v & k_ra8_mipi_dsi_link_hsbusy) != 0U);
222 out_status->lp_busy = ((v & k_ra8_mipi_dsi_link_lpbusy) != 0U);
223 return k_ra8_ok;
224}
225
226[[nodiscard]] ra8_err_t ra8_mipi_dsi_clear_status(uint32_t mask)
227{
228 volatile r_mipi_dsi_regs_t* reg = ra8_mipi_dsi();
229 if ((mask & k_ra8_mipi_dsi_isr_sq0) != 0U) {
230 /* HUM Ch 65.2 "SQCH0SCR : Sequence Channel 0 Status Clear", p 3902 */
232 }
233 if ((mask & k_ra8_mipi_dsi_isr_sq1) != 0U) {
234 /* HUM Ch 65.2 "SQCH1SCR : Sequence Channel 1 Status Clear", p 3907 */
236 }
237 if ((mask & k_ra8_mipi_dsi_isr_vm) != 0U) {
238 /* HUM Ch 65.2 "VMSCR : Video Mode Status Clear", p 3894 */
240 }
241 if ((mask & k_ra8_mipi_dsi_isr_rcv) != 0U) {
242 /* HUM Ch 65.2 "RXSCR : Receive Status Clear", p 3855 */
244 }
245 if ((mask & k_ra8_mipi_dsi_isr_ferr) != 0U) {
246 /* HUM Ch 65.2 "FERRSCR : Fatal Error Status Clear", p 3878 */
248 }
249 if ((mask & k_ra8_mipi_dsi_isr_ppi) != 0U) {
250 /* HUM Ch 65.2 "PLSCR : PHY Lane Status Clear", p 3887 */
252 }
253 return k_ra8_ok;
254}
255
257{
258 RA8_CHECK_NULL_PTR(out_err, s_tag, "out_err must not be nullptr");
259 volatile r_mipi_dsi_regs_t* reg = ra8_mipi_dsi();
260 /* HUM Ch 65.2 "AKEPACMSR : Ack/Error Report Accumulated Status", p 3864 */
261 const uint32_t v = reg->AKEPACMSR;
262 out_err->error_report = (uint16_t)(v & k_ra8_mipi_dsi_akep_erep_mask);
263 out_err->virtual_channel =
266 /* HUM Ch 65.2 "AKEPSCR : Ack/Error Report Status Clear", p 3865 */
267 reg->AKEPSCR = v;
268 return k_ra8_ok;
269}
270
271[[nodiscard]] ra8_err_t ra8_mipi_dsi_rx_result_get(uint8_t slot,
272 ra8_mipi_dsi_rx_result_t* out_result)
273{
274 RA8_CHECK_NULL_PTR(out_result, s_tag, "out_result must not be nullptr");
275 if (slot >= (uint8_t)k_ra8_mipi_dsi_rx_slots) {
277 }
278 volatile r_mipi_dsi_regs_t* reg = ra8_mipi_dsi();
279 /* HUM Ch 65.2 "RXRSSR : Receive Result Save Status Register", p 3866 */
280 const uint32_t valid_bit = (1U << slot);
281 if ((reg->RXRSSR & valid_bit) == 0U) {
282 return k_ra8_err_no_data;
283 }
284 uint32_t raw = 0U;
285 /* HUM Ch 65.2 "RXRSS0R..RXRSS3R : Receive Result Save 0..3", p 3879 */
286 switch (slot) {
287 case 0U:
288 raw = reg->RXRSS0R;
289 break;
290 case 1U:
291 raw = reg->RXRSS1R;
292 break;
293 case 2U:
294 raw = reg->RXRSS2R;
295 break;
296 case 3U:
297 default:
298 raw = reg->RXRSS3R;
299 break;
300 }
301 internal_ra8_mipi_dsi_decode_rx(raw, out_result);
302 /* HUM Ch 65.2 "RXRSSCR : Receive Result Save Status Clear", p 3867 */
303 reg->RXRSSCR = valid_bit;
304 /* HUM Ch 65.2 "RXRINFOOWSCR : Receive Result Info-Overwrite Clear", p 3869 */
305 reg->RXRINFOOWSCR = valid_bit;
306 return k_ra8_ok;
307}
308
309[[nodiscard]] ra8_err_t
310ra8_mipi_dsi_rx_payload_read(uint8_t* dest, uint16_t max_len, uint16_t* out_len)
311{
312 RA8_CHECK_NULL_PTR(dest, s_tag, "dest must not be nullptr");
313 RA8_CHECK_NULL_PTR(out_len, s_tag, "out_len must not be nullptr");
314 volatile r_mipi_dsi_regs_t* reg = ra8_mipi_dsi();
315 /* HUM Ch 65.2 "RXPPD0R..RXPPD3R : Receive Packet Payload 0..3", p 3879 */
316 const uint32_t words[4] = {reg->RXPPD0R, reg->RXPPD1R, reg->RXPPD2R, reg->RXPPD3R};
317 const uint16_t cap = k_ra8_mipi_dsi_payload_max;
318 const uint16_t eff = (max_len < cap) ? max_len : cap;
319 for (uint16_t i = 0U; i < eff; ++i) {
320 const uint16_t word_idx = (uint16_t)(i / 4U);
321 const uint16_t byte_idx = (uint16_t)(i % 4U);
322 dest[i] =
323 (uint8_t)((words[word_idx] >> (byte_idx * (uint32_t)k_shift_8)) & k_ra8_mipi_dsi_byte_mask);
324 }
325 *out_len = eff;
326 return k_ra8_ok;
327}
328
329[[nodiscard]] ra8_err_t ra8_mipi_dsi_te_event_pending(bool* out_pending)
330{
331 RA8_CHECK_NULL_PTR(out_pending, s_tag, "out_pending must not be nullptr");
332 /* HUM Ch 65.2 "RXSR : Receive Status Register", p 3852 */
333 const uint32_t v = ra8_mipi_dsi()->RXSR;
334 const uint32_t te_mask = k_ra8_mipi_dsi_rxsr_rxte | k_ra8_mipi_dsi_rxsr_extedet;
335 *out_pending = ((v & te_mask) != 0U);
336 return k_ra8_ok;
337}
338
340{
341 /* HUM Ch 65.2 "RXSCR : Receive Status Clear", p 3855 */
343 return k_ra8_ok;
344}
345
346[[nodiscard]] ra8_err_t
347ra8_mipi_dsi_irq_enable(ra8_mipi_dsi_event_t event, uint32_t mask, bool enable)
348{
349 volatile r_mipi_dsi_regs_t* reg = ra8_mipi_dsi();
350 volatile uint32_t* ier = nullptr;
351 switch (event) {
353 /* HUM Ch 65.2 "SQCH0IER : Sequence Channel 0 Interrupt Enable", p 3903 */
354 ier = &reg->SQCH0IER;
355 break;
357 /* HUM Ch 65.2 "SQCH1IER : Sequence Channel 1 Interrupt Enable", p 3909 */
358 ier = &reg->SQCH1IER;
359 break;
361 /* HUM Ch 65.2 "VMIER : Video Mode Interrupt Enable", p 3895 */
362 ier = &reg->VMIER;
363 break;
365 /* HUM Ch 65.2 "RXIER : Receive Interrupt Enable", p 3858 */
366 ier = &reg->RXIER;
367 break;
369 /* HUM Ch 65.2 "FERRIER : Fatal Error Interrupt Enable", p 3879 */
370 ier = &reg->FERRIER;
371 break;
373 /* HUM Ch 65.2 "PLIER : PHY Lane Interrupt Enable", p 3889 */
374 ier = &reg->PLIER;
375 break;
376 default:
378 }
379 if (enable) {
380 *ier |= mask;
381 } else {
382 *ier &= ~mask;
383 }
384 return k_ra8_ok;
385}
386
388{
391 return k_ra8_ok;
392}
393
394/* =============================================================================
395 * Per-class dispatch
396 * =============================================================================
397 */
398
415{
417 void* const ctx = s_mipi_dsi_event_ctx;
418 if (fn != nullptr) {
419 fn(ctx, event, mask);
420 }
421}
422
425{
426 volatile r_mipi_dsi_regs_t* reg = ra8_mipi_dsi();
427 /* HUM Ch 65.2 "SQCH0SR : Sequence Channel 0 Status Register", p 3900 */
428 const uint32_t bits = reg->SQCH0SR;
429 /* HUM Ch 65.2 "SQCH0SCR : Sequence Channel 0 Status Clear", p 3902 */
432}
433
436{
437 volatile r_mipi_dsi_regs_t* reg = ra8_mipi_dsi();
438 /* HUM Ch 65.2 "SQCH1SR : Sequence Channel 1 Status Register", p 3905 */
439 const uint32_t bits = reg->SQCH1SR;
440 /* HUM Ch 65.2 "SQCH1SCR : Sequence Channel 1 Status Clear", p 3907 */
443}
444
447{
448 volatile r_mipi_dsi_regs_t* reg = ra8_mipi_dsi();
449 /* HUM Ch 65.2 "VMSR : Video Mode Status Register", p 3893 */
450 const uint32_t bits = reg->VMSR;
451 /* HUM Ch 65.2 "VMSCR : Video Mode Status Clear", p 3894 */
453 /* If buffer over/underflow, FSP recommends a soft reset; mirror that. */
455 /* HUM Ch 65.2 "RSTCR : Reset Control Register", p 3845 */
457 /* HUM Ch 65.2 "RSTCR : Reset Control Register", p 3845 */
458 reg->RSTCR = 0U;
459 }
461}
462
465{
466 volatile r_mipi_dsi_regs_t* reg = ra8_mipi_dsi();
467 /* HUM Ch 65.2 "RXSR : Receive Status Register", p 3852 */
468 const uint32_t bits = reg->RXSR;
469 /* HUM Ch 65.2 "RXSCR : Receive Status Clear", p 3855 */
471 /* If a response packet arrived, copy RXPPD into the pending buffer. */
472 if ((bits & k_ra8_mipi_dsi_rxsr_rxresp) != 0U) {
473 // mcdc-deactivated: ra8_mipi_dsi_dispatch_receive pending-RX gate; s_mipi_dsi_pending_rx_buffer and s_mipi_dsi_pending_rx_len are written together (atomic pair) by ra8_mipi_dsi_rx_payload_register; the buffer is never set without a non-zero length and vice-versa, so the conditions are co-dependent on any reachable path.
474 if ((s_mipi_dsi_pending_rx_buffer != nullptr) && (s_mipi_dsi_pending_rx_len > 0U)) {
475 uint16_t got = 0U;
478 &got);
481 }
482 }
483 /* HUM Ch 65.2 "RXRINFOOWSCR : Receive Result Info-Overwrite Clear", p 3869 */
486}
487
490{
491 volatile r_mipi_dsi_regs_t* reg = ra8_mipi_dsi();
492 /* HUM Ch 65.2 "FERRSR : Fatal Error Status Register", p 3876 */
493 const uint32_t bits = reg->FERRSR;
494 /* HUM Ch 65.2 "FERRSCR : Fatal Error Status Clear", p 3878 */
497}
498
501{
502 volatile r_mipi_dsi_regs_t* reg = ra8_mipi_dsi();
503 /* HUM Ch 65.2 "PLSR : PHY Lane Status Register", p 3884 */
504 const uint32_t bits = reg->PLSR;
505 /* HUM Ch 65.2 "PLSCR : PHY Lane Status Clear", p 3887 */
508}
509
512{
513 /* HUM Ch 65.2 "ISR : Interrupt Status Register", p 3840 */
514 const uint32_t snapshot = ra8_mipi_dsi()->ISR;
515 if ((snapshot & k_ra8_mipi_dsi_isr_sq0) != 0U) {
517 }
518 if ((snapshot & k_ra8_mipi_dsi_isr_sq1) != 0U) {
520 }
521 if ((snapshot & k_ra8_mipi_dsi_isr_vm) != 0U) {
523 }
524 if ((snapshot & k_ra8_mipi_dsi_isr_rcv) != 0U) {
526 }
527 if ((snapshot & k_ra8_mipi_dsi_isr_ferr) != 0U) {
529 }
530 if ((snapshot & k_ra8_mipi_dsi_isr_ppi) != 0U) {
532 }
533 /* If nothing was set, still call user with mask=0 so the legacy
534 * "always invoke" contract from the previous revision is preserved. */
535 if ((snapshot & k_ra8_mipi_dsi_isr_all) == 0U) {
537 }
538}
539
540/* =============================================================================
541 * Sweep 6 convenience surfaces
542 * =============================================================================
543 */
544
559
561{
562 RA8_CHECK_NULL_PTR(timing, s_tag, "timing must not be nullptr");
563
564 /* Range-check every field against its register-width limit. */
568 }
574 }
578 }
579
580 /* Build a full video config with sensible defaults: RGB888 on VC0,
581 * sync-pulse off, blanking stays HS so the panel does not drop the
582 * link between lines. */
583 const ra8_mipi_dsi_video_cfg_t v = {
584 .pixel_format = k_ra8_mipi_dsi_dt_pixel_rgb888,
585 .virtual_channel = k_ra8_mipi_dsi_vc0,
586 .sync_pulse = false,
587 .hsa_no_lp = true,
588 .hbp_no_lp = true,
589 .hfp_no_lp = true,
590 .vsync_active_high = true,
591 .hsync_active_high = true,
592 .vertical_sync_lines = timing->vertical_sync,
593 .vertical_active_lines = timing->vertical_active,
594 .vertical_back_porch = timing->vertical_back_porch,
595 .vertical_front_porch = timing->vertical_front_porch,
596 .horizontal_sync_lines = timing->horizontal_sync,
597 .horizontal_active_pixels = timing->horizontal_active,
598 .horizontal_back_porch = timing->horizontal_back_porch,
599 .horizontal_front_porch = timing->horizontal_front_porch,
600 .video_mode_delay = 0U,
601 };
603}
604
606 const uint8_t params[2])
607{
608 RA8_CHECK_NULL_PTR(params, s_tag, "params must not be nullptr");
609 return ra8_mipi_dsi_send_short_packet(dt, k_ra8_mipi_dsi_vc0, params[0], params[1]);
610}
611
612[[nodiscard]] ra8_err_t
613ra8_mipi_dsi_send_command_long(ra8_mipi_dsi_dt_t dt, const uint8_t* payload, uint16_t len)
614{
615 if ((len > 0U) && (payload == nullptr)) {
616 return k_ra8_err_null_ptr;
617 }
618 /* HS path on VC0 -- command-mode panels always want this routing. */
619 return ra8_mipi_dsi_send_long_packet(dt, k_ra8_mipi_dsi_vc0, payload, len, false);
620}
621
623 const uint8_t* payload,
624 uint16_t len)
625{
626 if ((len > 0U) && (payload == nullptr)) {
627 return k_ra8_err_null_ptr;
628 }
629 /* HUM Ch 65 "Command-mode packet TX" pp 3839-3934 -- short writes
630 * pack the payload into the 2-parameter header; long writes stage
631 * via TXPPD0..3R. */
632 enum : uint16_t {
633 k_ra8_mipi_dsi_short_payload_max = 2U,
634 };
635 if (len <= k_ra8_mipi_dsi_short_payload_max) {
636 const uint8_t p0 = (len > 0U) ? payload[0] : 0U;
637 const uint8_t p1 = (len > 1U) ? payload[1] : 0U;
638 return ra8_mipi_dsi_send_short_packet(packet_type, k_ra8_mipi_dsi_vc0, p0, p1);
639 }
640 /* Long packet through LP escape (low_power = true). */
641 return ra8_mipi_dsi_send_long_packet(packet_type, k_ra8_mipi_dsi_vc0, payload, len, true);
642}
643
648
653
static const char * s_tag
Logging / check tag.
Definition ra8_app.c:17
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_no_data
No application data available (e.g.
Definition ra8_err.h:202
@ 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
Lightweight Logging Interface for ra8-firmware.
void * s_mipi_dsi_event_ctx
Single definition of the shared IRQ callback context.
uint16_t s_mipi_dsi_pending_rx_len
Single definition of the shared pending receive capacity.
ra8_err_t priv_ra8_mipi_dsi_internal_wait_eq(volatile const uint32_t *reg, uint32_t mask, uint32_t expect)
Implementation of priv_ra8_mipi_dsi_internal_wait_eq() – bounded busy-poll.
ra8_mipi_dsi_event_fn_t s_mipi_dsi_event_fn
Single definition of the shared IRQ callback pointer.
uint8_t * s_mipi_dsi_pending_rx_buffer
Single definition of the shared pending receive buffer.
MIPI DSI-2 host driver – public API (full HUM Ch 65 surface).
ra8_err_t ra8_mipi_dsi_ulps_exit(uint8_t lanes)
Wake the selected lanes out of ULPS.
ra8_err_t ra8_mipi_dsi_send_short_packet(ra8_mipi_dsi_dt_t cmd_id, ra8_mipi_dsi_vc_t vc, uint8_t param0, uint8_t param1)
Send a DSI short packet on sequence channel 0 (LP escape).
ra8_err_t ra8_mipi_dsi_send_long_packet(ra8_mipi_dsi_dt_t cmd_id, ra8_mipi_dsi_vc_t vc, const uint8_t *data, uint16_t tx_len, bool low_power)
Send a DSI long-packet write (Generic Long / DCS Long).
ra8_err_t ra8_mipi_dsi_ulps_enter(uint8_t lanes)
Drive the selected lanes into Ultra-Low-Power State.
ra8_err_t ra8_mipi_dsi_clear_status(uint32_t mask)
Clear bits in any of the sub-status registers.
void ra8_mipi_dsi_dispatch_fatal(void)
Fatal-error IRQ handler.
ra8_err_t ra8_mipi_dsi_video_configure(const ra8_mipi_dsi_video_cfg_t *vcfg)
Programme every video-mode timing register from a single config.
ra8_err_t ra8_mipi_dsi_rx_payload_read(uint8_t *dest, uint16_t max_len, uint16_t *out_len)
Copy out the most-recent long-packet RX payload (RXPPD0..3R).
void ra8_mipi_dsi_dispatch_seq1(void)
Sequence-channel-1 IRQ handler (HS path).
ra8_err_t ra8_mipi_dsi_te_event_pending(bool *out_pending)
Check if a tearing-effect (TE) trigger was received.
void ra8_mipi_dsi_dispatch_phy(void)
PHY-protocol-interface IRQ handler.
static void internal_ra8_mipi_dsi_decode_rx(uint32_t raw, ra8_mipi_dsi_rx_result_t *out_result)
Decode an RXRSS slot register into a struct.
void ra8_mipi_dsi_dispatch_seq0(void)
Sequence-channel-0 IRQ handler (LP path).
ra8_err_t ra8_mipi_dsi_video_stop(void)
Request a video-mode stop and wait for it.
void ra8_mipi_dsi_dispatch(void)
Snapshot ISR, clear sub-status, fan out per-class callbacks.
ra8_err_t ra8_mipi_dsi_send_command_long(ra8_mipi_dsi_dt_t dt, const uint8_t *payload, uint16_t len)
Send a DSI command-mode long packet on VC0 (HS path).
ra8_err_t ra8_mipi_dsi_get_status(uint32_t *out_mask)
Read the top-level Interrupt Status Register.
ra8_err_t ra8_mipi_dsi_irq_enable(ra8_mipi_dsi_event_t event, uint32_t mask, bool enable)
Toggle a sub-class IER bit.
ra8_mipi_dsi_timing_limits_t
Per-field bit-width caps for ra8_mipi_dsi_video_timing_t.
@ k_ra8_mipi_dsi_timing_max_active
15-bit field.
@ k_ra8_mipi_dsi_timing_max_porch
13-bit field.
@ k_ra8_mipi_dsi_timing_max_sync
12-bit field.
ra8_err_t ra8_mipi_dsi_exit_ulps(void)
Wake the entire link out of ULPS.
void ra8_mipi_dsi_dispatch_video(void)
Video-mode IRQ handler.
ra8_err_t ra8_mipi_dsi_enter_ulps(void)
Drive the entire link (clock + data lanes) into ULPS.
ra8_err_t ra8_mipi_dsi_send_command_short(ra8_mipi_dsi_dt_t dt, const uint8_t params[2])
Send a DSI command-mode short packet on VC0 (LP escape).
ra8_err_t ra8_mipi_dsi_video_start(const ra8_mipi_dsi_video_cfg_t *vcfg)
Start video-mode operation.
ra8_err_t ra8_mipi_dsi_ack_error_get(ra8_mipi_dsi_ack_error_t *out_err)
Read the latest accumulated ack/error report and clear it.
ra8_err_t ra8_mipi_dsi_send_command_payload(ra8_mipi_dsi_dt_t packet_type, const uint8_t *payload, uint16_t len)
Send a DSI command-mode packet (short or long) on VC0 in LP escape.
ra8_err_t ra8_mipi_dsi_set_video_timing(const ra8_mipi_dsi_video_timing_t *timing)
Load only the HSA/HBP/HACT/HFP/VSA/VBP/VACT/VFP video-timing registers from a compact descriptor.
static void internal_ra8_mipi_dsi_call_user(ra8_mipi_dsi_event_t event, uint32_t mask)
Common helper that fires the registered callback.
void ra8_mipi_dsi_dispatch_receive(void)
Receive IRQ handler.
ra8_err_t ra8_mipi_dsi_link_status_get(ra8_mipi_dsi_link_status_t *out_status)
Decode LINKSR into a struct.
ra8_err_t ra8_mipi_dsi_attach_handler(ra8_mipi_dsi_event_fn_t fn, void *ctx)
Attach a callback for MIPI DSI interrupt events.
ra8_err_t ra8_mipi_dsi_get_link_status(ra8_mipi_dsi_link_status_t *out)
Snapshot the link state (running flags + busy flags + accumulated ack/error report) into a single str...
ra8_err_t ra8_mipi_dsi_rx_result_get(uint8_t slot, ra8_mipi_dsi_rx_result_t *out_result)
Decode and consume an RXRSS slot.
ra8_err_t ra8_mipi_dsi_te_event_clear(void)
Clear the latched tearing-effect bits in RXSR.
Module-private link seam shared between the MIPI DSI-2 hostdriver translation units.
@ k_akep_vc_shift
Akep vc shift.
@ k_shift_8
Shift 8.
@ k_rxrss_vc_shift
Rxrss vc shift.
@ k_rxrss_dt_shift
Rxrss dt shift.
@ k_rxrss_data1_shift
Rxrss data1 shift.
@ k_ra8_mipi_dsi_byte_mask
8-bit byte field.
@ k_ra8_mipi_dsi_isr_all
RA8 mipi dsi ISR all.
@ k_ra8_mipi_dsi_vc_mask
2-bit virtual-channel.
MIPI DSI Host (DSI-2) register layout for the RA8D2.
@ k_ra8_mipi_dsi_vmsr_clear_all
Mask of every defined VMSR bit – write to VMSCR to scrub.
@ k_ra8_mipi_dsi_vmsr_virdy
Video mode ready (started).
@ k_ra8_mipi_dsi_vmsr_vbufovf
Video buffer overflow.
@ k_ra8_mipi_dsi_vmsr_stop
Video mode stopped.
@ k_ra8_mipi_dsi_vmsr_vbufudf
Video buffer underflow.
@ k_ra8_mipi_dsi_vmpp_vc_shift
VC field position.
@ k_ra8_mipi_dsi_vmpp_vc_mask
VC[23:22] mask, used to clamp the virtual-channel field.
@ k_ra8_mipi_dsi_vmpp_txesync
Transmit end-of-sync.
@ k_ra8_mipi_dsi_vmpp_dt_shift
DT field position.
@ k_ra8_mipi_dsi_vmpp_dt_mask
DT[21:16] mask, used to clamp the data-type field.
@ k_ra8_mipi_dsi_rstcr_swrst
Assert software reset.
@ k_ra8_mipi_dsi_rxrss_rxcerr
Correctable error.
@ k_ra8_mipi_dsi_rxrss_fmt
Long-packet flag.
@ k_ra8_mipi_dsi_rxrss_data0_mask
DATA0 byte 1 of pkt.
@ k_ra8_mipi_dsi_rxrss_rxfail
Receive fail.
@ k_ra8_mipi_dsi_rxrss_rxsuc
Receive success.
@ k_ra8_mipi_dsi_rxrss_data1_mask
DATA1 byte 2 of pkt.
@ k_ra8_mipi_dsi_rxrss_rxpfail
Packet data fail.
@ k_ra8_mipi_dsi_rxrss_vc_mask
Virtual channel.
@ k_ra8_mipi_dsi_rxrss_dt_mask
DT data type bits.
@ k_ra8_mipi_dsi_rxrss_rxferr
Fatal error.
@ k_ra8_mipi_dsi_rxrss_infoow
Info overwritten.
@ k_ra8_mipi_dsi_rxrss_rxake
Ack/error report.
@ k_ra8_mipi_dsi_ferrsr_clear_all
RW1C-able fields in FERRSCR (status-only bits 27/28 excluded).
@ k_ra8_mipi_dsi_vmset0_hsanolp
HSA period stays HS.
@ k_ra8_mipi_dsi_vmset0_hfpnolp
HFP period stays HS.
@ k_ra8_mipi_dsi_vmset0_vstop
VSTOP : request video stop.
@ k_ra8_mipi_dsi_vmset0_vstart
VSTART: start video mode.
@ k_ra8_mipi_dsi_vmset0_hbpnolp
HBP period stays HS.
@ k_ra8_mipi_dsi_vmhs_hact_shift
HACT shift.
@ k_ra8_mipi_dsi_vmhs_hsa_mask
HSA[11:0].
@ k_ra8_mipi_dsi_vmhs_hact_mask
HACT[30:16].
@ k_ra8_mipi_dsi_vmhs_hspol
HSYNC polarity.
@ k_ra8_mipi_dsi_vmhp_hfp_mask
HFP[28:16].
@ k_ra8_mipi_dsi_vmhp_hfp_shift
HFP shift.
@ k_ra8_mipi_dsi_vmhp_hbp_mask
HBP[12:0].
@ k_ra8_mipi_dsi_rx_slots
RXRSS0..3 receive slot count.
@ k_ra8_mipi_dsi_payload_max
TXPPD bytes (4 x 32-bit regs).
@ k_ra8_mipi_dsi_vmset1_dly_mask
DLY[13:2] field mask.
@ k_ra8_mipi_dsi_vmset1_dly_shift
DLY position.
@ k_ra8_mipi_dsi_vmvs_vact_shift
VACT shift.
@ k_ra8_mipi_dsi_vmvs_vspol
VSYNC polarity.
@ k_ra8_mipi_dsi_vmvs_vact_mask
VACT[30:16].
@ k_ra8_mipi_dsi_vmvs_vsa_mask
VSA[11:0].
static volatile r_mipi_dsi_regs_t * ra8_mipi_dsi(void)
Pointer to the RA8D2 MIPI DSI host register block.
@ k_ra8_mipi_dsi_isr_rcv
Receive interrupt.
@ k_ra8_mipi_dsi_isr_sq1
Sequence channel 1 interrupt.
@ k_ra8_mipi_dsi_isr_ppi
PPI (D-PHY) interrupt.
@ k_ra8_mipi_dsi_isr_ferr
Fatal-error interrupt.
@ k_ra8_mipi_dsi_isr_vm
Video-mode interrupt.
@ k_ra8_mipi_dsi_isr_sq0
Sequence channel 0 interrupt.
@ k_ra8_mipi_dsi_akep_vc_mask
Virtual channel id.
@ k_ra8_mipi_dsi_akep_erep_mask
16-bit error report.
@ k_ra8_mipi_dsi_rxrinfoow_sl0
Slot 0 overwrite flag.
@ k_ra8_mipi_dsi_rxsr_rxresp
Response packet received.
@ k_ra8_mipi_dsi_rxsr_rxte
Tearing-effect trigger rx.
@ k_ra8_mipi_dsi_rxsr_extedet
External TE detect.
@ k_ra8_mipi_dsi_rxsr_clear_all
Mask of every defined RXSR bit – write to RXSCR to scrub.
@ k_ra8_mipi_dsi_plsr_clear_all
Bit subset that is RW1C in PLSCR (steady-state lane bits aren't).
@ k_ra8_mipi_dsi_vmvp_vfp_mask
VFP[28:16].
@ k_ra8_mipi_dsi_vmvp_vbp_mask
VBP[12:0].
@ k_ra8_mipi_dsi_vmvp_vfp_shift
VFP shift.
@ k_ra8_mipi_dsi_sqch_clear_all
Mask of every RW1C bit in SQCH*SCR.
@ k_ra8_mipi_dsi_link_vrun
Video-mode operation running.
@ k_ra8_mipi_dsi_link_sq1run
Sequence ch 1 running.
@ k_ra8_mipi_dsi_link_lpbusy
LP operation busy.
@ k_ra8_mipi_dsi_link_hsbusy
HS operation busy.
@ k_ra8_mipi_dsi_link_sq0run
Sequence ch 0 running.
@ k_ra8_mipi_dsi_lane_all
Composite mask: clock + all data lanes.
ra8_mipi_dsi_dt_t
Frequently used DSI Data Types (cmd id) for short and long packets.
@ k_ra8_mipi_dsi_dt_pixel_rgb888
24-bit RGB packed pixel.
ra8_mipi_dsi_vc_t
DSI virtual channel identifier (DT[7:6] in the packet header).
@ k_ra8_mipi_dsi_vc3
Virtual channel 3.
@ k_ra8_mipi_dsi_vc0
Virtual channel 0 (default panel).
ra8_mipi_dsi_event_t
Event class delivered to the user callback.
@ k_ra8_mipi_dsi_event_seq1
Sequence channel 1 (HS) finished.
@ k_ra8_mipi_dsi_event_fatal
Fatal-error class IRQ.
@ k_ra8_mipi_dsi_event_receive
Packet / response received.
@ k_ra8_mipi_dsi_event_phy
PPI (PHY) lane event.
@ k_ra8_mipi_dsi_event_seq0
Sequence channel 0 (LP) finished.
@ k_ra8_mipi_dsi_event_video
Video-mode status changed.
void(* ra8_mipi_dsi_event_fn_t)(void *ctx, ra8_mipi_dsi_event_t event, uint32_t status_mask)
MIPI DSI ISR-context callback signature.
Ref-counted Module Stop Control wrapper for the RA8D2.
MIPI DSI host register block (full layout).
volatile uint32_t VMSET1R
+0x404 Video-mode set 1.
volatile uint32_t VMHSSETR
+0x430 Horizontal sync timing.
volatile uint32_t RSTCR
+0x110 Software reset control.
volatile uint32_t VMVPSETR
+0x42C Vertical porch timing.
volatile uint32_t SQCH0IER
+0x5D8 Sequence ch 0 int enable.
volatile uint32_t AKEPACMSR
+0x224 Ack/err accumulated (RO).
volatile uint32_t VMSCR
+0x414 Video-mode status clear.
volatile uint32_t SQCH1SR
+0x610 Sequence ch 1 status (RO).
volatile uint32_t VMVSSETR
+0x428 Vertical sync timing.
volatile uint32_t VMPPSETR
+0x420 Video pixel-packet set.
volatile uint32_t FERRIER
+0x308 Fatal-error int enable.
volatile uint32_t SQCH1IER
+0x618 Sequence ch 1 int enable.
volatile uint32_t LINKSR
+0x010 Link status (RO).
volatile uint32_t RXRSSCR
+0x234 Rx result save clear.
volatile uint32_t RXRSS0R
+0x240 Rx result save slot 0.
volatile uint32_t SQCH0SCR
+0x5D4 Sequence ch 0 clear.
volatile uint32_t RXSCR
+0x204 Receive status clear.
volatile uint32_t VMSET0R
+0x400 Video-mode set 0.
volatile uint32_t VMSR
+0x410 Video-mode status (RO).
volatile uint32_t VMIER
+0x418 Video-mode int enable.
volatile uint32_t PLSR
+0x320 PHY (PPI) status (RO).
volatile uint32_t RXRSS2R
+0x248 Rx result save slot 2.
volatile uint32_t RXRSS1R
+0x244 Rx result save slot 1.
volatile uint32_t RXRSS3R
+0x24C Rx result save slot 3.
volatile uint32_t RXRSSR
+0x230 Rx result save status.
volatile uint32_t RXPPD1R
+0x2C4 Rx packet payload data 1.
volatile uint32_t RXPPD3R
+0x2CC Rx packet payload data 3.
volatile uint32_t PLIER
+0x328 PHY interrupt enable.
volatile uint32_t RXIER
+0x208 Receive interrupt enable.
volatile uint32_t AKEPSCR
+0x228 Ack/err clear.
volatile uint32_t RXSR
+0x200 Receive status (RO).
volatile uint32_t FERRSR
+0x300 Fatal-error status (RO).
volatile uint32_t SQCH1SCR
+0x614 Sequence ch 1 clear.
volatile uint32_t ISR
+0x000 IRQ status (RO).
volatile uint32_t VMHPSETR
+0x434 Horizontal porch timing.
volatile uint32_t RXPPD0R
+0x2C0 Rx packet payload data 0.
volatile uint32_t PLSCR
+0x324 PHY status clear.
volatile uint32_t SQCH0SR
+0x5D0 Sequence ch 0 status (RO).
volatile uint32_t FERRSCR
+0x304 Fatal-error status clear.
volatile uint32_t RXRINFOOWSCR
+0x23C Rx info-overwrite clear.
volatile uint32_t RXPPD2R
+0x2C8 Rx packet payload data 2.
Decoded view of AKEPLATIR / AKEPACMSR.
ra8_mipi_dsi_vc_t virtual_channel
VC tag of the report.
uint16_t error_report
16-bit DSI ack/error bitmap.
Decoded view of a single RXRSS slot register.
bool long_packet
FMT bit (1 = long packet).
ra8_mipi_dsi_dt_t cmd_id
DT[5:0] received.
bool rx_packet_data_fail
RXPFAIL flag.
ra8_mipi_dsi_vc_t virtual_channel
VC[1:0] received.
uint8_t data[2]
Header DATA0 / DATA1 bytes.
bool info_overwritten
INFOOW flag.
bool rx_correctable_error
RXCERR flag.
Video-mode timing + format + sync configuration.
uint16_t horizontal_back_porch
VMHPSETR.HBP[12:0].
uint16_t horizontal_active_pixels
VMHSSETR.HACT[30:16].
uint16_t vertical_back_porch
VMVPSETR.VBP[12:0].
uint16_t vertical_sync_lines
VMVSSETR.VSA[11:0].
uint16_t video_mode_delay
VMSET1R.DLY[13:2] x 4.
bool sync_pulse
Non-burst with sync pulse.
uint16_t vertical_front_porch
VMVPSETR.VFP[28:16].
bool hsync_active_high
VMHSSETR.HSPOL.
bool vsync_active_high
VMVSSETR.VSPOL.
ra8_mipi_dsi_vc_t virtual_channel
VC for the pixel stream.
uint16_t vertical_active_lines
VMVSSETR.VACT[30:16].
bool hbp_no_lp
Stay HS during HBP period.
bool hfp_no_lp
Stay HS during HFP period.
bool hsa_no_lp
Stay HS during HSA period.
ra8_mipi_dsi_dt_t pixel_format
RGB565 / RGB666 / RGB888.
uint16_t horizontal_front_porch
VMHPSETR.HFP[28:16].
uint16_t horizontal_sync_lines
VMHSSETR.HSA[11:0].
Compact video-mode timing block (HSA/HBP/HACT/HFP + VSA/VBP/VACT/VFP).
uint16_t horizontal_front_porch
HFP pixel count -> VMHPSETR.HFP.
uint16_t vertical_back_porch
VBP line count -> VMVPSETR.VBP.
uint16_t horizontal_active
HACT pixel count -> VMHSSETR.HACT.
uint16_t horizontal_back_porch
HBP pixel count -> VMHPSETR.HBP.
uint16_t vertical_front_porch
VFP line count -> VMVPSETR.VFP.
uint16_t vertical_sync
VSA line count -> VMVSSETR.VSA.
uint16_t vertical_active
VACT line count -> VMVSSETR.VACT.
uint16_t horizontal_sync
HSA pixel count -> VMHSSETR.HSA.