From 547d352d5275345cd9c5a3948018f7158adf253a Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 30 May 2012 14:16:47 +0000 Subject: usb-spi now uses LUFA spi git-svn-id: https://svn.spreadspace.org/avr/trunk@49 aa12f405-d877-488e-9caf-2d797e2a1cc7 --- usb-spi/usb-spi.c | 124 +++++++++++++++++++++--------------------------------- 1 file changed, 48 insertions(+), 76 deletions(-) (limited to 'usb-spi/usb-spi.c') diff --git a/usb-spi/usb-spi.c b/usb-spi/usb-spi.c index 513df00..66c3671 100644 --- a/usb-spi/usb-spi.c +++ b/usb-spi/usb-spi.c @@ -72,27 +72,16 @@ #include "led.h" #include +#include #include #include /* Hardware Defines: */ -#define SPI_DDR DDRB -#define SPI_PORT PORTB -#define SPI_PINB_REG PINB +#define SPI_CS_DDR DDRB +#define SPI_CS_PORT PORTB #define CS 0 -#define SCK 1 -#define MOSI 2 -#define MISO 3 - - /* Function Prototypes: */ -void SetupHardware(void); -void SPI_TransferBuffer(void); - -void EVENT_USB_Device_Connect(void); -void EVENT_USB_Device_Disconnect(void); -void EVENT_USB_Device_ConfigurationChanged(void); -void EVENT_USB_Device_ControlRequest(void); + /* Global I/O Buffers: */ static RingBuffer_t USBtoSPI_Buffer; static uint8_t USBtoSPI_Buffer_Data[128]; static RingBuffer_t SPItoUSB_Buffer; @@ -122,6 +111,50 @@ USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface = }, }; +void SetupHardware(void) +{ + MCUSR &= ~(1 << WDRF); + wdt_disable(); + + cpu_init(); + led_init(); + USB_Init(); + + TCCR0B = (1 << CS02); + + SPI_CS_DDR |= (1<