Skip to content

Commit

Permalink
Update nrfx preview
Browse files Browse the repository at this point in the history
  • Loading branch information
e-rk committed Oct 15, 2024
1 parent d573c45 commit 3f74287
Show file tree
Hide file tree
Showing 11 changed files with 182 additions and 101 deletions.
9 changes: 5 additions & 4 deletions nrfx/drivers/include/nrfx_dppi.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@
#include <nrfx.h>
#include <haly/nrfy_dppi.h>

/* On devices with single instance (with no ID) use instance 0. */
#if defined(NRF_DPPIC) && defined(NRFX_DPPI_ENABLED) && !defined(NRFX_DPPI0_ENABLED)
#define NRFX_DPPI0_ENABLED 1
#endif

/**
* @defgroup nrfx_dppi DPPI allocator
* @{
* @ingroup nrf_dppi
* @brief Distributed Programmable Peripheral Interconnect (DPPI) allocator.
*/

#if defined DPPIC_COUNT && DPPIC_COUNT == 1
#define NRFX_DPPI0_ENABLED NRFX_DPPI_ENABLED
#endif

/** @brief Data structure of the Distributed programmable peripheral interconnect (DPPI) driver instance. */
typedef struct
{
Expand Down
124 changes: 113 additions & 11 deletions nrfx/drivers/include/nrfx_ppib.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
* @brief Programmable Peripheral Interconnect Bridge (PPIB) allocator.
*/

/** @brief Data structure of the Distributed programmable peripheral interconnect (PPIB) driver instance. */
/** @brief Data structure of the Programmable Peripheral Interconnect Bridge (PPIB) driver instance. */
typedef struct
{
NRF_PPIB_Type * p_reg; ///< Pointer to a structure containing PPIBC registers.
NRF_PPIB_Type * p_reg; ///< Pointer to a structure containing PPIBC registers.
} nrfx_ppib_t;

/** @brief Data structure of the pair of PPIB driver instances. */
Expand All @@ -66,7 +66,7 @@ enum {
};

enum {
/* List all enabled interconnects. Smaller PPIB idx are always to the left. */
/* List all enabled interconnects. Smaller PPIB idx are always on the left. */
#if defined(NRF54L15_ENGA_XXAA) || defined(NRF54L15_XXAA) || defined(NRF54L20_ENGA_XXAA)
#if NRFX_CHECK(NRFX_PPIB00_ENABLED) && NRFX_CHECK(NRFX_PPIB10_ENABLED)
NRFX_PPIB_INTERCONNECT_00_10_INST_IDX,
Expand Down Expand Up @@ -117,15 +117,15 @@ extern "C" {
#endif

/**
* @brief Function for freeing all allocated channels and groups.
* @brief Function for freeing all allocated channels for a given PPIB interconnection.
*
* @param[in] p_instance Pointer to the driver instance structure.
* @param[in] p_instance Pointer to the driver instance structure.
*/
void nrfx_ppib_free(nrfx_ppib_interconnect_t const * p_instance);

/**
* @brief Function for allocating a PPIB channel.
* @details This function allocates the first unused PPIB channel.
* @details This function allocates the highest available PPIB channel.
*
* @note Function is thread safe as it uses @ref nrfx_flag32_alloc.
*
Expand All @@ -138,7 +138,7 @@ void nrfx_ppib_free(nrfx_ppib_interconnect_t const * p_instance);
nrfx_err_t nrfx_ppib_channel_alloc(nrfx_ppib_interconnect_t const * p_instance, uint8_t * p_channel);

/**
* @brief Function for freeinpg a PPIB channel.
* @brief Function for freeing a PPIB channel.
* @details This function also clears the PUBLISH/SUBSCRIBE configuration.
*
* @note Function is thread safe as it uses @ref nrfx_flag32_free.
Expand All @@ -162,7 +162,8 @@ nrfx_err_t nrfx_ppib_channel_free(nrfx_ppib_interconnect_t const * p_instance, u
*
* @return SEND task associated with the specified channel.
*/
nrf_ppib_task_t nrfx_ppib_send_task_get(nrfx_ppib_t const * p_instance, uint8_t channel);
NRFX_STATIC_INLINE nrf_ppib_task_t nrfx_ppib_send_task_get(nrfx_ppib_t const * p_instance,
uint8_t channel);

/**
* @brief Function for getting the address of the PPIB SEND task for the specified channel.
Expand All @@ -172,7 +173,8 @@ nrf_ppib_task_t nrfx_ppib_send_task_get(nrfx_ppib_t const * p_instance, uint8_t
*
* @return Address of the specified SEND task.
*/
uint32_t nrfx_ppib_send_task_address_get(nrfx_ppib_t const * p_instance, uint8_t channel);
NRFX_STATIC_INLINE uint32_t nrfx_ppib_send_task_address_get(nrfx_ppib_t const * p_instance,
uint8_t channel);

/**
* @brief Function for getting the PPIB RECEIVE event for the specified channel.
Expand All @@ -185,7 +187,8 @@ uint32_t nrfx_ppib_send_task_address_get(nrfx_ppib_t const * p_instance, uint8_t
*
* @return RECEIVE event associated with the specified channel.
*/
nrf_ppib_event_t nrfx_ppib_receive_event_get(nrfx_ppib_t const * p_instance, uint8_t channel);
NRFX_STATIC_INLINE nrf_ppib_event_t nrfx_ppib_receive_event_get(nrfx_ppib_t const * p_instance,
uint8_t channel);

/**
* @brief Function for getting the address of a PPIB RECEIVE event.
Expand All @@ -195,7 +198,106 @@ nrf_ppib_event_t nrfx_ppib_receive_event_get(nrfx_ppib_t const * p_instance, uin
*
* @return Address of the specified RECEIVE event.
*/
uint32_t nrfx_ppib_receive_event_address_get(nrfx_ppib_t const * p_instance, uint8_t channel);
NRFX_STATIC_INLINE uint32_t nrfx_ppib_receive_event_address_get(nrfx_ppib_t const * p_instance,
uint8_t channel);

/**
* @brief Function for setting the subscribe configuration for a given
* PPIB task.
*
* @param[in] p_instance Pointer to the driver instance structure.
* @param[in] task Task for which to set the configuration.
* @param[in] channel Channel through which to subscribe events.
*/
NRF_STATIC_INLINE void nrfx_ppib_subscribe_set(nrfx_ppib_t const * p_instance,
nrf_ppib_task_t task,
uint8_t channel);

/**
* @brief Function for clearing the subscribe configuration for a given
* PPIB task.
*
* @param[in] p_instance Pointer to the driver instance structure.
* @param[in] task Task for which to clear the configuration.
*/
NRF_STATIC_INLINE void nrfx_ppib_subscribe_clear(nrfx_ppib_t const * p_instance,
nrf_ppib_task_t task);

/**
* @brief Function for setting the publish configuration for a given event.
*
* @param[in] p_instance Pointer to the driver instance structure.
* @param[in] event Event for which to set the configuration.
* @param[in] channel PPIB channel through which to publish the event.
*/
NRF_STATIC_INLINE void nrfx_ppib_publish_set(nrfx_ppib_t const * p_instance,
nrf_ppib_event_t event,
uint8_t channel);
/**
* @brief Function for clearing the publish configuration for a given event.
*
* @param[in] p_instance Pointer to the driver instance structure.
* @param[in] event Event for which to clear the configuration.
*/
NRF_STATIC_INLINE void nrfx_ppib_publish_clear(nrfx_ppib_t const * p_instance,
nrf_ppib_event_t event);
#ifndef NRFX_DECLARE_ONLY

NRFX_STATIC_INLINE nrf_ppib_task_t nrfx_ppib_send_task_get(nrfx_ppib_t const * p_instance,
uint8_t channel)
{
(void) p_instance;

return nrf_ppib_send_task_get(channel);
}

NRFX_STATIC_INLINE uint32_t nrfx_ppib_send_task_address_get(nrfx_ppib_t const * p_instance,
uint8_t channel)
{
return nrf_ppib_task_address_get(p_instance->p_reg, nrf_ppib_send_task_get(channel));
}

NRFX_STATIC_INLINE nrf_ppib_event_t nrfx_ppib_receive_event_get(nrfx_ppib_t const * p_instance,
uint8_t channel)
{
(void) p_instance;

return nrf_ppib_receive_event_get(channel);
}

NRFX_STATIC_INLINE uint32_t nrfx_ppib_receive_event_address_get(nrfx_ppib_t const * p_instance,
uint8_t channel)
{
return nrf_ppib_event_address_get(p_instance->p_reg, nrf_ppib_receive_event_get(channel));
}

NRF_STATIC_INLINE void nrfx_ppib_subscribe_set(nrfx_ppib_t const * p_instance,
nrf_ppib_task_t task,
uint8_t channel)
{
nrf_ppib_subscribe_set(p_instance->p_reg, task, channel);
}

NRF_STATIC_INLINE void nrfx_ppib_subscribe_clear(nrfx_ppib_t const * p_instance,
nrf_ppib_task_t task)
{
nrf_ppib_subscribe_clear(p_instance->p_reg, task);
}

NRF_STATIC_INLINE void nrfx_ppib_publish_set(nrfx_ppib_t const * p_instance,
nrf_ppib_event_t event,
uint8_t channel)
{
nrf_ppib_publish_set(p_instance->p_reg, event, channel);
}

NRF_STATIC_INLINE void nrfx_ppib_publish_clear(nrfx_ppib_t const * p_instance,
nrf_ppib_event_t event)
{
nrf_ppib_publish_clear(p_instance->p_reg, event);
}

#endif

/** @} */

Expand Down
18 changes: 6 additions & 12 deletions nrfx/drivers/src/nrfx_dppi.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
#define NRFX_LOG_MODULE DPPI
#include <nrfx_log.h>

/** @brief Set bit at given position. */
#define DPPI_BIT_SET(pos) (1uL << (pos))

#if defined(NRFX_DPPI_CHANNELS_USED)
#define NRFX_DPPI0_CHANNELS_USED NRFX_DPPI_CHANNELS_USED
#endif
Expand All @@ -53,7 +50,6 @@
#define NRFX_DPPI0_GROUPS_USED NRFX_DPPI_GROUPS_USED
#endif

#if !defined(__NRFX_DOXYGEN__)
#if defined(NRF_DPPIC0)

#if !defined(NRFX_DPPI0_CHANNELS_USED)
Expand Down Expand Up @@ -292,8 +288,6 @@

#endif

#endif // !defined(__NRFX_DOXYGEN__)

#define DPPI_CHANNELS_NUM(idx) NRFX_BIT_MASK(NRFX_CONCAT(DPPIC, idx, _CH_NUM)
#define DPPI_CHANNELS_USED(idx) NRFX_CONCAT(NRFX_DPPI, idx, _CHANNELS_USED)
#define DPPI_AVAILABLE_CHANNELS_MASK(idx) \
Expand Down Expand Up @@ -342,10 +336,10 @@ static void dppi_free(nrfx_dppi_t const * p_instance)
while (mask)
{
nrf_dppi_channel_group_t group = (nrf_dppi_channel_group_t)group_idx;
if (mask & DPPI_BIT_SET(group))
if (mask & NRFX_BIT(group))
{
nrfy_dppi_group_clear(p_instance->p_reg, group);
mask &= ~DPPI_BIT_SET(group);
mask &= ~NRFX_BIT(group);
}
group_idx++;
}
Expand Down Expand Up @@ -384,7 +378,7 @@ static nrfx_err_t dppi_channel_enable(nrfx_dppi_t const * p_instance, uint8_t ch
}
else
{
nrfy_dppi_channels_enable(p_instance->p_reg, DPPI_BIT_SET(channel));
nrfy_dppi_channels_enable(p_instance->p_reg, NRFX_BIT(channel));
}
NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
return err_code;
Expand All @@ -402,7 +396,7 @@ static nrfx_err_t dppi_channel_disable(nrfx_dppi_t const * p_instance, uint8_t c
}
else
{
nrfy_dppi_channels_disable(p_instance->p_reg, DPPI_BIT_SET(channel));
nrfy_dppi_channels_disable(p_instance->p_reg, NRFX_BIT(channel));
err_code = NRFX_SUCCESS;
}
NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
Expand Down Expand Up @@ -440,7 +434,7 @@ static nrfx_err_t dppi_channel_include_in_group(nrfx_dppi_t const * p_insta
else
{
NRFY_CRITICAL_SECTION_ENTER();
nrfy_dppi_channels_include_in_group(p_instance->p_reg, DPPI_BIT_SET(channel), group);
nrfy_dppi_channels_include_in_group(p_instance->p_reg, NRFX_BIT(channel), group);
NRFY_CRITICAL_SECTION_EXIT();
}
NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
Expand All @@ -462,7 +456,7 @@ static nrfx_err_t dppi_channel_remove_from_group(nrfx_dppi_t const * p_inst
else
{
NRFY_CRITICAL_SECTION_ENTER();
nrfy_dppi_channels_remove_from_group(p_instance->p_reg, DPPI_BIT_SET(channel), group);
nrfy_dppi_channels_remove_from_group(p_instance->p_reg, NRFX_BIT(channel), group);
NRFY_CRITICAL_SECTION_EXIT();
}
NRFX_LOG_INFO("Function: %s, error code: %s.", __func__, NRFX_LOG_ERROR_STRING_GET(err_code));
Expand Down
32 changes: 6 additions & 26 deletions nrfx/drivers/src/nrfx_ppib.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

#include <nrfx.h>

// Driver for single instance PPIB
#if NRFX_CHECK(NRFX_PPIB_ENABLED)

#include <nrfx_ppib.h>
Expand Down Expand Up @@ -122,7 +121,7 @@
#define PPIB_AVAILABLE_CHANNELS_MASK(left, right) \
((uint32_t)(PPIB_CHANNELS_MASK(left, right)) & ~(PPIB_CHANNELS_USED(left, right))))

/* Structure holding state of the pins */
/* Structure holding state of the PPIB instance. */
typedef struct
{
/**< Bitmap representing channels availability. */
Expand Down Expand Up @@ -196,6 +195,11 @@ nrfx_err_t nrfx_ppib_channel_free(nrfx_ppib_interconnect_t const * p_instance, u
{
ppib_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];

if ((p_cb->available_channels & NRFX_BIT(channel)) == 0)
{
return NRFX_ERROR_INVALID_PARAM;
}

nrf_ppib_subscribe_clear(p_instance->left.p_reg, nrf_ppib_send_task_get(channel));
nrf_ppib_subscribe_clear(p_instance->right.p_reg, nrf_ppib_send_task_get(channel));
nrf_ppib_publish_clear(p_instance->left.p_reg, nrf_ppib_receive_event_get(channel));
Expand All @@ -204,28 +208,4 @@ nrfx_err_t nrfx_ppib_channel_free(nrfx_ppib_interconnect_t const * p_instance, u
return nrfx_flag32_free(&p_cb->allocated_channels, channel);
}

nrf_ppib_task_t nrfx_ppib_send_task_get(nrfx_ppib_t const * p_instance, uint8_t channel)
{
(void) p_instance;

return nrf_ppib_send_task_get(channel);
}

uint32_t nrfx_ppib_send_task_address_get(nrfx_ppib_t const * p_instance, uint8_t channel)
{
return nrf_ppib_task_address_get(p_instance->p_reg, nrf_ppib_send_task_get(channel));
}

nrf_ppib_event_t nrfx_ppib_receive_event_get(nrfx_ppib_t const * p_instance, uint8_t channel)
{
(void) p_instance;

return nrf_ppib_receive_event_get(channel);
}

uint32_t nrfx_ppib_receive_event_address_get(nrfx_ppib_t const * p_instance, uint8_t channel)
{
return nrf_ppib_event_address_get(p_instance->p_reg, nrf_ppib_receive_event_get(channel));
}

#endif // defined(PPIB_PRESENT)
8 changes: 4 additions & 4 deletions nrfx/helpers/nrfx_gppi.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,17 +433,16 @@ nrfx_err_t nrfx_gppi_group_free(nrfx_gppi_channel_group_t group);

#if defined DPPI_PRESENT


/**
* @brief Function for creating a connection between two edge DPPIs.
*
* This function takes a pair of edge DPPIs and creates an interconnect
* between them using a provided GPPI channel. The GPPI channel must be
* allocated with @ref nrfx_gppi_group_alloc.
* allocated with @ref nrfx_gppi_channel_alloc.
* The configuration of the edge DPPIs is not affected by this function
* or when the GPPI channel is freed with @ref nrfx_gppi_group_free.
* or when the GPPI channel is freed with @ref nrfx_gppi_channel_free.
*
* @param[in] group GPPI channel used to make the connection.
* @param[in] channel GPPI channel used to make the connection.
* @param[in] p_src_dppi Instance of the source DPPI.
* @param[in] src_channel Source DPPI channel.
* @param[in] p_dst_dppi Instance of the destination DPPI.
Expand All @@ -453,6 +452,7 @@ nrfx_err_t nrfx_gppi_group_free(nrfx_gppi_channel_group_t group);
* @retval NRFX_ERROR_INVALID_PARAM The specified channel is not allocated or
* is not user-configurable.
* @retval NRFX_ERROR_NOT_SUPPORTED Driver is not enabled.
* @retval NRFX_ERROR_NO_MEM Necessary DPPI resources could not be acquired.
*/
nrfx_err_t nrfx_gppi_edge_connection_setup(uint8_t channel,
nrfx_dppi_t const * p_src_dppi,
Expand Down
10 changes: 5 additions & 5 deletions nrfx/helpers/nrfx_gppi_dppi.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,11 @@ nrfx_err_t nrfx_gppi_group_free(nrfx_gppi_channel_group_t group)
#endif
}

nrfx_err_t nrfx_gppi_channel_destination_setup(uint8_t channel,
nrfx_dppi_t const * p_src_dppi,
uint8_t src_channel,
nrfx_dppi_t const * p_dst_dppi,
uint8_t dst_channel)
nrfx_err_t nrfx_gppi_edge_connection_setup(uint8_t channel,
nrfx_dppi_t const * p_src_dppi,
uint8_t src_channel,
nrfx_dppi_t const * p_dst_dppi,
uint8_t dst_channel)
{
(void)channel;
(void)p_src_dppi;
Expand Down
Loading

0 comments on commit 3f74287

Please sign in to comment.