Used with eeprom_flash to write network configuration to STM32F103 flash

Dependents:   F103-Web-Server

Fork of my_eeprom_funcs by Chau Vo

Committer:
olympux
Date:
Mon Aug 29 21:29:38 2016 +0000
Revision:
20:858384cac44a
Parent:
19:5671f3c25342
Child:
21:23ae23754f0b
Add 2 more EEPROM variables

Who changed what in which revision?

UserRevisionLine numberNew contents of line
olympux 16:700377cd9d29 1 #ifndef __DEVICE_CONFIGURATION_H
olympux 16:700377cd9d29 2 #define __DEVICE_CONFIGURATION_H
olympux 0:aa07a25a9005 3
olympux 16:700377cd9d29 4 #include "mbed.h"
olympux 16:700377cd9d29 5 #include "eeprom_flash.h"
olympux 0:aa07a25a9005 6
olympux 3:69e1c4ed69e1 7
olympux 16:700377cd9d29 8 // Default device network configuration
olympux 19:5671f3c25342 9 #define DEFAULT_IP_ADDRESS "192.168.0.120"
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 19:5671f3c25342 12 #define DEFAULT_REMOTE_TCP_SERVER_IP "192.168.0.2"
olympux 19:5671f3c25342 13 #define DEFAULT_REMOTE_UDP_SERVER_IP "192.168.0.2"
olympux 0:aa07a25a9005 14 #define DEFAULT_MAC0 0x00
olympux 0:aa07a25a9005 15 #define DEFAULT_MAC1 0x08
olympux 0:aa07a25a9005 16 #define DEFAULT_MAC2 0xDC
olympux 0:aa07a25a9005 17 #define DEFAULT_MAC3 0x00
olympux 0:aa07a25a9005 18 #define DEFAULT_MAC4 0x00
olympux 0:aa07a25a9005 19 #define DEFAULT_MAC5 0x01
olympux 16:700377cd9d29 20 #define DEFAULT_LOCAL_TCP_SERVER_PORT 10000 // change to 7000 if internet required
olympux 18:d88314ae7979 21 #define DEFAULT_LOCAL_UDP_SERVER_PORT 11000
olympux 16:700377cd9d29 22 #define DEFAULT_TRANSMIT_PERIOD 1000
olympux 19:5671f3c25342 23 #define DEFAULT_REMOTE_TCP_SERVER_PORT 10000
olympux 19:5671f3c25342 24 #define DEFAULT_REMOTE_UDP_SERVER_PORT 11000
olympux 0:aa07a25a9005 25
olympux 6:241d1539914a 26 #define DEFAULT_ENABLE_FLAG_VALUE 0xA5A5
olympux 6:241d1539914a 27 #define DEFAULT_DISABLE_FLAG_VALUE 0xAAAA
olympux 0:aa07a25a9005 28
olympux 20:858384cac44a 29 #define DEFAULT_INTER_DATA_PERIOD 500 // in ms
olympux 20:858384cac44a 30 #define DEFAULT_SPECIAL_CHARACTER '\n' // LF
olympux 20:858384cac44a 31
olympux 16:700377cd9d29 32 // Positions of variables in EEPROM array
olympux 16:700377cd9d29 33 #define IP_ADDRESS_POS 0 // 4x16-bit
olympux 16:700377cd9d29 34 #define IP_SUBNET_POS 8 // 4x16-bit
olympux 16:700377cd9d29 35 #define IP_GATEWAY_POS 16 // 4x16-bit
olympux 16:700377cd9d29 36 #define MAC_ADDRESS_POS 24 // 3x16-bit
olympux 16:700377cd9d29 37 #define DEVICE_CONFIGURED_FLAG_POS 30 // 16-bit
olympux 16:700377cd9d29 38 #define LOCAL_TCP_SERVER_PORT_POS 32 // 16-bit
olympux 18:d88314ae7979 39 #define LOCAL_UDP_SERVER_PORT_POS 34 // 16-bit
olympux 16:700377cd9d29 40 // if TCP client is enabled, use parameters below to set parameters for the remote TCP server
olympux 16:700377cd9d29 41 #define REMOTE_TCP_SERVER_IP_ADDR_POS 36 // 4x16-bit
olympux 16:700377cd9d29 42 #define REMOTE_TCP_SERVER_PORT_POS 44 // 16-bit
olympux 16:700377cd9d29 43 #define AUTO_TRANSMIT_FLAG_POS 46 // 16-bit
olympux 16:700377cd9d29 44 #define AUTO_TRANSMIT_TIME_PERIOD_POS 48 // 16-bit
olympux 18:d88314ae7979 45 // If UDP client is enabled, use parameters below
olympux 18:d88314ae7979 46 #define REMOTE_UDP_SERVER_IP_ADDR_POS 50 // 4x16-bit
olympux 18:d88314ae7979 47 #define REMOTE_UDP_SERVER_PORT_POS 58 // 16-bit
olympux 16:700377cd9d29 48 // enable modes
olympux 18:d88314ae7979 49 #define ENABLE_TCP_SERVER_POS 60 // 16-bit
olympux 18:d88314ae7979 50 #define ENABLE_TCP_CLIENT_POS 62 // 16-bit
olympux 18:d88314ae7979 51 #define ENABLE_UDP_SERVER_POS 64 // 16-bit
olympux 18:d88314ae7979 52 #define ENABLE_UDP_CLIENT_POS 66 // 16-bit
olympux 20:858384cac44a 53 // serial inter-data period
olympux 20:858384cac44a 54 #define INTER_DATA_PERIOD_POS 68 // 16-bit
olympux 20:858384cac44a 55 // special character signals sending data
olympux 20:858384cac44a 56 #define SPECIAL_CHAR_POS 70 // 16-bit
olympux 0:aa07a25a9005 57
olympux 0:aa07a25a9005 58
olympux 16:700377cd9d29 59 // prototypes
olympux 19:5671f3c25342 60 void erase_device_configuration();
olympux 18:d88314ae7979 61 void write_device_configuration(uint16_t* ip, uint16_t* subnet, uint16_t* gateway, uint16_t* mac,
olympux 18:d88314ae7979 62 uint16_t tcp_port, uint16_t udp_port,
olympux 18:d88314ae7979 63 uint16_t* remote_tcp_ip, uint16_t remote_tcp_port, uint16_t auto_transmit, uint16_t transmit_period,
olympux 18:d88314ae7979 64 uint16_t* remote_udp_ip, uint16_t remote_udp_port,
olympux 20:858384cac44a 65 uint16_t enable_tcp_server, uint16_t enable_tcp_client, uint16_t enable_udp_server, uint16_t enable_udp_client,
olympux 20:858384cac44a 66 uint16_t inter_data_period, uint16_t special_char);
olympux 16:700377cd9d29 67 void read_device_configuration();
olympux 19:5671f3c25342 68 void reset_default_device_configuration();
olympux 1:6bdc99dd8e0a 69
olympux 0:aa07a25a9005 70 #endif