application: remove features unsupported by dongle
This commit is contained in:
parent
92fd728774
commit
2351a1c221
|
@ -20,20 +20,22 @@
|
||||||
/* own libraries */
|
/* own libraries */
|
||||||
#include "global.h" // board definitions
|
#include "global.h" // board definitions
|
||||||
#include "print.h" // printing utilities
|
#include "print.h" // printing utilities
|
||||||
#include "uart.h" // USART utilities
|
|
||||||
#include "usb_cdcacm.h" // USB CDC ACM utilities
|
#include "usb_cdcacm.h" // USB CDC ACM utilities
|
||||||
#include "terminal.h" // handle the terminal interface
|
#include "terminal.h" // handle the terminal interface
|
||||||
#include "menu.h" // menu utilities
|
#include "menu.h" // menu utilities
|
||||||
#include "busvoodoo_global.h" // BusVoodoo definitions
|
#include "busvoodoo_global.h" // BusVoodoo definitions
|
||||||
#include "busvoodoo_oled.h" // OLED utilities
|
|
||||||
#include "busvoodoo_hiz.h" // BusVoodoo HiZ mode
|
#include "busvoodoo_hiz.h" // BusVoodoo HiZ mode
|
||||||
#include "busvoodoo_uart.h" // BusVoodoo UART mode
|
#include "busvoodoo_uart.h" // BusVoodoo UART mode
|
||||||
#include "busvoodoo_i2c.h" // BusVoodoo I2C mode
|
#include "busvoodoo_i2c.h" // BusVoodoo I2C mode
|
||||||
#include "busvoodoo_spi.h" // BusVoodoo SPI mode
|
#include "busvoodoo_spi.h" // BusVoodoo SPI mode
|
||||||
|
#if BUSVOODOO_HARDWARE_VERSION != 2
|
||||||
#include "busvoodoo_onewire.h" // BusVoodoo 1-wire mode
|
#include "busvoodoo_onewire.h" // BusVoodoo 1-wire mode
|
||||||
|
#include "uart.h" // USART utilities
|
||||||
|
#include "busvoodoo_oled.h" // OLED utilities
|
||||||
#include "busvoodoo_rs232.h" // BusVoodoo RS-232 mode
|
#include "busvoodoo_rs232.h" // BusVoodoo RS-232 mode
|
||||||
#include "busvoodoo_rs485.h" // BusVoodoo RS-485/422 mode
|
#include "busvoodoo_rs485.h" // BusVoodoo RS-485/422 mode
|
||||||
#include "busvoodoo_sdio.h" // BusVoodoo SDIO mode
|
#include "busvoodoo_sdio.h" // BusVoodoo SDIO mode
|
||||||
|
#endif
|
||||||
|
|
||||||
/** watchdog period in ms */
|
/** watchdog period in ms */
|
||||||
#define WATCHDOG_PERIOD 10000
|
#define WATCHDOG_PERIOD 10000
|
||||||
|
@ -60,10 +62,12 @@ static const struct busvoodoo_mode_t* busvoodoo_modes[] = {
|
||||||
&busvoodoo_uart_mode,
|
&busvoodoo_uart_mode,
|
||||||
&busvoodoo_i2c_mode,
|
&busvoodoo_i2c_mode,
|
||||||
&busvoodoo_spi_mode,
|
&busvoodoo_spi_mode,
|
||||||
|
#if BUSVOODOO_HARDWARE_VERSION != 2
|
||||||
&busvoodoo_onewire_mode,
|
&busvoodoo_onewire_mode,
|
||||||
&busvoodoo_rs232_mode,
|
&busvoodoo_rs232_mode,
|
||||||
&busvoodoo_rs485_mode,
|
&busvoodoo_rs485_mode,
|
||||||
&busvoodoo_sdio_mode,
|
&busvoodoo_sdio_mode,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/** current BusVoodoo mode */
|
/** current BusVoodoo mode */
|
||||||
|
@ -77,12 +81,16 @@ size_t putc(char c)
|
||||||
static char last_c = 0; // to remember on which character we last sent
|
static char last_c = 0; // to remember on which character we last sent
|
||||||
if ('\n' == c) { // send carriage return (CR) + line feed (LF) newline for each LF
|
if ('\n' == c) { // send carriage return (CR) + line feed (LF) newline for each LF
|
||||||
if ('\r' != last_c) { // CR has not already been sent
|
if ('\r' != last_c) { // CR has not already been sent
|
||||||
|
#if BUSVOODOO_HARDWARE_VERSION != 2
|
||||||
uart_putchar_nonblocking('\r'); // send CR over USART
|
uart_putchar_nonblocking('\r'); // send CR over USART
|
||||||
|
#endif
|
||||||
usb_cdcacm_putchar('\r'); // send CR over USB
|
usb_cdcacm_putchar('\r'); // send CR over USB
|
||||||
length++; // remember we printed 1 character
|
length++; // remember we printed 1 character
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if BUSVOODOO_HARDWARE_VERSION != 2
|
||||||
uart_putchar_nonblocking(c); // send byte over USART
|
uart_putchar_nonblocking(c); // send byte over USART
|
||||||
|
#endif
|
||||||
usb_cdcacm_putchar(c); // send byte over USB
|
usb_cdcacm_putchar(c); // send byte over USB
|
||||||
length++; // remember we printed 1 character
|
length++; // remember we printed 1 character
|
||||||
last_c = c; // remember last character
|
last_c = c; // remember last character
|
||||||
|
@ -100,14 +108,16 @@ static void switch_mode(const struct busvoodoo_mode_t* mode)
|
||||||
busvoodoo_leds_off(); // switch off LEDs
|
busvoodoo_leds_off(); // switch off LEDs
|
||||||
busvoodoo_safe_state(); // return to safe state
|
busvoodoo_safe_state(); // return to safe state
|
||||||
// reset pinout
|
// reset pinout
|
||||||
for (uint8_t i=0; i<LENGTH(busvoodoo_global_pinout_rscan); i++) {
|
|
||||||
busvoodoo_global_pinout_rscan[i] = NULL;
|
|
||||||
}
|
|
||||||
for (uint8_t i=0; i<LENGTH(busvoodoo_global_pinout_io); i++) {
|
for (uint8_t i=0; i<LENGTH(busvoodoo_global_pinout_io); i++) {
|
||||||
busvoodoo_global_pinout_io[i] = NULL;
|
busvoodoo_global_pinout_io[i] = NULL;
|
||||||
}
|
}
|
||||||
|
#if BUSVOODOO_HARDWARE_VERSION != 2
|
||||||
|
for (uint8_t i=0; i<LENGTH(busvoodoo_global_pinout_rscan); i++) {
|
||||||
|
busvoodoo_global_pinout_rscan[i] = NULL;
|
||||||
|
}
|
||||||
busvoodoo_oled_clear(); // clear OLED display buffer
|
busvoodoo_oled_clear(); // clear OLED display buffer
|
||||||
busvoodoo_oled_update(); // update OLED display
|
busvoodoo_oled_update(); // update OLED display
|
||||||
|
#endif
|
||||||
if (NULL==mode) { // no mode provided
|
if (NULL==mode) { // no mode provided
|
||||||
busvoodoo_mode = &busvoodoo_hiz_mode; // use default mode
|
busvoodoo_mode = &busvoodoo_hiz_mode; // use default mode
|
||||||
} else { // mode provided
|
} else { // mode provided
|
||||||
|
@ -179,9 +189,11 @@ static void command_help(void* argument)
|
||||||
printf("available commands:\n");
|
printf("available commands:\n");
|
||||||
menu_print_commands(menu_commands, LENGTH(menu_commands)); // print global commands
|
menu_print_commands(menu_commands, LENGTH(menu_commands)); // print global commands
|
||||||
menu_print_commands(busvoodoo_global_commands, busvoodoo_global_commands_nb); // print BusVoodoo global commands
|
menu_print_commands(busvoodoo_global_commands, busvoodoo_global_commands_nb); // print BusVoodoo global commands
|
||||||
|
#if BUSVOODOO_HARDWARE_VERSION != 2
|
||||||
if (busvoodoo_full) {
|
if (busvoodoo_full) {
|
||||||
menu_print_commands(busvoodoo_global_full_commands, busvoodoo_global_full_commands_nb); // print BusVoodoo global commands
|
menu_print_commands(busvoodoo_global_full_commands, busvoodoo_global_full_commands_nb); // print BusVoodoo global commands
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (!busvoodoo_mode->full_only || busvoodoo_full) {
|
if (!busvoodoo_mode->full_only || busvoodoo_full) {
|
||||||
menu_print_commands(busvoodoo_mode->commands, busvoodoo_mode->commands_nb); // print BusVoodoo mode commands
|
menu_print_commands(busvoodoo_mode->commands, busvoodoo_mode->commands_nb); // print BusVoodoo mode commands
|
||||||
}
|
}
|
||||||
|
@ -253,9 +265,11 @@ static void process_command(char* str)
|
||||||
if (!busvoodoo_mode->full_only || busvoodoo_full) {
|
if (!busvoodoo_mode->full_only || busvoodoo_full) {
|
||||||
command_handled = menu_handle_command(str, busvoodoo_mode->commands, busvoodoo_mode->commands_nb); // try if the mode can handle this command
|
command_handled = menu_handle_command(str, busvoodoo_mode->commands, busvoodoo_mode->commands_nb); // try if the mode can handle this command
|
||||||
}
|
}
|
||||||
|
#if BUSVOODOO_HARDWARE_VERSION != 2
|
||||||
if (!command_handled && busvoodoo_full) {
|
if (!command_handled && busvoodoo_full) {
|
||||||
command_handled = menu_handle_command(str, busvoodoo_global_full_commands, busvoodoo_global_full_commands_nb); // try if full BusVoodoo can handle this command
|
command_handled = menu_handle_command(str, busvoodoo_global_full_commands, busvoodoo_global_full_commands_nb); // try if full BusVoodoo can handle this command
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (!command_handled) {
|
if (!command_handled) {
|
||||||
command_handled = menu_handle_command(str, busvoodoo_global_commands, busvoodoo_global_commands_nb); // try if the base BusVoodoo can handle this command
|
command_handled = menu_handle_command(str, busvoodoo_global_commands, busvoodoo_global_commands_nb); // try if the base BusVoodoo can handle this command
|
||||||
}
|
}
|
||||||
|
@ -291,7 +305,9 @@ void main(void)
|
||||||
|
|
||||||
// setup board
|
// setup board
|
||||||
board_setup(); // setup board
|
board_setup(); // setup board
|
||||||
|
#if BUSVOODOO_HARDWARE_VERSION != 2
|
||||||
uart_setup(); // setup USART (for printing)
|
uart_setup(); // setup USART (for printing)
|
||||||
|
#endif
|
||||||
busvoodoo_setup(); // setup BusVoodoo board
|
busvoodoo_setup(); // setup BusVoodoo board
|
||||||
usb_cdcacm_setup(); // setup USB CDC ACM (for printing)
|
usb_cdcacm_setup(); // setup USB CDC ACM (for printing)
|
||||||
puts("\nwelcome to \x1b[32mBus\x1b[35mVoodoo\x1b[0m\n"); // print welcome message
|
puts("\nwelcome to \x1b[32mBus\x1b[35mVoodoo\x1b[0m\n"); // print welcome message
|
||||||
|
@ -333,6 +349,7 @@ void main(void)
|
||||||
terminal_process = &process_command; // set central function to process commands
|
terminal_process = &process_command; // set central function to process commands
|
||||||
terminal_setup(); // start terminal
|
terminal_setup(); // start terminal
|
||||||
|
|
||||||
|
#if BUSVOODOO_HARDWARE_VERSION != 2
|
||||||
// setup OLED display
|
// setup OLED display
|
||||||
sleep_ms(10); // wait a bit until the display is ready
|
sleep_ms(10); // wait a bit until the display is ready
|
||||||
busvoodoo_oled_setup(); // setup OLED display
|
busvoodoo_oled_setup(); // setup OLED display
|
||||||
|
@ -352,6 +369,7 @@ void main(void)
|
||||||
busvoodoo_oled_update();
|
busvoodoo_oled_update();
|
||||||
sleep_ms(1000);
|
sleep_ms(1000);
|
||||||
busvoodoo_oled_clear();
|
busvoodoo_oled_clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
// setup default mode
|
// setup default mode
|
||||||
switch_mode(NULL);
|
switch_mode(NULL);
|
||||||
|
|
Loading…
Reference in New Issue