1 /* 2 * Copyright (c) 2022 Talkweb Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef __BSP_SPIFLASH_H__ 17 #define __BSP_SPIFLASH_H__ 18 19 #ifdef LOSCFG_DRIVERS_HDF_PLATFORM_SPI 20 #include "hdf_log.h" 21 #include "spi_if.h" 22 23 #define W25x_ID 0X4018 // W25Q128 16MB 24 25 uint8_t W25x_InitSpiFlash(uint32_t busNum, uint32_t csNum); 26 uint8_t W25x_DeInitSpiFlash(void); 27 DevHandle W25x_GetSpiHandle(void); 28 void W25x_SectorErase(uint32_t SectorAddr); 29 void W25x_BulkErase(void); 30 void W25x_PageWrite(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite); 31 void W25x_BufferWrite(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite); 32 void W25x_BufferRead(uint8_t *pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead); 33 uint32_t W25x_ReadID(void); 34 uint32_t W25x_ReadDeviceID(void); 35 void W25x_StartReadSequence(uint32_t ReadAddr); 36 void W25x_PowerDown(void); 37 void W25x_WAKEUP(void); 38 39 uint8_t W25x_ReadByte(void); 40 uint8_t W25x_SendByte(uint8_t byte); 41 void W25x_WriteEnable(void); 42 void W25x_WaitForWriteEnd(void); 43 #endif 44 45 #endif /* __BSP_SPIFLASH_H__ */ 46