forked from ROMEO/obsw
working on RX, broke FreeRTOS
This commit is contained in:
parent
910553df45
commit
2d8d8aeb0a
@ -47,6 +47,7 @@ add_executable(${TARGET_NAME})
|
||||
set (LWIP_INCLUDE_DIRS
|
||||
"${LWIP_DIR}/src/include"
|
||||
"bsp_z7/lwip/include"
|
||||
${LWIP_DIR}/contrib/ports/freertos/include
|
||||
)
|
||||
include(${LWIP_DIR}/src/Filelists.cmake)
|
||||
set(lwip_SRCS
|
||||
@ -54,6 +55,8 @@ set(lwip_SRCS
|
||||
${lwipcore4_SRCS}
|
||||
${lwipcore6_SRCS}
|
||||
${lwipnetif_SRCS}
|
||||
${lwipapi_SRCS}
|
||||
${LWIP_DIR}/contrib/ports/freertos/sys_arch.c
|
||||
#${LWIP_DIR}/src/netif/slipif.c
|
||||
#${LWIP_DIR}/src/apps/tftp/tftp.c
|
||||
)
|
||||
|
@ -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)
|
||||
|
@ -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"
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -65,7 +65,7 @@ int main(void) {
|
||||
|
||||
// printf("Booting Software\n");
|
||||
|
||||
testEth();
|
||||
//testEth();
|
||||
|
||||
mission();
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ void start_application();
|
||||
|
||||
struct netif server_netif;
|
||||
|
||||
u32_t sys_now(void) { return xTaskGetTickCount() * portTICK_PERIOD_MS; }
|
||||
// u32_t sys_now(void) { return xTaskGetTickCount() * portTICK_PERIOD_MS; }
|
||||
|
||||
static void print_ip(char *msg, ip_addr_t *ip) {
|
||||
xil_printf(msg);
|
||||
@ -135,7 +135,12 @@ void network_thread() {
|
||||
#endif
|
||||
}
|
||||
|
||||
int testEth() {
|
||||
int main_thread(void * _) {
|
||||
|
||||
|
||||
xil_printf("pre check\n");
|
||||
vTaskDelay(200 * portTICK_PERIOD_MS);
|
||||
xil_printf("check\n");
|
||||
|
||||
#if LWIP_DHCP == 1
|
||||
int mscnt = 0;
|
||||
@ -196,12 +201,10 @@ int testEth() {
|
||||
udp_sendto(udpecho_raw_pcb, tx, &addr, 1177);
|
||||
|
||||
while (1) {
|
||||
// slipif_rxbyte_input() is private, so we use slipif_poll and implement
|
||||
// sio_tryread()
|
||||
// sio_tryread() will do a blocking read with a timeout, so we get to check
|
||||
// the timeouts even if no data is incoming
|
||||
//slipif_poll(&netif);
|
||||
sys_check_timeouts();
|
||||
xil_printf("pre loop\n");
|
||||
vTaskDelay(200 * portTICK_PERIOD_MS);
|
||||
xil_printf("loop\n");
|
||||
}
|
||||
|
||||
pbuf_free(tx);
|
||||
@ -209,4 +212,10 @@ int testEth() {
|
||||
/* start the application*/
|
||||
// start_application();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int testEth(){
|
||||
sys_thread_new("main_thread", (void(*)(void*))main_thread, 0,
|
||||
THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
|
||||
vTaskStartScheduler();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user