drivers/periph/spi: add periph_spi_reconfigure feature
This commit is contained in:
parent
27da7c2797
commit
896fcd43b0
@ -203,7 +203,6 @@ void spi_init(spi_t bus);
|
|||||||
/**
|
/**
|
||||||
* @brief Initialize the used SPI bus pins, i.e. MISO, MOSI, and CLK
|
* @brief Initialize the used SPI bus pins, i.e. MISO, MOSI, and CLK
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* After calling spi_init, the pins must be initialized (i.e. spi_init is
|
* After calling spi_init, the pins must be initialized (i.e. spi_init is
|
||||||
* calling this function internally). In normal cases, this function will not be
|
* calling this function internally). In normal cases, this function will not be
|
||||||
* used. But there are some devices (e.g. CC110x), that use SPI bus lines also
|
* used. But there are some devices (e.g. CC110x), that use SPI bus lines also
|
||||||
@ -211,6 +210,9 @@ void spi_init(spi_t bus);
|
|||||||
* more of the used pins. So they can take control over certain pins and return
|
* more of the used pins. So they can take control over certain pins and return
|
||||||
* control back to the SPI driver using this function.
|
* control back to the SPI driver using this function.
|
||||||
*
|
*
|
||||||
|
* This function must be called after @ref spi_deinit_pins to return the pins to
|
||||||
|
* SPI operation.
|
||||||
|
*
|
||||||
* The pins used are configured in the board's periph_conf.h.
|
* The pins used are configured in the board's periph_conf.h.
|
||||||
*
|
*
|
||||||
* @param[in] bus SPI device the pins are configure for
|
* @param[in] bus SPI device the pins are configure for
|
||||||
@ -238,6 +240,71 @@ void spi_init_pins(spi_t bus);
|
|||||||
*/
|
*/
|
||||||
int spi_init_cs(spi_t bus, spi_cs_t cs);
|
int spi_init_cs(spi_t bus, spi_cs_t cs);
|
||||||
|
|
||||||
|
#if defined(MODULE_PERIPH_SPI_RECONFIGURE) || DOXYGEN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Change the pins of the given SPI bus back to plain GPIO functionality
|
||||||
|
*
|
||||||
|
* The pin mux of the MISO, MOSI and CLK pins of the bus will be changed back to
|
||||||
|
* default (GPIO) mode and the SPI bus is powered off.
|
||||||
|
* This allows to use the SPI pins for another function and return to SPI
|
||||||
|
* functionality again by calling spi_init_pins()
|
||||||
|
*
|
||||||
|
* If you want the pin to be in a defined state, call gpio_init() on it.
|
||||||
|
*
|
||||||
|
* The bus MUST not be acquired before initializing it, as this is handled
|
||||||
|
* internally by the spi_deinit_pins() function!
|
||||||
|
*
|
||||||
|
* Calls to spi_acquire() will block until spi_init_pins() is called again.
|
||||||
|
*
|
||||||
|
* @note Until this is implemented on all platforms, this requires the
|
||||||
|
* periph_spi_reconfigure feature to be used.
|
||||||
|
*
|
||||||
|
* @param[in] dev the device to de-initialize
|
||||||
|
*/
|
||||||
|
void spi_deinit_pins(spi_t dev);
|
||||||
|
|
||||||
|
#if DOXYGEN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the MISO pin of the given SPI bus.
|
||||||
|
*
|
||||||
|
* @param[in] dev The device to query
|
||||||
|
*
|
||||||
|
* @note Until this is implemented on all platforms, this requires the
|
||||||
|
* periph_spi_reconfigure feature to be used.
|
||||||
|
*
|
||||||
|
* @return The GPIO used for the SPI MISO line.
|
||||||
|
*/
|
||||||
|
gpio_t spi_pin_miso(spi_t dev);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the MOSI pin of the given SPI bus.
|
||||||
|
*
|
||||||
|
* @param[in] dev The device to query
|
||||||
|
*
|
||||||
|
* @note Until this is implemented on all platforms, this requires the
|
||||||
|
* periph_spi_reconfigure feature to be used.
|
||||||
|
*
|
||||||
|
* @return The GPIO used for the SPI MOSI line.
|
||||||
|
*/
|
||||||
|
gpio_t spi_pin_mosi(spi_t dev);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the CLK pin of the given SPI bus.
|
||||||
|
*
|
||||||
|
* @param[in] dev The device to query
|
||||||
|
*
|
||||||
|
* @note Until this is implemented on all platforms, this requires the
|
||||||
|
* periph_spi_reconfigure feature to be used.
|
||||||
|
*
|
||||||
|
* @return The GPIO used for the SPI CLK line.
|
||||||
|
*/
|
||||||
|
gpio_t spi_pin_clk(spi_t dev);
|
||||||
|
|
||||||
|
#endif /* DOXYGEN */
|
||||||
|
#endif /* MODULE_PERIPH_SPI_RECONFIGURE */
|
||||||
|
|
||||||
#if defined(MODULE_PERIPH_SPI_GPIO_MODE) || DOXYGEN
|
#if defined(MODULE_PERIPH_SPI_GPIO_MODE) || DOXYGEN
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -195,6 +195,11 @@ config HAS_PERIPH_SPI
|
|||||||
help
|
help
|
||||||
Indicates that an SPI peripheral is present.
|
Indicates that an SPI peripheral is present.
|
||||||
|
|
||||||
|
config HAS_PERIPH_SPI_RECONFIGURE
|
||||||
|
bool
|
||||||
|
help
|
||||||
|
Indicates that the SPI peripheral allows pin reconfiguration.
|
||||||
|
|
||||||
config HAS_PERIPH_SPI_GPIO_MODE
|
config HAS_PERIPH_SPI_GPIO_MODE
|
||||||
bool
|
bool
|
||||||
help
|
help
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user