Skip to content

Commit

Permalink
added demo entry for arduino
Browse files Browse the repository at this point in the history
  • Loading branch information
FT9R committed Mar 27, 2024
1 parent dd36302 commit 704c6e4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
10 changes: 8 additions & 2 deletions Examples/ArduinoNano/ArduinoNano.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ void setup() {
IO_Init();
Timer2_Init();
Serial.begin(9600);
if (!Serial)
Error_Handler();
SPI.begin();
SPI.beginTransaction(SPISettings(1e5, MSBFIRST, SPI_MODE0));
sei();

Serial.println("Type \"begin\" for demo");
while (true) {
String response = Serial.readString();

if (response == "begin\n")
break;
}
}

void loop() {
Expand Down
6 changes: 3 additions & 3 deletions Examples/ArduinoNano/w25qxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void w25qxx_Read(w25qxx_HandleTypeDef *w25qxx_Handle, uint8_t *buf, uint16_t dat
W25QXX_ERROR_SET(W25QXX_ERROR_ADDRESS);

/* Command */
w25qxx_Handle->CMD = fastRead ? W25QXX_CMD_FAST_READ : W25QXX_CMD_READ_DATA;
w25qxx_Handle->CMD = (fastRead == W25QXX_FASTREAD) ? W25QXX_CMD_FAST_READ : W25QXX_CMD_READ_DATA;
w25qxx_Handle->interface.CS_Set(W25QXX_CS_LOW);
W25QXX_BEGIN_TRASMIT(&w25qxx_Handle->CMD, sizeof(w25qxx_Handle->CMD), W25QXX_TX_TIMEOUT);

Expand All @@ -230,7 +230,7 @@ void w25qxx_Read(w25qxx_HandleTypeDef *w25qxx_Handle, uint8_t *buf, uint16_t dat
W25QXX_BEGIN_TRASMIT(w25qxx_Handle->addressBytes, sizeof(w25qxx_Handle->addressBytes), W25QXX_TX_TIMEOUT);

/* 8 dummy clocks */
if (fastRead)
if (fastRead == W25QXX_FASTREAD)
W25QXX_BEGIN_TRASMIT(&w25qxx_Handle->CMD, sizeof(w25qxx_Handle->CMD), W25QXX_TX_TIMEOUT);

/* Data receive */
Expand Down Expand Up @@ -505,7 +505,7 @@ void w25qxx_WriteStatus(w25qxx_HandleTypeDef *w25qxx_Handle, uint8_t statusRegis
w25qxx_Handle->interface.CS_Set(W25QXX_CS_HIGH);

/* Task wait */
if (statusRegisterBehaviour == W25QXX_SR_NONVOLATILE)
if (statusRegisterBehaviour != W25QXX_SR_VOLATILE)
{
if (w25qxx_WaitWithTimeout(w25qxx_Handle, W25QXX_WRITE_STATUS_REGISTER_TIME) != W25QXX_STATUS_READY)
W25QXX_ERROR_SET(W25QXX_ERROR_TIMEOUT);
Expand Down
6 changes: 3 additions & 3 deletions Examples/ArduinoNano/w25qxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ enum w25qxx_Device_e { W25Q80 = 0x13, W25Q16, W25Q32, W25Q64, W25Q128 };
/* Data types */
typedef enum w25qxx_WaitForTask_e { W25QXX_WAIT_NO, W25QXX_WAIT_DELAY, W25QXX_WAIT_BUSY } w25qxx_WaitForTask_t;

typedef enum w25qxx_CRC_e { W25QXX_CRC, W25QXX_CRC_NO } w25qxx_CRC_t;
typedef enum w25qxx_CRC_e { W25QXX_CRC_NO, W25QXX_CRC } w25qxx_CRC_t;

typedef enum w25qxx_FastRead_e { W25QXX_FASTREAD, W25QXX_FASTREAD_NO } w25qxx_FastRead_t;
typedef enum w25qxx_FastRead_e { W25QXX_FASTREAD_NO, W25QXX_FASTREAD } w25qxx_FastRead_t;

typedef enum w25qxx_SR_Behaviour_e { W25QXX_SR_VOLATILE, W25QXX_SR_NONVOLATILE } w25qxx_SR_Behaviour_t;
typedef enum w25qxx_SR_Behaviour_e { W25QXX_SR_NONVOLATILE, W25QXX_SR_VOLATILE } w25qxx_SR_Behaviour_t;

typedef enum w25qxx_EraseInstruction_e {
W25QXX_SECTOR_ERASE_4KB,
Expand Down
2 changes: 1 addition & 1 deletion Examples/ArduinoNano/w25qxx_Demo.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "w25qxx.h"

#define DEMO_TARGET_PAGE 15
#define DEMO_TARGET_PAGE 31

#ifdef __cplusplus
extern "C" {
Expand Down

0 comments on commit 704c6e4

Please sign in to comment.