-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
64 lines (53 loc) · 1 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
57
58
59
60
61
62
63
64
// SPDX-FileCopyrightText: 2023 Andreas Sig Rosvall
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "led.h"
#include "sleep.h"
#include "bsp/clock.h"
#include "bsp/flash.h"
#include "bsp/interrupts.h"
#include "bsp/radio.h"
#include "bsp/watchdog.h"
#include "config/pins.h"
#include "int.h"
#include "log.h"
#include "radio.h"
#include "uart.h"
#include "usb.h"
inline void
pins_setup(void)
{
gpio_dir_out(LED_GREEN);
gpio_dir_out(LED_RED);
}
inline void
print_csp_state(void)
{
u8 state;
state = RADIO.fsmstat0.fsm_ffctrl_state;
led_red_off();
led_green_off();
if (state > 0x1f) {
led_green_on();
} else if (state > 0x6) {
led_red_on();
}
}
int
main(void)
{
FLASH.ctl = FLASH_CTL_CACHE_MODE_PREFETCH;
clk_setup(CLKSPD_32M, TICKSPD_32M, OSC_32MHZ_XTAL, OSC32K_RC);
pins_setup();
uart_setup();
LOGI("CC2531 WPAN adapter " GIT_VERSION_STR " online!");
pins_setup();
usb_init();
radio_setup();
interrupts_enable();
for (;;) {
watchdog_feed();
maybe_sleep();
print_csp_state();
}
}