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
Diff: heating/boiler.c
- Revision:
- 5:82197a6997fd
- Parent:
- 1:ccc66fdf858d
- Child:
- 11:fa01ea25b62d
--- a/heating/boiler.c Sun Feb 04 11:36:24 2018 +0000 +++ b/heating/boiler.c Fri Feb 16 19:43:06 2018 +0000 @@ -2,13 +2,20 @@ #include <stdint.h> #include <stdbool.h> -#include "defs.h" +#include "gpio.h" #include "tick.h" #include "ds18b20.h" #include "fram.h" -#define BOILER_PUMP_MASK 1UL << 4 // P2.4 == p22 -#define BOILER_CALL_MASK 1UL << 5 // P2.5 == p21 +#define BOILER_PUMP_DIR FIO2DIR(4) // P2.4 == p22 +#define BOILER_PUMP_PIN FIO2PIN(4) +#define BOILER_PUMP_SET FIO2SET(4) +#define BOILER_PUMP_CLR FIO2CLR(4) + +#define BOILER_CALL_DIR FIO2DIR(5) // P2.5 == p21 +#define BOILER_CALL_PIN FIO2PIN(5) +#define BOILER_CALL_SET FIO2SET(5) +#define BOILER_CALL_CLR FIO2CLR(5) static char tankRom[8]; static int iTankRom; static char outputRom[8]; static int iOutputRom; @@ -49,8 +56,8 @@ def4 = 2; address = FramLoad( 4, &runOnResidual, &def4); if (address < 0) return -1; iRunOnResidual = address; def4 = 360; address = FramLoad( 4, &runOnTime, &def4); if (address < 0) return -1; iRunOnTime = address; - LPC_GPIO2->FIODIR |= BOILER_PUMP_MASK; //Set the direction to 1 == output - LPC_GPIO2->FIODIR |= BOILER_CALL_MASK; //Set the direction to 1 == output + BOILER_PUMP_DIR = 1; //Set the direction to 1 == output + BOILER_CALL_DIR = 1; //Set the direction to 1 == output return 0; } @@ -70,8 +77,8 @@ if (tankTemp16ths >= tankUpper16ths) BoilerCall = false; if (tankTemp16ths <= tankLower16ths) BoilerCall = true; } - if (BoilerCall) LPC_GPIO2->FIOSET = BOILER_CALL_MASK; - else LPC_GPIO2->FIOCLR = BOILER_CALL_MASK; + if (BoilerCall) BOILER_CALL_SET; + else BOILER_CALL_CLR; //Control boiler circulation pump int boilerOutput16ths = DS18B20ValueFromRom(outputRom); @@ -96,7 +103,7 @@ } } - if (BoilerPump) LPC_GPIO2->FIOSET = BOILER_PUMP_MASK; - else LPC_GPIO2->FIOCLR = BOILER_PUMP_MASK; + if (BoilerPump) BOILER_PUMP_SET; + else BOILER_PUMP_CLR; } \ No newline at end of file