mirror of https://github.com/ARMmbed/mbed-os.git
SPISlave: Add explicit pinmap support
parent
beec0f1e84
commit
3a38c6bae0
|
@ -71,6 +71,14 @@ public:
|
||||||
*/
|
*/
|
||||||
SPISlave(PinName mosi, PinName miso, PinName sclk, PinName ssel);
|
SPISlave(PinName mosi, PinName miso, PinName sclk, PinName ssel);
|
||||||
|
|
||||||
|
/** Create a SPI slave connected to the specified pins.
|
||||||
|
*
|
||||||
|
* @note Either mosi or miso can be specified as NC if not used.
|
||||||
|
*
|
||||||
|
* @param explicit_pinmap reference to strucure which holds static pinmap.
|
||||||
|
*/
|
||||||
|
SPISlave(const spi_pinmap_t &pinmap);
|
||||||
|
|
||||||
/** Configure the data transmission format.
|
/** Configure the data transmission format.
|
||||||
*
|
*
|
||||||
* @param bits Number of bits per SPI frame (4 - 16).
|
* @param bits Number of bits per SPI frame (4 - 16).
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include "drivers/SPISlave.h"
|
#include "drivers/SPISlave.h"
|
||||||
|
#include "mbed_assert.h"
|
||||||
|
|
||||||
#if DEVICE_SPISLAVE
|
#if DEVICE_SPISLAVE
|
||||||
|
|
||||||
|
@ -31,6 +32,17 @@ SPISlave::SPISlave(PinName mosi, PinName miso, PinName sclk, PinName ssel) :
|
||||||
spi_frequency(&_spi, _hz);
|
spi_frequency(&_spi, _hz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SPISlave::SPISlave(const spi_pinmap_t &pinmap) :
|
||||||
|
_spi(),
|
||||||
|
_bits(8),
|
||||||
|
_mode(0),
|
||||||
|
_hz(1000000)
|
||||||
|
{
|
||||||
|
spi_init_direct(&_spi, &pinmap);
|
||||||
|
spi_format(&_spi, _bits, _mode, 1);
|
||||||
|
spi_frequency(&_spi, _hz);
|
||||||
|
}
|
||||||
|
|
||||||
void SPISlave::format(int bits, int mode)
|
void SPISlave::format(int bits, int mode)
|
||||||
{
|
{
|
||||||
_bits = bits;
|
_bits = bits;
|
||||||
|
|
Loading…
Reference in New Issue