working on RX, broke FreeRTOS

This commit is contained in:
2024-08-20 11:26:27 +02:00
parent 910553df45
commit 2d8d8aeb0a
7 changed files with 46 additions and 25 deletions

View File

@ -35,7 +35,7 @@
#define LWIP_IPV4 1
#define LWIP_IPV6 0
#define NO_SYS 1
#define NO_SYS 0
#define LWIP_SOCKET (NO_SYS==0)
#define LWIP_NETCONN (NO_SYS==0)
#define LWIP_NETIF_API (NO_SYS==0)
@ -121,7 +121,7 @@
/* MEM_SIZE: the size of the heap memory. If the application will send
a lot of data that needs to be copied, this should be set high. */
#define MEM_SIZE 10240
#define MEM_SIZE 102400
/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
sends a lot of data out of ROM (or other static memory), this
@ -177,7 +177,7 @@ a lot of data that needs to be copied, this should be set high. */
/* ---------- TCP options ---------- */
#define LWIP_TCP 0
#define LWIP_TCP 1
#define TCP_TTL 255
#define LWIP_ALTCP (LWIP_TCP)

View File

@ -40,6 +40,9 @@ extern "C" {
#if !NO_SYS
#include "lwip/sys.h"
//TODO this is not portable:
#include "FreeRTOS.h"
#include "timers.h"
#endif
#include "lwip/netif.h"

View File

@ -215,11 +215,13 @@ xemacif_input_thread(struct netif *netif)
{
struct xemac_s *emac = (struct xemac_s *)netif->state;
while (1) {
xil_printf("input started\n");
/* sleep until there are packets to process
* This semaphore is set by the packet receive interrupt
* routine.
*/
sys_sem_wait(&emac->sem_rx_data_available);
xil_printf("input received\n");
/* move all received packets to lwIP */
xemacif_input(netif);

View File

@ -124,7 +124,8 @@ static volatile u32_t bd_space_index = 0;
static volatile u32_t bd_space_attr_set = 0;
#if !NO_SYS
extern u32 xInsideISR;
//extern u32 xInsideISR;
u32 xInsideISR; // TODO check if we are ISR safe
#endif
#define XEMACPS_BD_TO_INDEX(ringptr, bdptr) \
@ -576,7 +577,10 @@ void emacps_recv_handler(void *arg)
setup_rx_bds(xemacpsif, rxring);
}
#if !NO_SYS
sys_sem_signal(&xemac->sem_rx_data_available);
BaseType_t xHigherPriorityTaskWoken;
xSemaphoreGiveFromISR(xemac->sem_rx_data_available.sem, &xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken); //TODO delay this?
//sys_sem_signal(&xemac->sem_rx_data_available);
xInsideISR--;
#endif
@ -801,18 +805,18 @@ XStatus init_dma(struct xemac_s *xemac)
XEmacPs_Out32((xemacpsif->emacps.Config.BaseAddress + XEMACPS_TXQBASE_OFFSET),
(UINTPTR)bdtxterminate);
}
#if !NO_SYS
#ifdef SDT
xPortInstallInterruptHandler(xemacpsif->emacps.Config.IntrId,
( Xil_InterruptHandler ) XEmacPs_IntrHandler,
(void *)&xemacpsif->emacps);
#else
xPortInstallInterruptHandler(xtopologyp->scugic_emac_intr,
( Xil_InterruptHandler ) XEmacPs_IntrHandler,
(void *)&xemacpsif->emacps);
// #if !NO_SYS
// #ifdef SDT
// xPortInstallInterruptHandler(xemacpsif->emacps.Config.IntrId,
// ( Xil_InterruptHandler ) XEmacPs_IntrHandler,
// (void *)&xemacpsif->emacps);
// #else
// xPortInstallInterruptHandler(xtopologyp->scugic_emac_intr,
// ( Xil_InterruptHandler ) XEmacPs_IntrHandler,
// (void *)&xemacpsif->emacps);
#endif
#else
// #endif
// #else
#ifndef SDT
/*
* Connect the device driver handler that will be called when an
@ -823,7 +827,7 @@ XStatus init_dma(struct xemac_s *xemac)
(Xil_ExceptionHandler)XEmacPs_IntrHandler,
(void *)&xemacpsif->emacps);
#endif
#endif
// #endif
/*
* Enable the interrupt for emacps.
*/