Chau Vo / device_configuration

Dependents:   F103-Web-Server

Fork of my_eeprom_funcs by Chau Vo

Committer:
olympux
Date:
Sun Sep 28 17:35:07 2014 +0000
Revision:
1:6bdc99dd8e0a
Parent:
0:aa07a25a9005
Child:
3:69e1c4ed69e1
Rename .c into .cpp; Functions to load device network configuration, and tcp server info for auto transmit in TCP client mode

Who changed what in which revision?

UserRevisionLine numberNew contents of line
olympux 0:aa07a25a9005 1 #ifndef __MY_EEPROM_FUNCS_H
olympux 0:aa07a25a9005 2 #define __MY_EEPROM_FUNCS_H
olympux 0:aa07a25a9005 3
olympux 0:aa07a25a9005 4 #include "eeprom.h"
olympux 0:aa07a25a9005 5
olympux 0:aa07a25a9005 6 /*
olympux 0:aa07a25a9005 7 * Default device network configuration
olympux 0:aa07a25a9005 8 */
olympux 0:aa07a25a9005 9 #define DEFAULT_IP_ADDRESS "192.168.0.249"
olympux 0:aa07a25a9005 10 #define DEFAULT_IP_SUBNET "255.255.255.0"
olympux 0:aa07a25a9005 11 #define DEFAULT_IP_GATEWAY "192.168.0.1"
olympux 0:aa07a25a9005 12 #define DEFAULT_MAC0 0x00
olympux 0:aa07a25a9005 13 #define DEFAULT_MAC1 0x08
olympux 0:aa07a25a9005 14 #define DEFAULT_MAC2 0xDC
olympux 0:aa07a25a9005 15 #define DEFAULT_MAC3 0x00
olympux 0:aa07a25a9005 16 #define DEFAULT_MAC4 0x00
olympux 0:aa07a25a9005 17 #define DEFAULT_MAC5 0x01
olympux 0:aa07a25a9005 18
olympux 0:aa07a25a9005 19
olympux 0:aa07a25a9005 20 /*
olympux 0:aa07a25a9005 21 * Positions of variables in EEPROM array
olympux 0:aa07a25a9005 22 */
olympux 0:aa07a25a9005 23 #define IP_ADDRESS_POS 0
olympux 0:aa07a25a9005 24 #define IP_SUBNET_POS 4
olympux 0:aa07a25a9005 25 #define IP_GATEWAY_POS 8
olympux 0:aa07a25a9005 26 #define TCP_SERVER_LOCAL_PORT_POS 12
olympux 0:aa07a25a9005 27 #define UDP_SERVER_LOCAL_PORT_POS 13
olympux 0:aa07a25a9005 28 #define FIRST_RUN_FLAG_POS 14
olympux 0:aa07a25a9005 29 #define MAC_ADDRESS_POS 15
olympux 0:aa07a25a9005 30 // EEPROM: for TCP server this device connects to in TCP client mode
olympux 0:aa07a25a9005 31 #define AUTO_TRANSMIT_FLAG_POS 18
olympux 1:6bdc99dd8e0a 32 #define AUTO_TRANSMIT_TIME_PERIOD_POS 19
olympux 0:aa07a25a9005 33 #define TCP_SERVER_IP_ADDR_POS 20
olympux 0:aa07a25a9005 34 #define TCP_SERVER_PORT_POS 24
olympux 0:aa07a25a9005 35
olympux 0:aa07a25a9005 36
olympux 0:aa07a25a9005 37 /*
olympux 0:aa07a25a9005 38 * External variables in main.c
olympux 0:aa07a25a9005 39 */
olympux 0:aa07a25a9005 40 extern uint16_t VirtAddVarTab[];
olympux 0:aa07a25a9005 41
olympux 0:aa07a25a9005 42 extern uint8_t u8mac[], u8ip_addr[];// keep mac and ip address in 8-bits
olympux 0:aa07a25a9005 43 extern uint16_t u16mac_addr[], u16ip_addr[], u16ip_subnet[], u16ip_gateway[]; // 16-bits, directly loaded from eeprom
olympux 0:aa07a25a9005 44 extern char str_ip_addr[], str_ip_subnet[], str_ip_gateway[]; // for printf, converted from 16-bits u16ip_xxx
olympux 0:aa07a25a9005 45 extern uint16_t first_run; // first run flag
olympux 0:aa07a25a9005 46
olympux 0:aa07a25a9005 47 extern const uint16_t tcp_server_local_port; // fixed
olympux 0:aa07a25a9005 48 extern const uint16_t udp_server_local_port; // fixed
olympux 0:aa07a25a9005 49
olympux 0:aa07a25a9005 50 // this section is for the TCP server that this device connects to in TCP client mode
olympux 1:6bdc99dd8e0a 51 extern uint16_t auto_transmit_flag, transmit_time_period; // auto transmit status, time period = 1s
olympux 1:6bdc99dd8e0a 52 extern uint16_t u16server_ip_addr[]; // directly loaded from eeprom
olympux 1:6bdc99dd8e0a 53 extern uint16_t u16tcp_server_port; // directly loaded from eeprom
olympux 0:aa07a25a9005 54 extern uint8_t u8server_ip_addr[];
olympux 0:aa07a25a9005 55 extern char * server_ip_addr;
olympux 0:aa07a25a9005 56 extern char str_server_ip_addr[];
olympux 0:aa07a25a9005 57
olympux 0:aa07a25a9005 58
olympux 0:aa07a25a9005 59 /*
olympux 0:aa07a25a9005 60 * My eeprom functions
olympux 0:aa07a25a9005 61 */
olympux 1:6bdc99dd8e0a 62 void write_eeprom_network(char* buf);
olympux 0:aa07a25a9005 63 void load_eeprom_network(void);
olympux 1:6bdc99dd8e0a 64 void write_eeprom_tcpserver(char* buf);
olympux 0:aa07a25a9005 65 void load_eeprom_tcpserver(void);
olympux 1:6bdc99dd8e0a 66
olympux 0:aa07a25a9005 67 #endif