AT25DF.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*****************************************************************************
  2. AT25DF.h
  3. *****************************************************************************/
  4. #ifndef _AT25DF_H
  5. #define _AT25DF_H
  6. /*****************************************************************************/
  7. #include <stm32f10x.h>
  8. #define AT25DF_CS_PIN GPIO_Pin_4 /* PA.04 */
  9. #define AT25DF_CS_GPIO_PORT GPIOA /* GPIOA */
  10. #define AT25DF_CS_GPIO_CLK RCC_APB2Periph_GPIOA
  11. #define AT25DF_CS_LOW() GPIO_ResetBits(AT25DF_CS_GPIO_PORT, AT25DF_CS_PIN)
  12. #define AT25DF_CS_HIGH() GPIO_SetBits(AT25DF_CS_GPIO_PORT, AT25DF_CS_PIN)
  13. #define AT25DF_SPI SPI1
  14. #define AT25DF_SPI_CLK RCC_APB2Periph_SPI1
  15. #define AT25DF_SPI_SCK_PIN GPIO_Pin_5 /* PA.05 */
  16. #define AT25DF_SPI_SCK_GPIO_PORT GPIOA /* GPIOA */
  17. #define AT25DF_SPI_SCK_GPIO_CLK RCC_APB2Periph_GPIOA
  18. #define AT25DF_SPI_MISO_PIN GPIO_Pin_6 /* PA.06 */
  19. #define AT25DF_SPI_MISO_GPIO_PORT GPIOA /* GPIOA */
  20. #define AT25DF_SPI_MISO_GPIO_CLK RCC_APB2Periph_GPIOA
  21. #define AT25DF_SPI_MOSI_PIN GPIO_Pin_7 /* PA.07 */
  22. #define AT25DF_SPI_MOSI_GPIO_PORT GPIOA /* GPIOA */
  23. #define AT25DF_SPI_MOSI_GPIO_CLK RCC_APB2Periph_GPIOA
  24. int AT25DF_Init(void);
  25. void SPI_Flash_Global_Protect(void);
  26. void SPI_Flash_Global_Unprotect(void);
  27. void SPI_Flash_Erase_Chip(void);
  28. void SPI_Flash_Erase_Sector(u32 Dst_Addr);
  29. void SPI_Flash_Read(u8* pBuffer,u32 ReadAddr,u16 NumByteToRead);
  30. void SPI_Flash_Write(u8* pBuffer,u32 WriteAddr,u16 NumByteToWrite);
  31. void SPI_Flash_Write_NoCheck(u8* pBuffer,u32 WriteAddr,u16 NumByteToWrite);
  32. void SPI_Flash_PowerDown(void);
  33. void SPI_Flash_WAKEUP(void);
  34. void SPI_Flash_Unprotect_Sector(u32 Dst_Addr);
  35. void SPI_Flash_Protect_Sector(u32 Dst_Addr);
  36. void AT25DFTest(void);
  37. void DelayUs(u16 myUs);
  38. /*****************************************************************************/
  39. #endif
  40. /*****************************************************************************/