STM8L15x Standard Peripherals Drivers: stm8l15x_spi.c File Reference

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

stm8l15x_spi.c File Reference

This file provides firmware functions to manage the following functionalities of the Serial peripheral interface (SPI):

  • Initialization and Configuration
  • Data transfers functions
  • Hardware CRC Calculation
  • DMA transfers management
  • Interrupts and flags management.
More...
#include "stm8l15x_spi.h"

Go to the source code of this file.

Functions

void SPI_BiDirectionalLineConfig (SPI_TypeDef *SPIx, SPI_Direction_TypeDef SPI_Direction)
 Selects the data transfer direction in Bi-directional mode.
void SPI_CalculateCRCCmd (SPI_TypeDef *SPIx, FunctionalState NewState)
 Enables or disables the CRC value calculation of the transferred bytes.
void SPI_ClearFlag (SPI_TypeDef *SPIx, SPI_FLAG_TypeDef SPI_FLAG)
 Clears the SPI flags.
void SPI_ClearITPendingBit (SPI_TypeDef *SPIx, SPI_IT_TypeDef SPI_IT)
 Clears the interrupt pending bits.
void SPI_Cmd (SPI_TypeDef *SPIx, FunctionalState NewState)
 Enables or disables the SPI peripheral.
void SPI_DeInit (SPI_TypeDef *SPIx)
 Deinitializes the SPI peripheral registers to their default reset values.
void SPI_DMACmd (SPI_TypeDef *SPIx, SPI_DMAReq_TypeDef SPI_DMAReq, FunctionalState NewState)
 Enables or disables the SPI DMA interface.
uint8_t SPI_GetCRC (SPI_TypeDef *SPIx, SPI_CRC_TypeDef SPI_CRC)
 Returns the transmit or the receive CRC register value.
uint8_t SPI_GetCRCPolynomial (SPI_TypeDef *SPIx)
 Returns the CRC Polynomial register value.
FlagStatus SPI_GetFlagStatus (SPI_TypeDef *SPIx, SPI_FLAG_TypeDef SPI_FLAG)
 Checks whether the specified SPI flag is set or not.
ITStatus SPI_GetITStatus (SPI_TypeDef *SPIx, SPI_IT_TypeDef SPI_IT)
 Checks whether the specified interrupt has occurred or not.
void SPI_Init (SPI_TypeDef *SPIx, SPI_FirstBit_TypeDef SPI_FirstBit, SPI_BaudRatePrescaler_TypeDef SPI_BaudRatePrescaler, SPI_Mode_TypeDef SPI_Mode, SPI_CPOL_TypeDef SPI_CPOL, SPI_CPHA_TypeDef SPI_CPHA, SPI_DirectionMode_TypeDef SPI_Data_Direction, SPI_NSS_TypeDef SPI_Slave_Management, uint8_t CRCPolynomial)
 Initializes the SPI according to the specified parameters.
void SPI_ITConfig (SPI_TypeDef *SPIx, SPI_IT_TypeDef SPI_IT, FunctionalState NewState)
 Enables or disables the specified interrupts.
void SPI_NSSInternalSoftwareCmd (SPI_TypeDef *SPIx, FunctionalState NewState)
 Configures internally by software the NSS pin.
uint8_t SPI_ReceiveData (SPI_TypeDef *SPIx)
 Returns the most recent received data by the SPI peripheral.
void SPI_ResetCRC (SPI_TypeDef *SPIx)
 Reset the Rx CRCR and Tx CRCR registers.
void SPI_SendData (SPI_TypeDef *SPIx, uint8_t Data)
 Transmits a Data through the SPI peripheral.
void SPI_TransmitCRC (SPI_TypeDef *SPIx)
 Enables the transmit of the CRC value.

Detailed Description

This file provides firmware functions to manage the following functionalities of the Serial peripheral interface (SPI):

  • Initialization and Configuration
  • Data transfers functions
  • Hardware CRC Calculation
  • DMA transfers management
  • Interrupts and flags management.
Author:
MCD Application Team
Version:
V1.5.0
Date:
13-May-2011
  *          
  *          ===================================================================
  *                                 How to use this driver
  *          ===================================================================
  *          1. Enable peripheral clock using CLK_PeripheralClockConfig(CLK_Peripheral_SPIx,
  *             ENABLE) function (Refer to the product datasheet for the available SPI
  *           	peripherals)
  *
  *          2.  Enable the external Pull-up on the used SPI Pins using the
  *              GPIO_ExternalPullUpConfig() function or an eternal pull-up equivalent resistor
	*              (RPU = 45 KOhm typical value). 
  *
  *        
  *          3. Program the Polarity, Phase, First Data, Baud Rate Prescaler, Slave 
  *             Management, Peripheral Mode and CRC Polynomial values using the SPI_Init()
  *             function.
  *
  *          4. Enable the corresponding interrupt using the function SPI_ITConfig() if you
  *           	need to use interrupt mode. 
  *
  *          5. When using the DMA mode 
  *                   - Configure the DMA using DMA_Init() function
  *                   - Active the needed channel Request using SPI_DMACmd() function
  * 
  *          6. Enable the SPI using the SPI_Cmd() function.
  * 
  *          7. Enable the DMA using the DMA_Cmd() function when using DMA mode. 
  *
  *          8. Optionally you can enable/configure the following parameters without
  *             re-initialization (i.e there is no need to call again SPI_Init() function):
  *              - When bidirectional mode (SPI_Direction_1Line_Rx or SPI_Direction_1Line_Tx)
  *                is programmed as Data direction parameter using the SPI_Init() function
  *                it can be possible to switch between SPI_Direction_Tx or SPI_Direction_Rx
  *                using the SPI_BiDirectionalLineConfig() function.
  *              - When SPI_NSS_Soft is selected as Slave Select Management parameter 
  *                using the SPI_Init() function it can be possible to manage the 
  *                NSS internal signal using the SPI_NSSInternalSoftwareConfig() function.
  *          
  *          9. To use the CRC Hardware calculation feature refer to the Peripheral 
  *              CRC hardware Calculation subsection.
  *
  *  
Attention:

THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.

© COPYRIGHT 2011 STMicroelectronics

Definition in file stm8l15x_spi.c.

STM8S Firmware Library: Overview

 

 

 

For complete documentation on STM8L15x 8-bit microcontrollers platform visit www.st.com