Skip to content
Ryan Summers edited this page Sep 7, 2015 · 2 revisions

SPI Structures

This page outlines the structures implemented within the SPI peripheral library within SUBLIBinal. Please select the appropriate structure from the list below to be redirected to appropriate documentation.

Structures


SPI_Data

Definition

    typedef struct SPI_DATA {
        Queue Rx_queue;
        Queue Tx_queue;
        boolean is_idle;
    } SPI_Data;

Description
The SPI Data structure is an internal structure for use by the SUBLIBinal library. A pointer to this structure is returned by the initialization function. This structure should not be modified by the user of the library and is intended to be used to query the status of the SPI module. The library will function normally if a pointer to the SPI function is not maintained in the main program.

Parameters

  • Rx_queue: The Rx_queue is an internal buffer used for received SPI communications.
  • Tx_queue: The Tx_queue is an internal buffer used for transmission along the SPI communication line.
  • is_idle: this parameter species whether or not the SPI module is currently idle.

top


SPI_Config

Definition

    typedef struct SPI_CONFIG {
        uint speed;
        uint pb_clk;
        SPI_Channel which_spi; 
        uint8 clk_edge; 
        uint8 *tx_buffer_ptr; 
        uint tx_buffer_size; 
        void (*tx_callback); 
        boolean tx_en; 
        uint8 *rx_buffer_ptr; 
        uint rx_buffer_size; 
        void (*rx_callback); 
        boolean rx_en; 
    }SPI_Config;

Description
The SPI configuration structure is used for initializing the SPI module. Not all sections of the structure must be initialized for proper functionality.

Parameters

  • speed: This specifies the baud rate that this desired for SPI communication
  • pb_clk: This parameter is the speed of the peripheral bus clock that is running the SPI module and is used for configuring the communication speed
  • which_spi: This parameter specifies which SPI channel should be configured
  • clk_edge: This specifies when an activation occurs during SPI communication. This is defined as either a rising or a falling edge on the communication line.
  • tx_buffer_ptr: This parameter should be a pointer to a buffer of memory to be used by the transmission section of SPI. This data must not leave scope, and can only be used by the SPI module. Modification of this memory can cause the SPI module to malfunction.
  • tx_buffer_size: This should indicate the size of memory pointed to by tx_buffer_ptr in bytes.
  • tx_callback: the tx_callback function will be triggered whenever a communication is encountered on the SPI transmission line. Please see callback functions.
  • tx_en: This parameter specifies whether or not the transmission section of the SPI module should be enabled.
  • rx_buffer_ptr: This parameter should be a pointer to a buffer of memory to be used by the receiving section of SPI. This data must not leave scope, and can only be used by the SPI module. Modification of this memory can cause the SPI module to malfunction.
  • rx_buffer_size: This parameter specifies the amount of data pointed to by rx_buffer_ptr in bytes.
  • rx_callback:the rx_callback function will be triggered whenever a communication is encountered on the SPI receive line. Please see callback functions.
  • rx_en: This parameter specifies whether or not receiving should be enabled on the SPI module.

top

Clone this wiki locally