12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325 |
- #include "stm32f4xx_spi.h"
- #include "stm32f4xx_rcc.h"
-
- #define CR1_CLEAR_MASK ((uint16_t)0x3040)
- #define I2SCFGR_CLEAR_MASK ((uint16_t)0xF040)
- #define PLLCFGR_PPLR_MASK ((uint32_t)0x70000000)
- #define PLLCFGR_PPLN_MASK ((uint32_t)0x00007FC0)
- #define SPI_CR2_FRF ((uint16_t)0x0010)
- #define SPI_SR_TIFRFE ((uint16_t)0x0100)
- void SPI_I2S_DeInit(SPI_TypeDef* SPIx)
- {
-
- assert_param(IS_SPI_ALL_PERIPH(SPIx));
- if (SPIx == SPI1)
- {
-
- RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, ENABLE);
-
- RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, DISABLE);
- }
- else if (SPIx == SPI2)
- {
-
- RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, ENABLE);
-
- RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, DISABLE);
- }
- else if (SPIx == SPI3)
- {
-
- RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, ENABLE);
-
- RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI3, DISABLE);
- }
- else if (SPIx == SPI4)
- {
-
- RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI4, ENABLE);
-
- RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI4, DISABLE);
- }
- else if (SPIx == SPI5)
- {
-
- RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI5, ENABLE);
-
- RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI5, DISABLE);
- }
- else
- {
- if (SPIx == SPI6)
- {
-
- RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI6, ENABLE);
-
- RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI6, DISABLE);
- }
- }
- }
- void SPI_Init(SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct)
- {
- uint16_t tmpreg = 0;
-
-
- assert_param(IS_SPI_ALL_PERIPH(SPIx));
-
-
- assert_param(IS_SPI_DIRECTION_MODE(SPI_InitStruct->SPI_Direction));
- assert_param(IS_SPI_MODE(SPI_InitStruct->SPI_Mode));
- assert_param(IS_SPI_DATASIZE(SPI_InitStruct->SPI_DataSize));
- assert_param(IS_SPI_CPOL(SPI_InitStruct->SPI_CPOL));
- assert_param(IS_SPI_CPHA(SPI_InitStruct->SPI_CPHA));
- assert_param(IS_SPI_NSS(SPI_InitStruct->SPI_NSS));
- assert_param(IS_SPI_BAUDRATE_PRESCALER(SPI_InitStruct->SPI_BaudRatePrescaler));
- assert_param(IS_SPI_FIRST_BIT(SPI_InitStruct->SPI_FirstBit));
- assert_param(IS_SPI_CRC_POLYNOMIAL(SPI_InitStruct->SPI_CRCPolynomial));
-
- tmpreg = SPIx->CR1;
-
- tmpreg &= CR1_CLEAR_MASK;
-
-
-
-
-
-
-
- tmpreg |= (uint16_t)((uint32_t)SPI_InitStruct->SPI_Direction | SPI_InitStruct->SPI_Mode |
- SPI_InitStruct->SPI_DataSize | SPI_InitStruct->SPI_CPOL |
- SPI_InitStruct->SPI_CPHA | SPI_InitStruct->SPI_NSS |
- SPI_InitStruct->SPI_BaudRatePrescaler | SPI_InitStruct->SPI_FirstBit);
-
- SPIx->CR1 = tmpreg;
-
- SPIx->I2SCFGR &= (uint16_t)~((uint16_t)SPI_I2SCFGR_I2SMOD);
-
- SPIx->CRCPR = SPI_InitStruct->SPI_CRCPolynomial;
- }
- void I2S_Init(SPI_TypeDef* SPIx, I2S_InitTypeDef* I2S_InitStruct)
- {
- uint16_t tmpreg = 0, i2sdiv = 2, i2sodd = 0, packetlength = 1;
- uint32_t tmp = 0, i2sclk = 0;
- #ifndef I2S_EXTERNAL_CLOCK_VAL
- uint32_t pllm = 0, plln = 0, pllr = 0;
- #endif
-
-
- assert_param(IS_SPI_23_PERIPH(SPIx));
- assert_param(IS_I2S_MODE(I2S_InitStruct->I2S_Mode));
- assert_param(IS_I2S_STANDARD(I2S_InitStruct->I2S_Standard));
- assert_param(IS_I2S_DATA_FORMAT(I2S_InitStruct->I2S_DataFormat));
- assert_param(IS_I2S_MCLK_OUTPUT(I2S_InitStruct->I2S_MCLKOutput));
- assert_param(IS_I2S_AUDIO_FREQ(I2S_InitStruct->I2S_AudioFreq));
- assert_param(IS_I2S_CPOL(I2S_InitStruct->I2S_CPOL));
-
- SPIx->I2SCFGR &= I2SCFGR_CLEAR_MASK;
- SPIx->I2SPR = 0x0002;
-
-
- tmpreg = SPIx->I2SCFGR;
-
-
- if(I2S_InitStruct->I2S_AudioFreq == I2S_AudioFreq_Default)
- {
- i2sodd = (uint16_t)0;
- i2sdiv = (uint16_t)2;
- }
-
- else
- {
-
- if(I2S_InitStruct->I2S_DataFormat == I2S_DataFormat_16b)
- {
-
- packetlength = 16;
- }
- else
- {
-
- packetlength = 32;
- }
- if(I2S_InitStruct->I2S_Standard <= I2S_Standard_LSB)
- {
-
- packetlength = packetlength * 2;
- }
-
-
-
- #ifdef I2S_EXTERNAL_CLOCK_VAL
-
- if ((RCC->CFGR & RCC_CFGR_I2SSRC) == 0)
- {
- RCC->CFGR |= (uint32_t)RCC_CFGR_I2SSRC;
- }
-
-
- i2sclk = I2S_EXTERNAL_CLOCK_VAL;
- #else
-
- if ((RCC->CFGR & RCC_CFGR_I2SSRC) != 0)
- {
- RCC->CFGR &= ~(uint32_t)RCC_CFGR_I2SSRC;
- }
-
-
- plln = (uint32_t)(((RCC->PLLI2SCFGR & RCC_PLLI2SCFGR_PLLI2SN) >> 6) & \
- (RCC_PLLI2SCFGR_PLLI2SN >> 6));
-
-
- pllr = (uint32_t)(((RCC->PLLI2SCFGR & RCC_PLLI2SCFGR_PLLI2SR) >> 28) & \
- (RCC_PLLI2SCFGR_PLLI2SR >> 28));
-
-
- pllm = (uint32_t)(RCC->PLLCFGR & RCC_PLLCFGR_PLLM);
- if((RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) == RCC_PLLCFGR_PLLSRC_HSE)
- {
-
- i2sclk = (uint32_t)(((HSE_VALUE / pllm) * plln) / pllr);
- }
- else
- {
- i2sclk = (uint32_t)(((HSI_VALUE / pllm) * plln) / pllr);
- }
- #endif
-
-
- if(I2S_InitStruct->I2S_MCLKOutput == I2S_MCLKOutput_Enable)
- {
-
- tmp = (uint16_t)(((((i2sclk / 256) * 10) / I2S_InitStruct->I2S_AudioFreq)) + 5);
- }
- else
- {
-
- tmp = (uint16_t)(((((i2sclk / (32 * packetlength)) *10 ) / I2S_InitStruct->I2S_AudioFreq)) + 5);
- }
-
-
- tmp = tmp / 10;
-
-
- i2sodd = (uint16_t)(tmp & (uint16_t)0x0001);
-
-
- i2sdiv = (uint16_t)((tmp - i2sodd) / 2);
-
-
- i2sodd = (uint16_t) (i2sodd << 8);
- }
-
- if ((i2sdiv < 2) || (i2sdiv > 0xFF))
- {
-
- i2sdiv = 2;
- i2sodd = 0;
- }
-
- SPIx->I2SPR = (uint16_t)((uint16_t)i2sdiv | (uint16_t)(i2sodd | (uint16_t)I2S_InitStruct->I2S_MCLKOutput));
-
-
- tmpreg |= (uint16_t)((uint16_t)SPI_I2SCFGR_I2SMOD | (uint16_t)(I2S_InitStruct->I2S_Mode | \
- (uint16_t)(I2S_InitStruct->I2S_Standard | (uint16_t)(I2S_InitStruct->I2S_DataFormat | \
- (uint16_t)I2S_InitStruct->I2S_CPOL))));
-
- #if defined(SPI_I2SCFGR_ASTRTEN)
- if((I2S_InitStruct->I2S_Standard == I2S_Standard_PCMShort) || (I2S_InitStruct->I2S_Standard == I2S_Standard_PCMLong))
- {
-
- SPIx->I2SCFGR = tmpreg | SPI_I2SCFGR_ASTRTEN;
- }
- #else
-
- SPIx->I2SCFGR = tmpreg ;
- #endif
- }
- void SPI_StructInit(SPI_InitTypeDef* SPI_InitStruct)
- {
-
- SPI_InitStruct->SPI_Direction = SPI_Direction_2Lines_FullDuplex;
-
- SPI_InitStruct->SPI_Mode = SPI_Mode_Slave;
-
- SPI_InitStruct->SPI_DataSize = SPI_DataSize_8b;
-
- SPI_InitStruct->SPI_CPOL = SPI_CPOL_Low;
-
- SPI_InitStruct->SPI_CPHA = SPI_CPHA_1Edge;
-
- SPI_InitStruct->SPI_NSS = SPI_NSS_Hard;
-
- SPI_InitStruct->SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;
-
- SPI_InitStruct->SPI_FirstBit = SPI_FirstBit_MSB;
-
- SPI_InitStruct->SPI_CRCPolynomial = 7;
- }
- void I2S_StructInit(I2S_InitTypeDef* I2S_InitStruct)
- {
-
- I2S_InitStruct->I2S_Mode = I2S_Mode_SlaveTx;
-
-
- I2S_InitStruct->I2S_Standard = I2S_Standard_Phillips;
-
-
- I2S_InitStruct->I2S_DataFormat = I2S_DataFormat_16b;
-
-
- I2S_InitStruct->I2S_MCLKOutput = I2S_MCLKOutput_Disable;
-
-
- I2S_InitStruct->I2S_AudioFreq = I2S_AudioFreq_Default;
-
-
- I2S_InitStruct->I2S_CPOL = I2S_CPOL_Low;
- }
- void SPI_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState)
- {
-
- assert_param(IS_SPI_ALL_PERIPH(SPIx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
-
- SPIx->CR1 |= SPI_CR1_SPE;
- }
- else
- {
-
- SPIx->CR1 &= (uint16_t)~((uint16_t)SPI_CR1_SPE);
- }
- }
- void I2S_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState)
- {
-
- assert_param(IS_SPI_23_PERIPH_EXT(SPIx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
-
- if (NewState != DISABLE)
- {
-
- SPIx->I2SCFGR |= SPI_I2SCFGR_I2SE;
- }
- else
- {
-
- SPIx->I2SCFGR &= (uint16_t)~((uint16_t)SPI_I2SCFGR_I2SE);
- }
- }
- void SPI_DataSizeConfig(SPI_TypeDef* SPIx, uint16_t SPI_DataSize)
- {
-
- assert_param(IS_SPI_ALL_PERIPH(SPIx));
- assert_param(IS_SPI_DATASIZE(SPI_DataSize));
-
- SPIx->CR1 &= (uint16_t)~SPI_DataSize_16b;
-
- SPIx->CR1 |= SPI_DataSize;
- }
- void SPI_BiDirectionalLineConfig(SPI_TypeDef* SPIx, uint16_t SPI_Direction)
- {
-
- assert_param(IS_SPI_ALL_PERIPH(SPIx));
- assert_param(IS_SPI_DIRECTION(SPI_Direction));
- if (SPI_Direction == SPI_Direction_Tx)
- {
-
- SPIx->CR1 |= SPI_Direction_Tx;
- }
- else
- {
-
- SPIx->CR1 &= SPI_Direction_Rx;
- }
- }
- void SPI_NSSInternalSoftwareConfig(SPI_TypeDef* SPIx, uint16_t SPI_NSSInternalSoft)
- {
-
- assert_param(IS_SPI_ALL_PERIPH(SPIx));
- assert_param(IS_SPI_NSS_INTERNAL(SPI_NSSInternalSoft));
- if (SPI_NSSInternalSoft != SPI_NSSInternalSoft_Reset)
- {
-
- SPIx->CR1 |= SPI_NSSInternalSoft_Set;
- }
- else
- {
-
- SPIx->CR1 &= SPI_NSSInternalSoft_Reset;
- }
- }
- void SPI_SSOutputCmd(SPI_TypeDef* SPIx, FunctionalState NewState)
- {
-
- assert_param(IS_SPI_ALL_PERIPH(SPIx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
-
- SPIx->CR2 |= (uint16_t)SPI_CR2_SSOE;
- }
- else
- {
-
- SPIx->CR2 &= (uint16_t)~((uint16_t)SPI_CR2_SSOE);
- }
- }
- void SPI_TIModeCmd(SPI_TypeDef* SPIx, FunctionalState NewState)
- {
-
- assert_param(IS_SPI_ALL_PERIPH(SPIx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
-
- SPIx->CR2 |= SPI_CR2_FRF;
- }
- else
- {
-
- SPIx->CR2 &= (uint16_t)~SPI_CR2_FRF;
- }
- }
- void I2S_FullDuplexConfig(SPI_TypeDef* I2Sxext, I2S_InitTypeDef* I2S_InitStruct)
- {
- uint16_t tmpreg = 0, tmp = 0;
-
-
- assert_param(IS_I2S_EXT_PERIPH(I2Sxext));
- assert_param(IS_I2S_MODE(I2S_InitStruct->I2S_Mode));
- assert_param(IS_I2S_STANDARD(I2S_InitStruct->I2S_Standard));
- assert_param(IS_I2S_DATA_FORMAT(I2S_InitStruct->I2S_DataFormat));
- assert_param(IS_I2S_CPOL(I2S_InitStruct->I2S_CPOL));
-
- I2Sxext->I2SCFGR &= I2SCFGR_CLEAR_MASK;
- I2Sxext->I2SPR = 0x0002;
-
-
- tmpreg = I2Sxext->I2SCFGR;
-
-
- if ((I2S_InitStruct->I2S_Mode == I2S_Mode_MasterTx) || (I2S_InitStruct->I2S_Mode == I2S_Mode_SlaveTx))
- {
- tmp = I2S_Mode_SlaveRx;
- }
- else
- {
- if ((I2S_InitStruct->I2S_Mode == I2S_Mode_MasterRx) || (I2S_InitStruct->I2S_Mode == I2S_Mode_SlaveRx))
- {
- tmp = I2S_Mode_SlaveTx;
- }
- }
-
-
- tmpreg |= (uint16_t)((uint16_t)SPI_I2SCFGR_I2SMOD | (uint16_t)(tmp | \
- (uint16_t)(I2S_InitStruct->I2S_Standard | (uint16_t)(I2S_InitStruct->I2S_DataFormat | \
- (uint16_t)I2S_InitStruct->I2S_CPOL))));
-
-
- I2Sxext->I2SCFGR = tmpreg;
- }
- uint16_t SPI_I2S_ReceiveData(SPI_TypeDef* SPIx)
- {
-
- assert_param(IS_SPI_ALL_PERIPH_EXT(SPIx));
-
-
- return SPIx->DR;
- }
- void SPI_I2S_SendData(SPI_TypeDef* SPIx, uint16_t Data)
- {
-
- assert_param(IS_SPI_ALL_PERIPH_EXT(SPIx));
-
-
- SPIx->DR = Data;
- }
- void SPI_CalculateCRC(SPI_TypeDef* SPIx, FunctionalState NewState)
- {
-
- assert_param(IS_SPI_ALL_PERIPH(SPIx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
-
- SPIx->CR1 |= SPI_CR1_CRCEN;
- }
- else
- {
-
- SPIx->CR1 &= (uint16_t)~((uint16_t)SPI_CR1_CRCEN);
- }
- }
- void SPI_TransmitCRC(SPI_TypeDef* SPIx)
- {
-
- assert_param(IS_SPI_ALL_PERIPH(SPIx));
-
-
- SPIx->CR1 |= SPI_CR1_CRCNEXT;
- }
- uint16_t SPI_GetCRC(SPI_TypeDef* SPIx, uint8_t SPI_CRC)
- {
- uint16_t crcreg = 0;
-
- assert_param(IS_SPI_ALL_PERIPH(SPIx));
- assert_param(IS_SPI_CRC(SPI_CRC));
- if (SPI_CRC != SPI_CRC_Rx)
- {
-
- crcreg = SPIx->TXCRCR;
- }
- else
- {
-
- crcreg = SPIx->RXCRCR;
- }
-
- return crcreg;
- }
- uint16_t SPI_GetCRCPolynomial(SPI_TypeDef* SPIx)
- {
-
- assert_param(IS_SPI_ALL_PERIPH(SPIx));
-
-
- return SPIx->CRCPR;
- }
- void SPI_I2S_DMACmd(SPI_TypeDef* SPIx, uint16_t SPI_I2S_DMAReq, FunctionalState NewState)
- {
-
- assert_param(IS_SPI_ALL_PERIPH_EXT(SPIx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- assert_param(IS_SPI_I2S_DMAREQ(SPI_I2S_DMAReq));
- if (NewState != DISABLE)
- {
-
- SPIx->CR2 |= SPI_I2S_DMAReq;
- }
- else
- {
-
- SPIx->CR2 &= (uint16_t)~SPI_I2S_DMAReq;
- }
- }
- void SPI_I2S_ITConfig(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT, FunctionalState NewState)
- {
- uint16_t itpos = 0, itmask = 0 ;
-
-
- assert_param(IS_SPI_ALL_PERIPH_EXT(SPIx));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- assert_param(IS_SPI_I2S_CONFIG_IT(SPI_I2S_IT));
-
- itpos = SPI_I2S_IT >> 4;
-
- itmask = (uint16_t)1 << (uint16_t)itpos;
- if (NewState != DISABLE)
- {
-
- SPIx->CR2 |= itmask;
- }
- else
- {
-
- SPIx->CR2 &= (uint16_t)~itmask;
- }
- }
- FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG)
- {
- FlagStatus bitstatus = RESET;
-
- assert_param(IS_SPI_ALL_PERIPH_EXT(SPIx));
- assert_param(IS_SPI_I2S_GET_FLAG(SPI_I2S_FLAG));
-
-
- if ((SPIx->SR & SPI_I2S_FLAG) != (uint16_t)RESET)
- {
-
- bitstatus = SET;
- }
- else
- {
-
- bitstatus = RESET;
- }
-
- return bitstatus;
- }
- void SPI_I2S_ClearFlag(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG)
- {
-
- assert_param(IS_SPI_ALL_PERIPH_EXT(SPIx));
- assert_param(IS_SPI_I2S_CLEAR_FLAG(SPI_I2S_FLAG));
-
-
- SPIx->SR = (uint16_t)~SPI_I2S_FLAG;
- }
- ITStatus SPI_I2S_GetITStatus(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT)
- {
- ITStatus bitstatus = RESET;
- uint16_t itpos = 0, itmask = 0, enablestatus = 0;
-
- assert_param(IS_SPI_ALL_PERIPH_EXT(SPIx));
- assert_param(IS_SPI_I2S_GET_IT(SPI_I2S_IT));
-
- itpos = 0x01 << (SPI_I2S_IT & 0x0F);
-
- itmask = SPI_I2S_IT >> 4;
-
- itmask = 0x01 << itmask;
-
- enablestatus = (SPIx->CR2 & itmask) ;
-
- if (((SPIx->SR & itpos) != (uint16_t)RESET) && enablestatus)
- {
-
- bitstatus = SET;
- }
- else
- {
-
- bitstatus = RESET;
- }
-
- return bitstatus;
- }
- void SPI_I2S_ClearITPendingBit(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT)
- {
- uint16_t itpos = 0;
-
- assert_param(IS_SPI_ALL_PERIPH_EXT(SPIx));
- assert_param(IS_SPI_I2S_CLEAR_IT(SPI_I2S_IT));
-
- itpos = 0x01 << (SPI_I2S_IT & 0x0F);
-
- SPIx->SR = (uint16_t)~itpos;
- }
-
-
-
|