1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-15 07:29:15 +01:00

Fix the EXTI IRQ handlers

This commit is contained in:
James Cotton 2011-08-13 07:13:21 -05:00
parent e1f7a5003d
commit f82e5dde33
7 changed files with 40 additions and 19 deletions

View File

@ -47,6 +47,7 @@ volatile bool pios_bma180_data_ready = false;
static int16_t pios_bma180_buffer[PIOS_BMA180_MAX_DOWNSAMPLE * 3];
static t_fifo_buffer pios_bma180_fifo;
static const struct pios_bma180_cfg * dev_cfg;
/**
* @brief Initialize with good default settings
@ -72,6 +73,8 @@ void PIOS_BMA180_Init(const struct pios_bma180_cfg * cfg)
PIOS_BMA180_SetRange(BMA_RANGE_8G);
PIOS_DELAY_WaituS(50);
PIOS_BMA180_EnableIrq();
dev_cfg = cfg;
}
/**

View File

@ -63,6 +63,7 @@ static int32_t PIOS_BMP085_Write(uint8_t address, uint8_t buffer);
// Move into proper driver structure with cfg stored
static uint32_t oversampling;
const struct pios_bmp085_cfg * dev_cfg;
/**
* Initialise the BMP085 sensor
@ -89,6 +90,7 @@ void PIOS_BMP085_Init(const struct pios_bmp085_cfg * cfg)
NVIC_Init(&cfg->eoc_irq.init);
oversampling = cfg->oversampling;
dev_cfg = cfg;
/* Configure anothing GPIO pin pin as input floating */
/* WHAT DID THIS DO?
@ -294,16 +296,16 @@ int32_t PIOS_BMP085_Test()
/**
* Handle external lines 15 to 10 interrupt requests
*/
//void EXTI15_10_IRQHandler(void)
//{
// if (EXTI_GetITStatus(EXTI15_10) != RESET) {
// /* Read the ADC Value */
// PIOS_BMP085_EOC=1;
//
// /* Clear the EXTI line pending bit */
// EXTI_ClearITPendingBit(EXTI15_10);
// }
//}
void EXTI15_10_IRQHandler(void)
{
if (EXTI_GetITStatus(dev_cfg->eoc_exti.init.EXTI_Line) != RESET) {
/* Read the ADC Value */
PIOS_BMP085_EOC=1;
/* Clear the EXTI line pending bit */
EXTI_ClearITPendingBit(dev_cfg->eoc_exti.init.EXTI_Line);
}
}
#endif

View File

