diff flash.c @ 31:03592ca4d37e

Port tempctrl.c from AVR. I removed the beep code as I don't have a beeper on the STM32 board. Reworked the heat/cool stuff so it can use separate ports.
author Daniel O'Connor <darius@dons.net.au>
date Tue, 27 Nov 2012 13:20:52 +1030
parents 5c9d2e3d6591
children dcac5f08f87a
line wrap: on
line diff
--- a/flash.c	Tue Nov 27 13:19:11 2012 +1030
+++ b/flash.c	Tue Nov 27 13:20:52 2012 +1030
@@ -25,78 +25,11 @@
 #define RW_IDLE		0
 #define RW_RUNNING	1
 
-/* Holds all the settings needed */
-typedef struct {
-    uint8_t	fermenter_ROM[8];
-    uint8_t	fridge_ROM[8];
-    uint8_t	ambient_ROM[8];
-    int16_t	target_temp;
-    uint16_t	hysteresis;
-    /* How much to under/overshoot on heating/cooling */
-    int16_t	minheatovershoot;
-    int16_t	mincoolovershoot;
-
-    /* Minimum time the cooler can be on/off */
-    int16_t	mincoolontime;
-    int16_t	mincoolofftime;
-
-    /* Minimum time the heater can be on/off */
-    int16_t	minheatontime;
-    int16_t	minheatofftime;
-
-#define TC_MODE_AUTO	'a'	/* Automatic control */
-#define TC_MODE_HEAT	'h'	/* Force heating */
-#define TC_MODE_COOL	'c'	/* Force cooling */
-#define TC_MODE_IDLE	'i'	/* Force idle */
-#define TC_MODE_NOTHING	'n'	/* Do nothing (like idle but log nothing) */
-    char	mode;
-    
-    /* Bit patterns for various modes */
-    uint8_t	coolbits;
-    uint8_t	heatbits;
-    uint8_t	idlebits;
-
-    /* Check/stale times */
-    int16_t	check_interval;
-    int16_t	stale_factor;
-
-    /* Beep if stale */
-    int8_t	dobeep;
-
-    /* Pad to 4 bytes */
-    uint8_t	pad[1];
-    
-} __attribute__((packed, aligned(4))) settings_t;
-    
-const settings_t default_settings = {
-    .fermenter_ROM = { 0x10, 0x4c, 0x7d, 0x53, 0x01, 0x08, 0x00, 0xff },
-    .fridge_ROM =  { 0x10, 0x6f, 0x40, 0x53, 0x01, 0x08, 0x00, 0x16 },
-    .ambient_ROM = { 0x10, 0x76, 0x05, 0x53, 0x01, 0x08, 0x00, 0x8c },
-    .target_temp = 1000,
-    .hysteresis = 100,
-    .minheatovershoot = 50,
-    .mincoolovershoot = -50,
-    .mincoolontime = 300,
-    .mincoolofftime = 600,
-    .minheatontime = 60,
-    .minheatofftime = 60,
-    .mode = TC_MODE_AUTO,
-    .coolbits = 1 << 6,
-    .heatbits = 1<< 7,
-    .idlebits = 0x00,
-    .check_interval = 10,
-    .stale_factor = 3,
-    .dobeep = 0
-};
-
-/* RAM copy of setting */
-static settings_t ram_settings;
-
 static int writestate = RW_IDLE;
 static int readstate = RW_IDLE;
 
 void
-flashcmd(char **argv, int argc) {
+flashcmd(int argc, char **argv) {
     uint8_t status, tmp, len;
     uint32_t addr;
     
@@ -175,19 +108,6 @@
 		flashwriteword(data);
 	}
 	flashstopwrite();
-    } else if (!strcmp(argv[0], "tw")) {
-	/* Copy default to RAM */
-	bcopy(&default_settings, &ram_settings, sizeof(default_settings));
-	
-	/* Write RAM copy into flash */
-	flashwriteblock(0, sizeof(ram_settings), &ram_settings);
-    } else if (!strcmp(argv[0], "tr")) {
-	int crcok;
-	
-	/* Read flash copy to RAM */
-	crcok = flashreadblock(0, sizeof(ram_settings), &ram_settings);
-	
-	printf("CRC is %s\r\n", crcok ? "OK" : "bad");
     } else if (!strcmp(argv[0], "id")) {
 	printf("Flash ID = 0x%04hx (expect 0xbf41)\r\n", flashreadid());
     } else {