Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Wagner authored and Andre Wagner committed Mar 29, 2024
1 parent fe46574 commit 5275a46
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Connect the Pico USB to the computer, and then open a serial terminal to the USB
- `set uart.mode [MMM]` (default: 8N1)
- `set uart.hflow [on | off]` (default: off)
- `set uart.output [ascii | dec | bin | hex]` (default: ascii)
- `guess uart`: tries to autodetect baudrate
- `use uart guess`: tries to autodetect baudrate
- SPI
- `set spi.cpol [0 | 1]` (default: 0)
- `set spi.cpha [0 | 1]` (default: 0)
Expand All @@ -39,6 +39,7 @@ Connect the Pico USB to the computer, and then open a serial terminal to the USB
- I2C
- `set i2c.baud [NNNN]` (baud rate in Hz, master only, default: 100000)
- `set i2c.output [ascii | dec | bin | hex]` (default: hex)
- `use i2c scan`: scan for connected slave addresses
- PWM
- `set pwm.freq [NNNN]` (frequency in Hz, default: 100000)
- `set pwm.duty [NN]` (% duty cycle, default: 50)
Expand Down
12 changes: 4 additions & 8 deletions firmware/src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ void execute(uint8_t n_tokens, char tokens[MAX_TOKENS][MAX_TOKEN_SZ])
printf("Options: uart, spi_master, spi_slave, spi_sniff, i2c_master, i2c_slave, pmw\n");
} else if (n_tokens >= 2) {
if (strcmp(tokens[1], "uart") == 0) {
uart_init_();
if (n_tokens == 3 && strcmp(tokens[2], "guess") == 0)
uart_guess_speed();
else
uart_init_();
} else if (strcmp(tokens[1], "spi_master") == 0) {
spi_master_init();
} else if (strcmp(tokens[1], "spi_slave") == 0) {
Expand Down Expand Up @@ -89,13 +92,6 @@ void execute(uint8_t n_tokens, char tokens[MAX_TOKENS][MAX_TOKEN_SZ])
variable_set(tokens[1], tokens[2]);
else
syntax_error();
} else if (strcmp(tokens[0], "guess") == 0) {
if (n_tokens == 1)
printf("Options: uart\n");
else if (n_tokens == 2 && strcmp(tokens[0], "uart") == 0)
uart_guess_speed();
else
syntax_error();
} else {
syntax_error();
}
Expand Down
4 changes: 3 additions & 1 deletion firmware/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ int main()
gpio_set_dir(LED_PIN, GPIO_OUT);
gpio_put(LED_PIN, 1);

printf("Press any key to start...");
getchar();
printf("\n");

printf("Welcome to Poor Man Bus Pirate!\n");
printf("Available commands: set, reset, use, guess\n");
printf("Available commands: set, reset, use\n");

output_init();
variables_load();
Expand Down
2 changes: 1 addition & 1 deletion firmware/src/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void uart_guess_speed()

static const size_t speeds[] = {
3000000, 2000000, 1000000, 500000, 250000, 230400, 115200,
57600, 38400, 19200, 14400, 9600, 4800, 2400, 1200, 600, 300
57600, 38400, 19200, 14400, 9600, 4800, 2400, 1200, 600, 300, 0
};

for (size_t i = 0; speeds[i]; ++i) {
Expand Down

0 comments on commit 5275a46

Please sign in to comment.