| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- /*****************************************************************************
- * Copyright (c) 2019, Nations Technologies Inc.
- *
- * All rights reserved.
- * ****************************************************************************
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the disclaimer below.
- *
- * Nations' name may not be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
- * DISCLAIMED. IN NO EVENT SHALL NATIONS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * ****************************************************************************/
- /**
- * @file sfud.h
- * @author Nations
- * @version v1.0.0
- *
- * @copyright Copyright (c) 2019, Nations Technologies Inc. All rights reserved.
- */
- #ifndef _SFUD_H_
- #define _SFUD_H_
- #include "sfud_def.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- /* ../src/sfup.c */
- /**
- * SFUD library initialize.
- *
- * @return result
- */
- sfud_err sfud_init(void);
- /**
- * SFUD initialize by flash device
- *
- * @param flash flash device
- *
- * @return result
- */
- sfud_err sfud_device_init(sfud_flash *flash);
- /**
- * get flash device by its index which in the flash information table
- *
- * @param index the index which in the flash information table @see flash_table
- *
- * @return flash device
- */
- sfud_flash *sfud_get_device(size_t index);
- /**
- * get flash device total number on flash device information table @see flash_table
- *
- * @return flash device total number
- */
- size_t sfud_get_device_num(void);
- /**
- * get flash device information table @see flash_table
- *
- * @return flash device table pointer
- */
- const sfud_flash *sfud_get_device_table(void);
- #ifdef SFUD_USING_QSPI
- /**
- * Enbale the fast read mode in QSPI flash mode. Default read mode is normal SPI mode.
- *
- * it will find the appropriate fast-read instruction to replace the read instruction(0x03)
- * fast-read instruction @see SFUD_FLASH_EXT_INFO_TABLE
- *
- * @note When Flash is in QSPI mode, the method must be called after sfud_device_init().
- *
- * @param flash flash device
- * @param data_line_width the data lines max width which QSPI bus supported, such as 1, 2, 4
- *
- * @return result
- */
- sfud_err sfud_qspi_fast_read_enable(sfud_flash *flash, uint8_t data_line_width);
- #endif /* SFUD_USING_QSPI */
- /**
- * read flash data
- *
- * @param flash flash device
- * @param addr start address
- * @param size read size
- * @param data read data pointer
- *
- * @return result
- */
- sfud_err sfud_read(const sfud_flash *flash, uint32_t addr, size_t size, uint8_t *data);
- /**
- * erase flash data
- *
- * @note It will erase align by erase granularity.
- *
- * @param flash flash device
- * @param addr start address
- * @param size erase size
- *
- * @return result
- */
- sfud_err sfud_erase(const sfud_flash *flash, uint32_t addr, size_t size);
- /**
- * write flash data (no erase operate)
- *
- * @param flash flash device
- * @param addr start address
- * @param data write data
- * @param size write size
- *
- * @return result
- */
- sfud_err sfud_write(const sfud_flash *flash, uint32_t addr, size_t size, const uint8_t *data);
- /**
- * erase and write flash data
- *
- * @param flash flash device
- * @param addr start address
- * @param size write size
- * @param data write data
- *
- * @return result
- */
- sfud_err sfud_erase_write(const sfud_flash *flash, uint32_t addr, size_t size, const uint8_t *data);
- /**
- * erase all flash data
- *
- * @param flash flash device
- *
- * @return result
- */
- sfud_err sfud_chip_erase(const sfud_flash *flash);
- /**
- * read flash register status
- *
- * @param flash flash device
- * @param status register status
- *
- * @return result
- */
- sfud_err sfud_read_status(const sfud_flash *flash, uint8_t *status);
- /**
- * write status register
- *
- * @param flash flash device
- * @param is_volatile true: volatile mode, false: non-volatile mode
- * @param status register status
- *
- * @return result
- */
- sfud_err sfud_write_status(const sfud_flash *flash, bool is_volatile, uint8_t status);
- #ifdef __cplusplus
- }
- #endif
- #endif /* _SFUD_H_ */
|