Skip to content

Commit

Permalink
Make SPI frequency configurable on Native
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-bennett committed Aug 1, 2024
1 parent 4c1c5b0 commit d6a2a8a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
11 changes: 10 additions & 1 deletion bin/config-dist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ Lora:

# ch341_quirk: true # Uncomment this to use the chunked SPI transfer that seems to fix the ch341

# spiSpeed: 2000000

### Set gpio chip to use in /dev/. Defaults to 0.
### Notably the Raspberry Pi 5 puts the GPIO header on gpiochip4
# gpiochip: 4
Expand Down Expand Up @@ -111,6 +113,9 @@ Display:
# Height: 320
# Rotate: true

### You can also specify the spi device for the display to use
# spidev: spidev0.0

Touchscreen:
### Note, at least for now, the touchscreen must have a CS pin defined, even if you let Linux manage the CS switching.

Expand All @@ -126,9 +131,13 @@ Touchscreen:
# CS: 7
# IRQ: 17

### Configure device for direct keyboard input
### You can also specify the spi device for the touchscreen to use
# spidev: spidev0.0


Input:
### Configure device for direct keyboard input

# KeyboardDevice: /dev/input/by-id/usb-_Raspberry_Pi_Internal_Keyboard-event-kbd

###
Expand Down
7 changes: 5 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,11 @@ uint32_t timeLastPowered = 0;
static Periodic *ledPeriodic;
static OSThread *powerFSMthread;
static OSThread *ambientLightingThread;
#if ARCH_PORTDUINO
SPISettings spiSettings(settingsMap[spiSpeed], MSBFIRST, SPI_MODE0);
#else
SPISettings spiSettings(4000000, MSBFIRST, SPI_MODE0);

#endif
RadioInterface *rIf = NULL;

/**
Expand Down Expand Up @@ -1094,4 +1097,4 @@ void loop()
mainDelay.delay(delayMsec);
}
// if (didWake) LOG_DEBUG("wake!\n");
}
}
2 changes: 2 additions & 0 deletions src/platform/portduino/PortduinoGlue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ void portduinoSetup()
settingsStrings[webserverrootpath] = "";
settingsStrings[spidev] = "";
settingsStrings[displayspidev] = "";
settingsMap[spiSpeed] = 2000000;

YAML::Node yamlConfig;

Expand Down Expand Up @@ -173,6 +174,7 @@ void portduinoSetup()
settingsMap[rxen] = yamlConfig["Lora"]["RXen"].as<int>(RADIOLIB_NC);
settingsMap[gpiochip] = yamlConfig["Lora"]["gpiochip"].as<int>(0);
settingsMap[ch341Quirk] = yamlConfig["Lora"]["ch341_quirk"].as<bool>(false);
settingsMap[spiSpeed] = yamlConfig["Lora"]["spiSpeed"].as<int>(2000000);
gpioChipName += std::to_string(settingsMap[gpiochip]);

settingsStrings[spidev] = "/dev/" + yamlConfig["Lora"]["spidev"].as<std::string>("spidev0.0");
Expand Down
1 change: 1 addition & 0 deletions src/platform/portduino/PortduinoGlue.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum configNames {
user,
gpiochip,
spidev,
spiSpeed,
i2cdev,
has_gps,
touchscreenModule,
Expand Down

0 comments on commit d6a2a8a

Please sign in to comment.