Skip to content

Commit d435ee3

Browse files
TatsuyaOgawanxquytranpzz
authored andcommitted
hal: renesas: rx: Update BSP for the group interrupt driver
Made the group interrupt handler a global variable. Added a new function based on R_BSP_InterruptWrite. Signed-off-by: TatsuyaOgawa <[email protected]>
1 parent 740a944 commit d435ee3

File tree

7 files changed

+1276
-1201
lines changed

7 files changed

+1276
-1201
lines changed

drivers/rx/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ set(srcs
2020
rdp/src/r_bsp/mcu/${CONFIG_SOC_SERIES}/mcu_clocks.c
2121
rdp/src/r_bsp/mcu/${CONFIG_SOC_SERIES}/mcu_init.c
2222
rdp/src/r_bsp/mcu/${CONFIG_SOC_SERIES}/mcu_interrupts.c
23+
rdp/src/r_bsp/mcu/${CONFIG_SOC_SERIES}/mcu_mapped_interrupts.c
2324
)
2425

2526
zephyr_include_directories(${include_dirs})

drivers/rx/README

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,21 @@ Patch List:
8282
Impacted files:
8383
drivers/rx/rdp/src/r_lvd_rx/src/r_lvd_rx_hw.c
8484

85+
* Add include stdint header in BSP of RX130
86+
Impacted files:
87+
drivers/rx/rdp/src/r_bsp/mcu/rx130/mcu_clocks.h
88+
89+
* Made the group interrupt handler a global variable.
90+
Impacted files:
91+
drivers/rx/rdp/src/r_bsp/mcu/all/r_bsp_interrupts.c
92+
93+
* Added a new function based on R_BSP_InterruptWrite
94+
that allows passing a user-defined argument to the registered interrupt handler.
95+
Impacted files:
96+
drivers/rx/rdp/src/r_bsp/mcu/all/r_bsp_interrupts.c
97+
drivers/rx/rdp/src/r_bsp/mcu/all/r_bsp_interrupts.h
98+
drivers/rx/rdp/src/r_bsp/mcu/rx26t/mcu_interrupts.h
99+
85100
* Fix implicit conversion build warnings
86101
Impacted files:
87102
drivers/rx/rdp/src/r_bsp/mcu/rx26t/mcu_clocks.c

drivers/rx/rdp/src/r_bsp/mcu/all/r_bsp_interrupts.c

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ Private global variables and functions
5858
***********************************************************************************************************************/
5959
/* This array holds callback functions. */
6060
static void (* g_bsp_vectors[BSP_INT_SRC_TOTAL_ITEMS])(void * pdata);
61+
#if defined(BSP_MCU_RX26T)
62+
static void *g_bsp_contexts[BSP_INT_SRC_TOTAL_ITEMS];
63+
#endif
6164

6265
static bsp_int_err_t bsp_fit_interrupts_control (bool enable, bsp_int_ctrl_t * pdata);
6366

@@ -140,6 +143,9 @@ void bsp_interrupt_open(void)
140143
{
141144
/* Casting is valid because it matches the type to the right side or argument. */
142145
g_bsp_vectors[i] = FIT_NO_FUNC;
146+
#if defined(BSP_MCU_RX26T)
147+
g_bsp_contexts[i] = NULL;
148+
#endif
143149
}
144150

145151
#ifdef BSP_MCU_SOFTWARE_CONFIGURABLE_INTERRUPT
@@ -202,6 +208,58 @@ bsp_int_err_t R_BSP_InterruptWrite(bsp_int_src_t vector, bsp_int_cb_t callback)
202208
return err;
203209
} /* End of function R_BSP_InterruptWrite() */
204210

