-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
56 lines (42 loc) · 1.11 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
#include <stdlib.h>
#include <util/delay.h>
#include <serial.h>
#include <buffer.h>
#include <util.h>
#include <spi.h>
#include <stk500.h>
#include <dbg.h>
#include <timer.h>
#define RESET_TARGET_DDR DDRD
#define RESET_TARGET_PORT PORTD
#define RESET_TARGET_PIN PD6
PRIVATE uartSendByteFunc_t sendUser = sendUartByte;
PRIVATE uartGetByteFunc_t getUser = getUartByte;
PRIVATE spiSendByteFunc_t sendTarget = sendSpiByte;
PRIVATE spiGetByteFunc_t getTarget = getSpiByte;
PRIVATE resetTargetFunc_t resetTarget = NULL;
#define UART_BAUDRATE 38400
int main(void) {
initMSTimer();
// Init serial
initUart(UART_BAUDRATE, BITS_8, PAR_NONE);
// Enable debug print
initDBG();
// Init SPI, mode 0 with clock div 128
initSPI(0, 3);
initSTK500(sendUser, getUser, sendTarget, getTarget, resetTarget);
// Debug led output
DDRD |= _BV(PD7);
// Set the reset pin to output
RESET_TARGET_DDR |= _BV(RESET_TARGET_PIN);
// Enable interrupts
sei();
// Main loop
while (1) {
tickSTK500();
}
return 0;
}