Merge pull request #638 from marceloaqno/rpi-arduino-libs

RPi: Improve build process
This commit is contained in:
Henrik Ekblad
2016-11-19 19:32:40 +01:00
committed by GitHub
14 changed files with 219 additions and 104 deletions
+1
View File
@@ -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);
+12 -1
View File
@@ -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);
}
+4 -4
View File
@@ -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;