1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Merge remote-tracking branch 'origin/lilvinz/exti_end_switching_isr' into next

This commit is contained in:
James Cotton 2012-09-27 14:31:16 -05:00
commit a021659b75
11 changed files with 130 additions and 21 deletions

View File

@ -434,7 +434,7 @@ int32_t PIOS_BMA180_Test()
* @brief IRQ Handler. Read data from the BMA180 FIFO and push onto a local fifo. * @brief IRQ Handler. Read data from the BMA180 FIFO and push onto a local fifo.
*/ */
int32_t bma180_irqs = 0; int32_t bma180_irqs = 0;
void PIOS_BMA180_IRQHandler(void) bool PIOS_BMA180_IRQHandler(void)
{ {
bma180_irqs++; bma180_irqs++;
@ -471,6 +471,7 @@ void PIOS_BMA180_IRQHandler(void)
fifoBuf_putData(&dev->fifo, (uint8_t *) &data, sizeof(data)); fifoBuf_putData(&dev->fifo, (uint8_t *) &data, sizeof(data));
return false;
} }
#endif /* PIOS_INCLUDE_BMA180 */ #endif /* PIOS_INCLUDE_BMA180 */

View File

@ -391,9 +391,11 @@ int32_t PIOS_HMC5883_Test(void)
/** /**
* @brief IRQ Handler * @brief IRQ Handler
*/ */
void PIOS_HMC5883_IRQHandler(void) bool PIOS_HMC5883_IRQHandler(void)
{ {
pios_hmc5883_data_ready = true; pios_hmc5883_data_ready = true
return false;
} }
#endif /* PIOS_INCLUDE_HMC5883 */ #endif /* PIOS_INCLUDE_HMC5883 */

View File

@ -353,7 +353,7 @@ uint8_t PIOS_L3GD20_Test(void)
/** /**
* @brief IRQ Handler. Read all the data from onboard buffer * @brief IRQ Handler. Read all the data from onboard buffer
*/ */
void PIOS_L3GD20_IRQHandler(void) bool PIOS_L3GD20_IRQHandler(void)
{ {
l3gd20_irq++; l3gd20_irq++;
@ -375,7 +375,10 @@ void PIOS_L3GD20_IRQHandler(void)
memcpy((uint8_t *) &(data.gyro_x), &rec[1], 6); memcpy((uint8_t *) &(data.gyro_x), &rec[1], 6);
data.temperature = PIOS_L3GD20_GetReg(PIOS_L3GD20_OUT_TEMP); data.temperature = PIOS_L3GD20_GetReg(PIOS_L3GD20_OUT_TEMP);
xQueueSend(dev->queue, (void *) &data, 0); portBASE_TYPE xHigherPriorityTaskWoken;
xQueueSendToBackFromISR(dev->queue, (void *) &data, &xHigherPriorityTaskWoken);
return xHigherPriorityTaskWoken == pdTRUE;
} }
#endif /* L3GD20 */ #endif /* L3GD20 */

View File

@ -462,11 +462,14 @@ void PIOS_MPU6000_IRQHandler(void)
data.gyro_z = mpu6000_rec_buf[7] << 8 | mpu6000_rec_buf[8]; data.gyro_z = mpu6000_rec_buf[7] << 8 | mpu6000_rec_buf[8];
#endif #endif
xQueueSend(dev->queue, (void *) &data, 0); portBASE_TYPE xHigherPriorityTaskWoken;
xQueueSendToBackFromISR(dev->queue, (void *) &data, &xHigherPriorityTaskWoken);
mpu6000_irq++; mpu6000_irq++;
mpu6000_time_us = PIOS_DELAY_DiffuS(timeval); mpu6000_time_us = PIOS_DELAY_DiffuS(timeval);
return xHigherPriorityTaskWoken == pdTRUE;
} }
#endif #endif

View File

