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
settings/settings.c@0:3c04f4b47041, 2018-01-11 (annotated)
- Committer:
- andrewboyson
- Date:
- Thu Jan 11 17:40:08 2018 +0000
- Revision:
- 0:3c04f4b47041
- Child:
- 8:8b5e0bb28da0
Removed dependence on Mbed OS
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 0:3c04f4b47041 | 1 | #include <stdbool.h> |
andrewboyson | 0:3c04f4b47041 | 2 | |
andrewboyson | 0:3c04f4b47041 | 3 | #include "fram.h" |
andrewboyson | 0:3c04f4b47041 | 4 | #include "clock.h" |
andrewboyson | 0:3c04f4b47041 | 5 | #include "net.h" |
andrewboyson | 0:3c04f4b47041 | 6 | |
andrewboyson | 0:3c04f4b47041 | 7 | static int iClockSlewDivisor ; |
andrewboyson | 0:3c04f4b47041 | 8 | static int iClockSlewMaxMs ; |
andrewboyson | 0:3c04f4b47041 | 9 | static int iClockPpbDivisor ; |
andrewboyson | 0:3c04f4b47041 | 10 | static int iClockPpbChangeMax ; |
andrewboyson | 0:3c04f4b47041 | 11 | static int iClockSyncedLimitNs ; |
andrewboyson | 0:3c04f4b47041 | 12 | static int iClockSyncedLimitPpb ; |
andrewboyson | 0:3c04f4b47041 | 13 | static int iClockSyncedHysterisNs ; |
andrewboyson | 0:3c04f4b47041 | 14 | static int iClockSyncedHysterisPpb; |
andrewboyson | 0:3c04f4b47041 | 15 | static int iClockMaxOffsetSecs ; |
andrewboyson | 0:3c04f4b47041 | 16 | static int iNetPreferIp4Polled ; |
andrewboyson | 0:3c04f4b47041 | 17 | |
andrewboyson | 0:3c04f4b47041 | 18 | void SetClockSlewDivisor (int value) { ClockSlewDivisor = value; FramWrite(iClockSlewDivisor, 4, &ClockSlewDivisor ); } |
andrewboyson | 0:3c04f4b47041 | 19 | void SetClockSlewMaxMs (int value) { ClockSlewMaxMs = value; FramWrite(iClockSlewMaxMs, 4, &ClockSlewMaxMs ); } |
andrewboyson | 0:3c04f4b47041 | 20 | void SetClockPpbDivisor (int value) { ClockPpbDivisor = value; FramWrite(iClockPpbDivisor, 4, &ClockPpbDivisor ); } |
andrewboyson | 0:3c04f4b47041 | 21 | void SetClockPpbChangeMax (int value) { ClockPpbChangeMax = value; FramWrite(iClockPpbChangeMax, 4, &ClockPpbChangeMax ); } |
andrewboyson | 0:3c04f4b47041 | 22 | void SetClockSyncedLimitNs (int value) { ClockSyncedLimitNs = value; FramWrite(iClockSyncedLimitNs, 4, &ClockSyncedLimitNs ); } |
andrewboyson | 0:3c04f4b47041 | 23 | void SetClockSyncedLimitPpb (int value) { ClockSyncedLimitPpb = value; FramWrite(iClockSyncedLimitPpb, 4, &ClockSyncedLimitPpb ); } |
andrewboyson | 0:3c04f4b47041 | 24 | void SetClockSyncedHysterisNs (int value) { ClockSyncedHysterisNs = value; FramWrite(iClockSyncedHysterisNs, 4, &ClockSyncedHysterisNs ); } |
andrewboyson | 0:3c04f4b47041 | 25 | void SetClockSyncedHysterisPpb(int value) { ClockSyncedHysterisPpb = value; FramWrite(iClockSyncedHysterisPpb, 4, &ClockSyncedHysterisPpb); } |
andrewboyson | 0:3c04f4b47041 | 26 | void SetClockMaxOffsetSecs (int value) { ClockMaxOffsetSecs = value; FramWrite(iClockMaxOffsetSecs, 4, &ClockMaxOffsetSecs ); } |
andrewboyson | 0:3c04f4b47041 | 27 | void SetNetPreferIp4Polled (bool value) { NetPreferIp4Polled = value; FramWrite(iNetPreferIp4Polled, 1, &NetPreferIp4Polled ); } |
andrewboyson | 0:3c04f4b47041 | 28 | |
andrewboyson | 0:3c04f4b47041 | 29 | int SettingsInit() |
andrewboyson | 0:3c04f4b47041 | 30 | { |
andrewboyson | 0:3c04f4b47041 | 31 | int address; |
andrewboyson | 0:3c04f4b47041 | 32 | int32_t def4; |
andrewboyson | 0:3c04f4b47041 | 33 | char b; |
andrewboyson | 0:3c04f4b47041 | 34 | |
andrewboyson | 0:3c04f4b47041 | 35 | def4 = 10; address = FramLoad( 4, &ClockSlewDivisor, &def4); if (address < 0) return -1; iClockSlewDivisor = address; |
andrewboyson | 0:3c04f4b47041 | 36 | def4 = 20; address = FramLoad( 4, &ClockSlewMaxMs, &def4); if (address < 0) return -1; iClockSlewMaxMs = address; |
andrewboyson | 0:3c04f4b47041 | 37 | def4 = 1000; address = FramLoad( 4, &ClockPpbDivisor, &def4); if (address < 0) return -1; iClockPpbDivisor = address; |
andrewboyson | 0:3c04f4b47041 | 38 | def4 = 10000000; address = FramLoad( 4, &ClockPpbChangeMax, &def4); if (address < 0) return -1; iClockPpbChangeMax = address; |
andrewboyson | 0:3c04f4b47041 | 39 | def4 = 100000; address = FramLoad( 4, &ClockSyncedLimitNs, &def4); if (address < 0) return -1; iClockSyncedLimitNs = address; |
andrewboyson | 0:3c04f4b47041 | 40 | def4 = 100000; address = FramLoad( 4, &ClockSyncedLimitPpb, &def4); if (address < 0) return -1; iClockSyncedLimitPpb = address; |
andrewboyson | 0:3c04f4b47041 | 41 | def4 = 10000; address = FramLoad( 4, &ClockSyncedHysterisNs, &def4); if (address < 0) return -1; iClockSyncedHysterisNs = address; |
andrewboyson | 0:3c04f4b47041 | 42 | def4 = 1000; address = FramLoad( 4, &ClockSyncedHysterisPpb, &def4); if (address < 0) return -1; iClockSyncedHysterisPpb = address; |
andrewboyson | 0:3c04f4b47041 | 43 | def4 = 3; address = FramLoad( 4, &ClockMaxOffsetSecs, &def4); if (address < 0) return -1; iClockMaxOffsetSecs = address; |
andrewboyson | 0:3c04f4b47041 | 44 | address = FramLoad( 1, &b, NULL); NetPreferIp4Polled = b; if (address < 0) return -1; iNetPreferIp4Polled = address; |
andrewboyson | 0:3c04f4b47041 | 45 | |
andrewboyson | 0:3c04f4b47041 | 46 | return 0; |
andrewboyson | 0:3c04f4b47041 | 47 | } |