rp2040/example/shell/shell_no_os/main.c

43 lines
1.1 KiB
C
Raw Normal View History

2025-06-29 17:16:15 +08:00
#include "resets.h"
#include "timer.h"
#include "gpio.h"
#include "uart.h"
#include "stdio.h"
#include "stdlib.h"
#include "mem.h"
#include "shell.h"
#define LED_PIN (25)
#define LED_TIME (500 * 1000) /* 500ms */
int main(void)
{
reset_unreset_blocks_wait(RESETS_BLOCK_IO_BANK0 | RESETS_BLOCK_UART0 | RESETS_BLOCK_TIMER);
gpio_init(0, GPIO_FUNC_UART | GPIO_PULL_UP | GPIO_DRIVE_4MA); /* UART_TX pin */
gpio_init(1, GPIO_FUNC_UART | GPIO_PULL_UP | GPIO_SCHMITT | GPIO_PAD_IE | GPIO_PAD_OD); /* UART_RX pin */
uart_init(uart0_hw, 6 * 1000 * 1000, UART_DATABITS_8 | UART_PARITY_NONE | UART_STOPBITS_1);
printf("shell example\r\n");
kmem_init((void *)0x20030000, 64 * 1024);
shell_init();
while(1) {
int c = uart_get_char(uart0_hw);
if (c >= 0) {
shell_handler((char)c);
}
}
return 0;
}
int shell_test(int argc, char **argv)
{
printf("shell test, argc=%d:\r\n", argc);
for (int i = 0; i < argc; i++) {
printf("argv[%d] = %s\r\n", i, argv[i]);
}
printf("\r\n");
return 0;
}
SHELL_CMD_EXPORT_ALIAS(shell_test, test, shell test.);