안녕하세요
일단 W6100을 처음 써봅니다.
다른 시리즈는 써봤지만 W6100은 처음 접근해봅니다.
아래는 IO6library Git에 올라온 원문입니다.
WIZCHIP N bytes read/write Function : It is not mandatory. : But, If you want to use WIZCHIP for high speed access using a peripheral such as DMA, make it as follows. : Even if you do not, you can use N bytes read/write accesses because it is performed by repeating your 1-byte read/write function.
void your_spi_dma_write_buf(uint8_t* pbuf, iodata_t len)
{
/* HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size) */
HAL_SPI_Transmit_DMA(SPI1, pbuf, (uint16_t)len);
}
void your_spi_dma_read_buf(uint8_t* pbuf, iodata_t len)
{
/* HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size) */
HAL_SPI_Receive_DMA(SPI1, pbuf, (uint16_t)len);
}
위와 같이 동일하게 코드를 작성하였고 해봤지만 동작을 안합니다.
물론
DMA를 사용하지 않은 일반 SPI모드로는 정상 작동하는 것을 확인하였습니다.
아래는 소스의 W6100에 대한 소스입니다.
혹시 잘못된 점이 있을까요?
void wizchip_enable(void) {
HAL_GPIO_WritePin(W6100_SPI1_CS_GPIO_Port, W6100_SPI1_CS_Pin, GPIO_PIN_RESET);
}
void wizchip_disable(void) {
HAL_GPIO_WritePin(W6100_SPI1_CS_GPIO_Port, W6100_SPI1_CS_Pin, GPIO_PIN_SET);
}
void critical_enter(void)
{
__disable_irq();
}
void critical_exit(void)
{
__enable_irq();
}
/* Read 1 byte thru SPI */
uint8_t spi_read_byte()
{
uint8_t ret;
/*HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t pData, uint16_t Size, uint32_t Timeout)/
HAL_SPI_Receive(&hspi1, &ret, 1, 1000);
return ret;
} /* Write 1 byte thru SPI */
void spi_wite_byte(uint8_t wd)
{ /* HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout); */
HAL_SPI_Transmit(&hspi1, &wd, 1, 1000);
}
void spi_dma_write_buf(uint8_t* pbuf, datasize_t len)
{
/* HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size) */
HAL_SPI_Transmit_DMA(&hspi1, pbuf, (uint16_t)len);
}
void spi_dma_read_buf(uint8_t* pbuf, datasize_t len)
{
/* HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size) */
HAL_SPI_Receive_DMA(&hspi1, pbuf, (uint16_t)len);
}
void IP_OG_F(void)
{
//WIZCHIP Enable/Disable
reg_wizchip_cs_cbfunc(wizchip_enable, wizchip_disable);
//WIZCHIP Critical Section
reg_wizchip_cris_cbfunc(critical_enter, critical_exit);
//WIZCHIP read/write function
//reg_wizchip_spi_cbfunc(spi_read_byte, spi_wite_byte, 0, 0);
// If you made DMA function for readign/writting function, you can register as following
reg_wizchip_spi_cbfunc(0, 0, spi_dma_read_buf, spi_dma_write_buf);
// /* For io6Library Read/Write Test */
// Check WIZCHIP ID value for read test
ctlwizchip(CW_GET_ID,&chip_id); // Check WIZCHIP ID value for read test
ctlwizchip(CW_RESET_PHY, 0);
wizchip_init(bufSize, bufSize);
wiz_NetInfo gWIZNETINFO = { .mac = {0x00,0x08,0xdc,0xff,0xff,0xff},
.ip = {172,16,10,236},
.sn = {255, 255, 0, 0},
.gw = {172, 16, 44, 254},
.dns = {168, 126, 63, 1},
.lla = {0xfe,0x80, 0x00,0x00,
0x00,0x00, 0x00,0x00,
0x02,0x08, 0xdc,0xff,
0xfe,0xff, 0xff,0xff},
.gua={0x20,0x01,0x02,0xb8,
0x00,0x10,0x00,0x01,
0x02,0x08,0xdc,0xff,
0xfe,0xff,0xff,0xff},
.sn6={0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,
0x00,0x00,0x00, 0x00,
0x00,0x00,0x00,0x00},
.gw6={0xfe, 0x80, 0x00,0x00,
0x00,0x00,0x00,0x00,
0x02,0x00, 0x87,0xff,
0xfe,0x08, 0x4c,0x81}
}; // Gateway address
uint8_t syslock = SYS_NET_LOCK;
ctlwizchip(CW_SYS_UNLOCK,&syslock);
wizchip_setnetinfo(&gWIZNETINFO);
wizchip_getnetinfo(&gWIZNETINFO);
cpu_add[0] = gWIZNETINFO.ip[0];
// Check PHY Link Led to turn off and then on
//ctlwizchip(CW_GET_ID, &chip_id);
//ctlwizchip(CW_PHY_RESET, 0);
}