SPIFlash庫

出自YFRobotwiki
跳轉到: 導覽搜尋


小編奮力編輯中....


SPIFlash庫 -- SPI華邦電子閃存Flash芯片arduino庫 GITHUB 工程地址:SPIFlash

該庫是用於華邦串行閃存芯片的庫。目前的形式支持識別閃存芯片和它的各種功能;自動地址分配管理;在不同位置讀寫數據類型bytes/chars/ints/longs/floats/Strings;讀寫頁面字節;連續讀寫字節/字符數組;扇區,塊或整個芯片的擦除,關閉低功率操作。

支持arduino IDE 版本:

  • IDE v1.5.x
  • IDE v1.6.0-v1.6.5
  • IDE v1.6.9-v1.6.11

支持控制板:

  • Arduino Uno
  • Arduino Leonardo
  • Arduino Micro
  • Arduino Fio
  • Arduino Mega
  • Arduino Due
  • ESP8266 (On the Arduino IDE)
  • ATTiny85


示例


- Diagnostics: For a full diagnostics rundown - with error codes and details of the errors./有關完整診斷程序 - 包含錯誤代碼和錯誤詳細信息
- Struct_writer: This program writes a struct to a random location on your flash memory chip and reads it back./這個程序寫一個struct到閃存芯片的隨機位置然後讀取它。
- TestFlash: The Test program show all most function./測試程序演示大部分功能函數
- getAddressEx: This program shows the method to use the getAddress() function to automate the process of address allocation when using a flash memory module. Please note the special function used to get the size of the String object./這個程序演示了使用getAddress()函數自動地址配置的過程在使用閃存模塊。 請注意特殊函數使用字符串對象的大小。

- readWriteString: This program shows the method of reading a string from the console and saving it to flash memory./這個程序演示了閱讀一個字符串從控制台並保存到閃存

SPIFlash

SPIFlash 函數。

- begin() -- 初始化
參數:無
返回:無
- error() -- 檢查錯誤
參數:無
返回:uint8_t
- getCapacity() -- 獲取芯片容量
參數:無
返回:uint32_t
- getMaxPage() -- 獲取最大頁數
參數:無
返回:uint32_t
- getChipName() -- 獲取芯片識別名稱
參數:無
返回:uint16_t


- getManID() -- 檢查和啟動芯片並獲取16位int型製造商ID
參數:無
返回:uint16_t
- getJEDECID() -- 檢查和啟動芯片並獲取32位int型 JEDEC ID
參數:無
返回:uint32_t


-- 獲取下一個可用地址使用: -- A.以數據的大小作為參數,並返回一個32位的地址 -- B.3個參數,數據大小、頁數及位置 -- 所有地址的素描必須獲得通過該函數或不

- getAddress(uint16_t size) -- A
參數:size - 數據大小
返回:uint32_t
- getAddress(uint16_t size, uint16_t &page_number, uint8_t &offset) -- B
參數:
  • size -
  • &page_number -
  • &offset -
返回:bool
- sizeofStr(String &inputStr) -- 函數返回字符串的大小(僅用於getAddress()函數)
參數:inputStr - 字符串
返回:uint16_t


-- 從一個頁面的特定位置讀一個字節的數據 -- A & B

- readByte(uint32_t address, bool fastRead) -- A
參數:
  • address - 地址(0 - 最大存儲地址)
  • fastRead - 默認為false( 如果設置為true將執行 _beginFastRead() )
返回:uint8_t
- readByte(uint16_t page_number, uint8_t offset, bool fastRead) -- B
參數:
  • page_number - 頁數(0-最大頁數)
  • offset - 頁面中的地址(0-255)
  • fastRead - 默認為false( 如果設置為true將執行 _beginFastRead() )
返回:uint8_t


-- 從一個頁面的特定位置讀一個字符的數據 -- A & B

- readChar(uint32_t address, bool fastRead) -- A
參數:
  • address - 地址(0 - 最大存儲地址)
  • fastRead - 默認為false( 如果設置為true將執行 _beginFastRead() )
返回:int8_t
- readChar(uint16_t page_number, uint8_t offset, bool fastRead) -- B
參數:
  • page_number - 頁數(0-最大頁數)
  • offset - 頁面中的地址(0-255)
  • fastRead - 默認為false( 如果設置為true將執行 _beginFastRead() )
