Merge pull request #638 from marceloaqno/rpi-arduino-libs
RPi: Improve build process
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