feat(pcnt): replace periph_module func with new ll func

This commit is contained in:
Planck (Lu Zeyu)
2023-09-12 12:28:56 +08:00
parent 5738ba18e9
commit 59f8008e22
8 changed files with 199 additions and 5 deletions

View File

@@ -21,6 +21,8 @@
#include "soc/pcnt_struct.h"
#include "hal/pcnt_types.h"
#include "hal/misc.h"
#include "soc/dport_access.h"
#include "soc/dport_reg.h"
#ifdef __cplusplus
extern "C" {
@@ -437,6 +439,39 @@ static inline volatile void *pcnt_ll_get_intr_status_reg(pcnt_dev_t *hw)
return &hw->int_st.val;
}
/**
* @brief Enable or disable the bus clock for the PCNT module
*
* @param set_bit True to set bit, false to clear bit
*/
static inline void pcnt_ll_enable_bus_clock(int group_id, bool enable)
{
(void)group_id;
if (enable) {
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_PCNT_CLK_EN);
} else {
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_PCNT_CLK_EN);
}
}
/// use a macro to wrap the function, force the caller to use it in a critical section
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
#define pcnt_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; pcnt_ll_enable_bus_clock(__VA_ARGS__)
/**
* @brief Reset the PCNT module
*/
static inline void pcnt_ll_reset_register(int group_id)
{
(void)group_id;
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_PCNT_RST);
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_PCNT_RST);
}
/// use a macro to wrap the function, force the caller to use it in a critical section
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
#define pcnt_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; pcnt_ll_reset_register(__VA_ARGS__)
#ifdef __cplusplus
}
#endif