Modify the file main.cpp for M487

Dependencies:   BufferedSerial

Committer:
shliu1
Date:
Fri Sep 29 05:45:43 2017 +0000
Revision:
0:c89ccc69a48b
main.cpp adds the setting of TARGET_NUMAKER_PFM_M487 for M487

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shliu1 0:c89ccc69a48b 1 /*
shliu1 0:c89ccc69a48b 2 * Copyright (c) 2017 Nuvoton Tecnology Corp. All rights reserved.
shliu1 0:c89ccc69a48b 3 *
shliu1 0:c89ccc69a48b 4 * Header for Serial-To-Ethernet configuration.
shliu1 0:c89ccc69a48b 5 *
shliu1 0:c89ccc69a48b 6 */
shliu1 0:c89ccc69a48b 7
shliu1 0:c89ccc69a48b 8 #ifndef _STE_CONFIG_H
shliu1 0:c89ccc69a48b 9 #define _STE_CONFIG_H
shliu1 0:c89ccc69a48b 10
shliu1 0:c89ccc69a48b 11 #include "mbed.h"
shliu1 0:c89ccc69a48b 12 #include "EthernetInterface.h"
shliu1 0:c89ccc69a48b 13 #include "TCPSocket.h"
shliu1 0:c89ccc69a48b 14 #include "TCPServer.h"
shliu1 0:c89ccc69a48b 15 #include "BufferedSerial.h"
shliu1 0:c89ccc69a48b 16 #include "FATFileSystem.h"
shliu1 0:c89ccc69a48b 17 #include "NuSDBlockDevice.h"
shliu1 0:c89ccc69a48b 18
shliu1 0:c89ccc69a48b 19
shliu1 0:c89ccc69a48b 20 //#define ENABLE_WEB_CONFIG // Define this to active a simple web sever for
shliu1 0:c89ccc69a48b 21 // UART ports and Ethernet port parameters configuration.
shliu1 0:c89ccc69a48b 22
shliu1 0:c89ccc69a48b 23 /* Maximum UART ports supported */
shliu1 0:c89ccc69a48b 24 #define MAX_UART_PORTS 2
shliu1 0:c89ccc69a48b 25
shliu1 0:c89ccc69a48b 26 /* Default UART baud */
shliu1 0:c89ccc69a48b 27 #define DEFAULT_UART_BAUD 115200
shliu1 0:c89ccc69a48b 28
shliu1 0:c89ccc69a48b 29 /* Network base port number to listen.
shliu1 0:c89ccc69a48b 30 So the base port maps to the 1st UART port,
shliu1 0:c89ccc69a48b 31 the (base port + 1) maps to the 2nd UART port, etc. */
shliu1 0:c89ccc69a48b 32 #define NET_PORT_BASE 10001
shliu1 0:c89ccc69a48b 33
shliu1 0:c89ccc69a48b 34 /* Path and Filename of configuration files */
shliu1 0:c89ccc69a48b 35 #define SER_CONFIG_FILE "/fs/STE_SER.TXT" // for serial ports
shliu1 0:c89ccc69a48b 36 #define NET_CONFIG_FILE "/fs/STE_NET.TXT" // for network
shliu1 0:c89ccc69a48b 37
shliu1 0:c89ccc69a48b 38 /* Maximum size of server address */
shliu1 0:c89ccc69a48b 39 #define MAX_SERVER_ADDRESS_SIZE 63
shliu1 0:c89ccc69a48b 40
shliu1 0:c89ccc69a48b 41 /* Maximum size of IP address */
shliu1 0:c89ccc69a48b 42 #define MAX_IPV4_ADDRESS_SIZE 15
shliu1 0:c89ccc69a48b 43
shliu1 0:c89ccc69a48b 44 /* Functions and global variables declaration. */
shliu1 0:c89ccc69a48b 45
shliu1 0:c89ccc69a48b 46 typedef enum {
shliu1 0:c89ccc69a48b 47 NET_SERVER_MODE = 0,
shliu1 0:c89ccc69a48b 48 NET_CLIENT_MODE
shliu1 0:c89ccc69a48b 49 } E_NetMode;
shliu1 0:c89ccc69a48b 50
shliu1 0:c89ccc69a48b 51 typedef enum {
shliu1 0:c89ccc69a48b 52 IP_STATIC_MODE = 0,
shliu1 0:c89ccc69a48b 53 IP_DHCP_MODE
shliu1 0:c89ccc69a48b 54 } E_IPMode;
shliu1 0:c89ccc69a48b 55
shliu1 0:c89ccc69a48b 56 typedef struct {
shliu1 0:c89ccc69a48b 57 E_IPMode mode;
shliu1 0:c89ccc69a48b 58 char ip[MAX_IPV4_ADDRESS_SIZE+1];
shliu1 0:c89ccc69a48b 59 char mask[MAX_IPV4_ADDRESS_SIZE+1];
shliu1 0:c89ccc69a48b 60 char gateway[MAX_IPV4_ADDRESS_SIZE+1];
shliu1 0:c89ccc69a48b 61 } S_NET_CONFIG;
shliu1 0:c89ccc69a48b 62
shliu1 0:c89ccc69a48b 63 typedef struct {
shliu1 0:c89ccc69a48b 64 E_NetMode mode; // Network server or client mode
shliu1 0:c89ccc69a48b 65 int port; // Network port number
shliu1 0:c89ccc69a48b 66 BufferedSerial *pserial; // UART number
shliu1 0:c89ccc69a48b 67 int baud; // UART baud
shliu1 0:c89ccc69a48b 68 int data; // UART data bits
shliu1 0:c89ccc69a48b 69 int stop; // UART stop bits
shliu1 0:c89ccc69a48b 70 mbed::SerialBase::Parity parity; // UART parity bit
shliu1 0:c89ccc69a48b 71 char server_addr[MAX_SERVER_ADDRESS_SIZE+1]; // Server address for TCP client mode
shliu1 0:c89ccc69a48b 72 unsigned short server_port; // Server port for TCP client mode
shliu1 0:c89ccc69a48b 73 } S_PORT_CONFIG;
shliu1 0:c89ccc69a48b 74
shliu1 0:c89ccc69a48b 75 extern RawSerial output; // for debug output
shliu1 0:c89ccc69a48b 76 extern EthernetInterface eth;
shliu1 0:c89ccc69a48b 77 extern S_PORT_CONFIG port_config[MAX_UART_PORTS];
shliu1 0:c89ccc69a48b 78 extern S_NET_CONFIG net_config;
shliu1 0:c89ccc69a48b 79
shliu1 0:c89ccc69a48b 80 extern bool SD_Card_Mounted;
shliu1 0:c89ccc69a48b 81 void start_httpd(void);
shliu1 0:c89ccc69a48b 82
shliu1 0:c89ccc69a48b 83 #endif