Used with eeprom_flash to write network configuration to STM32F103 flash

Dependents:   F103-Web-Server

Fork of my_eeprom_funcs by Chau Vo

device_configuration.h

Committer:
olympux
Date:
2016-08-14
Revision:
16:700377cd9d29
Parent:
my_eeprom_funcs.h@ 12:613ab276bf37
Child:
18:d88314ae7979

File content as of revision 16:700377cd9d29:

#ifndef __DEVICE_CONFIGURATION_H
#define __DEVICE_CONFIGURATION_H

#include "mbed.h"
#include "eeprom_flash.h"


// Default device network configuration
#define DEFAULT_IP_ADDRESS      "192.168.0.239"
#define DEFAULT_IP_SUBNET       "255.255.255.0"
#define DEFAULT_IP_GATEWAY      "192.168.0.1"
#define DEFAULT_REMOTE_TCP_SERVER_IP      "0.0.0.0"
#define DEFAULT_MAC0            0x00
#define DEFAULT_MAC1            0x08
#define DEFAULT_MAC2            0xDC
#define DEFAULT_MAC3            0x00
#define DEFAULT_MAC4            0x00
#define DEFAULT_MAC5            0x01
#define DEFAULT_LOCAL_TCP_SERVER_PORT   10000 // change to 7000 if internet required
#define DEFAULT_LOCAL_UDP_PORT          11000
#define DEFAULT_TRANSMIT_PERIOD         1000

#define DEFAULT_ENABLE_FLAG_VALUE   0xA5A5
#define DEFAULT_DISABLE_FLAG_VALUE  0xAAAA

// Positions of variables in EEPROM array
#define IP_ADDRESS_POS         0 // 4x16-bit
#define IP_SUBNET_POS          8 // 4x16-bit
#define IP_GATEWAY_POS         16 // 4x16-bit
#define MAC_ADDRESS_POS             24 // 3x16-bit
#define DEVICE_CONFIGURED_FLAG_POS  30 // 16-bit
#define LOCAL_TCP_SERVER_PORT_POS   32 // 16-bit
#define LOCAL_UDP_PORT_POS          34 // 16-bit
// if TCP client is enabled, use parameters below to set parameters for the remote TCP server
#define REMOTE_TCP_SERVER_IP_ADDR_POS   36 // 4x16-bit
#define REMOTE_TCP_SERVER_PORT_POS      44 // 16-bit
#define AUTO_TRANSMIT_FLAG_POS          46 // 16-bit
#define AUTO_TRANSMIT_TIME_PERIOD_POS   48 // 16-bit
// enable modes
#define ENABLE_TCP_SERVER_POS   50 // 16-bit
#define ENABLE_TCP_CLIENT_POS   52 // 16-bit
#define ENABLE_UDP_MODE_POS     54 // 16-bit


// prototypes
void write_device_configuration(uint16_t* ip, uint16_t* subnet, uint16_t* gateway,
            uint16_t* mac, uint16_t tcp_port, uint16_t udp_port,
            uint16_t* remote_ip, uint16_t remote_port, uint16_t auto_transmit, uint16_t transmit_period,
            uint16_t enable_tcp_server, uint16_t enable_tcp_client, uint16_t enable_udp);
void reset_device_configuration();
void read_device_configuration();

#endif