Add DREQ methods for PWM/SPI/UART/I2C (#603)

This commit is contained in:
Graham Sanderson
2021-10-12 16:04:16 -05:00
committed by GitHub
parent 2f2e62968d
commit f808b5f2dc
5 changed files with 62 additions and 2 deletions

View File

@ -9,6 +9,7 @@
#include "pico.h"
#include "hardware/structs/pwm.h"
#include "hardware/regs/dreq.h"
#ifdef __cplusplus
extern "C" {
@ -539,6 +540,18 @@ static inline void pwm_force_irq(uint slice_num) {
pwm_hw->intf = 1u << slice_num;
}
/*! \brief Return the DREQ to use for pacing transfers to a particular PWM slice
* \ingroup hardware_pwm
*
* \param slice_num PWM slice number
*/
static inline uint pwm_get_dreq(uint slice_num) {
static_assert(DREQ_PWM_WRAP1 == DREQ_PWM_WRAP0 + 1, "");
static_assert(DREQ_PWM_WRAP7 == DREQ_PWM_WRAP0 + 7, "");
check_slice_num_param(slice_num);
return DREQ_PWM_WRAP0 + slice_num;
}
#ifdef __cplusplus
}
#endif