MCPcopy Create free account
hub / github.com/Santroller/Santroller / SPIMasterInterface

Method SPIMasterInterface

lib/peripherals/spi.cpp:8–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include "utils.h"
7#include <stdio.h>
8SPIMasterInterface::SPIMasterInterface(uint8_t block, spi_cpha_t cpha, spi_cpol_t cpol, int8_t sck, int8_t mosi, int8_t miso, bool msbfirst, uint32_t clock): m_msbfirst(msbfirst)
9{
10 spi = _hardwareBlocks[block];
11 printf("spi: %d %d %d %d %d\r\n", sck, mosi, miso, block, clock);
12 spi_init(spi, clock);
13 spi_set_format(spi, 8, cpol, cpha, SPI_MSB_FIRST);
14 if (sck != -1) {
15 gpio_set_function(sck, GPIO_FUNC_SPI);
16 }
17 if (mosi != -1)
18 {
19 gpio_set_function(mosi, GPIO_FUNC_SPI);
20 }
21 if (miso != -1)
22 {
23 gpio_set_function(miso, GPIO_FUNC_SPI);
24 gpio_set_pulls(miso, true, false);
25 }
26 m_valid = sck != -1 || mosi != -1 || miso != -1;
27}
28uint8_t SPIMasterInterface::transfer(uint8_t data)
29{
30 if (!m_valid) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected