iomux_set_function: remove the IOMUX_FUNC transform of the func argument.
The allows the IOMUX_GPIO<n>_FUNC_<function> definitions to be used here.
This commit is contained in:
parent
3dcc4f14a9
commit
8405b989f9
3 changed files with 10 additions and 9 deletions
|
@ -23,8 +23,8 @@
|
|||
#define _SPI1_SCK_GPIO 14
|
||||
#define _SPI1_CS0_GPIO 15
|
||||
|
||||
#define _SPI0_FUNC 1
|
||||
#define _SPI1_FUNC 2
|
||||
#define _SPI0_FUNC IOMUX_FUNC(1)
|
||||
#define _SPI1_FUNC IOMUX_FUNC(2)
|
||||
|
||||
#define _SPI_BUF_SIZE 64
|
||||
|
||||
|
|
|
@ -43,10 +43,16 @@ inline static esp_reg_t gpio_iomux_reg(const uint8_t gpio_number)
|
|||
return &(IOMUX.PIN[gpio_to_iomux(gpio_number)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the I/O Mux function. The iomux_num is an IOMUX register number, see
|
||||
* gpio_to_iomux to obtain the IOMUX register number of a GPIO number.
|
||||
* The 'func' is an IOMUX_GPIO<n>_FUNC_<function> value, see iomux_regs.h
|
||||
*
|
||||
*/
|
||||
inline static void iomux_set_function(uint8_t iomux_num, uint32_t func)
|
||||
{
|
||||
uint32_t prev = IOMUX.PIN[iomux_num] & ~IOMUX_PIN_FUNC_MASK;
|
||||
IOMUX.PIN[iomux_num] = IOMUX_FUNC(func) | prev;
|
||||
IOMUX.PIN[iomux_num] = func | prev;
|
||||
}
|
||||
|
||||
inline static void iomux_set_direction_flags(uint8_t iomux_num, uint32_t dir_flags)
|
||||
|
@ -75,7 +81,7 @@ 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;
|
||||
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…
Reference in a new issue