Central Heating controller using the real time clock, PHY module for internet, 1-wire interface for temperature sensors, a system log and a configuration file

Dependencies:   net 1-wire lpc1768 crypto clock web fram log

/media/uploads/andrewboyson/heating.sch

/media/uploads/andrewboyson/heating.brd

/media/uploads/andrewboyson/eagle.epf

Committer:
andrewboyson
Date:
Fri Apr 23 08:36:42 2021 +0000
Revision:
106:41ed3ea0bbba
Parent:
103:15583327fcdd
Not working, crashes.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 0:3c04f4b47041 1 #include <stdbool.h>
andrewboyson 8:8b5e0bb28da0 2 #include <stdlib.h>
andrewboyson 28:bb55def47737 3 #include <string.h>
andrewboyson 0:3c04f4b47041 4
andrewboyson 21:0c9673027ff9 5 #include "clkgov.h"
andrewboyson 8:8b5e0bb28da0 6 #include "fram.h"
andrewboyson 8:8b5e0bb28da0 7 #include "log.h"
andrewboyson 8:8b5e0bb28da0 8 #include "net.h"
andrewboyson 8:8b5e0bb28da0 9 #include "link.h"
andrewboyson 8:8b5e0bb28da0 10 #include "dnsname.h"
andrewboyson 8:8b5e0bb28da0 11 #include "dnsquery.h"
andrewboyson 8:8b5e0bb28da0 12 #include "dnsreply.h"
andrewboyson 8:8b5e0bb28da0 13 #include "dnsserver.h"
andrewboyson 38:2bfeefa8709a 14 #include "dnslabel.h"
andrewboyson 8:8b5e0bb28da0 15 #include "ntp.h"
andrewboyson 8:8b5e0bb28da0 16 #include "dhcp.h"
andrewboyson 8:8b5e0bb28da0 17 #include "ns.h"
andrewboyson 101:77fd93f0bde1 18 #include "nr.h"
andrewboyson 28:bb55def47737 19 #include "ntpclient.h"
andrewboyson 8:8b5e0bb28da0 20 #include "1-wire.h"
andrewboyson 8:8b5e0bb28da0 21 #include "echo4.h"
andrewboyson 8:8b5e0bb28da0 22 #include "echo6.h"
andrewboyson 8:8b5e0bb28da0 23 #include "dest6.h"
andrewboyson 8:8b5e0bb28da0 24 #include "ra.h"
andrewboyson 8:8b5e0bb28da0 25 #include "rs.h"
andrewboyson 8:8b5e0bb28da0 26 #include "ar4.h"
andrewboyson 8:8b5e0bb28da0 27 #include "ar6.h"
andrewboyson 8:8b5e0bb28da0 28 #include "arp.h"
andrewboyson 8:8b5e0bb28da0 29 #include "ip4.h"
andrewboyson 8:8b5e0bb28da0 30 #include "ip6.h"
andrewboyson 8:8b5e0bb28da0 31 #include "udp.h"
andrewboyson 8:8b5e0bb28da0 32 #include "tcp.h"
andrewboyson 74:8228f0297227 33 #include "web.h"
andrewboyson 8:8b5e0bb28da0 34 #include "tftp.h"
andrewboyson 8:8b5e0bb28da0 35 #include "dns.h"
andrewboyson 28:bb55def47737 36 #include "led.h"
andrewboyson 0:3c04f4b47041 37
andrewboyson 21:0c9673027ff9 38 static int iClkGovSlewDivisor ;
andrewboyson 21:0c9673027ff9 39 static int iClkGovSlewMaxMs ;
andrewboyson 21:0c9673027ff9 40 static int iClkGovPpbDivisor ;
andrewboyson 21:0c9673027ff9 41 static int iClkGovPpbChangeMax ;
andrewboyson 21:0c9673027ff9 42 static int iClkGovSyncedLimitNs ;
andrewboyson 21:0c9673027ff9 43 static int iClkGovSyncedLimitPpb ;
andrewboyson 21:0c9673027ff9 44 static int iClkGovSyncedHysterisNs ;
andrewboyson 21:0c9673027ff9 45 static int iClkGovSyncedHysterisPpb;
andrewboyson 21:0c9673027ff9 46 static int iClkGovMaxOffsetSecs ;
andrewboyson 21:0c9673027ff9 47 static int iClkGov;
andrewboyson 8:8b5e0bb28da0 48
andrewboyson 8:8b5e0bb28da0 49 static int iOneWire;
andrewboyson 8:8b5e0bb28da0 50
andrewboyson 8:8b5e0bb28da0 51 static int iDnsSendRequestsViaIp4 ;
andrewboyson 8:8b5e0bb28da0 52 static int iNtpSendRequestsViaIp4 ;
andrewboyson 8:8b5e0bb28da0 53 static int iTftpSendRequestsViaIp4;
andrewboyson 0:3c04f4b47041 54
andrewboyson 8:8b5e0bb28da0 55 static int iNetHost;
andrewboyson 8:8b5e0bb28da0 56 static int iLogUart;
andrewboyson 8:8b5e0bb28da0 57 static int iNetStack;
andrewboyson 8:8b5e0bb28da0 58 static int iNetNewLine;
andrewboyson 8:8b5e0bb28da0 59 static int iNetVerbose;
andrewboyson 8:8b5e0bb28da0 60 static int iLink;
andrewboyson 8:8b5e0bb28da0 61 static int iDnsName;
andrewboyson 8:8b5e0bb28da0 62 static int iDnsQuery;
andrewboyson 8:8b5e0bb28da0 63 static int iDnsReply;
andrewboyson 8:8b5e0bb28da0 64 static int iDnsServer;
andrewboyson 8:8b5e0bb28da0 65 static int iNtp;
andrewboyson 8:8b5e0bb28da0 66 static int iDhcp;
andrewboyson 8:8b5e0bb28da0 67 static int iNsRecvSol;
andrewboyson 8:8b5e0bb28da0 68 static int iNsRecvAdv;
andrewboyson 8:8b5e0bb28da0 69 static int iNsSendSol;
andrewboyson 8:8b5e0bb28da0 70 static int iNr4;
andrewboyson 101:77fd93f0bde1 71 static int iNr;
andrewboyson 8:8b5e0bb28da0 72 static int iNtpClient;
andrewboyson 8:8b5e0bb28da0 73 static int iEcho4;
andrewboyson 8:8b5e0bb28da0 74 static int iEcho6;
andrewboyson 8:8b5e0bb28da0 75 static int iDest6;
andrewboyson 8:8b5e0bb28da0 76 static int iRa;
andrewboyson 8:8b5e0bb28da0 77 static int iRs;
andrewboyson 8:8b5e0bb28da0 78 static int iAr4;
andrewboyson 8:8b5e0bb28da0 79 static int iAr6;
andrewboyson 8:8b5e0bb28da0 80 static int iArp;
andrewboyson 8:8b5e0bb28da0 81 static int iIp4;
andrewboyson 8:8b5e0bb28da0 82 static int iIp6;
andrewboyson 8:8b5e0bb28da0 83 static int iUdp;
andrewboyson 8:8b5e0bb28da0 84 static int iTcp;
andrewboyson 8:8b5e0bb28da0 85 static int iHttp;
andrewboyson 8:8b5e0bb28da0 86 static int iTftp;
andrewboyson 8:8b5e0bb28da0 87
andrewboyson 106:41ed3ea0bbba 88 //Values
andrewboyson 106:41ed3ea0bbba 89 static int iValuesServerName;
andrewboyson 106:41ed3ea0bbba 90 void SetValuesServerName(char* value) { FramWrite(iValuesServerName, DNS_MAX_LABEL_LENGTH, value); }
andrewboyson 106:41ed3ea0bbba 91 void GetValuesServerName(char* value) { FramRead (iValuesServerName, DNS_MAX_LABEL_LENGTH, value); value[DNS_MAX_LABEL_LENGTH] = 0; }
andrewboyson 106:41ed3ea0bbba 92
andrewboyson 106:41ed3ea0bbba 93 static int iValuesFileName;
andrewboyson 106:41ed3ea0bbba 94 void SetValuesFileName(char* value) { FramWrite(iValuesFileName, DNS_MAX_LABEL_LENGTH, value); }
andrewboyson 106:41ed3ea0bbba 95 void GetValuesFileName(char* value) { FramRead (iValuesFileName, DNS_MAX_LABEL_LENGTH, value); value[DNS_MAX_LABEL_LENGTH] = 0; }
andrewboyson 106:41ed3ea0bbba 96
andrewboyson 106:41ed3ea0bbba 97 static int iValuesWriteSize;
andrewboyson 106:41ed3ea0bbba 98 void SetValuesWriteSize(int* pValue) { FramWrite(iValuesWriteSize, 4, pValue); }
andrewboyson 106:41ed3ea0bbba 99 void GetValuesWriteSize(int* pValue) { FramRead (iValuesWriteSize, 4, pValue); }
andrewboyson 106:41ed3ea0bbba 100
andrewboyson 106:41ed3ea0bbba 101 static int iValuesReadInterval;
andrewboyson 106:41ed3ea0bbba 102 void SetValuesReadInterval(int* pValue) { FramWrite(iValuesReadInterval, 4, pValue); }
andrewboyson 106:41ed3ea0bbba 103 void GetValuesReadInterval(int* pValue) { FramRead (iValuesReadInterval, 4, pValue); }
andrewboyson 106:41ed3ea0bbba 104
andrewboyson 106:41ed3ea0bbba 105 static int iValuesStartTime;
andrewboyson 106:41ed3ea0bbba 106 void SetValuesStartTime(int64_t* pValue) { FramWrite(iValuesStartTime, 8, pValue); }
andrewboyson 106:41ed3ea0bbba 107 void GetValuesStartTime(int64_t* pValue) { FramRead (iValuesStartTime, 8, pValue); }
andrewboyson 106:41ed3ea0bbba 108
andrewboyson 106:41ed3ea0bbba 109 static int iValuesCount;
andrewboyson 106:41ed3ea0bbba 110 void SetValuesCount(int* pValue) { FramWrite(iValuesCount, 4, pValue); }
andrewboyson 106:41ed3ea0bbba 111 void GetValuesCount(int* pValue) { FramRead (iValuesCount, 4, pValue); }
andrewboyson 106:41ed3ea0bbba 112
andrewboyson 106:41ed3ea0bbba 113 static int iValuesData;
andrewboyson 106:41ed3ea0bbba 114 void GetValuesData(int index, char* pValue) { FramRead (iValuesData + index, 1, pValue); }
andrewboyson 106:41ed3ea0bbba 115 void SetValuesData(int count, void* pValue) { FramWrite(iValuesData + 8 * count, 8, pValue); }
andrewboyson 106:41ed3ea0bbba 116
andrewboyson 8:8b5e0bb28da0 117 //Clock settings
andrewboyson 32:bbf9c8b45a2e 118 void SetClockSlewDivisor (int value) { ClkGovSlewDivisor = value; FramWrite(iClkGovSlewDivisor, 4, &ClkGovSlewDivisor ); }
andrewboyson 32:bbf9c8b45a2e 119 void SetClockSlewMaxMs (int value) { ClkGovSlewChangeMaxMs = value; FramWrite(iClkGovSlewMaxMs, 4, &ClkGovSlewChangeMaxMs ); }
andrewboyson 32:bbf9c8b45a2e 120 void SetClockPpbDivisor (int value) { ClkGovFreqDivisor = value; FramWrite(iClkGovPpbDivisor, 4, &ClkGovFreqDivisor ); }
andrewboyson 32:bbf9c8b45a2e 121 void SetClockPpbChangeMax (int value) { ClkGovFreqChangeMaxPpb = value; FramWrite(iClkGovPpbChangeMax, 4, &ClkGovFreqChangeMaxPpb ); }
andrewboyson 32:bbf9c8b45a2e 122 void SetClockSyncedLimitNs (int value) { ClkGovSlewSyncedLimNs = value; FramWrite(iClkGovSyncedLimitNs, 4, &ClkGovSlewSyncedLimNs ); }
andrewboyson 32:bbf9c8b45a2e 123 void SetClockSyncedLimitPpb (int value) { ClkGovFreqSyncedLimPpb = value; FramWrite(iClkGovSyncedLimitPpb, 4, &ClkGovFreqSyncedLimPpb ); }
andrewboyson 32:bbf9c8b45a2e 124 void SetClockSyncedHysterisNs (int value) { ClkGovSlewSyncedHysNs = value; FramWrite(iClkGovSyncedHysterisNs, 4, &ClkGovSlewSyncedHysNs ); }
andrewboyson 32:bbf9c8b45a2e 125 void SetClockSyncedHysterisPpb(int value) { ClkGovFreqSyncedHysPpb = value; FramWrite(iClkGovSyncedHysterisPpb, 4, &ClkGovFreqSyncedHysPpb ); }
andrewboyson 32:bbf9c8b45a2e 126 void SetClockMaxOffsetSecs (int value) { ClkGovSlewOffsetMaxSecs = value; FramWrite(iClkGovMaxOffsetSecs, 4, &ClkGovSlewOffsetMaxSecs); }
andrewboyson 32:bbf9c8b45a2e 127 void ChgTraceSync () { ClkGovTrace = !ClkGovTrace ; FramWrite(iClkGov, 1, &ClkGovTrace ); }
andrewboyson 8:8b5e0bb28da0 128
andrewboyson 45:21033b9620c1 129 //Log settings
andrewboyson 45:21033b9620c1 130 void ChgLogUart () { LogUart = !LogUart; FramWrite(iLogUart, 1, &LogUart ); }
andrewboyson 45:21033b9620c1 131
andrewboyson 8:8b5e0bb28da0 132 //Heating settings
andrewboyson 13:2ca12dd42e91 133 void ChgTraceOneWire () { OneWireTrace = !OneWireTrace ; FramWrite(iOneWire, 1, &OneWireTrace ); }
andrewboyson 8:8b5e0bb28da0 134
andrewboyson 8:8b5e0bb28da0 135 //Net settings
andrewboyson 28:bb55def47737 136 void ChgDnsSendRequestsViaIp4 () { DnsSendRequestsViaIp4 = !DnsSendRequestsViaIp4; FramWrite( iDnsSendRequestsViaIp4, 1, &DnsSendRequestsViaIp4); }
andrewboyson 28:bb55def47737 137 void ChgNtpSendRequestsViaIp4 () { NtpClientQuerySendRequestsViaIp4 = !NtpClientQuerySendRequestsViaIp4; FramWrite( iNtpSendRequestsViaIp4, 1, &NtpClientQuerySendRequestsViaIp4); }
andrewboyson 28:bb55def47737 138 void ChgTftpSendRequestsViaIp4 () { TftpSendRequestsViaIp4 = !TftpSendRequestsViaIp4; FramWrite(iTftpSendRequestsViaIp4, 1, &TftpSendRequestsViaIp4); }
andrewboyson 8:8b5e0bb28da0 139
andrewboyson 8:8b5e0bb28da0 140 void SetTraceNetHost (char* text)
andrewboyson 8:8b5e0bb28da0 141 {
andrewboyson 8:8b5e0bb28da0 142 int value = strtol(text, NULL, 16);
andrewboyson 8:8b5e0bb28da0 143 NetTraceHost[1] = value & 0xFF;
andrewboyson 8:8b5e0bb28da0 144 NetTraceHost[0] = (value >> 8) & 0xFF;
andrewboyson 8:8b5e0bb28da0 145 FramWrite(iNetHost, 2, NetTraceHost);
andrewboyson 8:8b5e0bb28da0 146 }
andrewboyson 8:8b5e0bb28da0 147 void ChgTraceNetStack () { NetTraceStack = !NetTraceStack; FramWrite(iNetStack, 1, &NetTraceStack ); }
andrewboyson 8:8b5e0bb28da0 148 void ChgTraceNetNewLine() { NetTraceNewLine = !NetTraceNewLine; FramWrite(iNetNewLine, 1, &NetTraceNewLine); }
andrewboyson 8:8b5e0bb28da0 149 void ChgTraceNetVerbose() { NetTraceVerbose = !NetTraceVerbose; FramWrite(iNetVerbose, 1, &NetTraceVerbose); }
andrewboyson 8:8b5e0bb28da0 150 void ChgTraceLink () { LinkTrace = !LinkTrace; FramWrite(iLink, 1, &LinkTrace ); }
andrewboyson 8:8b5e0bb28da0 151 void ChgTraceDnsName () { DnsNameTrace = !DnsNameTrace; FramWrite(iDnsName, 1, &DnsNameTrace ); }
andrewboyson 8:8b5e0bb28da0 152 void ChgTraceDnsQuery () { DnsQueryTrace = !DnsQueryTrace; FramWrite(iDnsQuery, 1, &DnsQueryTrace ); }
andrewboyson 8:8b5e0bb28da0 153 void ChgTraceDnsReply () { DnsReplyTrace = !DnsReplyTrace; FramWrite(iDnsReply, 1, &DnsReplyTrace ); }
andrewboyson 8:8b5e0bb28da0 154 void ChgTraceDnsServer () { DnsServerTrace = !DnsServerTrace; FramWrite(iDnsServer, 1, &DnsServerTrace ); }
andrewboyson 8:8b5e0bb28da0 155 void ChgTraceNtp () { NtpTrace = !NtpTrace; FramWrite(iNtp, 1, &NtpTrace ); }
andrewboyson 8:8b5e0bb28da0 156 void ChgTraceDhcp () { DhcpTrace = !DhcpTrace; FramWrite(iDhcp, 1, &DhcpTrace ); }
andrewboyson 8:8b5e0bb28da0 157 void ChgTraceNsRecvSol () { NsTraceRecvSol = !NsTraceRecvSol; FramWrite(iNsRecvSol, 1, &NsTraceRecvSol); }
andrewboyson 8:8b5e0bb28da0 158 void ChgTraceNsRecvAdv () { NsTraceRecvAdv = !NsTraceRecvAdv; FramWrite(iNsRecvAdv, 1, &NsTraceRecvAdv); }
andrewboyson 8:8b5e0bb28da0 159 void ChgTraceNsSendSol () { NsTraceSendSol = !NsTraceSendSol; FramWrite(iNsSendSol, 1, &NsTraceSendSol); }
andrewboyson 8:8b5e0bb28da0 160 void ChgTraceNr4 () { Nr4Trace = !Nr4Trace ; FramWrite(iNr4, 1, &Nr4Trace ); }
andrewboyson 103:15583327fcdd 161 void ChgTraceNr () { NrTrace = !NrTrace ; FramWrite(iNr, 1, &NrTrace ); }
andrewboyson 8:8b5e0bb28da0 162 void ChgTraceNtpClient () { NtpClientTrace = !NtpClientTrace ; FramWrite(iNtpClient, 1, &NtpClientTrace ); }
andrewboyson 8:8b5e0bb28da0 163 void ChgTraceEcho4 () { Echo4Trace = !Echo4Trace ; FramWrite(iEcho4, 1, &Echo4Trace ); }
andrewboyson 8:8b5e0bb28da0 164 void ChgTraceEcho6 () { Echo6Trace = !Echo6Trace ; FramWrite(iEcho6, 1, &Echo6Trace ); }
andrewboyson 8:8b5e0bb28da0 165 void ChgTraceDest6 () { Dest6Trace = !Dest6Trace ; FramWrite(iDest6, 1, &Dest6Trace ); }
andrewboyson 8:8b5e0bb28da0 166 void ChgTraceRa () { RaTrace = !RaTrace ; FramWrite(iRa, 1, &RaTrace ); }
andrewboyson 8:8b5e0bb28da0 167 void ChgTraceRs () { RsTrace = !RsTrace ; FramWrite(iRs, 1, &RsTrace ); }
andrewboyson 8:8b5e0bb28da0 168 void ChgTraceAr4 () { Ar4Trace = !Ar4Trace ; FramWrite(iAr4, 1, &Ar4Trace ); }
andrewboyson 8:8b5e0bb28da0 169 void ChgTraceAr6 () { Ar6Trace = !Ar6Trace ; FramWrite(iAr6, 1, &Ar6Trace ); }
andrewboyson 8:8b5e0bb28da0 170 void ChgTraceArp () { ArpTrace = !ArpTrace ; FramWrite(iArp, 1, &ArpTrace ); }
andrewboyson 8:8b5e0bb28da0 171 void ChgTraceIp4 () { Ip4Trace = !Ip4Trace ; FramWrite(iIp4, 1, &Ip4Trace ); }
andrewboyson 8:8b5e0bb28da0 172 void ChgTraceIp6 () { Ip6Trace = !Ip6Trace ; FramWrite(iIp6, 1, &Ip6Trace ); }
andrewboyson 8:8b5e0bb28da0 173 void ChgTraceUdp () { UdpTrace = !UdpTrace ; FramWrite(iUdp, 1, &UdpTrace ); }
andrewboyson 8:8b5e0bb28da0 174 void ChgTraceTcp () { TcpTrace = !TcpTrace ; FramWrite(iTcp, 1, &TcpTrace ); }
andrewboyson 74:8228f0297227 175 void ChgTraceHttp () { WebTrace = !WebTrace ; FramWrite(iHttp, 1, &WebTrace ); }
andrewboyson 8:8b5e0bb28da0 176 void ChgTraceTftp () { TftpTrace = !TftpTrace ; FramWrite(iTftp, 1, &TftpTrace ); }
andrewboyson 0:3c04f4b47041 177
andrewboyson 28:bb55def47737 178 static int iServerName;
andrewboyson 28:bb55def47737 179 static int iInitialInterval;
andrewboyson 28:bb55def47737 180 static int iNormalInterval;
andrewboyson 28:bb55def47737 181 static int iRetryInterval;
andrewboyson 28:bb55def47737 182 static int iOffsetMs;
andrewboyson 28:bb55def47737 183 static int iMaxDelayMs;
andrewboyson 28:bb55def47737 184
andrewboyson 38:2bfeefa8709a 185 void SetNtpClientServerName ( char* value) { DnsLabelCopy(NtpClientQueryServerName, value); FramWrite(iServerName, DNS_MAX_LABEL_LENGTH, NtpClientQueryServerName ); }
andrewboyson 28:bb55def47737 186 void SetNtpClientInitialInterval ( int value) { NtpClientQueryInitialInterval = (int32_t)value ; FramWrite(iInitialInterval, 4, &NtpClientQueryInitialInterval ); }
andrewboyson 28:bb55def47737 187 void SetNtpClientNormalInterval ( int value) { NtpClientQueryNormalInterval = (int32_t)value ; FramWrite(iNormalInterval, 4, &NtpClientQueryNormalInterval ); }
andrewboyson 28:bb55def47737 188 void SetNtpClientRetryInterval ( int value) { NtpClientQueryRetryInterval = (int32_t)value ; FramWrite(iRetryInterval, 4, &NtpClientQueryRetryInterval ); }
andrewboyson 28:bb55def47737 189 void SetNtpClientOffsetMs ( int value) { NtpClientReplyOffsetMs = (int32_t)value ; FramWrite(iOffsetMs, 4, &NtpClientReplyOffsetMs ); }
andrewboyson 28:bb55def47737 190 void SetNtpClientMaxDelayMs ( int value) { NtpClientReplyMaxDelayMs = (int32_t)value ; FramWrite(iMaxDelayMs, 4, &NtpClientReplyMaxDelayMs ); }
andrewboyson 28:bb55def47737 191
andrewboyson 28:bb55def47737 192 int SettingsNtpInit()
andrewboyson 28:bb55def47737 193 {
andrewboyson 28:bb55def47737 194 int address;
andrewboyson 28:bb55def47737 195 int32_t def4;
andrewboyson 28:bb55def47737 196
andrewboyson 28:bb55def47737 197 def4 = 0; address = FramLoad( DNS_MAX_LABEL_LENGTH+1, NtpClientQueryServerName, NULL ); if (address < 0) return -1; iServerName = address;
andrewboyson 28:bb55def47737 198 def4 = 1; address = FramLoad( 4, &NtpClientQueryInitialInterval, &def4); if (address < 0) return -1; iInitialInterval = address;
andrewboyson 28:bb55def47737 199 def4 = 600; address = FramLoad( 4, &NtpClientQueryNormalInterval, &def4); if (address < 0) return -1; iNormalInterval = address;
andrewboyson 28:bb55def47737 200 def4 = 60; address = FramLoad( 4, &NtpClientQueryRetryInterval, &def4); if (address < 0) return -1; iRetryInterval = address;
andrewboyson 28:bb55def47737 201 def4 = 0; address = FramLoad( 4, &NtpClientReplyOffsetMs, &def4); if (address < 0) return -1; iOffsetMs = address;
andrewboyson 28:bb55def47737 202 def4 = 50; address = FramLoad( 4, &NtpClientReplyMaxDelayMs, &def4); if (address < 0) return -1; iMaxDelayMs = address;
andrewboyson 28:bb55def47737 203
andrewboyson 28:bb55def47737 204 return 0;
andrewboyson 28:bb55def47737 205 }
andrewboyson 28:bb55def47737 206
andrewboyson 0:3c04f4b47041 207 int SettingsInit()
andrewboyson 0:3c04f4b47041 208 {
andrewboyson 0:3c04f4b47041 209 int address;
andrewboyson 0:3c04f4b47041 210 int32_t def4;
andrewboyson 106:41ed3ea0bbba 211 int64_t def8;
andrewboyson 0:3c04f4b47041 212 char b;
andrewboyson 0:3c04f4b47041 213
andrewboyson 32:bbf9c8b45a2e 214 def4 = 10; address = FramLoad( 4, &ClkGovSlewDivisor, &def4); if (address < 0) return -1; iClkGovSlewDivisor = address;
andrewboyson 32:bbf9c8b45a2e 215 def4 = 20; address = FramLoad( 4, &ClkGovSlewChangeMaxMs, &def4); if (address < 0) return -1; iClkGovSlewMaxMs = address;
andrewboyson 32:bbf9c8b45a2e 216 def4 = 1000; address = FramLoad( 4, &ClkGovFreqDivisor, &def4); if (address < 0) return -1; iClkGovPpbDivisor = address;
andrewboyson 32:bbf9c8b45a2e 217 def4 = 10000000; address = FramLoad( 4, &ClkGovFreqChangeMaxPpb, &def4); if (address < 0) return -1; iClkGovPpbChangeMax = address;
andrewboyson 32:bbf9c8b45a2e 218 def4 = 100000; address = FramLoad( 4, &ClkGovSlewSyncedLimNs, &def4); if (address < 0) return -1; iClkGovSyncedLimitNs = address;
andrewboyson 32:bbf9c8b45a2e 219 def4 = 100000; address = FramLoad( 4, &ClkGovFreqSyncedLimPpb, &def4); if (address < 0) return -1; iClkGovSyncedLimitPpb = address;
andrewboyson 32:bbf9c8b45a2e 220 def4 = 10000; address = FramLoad( 4, &ClkGovSlewSyncedHysNs, &def4); if (address < 0) return -1; iClkGovSyncedHysterisNs = address;
andrewboyson 32:bbf9c8b45a2e 221 def4 = 1000; address = FramLoad( 4, &ClkGovFreqSyncedHysPpb, &def4); if (address < 0) return -1; iClkGovSyncedHysterisPpb = address;
andrewboyson 32:bbf9c8b45a2e 222 def4 = 3; address = FramLoad( 4, &ClkGovSlewOffsetMaxSecs, &def4); if (address < 0) return -1; iClkGovMaxOffsetSecs = address;
andrewboyson 32:bbf9c8b45a2e 223 address = FramLoad( 1, &b, NULL); ClkGovTrace = b; if (address < 0) return -1; iClkGov = address;
andrewboyson 32:bbf9c8b45a2e 224 address = FramLoad( 1, &b, NULL); OneWireTrace = b; if (address < 0) return -1; iOneWire = address;
andrewboyson 28:bb55def47737 225 address = FramLoad( 1, &b, NULL); DnsSendRequestsViaIp4 = b; if (address < 0) return -1; iDnsSendRequestsViaIp4 = address;
andrewboyson 28:bb55def47737 226 address = FramLoad( 1, &b, NULL); NtpClientQuerySendRequestsViaIp4 = b; if (address < 0) return -1; iNtpSendRequestsViaIp4 = address;
andrewboyson 28:bb55def47737 227 address = FramLoad( 1, &b, NULL); TftpSendRequestsViaIp4 = b; if (address < 0) return -1; iTftpSendRequestsViaIp4 = address;
andrewboyson 13:2ca12dd42e91 228 address = FramLoad( 1, &b, NULL); LogUart = b; if (address < 0) return -1; iLogUart = address;
andrewboyson 13:2ca12dd42e91 229 address = FramLoad( 2, NetTraceHost, NULL) ; if (address < 0) return -1; iNetHost = address;
andrewboyson 13:2ca12dd42e91 230 address = FramLoad( 1, &b, NULL); NetTraceStack = b; if (address < 0) return -1; iNetStack = address;
andrewboyson 13:2ca12dd42e91 231 address = FramLoad( 1, &b, NULL); NetTraceNewLine = b; if (address < 0) return -1; iNetNewLine = address;
andrewboyson 13:2ca12dd42e91 232 address = FramLoad( 1, &b, NULL); NetTraceVerbose = b; if (address < 0) return -1; iNetVerbose = address;
andrewboyson 13:2ca12dd42e91 233 address = FramLoad( 1, &b, NULL); LinkTrace = b; if (address < 0) return -1; iLink = address;
andrewboyson 13:2ca12dd42e91 234 address = FramLoad( 1, &b, NULL); DnsNameTrace = b; if (address < 0) return -1; iDnsName = address;
andrewboyson 13:2ca12dd42e91 235 address = FramLoad( 1, &b, NULL); DnsQueryTrace = b; if (address < 0) return -1; iDnsQuery = address;
andrewboyson 13:2ca12dd42e91 236 address = FramLoad( 1, &b, NULL); DnsReplyTrace = b; if (address < 0) return -1; iDnsReply = address;
andrewboyson 13:2ca12dd42e91 237 address = FramLoad( 1, &b, NULL); DnsServerTrace = b; if (address < 0) return -1; iDnsServer = address;
andrewboyson 13:2ca12dd42e91 238 address = FramLoad( 1, &b, NULL); NtpTrace = b; if (address < 0) return -1; iNtp = address;
andrewboyson 13:2ca12dd42e91 239 address = FramLoad( 1, &b, NULL); DhcpTrace = b; if (address < 0) return -1; iDhcp = address;
andrewboyson 13:2ca12dd42e91 240 address = FramLoad( 1, &b, NULL); NsTraceRecvSol = b; if (address < 0) return -1; iNsRecvSol = address;
andrewboyson 13:2ca12dd42e91 241 address = FramLoad( 1, &b, NULL); NsTraceRecvAdv = b; if (address < 0) return -1; iNsRecvAdv = address;
andrewboyson 13:2ca12dd42e91 242 address = FramLoad( 1, &b, NULL); NsTraceSendSol = b; if (address < 0) return -1; iNsSendSol = address;
andrewboyson 13:2ca12dd42e91 243 address = FramLoad( 1, &b, NULL); Nr4Trace = b; if (address < 0) return -1; iNr4 = address;
andrewboyson 101:77fd93f0bde1 244 address = FramLoad( 1, &b, NULL); NrTrace = b; if (address < 0) return -1; iNr = address;
andrewboyson 13:2ca12dd42e91 245 address = FramLoad( 1, &b, NULL); NtpClientTrace = b; if (address < 0) return -1; iNtpClient = address;
andrewboyson 13:2ca12dd42e91 246 address = FramLoad( 1, &b, NULL); Echo4Trace = b; if (address < 0) return -1; iEcho4 = address;
andrewboyson 13:2ca12dd42e91 247 address = FramLoad( 1, &b, NULL); Echo6Trace = b; if (address < 0) return -1; iEcho6 = address;
andrewboyson 13:2ca12dd42e91 248 address = FramLoad( 1, &b, NULL); Dest6Trace = b; if (address < 0) return -1; iDest6 = address;
andrewboyson 13:2ca12dd42e91 249 address = FramLoad( 1, &b, NULL); RaTrace = b; if (address < 0) return -1; iRa = address;
andrewboyson 13:2ca12dd42e91 250 address = FramLoad( 1, &b, NULL); RsTrace = b; if (address < 0) return -1; iRs = address;
andrewboyson 13:2ca12dd42e91 251 address = FramLoad( 1, &b, NULL); Ar4Trace = b; if (address < 0) return -1; iAr4 = address;
andrewboyson 13:2ca12dd42e91 252 address = FramLoad( 1, &b, NULL); Ar6Trace = b; if (address < 0) return -1; iAr6 = address;
andrewboyson 13:2ca12dd42e91 253 address = FramLoad( 1, &b, NULL); ArpTrace = b; if (address < 0) return -1; iArp = address;
andrewboyson 13:2ca12dd42e91 254 address = FramLoad( 1, &b, NULL); Ip4Trace = b; if (address < 0) return -1; iIp4 = address;
andrewboyson 13:2ca12dd42e91 255 address = FramLoad( 1, &b, NULL); Ip6Trace = b; if (address < 0) return -1; iIp6 = address;
andrewboyson 13:2ca12dd42e91 256 address = FramLoad( 1, &b, NULL); UdpTrace = b; if (address < 0) return -1; iUdp = address;
andrewboyson 13:2ca12dd42e91 257 address = FramLoad( 1, &b, NULL); TcpTrace = b; if (address < 0) return -1; iTcp = address;
andrewboyson 74:8228f0297227 258 address = FramLoad( 1, &b, NULL); WebTrace = b; if (address < 0) return -1; iHttp = address;
andrewboyson 13:2ca12dd42e91 259 address = FramLoad( 1, &b, NULL); TftpTrace = b; if (address < 0) return -1; iTftp = address;
andrewboyson 8:8b5e0bb28da0 260
andrewboyson 106:41ed3ea0bbba 261 address = FramAllocate(DNS_MAX_LABEL_LENGTH); if (address < 0) return -1; iValuesServerName = address;
andrewboyson 106:41ed3ea0bbba 262 FramAllocate(1); //Spare
andrewboyson 106:41ed3ea0bbba 263 address = FramAllocate(DNS_MAX_LABEL_LENGTH); if (address < 0) return -1; iValuesFileName = address;
andrewboyson 106:41ed3ea0bbba 264 FramAllocate(1); //Spare
andrewboyson 106:41ed3ea0bbba 265 address = FramAllocate( 4); if (address < 0) return -1; iValuesWriteSize = address;
andrewboyson 106:41ed3ea0bbba 266 address = FramAllocate( 4); if (address < 0) return -1; iValuesReadInterval = address;
andrewboyson 106:41ed3ea0bbba 267 address = FramAllocate( 8); if (address < 0) return -1; iValuesStartTime = address;
andrewboyson 106:41ed3ea0bbba 268 address = FramAllocate( 4); if (address < 0) return -1; iValuesCount = address;
andrewboyson 106:41ed3ea0bbba 269 address = FramAllocate( 1); if (address < 0) return -1; iValuesData = address;
andrewboyson 106:41ed3ea0bbba 270 if (FramEmpty)
andrewboyson 106:41ed3ea0bbba 271 {
andrewboyson 106:41ed3ea0bbba 272 b = 0; FramWrite(iValuesServerName , 1, &b );
andrewboyson 106:41ed3ea0bbba 273 b = 0; FramWrite(iValuesFileName , 1, &b );
andrewboyson 106:41ed3ea0bbba 274 def4 = 100; FramWrite(iValuesWriteSize , 4, &def4);
andrewboyson 106:41ed3ea0bbba 275 def4 = 15; FramWrite(iValuesReadInterval, 4, &def4);
andrewboyson 106:41ed3ea0bbba 276 def8 = 0; FramWrite(iValuesStartTime , 8, &def8);
andrewboyson 106:41ed3ea0bbba 277 def4 = 0; FramWrite(iValuesCount , 4, &def4);
andrewboyson 106:41ed3ea0bbba 278 }
andrewboyson 0:3c04f4b47041 279 return 0;
andrewboyson 106:41ed3ea0bbba 280
andrewboyson 0:3c04f4b47041 281 }