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:
Thu Sep 01 14:14:26 2016 +0000
Revision:
22:0e1d8a9e8f54
Parent:
21:23ae23754f0b
Add DHCP configuration

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 21:23ae23754f0b 32 #define DEFAULT_UART_BAUDRATE 9 // 0: 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200 (default), 10: 230400
olympux 21:23ae23754f0b 33 #define DEFAULT_UART_BITS 8 // 5 to 8 (default)
olympux 21:23ae23754f0b 34 #define DEFAULT_UART_STOPBITS 1 // 1 (default) or 2
olympux 21:23ae23754f0b 35 #define DEFAULT_UART_PARITY 0 // 0: None (default), 1: Even, 2: Odd
olympux 21:23ae23754f0b 36 #define DEFAULT_UART_HANDSHAKE 0 // 0: None (default), 1: RTS/CTS
olympux 21:23ae23754f0b 37
olympux 16:700377cd9d29 38 // Positions of variables in EEPROM array
olympux 16:700377cd9d29 39 #define IP_ADDRESS_POS 0 // 4x16-bit
olympux 16:700377cd9d29 40 #define IP_SUBNET_POS 8 // 4x16-bit
olympux 16:700377cd9d29 41 #define IP_GATEWAY_POS 16 // 4x16-bit
olympux 16:700377cd9d29 42 #define MAC_ADDRESS_POS 24 // 3x16-bit
olympux 16:700377cd9d29 43 #define DEVICE_CONFIGURED_FLAG_POS 30 // 16-bit
olympux 16:700377cd9d29 44 #define LOCAL_TCP_SERVER_PORT_POS 32 // 16-bit
olympux 18:d88314ae7979 45 #define LOCAL_UDP_SERVER_PORT_POS 34 // 16-bit
olympux 16:700377cd9d29 46 // if TCP client is enabled, use parameters below to set parameters for the remote TCP server
olympux 16:700377cd9d29 47 #define REMOTE_TCP_SERVER_IP_ADDR_POS 36 // 4x16-bit
olympux 16:700377cd9d29 48 #define REMOTE_TCP_SERVER_PORT_POS 44 // 16-bit
olympux 16:700377cd9d29 49 #define AUTO_TRANSMIT_FLAG_POS 46 // 16-bit
olympux 16:700377cd9d29 50 #define AUTO_TRANSMIT_TIME_PERIOD_POS 48 // 16-bit
olympux 18:d88314ae7979 51 // If UDP client is enabled, use parameters below
olympux 18:d88314ae7979 52 #define REMOTE_UDP_SERVER_IP_ADDR_POS 50 // 4x16-bit
olympux 18:d88314ae7979 53 #define REMOTE_UDP_SERVER_PORT_POS 58 // 16-bit
olympux 16:700377cd9d29 54 // enable modes
olympux 18:d88314ae7979 55 #define ENABLE_TCP_SERVER_POS 60 // 16-bit
olympux 18:d88314ae7979 56 #define ENABLE_TCP_CLIENT_POS 62 // 16-bit
olympux 18:d88314ae7979 57 #define ENABLE_UDP_SERVER_POS 64 // 16-bit
olympux 18:d88314ae7979 58 #define ENABLE_UDP_CLIENT_POS 66 // 16-bit
olympux 20:858384cac44a 59 // serial inter-data period
olympux 20:858384cac44a 60 #define INTER_DATA_PERIOD_POS 68 // 16-bit
olympux 20:858384cac44a 61 // special character signals sending data
olympux 20:858384cac44a 62 #define SPECIAL_CHAR_POS 70 // 16-bit
olympux 21:23ae23754f0b 63 // Uart
olympux 21:23ae23754f0b 64 #define UART_BAUDRATE_POS 72 // 16-bit
olympux 21:23ae23754f0b 65 #define UART_BITS_POS 74 // 16-bit
olympux 21:23ae23754f0b 66 #define UART_STOPBITS_POS 76 // 16-bit
olympux 21:23ae23754f0b 67 #define UART_PARITY_POS 78 // 16-bit
olympux 21:23ae23754f0b 68 #define UART_HANDSHAKE_POS 80 // 16-bit
olympux 22:0e1d8a9e8f54 69 // DHCP vs Static
olympux 22:0e1d8a9e8f54 70 #define ENABLE_DHCP_POS 82 // 16-bit
olympux 0:aa07a25a9005 71
olympux 0:aa07a25a9005 72
olympux 16:700377cd9d29 73 // prototypes
olympux 19:5671f3c25342 74 void erase_device_configuration();
olympux 18:d88314ae7979 75 void write_device_configuration(uint16_t* ip, uint16_t* subnet, uint16_t* gateway, uint16_t* mac,
olympux 18:d88314ae7979 76 uint16_t tcp_port, uint16_t udp_port,
olympux 18:d88314ae7979 77 uint16_t* remote_tcp_ip, uint16_t remote_tcp_port, uint16_t auto_transmit, uint16_t transmit_period,
olympux 18:d88314ae7979 78 uint16_t* remote_udp_ip, uint16_t remote_udp_port,
olympux 20:858384cac44a 79 uint16_t enable_tcp_server, uint16_t enable_tcp_client, uint16_t enable_udp_server, uint16_t enable_udp_client,
olympux 21:23ae23754f0b 80 uint16_t inter_data_period, uint16_t special_char,
olympux 22:0e1d8a9e8f54 81 uint16_t uart_baudrate, uint16_t uart_bits, uint16_t uart_stopbits, uint16_t uart_parity, uint16_t uart_handshake,
olympux 22:0e1d8a9e8f54 82 uint16_t enable_dhcp);
olympux 16:700377cd9d29 83 void read_device_configuration();
olympux 19:5671f3c25342 84 void reset_default_device_configuration();
olympux 1:6bdc99dd8e0a 85
olympux 0:aa07a25a9005 86 #endif