@ -149,7 +149,7 @@ out_fail:
return -1; return -1;
} }
static void PIOS_EXTI_generic_irq_handler(uint8_t line_index) static bool PIOS_EXTI_generic_irq_handler(uint8_t line_index)
{ {
uint8_t cfg_index = pios_exti_line_to_cfg_map[line_index]; uint8_t cfg_index = pios_exti_line_to_cfg_map[line_index];
@ -158,69 +158,119 @@ static void PIOS_EXTI_generic_irq_handler(uint8_t line_index)
if (cfg_index > NELEMENTS(pios_exti_line_to_cfg_map) || if (cfg_index > NELEMENTS(pios_exti_line_to_cfg_map) ||
cfg_index == PIOS_EXTI_INVALID) { cfg_index == PIOS_EXTI_INVALID) {
/* Unconfigured interrupt just fired! */ /* Unconfigured interrupt just fired! */
return; return false;
} }
struct pios_exti_cfg * cfg = &__start__exti + cfg_index; struct pios_exti_cfg * cfg = &__start__exti + cfg_index;
cfg->vector(); return cfg->vector();
} }
/* Bind Interrupt Handlers */ #ifdef PIOS_INCLUDE_FREERTOS
#define PIOS_EXTI_HANDLE_LINE(line) \
if (EXTI_GetITStatus(EXTI_Line##line) != RESET) { \
EXTI_ClearITPendingBit(EXTI_Line##line); \
xHigherPriorityTaskWoken |= PIOS_EXTI_generic_irq_handler(line); \
}
#else
#define PIOS_EXTI_HANDLE_LINE(line) \ #define PIOS_EXTI_HANDLE_LINE(line) \
if (EXTI_GetITStatus(EXTI_Line##line) != RESET) { \ if (EXTI_GetITStatus(EXTI_Line##line) != RESET) { \
EXTI_ClearITPendingBit(EXTI_Line##line); \ EXTI_ClearITPendingBit(EXTI_Line##line); \
PIOS_EXTI_generic_irq_handler(line); \ PIOS_EXTI_generic_irq_handler(line); \
} }
#endif
/* Bind Interrupt Handlers */
static void PIOS_EXTI_0_irq_handler (void) static void PIOS_EXTI_0_irq_handler (void)
{ {
#ifdef PIOS_INCLUDE_FREERTOS
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
#endif
PIOS_EXTI_HANDLE_LINE(0); PIOS_EXTI_HANDLE_LINE(0);
#ifdef PIOS_INCLUDE_FREERTOS
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
#endif
} }
void EXTI0_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_0_irq_handler"))); void EXTI0_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_0_irq_handler")));
static void PIOS_EXTI_1_irq_handler (void) static void PIOS_EXTI_1_irq_handler (void)
{ {
#ifdef PIOS_INCLUDE_FREERTOS
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
#endif
PIOS_EXTI_HANDLE_LINE(1); PIOS_EXTI_HANDLE_LINE(1);
#ifdef PIOS_INCLUDE_FREERTOS
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
#endif
} }
void EXTI1_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_1_irq_handler"))); void EXTI1_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_1_irq_handler")));
static void PIOS_EXTI_2_irq_handler (void) static void PIOS_EXTI_2_irq_handler (void)
{ {
#ifdef PIOS_INCLUDE_FREERTOS
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
#endif
PIOS_EXTI_HANDLE_LINE(2); PIOS_EXTI_HANDLE_LINE(2);
#ifdef PIOS_INCLUDE_FREERTOS
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
#endif
} }
void EXTI2_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_2_irq_handler"))); void EXTI2_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_2_irq_handler")));
static void PIOS_EXTI_3_irq_handler (void) static void PIOS_EXTI_3_irq_handler (void)
{ {
#ifdef PIOS_INCLUDE_FREERTOS
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
#endif
PIOS_EXTI_HANDLE_LINE(3); PIOS_EXTI_HANDLE_LINE(3);
#ifdef PIOS_INCLUDE_FREERTOS
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
#endif
} }
void EXTI3_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_3_irq_handler"))); void EXTI3_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_3_irq_handler")));
static void PIOS_EXTI_4_irq_handler (void) static void PIOS_EXTI_4_irq_handler (void)
{ {
#ifdef PIOS_INCLUDE_FREERTOS
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
#endif
PIOS_EXTI_HANDLE_LINE(4); PIOS_EXTI_HANDLE_LINE(4);
#ifdef PIOS_INCLUDE_FREERTOS
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
#endif
} }
void EXTI4_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_4_irq_handler"))); void EXTI4_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_4_irq_handler")));
static void PIOS_EXTI_9_5_irq_handler (void) static void PIOS_EXTI_9_5_irq_handler (void)
{ {
#ifdef PIOS_INCLUDE_FREERTOS
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
#endif
PIOS_EXTI_HANDLE_LINE(5); PIOS_EXTI_HANDLE_LINE(5);
PIOS_EXTI_HANDLE_LINE(6); PIOS_EXTI_HANDLE_LINE(6);
PIOS_EXTI_HANDLE_LINE(7); PIOS_EXTI_HANDLE_LINE(7);
PIOS_EXTI_HANDLE_LINE(8); PIOS_EXTI_HANDLE_LINE(8);
PIOS_EXTI_HANDLE_LINE(9); PIOS_EXTI_HANDLE_LINE(9);
#ifdef PIOS_INCLUDE_FREERTOS
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
#endif
} }
void EXTI9_5_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_9_5_irq_handler"))); void EXTI9_5_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_9_5_irq_handler")));
static void PIOS_EXTI_15_10_irq_handler (void) static void PIOS_EXTI_15_10_irq_handler (void)
{ {
#ifdef PIOS_INCLUDE_FREERTOS
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
#endif
PIOS_EXTI_HANDLE_LINE(10); PIOS_EXTI_HANDLE_LINE(10);
PIOS_EXTI_HANDLE_LINE(11); PIOS_EXTI_HANDLE_LINE(11);
PIOS_EXTI_HANDLE_LINE(12); PIOS_EXTI_HANDLE_LINE(12);
PIOS_EXTI_HANDLE_LINE(13); PIOS_EXTI_HANDLE_LINE(13);
PIOS_EXTI_HANDLE_LINE(14); PIOS_EXTI_HANDLE_LINE(14);
PIOS_EXTI_HANDLE_LINE(15); PIOS_EXTI_HANDLE_LINE(15);
#ifdef PIOS_INCLUDE_FREERTOS
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
#endif
} }
void EXTI15_10_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_15_10_irq_handler"))); void EXTI15_10_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_15_10_irq_handler")));

