{
int result;
-#if defined USE_OLD_SPI_SW
- /**
- * Command
- **/
- result = spi_cmd(CMD_INTERNAL_WRITE, adr, dat, 4, 0);
- if (result != N_OK) {
- PRINT_ER("[wilc spi]: Failed internal write cmd...\n");
- return 0;
- }
-
- result = spi_cmd_rsp(CMD_INTERNAL_WRITE, 0);
- if (result != N_OK) {
- PRINT_ER("[wilc spi]: Failed internal write cmd response...\n");
- }
-#else
-
#ifdef BIG_ENDIAN
dat = BYTE_SWAP(dat);
#endif
PRINT_ER("[wilc spi]: Failed internal write cmd...\n");
}
-#endif
return result;
}
{
int result;
-#if defined USE_OLD_SPI_SW
- result = spi_cmd(CMD_INTERNAL_READ, adr, 0, 4, 0);
- if (result != N_OK) {
- PRINT_ER("[wilc spi]: Failed internal read cmd...\n");
- return 0;
- }
-
- result = spi_cmd_rsp(CMD_INTERNAL_READ, 0);
- if (result != N_OK) {
- PRINT_ER("[wilc spi]: Failed internal read cmd response...\n");
- return 0;
- }
-
- /**
- * Data
- **/
- result = spi_data_read((u8 *)data, 4);
- if (result != N_OK) {
- PRINT_ER("[wilc spi]: Failed internal read data...\n");
- return 0;
- }
-#else
result = spi_cmd_complete(CMD_INTERNAL_READ, adr, (u8 *)data, 4, 0);
if (result != N_OK) {
PRINT_ER("[wilc spi]: Failed internal read cmd...\n");
return 0;
}
-#endif
-
#ifdef BIG_ENDIAN
*data = BYTE_SWAP(*data);
u8 cmd = CMD_SINGLE_WRITE;
u8 clockless = 0;
-
-#if defined USE_OLD_SPI_SW
- {
- result = spi_cmd(cmd, addr, data, 4, 0);
- if (result != N_OK) {
- PRINT_ER("[wilc spi]: Failed cmd, write reg (%08x)...\n", addr);
- return 0;
- }
-
- result = spi_cmd_rsp(cmd, 0);
- if (result != N_OK) {
- PRINT_ER("[wilc spi]: Failed cmd response, write reg (%08x)...\n", addr);
- return 0;
- }
-
- return 1;
- }
-#else
#ifdef BIG_ENDIAN
data = BYTE_SWAP(data);
#endif
}
return result;
-#endif
-
}
static int spi_write(u32 addr, u8 *buf, u32 size)
if (size <= 4)
return 0;
-#if defined USE_OLD_SPI_SW
- /**
- * Command
- **/
- result = spi_cmd(cmd, addr, 0, size, 0);
- if (result != N_OK) {
- PRINT_ER("[wilc spi]: Failed cmd, write block (%08x)...\n", addr);
- return 0;
- }
-
- result = spi_cmd_rsp(cmd, 0);
- if (result != N_OK) {
- PRINT_ER("[wilc spi ]: Failed cmd response, write block (%08x)...\n", addr);
- return 0;
- }
-#else
result = spi_cmd_complete(cmd, addr, NULL, size, 0);
if (result != N_OK) {
PRINT_ER("[wilc spi]: Failed cmd, write block (%08x)...\n", addr);
return 0;
}
-#endif
/**
* Data
u8 cmd = CMD_SINGLE_READ;
u8 clockless = 0;
-#if defined USE_OLD_SPI_SW
- result = spi_cmd(cmd, addr, 0, 4, 0);
- if (result != N_OK) {
- PRINT_ER("[wilc spi]: Failed cmd, read reg (%08x)...\n", addr);
- return 0;
- }
- result = spi_cmd_rsp(cmd, 0);
- if (result != N_OK) {
- PRINT_ER("[wilc spi]: Failed cmd response, read reg (%08x)...\n", addr);
- return 0;
- }
-
- result = spi_data_read((u8 *)data, 4);
- if (result != N_OK) {
- PRINT_ER("[wilc spi]: Failed data read...\n");
- return 0;
- }
-#else
if (addr < 0x30) {
/* PRINT_ER("***** read addr %d\n\n", addr); */
/* Clockless register*/
PRINT_ER("[wilc spi]: Failed cmd, read reg (%08x)...\n", addr);
return 0;
}
-#endif
-
#ifdef BIG_ENDIAN
*data = BYTE_SWAP(*data);
if (size <= 4)
return 0;
-#if defined USE_OLD_SPI_SW
- /**
- * Command
- **/
- result = spi_cmd(cmd, addr, 0, size, 0);
- if (result != N_OK) {
- PRINT_ER("[wilc spi]: Failed cmd, read block (%08x)...\n", addr);
- return 0;
- }
-
- result = spi_cmd_rsp(cmd, 0);
- if (result != N_OK) {
- PRINT_ER("[wilc spi]: Failed cmd response, read block (%08x)...\n", addr);
- return 0;
- }
-
- /**
- * Data
- **/
- result = spi_data_read(buf, size);
- if (result != N_OK) {
- PRINT_ER("[wilc spi]: Failed block data read...\n");
- return 0;
- }
-#else
result = spi_cmd_complete(cmd, addr, buf, size, 0);
if (result != N_OK) {
PRINT_ER("[wilc spi]: Failed cmd, read block (%08x)...\n", addr);
return 0;
}
-#endif
-
return 1;
}