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