MSPM0_ValvanoWare  1.0
ECE445L starter code
Files | Macros | Functions
SPI

Synchronous serial communication. More...

Files

file  MCP4921.h
 Synchronous serial communication.
 
file  SPI.h
 Synchronous serial communication.
 

Macros

#define MCP4921_OutNonBlocking(code)   SPI0->TXDATA = code|(1<<12);
 Output data, nonblocking Send data to MCP4921 12-bit DAC without waiting for a response. This is useful in audio applications where DAC outputs are relatively infrequent and where the DAC response is meaningless. Since the state of the FIFO is not checked before sending, data may be lost. More...
 
#define ECE445L_Lab6   0
 
#define SPI1_SCLKINDEX   (PB9INDEX)
 
#define SPI1_PICOINDEX   (PB8INDEX)
 
#define SPI1_POCIINDEX   (PB7INDEX)
 
#define SDC_CS   GPIOA
 
#define SDC_CS_PIN   (1<<12)
 
#define SDC_CS_INDEX   (PA12INDEX)
 
#define SDC_CS_LOW()   (SDC_CS->DOUTCLR31_0 = SDC_CS_PIN)
 
#define SDC_CS_HIGH()   (SDC_CS->DOUTSET31_0 = SDC_CS_PIN)
 
#define TFT_CS   GPIOB
 
#define TFT_CS_PIN   (1<<6)
 
#define TFT_CS_INDEX   (PB6INDEX)
 
#define TFT_CS_LOW()   (TFT_CS->DOUTCLR31_0 = TFT_CS_PIN)
 
#define TFT_CS_HIGH()   (TFT_CS->DOUTSET31_0 = TFT_CS_PIN)
 
#define TFT_DC   GPIOA
 
#define TFT_DC_PIN   (1<<13)
 
#define TFT_DC_INDEX   (PA13INDEX)
 
#define TFT_DC_LOW()   (TFT_DC->DOUTCLR31_0 = TFT_DC_PIN)
 
#define TFT_DC_HIGH()   (TFT_DC->DOUTSET31_0 = TFT_DC_PIN)
 
#define TFT_RST   GPIOB
 
#define TFT_RST_PIN   (1<<15)
 
#define TFT_RST_INDEX   (PB15INDEX)
 
#define TFT_RST_LOW()   (TFT_RST->DOUTCLR31_0 = TFT_RST_PIN)
 
#define TFT_RST_HIGH()   (TFT_RST->DOUTSET31_0 = TFT_RST_PIN)
 

Functions

void MCP4921_Init (uint32_t data)
 initialize MCP4921 More...
 
void MCP4921_Out (uint32_t data)
 Output data. More...
 
void SPI_OutData (char data)
 Output data. More...
 
void SPI_OutCommand (char command)
 Output command. More...
 
void SPI1_Reset (void)
 Reset LCD. More...
 
void CS_Init (void)
 
void SPI1_Init (void)
 initialize SPI1 More...
 
void TFT_OutCommand (char command)
 
void TFT_OutData (char data)
 Output data. More...
 

Detailed Description

Synchronous serial communication.

SPI-DAC pins
Pin Function Description
PB18 SPI0 SCLK DAC SPI clock (SPI)
PA8 SPI0 CS DAC SPI CS
PB17 SPI0 PICO DAC SPI data (SPI)
SPI-LCD pins
Pin Function Description
PB9 SPI1 SCLK LCD SPI clock (SPI)
PB6 GPIO CS LCD SPI CS
PA12GPIO CS SDC SPI CS
PB8 SPI1 PICO LCD SPI data (SPI)
PB7 SPI1 POCI SCD SPI data (SPI)
PB15GPIO LCD !RST =1 for run, =0 for reset
PA13GPIO LCD D/C RS =1 for data, =0 for command

Macro Definition Documentation

◆ MCP4921_OutNonBlocking

#define MCP4921_OutNonBlocking (   code)    SPI0->TXDATA = code|(1<<12);

Output data, nonblocking Send data to MCP4921 12-bit DAC without waiting for a response. This is useful in audio applications where DAC outputs are relatively infrequent and where the DAC response is meaningless. Since the state of the FIFO is not checked before sending, data may be lost.

Output 16-bit data to SPI port, nonblocking.

Parameters
codeis an 16-bit data to be transferred
Returns
none

Function Documentation

◆ MCP4921_Init()

void MCP4921_Init ( uint32_t  data)

initialize MCP4921

Initialize MCP4921 using SPI0 for 8 MHz baud clock 16-bit data using busy-wait synchronization. Calls Clock_Freq to get bus clock

  • PA8 SPI0_CS0
  • PB18 SPI0_SCK
  • PB17 SPI0_PICO
    Note
    SPI0,SPI1 in power domain PD1 SysClk equals bus CPU clock
    Parameters
    datainitial value to DAC
    Returns
    none

◆ MCP4921_Out()

void MCP4921_Out ( uint32_t  data)

Output data.

Output 16-bit data to MCP4921 using SPI0.

Parameters
datais an 16-bit data to be transferred
Returns
none

◆ SPI1_Init()

void SPI1_Init ( void  )

initialize SPI1

Initialize SPI1 for 8 MHz baud clock for both SDC and TFT using busy-wait synchronization. Calls Clock_Freq to get bus clock

  • PB9 SPI1 SCLK
  • PB6 SPI1 CS0
  • PB8 SPI1 PICO
  • PB15 GPIO !RST =1 for run, =0 for reset
  • PA13 GPIO RS =1 for data, =0 for command
Note
SPI0,SPI1 in power domain PD1 SysClk equals bus CPU clock
Parameters
none
Returns
none

◆ SPI1_Reset()

void SPI1_Reset ( void  )

Reset LCD.

Reset LCD

  1. drive RST high for 500ms
  2. drive RST low for 500ms
  3. drive RST high for 500ms
Parameters
none
Returns
none

◆ SPI_OutCommand()

void SPI_OutCommand ( char  command)

Output command.

Output 8-bit command to SPI port. RS=PA13=0 for command

Parameters
commandis an 8-bit command to be transferred
Returns
none

◆ SPI_OutData()

void SPI_OutData ( char  data)

Output data.

Output 8-bit data to SPI port. RS=PA13=1 for data.

Parameters
datais an 8-bit data to be transferred
Returns
none

◆ TFT_OutData()

void TFT_OutData ( char  data)

Output data.

Output 8-bit data to SPI port. RS=PB16=1 for data.

Parameters
datais an 8-bit data to be transferred
Returns
none