返回:int8_t


-- 從一個頁面的特定位置讀一個字節數組的數據 -- A & B

- readByteArray(uint32_t address, uint8_t *data_buffer, uint16_t bufferSize, bool fastRead) -- A
參數:
  • address - 地址(0 - 最大存儲地址)
  • data_buffer - 讀取的數據
  • bufferSize - 讀取數據大小
  • fastRead - 默認為false( 如果設置為true將執行 _beginFastRead() )
返回:bool
- readByteArray(uint16_t page_number, uint8_t offset, uint8_t *data_buffer, uint16_t bufferSize, bool fastRead) -- B
參數:
  • page_number - 頁數(0-最大頁數)
  • offset - 頁面中的地址(0-255)
  • data_buffer - 讀取的數據
  • bufferSize - 讀取數據大小
  • fastRead - 默認為false( 如果設置為true將執行 _beginFastRead() )
返回:bool


-- 從一個頁面的特定位置讀一個字符數組的數據 -- A & B

- readCharArray(uint32_t address, uint8_t *data_buffer, uint16_t bufferSize, bool fastRead) -- A
參數:
  • address - 地址(0 - 最大存儲地址)
  • data_buffer - 讀取的數據
  • bufferSize - 讀取數據大小
  • fastRead - 默認為false( 如果設置為true將執行 _beginFastRead() )
返回:bool
- readCharArray(uint16_t page_number, uint8_t offset, uint8_t *data_buffer, uint16_t bufferSize, bool fastRead) -- B
參數:
  • page_number - 頁數(0-最大頁數)
  • offset - 頁面中的地址(0-255)
  • data_buffer - 讀取的數據
  • bufferSize - 讀取數據大小
  • fastRead - 默認為false( 如果設置為true將執行 _beginFastRead() )
返回:bool


-- 從一個頁面的特定位置讀一個無符號整型(unsigned int)數據 -- A & B

- readWord(uint32_t address, bool fastRead) -- A
參數:
  • address - 地址(0 - 最大存儲地址)
  • fastRead - 默認為false( 如果設置為true將執行 _beginFastRead() )
返回:uint16_t
- readWord(uint16_t page_number, uint8_t offset, bool fastRead) -- B
參數:
  • page_number - 頁數(0-最大頁數)
  • offset - 頁面中的地址(0-255)
  • fastRead - 默認為false( 如果設置為true將執行 _beginFastRead() )
返回:uint16_t


-- 從一個頁面的特定位置讀一個整型(int)數據 -- A & B

- readShort(uint32_t address, bool fastRead) -- A
參數:
  • address - 地址(0 - 最大存儲地址)
  • fastRead - 默認為false( 如果設置為true將執行 _beginFastRead() )
返回:int16_t
- readShort(uint16_t page_number, uint8_t offset, bool fastRead) -- B
參數:
  • page_number - 頁數(0-最大頁數)
  • offset - 頁面中的地址(0-255)
  • fastRead - 默認為false( 如果設置為true將執行 _beginFastRead() )
返回:int16_t


-- 從一個頁面的特定位置讀一個無符號長整型(unsigned long)數據 -- A & B

- readULong(uint32_t address, bool fastRead) -- A
參數:
  • address - 地址(0 - 最大存儲地址)
  • fastRead - 默認為false( 如果設置為true將執行 _beginFastRead() )
返回:uint32_t
- readULong(uint16_t page_number, uint8_t offset, bool fastRead) -- B
參數:
  • page_number - 頁數(0-最大頁數)
  • offset - 頁面中的地址(0-255)
  • fastRead - 默認為false( 如果設置為true將執行 _beginFastRead() )
返回:uint32_t


-- 從一個頁面的特定位置讀一個長整型(long)數據 -- A & B

- readLong(uint32_t address, bool fastRead) -- A
參數:
  • address - 地址(0 - 最大存儲地址)
  • fastRead - 默認為false( 如果設置為true將執行 _beginFastRead() )
