Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions drivers/rz/README
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,7 @@ Patch List:
Impacted files:
drivers/rz/fsp/src/rzg/r_gtm/r_gtm.c
drivers/rz/fsp/src/rzv/r_gtm/r_gtm.c

* Use r_transfer_api.h of rzv-fsp to support the callbackSet member of the transfer_api_t struct
Impacted files:
drivers/rz/fsp/inc/api/r_transfer_api.h
49 changes: 23 additions & 26 deletions drivers/rz/fsp/inc/api/r_transfer_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
*/

/*******************************************************************************************************************//**
* @ingroup RENESAS_INTERFACES
* @ingroup RENESAS_TRANSFER_INTERFACES
* @defgroup TRANSFER_API Transfer Interface
*
* @brief Interface for data transfer functions.
*
* @section TRANSFER_API_SUMMARY Summary
* The transfer interface supports background data transfer (no CPU intervention).
*
* Implemented by:
* - @ref DMAC_B
*
* @{
**********************************************************************************************************************/
Expand Down Expand Up @@ -49,8 +47,6 @@ FSP_HEADER
**********************************************************************************************************************/

/** Transfer control block. Allocate an instance specific control block to pass into the transfer API calls.
* @par Implemented as
* - dmac_b_instance_ctrl_t
*/
typedef void transfer_ctrl_t;

Expand Down Expand Up @@ -95,7 +91,8 @@ typedef enum e_transfer_size
{
TRANSFER_SIZE_1_BYTE = 0, ///< Each transfer transfers a 8-bit value
TRANSFER_SIZE_2_BYTE = 1, ///< Each transfer transfers a 16-bit value
TRANSFER_SIZE_4_BYTE = 2 ///< Each transfer transfers a 32-bit value
TRANSFER_SIZE_4_BYTE = 2, ///< Each transfer transfers a 32-bit value
TRANSFER_SIZE_8_BYTE = 3 ///< Each transfer transfers a 64-bit value
} transfer_size_t;

#endif
Expand Down Expand Up @@ -172,6 +169,16 @@ typedef enum e_transfer_irq

#endif

#ifndef BSP_OVERRIDE_TRANSFER_CALLBACK_ARGS_T

/** Callback function parameter data. */
typedef struct st_transfer_callback_args_t
{
void const * p_context; ///< Placeholder for user data. Set in @ref transfer_api_t::open function in ::transfer_cfg_t.
} transfer_callback_args_t;

#endif