View File

@ -149,7 +149,7 @@ out_fail:
return -1; return -1;
} }
static void PIOS_EXTI_generic_irq_handler(uint8_t line_index) static bool PIOS_EXTI_generic_irq_handler(uint8_t line_index)
{ {
uint8_t cfg_index = pios_exti_line_to_cfg_map[line_index]; uint8_t cfg_index = pios_exti_line_to_cfg_map[line_index];
@ -158,69 +158,119 @@ static void PIOS_EXTI_generic_irq_handler(uint8_t line_index)
if (cfg_index > NELEMENTS(pios_exti_line_to_cfg_map) || if (cfg_index > NELEMENTS(pios_exti_line_to_cfg_map) ||
cfg_index == PIOS_EXTI_INVALID) { cfg_index == PIOS_EXTI_INVALID) {
/* Unconfigured interrupt just fired! */ /* Unconfigured interrupt just fired! */
return; return false;
} }
struct pios_exti_cfg * cfg = &__start__exti + cfg_index; struct pios_exti_cfg * cfg = &__start__exti + cfg_index;
cfg->vector(); return cfg->vector();
} }
/* Bind Interrupt Handlers */ /* Bind Interrupt Handlers */
#ifdef PIOS_INCLUDE_FREERTOS
#define PIOS_EXTI_HANDLE_LINE(line) \
if (EXTI_GetITStatus(EXTI_Line##line) != RESET) { \
EXTI_ClearITPendingBit(EXTI_Line##line); \
xHigherPriorityTaskWoken |= PIOS_EXTI_generic_irq_handler(line); \
}
#else
#define PIOS_EXTI_HANDLE_LINE(line) \ #define PIOS_EXTI_HANDLE_LINE(line) \
if (EXTI_GetITStatus(EXTI_Line##line) != RESET) { \ if (EXTI_GetITStatus(EXTI_Line##line) != RESET) { \
EXTI_ClearITPendingBit(EXTI_Line##line); \ EXTI_ClearITPendingBit(EXTI_Line##line); \
PIOS_EXTI_generic_irq_handler(line); \ PIOS_EXTI_generic_irq_handler(line); \
} }
#endif
static void PIOS_EXTI_0_irq_handler (void) static void PIOS_EXTI_0_irq_handler (void)
{ {
#ifdef PIOS_INCLUDE_FREERTOS
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
#endif
PIOS_EXTI_HANDLE_LINE(0); PIOS_EXTI_HANDLE_LINE(0);
#ifdef PIOS_INCLUDE_FREERTOS
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
#endif
} }
void EXTI0_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_0_irq_handler"))); void EXTI0_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_0_irq_handler")));
static void PIOS_EXTI_1_irq_handler (void) static void PIOS_EXTI_1_irq_handler (void)
{ {
#ifdef PIOS_INCLUDE_FREERTOS
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
#endif
PIOS_EXTI_HANDLE_LINE(1); PIOS_EXTI_HANDLE_LINE(1);
#ifdef PIOS_INCLUDE_FREERTOS
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
#endif
} }
void EXTI1_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_1_irq_handler"))); void EXTI1_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_1_irq_handler")));
static void PIOS_EXTI_2_irq_handler (void) static void PIOS_EXTI_2_irq_handler (void)
{ {
#ifdef PIOS_INCLUDE_FREERTOS
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
#endif
PIOS_EXTI_HANDLE_LINE(2); PIOS_EXTI_HANDLE_LINE(2);
#ifdef PIOS_INCLUDE_FREERTOS
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
#endif
} }
void EXTI2_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_2_irq_handler"))); void EXTI2_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_2_irq_handler")));
static void PIOS_EXTI_3_irq_handler (void) static void PIOS_EXTI_3_irq_handler (void)
{ {
#ifdef PIOS_INCLUDE_FREERTOS
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
#endif
PIOS_EXTI_HANDLE_LINE(3); PIOS_EXTI_HANDLE_LINE(3);
#ifdef PIOS_INCLUDE_FREERTOS
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
#endif
} }
void EXTI3_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_3_irq_handler"))); void EXTI3_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_3_irq_handler")));
static void PIOS_EXTI_4_irq_handler (void) static void PIOS_EXTI_4_irq_handler (void)
{ {
#ifdef PIOS_INCLUDE_FREERTOS
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
#endif
PIOS_EXTI_HANDLE_LINE(4); PIOS_EXTI_HANDLE_LINE(4);
#ifdef PIOS_INCLUDE_FREERTOS
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
#endif
} }
void EXTI4_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_4_irq_handler"))); void EXTI4_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_4_irq_handler")));
static void PIOS_EXTI_9_5_irq_handler (void) static void PIOS_EXTI_9_5_irq_handler (void)
{ {
#ifdef PIOS_INCLUDE_FREERTOS
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
#endif
PIOS_EXTI_HANDLE_LINE(5); PIOS_EXTI_HANDLE_LINE(5);
PIOS_EXTI_HANDLE_LINE(6); PIOS_EXTI_HANDLE_LINE(6);
PIOS_EXTI_HANDLE_LINE(7); PIOS_EXTI_HANDLE_LINE(7);
PIOS_EXTI_HANDLE_LINE(8); PIOS_EXTI_HANDLE_LINE(8);
PIOS_EXTI_HANDLE_LINE(9); PIOS_EXTI_HANDLE_LINE(9);
#ifdef PIOS_INCLUDE_FREERTOS
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
#endif
} }
void EXTI9_5_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_9_5_irq_handler"))); void EXTI9_5_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_9_5_irq_handler")));
static void PIOS_EXTI_15_10_irq_handler (void) static void PIOS_EXTI_15_10_irq_handler (void)
{ {
#ifdef PIOS_INCLUDE_FREERTOS
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
#endif
PIOS_EXTI_HANDLE_LINE(10); PIOS_EXTI_HANDLE_LINE(10);
PIOS_EXTI_HANDLE_LINE(11); PIOS_EXTI_HANDLE_LINE(11);
PIOS_EXTI_HANDLE_LINE(12); PIOS_EXTI_HANDLE_LINE(12);
PIOS_EXTI_HANDLE_LINE(13); PIOS_EXTI_HANDLE_LINE(13);
PIOS_EXTI_HANDLE_LINE(14); PIOS_EXTI_HANDLE_LINE(14);
PIOS_EXTI_HANDLE_LINE(15); PIOS_EXTI_HANDLE_LINE(15);
#ifdef PIOS_INCLUDE_FREERTOS
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
#endif
} }
void EXTI15_10_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_15_10_irq_handler"))); void EXTI15_10_IRQHandler(void) __attribute__ ((alias ("PIOS_EXTI_15_10_irq_handler")));

