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:
Tue Aug 23 11:05:38 2016 +0000
Revision:
19:5671f3c25342
Parent:
18:d88314ae7979
Child:
20:858384cac44a
Upgraded EEPROM functions

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 16:700377cd9d29 29 // Positions of variables in EEPROM array
olympux 16:700377cd9d29 30 #define IP_ADDRESS_POS 0 // 4x16-bit
olympux 16:700377cd9d29 31 #define IP_SUBNET_POS 8 // 4x16-bit
olympux 16:700377cd9d29 32 #define IP_GATEWAY_POS 16 // 4x16-bit
olympux 16:700377cd9d29 33 #define MAC_ADDRESS_POS 24 // 3x16-bit
olympux 16:700377cd9d29 34 #define DEVICE_CONFIGURED_FLAG_POS 30 // 16-bit
olympux 16:700377cd9d29 35 #define LOCAL_TCP_SERVER_PORT_POS 32 // 16-bit
olympux 18:d88314ae7979 36 #define LOCAL_UDP_SERVER_PORT_POS 34 // 16-bit
olympux 16:700377cd9d29 37 // if TCP client is enabled, use parameters below to set parameters for the remote TCP server
olympux 16:700377cd9d29 38 #define REMOTE_TCP_SERVER_IP_ADDR_POS 36 // 4x16-bit
olympux 16:700377cd9d29 39 #define REMOTE_TCP_SERVER_PORT_POS 44 // 16-bit
olympux 16:700377cd9d29 40 #define AUTO_TRANSMIT_FLAG_POS 46 // 16-bit
olympux 16:700377cd9d29 41 #define AUTO_TRANSMIT_TIME_PERIOD_POS 48 // 16-bit
olympux 18:d88314ae7979 42 // If UDP client is enabled, use parameters below
olympux 18:d88314ae7979 43 #define REMOTE_UDP_SERVER_IP_ADDR_POS 50 // 4x16-bit
olympux 18:d88314ae7979 44 #define REMOTE_UDP_SERVER_PORT_POS 58 // 16-bit
olympux 16:700377cd9d29 45 // enable modes
olympux 18:d88314ae7979 46 #define ENABLE_TCP_SERVER_POS 60 // 16-bit
olympux 18:d88314ae7979 47 #define ENABLE_TCP_CLIENT_POS 62 // 16-bit
olympux 18:d88314ae7979 48 #define ENABLE_UDP_SERVER_POS 64 // 16-bit
olympux 18:d88314ae7979 49 #define ENABLE_UDP_CLIENT_POS 66 // 16-bit
olympux 0:aa07a25a9005 50
olympux 0:aa07a25a9005 51
olympux 16:700377cd9d29 52 // prototypes
olympux 19:5671f3c25342 53 void erase_device_configuration();
olympux 18:d88314ae7979 54 void write_device_configuration(uint16_t* ip, uint16_t* subnet, uint16_t* gateway, uint16_t* mac,
olympux 18:d88314ae7979 55 uint16_t tcp_port, uint16_t udp_port,
olympux 18:d88314ae7979 56 uint16_t* remote_tcp_ip, uint16_t remote_tcp_port, uint16_t auto_transmit, uint16_t transmit_period,
olympux 18:d88314ae7979 57 uint16_t* remote_udp_ip, uint16_t remote_udp_port,
olympux 18:d88314ae7979 58 uint16_t enable_tcp_server, uint16_t enable_tcp_client, uint16_t enable_udp_server, uint16_t enable_udp_client);
olympux 16:700377cd9d29 59 void read_device_configuration();
olympux 19:5671f3c25342 60 void reset_default_device_configuration();
olympux 1:6bdc99dd8e0a 61
olympux 0:aa07a25a9005 62 #endif