summaryrefslogtreecommitdiff
path: root/firmware/c1224/src/common/main.c
blob: e113f91e5fdf4e33b4b13fc37a7ba02468abe22c (plain)
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
/*
 * T-Modem-c1224 — USB KISS half-TNC (HDLC on Pico + bitbang to TCM3105).
 * No softmodem · no transparent Host↔Chip bit bridge · one FW · rate = crystal.
 * SPDX-License-Identifier: GPL-3.0-or-later
 */
#include "pico/stdlib.h"
#include "board_pins.h"
#include "status.h"
#include "ptt.h"
#include "modem_probe.h"
#include "usb_cmd.h"
#include "display.h"
#include "crystal_steer.h"
#include "baud_config.h"
#include "config.h"
#include "sense.h"
#include "afsk_bitbang.h"
#include "banner.h"
#include "hardware/gpio.h"
#include <stdio.h>

int main(void)
{
    stdio_init_all();
    sleep_ms(800);

    board_pins_init();
    ptt_init();
    config_init();
    display_init();
    sense_init();
    afsk_bitbang_init();
    usb_cmd_init();
    afsk_rx_set_callback(usb_cmd_on_rx_frame);

    status_set(C1224_STATE_STARTING);
    status_publish();
    /* Fixed boot banner — always once after CDC ready; source-only (banner.c). */
    banner_print();

    modem_probe_result_t probe = modem_probe_run();
    if (probe.ready) {
        status_set(C1224_STATE_READY);
    } else {
        status_set(C1224_STATE_FAULT);
    }
    status_publish();

    while (true) {
        usb_cmd_poll();
        afsk_rx_poll();
        sense_poll();

        gpio_put(PIN_LED_DCD, sense_signal_active() ? 1 : 0);
        gpio_put(PIN_LED_PTT, ptt_get() ? 1 : 0);
        gpio_put(PIN_LED_TXRX, sense_packet_active() ? 1 : 0);

        status_tick();
        sleep_us(50);
    }
}
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com