36#include "inc/hw_memmap.h"
37#include "driverlib/sysctl.h"
38#include "driverlib/rom.h"
39#include "driverlib/rom_map.h"
40#include "driverlib/interrupt.h"
46 ChipSelectMethod cs_assert, ChipSelectMethod cs_deassert,
49 uint32_t dma_channel_index_tx,
50 uint32_t dma_channel_index_rx)
51 :
SPI(name, cs_assert, cs_deassert, bus_lock)
53 , interrupt_(interrupt)
54 , dmaThreshold_(dma_threshold)
55 , dmaChannelIndexTx_(dma_channel_index_tx)
56 , dmaChannelIndexRx_(dma_channel_index_rx)
61 p = SYSCTL_PERIPH_SSI0;
65 p = SYSCTL_PERIPH_SSI1;
69 p = SYSCTL_PERIPH_SSI2;
73 p = SYSCTL_PERIPH_SSI3;
77 DIE(
"Unknown SPI peripheral.");
79 MAP_SysCtlPeripheralEnable(p);
80 MAP_SysCtlPeripheralReset(p);
102 unsigned long new_mode;
108 new_mode = SSI_FRF_MOTO_MODE_0;
111 new_mode = SSI_FRF_MOTO_MODE_1;
114 new_mode = SSI_FRF_MOTO_MODE_2;
117 new_mode = SSI_FRF_MOTO_MODE_3;
123 uint32_t clock = cm3_cpu_clock_hz;
132 else if ((clock %
speedHz) != 0)
137 MAP_SSIDisable(
base_);
138 MAP_SSIConfigSetExpClk(
base_, clock, new_mode, SSI_MODE_MASTER,
140 MAP_IntPrioritySet(
interrupt_, configKERNEL_INTERRUPT_PRIORITY);
142 MAP_SSIEnable(
base_);
156__attribute__((optimize(
"-O3")))
157void
TivaSPI::config_dma(struct spi_ioc_transfer *msg)
159 DIE(
"DMA transfer is not yet implemented.");
162__attribute__((optimize(
"-O3")))
165 DIE(
"SPI interrupt is not yet implemented.");
OSSem sem[1]
One semaphore required per instance pointer.
OSSem sem[4]
One semaphore per peripheral.
mode_t mode_
File open mode, such as O_NONBLOCK.
This class provides a mutex API.
This class provides a counting semaphore API.
Private data for an SPI device.
uint32_t speedHz
Max default speed in Hz.
uint8_t bitsPerWord
number of bits per word transaction
OSSem * sem_
reference to the semaphore belonging to this bus
void disable() override
Function to disable device.
TivaSPI(const char *name, unsigned long base, uint32_t interrupt, ChipSelectMethod cs_assert, ChipSelectMethod cs_deassert, OSMutex *bus_lock=nullptr, size_t dma_threshold=DEFAULT_DMA_THRESHOLD_BYTES, uint32_t dma_channel_index_tx=UDMA_CH11_SSI0TX, uint32_t dma_channel_index_rx=UDMA_CH10_SSI0RX)
Constructor.
uint16_t spiCr1_
Configuration register 1 local copy.
unsigned long base_
base address of this device
uint16_t spiPrescaler_
Prescale register local copy.
int update_configuration() override
Update the configuration of the bus.
void enable() override
Function to enable device.
unsigned long interrupt_
interrupt of this device
uint16_t spiCr0_
Configuration register 0 local copy.
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
#define DIE(MSG)
Unconditionally terminates the current process with a message.