From f817d45d27a577c3c6bc32413611dc8511a4f159 Mon Sep 17 00:00:00 2001 From: its your bedtime <23366927+itsyourbedtime@users.noreply.github.com> Date: Mon, 7 Jun 2021 18:33:47 +0300 Subject: [PATCH] [FL-1288] Additional gpio_set pins for testing (#508) * uart rx, speaker and ir rx/tx pins added to cli_command_gpio_set * gpio_set: Warning for PA0, cli: added motd by @maratsafi --- applications/cli/cli.c | 39 +++++++++++++-------------------- applications/cli/cli_commands.c | 38 ++++++++++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 26 deletions(-) diff --git a/applications/cli/cli.c b/applications/cli/cli.c index be3b6d52..ae84f325 100644 --- a/applications/cli/cli.c +++ b/applications/cli/cli.c @@ -79,30 +79,21 @@ void cli_print_usage(const char* cmd, const char* usage, const char* arg) { } void cli_motd() { - printf(" __ \r\n \ - _.-~ ) \r\n \ - _..--~~~~,' ,-/ _\r\n \ - .-'. . . .' ,-',' ,' ) \r\n \ - ,'. . . _ ,--~,-'__..-' ,' \r\n \ - ,'. . . (@)' ---~~~~ ,'\r\n \ - /. . . . '~~ ,-'\r\n \ - /. . . . . ,-'\r\n \ - ; . . . . - . ,'\r\n \ - : . . . . _ /\r\n \ - . . . . . `-.:\r\n \ - . . . ./ - . )\r\n \ - . . . | _____..---.._/ _____\r\n \ -~-----~~~~----~~~~ ~~~-----~~~~~-----~\r\n \ - ______ _ _ _____ _ _____\r\n \ -| ____| (_) / ____| | |_ _|\r\n \ -| |__ | |_ _ __ _ __ ___ _ __ | | | | | |\r\n \ -| __| | | | '_ \\| '_ \\ / _ \\ '__| | | | | | |\r\n \ -| | | | | |_) | |_) | __/ | | |____| |____ _| |_\r\n \ -|_| |_|_| .__/| .__/ \\___|_| \\_____|______|_____|\r\n \ - | | | |\r\n \ - |_| |_|\r\n\r\n" - - ); + printf("\r\n \ + _.-------.._ -,\r\n \ + .-\"```\"--..,,_/ /`-, -, \\ \r\n \ + .:\" /:/ /'\\ \\ ,_..., `. | |\r\n \ + / ,----/:/ /`\\ _\\~`_-\"` _;\r\n \ + ' / /`\"\"\"'\\ \\ \\.~`_-' ,-\"'/ \r\n \ + | | | 0 | | .-' ,/` /\r\n \ + | ,..\\ \\ ,.-\"` ,/` /\r\n \ + ; : `/`\"\"\\` ,/--==,/-----,\r\n \ + | `-...| -.___-Z:_______J...---;\r\n \ + : ` _-'\r\n \ + _L_ _ ___ ___ ___ ___ ____--\"`___ _ ___\r\n \ +| __|| | |_ _|| _ \\| _ \\| __|| _ \\ / __|| | |_ _|\r\n \ +| _| | |__ | | | _/| _/| _| | / | (__ | |__ | |\r\n \ +|_| |____||___||_| |_| |___||_|_\\ \\___||____||___|\r\n\r\n"); printf("You are now connected to Flipper Command Line Interface.\r\n\r\n"); diff --git a/applications/cli/cli_commands.c b/applications/cli/cli_commands.c index 20b10263..049e706e 100644 --- a/applications/cli/cli_commands.c +++ b/applications/cli/cli_commands.c @@ -181,7 +181,22 @@ void cli_command_led(Cli* cli, string_t args, void* context) { } void cli_command_gpio_set(Cli* cli, string_t args, void* context) { - char pin_names[][4] = {"PC0", "PC1", "PC3", "PB2", "PB3", "PA4", "PA6", "PA7"}; + char pin_names[][4] = { + "PC0", + "PC1", + "PC3", + "PB2", + "PB3", + "PA4", + "PA6", + "PA7", +#ifdef DEBUG + "PA0", + "PB7", + "PB8", + "PB9" +#endif + }; GpioPin gpio[] = { {.port = GPIOC, .pin = LL_GPIO_PIN_0}, {.port = GPIOC, .pin = LL_GPIO_PIN_1}, @@ -190,7 +205,14 @@ void cli_command_gpio_set(Cli* cli, string_t args, void* context) { {.port = GPIOB, .pin = LL_GPIO_PIN_3}, {.port = GPIOA, .pin = LL_GPIO_PIN_4}, {.port = GPIOA, .pin = LL_GPIO_PIN_6}, - {.port = GPIOA, .pin = LL_GPIO_PIN_7}}; + {.port = GPIOA, .pin = LL_GPIO_PIN_7}, +#ifdef DEBUG + {.port = GPIOA, .pin = LL_GPIO_PIN_0}, // IR_RX (PA0) + {.port = GPIOB, .pin = LL_GPIO_PIN_7}, // UART RX (PB7) + {.port = GPIOB, .pin = LL_GPIO_PIN_8}, // SPEAKER (PB8) + {.port = GPIOB, .pin = LL_GPIO_PIN_9}, // IR_TX (PB9) +#endif + }; uint8_t num = 0; bool pin_found = false; @@ -229,6 +251,18 @@ void cli_command_gpio_set(Cli* cli, string_t args, void* context) { LL_GPIO_SetPinOutputType(gpio[num].port, gpio[num].pin, LL_GPIO_OUTPUT_PUSHPULL); LL_GPIO_ResetOutputPin(gpio[num].port, gpio[num].pin); } else if(!string_cmp(args, "1")) { +#ifdef DEBUG + if(num == 8) { // PA0 + printf( + "Setting PA0 pin HIGH with TSOP connected can damage IR receiver. Are you sure you want to continue? (y/n)?\r\n"); + char c = cli_getc(cli); + if(c != 'y' || c != 'Y') { + printf("Cancelled.\r\n"); + return; + } + } +#endif + LL_GPIO_SetPinMode(gpio[num].port, gpio[num].pin, LL_GPIO_MODE_OUTPUT); LL_GPIO_SetPinOutputType(gpio[num].port, gpio[num].pin, LL_GPIO_OUTPUT_PUSHPULL); LL_GPIO_SetOutputPin(gpio[num].port, gpio[num].pin);