Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of my_eeprom_funcs by
Diff: device_configuration.cpp
- Revision:
- 21:23ae23754f0b
- Parent:
- 20:858384cac44a
- Child:
- 22:0e1d8a9e8f54
--- a/device_configuration.cpp Mon Aug 29 21:29:38 2016 +0000
+++ b/device_configuration.cpp Thu Sep 01 12:22:10 2016 +0000
@@ -48,6 +48,8 @@
uint16_t u16InterDataPeriod;
// special character to signal sending data
uint16_t u16SpecialChar;
+// uart
+uint16_t u16UartBaudrate, u16UartBits, u16UartStopBits, u16UartParity, u16UartHandshake;
// extra, not actually in EEPROM
uint8_t u8IpAddr[4]; // keep device ip address in 8-bits
@@ -79,7 +81,8 @@
uint16_t* remote_tcp_ip, uint16_t remote_tcp_port, uint16_t auto_transmit, uint16_t transmit_period,
uint16_t* remote_udp_ip, uint16_t remote_udp_port,
uint16_t enable_tcp_server, uint16_t enable_tcp_client, uint16_t enable_udp_server, uint16_t enable_udp_client,
- uint16_t inter_data_period, uint16_t special_char) {
+ uint16_t inter_data_period, uint16_t special_char,
+ uint16_t uart_baudrate, uint16_t uart_bits, uint16_t uart_stopbits, uint16_t uart_parity, uint16_t uart_handshake) {
// Write network configuration
// 4-byte IP address + 4-byte subnet + 4-byte gateway + 3-byte MAC
// + local TCP server port + local UDP port
@@ -152,6 +155,13 @@
// Special char
writeEEPROMHalfWord(SPECIAL_CHAR_POS, special_char);
+ // UART
+ writeEEPROMHalfWord(UART_BAUDRATE_POS, uart_baudrate);
+ writeEEPROMHalfWord(UART_BITS_POS, uart_bits);
+ writeEEPROMHalfWord(UART_STOPBITS_POS, uart_stopbits);
+ writeEEPROMHalfWord(UART_PARITY_POS, uart_parity);
+ writeEEPROMHalfWord(UART_HANDSHAKE_POS, uart_handshake);
+
disableEEPROMWriting();
INFO("Successful");
@@ -248,6 +258,14 @@
// Special character
u16SpecialChar = readEEPROMHalfWord(SPECIAL_CHAR_POS);
+ // UART
+ u16UartBaudrate = readEEPROMHalfWord(UART_BAUDRATE_POS);
+ u16UartBits = readEEPROMHalfWord(UART_BITS_POS);
+ u16UartStopBits = readEEPROMHalfWord(UART_STOPBITS_POS);
+ u16UartParity = readEEPROMHalfWord(UART_PARITY_POS);
+ u16UartHandshake = readEEPROMHalfWord(UART_HANDSHAKE_POS);
+
+ // convert to strings
sprintf(strIpAddr, "%d.%d.%d.%d", u8IpAddr[0], u8IpAddr[1], u8IpAddr[2], u8IpAddr[3]);
sprintf(strIpSubnet, "%d.%d.%d.%d", (uint8_t)u16IpSubnet[0], (uint8_t)u16IpSubnet[1], (uint8_t)u16IpSubnet[2], (uint8_t)u16IpSubnet[3]);
sprintf(strIpGateway, "%d.%d.%d.%d", (uint8_t)u16IpGateway[0], (uint8_t)u16IpGateway[1], (uint8_t)u16IpGateway[2], (uint8_t)u16IpGateway[3]);
@@ -285,6 +303,11 @@
u16InterDataPeriod = DEFAULT_INTER_DATA_PERIOD;
u16SpecialChar = DEFAULT_SPECIAL_CHARACTER;
+ u16UartBaudrate = DEFAULT_UART_BAUDRATE;
+ u16UartBits = DEFAULT_UART_BITS;
+ u16UartStopBits = DEFAULT_UART_STOPBITS;
+ u16UartParity = DEFAULT_UART_PARITY;
+ u16UartHandshake = DEFAULT_UART_HANDSHAKE;
}
INFO("Successful");
@@ -338,6 +361,12 @@
uint16_t inter_data_period = DEFAULT_INTER_DATA_PERIOD;
uint16_t special_char = DEFAULT_SPECIAL_CHARACTER;
+ uint16_t uart_baudrate = DEFAULT_UART_BAUDRATE;
+ uint16_t uart_bits = DEFAULT_UART_BITS;
+ uint16_t uart_stopbits = DEFAULT_UART_STOPBITS;
+ uint16_t uart_parity = DEFAULT_UART_PARITY;
+ uint16_t uart_handshake = DEFAULT_UART_HANDSHAKE;
+
// erase the device configured flag
erase_device_configuration();
@@ -347,5 +376,6 @@
remote_tcp_ip, remote_tcp_port, auto_transmit, transmit_period,
remote_udp_ip, remote_udp_port,
enable_tcp_server, enable_tcp_client, enable_udp_server, enable_udp_client,
- inter_data_period, special_char);
+ inter_data_period, special_char,
+ uart_baudrate, uart_bits, uart_stopbits, uart_parity, uart_handshake);
}
