/* Configures SPI mode parameters for clock edge and clock polarity. spi_no - SPI (0) or HSPI (1) spi_cpha - (0) Data is valid on clock leading edge (1) Data is valid on clock trailing edge spi_cpol - (0) Clock is low when inactive (1) Clock is high when inactive For MicroPython this version is different from original.  */
void spi_mode(uint8_t spi_no, uint8_t spi_cpha, uint8_t spi_cpol)
/* Configures SPI mode parameters for clock edge and clock polarity. spi_no - SPI (0) or HSPI (1) spi_cpha - (0) Data is valid on clock leading edge (1) Data is valid on clock trailing edge spi_cpol - (0) Clock is low when inactive (1) Clock is high when inactive For MicroPython this version is different from original.  */
void spi_mode(uint8_t spi_no, uint8_t spi_cpha, uint8_t spi_cpol)
{
        SET_PERI_REG_MASK(SPI_PIN(HSPI), SPI_IDLE_EDGE);
    } else {
        CLEAR_PERI_REG_MASK(SPI_PIN(HSPI), SPI_IDLE_EDGE);
    }
    if (spi_cpha == spi_cpol) {
        CLEAR_PERI_REG_MASK(SPI_USER(HSPI), SPI_CK_OUT_EDGE);
        SET_PERI_REG_MASK(SPI_USER(HSPI), SPI_CK_I_EDGE);
    } else {
        SET_PERI_REG_MASK(SPI_USER(HSPI), SPI_CK_OUT_EDGE);
        CLEAR_PERI_REG_MASK(SPI_USER(HSPI), SPI_CK_I_EDGE);
    }
}