mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/driver-w25qxxx.git
synced 2025-08-02 04:21:54 +00:00
Added delay function to driver
This commit is contained in:
parent
b6122a2dd8
commit
ad76f8e12f
@ -40,13 +40,18 @@ namespace sta
|
||||
class W25Qxx
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Signature for delay msec function.
|
||||
*/
|
||||
using DelayUsFunc = void (*)(uint32_t);
|
||||
|
||||
/**
|
||||
* @brief Construct a new W25Qxx object
|
||||
*
|
||||
* @param device
|
||||
* @param addrMode
|
||||
*/
|
||||
W25Qxx(SPIDevice * device, AddressMode addrMode = AddressMode::_24BIT);
|
||||
W25Qxx(SPIDevice * device, DelayUsFunc delay, AddressMode addrMode = AddressMode::_24BIT);
|
||||
|
||||
uint8_t init();
|
||||
|
||||
@ -251,7 +256,7 @@ namespace sta
|
||||
* @param arg_length
|
||||
* @return uint8_t
|
||||
*/
|
||||
uint8_t busWrite(uint8_t instruction, const uint8_t * data = nullptr, size_t length = 0, uint8_t * arguments = nullptr, size_t arg_length = 0);
|
||||
uint8_t busWrite(uint8_t instruction, const uint8_t * data = nullptr, size_t length = 0, uint8_t * arguments = nullptr, size_t arg_length = 0, uint32_t delayCsHigh = 0);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
@ -280,6 +285,7 @@ namespace sta
|
||||
|
||||
private:
|
||||
SPIDevice * device_;
|
||||
DelayUsFunc delay_;
|
||||
ChipState state_;
|
||||
AddressMode addrMode_;
|
||||
};
|
||||
|
@ -7,8 +7,9 @@
|
||||
|
||||
namespace sta
|
||||
{
|
||||
W25Qxx::W25Qxx(SPIDevice * device, AddressMode addrMode /* = AddressMode::_24BIT */)
|
||||
W25Qxx::W25Qxx(SPIDevice * device, DelayUsFunc delay, AddressMode addrMode /* = AddressMode::_24BIT */)
|
||||
: device_{device},
|
||||
delay_{delay},
|
||||
state_{ChipState::POWERED_DOWN},
|
||||
addrMode_{addrMode}
|
||||
{
|
||||
@ -18,6 +19,7 @@ namespace sta
|
||||
uint8_t W25Qxx::init()
|
||||
{
|
||||
powerDown();
|
||||
delay_(3);
|
||||
|
||||
if (!releasePowerDown())
|
||||
{
|
||||
@ -172,7 +174,7 @@ namespace sta
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t W25Qxx::busWrite(uint8_t instruction, const uint8_t * data /* = nullptr */, size_t length /* = 0 */, uint8_t * arguments /* = nullptr */, size_t arg_length /* = 0 */)
|
||||
uint8_t W25Qxx::busWrite(uint8_t instruction, const uint8_t * data /* = nullptr */, size_t length /* = 0 */, uint8_t * arguments /* = nullptr */, size_t arg_length /* = 0 */, uint32_t delayCsHigh /*= 0 */)
|
||||
{
|
||||
device_->beginTransmission();
|
||||
|
||||
@ -191,6 +193,11 @@ namespace sta
|
||||
device_->transfer(data, length);
|
||||
}
|
||||
|
||||
if (delayCsHigh != 0)
|
||||
{
|
||||
delay_(2);
|
||||
}
|
||||
|
||||
device_->endTransmission();
|
||||
|
||||
return 1;
|
||||
@ -396,7 +403,7 @@ namespace sta
|
||||
{
|
||||
if (state_ == ChipState::POWERED_DOWN)
|
||||
{
|
||||
return busWrite(W25QXX_RELEASE_POWER_DOWN);
|
||||
return busWrite(W25QXX_RELEASE_POWER_DOWN, nullptr, 0, nullptr, 0, 2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user