---
title: "Problem at this stage \"void reg_wizchip_spi_cbfunc\""
url: "https://maker.wiznet.io/forum/10673"
markdown_url: "https://maker.wiznet.io/forum/10673/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "Christian"
created: "2014-11-17T13:20:19+09:00"
last_activity: "2017-05-04T08:34:26+09:00"
language: "en"
views: 1460
replies: 3
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# Problem at this stage "void reg_wizchip_spi_cbfunc"

## Question

Asked by Christian on 2014-11-17 in Ethernet Chips.

Hi,

I am using the project from Javakys, which can be found here:
[github.com/javakys/W5500_STM32F4_SPI_DMA](https://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

## Replies

### Reply 1 by Christian, 2014-11-21

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

### Reply 2 by Christian, 2014-11-27

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

### Reply 3 by Christian, 2014-11-27

Problem solved.
I change declaration of the “id” variable (wizchip_conf.h file) from 6 to 7:
uint8_t id[7]; ///&lt; @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on.

---

Source: https://maker.wiznet.io/forum/10673
