This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS570LC4357: TMS570LC4357: wiznet with tms570lc4357

Part Number: TMS570LC4357

Tool/software:

i try to interface w5500 with mibspi 5  for simple tcp client application 

/*
* w5500_spi.c
*
* Created on: 17-Jul-2024
* Author: Anshul Sahu (AMS) AARTECH SOLONICS LIMITED
*/

#include "wizchip_conf.h"
#include "stdio.h"
#include "w5500_spi.h"
#include "Device_header.h"
//#include "Device_TMS570LC43.h"
#include "Device_types.h"
#include "HL_sys_common.h"
#include "HL_system.h"
#include "HL_gio.h"
#include "HL_mibspi.h"
#define CS_PIN PIN_CS0
#define RESET_PIN 7U // Using GIOA7 for reset

// Function to initialize mibspi5
void mibspi5_init(void) {
printf("Initializing SPI...\n");
mibspiInit();
mibspiSetFunctional(mibspiREG5, CS_PIN); // Set functional mode for CS0
printf("SPI initialized.\n");
}

uint8_t SPIReadWrite(uint8_t data) {
uint32_t dat1_value = 0x00000000;
dat1_value |= (uint32_t)(data & 0xFF); // Data bits (lower 8 bits)
// Chip Select (example placement)

mibspiREG5->DAT1 = dat1_value; // Write data with additional configuration

// Debug: Print status before waiting


// Wait until the transmission is complete
while (!(mibspiREG5->FLG & 0x00000100)); // Check TXINTFLG bit (9th bit) for transmission complete

return (uint8_t)(mibspiREG5->BUF & 0xFF); // Read received data
}

// SPI chip select and deselect functions
void wizchip_select(void) {
mibspiREG5->PC3 &= ~(1U << CS_PIN); // CS low
}

void wizchip_deselect(void) {
mibspiREG5->PC3 |= (1U << CS_PIN); // CS high
}

// SPI read and write functions
uint8_t wizchip_read(void) {
return SPIReadWrite(0x00);
}

void wizchip_write(uint8_t wb) {
SPIReadWrite(wb);
}

// SPI burst read and write functions
void wizchip_readburst(uint8_t* pBuf, uint16_t len) {
uint16_t i;
for (i = 0; i < len; i++) {
*pBuf = SPIReadWrite(0x00);
pBuf++;
}
}

void wizchip_writeburst(uint8_t* pBuf, uint16_t len) {
uint16_t i;
for (i = 0; i < len; i++) {
SPIReadWrite(*pBuf);
pBuf++;
}
}

// Function to initialize GPIO pins
void W5500IOInit(void) {
gioInit();
gioSetDirection(gioPORTA, 1U << RESET_PIN); // Set GIOA7 as output
gioSetBit(gioPORTA, RESET_PIN, 1); // Set GIOA7 high (default state)
}

// Function to initialize W5500
void W5500Init(void) {
uint8_t memsize[2][8] = { { 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, 2, 2, 2, 2, 2, 2 } };

W5500IOInit();

// Send a pulse on reset pin
gioSetBit(gioPORTA, RESET_PIN, 0); // Reset low
volatile int i ;
for ( i = 0; i < 10000; i++); // Short delay
gioSetBit(gioPORTA, RESET_PIN, 1); // Reset high

reg_wizchip_cs_cbfunc(wizchip_select, wizchip_deselect);
reg_wizchip_spi_cbfunc(wizchip_read, wizchip_write);
reg_wizchip_spiburst_cbfunc(wizchip_readburst, wizchip_writeburst);

// WIZChip Initialize
if (ctlwizchip(CW_INIT_WIZCHIP, (void*) memsize) == -1) {
printf("WIZCHIP Initialized Failed.\r\n");
while (1);
}
printf("WIZCHIP Initialization Success.\r\n");

intialization if wiznet successful but unable to read socket number using mibspi5  is there any working example or any other reference