From a9f1d00865b1826d4574cce9d2ce7331152f325e Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Mon, 3 Nov 2014 15:43:49 +0100 Subject: [PATCH] Move MAX6675 initialisation from mendel.c to temp.c. Also note a misplaced and misnamed pin. --- arduino_1280.h | 4 ++++ arduino_168_328p.h | 4 ++++ arduino_32U4.h | 4 ++++ arduino_644.h | 4 ++++ arduino_usb1286.h | 4 ++++ arduino_usb1287.h | 4 ++++ mendel.c | 1 - temp.c | 13 +++++++------ 8 files changed, 31 insertions(+), 7 deletions(-) diff --git a/arduino_1280.h b/arduino_1280.h index e2ef24f..4baca97 100644 --- a/arduino_1280.h +++ b/arduino_1280.h @@ -6,6 +6,10 @@ #define SCK DIO52 #define MISO DIO50 #define MOSI DIO51 +// TODO: This depends on the board, so this definition is misplaced here, +// should be more appropriately named and go to config.h. It's used in +// temp.c and simulator.h and defines the Chip Select pin for an eventual +// MAX6675 temperature sensor. #define SS DIO53 // TWI (I2C) diff --git a/arduino_168_328p.h b/arduino_168_328p.h index e3b02f0..e00586e 100644 --- a/arduino_168_328p.h +++ b/arduino_168_328p.h @@ -6,6 +6,10 @@ #define SCK DIO13 #define MISO DIO12 #define MOSI DIO11 +// TODO: This depends on the board, so this definition is misplaced here, +// should be more appropriately named and go to config.h. It's used in +// temp.c and simulator.h and defines the Chip Select pin for an eventual +// MAX6675 temperature sensor. #define SS DIO10 // TWI (I2C) diff --git a/arduino_32U4.h b/arduino_32U4.h index 014f678..4fd85d1 100644 --- a/arduino_32U4.h +++ b/arduino_32U4.h @@ -30,6 +30,10 @@ #define SCK DIO1 #define MISO DIO3 #define MOSI DIO2 +// TODO: This depends on the board, so this definition is misplaced here, +// should be more appropriately named and go to config.h. It's used in +// temp.c and simulator.h and defines the Chip Select pin for an eventual +// MAX6675 temperature sensor. #define SS DIO0 // TWI (I2C) diff --git a/arduino_644.h b/arduino_644.h index 3fe34d1..1fe5035 100644 --- a/arduino_644.h +++ b/arduino_644.h @@ -11,6 +11,10 @@ #define SCK DIO7 #define MISO DIO6 #define MOSI DIO5 +// TODO: This depends on the board, so this definition is misplaced here, +// should be more appropriately named and go to config.h. It's used in +// temp.c and simulator.h and defines the Chip Select pin for an eventual +// MAX6675 temperature sensor. #define SS DIO4 // TWI (I2C) diff --git a/arduino_usb1286.h b/arduino_usb1286.h index 05e0d74..0233e0d 100644 --- a/arduino_usb1286.h +++ b/arduino_usb1286.h @@ -11,6 +11,10 @@ #define SCK DIO9 #define MISO DIO11 #define MOSI DIO10 +// TODO: This depends on the board, so this definition is misplaced here, +// should be more appropriately named and go to config.h. It's used in +// temp.c and simulator.h and defines the Chip Select pin for an eventual +// MAX6675 temperature sensor. #define SS DIO8 diff --git a/arduino_usb1287.h b/arduino_usb1287.h index ce4e545..fccba7e 100644 --- a/arduino_usb1287.h +++ b/arduino_usb1287.h @@ -2,6 +2,10 @@ #define SCK DIO9 #define MISO DIO11 #define MOSI DIO10 +// TODO: This depends on the board, so this definition is misplaced here, +// should be more appropriately named and go to config.h. It's used in +// temp.c and simulator.h and defines the Chip Select pin for an eventual +// MAX6675 temperature sensor. #define SS DIO8 diff --git a/mendel.c b/mendel.c index 98e53eb..7123c75 100644 --- a/mendel.c +++ b/mendel.c @@ -184,7 +184,6 @@ void io_init(void) { WRITE(SCK, 0); SET_OUTPUT(SCK); WRITE(MOSI, 1); SET_OUTPUT(MOSI); WRITE(MISO, 1); SET_INPUT(MISO); - WRITE(SS, 1); SET_OUTPUT(SS); #endif #ifdef TEMP_INTERCOM diff --git a/temp.c b/temp.c index 6f070ec..bd9f9d4 100644 --- a/temp.c +++ b/temp.c @@ -73,16 +73,17 @@ struct { uint16_t next_read_time; ///< how long until we can read this sensor again? } temp_sensors_runtime[NUM_TEMP_SENSORS]; -/// set up temp sensors. Currently only the 'intercom' sensor needs initialisation. +/// Set up temp sensors. void temp_init() { temp_sensor_t i; for (i = 0; i < NUM_TEMP_SENSORS; i++) { switch(temp_sensors[i].temp_type) { - #ifdef TEMP_MAX6675 - // initialised when read -/* case TT_MAX6675: - break;*/ - #endif + #ifdef TEMP_MAX6675 + case TT_MAX6675: + WRITE(SS, 1); // Turn sensor off. + SET_OUTPUT(SS); + // Intentionally no break, we might have more than one sensor type. + #endif #ifdef TEMP_THERMISTOR // handled by analog_init()