【正文】
ck. */uint32_t sEE_WaitEepromStandbyState(void) { __IO uint16_t tmpSR1 = 0。 /* Wait transfer through DMA to be plete */ sEETimeout = sEE_LONG_TIMEOUT。 } } /*! If NumByteToWrite sEE_PAGESIZE */ else { NumByteToWrite = count。 /* Store the number of data to be written */ sEEDataNum = (NumByteToWrite count)。 } if(NumOfSingle!=0) { /* Store the number of data to be written */ sEEDataNum = NumOfSingle。sEEDataNum))。s internal address to write to : LSB of the address */ I2C_SendData(sEE_I2C, (uint8_t)(WriteAddr amp。 while(I2C_GetFlagStatus(sEE_I2C, I2C_FLAG_BUSY)) { if((sEETimeout) == 0) return sEE_TIMEOUT_UserCallback()。 } /*! Read the byte received from the EEPROM */ *pBuffer = I2C_ReceiveData(sEE_I2C)。 //發(fā)送低位地址 endif /*! sEE_M24C08 */ /*! Test on EV8 and clear it */ sEETimeout = sEE_FLAG_TIMEOUT。 } /*! Send START condition */ I2C_GenerateSTART(sEE_I2C, ENABLE)。 }/** * brief Initializes peripherals used by the I2C EEPROM driver. * param None * retval None */void sEE_Init(void){ I2C_InitTypeDef I2C_InitStructure。 /* I2C RX DMA Channel configuration */ DMA_DeInit(sEE_I2C_DMA_CHANNEL_RX)。NVIC_InitStructure)。 = GPIO_Mode_AF_OD。NVIC_InitStructure)。 NVIC_InitTypeDef NVIC_InitStructure。void sEE_Init(void)。 __IO uint8_t sEEDataNum。 = sEE_I2C_DMA_SUBPRIO。 /*! sEE_I2C Periph clock enable */ RCC_APB1PeriphClockCmd(sEE_I2C_CLK, ENABLE)。 = sEE_I2C_DMA_PREPRIO。 = DMA_M2M_Disable。 DMA_Init(sEE_I2C_DMA_CHANNEL_RX, amp。s internal address to start reading from. * param NumByteToRead : pointer to the variable holding number of bytes to * be read from the EEPROM. * * note The variable pointed by NumByteToRead is reset to 0 when all the * data are read from the EEPROM. Application should monitor this * variable in order know when the transfer is plete. * * note When number of data to be read is higher than 1, this function just * configures the munication and enable the DMA channel to transfer data. * Meanwhile, the user application may perform other tasks. * When number of data to be read is 1, then the DMA is not used. The byte * is read in polling mode. * * retval sEE_OK (0) if operation is correctly performed, else return value * different from sEE_OK (0) or the timeout user callback. */uint32_t sEE_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead){ /* Set the pointer to the Number of data to be read. This pointer will be used by the DMA Transfer Completer interrupt Handler in order to reset the variable to 0. User should check on this variable in order to know if the DMA transfer has been plete or not. */ sEEDataReadPointer = NumByteToRead。 } /*! Send the EEPROM39。 /* Call User callback for critical section end (should typically reenable interrupts) */ sEE_ExitCriticalSection_UserCallback()。t check on boundaries condition (in this driver * the function sEE_WriteBuffer() which calls sEE_WritePage() is * responsible of checking on Page boundaries). * * param pBuffer : pointer to the buffer containing the data to be written to * the EEPROM. * param WriteAddr : EEPROM39。 /*! Test on EV8 and clear it */ sEETimeout = sEE_FLAG_TIMEOUT。 NumOfSingle = NumByteToWrite % sEE_PAGESIZE。 } sEE_WaitEepromStandbyState()。 return。 return。 } while(NumOfPage) { /* Store the number of data to be written */ sEEDataNum = sEE_PAGESIZE。}。 /* Check if the ADDR flag has been set */ if (tmpSR1 amp。 } /*! Send STOP condition */ I2C_GenerateSTOP(sEE_I2C, ENABLE)。 } /*! Send EEPROM address for write */ I2C_Send7bitAddress(sEE_I2C, sEEAddress, I2C_Direction_Transmitter)。 } if(NumOfSingle != 0) { /* Store the number of data to be written */ sEEDataNum = NumOfSingle。 while (sEEDataNum 0) { if((sEETimeout) == 0) {sEE_TIMEOUT_UserCallback()。 } sEE_WaitEepromStandbyState()。 } sEE_WaitEepromStandbyState()。 sEE_WritePage(pBuffer, WriteAddr, (uint8_t*)(amp。}/** * brief Writes buffer of data to the I2C EEPROM. * param pBuffer : pointer to the buffer containing the data to be written * to the EEPROM. * param WriteAddr : EEPROM39。 while(!I2C_CheckEvent(sEE_I2C, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)) { if((sEETimeout) == 0) return sEE_TIMEOUT_UserCallback()。 while(!I2C_CheckEvent(sEE_I2C, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)) { if((sEETimeout) == 0) return sEE_TIMEOUT_UserCallback()。t be used */ /* One Byte Master Reception procedure (POLLING) */ if ((uint16_t)(*NumByteToRead) 2) { /* Wait on ADDR flag to be set (ADDR is still not cleared at this level */ sEETimeout = sEE_FLAG_TIMEOUT。s internal address to read from: Only one byte address */ I2C_SendData(sEE_I2C, ReadAddr)。 = I2C_SPEED。 = (uint32_t)BufferSize。 /* This parameter will be configured durig munication */ = DMA_PeripheralInc_Disable。 = sEE_I2C_DMA_PREPRIO。 DMA_Cmd(sEE_I2C_DMA_CHANNEL_RX, DISABLE)。GPIO_InitStructure)。/* Start and End of critical section: these callbacks should be typically used to disable interrupts when entering a critical section of I2C munication You may use default callbacks provided into this driver by unmenting the define USE_DEFAULT_CRITICAL_