Skip to content

Commit

Permalink
ERROR_CHECK macro edit
Browse files Browse the repository at this point in the history
  • Loading branch information
FT9R committed May 22, 2024
1 parent 5b5dd92 commit c9cb27f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions w25qxx/w25qxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ w25qxx_Error_t w25qxx_Init(w25qxx_HandleTypeDef *w25qxx_Handle)
w25qxx_Handle->interface.Delay(100);

w25qxx_ReleasePowerDown(w25qxx_Handle);
W25QXX_ERROR_CHECK(W25QXX_ERROR_INITIALIZATION);
W25QXX_ERROR_CHECK;

w25qxx_ResetDevice(w25qxx_Handle);
W25QXX_ERROR_CHECK(W25QXX_ERROR_INITIALIZATION);
W25QXX_ERROR_CHECK;

/* Get the Manufacturer ID and Device ID */
w25qxx_ReadID(w25qxx_Handle);
W25QXX_ERROR_CHECK(W25QXX_ERROR_INITIALIZATION);
W25QXX_ERROR_CHECK;
if (w25qxx_Handle->ID[0] != W25QXX_MANUFACTURER_ID)
W25QXX_ERROR_SET(W25QXX_ERROR_INITIALIZATION);

Expand Down Expand Up @@ -132,7 +132,7 @@ w25qxx_Error_t w25qxx_Write(w25qxx_HandleTypeDef *w25qxx_Handle, const uint8_t *

/* Command */
w25qxx_WriteEnable(w25qxx_Handle);
W25QXX_ERROR_CHECK(W25QXX_ERROR_SPI);
W25QXX_ERROR_CHECK;
w25qxx_Handle->CMD = W25QXX_CMD_PAGE_PROGRAM;
w25qxx_Handle->interface.CS_Set(W25QXX_CS_LOW);
W25QXX_BEGIN_TRASMIT(&w25qxx_Handle->CMD, sizeof(w25qxx_Handle->CMD), W25QXX_TX_TIMEOUT);
Expand Down Expand Up @@ -250,7 +250,7 @@ w25qxx_Error_t w25qxx_Erase(w25qxx_HandleTypeDef *w25qxx_Handle, w25qxx_EraseIns

/* Command */
w25qxx_WriteEnable(w25qxx_Handle);
W25QXX_ERROR_CHECK(W25QXX_ERROR_SPI);
W25QXX_ERROR_CHECK;
w25qxx_Handle->CMD = W25QXX_CMD_SECTOR_ERASE_4KB;
w25qxx_Handle->interface.CS_Set(W25QXX_CS_LOW);
W25QXX_BEGIN_TRASMIT(&w25qxx_Handle->CMD, sizeof(w25qxx_Handle->CMD), W25QXX_TX_TIMEOUT);
Expand Down Expand Up @@ -289,7 +289,7 @@ w25qxx_Error_t w25qxx_Erase(w25qxx_HandleTypeDef *w25qxx_Handle, w25qxx_EraseIns

/* Command */
w25qxx_WriteEnable(w25qxx_Handle);
W25QXX_ERROR_CHECK(W25QXX_ERROR_SPI);
W25QXX_ERROR_CHECK;
w25qxx_Handle->CMD = W25QXX_CMD_BLOCK_ERASE_32KB;
w25qxx_Handle->interface.CS_Set(W25QXX_CS_LOW);
W25QXX_BEGIN_TRASMIT(&w25qxx_Handle->CMD, sizeof(w25qxx_Handle->CMD), W25QXX_TX_TIMEOUT);
Expand Down Expand Up @@ -328,7 +328,7 @@ w25qxx_Error_t w25qxx_Erase(w25qxx_HandleTypeDef *w25qxx_Handle, w25qxx_EraseIns

/* Command */
w25qxx_WriteEnable(w25qxx_Handle);
W25QXX_ERROR_CHECK(W25QXX_ERROR_SPI);
W25QXX_ERROR_CHECK;
w25qxx_Handle->CMD = W25QXX_CMD_BLOCK_ERASE_64KB;
w25qxx_Handle->interface.CS_Set(W25QXX_CS_LOW);
W25QXX_BEGIN_TRASMIT(&w25qxx_Handle->CMD, sizeof(w25qxx_Handle->CMD), W25QXX_TX_TIMEOUT);
Expand Down Expand Up @@ -389,7 +389,7 @@ w25qxx_Error_t w25qxx_Erase(w25qxx_HandleTypeDef *w25qxx_Handle, w25qxx_EraseIns

/* Command */
w25qxx_WriteEnable(w25qxx_Handle);
W25QXX_ERROR_CHECK(W25QXX_ERROR_SPI);
W25QXX_ERROR_CHECK;
w25qxx_Handle->CMD = W25QXX_CMD_CHIP_ERASE;
w25qxx_Handle->interface.CS_Set(W25QXX_CS_LOW);
W25QXX_BEGIN_TRASMIT(&w25qxx_Handle->CMD, sizeof(w25qxx_Handle->CMD), W25QXX_TX_TIMEOUT);
Expand Down
4 changes: 2 additions & 2 deletions w25qxx/w25qxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ enum w25qxx_Device_e { W25Q80 = 0x13, W25Q16, W25Q32, W25Q64, W25Q128 };
} \
while (0)

#define W25QXX_ERROR_CHECK(W25QXX_ERROR) \
#define W25QXX_ERROR_CHECK \
do \
{ \
if (w25qxx_Handle->error != W25QXX_ERROR_NONE) \
W25QXX_ERROR_SET((W25QXX_ERROR)); \
W25QXX_ERROR_SET(w25qxx_Handle->error); \
} \
while (0)

Expand Down

0 comments on commit c9cb27f

Please sign in to comment.