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
|
set (LWIP_INCLUDE_DIRS
|
||||||
"${LWIP_DIR}/src/include"
|
"${LWIP_DIR}/src/include"
|
||||||
"bsp_z7/lwip/include"
|
"bsp_z7/lwip/include"
|
||||||
|
${LWIP_DIR}/contrib/ports/freertos/include
|
||||||
)
|
)
|
||||||
include(${LWIP_DIR}/src/Filelists.cmake)
|
include(${LWIP_DIR}/src/Filelists.cmake)
|
||||||
set(lwip_SRCS
|
set(lwip_SRCS
|
||||||
@ -54,6 +55,8 @@ set(lwip_SRCS
|
|||||||
${lwipcore4_SRCS}
|
${lwipcore4_SRCS}
|
||||||
${lwipcore6_SRCS}
|
${lwipcore6_SRCS}
|
||||||
${lwipnetif_SRCS}
|
${lwipnetif_SRCS}
|
||||||
|
${lwipapi_SRCS}
|
||||||
|
${LWIP_DIR}/contrib/ports/freertos/sys_arch.c
|
||||||
#${LWIP_DIR}/src/netif/slipif.c
|
#${LWIP_DIR}/src/netif/slipif.c
|
||||||
#${LWIP_DIR}/src/apps/tftp/tftp.c
|
#${LWIP_DIR}/src/apps/tftp/tftp.c
|
||||||
)
|
)
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#define LWIP_IPV4 1
|
#define LWIP_IPV4 1
|
||||||
#define LWIP_IPV6 0
|
#define LWIP_IPV6 0
|
||||||
|
|
||||||
#define NO_SYS 1
|
#define NO_SYS 0
|
||||||
#define LWIP_SOCKET (NO_SYS==0)
|
#define LWIP_SOCKET (NO_SYS==0)
|
||||||
#define LWIP_NETCONN (NO_SYS==0)
|
#define LWIP_NETCONN (NO_SYS==0)
|
||||||
#define LWIP_NETIF_API (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
|
/* 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. */
|
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
|
/* 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
|
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 ---------- */
|
/* ---------- TCP options ---------- */
|
||||||
#define LWIP_TCP 0
|
#define LWIP_TCP 1
|
||||||
#define TCP_TTL 255
|
#define TCP_TTL 255
|
||||||
|
|
||||||
#define LWIP_ALTCP (LWIP_TCP)
|
#define LWIP_ALTCP (LWIP_TCP)
|
||||||
|
@ -40,6 +40,9 @@ extern "C" {
|
|||||||
|
|
||||||
#if !NO_SYS
|
#if !NO_SYS
|
||||||
#include "lwip/sys.h"
|
#include "lwip/sys.h"
|
||||||
|
//TODO this is not portable:
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "timers.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "lwip/netif.h"
|
#include "lwip/netif.h"
|
||||||
|
@ -215,11 +215,13 @@ xemacif_input_thread(struct netif *netif)
|
|||||||
{
|
{
|
||||||
struct xemac_s *emac = (struct xemac_s *)netif->state;
|
struct xemac_s *emac = (struct xemac_s *)netif->state;
|
||||||
while (1) {
|
while (1) {
|
||||||
|
xil_printf("input started\n");
|
||||||
/* sleep until there are packets to process
|
/* sleep until there are packets to process
|
||||||
* This semaphore is set by the packet receive interrupt
|
* This semaphore is set by the packet receive interrupt
|
||||||
* routine.
|
* routine.
|
||||||
*/
|
*/
|
||||||
sys_sem_wait(&emac->sem_rx_data_available);
|
sys_sem_wait(&emac->sem_rx_data_available);
|
||||||
|
xil_printf("input received\n");
|
||||||
|
|
||||||
/* move all received packets to lwIP */
|
/* move all received packets to lwIP */
|
||||||
xemacif_input(netif);
|
xemacif_input(netif);
|
||||||
|
@ -124,7 +124,8 @@ static volatile u32_t bd_space_index = 0;
|
|||||||
static volatile u32_t bd_space_attr_set = 0;
|
static volatile u32_t bd_space_attr_set = 0;
|
||||||
|
|
||||||
#if !NO_SYS
|
#if !NO_SYS
|
||||||
extern u32 xInsideISR;
|
//extern u32 xInsideISR;
|
||||||
|
u32 xInsideISR; // TODO check if we are ISR safe
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define XEMACPS_BD_TO_INDEX(ringptr, bdptr) \
|
#define XEMACPS_BD_TO_INDEX(ringptr, bdptr) \
|
||||||
@ -576,7 +577,10 @@ void emacps_recv_handler(void *arg)
|
|||||||
setup_rx_bds(xemacpsif, rxring);
|
setup_rx_bds(xemacpsif, rxring);
|
||||||
}
|
}
|
||||||
#if !NO_SYS
|
#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--;
|
xInsideISR--;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -801,18 +805,18 @@ XStatus init_dma(struct xemac_s *xemac)
|
|||||||
XEmacPs_Out32((xemacpsif->emacps.Config.BaseAddress + XEMACPS_TXQBASE_OFFSET),
|
XEmacPs_Out32((xemacpsif->emacps.Config.BaseAddress + XEMACPS_TXQBASE_OFFSET),
|
||||||
(UINTPTR)bdtxterminate);
|
(UINTPTR)bdtxterminate);
|
||||||
}
|
}
|
||||||
#if !NO_SYS
|
// #if !NO_SYS
|
||||||
#ifdef SDT
|
// #ifdef SDT
|
||||||
xPortInstallInterruptHandler(xemacpsif->emacps.Config.IntrId,
|
// xPortInstallInterruptHandler(xemacpsif->emacps.Config.IntrId,
|
||||||
( Xil_InterruptHandler ) XEmacPs_IntrHandler,
|
// ( Xil_InterruptHandler ) XEmacPs_IntrHandler,
|
||||||
(void *)&xemacpsif->emacps);
|
// (void *)&xemacpsif->emacps);
|
||||||
#else
|
// #else
|
||||||
xPortInstallInterruptHandler(xtopologyp->scugic_emac_intr,
|
// xPortInstallInterruptHandler(xtopologyp->scugic_emac_intr,
|
||||||
( Xil_InterruptHandler ) XEmacPs_IntrHandler,
|
// ( Xil_InterruptHandler ) XEmacPs_IntrHandler,
|
||||||
(void *)&xemacpsif->emacps);
|
// (void *)&xemacpsif->emacps);
|
||||||
|
|
||||||
#endif
|
// #endif
|
||||||
#else
|
// #else
|
||||||
#ifndef SDT
|
#ifndef SDT
|
||||||
/*
|
/*
|
||||||
* Connect the device driver handler that will be called when an
|
* 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,
|
(Xil_ExceptionHandler)XEmacPs_IntrHandler,
|
||||||
(void *)&xemacpsif->emacps);
|
(void *)&xemacpsif->emacps);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
// #endif
|
||||||
/*
|
/*
|
||||||
* Enable the interrupt for emacps.
|
* Enable the interrupt for emacps.
|
||||||
*/
|
*/
|
||||||
|
@ -65,7 +65,7 @@ int main(void) {
|
|||||||
|
|
||||||
// printf("Booting Software\n");
|
// printf("Booting Software\n");
|
||||||
|
|
||||||
testEth();
|
//testEth();
|
||||||
|
|
||||||
mission();
|
mission();
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ void start_application();
|
|||||||
|
|
||||||
struct netif server_netif;
|
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) {
|
static void print_ip(char *msg, ip_addr_t *ip) {
|
||||||
xil_printf(msg);
|
xil_printf(msg);
|
||||||
@ -135,7 +135,12 @@ void network_thread() {
|
|||||||
#endif
|
#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
|
#if LWIP_DHCP == 1
|
||||||
int mscnt = 0;
|
int mscnt = 0;
|
||||||
@ -196,12 +201,10 @@ int testEth() {
|
|||||||
udp_sendto(udpecho_raw_pcb, tx, &addr, 1177);
|
udp_sendto(udpecho_raw_pcb, tx, &addr, 1177);
|
||||||
|
|
||||||
while (1) {
|
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();
|
sys_check_timeouts();
|
||||||
|
xil_printf("pre loop\n");
|
||||||
|
vTaskDelay(200 * portTICK_PERIOD_MS);
|
||||||
|
xil_printf("loop\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
pbuf_free(tx);
|
pbuf_free(tx);
|
||||||
@ -209,4 +212,10 @@ int testEth() {
|
|||||||
/* start the application*/
|
/* start the application*/
|
||||||
// start_application();
|
// start_application();
|
||||||
return 0;
|
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