211+
#if defined(BSP_MCU_RX26T)
212+
/**********************************************************************************************************************
213+
* Function Name: R_BSP_InterruptWrite_EX
214+
******************************************************************************************************************//**
215+
* @brief Registers a callback function for an interrupt.
216+
* @param[in] vector Which interrupt to register a callback for.
217+
* @param[in] callback Pointer to function to call when interrupt occurs.
218+
* @param[in] context Pointer to the callback function's argument.
219+
* @retval BSP_INT_SUCCESS Successful, callback has been registered.
220+
* @retval BSP_INT_ERR_INVALID_ARG An invalid interrupt source was specified for vector.
221+
* @details This function registers a callback function for an interrupt. If FIT_NO_FUNC, NULL, or any other invalid
222+
* function address is passed for the callback argument then any previously registered callbacks are unregistered.
223+
* If one of the interrupts that is handled by this code is triggered then the interrupt handler will query this code
224+
* to see if a valid callback function is registered. If one is found then the callback function will be called.
225+
* If one is not found then the interrupt handler will clear the appropriate flag(s) and exit. If the user has a
226+
* callback function registered and wishes to no longer handle the interrupt then the user should call this function
227+
* again with FIT_NO_FUNC as the vector parameter.
228+
* @note Use of FIT_NO_FUNC is preferred over NULL since access to the address defined by FIT_NO_FUNC will cause a
229+
* bus error which is easy for the user to catch. NULL typically resolves to 0 which is a valid address on RX MCUs.
230+
*/
231+
bsp_int_err_t R_BSP_InterruptWrite_EX(bsp_int_src_t vector, bsp_int_cb_t callback, void *context)
232+
{
233+
bsp_int_err_t err;
234+
235+
err = BSP_INT_SUCCESS;
236+
237+
/* Check for valid address. */
238+
if (((uint32_t)callback == (uint32_t)NULL) || ((uint32_t)callback == (uint32_t)FIT_NO_FUNC))
239+
{
240+
/* Casting is valid because it matches the type to the right side or argument. */
241+
g_bsp_vectors[vector] = FIT_NO_FUNC;
242+
g_bsp_contexts[vector] = NULL;
243+
}
244+
else
245+
{
246+
if ((BSP_INT_SRC_BUS_ERROR_ILLEGAL_ACCESS == vector) || (BSP_INT_SRC_BUS_ERROR_TIMEOUT == vector) ||
247+
(BSP_INT_SRC_EMPTY <= vector))
248+
{
249+
/* When registering a bus error callback function, specify BSP_INT_SRC_BUS_ERROR in the vector. */
250+
err = BSP_INT_ERR_INVALID_ARG;
251+
}
252+
else
253+
{
254+
g_bsp_vectors[vector] = callback;
255+
g_bsp_contexts[vector] = context;
256+
}
257+
}
258+
259+
return err;
260+
} /* End of function R_BSP_InterruptWrite_EX() */
261+
#endif
262+
205263
/**********************************************************************************************************************
206264
* Function Name: R_BSP_InterruptRead
207265
******************************************************************************************************************//**
@@ -297,7 +355,9 @@ bsp_int_err_t R_BSP_InterruptControl(bsp_int_src_t vector, bsp_int_cmd_t cmd, vo
297355
{
298356
/* Fill in callback info. */
299357
cb_args.vector = vector;
300-
358+
#if defined(BSP_MCU_RX26T)
359+
cb_args.p_context = g_bsp_contexts[vector];
360+
#endif
301361
g_bsp_vectors[vector](&cb_args);
302362
}
303363
else

drivers/rx/rdp/src/r_bsp/mcu/all/r_bsp_interrupts.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ Exported global functions (to be accessed by other files)
4141
void R_BSP_InterruptRequestEnable(uint32_t vector);
4242
void R_BSP_InterruptRequestDisable(uint32_t vector);
4343
bsp_int_err_t R_BSP_InterruptWrite(bsp_int_src_t vector, bsp_int_cb_t callback);
44+
#if defined(BSP_MCU_RX26T)
45+
bsp_int_err_t R_BSP_InterruptWrite_EX(bsp_int_src_t vector, bsp_int_cb_t callback, void *context);
46+
#endif
4447
bsp_int_err_t R_BSP_InterruptRead(bsp_int_src_t vector, bsp_int_cb_t * callback);
4548
bsp_int_err_t R_BSP_InterruptControl(bsp_int_src_t vector, bsp_int_cmd_t cmd, void * pdata);
4649

0 commit comments

Comments
 (0)