返回:int32_t
- readLong(uint16_t page_number, uint8_t offset, bool fastRead) -- B
參數:
  • page_number - 頁數(0-最大頁數)
  • offset - 頁面中的地址(0-255)
  • fastRead - 默認為false( 如果設置為true將執行 _beginFastRead() )
返回:int32_t


-- 從一個頁面的特定位置讀一個浮點(float)數據 ?? -- A & B

- readFloat(uint32_t address, bool fastRead) -- A
參數:
  • address - 地址(0 - 最大存儲地址)
  • fastRead - 默認為false( 如果設置為true將執行 _beginFastRead() )
返回:float
- readFloat(uint16_t page_number, uint8_t offset, bool fastRead) -- B
參數:
  • page_number - 頁數(0-最大頁數)
  • offset - 頁面中的地址(0-255)
  • fastRead - 默認為false( 如果設置為true將執行 _beginFastRead() )
返回:float


-- 從一個頁面的特定位置讀一個字符串(string)數據 -- A & B

- readStr(uint32_t address, String &outStr, bool fastRead) -- A
參數:
  • address - 地址(0 - 最大存儲地址)
  • outputString --> 字符串
  • fastRead - 默認為false( 如果設置為true將執行 _beginFastRead() )
返回:bool
- readStr(uint16_t page_number, uint8_t offset, String &outStr, bool fastRead) -- B
參數:
  • page_number - 頁數(0-最大頁數)
  • offset - 頁面中的地址(0-255)
  • outputString --> 字符串
  • fastRead - 默認為false( 如果設置為true將執行 _beginFastRead() )
返回:bool


-- 寫一個字節(byte)數據到一個頁面的特定位置 -- A & B -- 提示:寫數據之前需要清除存儲位置

- writeByte(uint32_t address, uint8_t data, bool errorCheck) -- A
參數:
  • address - 地址(0 - 最大存儲地址)
  • data - 寫入的數據(0-255)
  • errorCheck - 默認true,檢查是否寫入
返回:bool
- writeByte(uint16_t page_number, uint8_t offset, uint8_t data, bool errorCheck) -- B
參數:
  • page_number - 頁數(0-最大頁數)
  • offset - 頁面中的地址(0-255)
  • data - 寫入的數據(0-255)
  • errorCheck - 默認true,檢查是否寫入
返回:bool


-- 寫一個字符(char)數據到一個頁面的特定位置 -- A & B -- 提示:寫數據之前需要清除存儲位置

- writeChar(uint32_t address, int8_t data, bool errorCheck) -- A
參數:
  • address - 地址(0 - 最大存儲地址)
  • data - 寫入的數據(0-255)
  • errorCheck - 默認true,檢查是否寫入
返回:bool
- writeChar(uint16_t page_number, uint8_t offset, int8_t data, bool errorCheck) -- B
參數:
  • page_number - 頁數(0-最大頁數)
  • offset - 頁面中的地址(0-255)
  • data - 寫入的數據(0-255)
  • errorCheck - 默認true,檢查是否寫入
返回:bool

-- 寫一組字節數組數據從一個頁面的特定位置 -- A & B -- 提示:寫數據之前需要清除存儲位置

- writeByteArray(uint32_t address, uint8_t *data_buffer, uint16_t bufferSize, bool errorCheck) -- A
參數:
  • address - 地址(0 - 最大存儲地址)
  • data - 寫入的數據(0-255)
  • errorCheck - 默認true,檢查是否寫入
返回:bool
- writeByteArray(uint16_t page_number, uint8_t offset, uint8_t *data_buffer, uint16_t bufferSize, bool errorCheck) -- B
參數:
  • page_number - 頁數(0-最大頁數)
  • offset - 頁面中的地址(0-255)
  • data - 寫入的數據(0-255)
  • errorCheck - 默認true,檢查是否寫入
返回:bool












- getMaxPage() -- 檢查錯誤
參數:無
返回:uint32_t
- getMaxPage() -- 檢查錯誤
參數:無
返回:uint32_t


- getMaxPage() -- 檢查錯誤
參數:無
返回:uint32_t
- getMaxPage() -- 檢查錯誤
參數:無
返回:uint32_t





返回語音模塊

返回Arduino庫菜單

返回首頁

更多建議和問題歡迎反饋至 YFRobot論壇