mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/driver-w25qxxx.git
synced 2025-06-13 03:35:59 +00:00
small buxfix for manufacturer read
This commit is contained in:
parent
517510c204
commit
ebbcd79fb9
@ -1,7 +1,9 @@
|
|||||||
#include <sta/sensors/w25qxx.hpp>
|
#include <sta/sensors/w25qxx.hpp>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <sta/debug/assert.hpp>
|
#include <sta/debug/assert.hpp>
|
||||||
|
#include <sta/debug/debug.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace sta
|
namespace sta
|
||||||
@ -30,10 +32,10 @@ namespace sta
|
|||||||
|
|
||||||
uint8_t W25Qxx::getManufacturerID()
|
uint8_t W25Qxx::getManufacturerID()
|
||||||
{
|
{
|
||||||
Address24 address = {0};
|
uint8_t dummy[3] = {0, 0, 0};
|
||||||
|
|
||||||
uint8_t id;
|
uint8_t id;
|
||||||
busRead(W25QXX_JEDEC_ID, &id, 1, address.buffer, 3);
|
|
||||||
|
busRead(W25QXX_JEDEC_ID, &id, 1, dummy, 3);
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -43,9 +45,11 @@ namespace sta
|
|||||||
uint8_t dummy[4];
|
uint8_t dummy[4];
|
||||||
uint8_t id[8];
|
uint8_t id[8];
|
||||||
|
|
||||||
|
STA_DEBUG_PRINTLN("Before crash?");
|
||||||
|
|
||||||
busRead(W25QXX_READ_UNIQUE_ID, id, 8, dummy, 4);
|
busRead(W25QXX_READ_UNIQUE_ID, id, 8, dummy, 4);
|
||||||
|
|
||||||
uint64_t id_complete;
|
uint64_t id_complete = 0;
|
||||||
|
|
||||||
for (size_t i; i < 8; i++)
|
for (size_t i; i < 8; i++)
|
||||||
{
|
{
|
||||||
@ -99,11 +103,49 @@ 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 */)
|
||||||
{
|
{
|
||||||
|
device_->beginTransmission();
|
||||||
|
|
||||||
|
// Send the instruction.
|
||||||
|
device_->transfer(instruction);
|
||||||
|
|
||||||
|
// If requested, send argument bytes before the actual data.
|
||||||
|
if (arguments != nullptr && arg_length != 0)
|
||||||
|
{
|
||||||
|
device_->transfer(arguments, arg_length);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the actual data bytes.
|
||||||
|
device_->transfer(data, length);
|
||||||
|
|
||||||
|
device_->endTransmission();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t W25Qxx::busRead(uint8_t instruction, uint8_t * data, size_t length, uint8_t * arguments /* = nullptr */, size_t arg_length /* = 0 */)
|
uint8_t W25Qxx::busRead(uint8_t instruction, uint8_t * data, size_t length, uint8_t * arguments /* = nullptr */, size_t arg_length /* = 0 */)
|
||||||
{
|
{
|
||||||
|
device_->beginTransmission();
|
||||||
|
|
||||||
|
STA_DEBUG_PRINTLN("MAYBE HERE?");
|
||||||
|
|
||||||
|
// Send the instruction.
|
||||||
|
device_->transfer(instruction);
|
||||||
|
|
||||||
|
STA_DEBUG_PRINTLN("OR HERE?");
|
||||||
|
|
||||||
|
// If requested, send argument bytes before receiving the actual data.
|
||||||
|
if (arguments != nullptr && arg_length != 0)
|
||||||
|
{
|
||||||
|
device_->transfer(arguments, arg_length);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the actual data bytes.
|
||||||
|
device_->receive(data, length);
|
||||||
|
|
||||||
|
device_->endTransmission();
|
||||||
|
|
||||||
|
STA_DEBUG_PRINTLN("STILL ALIVE?");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user