-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_2.c
78 lines (60 loc) · 1.76 KB
/
main_2.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <asf.h>
#include <board.h>
#include <gpio.h>
#include <sysclk.h>
#include "busy_delay.h"
#define CONFIG_USART_IF (AVR32_USART2)
// defines for BRTT interface
#define TEST_A AVR32_PIN_PA31
#define RESPONSE_A AVR32_PIN_PA30
#define TEST_B AVR32_PIN_PA29
#define RESPONSE_B AVR32_PIN_PA28
#define TEST_C AVR32_PIN_PA27
#define RESPONSE_C AVR32_PIN_PB00
__attribute__((__interrupt__)) static void interrupt_J3(void);
void init(){
sysclk_init();
board_init();
busy_delay_init(BOARD_OSC0_HZ);
gpio_configure_pin(TEST_A, (GPIO_DIR_INPUT | GPIO_PULL_UP));
gpio_configure_pin(RESPONSE_A, (GPIO_DIR_OUTPUT | GPIO_PULL_UP));
gpio_configure_pin(TEST_B, (GPIO_DIR_INPUT | GPIO_PULL_UP));
gpio_configure_pin(RESPONSE_B, (GPIO_DIR_OUTPUT | GPIO_PULL_UP));
gpio_configure_pin(TEST_C, (GPIO_DIR_INPUT | GPIO_PULL_UP));
gpio_configure_pin(RESPONSE_C, (GPIO_DIR_OUTPUT | GPIO_PULL_UP));
cpu_irq_disable();
INTC_init_interrupts();
INTC_register_interrupt(&interrupt_J3, AVR32_GPIO_IRQ_3, AVR32_INTC_INT1);
cpu_irq_enable();
stdio_usb_init(&CONFIG_USART_IF);
#if defined(__GNUC__) && defined(__AVR32__)
setbuf(stdout, NULL);
setbuf(stdin, NULL);
#endif
}
__attribute__((__interrupt__)) static void interrupt_J3(void)
{
}
int main (void){
init();
while(1){
if(gpio_get_pin_value(TEST_A) != 1)
{
gpio_set_pin_low(RESPONSE_A);
busy_delay_us(5);
gpio_set_pin_high(RESPONSE_A);
}
if(gpio_get_pin_value(TEST_B) != 1)
{
gpio_set_pin_low(RESPONSE_B);
busy_delay_us(5);
gpio_set_pin_high(RESPONSE_B);
}
if(gpio_get_pin_value(TEST_C) != 1)
{
gpio_set_pin_low(RESPONSE_C);
busy_delay_us(5);
gpio_set_pin_high(RESPONSE_C);
}
}
}