# HG changeset patch # User kripperger@CL-SEC241-09.cedarville.edu # Date 2012-11-27 14:55:18 # Node ID 29a47f4a335d7c69e0e5bca946cce0c173cf70de # Parent 5a775958ef6524cce480c52faa243866684ea14a spi diff --git a/slave/slave/lib/sensors.c b/slave/slave/lib/sensors.c --- a/slave/slave/lib/sensors.c +++ b/slave/slave/lib/sensors.c @@ -12,4 +12,24 @@ #include "../config.h" #include #include "sensors.h" +#include "spi.h" + +uint8_t readSpiTemp() +{ + // select TEMP wait 100 microseconds then read four bytes + SELECT_TEMP; + _delay_us(100); + unsigned char one = send_spi(0xFF); + _delay_us(100); + unsigned char two = send_spi(0xFF); + _delay_us(100); + unsigned char three = send_spi(0xFF); + _delay_us(100); + unsigned char four = send_spi(0xFF); + DESELECT_TEMP; + + + //return ((0x1F & one) << 7) | (two >> 1); + return 0; //DEBUG +} \ No newline at end of file diff --git a/slave/slave/lib/sensors.h b/slave/slave/lib/sensors.h --- a/slave/slave/lib/sensors.h +++ b/slave/slave/lib/sensors.h @@ -9,7 +9,7 @@ #ifndef SENSORS_H_ #define SENSORS_H_ - +uint8_t readSpiTemp(void); diff --git a/slave/slave/lib/spi.c b/slave/slave/lib/spi.c --- a/slave/slave/lib/spi.c +++ b/slave/slave/lib/spi.c @@ -13,27 +13,29 @@ void setup_spi(uint8_t mode, int dord, int interrupt, uint8_t clock) { + DESELECT_TEMP; + // specify pin directions for SPI pins on port B - if (clock == SPI_SLAVE) { // if slave SS and SCK is input - DDRB &= ~(1< -#define SPI_SS_PIN PORTA1 //DEBUG +#define SPI_SS_PIN PORTA1 #define SPI_SCK_PIN PORTB7 #define SPI_MOSI_PIN PORTB5 #define SPI_MISO_PIN PORTB6 +#define SELECT_TEMP PORTA &= ~(1< #include "modules.h" - + #include "lib/spi.h" void modules_setup(uint8_t id) @@ -78,6 +78,7 @@ void modules_sensors_setup() { + setup_spi(SPI_MODE_0, SPI_MSB, SPI_NO_INTERRUPT, SPI_MSTR_CLK16); } diff --git a/slave/slave/slave.cproj b/slave/slave/slave.cproj --- a/slave/slave/slave.cproj +++ b/slave/slave/slave.cproj @@ -169,10 +169,5 @@ - - - compile - - \ No newline at end of file