busvoodoo_spi: remove features unsupported by dongle
This commit is contained in:
parent
f4231c9cc0
commit
e0f7f5c39c
|
@ -12,10 +12,10 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
/** BusVoodoo SPI mode (code)
|
||||
* @file busvoodoo_spi.c
|
||||
/** BusVoodoo SPI mode
|
||||
* @file
|
||||
* @author King Kévin <kingkevin@cuvoodoo.info>
|
||||
* @date 2018
|
||||
* @date 2018-2020
|
||||
* @note peripherals used: SPI @ref busvoodoo_spi
|
||||
*/
|
||||
/* standard libraries */
|
||||
|
@ -33,7 +33,9 @@
|
|||
#include "print.h" // printing utilities
|
||||
#include "menu.h" // menu definitions
|
||||
#include "busvoodoo_global.h" // BusVoodoo definitions
|
||||
#if BUSVOODOO_HARDWARE_VERSION != 2
|
||||
#include "busvoodoo_oled.h" // OLED utilities
|
||||
#endif
|
||||
#include "busvoodoo_spi.h" // own definitions
|
||||
|
||||
/** @defgroup busvoodoo_spi SPI peripheral used for SPI communication
|
||||
|
@ -65,8 +67,10 @@ static bool busvoodoo_spi_bitorder = true;
|
|||
static uint8_t busvoodoo_spi_standard_mode = 0;
|
||||
/** pin drive mode (true = push-pull, false = open-drain) */
|
||||
static bool busvoodoo_spi_drive = true;
|
||||
#if BUSVOODOO_HARDWARE_VERSION != 2
|
||||
/** if embedded pull-up resistors are used */
|
||||
static bool busvoodoo_spi_pullup = true;
|
||||
#endif
|
||||
|
||||
/** setup SPI mode
|
||||
* @param[out] prefix terminal prompt prefix
|
||||
|
@ -159,14 +163,23 @@ static bool busvoodoo_spi_setup(char** prefix, const char* line)
|
|||
break;
|
||||
case BUSVOODOO_SPI_SETTING_MODE:
|
||||
if (NULL==line || 0==strlen(line)) { // use default setting
|
||||
#if BUSVOODOO_HARDWARE_VERSION != 2
|
||||
busvoodoo_spi_setting = BUSVOODOO_SPI_SETTING_DRIVE; // go to next setting
|
||||
#else
|
||||
busvoodoo_spi_setting = BUSVOODOO_SPI_SETTING_DONE; // go to next setting
|
||||
#endif
|
||||
} else if (1==strlen(line)) { // setting provided
|
||||
uint8_t mode = atoi(line); // parse setting
|
||||
if (mode>=1 && mode<=4) {
|
||||
busvoodoo_spi_standard_mode = mode-1; // remember setting
|
||||
#if BUSVOODOO_HARDWARE_VERSION != 2
|
||||
busvoodoo_spi_setting = BUSVOODOO_SPI_SETTING_DRIVE; // go to next setting
|
||||
#else
|
||||
busvoodoo_spi_setting = BUSVOODOO_SPI_SETTING_DONE; // go to next setting
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#if BUSVOODOO_HARDWARE_VERSION != 2
|
||||
if (BUSVOODOO_SPI_SETTING_DRIVE==busvoodoo_spi_setting) { // if next setting
|
||||
printf("1) push-pull (3.3V)\n");
|
||||
printf("2) open-drain, with embedded pull-up resistors (2kO)\n");
|
||||
|
@ -186,6 +199,7 @@ static bool busvoodoo_spi_setup(char** prefix, const char* line)
|
|||
busvoodoo_spi_setting = BUSVOODOO_SPI_SETTING_DONE; // go to next setting
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (BUSVOODOO_SPI_SETTING_DONE==busvoodoo_spi_setting) { // we have all settings, configure SPI
|
||||
rcc_periph_clock_enable(RCC_AFIO); // enable clock for SPI alternate function
|
||||
rcc_periph_clock_enable(RCC_SPI(BUSVOODOO_SPI_ID)); // enable clock for SPI peripheral
|
||||
|
@ -236,14 +250,15 @@ static bool busvoodoo_spi_setup(char** prefix, const char* line)
|
|||
}
|
||||
spi_set_master_mode(SPI(BUSVOODOO_SPI_ID)); // set master mode
|
||||
spi_enable(SPI(BUSVOODOO_SPI_ID)); // enable SPI
|
||||
#if BUSVOODOO_HARDWARE_VERSION != 2
|
||||
if (!busvoodoo_spi_drive && busvoodoo_spi_pullup) {
|
||||
busvoodoo_embedded_pullup(true); // set embedded pull-ups
|
||||
printf("use LV to set pull-up voltage\n");
|
||||
}
|
||||
#endif
|
||||
busvoodoo_led_blue_off(); // disable blue LED because there is no activity
|
||||
busvoodoo_spi_setting = BUSVOODOO_SPI_SETTING_NONE; // restart settings next time
|
||||
*prefix = "SPI"; // display mode
|
||||
busvoodoo_oled_text_left(*prefix); // set mode title on OLED display
|
||||
const char* pinout_io[10] = {"GND", "5V", "3V3", "LV", NULL, NULL, "MISO", "SCK", "MOSI", "SS"}; // SPI mode pinout
|
||||
if (!busvoodoo_spi_duplex) {
|
||||
pinout_io[6] = NULL; // MISO is not used
|
||||
|
@ -252,14 +267,17 @@ static bool busvoodoo_spi_setup(char** prefix, const char* line)
|
|||
for (uint8_t i=0; i<LENGTH(pinout_io) && i<LENGTH(busvoodoo_global_pinout_io); i++) {
|
||||
busvoodoo_global_pinout_io[i] = pinout_io[i]; // set pin names
|
||||
}
|
||||
#if BUSVOODOO_HARDWARE_VERSION != 2
|
||||
if (busvoodoo_full) {
|
||||
const char* pinout_rscan[5] = {"HV", NULL, NULL, NULL, NULL}; // HiZ mode RS/CAN pinout
|
||||
for (uint8_t i=0; i<LENGTH(pinout_rscan) && i<LENGTH(busvoodoo_global_pinout_rscan); i++) {
|
||||
busvoodoo_global_pinout_rscan[i] = pinout_rscan[i]; // set pin names
|
||||
}
|
||||
}
|
||||
busvoodoo_oled_text_left(*prefix); // set mode title on OLED display
|
||||
busvoodoo_oled_text_pinout(pinout_io, true); // set pinout on display
|
||||
busvoodoo_oled_update(); // update display to show text and pinout
|
||||
#endif
|
||||
complete = true; // configuration is complete
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
/** BusVoodoo SPI mode (API)
|
||||
* @file busvoodoo_spi.h
|
||||
/** BusVoodoo SPI mode
|
||||
* @file
|
||||
* @author King Kévin <kingkevin@cuvoodoo.info>
|
||||
* @date 2018
|
||||
* @date 2018-2020
|
||||
* @note peripherals used: SPI @ref busvoodoo_spi
|
||||
*/
|
||||
|
||||
|
|
Loading…
Reference in New Issue