[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
This commit is contained in:
its your bedtime 2021-06-07 18:33:47 +03:00 committed by GitHub
parent 31c31db479
commit f817d45d27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 26 deletions

View file

@ -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");

View file

@ -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);