File tree 6 files changed +66
-74
lines changed
samples/boards/rpi_pico/uart_pio
6 files changed +66
-74
lines changed Original file line number Diff line number Diff line change 1
- # SPDX-License-Identifier: Apache-2.0
2
-
3
- cmake_minimum_required (VERSION 3.20.0)
1
+ cmake_minimum_required (VERSION 3.15.0)
4
2
find_package (Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} )
5
- project (uart_pio )
3
+ project (pio_shell_uart )
6
4
7
5
target_sources (app PRIVATE src/main.c)
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2023, Ionut Pavel <
[email protected] >
3
+ * Copyright (c) 2023 Yonatan Schachter
4
+ *
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */
7
+
8
+ #include <zephyr/dt-bindings/pinctrl/rpi-pico-rp2040-pinctrl.h>
9
+
10
+ &pinctrl {
11
+ pio0_uart0_default: pio0_uart0_default {
12
+ tx_gpio {
13
+ pinmux = <PIO0_P0>;
14
+ };
15
+
16
+ rx_gpio {
17
+ pinmux = <PIO0_P1>;
18
+ input-enable;
19
+ bias-pull-up;
20
+ };
21
+ };
22
+ };
Original file line number Diff line number Diff line change
1
+ #include "app-pinctrl.dtsi"
2
+
3
+ / {
4
+ chosen {
5
+ zephyr,console = &pio0_uart0;
6
+ zephyr,shell-uart = &pio0_uart0;
7
+ };
8
+ };
9
+
10
+ &uart0 {
11
+ status = "disabled";
12
+ };
13
+
14
+ &pio0 {
15
+ status = "okay";
16
+
17
+ pio0_uart0: pio0_uart0 {
18
+ compatible = "raspberrypi,pico-uart-pio";
19
+
20
+ status = "okay";
21
+
22
+ pio,interrupts = <0>;
23
+ pio,interrupt-names = "shared";
24
+
25
+ pinctrl-0 = <&pio0_uart0_default>;
26
+ pinctrl-names = "default";
27
+
28
+ current-speed = <115200>;
29
+ };
30
+ };
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
- # nothing here
1
+ CONFIG_LOG=y
2
+ CONFIG_SHELL=y
3
+ CONFIG_SERIAL=y
4
+ CONFIG_UART_INTERRUPT_DRIVEN=y
5
+ CONFIG_UART_CONSOLE=y
Original file line number Diff line number Diff line change 1
1
/*
2
+ * Copyright (c) 2023 Ionut Pavel <[email protected] >
2
3
* Copyright (c) 2023 Yonatan Schachter
3
4
*
4
5
* SPDX-License-Identifier: Apache-2.0
5
6
*/
6
7
7
8
#include <zephyr/kernel.h>
8
- #include <zephyr/device.h>
9
- #include <zephyr/drivers/uart.h>
10
9
11
- int main (void )
12
- {
13
- char data ;
14
- const struct device * uart0 = DEVICE_DT_GET (DT_NODELABEL (pio1_uart0 ));
15
- const struct device * uart1 = DEVICE_DT_GET (DT_NODELABEL (pio1_uart1 ));
16
-
17
- if (!device_is_ready (uart0 )) {
18
- return 0 ;
19
- }
20
-
21
- if (!device_is_ready (uart1 )) {
22
- return 0 ;
23
- }
10
+ #include <zephyr/logging/log.h>
11
+ LOG_MODULE_REGISTER (main );
24
12
13
+ void main (void )
14
+ {
25
15
while (1 ) {
26
- if (!uart_poll_in (uart0 , & data )) {
27
- uart_poll_out (uart0 , data );
28
- }
29
-
30
- if (!uart_poll_in (uart1 , & data )) {
31
- uart_poll_out (uart1 , data );
32
- }
16
+ k_msleep (1000 );
17
+ LOG_INF ("One second passed..." );
33
18
}
34
-
35
- return 0 ;
36
19
}
You can’t perform that action at this time.
0 commit comments