forked from ROMEO/obsw
tftp demo on uart0 (NSFZed)
This commit is contained in:
parent
8bca815cd2
commit
1ba3d9412d
@ -56,6 +56,7 @@ set(lwip_SRCS
|
||||
${lwipapi_SRCS}
|
||||
${lwipnetif_SRCS}
|
||||
${LWIP_DIR}/src/netif/slipif.c
|
||||
${LWIP_DIR}/src/apps/tftp/tftp.c
|
||||
${LWIP_DIR}/contrib/ports/freertos/sys_arch.c
|
||||
)
|
||||
add_library(lwip ${lwip_SRCS})
|
||||
|
@ -24,8 +24,8 @@
|
||||
#include "xparameters_ps.h"
|
||||
|
||||
|
||||
#define STDIN_BASEADDRESS XPS_UART1_BASEADDR
|
||||
#define STDOUT_BASEADDRESS XPS_UART1_BASEADDR
|
||||
#define STDIN_BASEADDRESS XPS_UART0_BASEADDR
|
||||
#define STDOUT_BASEADDRESS XPS_UART0_BASEADDR
|
||||
|
||||
|
||||
/******************************************************************/
|
||||
|
@ -15,5 +15,5 @@ void outbyte(char c);
|
||||
#endif
|
||||
|
||||
void outbyte(char c) {
|
||||
XUartPs_SendByte(STDOUT_BASEADDRESS, c);
|
||||
//XUartPs_SendByte(STDOUT_BASEADDRESS, c);
|
||||
}
|
||||
|
@ -12,11 +12,54 @@
|
||||
#include <xscugic.h>
|
||||
#include <xuartps.h>
|
||||
|
||||
|
||||
|
||||
#undef XUARTPS_IXR_RXOVR
|
||||
#define XUARTPS_IXR_RXOVR 0x00000020U /**< Rx Overrun error interrupt */
|
||||
#define XUARTPS_IXR_RTRIG 0x00000001U /**< RX FIFO trigger interrupt. */
|
||||
|
||||
#define UART_INT_NR XPAR_XUARTPS_0_INTR
|
||||
|
||||
extern "C" {
|
||||
#include <lwip/apps/tftp_server.h>
|
||||
|
||||
static void*
|
||||
tftp_open(const char* fname, const char* mode, u8_t is_write)
|
||||
{
|
||||
LWIP_UNUSED_ARG(mode);
|
||||
return (void*)13;
|
||||
}
|
||||
|
||||
static void
|
||||
tftp_close(void* handle)
|
||||
{}
|
||||
|
||||
static int
|
||||
tftp_read(void* handle, void* buf, int bytes)
|
||||
{
|
||||
memset(buf, 'x', bytes);
|
||||
return bytes - 60;
|
||||
}
|
||||
|
||||
static int
|
||||
tftp_write(void* handle, struct pbuf* p)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* For TFTP client only */
|
||||
static void
|
||||
tftp_error(void* handle, int err, const char* msg, int size)
|
||||
{}
|
||||
|
||||
static const struct tftp_context tftp = {
|
||||
tftp_open,
|
||||
tftp_close,
|
||||
tftp_read,
|
||||
tftp_write,
|
||||
tftp_error
|
||||
};
|
||||
|
||||
void slipif_rxbyte_input(struct netif *netif, u8_t c);
|
||||
|
||||
void myInitDone(void *arg) { puts("init done"); }
|
||||
@ -27,8 +70,6 @@ extern XScuGic xInterruptController; /* Interrupt controller instance */
|
||||
|
||||
/** this is based on XUartPs_InterruptHandler() in xuartps_intr.c*/
|
||||
void handleUARTInt(void *) {
|
||||
XUartPs_SendByte(STDOUT_BASEADDRESS, 'I');
|
||||
|
||||
u32 IsrStatus;
|
||||
|
||||
/*
|
||||
@ -87,7 +128,7 @@ void testIp() {
|
||||
|
||||
/* Install the UART Interrupt handler. */
|
||||
BaseType_t xStatus =
|
||||
XScuGic_Connect(&xInterruptController, XPAR_XUARTPS_1_INTR,
|
||||
XScuGic_Connect(&xInterruptController, UART_INT_NR,
|
||||
(Xil_ExceptionHandler)handleUARTInt, nullptr);
|
||||
configASSERT(xStatus == XST_SUCCESS);
|
||||
(void)xStatus; /* Remove compiler warning if configASSERT() is not defined. */
|
||||
@ -106,7 +147,7 @@ void testIp() {
|
||||
XUartPs_WriteReg(STDIN_BASEADDRESS, XUARTPS_IDR_OFFSET, (~mask));
|
||||
|
||||
/* Enable the interrupt for the UART1 in the interrupt controller. */
|
||||
XScuGic_Enable(&xInterruptController, XPAR_XUARTPS_1_INTR);
|
||||
XScuGic_Enable(&xInterruptController, UART_INT_NR);
|
||||
|
||||
// Start task to forwad packets from ISR to IP Task
|
||||
xTaskCreate(forwardPackets, /* The function that implements the task. */
|
||||
@ -118,6 +159,8 @@ void testIp() {
|
||||
4, /* The priority assigned to the task. */
|
||||
nullptr);
|
||||
|
||||
tftp_init_server(&tftp);
|
||||
|
||||
puts("socket");
|
||||
|
||||
int serverSocket = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user