/** Driver specific information. */
typedef struct st_transfer_properties
{
Expand Down Expand Up @@ -266,8 +273,6 @@ typedef enum e_transfer_start_mode
typedef struct st_transfer_api
{
/** Initial configuration.
* @par Implemented as
* - @ref R_DMAC_B_Open()
*
* @param[in,out] p_ctrl Pointer to control block. Must be declared by user. Elements set here.
* @param[in] p_cfg Pointer to configuration structure. All elements of this structure
Expand All @@ -277,8 +282,6 @@ typedef struct st_transfer_api

/** Reconfigure the transfer.
* Enable the transfer if p_info is valid.
* @par Implemented as
* - @ref R_DMAC_B_Reconfigure()
*
* @param[in,out] p_ctrl Pointer to control block. Must be declared by user. Elements set here.
* @param[in] p_info Pointer to a new transfer info structure.
Expand All @@ -287,8 +290,6 @@ typedef struct st_transfer_api

/** Reset source address pointer, destination address pointer, and/or length, keeping all other settings the same.
* Enable the transfer if p_src, p_dest, and length are valid.
* @par Implemented as
* - @ref R_DMAC_B_Reset()
*
* @param[in] p_ctrl Control block set in @ref transfer_api_t::open call for this transfer.
* @param[in] p_src Pointer to source. Set to NULL if source pointer should not change.
Expand All @@ -302,8 +303,6 @@ typedef struct st_transfer_api

/** Enable transfer. Transfers occur after the activation source event (or when
* @ref transfer_api_t::softwareStart is called if no peripheral event is chosen as activation source).
* @par Implemented as
* - @ref R_DMAC_B_Enable()
*
* @param[in] p_ctrl Control block set in @ref transfer_api_t::open call for this transfer.
*/
Expand All @@ -313,8 +312,6 @@ typedef struct st_transfer_api
* @ref transfer_api_t::softwareStart is called if no peripheral event is chosen as the DMAC activation source).
* @note If a transfer is in progress, it will be completed. Subsequent transfer requests do not cause a
* transfer.
* @par Implemented as
* - @ref R_DMAC_B_Disable()
*
* @param[in] p_ctrl Control block set in @ref transfer_api_t::open call for this transfer.
*/
Expand All @@ -323,8 +320,6 @@ typedef struct st_transfer_api
/** Start transfer in software.
* @warning Only works if no peripheral event is chosen as the DMAC activation source.
* @note Not supported for DTC.
* @par Implemented as
* - @ref R_DMAC_B_SoftwareStart()
*
* @param[in] p_ctrl Control block set in @ref transfer_api_t::open call for this transfer.
* @param[in] mode Select mode from @ref transfer_start_mode_t.
Expand All @@ -335,34 +330,26 @@ typedef struct st_transfer_api
* @note Not supported for DTC.
* @note Only applies for transfers started with TRANSFER_START_MODE_REPEAT.
* @warning Only works if no peripheral event is chosen as the DMAC activation source.
* @par Implemented as
* - @ref R_DMAC_B_SoftwareStop()
*
* @param[in] p_ctrl Control block set in @ref transfer_api_t::open call for this transfer.
*/
fsp_err_t (* softwareStop)(transfer_ctrl_t * const p_ctrl);

/** Provides information about this transfer.
* @par Implemented as
* - @ref R_DMAC_B_InfoGet()
*
* @param[in] p_ctrl Control block set in @ref transfer_api_t::open call for this transfer.
* @param[out] p_properties Driver specific information.
*/
fsp_err_t (* infoGet)(transfer_ctrl_t * const p_ctrl, transfer_properties_t * const p_properties);

/** Releases hardware lock. This allows a transfer to be reconfigured using @ref transfer_api_t::open.
* @par Implemented as
* - @ref R_DMAC_B_Close()
*
* @param[in] p_ctrl Control block set in @ref transfer_api_t::open call for this transfer.
*/
fsp_err_t (* close)(transfer_ctrl_t * const p_ctrl);

/** To update next transfer information without interruption during transfer.
* Allow further transfer continuation.
* @par Implemented as
* - @ref R_DMAC_B_Reload()
*
* @param[in] p_ctrl Control block set in @ref transfer_api_t::open call for this transfer.
* @param[in] p_src Pointer to source. Set to NULL if source pointer should not change.
Expand All @@ -372,6 +359,16 @@ typedef struct st_transfer_api
fsp_err_t (* reload)(transfer_ctrl_t * const p_ctrl, void const * p_src, void * p_dest,
uint32_t const num_transfers);

/** Specify callback function and optional context pointer and working memory pointer.
*
* @param[in] p_ctrl Control block set in @ref transfer_api_t::open call for this transfer.
* @param[in] p_callback Callback function to register
* @param[in] p_context Pointer to send to callback function
* @param[in] p_callback_memory Pointer to volatile memory where callback structure can be allocated.
* Callback arguments allocated here are only valid during the callback.
*/
fsp_err_t (* callbackSet)(transfer_ctrl_t * const p_ctrl, void (* p_callback)(transfer_callback_args_t *),
void const * const p_context, transfer_callback_args_t * const p_callback_memory);
} transfer_api_t;

/** This structure encompasses everything that is needed to use an instance of this interface. */
Expand Down
219 changes: 219 additions & 0 deletions drivers/rz/fsp/inc/instances/rzv/r_dmac_b.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
/*
* Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates
*
* SPDX-License-Identifier: BSD-3-Clause
*/

/*******************************************************************************************************************//**
* @addtogroup DMAC_B
* @{
**********************************************************************************************************************/

#ifndef R_DMAC_B_H
#define R_DMAC_B_H

/***********************************************************************************************************************
* Includes
**********************************************************************************************************************/
#include "bsp_api.h"
#include "r_transfer_api.h"

/* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */
FSP_HEADER

/***********************************************************************************************************************
* Macro definitions
**********************************************************************************************************************/

/** Max configurable number of transfers in TRANSFER_MODE_NORMAL. */
#define DMAC_B_MAX_NORMAL_TRANSFER_LENGTH (0xFFFFFFFF)

/** Max number of transfers per block in TRANSFER_MODE_BLOCK */
#define DMAC_B_MAX_BLOCK_TRANSFER_LENGTH (0xFFFFFFFF)

/***********************************************************************************************************************
* Typedef definitions
**********************************************************************************************************************/

typedef transfer_callback_args_t dmac_b_callback_args_t;

