RPi: Improve build process
Add option to set an external arduino libraries directory. All libraries from this folder will be compile and available for use in the gateway. Some Arduino libraries can be used on Linux/RPI with minor adjustments, but there are some that will have to be completely rewritten. The build process uses a separate folder for objects and binary files which can be set by the user. Initialize the bcm2835 inside a class constructor to fix cases where pin operations are used before hwInit(). Fix SPI pins default values. Fix activation interrupt functions. Fix some headers. Rename gateway binary and services to mysgw.
This commit is contained in:
@@ -68,6 +68,7 @@ using std::abs;
|
||||
typedef bool boolean;
|
||||
typedef uint8_t byte;
|
||||
typedef string String;
|
||||
typedef char __FlashStringHelper;
|
||||
|
||||
void yield(void);
|
||||
unsigned long millis(void);
|
||||
|
||||
@@ -44,6 +44,7 @@ struct ThreadArgs {
|
||||
int gpioPin;
|
||||
};
|
||||
|
||||
volatile bool interruptsEnabled = true;
|
||||
static pthread_mutex_t intMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static pthread_t *threadIds[64] = {NULL};
|
||||
@@ -152,7 +153,13 @@ void *interruptHandler(void *args) {
|
||||
(void)read (fd, &c, 1) ;
|
||||
lseek (fd, 0, SEEK_SET) ;
|
||||
// Call user function.
|
||||
func();
|
||||
pthread_mutex_lock(&intMutex);
|
||||
if (interruptsEnabled) {
|
||||
pthread_mutex_unlock(&intMutex);
|
||||
func();
|
||||
} else {
|
||||
pthread_mutex_unlock(&intMutex);
|
||||
}
|
||||
}
|
||||
|
||||
close(fd);
|
||||
@@ -322,9 +329,13 @@ uint8_t rpi_util::digitalPinToInterrupt(uint8_t physPin) {
|
||||
}
|
||||
|
||||
void rpi_util::interrupts() {
|
||||
pthread_mutex_lock(&intMutex);
|
||||
interruptsEnabled = true;
|
||||
pthread_mutex_unlock(&intMutex);
|
||||
}
|
||||
|
||||
void rpi_util::noInterrupts() {
|
||||
pthread_mutex_lock(&intMutex);
|
||||
interruptsEnabled = false;
|
||||
pthread_mutex_unlock(&intMutex);
|
||||
}
|
||||
|
||||
@@ -45,10 +45,10 @@ typedef enum {
|
||||
} rpi_pinedge;
|
||||
|
||||
typedef enum {
|
||||
PIN_SPI_SS = RPI_GPIO_P1_24,
|
||||
PIN_SPI_MOSI = RPI_GPIO_P1_19,
|
||||
PIN_SPI_MISO = RPI_GPIO_P1_21,
|
||||
PIN_SPI_SCK = RPI_GPIO_P1_23
|
||||
PIN_SPI_SS = 24,
|
||||
PIN_SPI_MOSI = 19,
|
||||
PIN_SPI_MISO = 21,
|
||||
PIN_SPI_SCK = 23
|
||||
} rpi_spipins;
|
||||
|
||||
const uint8_t SS = PIN_SPI_SS;
|
||||
|
||||
Reference in New Issue
Block a user