mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/driver-w25qxxx.git
synced 2025-06-12 03:25:58 +00:00
Merge branch 'feature/logger' of ssh://git.intern.spaceteamaachen.de:22222/ALPAKA/driver-w25qxxx into feature/logger
This commit is contained in:
commit
e2adee029e
@ -2,6 +2,7 @@
|
|||||||
#define STA_SENSORS_W25Q128_HPP
|
#define STA_SENSORS_W25Q128_HPP
|
||||||
|
|
||||||
#include <sta/bus/spi/device.hpp>
|
#include <sta/bus/spi/device.hpp>
|
||||||
|
//#include <sta/devices/stm32/bus/spi.hpp>
|
||||||
#include <sta/mutex.hpp>
|
#include <sta/mutex.hpp>
|
||||||
|
|
||||||
#include <sta/drivers/w25qxx_defs.hpp>
|
#include <sta/drivers/w25qxx_defs.hpp>
|
||||||
@ -333,4 +334,4 @@ namespace sta
|
|||||||
} // namespace sta
|
} // namespace sta
|
||||||
|
|
||||||
|
|
||||||
#endif // STA_SENSORS_W25Q128_HPP
|
#endif // STA_SENSORS_W25Q128_HPP
|
||||||
|
@ -16,7 +16,7 @@ namespace sta
|
|||||||
ptr_ {0}
|
ptr_ {0}
|
||||||
{
|
{
|
||||||
STA_ASSERT(flash != nullptr);
|
STA_ASSERT(flash != nullptr);
|
||||||
STA_ASSERT(endAddr > startAddr);
|
STA_ASSERT(endSec > startSec);
|
||||||
|
|
||||||
// Jump to the last written page.
|
// Jump to the last written page.
|
||||||
findLast();
|
findLast();
|
||||||
|
@ -22,7 +22,7 @@ namespace sta
|
|||||||
|
|
||||||
uint8_t W25Qxx::init()
|
uint8_t W25Qxx::init()
|
||||||
{
|
{
|
||||||
lock_guard<Mutex>(*mutex_);
|
lock_guard<Mutex>lock(*mutex_);
|
||||||
|
|
||||||
powerDown();
|
powerDown();
|
||||||
delay_(5);
|
delay_(5);
|
||||||
@ -76,7 +76,7 @@ namespace sta
|
|||||||
{
|
{
|
||||||
STA_ASSERT(startAddr <= endAddr);
|
STA_ASSERT(startAddr <= endAddr);
|
||||||
|
|
||||||
lock_guard<Mutex>(*mutex_);
|
lock_guard<Mutex>lock(*mutex_);
|
||||||
uint32_t bytes = getChunkBytes(size);
|
uint32_t bytes = getChunkBytes(size);
|
||||||
|
|
||||||
uint32_t left = startAddr / bytes;
|
uint32_t left = startAddr / bytes;
|
||||||
@ -115,7 +115,7 @@ namespace sta
|
|||||||
|
|
||||||
uint8_t W25Qxx::setAddressMode(AddressMode addrMode)
|
uint8_t W25Qxx::setAddressMode(AddressMode addrMode)
|
||||||
{
|
{
|
||||||
lock_guard<Mutex>(*mutex_);
|
lock_guard<Mutex>lock(*mutex_);
|
||||||
busWrite(W25QXX_4_BYTE_ADDR_ENABLE);
|
busWrite(W25QXX_4_BYTE_ADDR_ENABLE);
|
||||||
|
|
||||||
while (isBusy()) {}
|
while (isBusy()) {}
|
||||||
@ -125,7 +125,7 @@ namespace sta
|
|||||||
|
|
||||||
AddressMode W25Qxx::getAddressMode()
|
AddressMode W25Qxx::getAddressMode()
|
||||||
{
|
{
|
||||||
lock_guard<Mutex>(*mutex_);
|
lock_guard<Mutex>lock(*mutex_);
|
||||||
|
|
||||||
uint8_t status;
|
uint8_t status;
|
||||||
readStatusRegister(3, &status);
|
readStatusRegister(3, &status);
|
||||||
@ -135,7 +135,7 @@ namespace sta
|
|||||||
|
|
||||||
uint8_t W25Qxx::getChipID()
|
uint8_t W25Qxx::getChipID()
|
||||||
{
|
{
|
||||||
lock_guard<Mutex>(*mutex_);
|
lock_guard<Mutex>lock(*mutex_);
|
||||||
|
|
||||||
uint8_t buffer[4];
|
uint8_t buffer[4];
|
||||||
busRead(W25QXX_RELEASE_POWER_DOWN, buffer, 3);
|
busRead(W25QXX_RELEASE_POWER_DOWN, buffer, 3);
|
||||||
@ -145,7 +145,7 @@ namespace sta
|
|||||||
|
|
||||||
uint8_t W25Qxx::getManufacturerID()
|
uint8_t W25Qxx::getManufacturerID()
|
||||||
{
|
{
|
||||||
lock_guard<Mutex>(*mutex_);
|
lock_guard<Mutex>lock(*mutex_);
|
||||||
|
|
||||||
uint8_t dummy[3] = {0, 0, 0};
|
uint8_t dummy[3] = {0, 0, 0};
|
||||||
uint8_t id[2] = {0, 0};
|
uint8_t id[2] = {0, 0};
|
||||||
@ -157,7 +157,7 @@ namespace sta
|
|||||||
|
|
||||||
uint64_t W25Qxx::getUniqueID()
|
uint64_t W25Qxx::getUniqueID()
|
||||||
{
|
{
|
||||||
lock_guard<Mutex>(*mutex_);
|
lock_guard<Mutex>lock(*mutex_);
|
||||||
|
|
||||||
uint8_t dummy[4];
|
uint8_t dummy[4];
|
||||||
uint8_t id[8];
|
uint8_t id[8];
|
||||||
@ -176,7 +176,7 @@ namespace sta
|
|||||||
|
|
||||||
bool W25Qxx::isBusy()
|
bool W25Qxx::isBusy()
|
||||||
{
|
{
|
||||||
lock_guard<Mutex>(*mutex_);
|
lock_guard<Mutex>lock(*mutex_);
|
||||||
|
|
||||||
uint8_t status = 0;
|
uint8_t status = 0;
|
||||||
readStatusRegister(1, &status);
|
readStatusRegister(1, &status);
|
||||||
@ -186,7 +186,7 @@ namespace sta
|
|||||||
|
|
||||||
uint8_t W25Qxx::readData(uint32_t address, uint8_t * buffer, size_t length, bool fast /* = true */)
|
uint8_t W25Qxx::readData(uint32_t address, uint8_t * buffer, size_t length, bool fast /* = true */)
|
||||||
{
|
{
|
||||||
lock_guard<Mutex>(*mutex_);
|
lock_guard<Mutex>lock(*mutex_);
|
||||||
|
|
||||||
uint8_t instruction = fast ? W25QXX_FAST_READ : W25QXX_READ;
|
uint8_t instruction = fast ? W25QXX_FAST_READ : W25QXX_READ;
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ namespace sta
|
|||||||
|
|
||||||
uint8_t W25Qxx::pageProgram(uint32_t address, uint8_t * buffer, size_t length)
|
uint8_t W25Qxx::pageProgram(uint32_t address, uint8_t * buffer, size_t length)
|
||||||
{
|
{
|
||||||
lock_guard<Mutex>(*mutex_);
|
lock_guard<Mutex>lock(*mutex_);
|
||||||
|
|
||||||
STA_ASSERT(length <= W25QXX_PAGE_SIZE);
|
STA_ASSERT(length <= W25QXX_PAGE_SIZE);
|
||||||
while (isBusy()) {}
|
while (isBusy()) {}
|
||||||
@ -275,7 +275,7 @@ namespace sta
|
|||||||
|
|
||||||
uint8_t W25Qxx::sectorProgram(uint32_t address, uint8_t * buffer, size_t length)
|
uint8_t W25Qxx::sectorProgram(uint32_t address, uint8_t * buffer, size_t length)
|
||||||
{
|
{
|
||||||
lock_guard<Mutex>(*mutex_);
|
lock_guard<Mutex>lock(*mutex_);
|
||||||
|
|
||||||
STA_ASSERT(length <= W25QXX_SECTOR_SIZE);
|
STA_ASSERT(length <= W25QXX_SECTOR_SIZE);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user