Hi,
I am using the project from Javakys, which can be found here:
github.com/javakys/W5500_STM32F4_SPI_DMA
I have moved it to use the STM32F2xx MCU and have a small problem as the programm stop at this funktion in the
winzip_conf.c source in line 240
while(!(WIZCHIP.if_mode & WIZCHIP_IO_MODE_SPI));
void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb))
{
while(!(WIZCHIP.if_mode & _WIZCHIP_IO_MODE_SPI_));
if(!spi_rb || !spi_wb)
{
WIZCHIP.IF.SPI._read_byte = wizchip_spi_readbyte;
WIZCHIP.IF.SPI._write_byte = wizchip_spi_writebyte;
}
else
{
WIZCHIP.IF.SPI._read_byte = spi_rb;
WIZCHIP.IF.SPI._write_byte = spi_wb;
}
}
If debugging I am getting for
WIZCHIP.if_mode = 0
WIZCHIP_IO_MODE_SPI_ =512
spi_rb =-1
spi_wb =-1
Any help on that?
Best regards
Christian
Hi,
I think that your problem caused by WIZCHIP_IO_MODE didn’t define WIZCHIP_IO_MODE_SPI.
WIZCHIP_IO_MODE is defined in wizchip_conf.h
#elif (_WIZCHIP_ == 5500)
#define _WIZCHIP_ID_ "W5500\0"
/**
* @brief Define interface mode. \n
* @todo Should select interface mode as chip.
* - @ref \_WIZCHIP_IO_MODE_SPI_ \n
* -@ref \_WIZCHIP_IO_MODE_SPI_VDM_ : Valid only in @ref \_WIZCHIP_ == 5500 \n
* -@ref \_WIZCHIP_IO_MODE_SPI_FDM_ : Valid only in @ref \_WIZCHIP_ == 5500 \n
* - @ref \_WIZCHIP_IO_MODE_BUS_ \n
* - @ref \_WIZCHIP_IO_MODE_BUS_DIR_ \n
* - @ref \_WIZCHIP_IO_MODE_BUS_INDIR_ \n
* - Others will be defined in future. \n\n
* ex> <code> #define \_WIZCHIP_IO_MODE_ \_WIZCHIP_IO_MODE_SPI_VDM_ </code>
*
*/
//#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_FDM_
#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_
#include "W5500/w5500.h"
#else
#error "Unknown defined _WIZCHIP_. You should define one of 5100, 5200, and 5500 !!!"
#endif
WIZCHIP_IO_MODE should be defined WIZCHIP_IO_MODE_SPI_VDM or WIZCHIP_IO_MODE_FDM.
If you used with javakys code, You should define it WIZCHIP_IO_MODE_VDM.
Thank you.
Dear Midnightcow,
I have checked the wizchip_conf.h file and all was and is still definded as you mention.
#define _WIZCHIP_IO_MODE_ _WIZCHIP_IO_MODE_SPI_VDM_
Any other think that can cause that problem?
Christian
Hi,
I am so sorry too late.
Did you check to initialize WIZCHIP structure.
I think you have some problem WIZCHIP initialization.
The while loop code can be removed but I think your code is not runnring because while loop should be exited as far as WIZCHIP is initialized.
Thank you.
Dear Midnightcow,
you are right I am having a problem with the WIZCHIP structure, just working on it and
got a update of my compiler and had some new problems that are solved now.
This is how the structure is:
typedef struct __WIZCHIP
{
uint16_t if_mode; ///< host interface mode
uint8_t id[6]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on.
/**
* The set of critical section callback func.
*/
struct _CRIS
{
void (*_enter) (void); ///< crtical section enter
void (*_exit) (void); ///< critial section exit
}CRIS;
/**
* The set of @ref\_WIZCHIP_ select control callback func.
*/
struct _CS
{
void (*_select) (void); ///< @ref \_WIZCHIP_ selected
void (*_deselect)(void); ///< @ref \_WIZCHIP_ deselected
}CS;
/**
* The set of interface IO callback func.
*/
union _IF
{
/**
* For BUS interface IO
*/
struct
{
uint8_t (*_read_byte) (uint32_t AddrSel);
void (*_write_byte) (uint32_t AddrSel, uint8_t wb);
}BUS;
/**
* For SPI interface IO
*/
struct
{
uint8_t (*_read_byte) (void);
void (*_write_byte) (uint8_t wb);
// void (*_read_burst) (uint8_t* pBuf, uint16_t len);
// void (*_write_burst) (uint8_t* pBuf, uint16_t len);
}SPI;
// To be added
//
}IF;
}_WIZCHIP;
And here I am getting in the wizchip_conf.c file this error message: Assigning to non-lvalue WIZCHIP.id = WIZCHIP_ID,
_WIZCHIP WIZCHIP = // {_WIZCHIP_IO_MODE_,_WIZCHIP_ID_,wizchip_cris_enter,wizchip_cris_exit,wizchip_cs_select,wizchip_cs_deselect,wizchip_bus_readbyte,wizchip_bus_writebyte};
//#if 0
{
WIZCHIP.if_mode = _WIZCHIP_IO_MODE_,
WIZCHIP.id = _WIZCHIP_ID_,
WIZCHIP.CRIS._enter = wizchip_cris_enter,
WIZCHIP.CRIS._exit = wizchip_cris_exit,
WIZCHIP.CS._select = wizchip_cs_select,
WIZCHIP.CS._deselect = wizchip_cs_deselect,
WIZCHIP.IF.BUS._read_byte = wizchip_bus_readbyte,
WIZCHIP.IF.BUS._write_byte = wizchip_bus_writebyte
//.IF.SPI._read_byte = wizchip_spi_readbyte,
//.IF.SPI._write_byte = wizchip_spi_writebyte
};
//#endif
Thx for the support
Christian
Problem solved.
I change declaration of the “id” variable (wizchip_conf.h file) from 6 to 7:
uint8_t id[7]; ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on.