Chau Vo / device_configuration

Dependents:   F103-Web-Server

Fork of my_eeprom_funcs by Chau Vo

Committer:
olympux
Date:
Thu Oct 02 19:41:15 2014 +0000
Revision:
3:69e1c4ed69e1
Parent:
1:6bdc99dd8e0a
Child:
4:944a4646b825
Added DBG

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 3:69e1c4ed69e1 6
olympux 3:69e1c4ed69e1 7 //Debug is disabled by default
olympux 3:69e1c4ed69e1 8 #if 1
olympux 3:69e1c4ed69e1 9 //Enable debug
olympux 3:69e1c4ed69e1 10 #include <cstdio>
olympux 3:69e1c4ed69e1 11 #define DBG(x, ...) std::printf("[main : DBG]"x"\r\n", ##__VA_ARGS__);
olympux 3:69e1c4ed69e1 12 #define WARN(x, ...) std::printf("[main : WARN]"x"\r\n", ##__VA_ARGS__);
olympux 3:69e1c4ed69e1 13 #define ERR(x, ...) std::printf("[main : ERR]"x"\r\n", ##__VA_ARGS__);
olympux 3:69e1c4ed69e1 14
olympux 3:69e1c4ed69e1 15 #else
olympux 3:69e1c4ed69e1 16 //Disable debug
olympux 3:69e1c4ed69e1 17 #define DBG(x, ...)
olympux 3:69e1c4ed69e1 18 #define WARN(x, ...)
olympux 3:69e1c4ed69e1 19 #define ERR(x, ...)
olympux 3:69e1c4ed69e1 20
olympux 3:69e1c4ed69e1 21 #endif
olympux 3:69e1c4ed69e1 22
olympux 3:69e1c4ed69e1 23
olympux 3:69e1c4ed69e1 24
olympux 0:aa07a25a9005 25 /*
olympux 0:aa07a25a9005 26 * Default device network configuration
olympux 0:aa07a25a9005 27 */
olympux 0:aa07a25a9005 28 #define DEFAULT_IP_ADDRESS "192.168.0.249"
olympux 0:aa07a25a9005 29 #define DEFAULT_IP_SUBNET "255.255.255.0"
olympux 0:aa07a25a9005 30 #define DEFAULT_IP_GATEWAY "192.168.0.1"
olympux 0:aa07a25a9005 31 #define DEFAULT_MAC0 0x00
olympux 0:aa07a25a9005 32 #define DEFAULT_MAC1 0x08
olympux 0:aa07a25a9005 33 #define DEFAULT_MAC2 0xDC
olympux 0:aa07a25a9005 34 #define DEFAULT_MAC3 0x00
olympux 0:aa07a25a9005 35 #define DEFAULT_MAC4 0x00
olympux 0:aa07a25a9005 36 #define DEFAULT_MAC5 0x01
olympux 0:aa07a25a9005 37
olympux 0:aa07a25a9005 38
olympux 0:aa07a25a9005 39 /*
olympux 0:aa07a25a9005 40 * Positions of variables in EEPROM array
olympux 0:aa07a25a9005 41 */
olympux 0:aa07a25a9005 42 #define IP_ADDRESS_POS 0
olympux 0:aa07a25a9005 43 #define IP_SUBNET_POS 4
olympux 0:aa07a25a9005 44 #define IP_GATEWAY_POS 8
olympux 0:aa07a25a9005 45 #define TCP_SERVER_LOCAL_PORT_POS 12
olympux 0:aa07a25a9005 46 #define UDP_SERVER_LOCAL_PORT_POS 13
olympux 0:aa07a25a9005 47 #define FIRST_RUN_FLAG_POS 14
olympux 0:aa07a25a9005 48 #define MAC_ADDRESS_POS 15
olympux 0:aa07a25a9005 49 // EEPROM: for TCP server this device connects to in TCP client mode
olympux 0:aa07a25a9005 50 #define AUTO_TRANSMIT_FLAG_POS 18
olympux 1:6bdc99dd8e0a 51 #define AUTO_TRANSMIT_TIME_PERIOD_POS 19
olympux 0:aa07a25a9005 52 #define TCP_SERVER_IP_ADDR_POS 20
olympux 0:aa07a25a9005 53 #define TCP_SERVER_PORT_POS 24
olympux 0:aa07a25a9005 54
olympux 0:aa07a25a9005 55
olympux 0:aa07a25a9005 56 /*
olympux 0:aa07a25a9005 57 * External variables in main.c
olympux 0:aa07a25a9005 58 */
olympux 0:aa07a25a9005 59 extern uint16_t VirtAddVarTab[];
olympux 0:aa07a25a9005 60
olympux 0:aa07a25a9005 61 extern uint8_t u8mac[], u8ip_addr[];// keep mac and ip address in 8-bits
olympux 0:aa07a25a9005 62 extern uint16_t u16mac_addr[], u16ip_addr[], u16ip_subnet[], u16ip_gateway[]; // 16-bits, directly loaded from eeprom
olympux 0:aa07a25a9005 63 extern char str_ip_addr[], str_ip_subnet[], str_ip_gateway[]; // for printf, converted from 16-bits u16ip_xxx
olympux 0:aa07a25a9005 64 extern uint16_t first_run; // first run flag
olympux 0:aa07a25a9005 65
olympux 0:aa07a25a9005 66 extern const uint16_t tcp_server_local_port; // fixed
olympux 0:aa07a25a9005 67 extern const uint16_t udp_server_local_port; // fixed
olympux 0:aa07a25a9005 68
olympux 0:aa07a25a9005 69 // this section is for the TCP server that this device connects to in TCP client mode
olympux 1:6bdc99dd8e0a 70 extern uint16_t auto_transmit_flag, transmit_time_period; // auto transmit status, time period = 1s
olympux 1:6bdc99dd8e0a 71 extern uint16_t u16server_ip_addr[]; // directly loaded from eeprom
olympux 1:6bdc99dd8e0a 72 extern uint16_t u16tcp_server_port; // directly loaded from eeprom
olympux 0:aa07a25a9005 73 extern uint8_t u8server_ip_addr[];
olympux 0:aa07a25a9005 74 extern char * server_ip_addr;
olympux 0:aa07a25a9005 75 extern char str_server_ip_addr[];
olympux 0:aa07a25a9005 76
olympux 0:aa07a25a9005 77
olympux 0:aa07a25a9005 78 /*
olympux 0:aa07a25a9005 79 * My eeprom functions
olympux 0:aa07a25a9005 80 */
olympux 1:6bdc99dd8e0a 81 void write_eeprom_network(char* buf);
olympux 0:aa07a25a9005 82 void load_eeprom_network(void);
olympux 1:6bdc99dd8e0a 83 void write_eeprom_tcpserver(char* buf);
olympux 0:aa07a25a9005 84 void load_eeprom_tcpserver(void);
olympux 1:6bdc99dd8e0a 85
olympux 0:aa07a25a9005 86 #endif