Skip to content

Commit 582b73c

Browse files
Thinh Le Congthenguyenyf
authored andcommitted
hal: renesas: ra: Initial support for SCI SPI of Renesas RA SoCs
Initial support for SCI SPI of Renesas RA2, RA4, RA6 SoCs Signed-off-by: Thinh Le Cong <[email protected]>
1 parent 5ab2c84 commit 582b73c

File tree

4 files changed

+1135
-0
lines changed

4 files changed

+1135
-0
lines changed

drivers/ra/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ zephyr_library_sources_ifdef(CONFIG_USE_RA_FSP_SPI
4444
fsp/src/r_spi/r_spi.c)
4545
zephyr_library_sources_ifdef(CONFIG_USE_RA_FSP_SCI_B_SPI
4646
fsp/src/r_sci_b_spi/r_sci_b_spi.c)
47+
zephyr_library_sources_ifdef(CONFIG_USE_RA_FSP_SCI_SPI
48+
fsp/src/r_sci_spi/r_sci_spi.c)
4749
zephyr_library_sources_ifdef(CONFIG_USE_RA_FSP_TIMER_ULPT
4850
fsp/src/r_ulpt/r_ulpt.c)
4951
zephyr_library_sources_ifdef(CONFIG_USE_RA_FSP_LPM
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
* Copyright (c) 2020 - 2025 Renesas Electronics Corporation and/or its affiliates
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
#ifndef R_SCI_SPI_H
8+
#define R_SCI_SPI_H
9+
10+
/***********************************************************************************************************************
11+
* Includes
12+
**********************************************************************************************************************/
13+
#include "r_spi_api.h"
14+
15+
/* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */
16+
FSP_HEADER
17+
18+
/*****************************************************************************************************************//**
19+
* @ingroup SCI_SPI
20+
* @{
21+
********************************************************************************************************************/
22+
23+
/***********************************************************************************************************************
24+
* Macro definitions
25+
**********************************************************************************************************************/
26+
27+
/***********************************************************************************************************************
28+
* Typedef definitions
29+
**********************************************************************************************************************/
30+
31+
/** Settings for adjusting the SPI CLK. */
32+
typedef struct
33+
{
34+
uint8_t brr;
35+
uint8_t cks : 2;
36+
uint8_t mddr; ///< Set to 0 to disable MDDR.
37+
} sci_spi_div_setting_t;
38+
39+
/** SCI SPI extended configuration */
40+
typedef struct st_sci_spi_extended_cfg
41+
{
42+
sci_spi_div_setting_t clk_div;
43+
} sci_spi_extended_cfg_t;
44+
45+
/** SPI instance control block. DO NOT INITIALIZE. */
46+
typedef struct st_sci_spi_instance_ctrl
47+
{
48+
uint32_t open;
49+
spi_cfg_t const * p_cfg;
50+
R_SCI0_Type * p_reg;
51+
uint8_t * p_src;
52+
uint8_t * p_dest;
53+
uint32_t tx_count;
54+
uint32_t rx_count;
55+
uint32_t count;
56+
57+
/* Pointer to callback and optional working memory */
58+
void (* p_callback)(spi_callback_args_t *);
59+
spi_callback_args_t * p_callback_memory;
60+
61+
/* Pointer to context to be passed into callback function */
62+
void * p_context;
63+
} sci_spi_instance_ctrl_t;
64+
65+
/**********************************************************************************************************************
66+
* Exported global variables
67+
**********************************************************************************************************************/
68+
69+
/** @cond INC_HEADER_DEFS_SEC */
70+
/** Filled in Interface API structure for this Instance. */
71+
extern const spi_api_t g_spi_on_sci;
72+
73+
/** @endcond */
74+
75+
/**********************************************************************************************************************
76+
* Public Function Prototypes
77+
**********************************************************************************************************************/
78+
fsp_err_t R_SCI_SPI_Open(spi_ctrl_t * p_api_ctrl, spi_cfg_t const * const p_cfg);
79+
fsp_err_t R_SCI_SPI_Read(spi_ctrl_t * const p_api_ctrl,
80+
void * p_dest,
81+
uint32_t const length,
82+
spi_bit_width_t const bit_width);
83+
fsp_err_t R_SCI_SPI_Write(spi_ctrl_t * const p_api_ctrl,
84+
void const * p_src,
85+
uint32_t const length,
86+
spi_bit_width_t const bit_width);
87+
fsp_err_t R_SCI_SPI_WriteRead(spi_ctrl_t * const p_api_ctrl,
88+
void const * p_src,
89+
void * p_dest,
90+
uint32_t const length,
91+
spi_bit_width_t const bit_width);
92+
fsp_err_t R_SCI_SPI_Close(spi_ctrl_t * const p_api_ctrl);
93+
fsp_err_t R_SCI_SPI_CalculateBitrate(uint32_t bitrate, sci_spi_div_setting_t * sclk_div, bool use_mddr);
94+
fsp_err_t R_SCI_SPI_CallbackSet(spi_ctrl_t * const p_api_ctrl,
95+
void ( * p_callback)(spi_callback_args_t *),
96+
void * const p_context,
97+
spi_callback_args_t * const p_callback_memory);
98+
99+
/* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */
100+
FSP_FOOTER
101+
102+
#endif
103+
104+
/*******************************************************************************************************************//**
105+
* @} (end ingroup SCI_SPI)
106+
**********************************************************************************************************************/

0 commit comments

Comments
 (0)