/** Transfer size specifies the size of each individual transfer. */
typedef enum e_dmac_b_transfer_size
{
DMAC_B_TRANSFER_SIZE_1_BYTE = 0, ///< Each transfer transfers a 8-bit value.
DMAC_B_TRANSFER_SIZE_2_BYTE = 1, ///< Each transfer transfers a 16-bit value.
DMAC_B_TRANSFER_SIZE_4_BYTE = 2, ///< Each transfer transfers a 32-bit value.
DMAC_B_TRANSFER_SIZE_8_BYTE = 3, ///< Each transfer transfers a 64-bit value.
DMAC_B_TRANSFER_SIZE_16_BYTE = 4, ///< Each transfer transfers a 128-bit value.
DMAC_B_TRANSFER_SIZE_32_BYTE = 5, ///< Each transfer transfers a 256-bit value.
DMAC_B_TRANSFER_SIZE_64_BYTE = 6, ///< Each transfer transfers a 512-bit value.
DMAC_B_TRANSFER_SIZE_128_BYTE = 7, ///< Each transfer transfers a 1024-bit value.
} dmac_b_transfer_size_t;

/** DACK output mode. See RZ/T2M hardware manual Table 14.19 DMA Transfer Request Detection Operation Setting Table. */
typedef enum e_dmac_b_ack_mode
{
DMAC_B_ACK_MODE_LEVEL_MODE = 1, ///< Level mode.
DMAC_B_ACK_MODE_BUS_CYCLE_MODE = 2, ///< Bus cycle mode.
DMAC_B_ACK_MODE_MASK_DACK_OUTPUT = 4, ///< Output is masked.
} dmac_b_ack_mode_t;

#ifndef BSP_OVERRIDE_DMAC_B_EXTERNAL_DETECTION_T

/** Detection method of the external DMA request signal. See RZ/T2M hardware manual Table 14.19 DMA Transfer Request Detection Operation Setting Table. */
typedef enum e_dmac_b_external_detection
{
DMAC_B_EXTERNAL_DETECTION_LOW_LEVEL = 0, ///< Low level detection.
DMAC_B_EXTERNAL_DETECTION_FALLING_EDGE = 1, ///< Falling edge detection.
DMAC_B_EXTERNAL_DETECTION_RISING_EDGE = 2, ///< Rising edge detection.
DMAC_B_EXTERNAL_DETECTION_FALLING_RISING_EDGE = 3, ///< Falling/Rising edge detection.
} dmac_b_external_detection_t;

#endif

/** Detection method of the internal DMA request signal. See RZ/T2M hardware manual Table 14.19 DMA Transfer Request Detection Operation Setting Table. */
typedef enum e_dmac_b_internal_detection
{
DMAC_B_INTERNAL_DETECTION_NO_DETECTION = 0, ///< Not using hardware detection.
DMAC_B_INTERNAL_DETECTION_FALLING_EDGE = 1, ///< Falling edge detection.
DMAC_B_INTERNAL_DETECTION_RISING_EDGE = 2, ///< Rising edge detection.
DMAC_B_INTERNAL_DETECTION_LOW_LEVEL = 5, ///< Low level detection.
DMAC_B_INTERNAL_DETECTION_HIGH_LEVEL = 6, ///< High level detection.
} dmac_b_internal_detection_t;

/** DMA activation request source select. See RZ/T2M hardware manual Table 14.19 DMA Transfer Request Detection Operation Setting Table. */
typedef enum e_dmac_b_request_direction
{
DMAC_B_REQUEST_DIRECTION_SOURCE_MODULE = 0, ///< Requested by a transfer source module.
DMAC_B_REQUEST_DIRECTION_DESTINATION_MODULE = 1, ///< Requested by a transfer destination module.
} dmac_b_request_direction_t;

/** Select the Next register set to be executed next. */
typedef enum e_dmac_b_continuous_setting
{
DMAC_B_CONTINUOUS_SETTING_TRANSFER_ONCE = 0x0, ///< Transfer only once using the Next0 register set.
DMAC_B_CONTINUOUS_SETTING_TRANSFER_ALTERNATELY = 0x3, ///< Transfers are performed alternately with the Next0 register set and the Next1 register set.
} dmac_b_continuous_setting_t;

/** Register set settings. */
typedef struct st_dmac_b_register_set_setting_t
{
void const * p_src; ///< Source pointer.
void * p_dest; ///< Destination pointer.
uint32_t length; ///< Transfer byte.
} dmac_b_register_set_setting_t;

/** DMAC channel scheduling. */
typedef enum e_dmac_b_channel_scheduling
{
DMAC_B_CHANNEL_SCHEDULING_FIXED = 0, ///< Fixed priority mode.
DMAC_B_CHANNEL_SCHEDULING_ROUND_ROBIN = 1, ///< Round-robin mode.
} dmac_b_channel_scheduling_t;

/** DMAC mode setting. */
typedef enum e_dmac_b_mode_select
{
DMAC_B_MODE_SELECT_REGISTER = 0, ///< Register mode.
DMAC_B_MODE_SELECT_LINK = 1, ///< Link mode.
} dmac_b_mode_select_t;