View File

@ -103,7 +103,7 @@ extern float PIOS_BMA180_GetScale();
extern int32_t PIOS_BMA180_ReadFifo(struct pios_bma180_data * buffer); extern int32_t PIOS_BMA180_ReadFifo(struct pios_bma180_data * buffer);
extern int32_t PIOS_BMA180_ReadAccels(struct pios_bma180_data * data); extern int32_t PIOS_BMA180_ReadAccels(struct pios_bma180_data * data);
extern int32_t PIOS_BMA180_Test(); extern int32_t PIOS_BMA180_Test();
extern void PIOS_BMA180_IRQHandler(); extern bool PIOS_BMA180_IRQHandler();
#endif /* PIOS_BMA180_H */ #endif /* PIOS_BMA180_H */

View File

@ -36,7 +36,7 @@
#include <pios_stm32.h> #include <pios_stm32.h>
struct pios_exti_cfg { struct pios_exti_cfg {
void (* vector)(void); bool (* vector)(void);
uint32_t line; /* use EXTI_LineN macros */ uint32_t line; /* use EXTI_LineN macros */
struct stm32_gpio pin; struct stm32_gpio pin;
struct stm32_irq irq; struct stm32_irq irq;

View File

@ -107,7 +107,7 @@ extern bool PIOS_HMC5883_NewDataAvailable(void);
extern int32_t PIOS_HMC5883_ReadMag(int16_t out[3]); extern int32_t PIOS_HMC5883_ReadMag(int16_t out[3]);
extern uint8_t PIOS_HMC5883_ReadID(uint8_t out[4]); extern uint8_t PIOS_HMC5883_ReadID(uint8_t out[4]);
extern int32_t PIOS_HMC5883_Test(void); extern int32_t PIOS_HMC5883_Test(void);
extern void PIOS_HMC5883_IRQHandler(); bool void PIOS_HMC5883_IRQHandler();
#endif /* PIOS_HMC5883_H */ #endif /* PIOS_HMC5883_H */
/** /**

View File

@ -141,7 +141,7 @@ extern int32_t PIOS_L3GD20_SetRange(enum pios_l3gd20_range range);
extern float PIOS_L3GD20_GetScale(); extern float PIOS_L3GD20_GetScale();
extern int32_t PIOS_L3GD20_ReadID(); extern int32_t PIOS_L3GD20_ReadID();
extern uint8_t PIOS_L3GD20_Test(); extern uint8_t PIOS_L3GD20_Test();
extern void PIOS_L3GD20_IRQHandler(); bool void PIOS_L3GD20_IRQHandler();
#endif /* PIOS_L3GD20_H */ #endif /* PIOS_L3GD20_H */

View File

@ -156,7 +156,7 @@ extern int32_t PIOS_MPU6000_ReadID();
extern uint8_t PIOS_MPU6000_Test(); extern uint8_t PIOS_MPU6000_Test();
extern float PIOS_MPU6000_GetScale(); extern float PIOS_MPU6000_GetScale();
extern float PIOS_MPU6000_GetAccelScale(); extern float PIOS_MPU6000_GetAccelScale();
extern void PIOS_MPU6000_IRQHandler(void); extern bool PIOS_MPU6000_IRQHandler(void);
#endif /* PIOS_MPU6000_H */ #endif /* PIOS_MPU6000_H */