Rev 2294 Rev 3500
1 // Oscilloscope firmware, Roman Pavelka, 2011 1 // Oscilloscope firmware, Roman Pavelka, 2011
2 // written for atmega8 2 // written for atmega8
3   3  
4 #define F_CPU 16000000 4 #define F_CPU 16000000
5 #define BAUD 1000000 5 #define BAUD 1000000
6 //#define MYUBRR F_CPU/8/BAUD-1 6 //#define MYUBRR F_CPU/8/BAUD-1
7 #define MYUBRR 1 7 #define MYUBRR 1
8   8  
9 #include "./libs/usart.h" 9 #include "./libs/usart.h"
10 #include "./libs/spi.h" 10 #include "./libs/spi.h"
11   11  
12 #include <avr/io.h> 12 #include <avr/io.h>
13 #include <avr/interrupt.h> 13 #include <avr/interrupt.h>
14 #include <util/delay.h> 14 #include <util/delay.h>
15 #include <inttypes.h> 15 #include <inttypes.h>
16   16  
17 int main (void) { 17 int main (void) {
18 USART_Init(MYUBRR); 18 USART_Init(MYUBRR);
19   19  
20 DDRB = 0b00100100; //SCK, SS out 20 DDRB = 0b00100100; //SCK, SS out
21 PORTB = 0b00000000; // CONV low 21 PORTB = 0b00000000; // CONV low
22   22  
23 SPI_MasterInit(); 23 SPI_MasterInit();
24   24  
25   25  
26 while(1) 26 while(1)
27 { 27 {
28 PORTB |= 0b00000100; 28 PORTB |= 0b00000100;
29 _delay_us(4); 29 _delay_us(4);
30 PORTB &= 0b11111011; //one conversion 30 PORTB &= 0b11111011; //one conversion
31   31  
32 USART_Transmit(SPI_MasterTransmit(0x0)); //Binary transfer 32 USART_Transmit(SPI_MasterTransmit(0x0)); //Binary transfer
33 USART_Transmit(SPI_MasterTransmit(0x0)); 33 USART_Transmit(SPI_MasterTransmit(0x0));
34 _delay_us(4); 34 _delay_us(4);
35 } 35 }
36 return 0; 36 return 0;
37 } 37 }
38   38