Merge branch 'iomux-set-func' of https://github.com/ourairquality/esp-open-rtos into ourairquality-iomux-set-func
Conflicts: core/include/esp/iomux.h
This commit is contained in:
commit
0875e5d55b
4 changed files with 24 additions and 24 deletions
|
@ -143,6 +143,16 @@ static inline gpio_inttype_t gpio_get_interrupt(const uint8_t gpio_num)
|
|||
return (gpio_inttype_t)FIELD2VAL(GPIO_CONF_INTTYPE, GPIO.CONF[gpio_num]);
|
||||
}
|
||||
|
||||
/* Set GPIO I/O Mux function.
|
||||
* The 'func' is an IOMUX_GPIO<n>_FUNC_<function> value, see iomux_regs.h
|
||||
*/
|
||||
inline static void gpio_set_iomux_function(const uint8_t gpio_num, uint32_t func)
|
||||
{
|
||||
uint8_t iomux_num = gpio_to_iomux(gpio_num);
|
||||
uint32_t prev = IOMUX.PIN[iomux_num] & ~IOMUX_PIN_FUNC_MASK;
|
||||
IOMUX.PIN[iomux_num] = func | prev;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -82,8 +82,8 @@ inline static void iomux_set_pullup_flags(uint8_t iomux_num, uint32_t pullup_fla
|
|||
inline static void iomux_set_gpio_function(uint8_t gpio_number, bool output_enable)
|
||||
{
|
||||
const uint8_t iomux_num = gpio_to_iomux(gpio_number);
|
||||
const uint32_t func = iomux_num > 11 ? 0 : 3;
|
||||
iomux_set_function(iomux_num, IOMUX_FUNC(func));
|
||||
const uint32_t func = iomux_num > 11 ? IOMUX_FUNC(0) : IOMUX_FUNC(3);
|
||||
iomux_set_function(iomux_num, func);
|
||||
iomux_set_direction_flags(iomux_num, output_enable ? IOMUX_PIN_OUTPUT_ENABLE : 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,11 +47,6 @@ _Static_assert(sizeof(struct IOMUX_REGS) == 0x44, "IOMUX_REGS is the wrong size"
|
|||
/* WARNING: Macro evaluates argument twice */
|
||||
#define IOMUX_FUNC(val) (VAL2FIELD_M(IOMUX_PIN_FUNC_LOW, val) | VAL2FIELD_M(IOMUX_PIN_FUNC_HIGH, val))
|
||||
|
||||
/* WARNING: Macro evaluates argument twice */
|
||||
#define IOMUX_FUNC_VALUE(regbits) (FIELD2VAL(IOMUX_PIN_FUNC_LOW, regbits) | FIELD2VAL(IOMUX_PIN_FUNC_HIGH, regbits))
|
||||
|
||||
#define IOMUX_SET_FUNC(regbits, funcval) (((regbits) & ~IOMUX_PIN_FUNC_MASK) | (funcval))
|
||||
|
||||
#define IOMUX_GPIO0 IOMUX.PIN[12]
|
||||
#define IOMUX_GPIO1 IOMUX.PIN[5]
|
||||
#define IOMUX_GPIO2 IOMUX.PIN[13]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue