#include #include #include #include /* for sei() */ #include /* for _delay_ms() */ void Writetoreg (int); void ReadData(char); void USART_vInit(void); void USART_vSendByte(char u8Data); unsigned char USART_Receive( void ); #define DDR_SPI DDRB #define SPI_SS PINB2 #define SPI_MOSI PINB3 #define SPI_MISO PINB4 #define SPI_SCK PINB5 #define NUM_SAMPLES 50 /* change the number of data samples */ #define MAX_REG_LENGTH 3 /* this says that the max length of a register is 3 bytes */ char store[NUM_SAMPLES*MAX_REG_LENGTH + 30]; int cur; int main() { // Allow interrupts sei(); USART_vInit(); USART_Receive(); int a; cur=0; for(a=0;a>7)==1); /* wait for /DRDY to go low */ a=0; for(a=0;a>7)==1); /* wait for /DRDY to go low */ PORTB&=~_BV(SPI_SS); /* /CS is low */ char b; for(b=0;b>8); UBRRL = (uint8_t)USART_UBBR_VALUE; /* Set frame format: 8data, 2stop bit */ UCSRC = (1<