This commit is contained in:
hathach
2025-01-25 16:29:56 +07:00
parent 6b3a5957c2
commit 8c7998b0e9
11 changed files with 51 additions and 109 deletions

View File

@@ -23,7 +23,6 @@
*
*/
#if 1
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -52,7 +51,7 @@ int main(void) {
// Blink and print every interval ms
if (!(board_millis() - start_ms < interval_ms)) {
// board_uart_write(HELLO_STR, strlen(HELLO_STR));
board_uart_write(HELLO_STR, strlen(HELLO_STR));
start_ms = board_millis();
@@ -61,57 +60,12 @@ int main(void) {
}
// echo
// uint8_t ch;
// if (board_uart_read(&ch, 1) > 0) {
// board_uart_write(&ch, 1);
// }
}
}
#else
#include <stdio.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>
/* 1000 msec = 1 sec */
#define SLEEP_TIME_MS 200
/* The devicetree node identifier for the "led0" alias. */
#define LED0_NODE DT_ALIAS(led0)
/*
* A build error on this line means your board is unsupported.
* See the sample documentation for information on how to fix this.
*/
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
int main(void)
{
int ret;
bool led_state = true;
if (!gpio_is_ready_dt(&led)) {
return 0;
}
ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
if (ret < 0) {
return 0;
}
while (1) {
ret = gpio_pin_toggle_dt(&led);
if (ret < 0) {
return 0;
uint8_t ch;
if (board_uart_read(&ch, 1) > 0) {
board_uart_write(&ch, 1);
}
led_state = !led_state;
printf("LED state: %s\n", led_state ? "ON" : "OFF");
k_msleep(SLEEP_TIME_MS);
}
return 0;
}
#endif
#if TUSB_MCU_VENDOR_ESPRESSIF
void app_main(void) {