blob: 79eb64a338f1d531c88da11d7bb0892376f34c76 (
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
|
/*****************************************************************************
# #
# KVMD - The main PiKVM daemon. #
# #
# Copyright (C) 2018-2023 Maxim Devaev <[email protected]> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
# #
*****************************************************************************/
#include "pico/stdlib.h"
#include "hardware/gpio.h"
#include "ph_types.h"
#define _UART uart0
#define _SPEED 3000000
#define _RX_PIN -1 // 1 - No stdin
#define _TX_PIN 0
#define _ACT_PIN 25
void ph_debug_init(bool enable_uart) {
if (enable_uart) {
stdio_uart_init_full(_UART, _SPEED, _TX_PIN, _RX_PIN);
}
gpio_init(_ACT_PIN);
gpio_set_dir(_ACT_PIN, GPIO_OUT);
}
void ph_debug_act(bool flag) {
gpio_put(_ACT_PIN, flag);
}
void ph_debug_act_pulse(u64 delay_ms) {
static bool flag = false;
static u64 next_ts = 0;
const u64 now_ts = time_us_64();
if (now_ts >= next_ts) {
ph_debug_act(flag);
flag = !flag;
next_ts = now_ts + (delay_ms * 1000);
}
}
|