ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_esp_hosted_c6link.c
Go to the documentation of this file.
1
19
21
22#include <stdint.h>
23#include <string.h>
24
25#include "esp_hosted_os_abstraction.h"
29#include "ra8_attributes.h"
30#include "ra8_c6link.h"
32#include "ra8_err.h"
33#include "ra8_esp_hosted_port.h"
34#include "transport_drv.h"
35
50
72internal_ra8_esp_hosted_c6link_transfer(void* ctx, const uint8_t* tx, uint8_t* rx, uint16_t len)
73{
74 (void)ctx;
77 }
78 if (len > (uint16_t)k_ra8_c6link_frame_bytes) {
80 }
81
82 /* The vendored transport context's transmit pointer is not const, and
83 casting the caller's const one to fit would be a pointer-to-integer
84 conversion with no recorded MISRA deviation behind it. Staging the frame
85 instead costs a memcpy of about a microsecond against a transaction that
86 takes milliseconds, and it buys something real: the buffer the bus sees is
87 always DMA-aligned regardless of what the caller allocated. */
88 (void)memcpy(s_ra8_esp_hosted_c6link_tx, tx, (size_t)len);
89
90 struct hosted_transport_context_t xfer = {};
91 xfer.tx_buf = s_ra8_esp_hosted_c6link_tx;
92 xfer.tx_buf_size = (uint32_t)len;
93 xfer.rx_buf = rx;
94
95 const int32_t moved = (int32_t)g_h.funcs->_h_do_bus_transfer(&xfer);
96 return (moved == (int32_t)RET_OK) ? k_ra8_ok : k_ra8_err_spi_error;
97}
98
117{
118 (void)ctx;
120 return false;
121 }
122 const int32_t level =
123 (int32_t)g_h.funcs->_h_read_gpio(H_GPIO_HANDSHAKE_Port, (uint32_t)H_GPIO_HANDSHAKE_Pin);
124 return level == (int32_t)H_HS_VAL_ACTIVE;
125}
126
142RA8_INTERNAL static void internal_ra8_esp_hosted_c6link_delay(void* ctx, uint16_t ms)
143{
144 (void)ctx;
146 return;
147 }
148 (void)g_h.funcs->_h_msleep((unsigned int)ms);
149}
150
esp-hosted port header: transport selection, side-band pin map, link polarity.
#define H_GPIO_HANDSHAKE_Pin
Pin index of the HANDSHAKE input, or -1 when it is not wired.
#define H_GPIO_HANDSHAKE_Port
Opaque port handle of the HANDSHAKE input.
#define H_HS_VAL_ACTIVE
Level read back on HANDSHAKE when it is asserted.
esp-hosted port header: RTOS handle types, return codes and budgets.
#define RET_OK
Operation completed.
esp-hosted port header: full-duplex SPI transport buffer size.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Error Code Definitions for ra8-firmware.
@ k_ra8_err_spi_error
SPI transfer failed (bus fault, mode fault, overrun, ...).
Definition ra8_err.h:405
@ 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
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
Definition ra8_err.h:478
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
Definition ra8_err.h:167
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
struct hosted_config_t g_h
The handle the vendored core dereferences to reach the vtable.
Public entry point of the RA8D2 + ThreadX port of esp-hosted.
bool ra8_esp_hosted_port_is_ready(void)
Report whether the port is currently initialised.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.