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;