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

Revision:
5:82197a6997fd
Parent:
1:ccc66fdf858d
Child:
6:b325de442777
diff -r 9e1c6ac4ef06 -r 82197a6997fd heating/radiator.c
--- a/heating/radiator.c	Sun Feb 04 11:36:24 2018 +0000
+++ b/heating/radiator.c	Fri Feb 16 19:43:06 2018 +0000
@@ -2,15 +2,23 @@
 #include <string.h>
 #include <stdbool.h>
 
-#include     "defs.h"
+#include     "gpio.h"
 #include  "program.h"
 #include  "ds18b20.h"
 #include     "fram.h"
 #include "radiator.h"
 
-#define       HALL_PB_MASK 1ULL <<  5 // P0. 5 == p29;
-#define      HALL_LED_MASK 1ULL << 10 // P0.10 == p28;
-#define RADIATOR_PUMP_MASK 1ULL <<  3 // P2. 3 == p23;
+#define       HALL_PB_PIN FIO0PIN(05) // P0. 5 == p29;
+
+#define      HALL_LED_DIR FIO0DIR(10) // P0.10 == p28;
+#define      HALL_LED_PIN FIO0PIN(10)
+#define      HALL_LED_SET FIO0SET(10)
+#define      HALL_LED_CLR FIO0CLR(10)
+
+#define RADIATOR_PUMP_DIR FIO2DIR(03) // P2.03 == p23;
+#define RADIATOR_PUMP_PIN FIO2PIN(03)
+#define RADIATOR_PUMP_SET FIO2SET(03)
+#define RADIATOR_PUMP_CLR FIO2CLR(03)
 
 
 static char      htgMode;        static int iMode;
@@ -102,8 +110,8 @@
     def4 = 15; address = FramLoad( 4, &nightTemperature, &def4); if (address < 0) return -1; iNightTemperature = address; 
     def4 =  8; address = FramLoad( 4, &frostTemperature, &def4); if (address < 0) return -1; iFrostTemperature = address; 
     
-    LPC_GPIO2->FIODIR |= RADIATOR_PUMP_MASK; //Set the direction to 1 == output
-    LPC_GPIO0->FIODIR |=      HALL_LED_MASK; //Set the direction to 1 == output
+    RADIATOR_PUMP_DIR = 1; //Set the direction to 1 == output
+         HALL_LED_DIR = 1; //Set the direction to 1 == output
     
     return 0;
 }
@@ -111,7 +119,7 @@
 {
     //deal with pushbutton
     static bool prevHallPb = false;
-           bool thisHallPb = LPC_GPIO0->FIOPIN & HALL_PB_MASK;
+           bool thisHallPb = HALL_PB_PIN;
     bool hallPbPressed = thisHallPb && !prevHallPb;
     prevHallPb = thisHallPb;
     if (hallPbPressed) RadiatorChgOverride();
@@ -122,11 +130,11 @@
     makeOutputWithOverride();
     
     //Pump output
-    if (RadiatorPump) LPC_GPIO2->FIOSET = RADIATOR_PUMP_MASK;
-    else              LPC_GPIO2->FIOCLR = RADIATOR_PUMP_MASK;
+    if (RadiatorPump) RADIATOR_PUMP_SET;
+    else              RADIATOR_PUMP_CLR;
 
     
     //Display the led
-    if (RadiatorPump) LPC_GPIO0->FIOSET = HALL_LED_MASK;
-    else              LPC_GPIO0->FIOCLR = HALL_LED_MASK;
+    if (RadiatorPump) HALL_LED_SET;
+    else              HALL_LED_CLR;
 }
\ No newline at end of file