/** Control block used by driver. DO NOT INITIALIZE - this structure will be initialized in @ref transfer_api_t::open. */
typedef struct st_dmac_b_instance_ctrl
{
uint32_t open; // Driver ID

transfer_cfg_t const * p_cfg;

/* Pointer to base register. */
R_DMAC_B0_Type * p_reg;

void (* p_callback)(dmac_b_callback_args_t *); // Pointer to callback
dmac_b_callback_args_t * p_callback_memory; // Pointer to optional callback argument memory
void const * p_context; // Pointer to context to be passed into callback function
} dmac_b_instance_ctrl_t;

/** DMAC transfer configuration extension. This extension is required. */
typedef struct st_dmac_b_extended_cfg
{
uint8_t unit; ///< Unit number
uint8_t channel; ///< Channel number
IRQn_Type dmac_int_irq; ///< DMAC interrupt number
uint8_t dmac_int_ipl; ///< DMAC interrupt priority

/** Select which event will trigger the transfer. */
dmac_trigger_event_t activation_source;
dmac_b_ack_mode_t ack_mode; ///< DACK output mode
dmac_b_external_input_pin_t dreq_input_pin; ///< DREQ input pin name
dmac_b_external_output_pin_t ack_output_pin; ///< DACK output pin name
dmac_b_external_output_pin_t tend_output_pin; ///< TEND output pin name
dmac_b_external_detection_t external_detection_mode; ///< DMAC request detection method for external pin
dmac_b_internal_detection_t internal_detection_mode; ///< DMAC request detection method for internal pin
dmac_b_request_direction_t activation_request_source_select; ///< DMAC activation request source

dmac_b_mode_select_t dmac_mode; ///< DMAC Mode
dmac_b_continuous_setting_t continuous_setting; ///< Next register operation settings
uint16_t transfer_interval; ///< DMA transfer interval
dmac_b_channel_scheduling_t channel_scheduling; ///< DMA channel scheduling

/** Callback for transfer end interrupt. */
void (* p_callback)(dmac_b_callback_args_t * cb_data);

/** Placeholder for user data. Passed to the user p_callback in ::transfer_callback_args_t. */
void const * p_context;
} dmac_b_extended_cfg_t;

/** DMAC transfer information configuration extension. This extension is required. */
typedef struct st_dmac_b_extended_info
{
/** Select number of source bytes to transfer at once. */
dmac_b_transfer_size_t src_size;

/** Select number of destination bytes to transfer at once. */
dmac_b_transfer_size_t dest_size;

/** Next1 Register set settings */
dmac_b_register_set_setting_t * p_next1_register_setting;
} dmac_b_extended_info_t;

/**********************************************************************************************************************
* Exported global variables
**********************************************************************************************************************/

/** @cond INC_HEADER_DEFS_SEC */
/** Filled in Interface API structure for this Instance. */
extern const transfer_api_t g_transfer_on_dmac_b;

/** @endcond */

/***********************************************************************************************************************
* Public Function Prototypes
**********************************************************************************************************************/
fsp_err_t R_DMAC_B_Open(transfer_ctrl_t * const p_api_ctrl, transfer_cfg_t const * const p_cfg);
fsp_err_t R_DMAC_B_Reconfigure(transfer_ctrl_t * const p_api_ctrl, transfer_info_t * p_info);
fsp_err_t R_DMAC_B_Reset(transfer_ctrl_t * const p_api_ctrl,
void const * volatile p_src,
void * volatile p_dest,
uint16_t const num_transfers);
fsp_err_t R_DMAC_B_SoftwareStart(transfer_ctrl_t * const p_api_ctrl, transfer_start_mode_t mode);
fsp_err_t R_DMAC_B_SoftwareStop(transfer_ctrl_t * const p_api_ctrl);
fsp_err_t R_DMAC_B_Enable(transfer_ctrl_t * const p_api_ctrl);
fsp_err_t R_DMAC_B_Disable(transfer_ctrl_t * const p_api_ctrl);
fsp_err_t R_DMAC_B_InfoGet(transfer_ctrl_t * const p_api_ctrl, transfer_properties_t * const p_info);
fsp_err_t R_DMAC_B_Close(transfer_ctrl_t * const p_api_ctrl);
fsp_err_t R_DMAC_B_Reload(transfer_ctrl_t * const p_api_ctrl,
void const * p_src,
void * p_dest,
uint32_t const num_transfers);
fsp_err_t R_DMAC_B_CallbackSet(transfer_ctrl_t * const p_api_ctrl,
void ( * p_callback)(dmac_b_callback_args_t *),
void const * const p_context,
dmac_b_callback_args_t * const p_callback_memory);

/* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */
FSP_FOOTER

#endif

/*******************************************************************************************************************//**
* @} (end defgroup DMAC)
**********************************************************************************************************************/
Loading