SFUD 사용 예시

1896 단어 RT-Thread
준비 하 다.
판도 라,판 넬 재 spi 플래시 열기
예제 코드
간단 한 테스트 진행:
#include 
#include 
#include 
#include 

int main(void)
{
    sfud_err result;
    uint8_t *read_data;//      
    uint8_t *write_data;//       
    sfud_flash *sfud_dev = NULL;

#if 0      //  1:   sfud_dev
    sfud_dev = rt_sfud_flash_find_by_dev_name("W25Q128");
    if (sfud_dev != RT_NULL)
    {
        rt_kprintf("Find sfud_dev success, sfud_dev name = %s
", sfud_dev->name); } #else // 2: sfud_dev sfud_dev = rt_sfud_flash_find("qspi10"); if (sfud_dev != RT_NULL) { rt_kprintf("Find sfud_dev success, sfud_dev name = %s
", sfud_dev->name); } #endif /* 0 4096 */ result = sfud_erase(sfud_dev, 0, 4096); if (result == SFUD_SUCCESS) { rt_kprintf("Erase success
"); } /* 0 32 , 0x01 */ write_data = rt_malloc(32); rt_memset(write_data, 1, 32); result = sfud_write(sfud_dev, 0, 32, write_data); if (result == SFUD_SUCCESS) { rt_kprintf("Write success.
"); } /* 0 32 */ read_data = rt_malloc(32); result = sfud_read(sfud_dev, 0, 32, read_data); if (result == SFUD_SUCCESS) { rt_kprintf("Read success.
"); } return RT_EOK; }

결실
 \ | /
- RT -     Thread Operating System
 / | \     4.0.3 build Apr 27 2020
 2006 - 2020 Copyright by rt-thread team
[D/drv.qspi] qspi init success!
[SFUD] Find a Winbond flash chip. Size is 16777216 bytes.
[SFUD] W25Q128 flash device is initialize success.
[D/drv.qspi] qspi init success!
Find sfud_dev success, sfud_dev name = W25Q128
msh >Erase success
Write success.
Read success.

좋은 웹페이지 즐겨찾기