@ -52,6 +52,8 @@ static void PIOS_HMC5883_Config(PIOS_HMC5883_ConfigTypeDef * HMC5883_Config_Stru
static bool PIOS_HMC5883_Read(uint8_t address, uint8_t * buffer, uint8_t len);
static bool PIOS_HMC5883_Write(uint8_t address, uint8_t buffer);
static const struct pios_hmc5883_cfg * dev_cfg;
/**
* @brief Initialize the HMC5883 magnetometer sensor.
* @return none
@ -77,6 +79,8 @@ void PIOS_HMC5883_Init(const struct pios_hmc5883_cfg * cfg)
PIOS_HMC5883_Config(&HMC5883_InitStructure);
pios_hmc5883_data_ready = false;
dev_cfg = cfg;
}
/**
@ -163,9 +167,9 @@ static void PIOS_HMC5883_Config(PIOS_HMC5883_ConfigTypeDef * HMC5883_Config_Stru
* \param[out] int16_t array of size 3 to store X, Z, and Y magnetometer readings
* \return none
*/
uint8_t buffer[6];
void PIOS_HMC5883_ReadMag(int16_t out[3])
{
uint8_t buffer[6];
uint8_t ctrlB;
pios_hmc5883_data_ready = false;
@ -226,12 +230,13 @@ void PIOS_HMC5883_ReadMag(int16_t out[3])
/**
* @brief Read the identification bytes from the HMC5883 sensor
* \param[out] uint8_t array of size 4 to store HMC5883 ID.
* \return none
* \return 0 if successful, -1 if not
*/
void PIOS_HMC5883_ReadID(uint8_t out[4])
uint8_t PIOS_HMC5883_ReadID(uint8_t out[4])
{
while (!PIOS_HMC5883_Read(PIOS_HMC5883_DATAOUT_IDA_REG, out, 3)) ;
uint8_t retval = PIOS_HMC5883_Read(PIOS_HMC5883_DATAOUT_IDA_REG, out, 3);
out[3] = '\0';
return retval;
}
/**
@ -321,6 +326,7 @@ int32_t PIOS_HMC5883_Test(void)
return -1;
return 0;
int32_t passed = 1;
uint8_t registers[3] = {0,0,0};
@ -376,11 +382,15 @@ void PIOS_HMC5883_IRQHandler(void)
* Soon this will be generic in pios_exti and the BMA180 will register
* against it. Right now this is crap!
*/
uint32_t count = 0;
uint32_t count2 = 0;
void EXTI9_5_IRQHandler(void)
{
if (EXTI_GetITStatus(EXTI9_5_IRQn) != RESET) {
count++;
if (EXTI_GetITStatus(dev_cfg->eoc_exti.init.EXTI_Line) != RESET) {
count2++;
PIOS_HMC5883_IRQHandler();
EXTI_ClearITPendingBit(EXTI9_5_IRQn);
EXTI_ClearITPendingBit(dev_cfg->eoc_exti.init.EXTI_Line);
}
}

View File

@ -907,8 +907,11 @@ out_fail:
return(-1);
}
uint32_t transfers = 0;
uint32_t transfers_successful = 0;
bool PIOS_I2C_Transfer(uint32_t i2c_id, const struct pios_i2c_txn txn_list[], uint32_t num_txns)
{
transfers++;
struct pios_i2c_adapter * i2c_adapter = (struct pios_i2c_adapter *)i2c_id;
bool valid = PIOS_I2C_validate(i2c_adapter);
@ -962,6 +965,7 @@ bool PIOS_I2C_Transfer(uint32_t i2c_id, const struct pios_i2c_txn txn_list[], ui
i2c_timeout_counter++;
#endif /* USE_FREERTOS */
transfers_successful+= (!i2c_adapter->bus_error) && semaphore_success;
return (!i2c_adapter->bus_error) && semaphore_success;
}

View File

@ -52,6 +52,7 @@ typedef struct {
static void PIOS_IMU3000_Config(PIOS_IMU3000_ConfigTypeDef * IMU3000_Config_Struct);
static int32_t PIOS_IMU3000_Read(uint8_t address, uint8_t * buffer, uint8_t len);
static int32_t PIOS_IMU3000_Write(uint8_t address, uint8_t buffer);
int32_t imu3000_id = 0;
/**
* @brief Initialize the IMU3000 3-axis gyro sensor.
@ -134,8 +135,9 @@ int32_t PIOS_IMU3000_ReadGyros(int16_t * data)
int32_t PIOS_IMU3000_ReadID()
{
uint8_t id;
if(PIOS_IMU3000_Read(0x00, &id, 1) != 0)
if(PIOS_IMU3000_Read(0x00, (uint8_t *) &imu3000_id, 1) != 0)
return -1;
id = imu3000_id;
return id;
}

View File

@ -103,7 +103,7 @@ struct pios_hmc5883_cfg {
extern void PIOS_HMC5883_Init(const struct pios_hmc5883_cfg * cfg);
extern bool PIOS_HMC5883_NewDataAvailable(void);
extern void PIOS_HMC5883_ReadMag(int16_t out[3]);
extern void PIOS_HMC5883_ReadID(uint8_t out[4]);
extern uint8_t PIOS_HMC5883_ReadID(uint8_t out[4]);
extern int32_t PIOS_HMC5883_Test(void);
#endif /* PIOS_HMC5883_H */

View File

@ -49,7 +49,7 @@ struct pios_i2c_txn {
uint8_t *buf;
};
#define I2C_LOG_DEPTH 5
#define I2C_LOG_DEPTH 20
enum pios_i2c_error_type {
PIOS_I2C_ERROR_EVENT,
PIOS_I2C_ERROR_FSM,