Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Stop touching SPI and GPIOs when not running on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
geeksville committed May 23, 2021
1 parent faa35bd commit d22ebe0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 111 deletions.
8 changes: 7 additions & 1 deletion cores/portduino/linux/LinuxHardwareSPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
#include "HardwareSPI.h"
#include "SPIChip.h"
#include "Utility.h"
#include "linux/PosixFile.h"
#include "logging.h"

#include <assert.h>

#ifdef PORTDUINO_LINUX_HARDWARE

#include "linux/PosixFile.h"
#include <linux/spi/spidev.h>

class LinuxSPIChip : public SPIChip, private PosixFile {
Expand Down Expand Up @@ -69,6 +72,7 @@ class LinuxSPIChip : public SPIChip, private PosixFile {
return 0;
}
};
#endif

// FIXME, this is kinda skanky, but for now we assume one SPI device
SPIChip *spiChip;
Expand Down Expand Up @@ -139,13 +143,15 @@ void HardwareSPI::begin() {
// We only do this init once per boot
if (!spiChip) {

#ifdef PORTDUINO_LINUX_HARDWARE
// FIXME, only install the following on linux and only if we see that the
// device exists in the filesystem
try {
spiChip = new LinuxSPIChip();
} catch (...) {
printf("No hardware spi chip found...\n");
}
#endif

if (!spiChip) // no hw spi found, use the simulator
spiChip = new SimSPIChip();
Expand Down
3 changes: 3 additions & 0 deletions cores/portduino/linux/gpio/LinuxGPIOPin.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifdef PORTDUINO_LINUX_HARDWARE

#include "linux/gpio/LinuxGPIOPin.h"
#include <assert.h>
#include <dirent.h>
Expand Down Expand Up @@ -115,3 +117,4 @@ void LinuxGPIOPin::setPinMode(PinMode m) {
}


#endif
4 changes: 3 additions & 1 deletion cores/portduino/linux/gpio/LinuxGPIOPin.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Created by kevinh on 9/1/20.
//

#ifdef PORTDUINO_LINUX_HARDWARE

#include "Arduino.h"
#include "Common.h"
#include "PortduinoGPIO.h"
Expand Down Expand Up @@ -44,4 +46,4 @@ class LinuxGPIOPin : public GPIOPin {
virtual void setPinMode(PinMode m);
};


#endif
39 changes: 0 additions & 39 deletions cores/portduino/linux/gpio/classic/ClassicLinuxGpio.cpp

This file was deleted.

70 changes: 0 additions & 70 deletions cores/portduino/linux/gpio/classic/GPIOChip.h

This file was deleted.

0 comments on commit d22ebe0

Please sign in to comment.