49 #define CR1_SPE_Set ((uint16_t)0x0040) 50 #define CR1_SPE_Reset ((uint16_t)0xFFBF) 53 #define I2SCFGR_I2SE_Set ((uint16_t)0x0400) 54 #define I2SCFGR_I2SE_Reset ((uint16_t)0xFBFF) 57 #define CR1_CRCNext_Set ((uint16_t)0x1000) 60 #define CR1_CRCEN_Set ((uint16_t)0x2000) 61 #define CR1_CRCEN_Reset ((uint16_t)0xDFFF) 64 #define CR2_SSOE_Set ((uint16_t)0x0004) 65 #define CR2_SSOE_Reset ((uint16_t)0xFFFB) 68 #define CR1_CLEAR_Mask ((uint16_t)0x3040) 69 #define I2SCFGR_CLEAR_Mask ((uint16_t)0xF040) 72 #define SPI_Mode_Select ((uint16_t)0xF7FF) 73 #define I2S_Mode_Select ((uint16_t)0x0800) 76 #define I2S2_CLOCK_SRC ((uint32_t)(0x00020000)) 77 #define I2S3_CLOCK_SRC ((uint32_t)(0x00040000)) 78 #define I2S_MUL_MASK ((uint32_t)(0x0000F000)) 79 #define I2S_DIV_MASK ((uint32_t)(0x000000F0)) 131 else if (SPIx ==
SPI2)
221 uint16_t tmpreg = 0, i2sdiv = 2, i2sodd = 0, packetlength = 1;
224 uint32_t sourceclock = 0;
238 SPIx->
I2SPR = 0x0002;
246 i2sodd = (uint16_t)0;
247 i2sdiv = (uint16_t)2;
279 if((
RCC->CFGR2 & tmp) != 0)
285 if((tmp > 5) && (tmp < 15))
302 sourceclock = (uint32_t) ((
HSE_Value / sourceclock) * tmp * 2);
324 tmp = (uint16_t)(((((sourceclock / 256) * 10) / I2S_InitStruct->
I2S_AudioFreq)) + 5);
329 tmp = (uint16_t)(((((sourceclock / (32 * packetlength)) *10 ) / I2S_InitStruct->
I2S_AudioFreq)) + 5);
336 i2sodd = (uint16_t)(tmp & (uint16_t)0x0001);
339 i2sdiv = (uint16_t)((tmp - i2sodd) / 2);
342 i2sodd = (uint16_t) (i2sodd << 8);
346 if ((i2sdiv < 2) || (i2sdiv > 0xFF))
354 SPIx->
I2SPR = (uint16_t)(i2sdiv | (uint16_t)(i2sodd | (uint16_t)I2S_InitStruct->
I2S_MCLKOutput));
359 (uint16_t)I2S_InitStruct->
I2S_CPOL))));
484 uint16_t itpos = 0, itmask = 0 ;
491 itpos = SPI_I2S_IT >> 4;
494 itmask = (uint16_t)1 << (uint16_t)itpos;
504 SPIx->
CR2 &= (uint16_t)~itmask;
530 SPIx->
CR2 |= SPI_I2S_DMAReq;
535 SPIx->
CR2 &= (uint16_t)~SPI_I2S_DMAReq;
639 SPIx->
CR1 |= SPI_DataSize;
773 if ((SPIx->
SR & SPI_I2S_FLAG) != (uint16_t)
RESET)
811 SPIx->
SR = (uint16_t)~SPI_I2S_FLAG;
832 uint16_t itpos = 0, itmask = 0, enablestatus = 0;
839 itpos = 0x01 << (SPI_I2S_IT & 0x0F);
842 itmask = SPI_I2S_IT >> 4;
845 itmask = 0x01 << itmask;
848 enablestatus = (SPIx->
CR2 & itmask) ;
851 if (((SPIx->
SR & itpos) != (uint16_t)
RESET) && enablestatus)
891 itpos = 0x01 << (SPI_I2S_IT & 0x0F);
894 SPIx->
SR = (uint16_t)~itpos;
void SPI_CalculateCRC(SPI_TypeDef *SPIx, FunctionalState NewState)
Enables or disables the CRC value calculation of the transferred bytes.
#define IS_SPI_NSS_INTERNAL(INTERNAL)
#define IS_SPI_I2S_GET_IT(IT)
#define IS_SPI_ALL_PERIPH(PERIPH)
void SPI_TransmitCRC(SPI_TypeDef *SPIx)
Transmit the SPIx CRC value.
#define IS_SPI_I2S_CLEAR_FLAG(FLAG)
#define I2SCFGR_I2SE_Reset
#define IS_I2S_AUDIO_FREQ(FREQ)
#define IS_SPI_I2S_DMAREQ(DMAREQ)
uint16_t SPI_BaudRatePrescaler
#define I2S_MCLKOutput_Disable
void SPI_I2S_DeInit(SPI_TypeDef *SPIx)
Deinitializes the SPIx peripheral registers to their default reset values (Affects also the I2Ss)...
void SPI_I2S_SendData(SPI_TypeDef *SPIx, uint16_t Data)
Transmits a Data through the SPIx/I2Sx peripheral.
#define I2SCFGR_CLEAR_Mask
uint16_t SPI_CRCPolynomial
void assert_param(int val)
void SPI_I2S_ClearITPendingBit(SPI_TypeDef *SPIx, uint8_t SPI_I2S_IT)
Clears the SPIx CRC Error (CRCERR) interrupt pending bit.
#define IS_SPI_DIRECTION(DIRECTION)
#define IS_FUNCTIONAL_STATE(STATE)
void SPI_SSOutputCmd(SPI_TypeDef *SPIx, FunctionalState NewState)
Enables or disables the SS output for the selected SPI.
Serial Peripheral Interface.
void SPI_NSSInternalSoftwareConfig(SPI_TypeDef *SPIx, uint16_t SPI_NSSInternalSoft)
Configures internally by software the NSS pin for the selected SPI.
#define RCC_APB1Periph_SPI2
void SPI_StructInit(SPI_InitTypeDef *SPI_InitStruct)
Fills each SPI_InitStruct member with its default value.
FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef *SPIx, uint16_t SPI_I2S_FLAG)
Checks whether the specified SPI/I2S flag is set or not.
#define RCC_APB2Periph_SPI1
void SPI_DataSizeConfig(SPI_TypeDef *SPIx, uint16_t SPI_DataSize)
Configures the data size for the selected SPI.
#define IS_SPI_FIRST_BIT(BIT)
void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
Forces or releases Low Speed APB (APB1) peripheral reset.
uint16_t SPI_I2S_ReceiveData(SPI_TypeDef *SPIx)
Returns the most recent received data by the SPIx/I2Sx peripheral.
#define SPI_NSSInternalSoft_Set
void I2S_Init(SPI_TypeDef *SPIx, I2S_InitTypeDef *I2S_InitStruct)
Initializes the SPIx peripheral according to the specified parameters in the I2S_InitStruct.
#define IS_I2S_CPOL(CPOL)
#define IS_SPI_DATASIZE(DATASIZE)
#define SPI_BaudRatePrescaler_2
#define IS_I2S_MODE(MODE)
SPI Init structure definition.
#define SPI_Direction_2Lines_FullDuplex
#define IS_SPI_MODE(MODE)
#define I2S_Standard_Phillips
#define IS_SPI_CPHA(CPHA)
#define SPI_NSSInternalSoft_Reset
This file contains all the functions prototypes for the RCC firmware library.
#define IS_I2S_STANDARD(STANDARD)
#define IS_SPI_I2S_GET_FLAG(FLAG)
uint16_t SPI_GetCRCPolynomial(SPI_TypeDef *SPIx)
Returns the CRC Polynomial register value for the specified SPI.
#define IS_SPI_23_PERIPH(PERIPH)
#define IS_SPI_I2S_CONFIG_IT(IT)
void RCC_APB2PeriphResetCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
Forces or releases High Speed APB (APB2) peripheral reset.
void SPI_I2S_ClearFlag(SPI_TypeDef *SPIx, uint16_t SPI_I2S_FLAG)
Clears the SPIx CRC Error (CRCERR) flag.
void I2S_StructInit(I2S_InitTypeDef *I2S_InitStruct)
Fills each I2S_InitStruct member with its default value.
#define IS_SPI_CPOL(CPOL)
I2S Init structure definition.
#define IS_SPI_BAUDRATE_PRESCALER(PRESCALER)
ITStatus SPI_I2S_GetITStatus(SPI_TypeDef *SPIx, uint8_t SPI_I2S_IT)
Checks whether the specified SPI/I2S interrupt has occurred or not.
#define RCC_APB1Periph_SPI3
void SPI_BiDirectionalLineConfig(SPI_TypeDef *SPIx, uint16_t SPI_Direction)
Selects the data transfer direction in bi-directional mode for the specified SPI. ...
void I2S_Cmd(SPI_TypeDef *SPIx, FunctionalState NewState)
Enables or disables the specified SPI peripheral (in I2S mode).
#define I2S_MCLKOutput_Enable
uint32_t SYSCLK_Frequency
void RCC_GetClocksFreq(RCC_ClocksTypeDef *RCC_Clocks)
Returns the frequencies of different on chip clocks; SYSCLK, HCLK, PCLK1 and PCLK2.
#define IS_SPI_DIRECTION_MODE(MODE)
#define IS_I2S_MCLK_OUTPUT(OUTPUT)
#define IS_SPI_CRC_POLYNOMIAL(POLYNOMIAL)
void SPI_I2S_DMACmd(SPI_TypeDef *SPIx, uint16_t SPI_I2S_DMAReq, FunctionalState NewState)
Enables or disables the SPIx/I2Sx DMA interface.
void SPI_I2S_ITConfig(SPI_TypeDef *SPIx, uint8_t SPI_I2S_IT, FunctionalState NewState)
Enables or disables the specified SPI/I2S interrupts.
void SPI_Init(SPI_TypeDef *SPIx, SPI_InitTypeDef *SPI_InitStruct)
Initializes the SPIx peripheral according to the specified parameters in the SPI_InitStruct.
#define IS_SPI_I2S_CLEAR_IT(IT)
uint16_t SPI_GetCRC(SPI_TypeDef *SPIx, uint8_t SPI_CRC)
Returns the transmit or the receive CRC register value for the specified SPI.
This file contains all the functions prototypes for the SPI firmware library.
void SPI_Cmd(SPI_TypeDef *SPIx, FunctionalState NewState)
Enables or disables the specified SPI peripheral.
#define I2S_AudioFreq_Default