From 5f7abba64c2d59961d6a48bc4c0ba4e0b3ab6b71 Mon Sep 17 00:00:00 2001 From: Paul Goeser Date: Sat, 11 Dec 2010 01:20:41 +0100 Subject: [PATCH] fixed spi dependency crazyness --- firmware/masterchip/spi_config.h | 8 +++----- firmware/masterchip/spi_proto.h | 2 ++ firmware/shared/spi.c | 15 +-------------- firmware/slavechip/spi_config.h | 8 +++++--- firmware/slavechip/spi_proto.c | 14 ++++++++++++++ 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/firmware/masterchip/spi_config.h b/firmware/masterchip/spi_config.h index 30e155c..08250e4 100644 --- a/firmware/masterchip/spi_config.h +++ b/firmware/masterchip/spi_config.h @@ -1,7 +1,5 @@ #define SPI_BAUDRATE 1000000 -#ifdef SPI_MASTER -#undef SPI_MASTER -#endif //SPI_MASTER -//#define SPI_SS_PORT D -//#define SPI_SS_PIN 7 +#define SPI_MASTER +#define SPI_SS_PORT D +#define SPI_SS_PIN 7 diff --git a/firmware/masterchip/spi_proto.h b/firmware/masterchip/spi_proto.h index 93d0dfa..b425693 100644 --- a/firmware/masterchip/spi_proto.h +++ b/firmware/masterchip/spi_proto.h @@ -1,6 +1,8 @@ #ifndef SPI_PROTO_H #define SPI_PROTO_H +#include + #define SPI_WRITE_DATA 0x01 #define SPI_READ_DATA 0x10 #define SPI_NONE 0 diff --git a/firmware/shared/spi.c b/firmware/shared/spi.c index 2252f62..3ad1108 100644 --- a/firmware/shared/spi.c +++ b/firmware/shared/spi.c @@ -9,19 +9,6 @@ #include -uint16_t *spi_proto_globals8[] = { - &foo - }; -uint8_t *spi_proto_globals16[] = { - &bar - }; -funptr_t spi_proto_funcs[] = { - &baz - }; - - - - /* SPI framework. * * currently alpha, uses interrupts, single master/single slave operation @@ -116,6 +103,7 @@ void spi_mst_read(uint8_t len, uint8_t *data){ } +#ifndef SPI_MASTER void __attribute__((always_inline)) spi_sla_handle_packet(){ // TODO: make slave not hangup in case of partial read @@ -144,7 +132,6 @@ void __attribute__((always_inline)) spi_sla_handle_packet(){ } } -#ifndef SPI_MASTER ISR(SPI_vect){ SPCR &= ~(_BV(SPIE)); //disable spi interrupts spi_sla_handle_packet(); diff --git a/firmware/slavechip/spi_config.h b/firmware/slavechip/spi_config.h index 08250e4..30e155c 100644 --- a/firmware/slavechip/spi_config.h +++ b/firmware/slavechip/spi_config.h @@ -1,5 +1,7 @@ #define SPI_BAUDRATE 1000000 -#define SPI_MASTER -#define SPI_SS_PORT D -#define SPI_SS_PIN 7 +#ifdef SPI_MASTER +#undef SPI_MASTER +#endif //SPI_MASTER +//#define SPI_SS_PORT D +//#define SPI_SS_PIN 7 diff --git a/firmware/slavechip/spi_proto.c b/firmware/slavechip/spi_proto.c index bcf9928..2169d1e 100644 --- a/firmware/slavechip/spi_proto.c +++ b/firmware/slavechip/spi_proto.c @@ -1,5 +1,19 @@ #include "spi_proto.h" + +uint16_t *spi_proto_globals8[] = { + &foo + }; +uint8_t *spi_proto_globals16[] = { + &bar + }; +funptr_t spi_proto_funcs[] = { + &baz + }; + + + + uint8_t spi_proto_needswrite(uint8_t opcode) { if(opcode == 4 || opcode == 5) return 1; return 0;