mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
Update the F4 copyright headers to 2012
This commit is contained in:
parent
25dfb5463e
commit
0da6109871
@ -7,7 +7,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file pios_bma180.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011.
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief PiOS BMA180 digital accelerometer driver.
|
||||
* - Driver for the BMA180 digital accelerometer on the SPI bus.
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
|
@ -1,17 +1,17 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_BMP085 BMP085 Functions
|
||||
* @brief Hardware functions to deal with the altitude pressure sensor
|
||||
* @{
|
||||
*
|
||||
* @file pios_bmp085.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief BMP085 Pressure Sensor Routines
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
******************************************************************************/
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_BMP085 BMP085 Functions
|
||||
* @brief Hardware functions to deal with the altitude pressure sensor
|
||||
* @{
|
||||
*
|
||||
* @file pios_bmp085.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief BMP085 Pressure Sensor Routines
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
******************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -7,7 +7,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file pios_debug.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief Debugging Functions
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
|
@ -7,7 +7,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file pios_delay.c
|
||||
* @author Michael Smith Copyright (C) 2011
|
||||
* @author Michael Smith Copyright (C) 2012
|
||||
* @brief Delay Functions
|
||||
* - Provides a micro-second granular delay using the CPU
|
||||
* cycle counter.
|
||||
|
@ -7,7 +7,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file pios_dsm.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011.
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief Code bind and read Spektrum/JR DSMx satellite receiver serial stream
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
|
@ -1,6 +1,5 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_EXTI External Interrupt Handlers
|
||||
@ -9,7 +8,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file pios_exti.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief External Interrupt Handlers
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
|
@ -7,7 +7,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file pios_gpio.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief GPIO functions, init, toggle, on & off.
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
|
@ -5,9 +5,8 @@
|
||||
* @addtogroup PIOS_HMC5883 HMC5883 Functions
|
||||
* @brief Deals with the hardware interface to the magnetometers
|
||||
* @{
|
||||
*
|
||||
* @file pios_hmc5883.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011.
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief HMC5883 Magnetic Sensor Functions from AHRS
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
|
@ -3,12 +3,11 @@
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_I2C I2C Functions
|
||||
* @brief STM32F2xx Hardware dependent I2C functionality
|
||||
* @brief STM32F4xx Hardware dependent I2C functionality
|
||||
* @{
|
||||
*
|
||||
* @file pios_i2c.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Thorsten Klose (tk@midibox.org) (tk@midibox.org)
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief I2C Enable/Disable routines
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
|
@ -1,12 +1,33 @@
|
||||
/*!
|
||||
* @File iap.c
|
||||
* @Brief
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_IAP IAP Functions
|
||||
* @brief STM32F4xx Hardware dependent I2C functionality
|
||||
* @{
|
||||
*
|
||||
* Created on: Sep 6, 2010
|
||||
* Author: joe
|
||||
* @file pios_iap.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief In application programming functions
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
* Header files
|
||||
****************************************************************************************/
|
||||
@ -131,3 +152,8 @@ void PIOS_IAP_ClearRequest(void)
|
||||
BKP_WriteBackupRegister( MAGIC_REG_2, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
@ -1,397 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_IMU3000 IMU3000 Functions
|
||||
* @brief Deals with the hardware interface to the 3-axis gyro
|
||||
* @{
|
||||
*
|
||||
* @file pios_IMU3000.c
|
||||
* @author David "Buzz" Carlson (buzz@chebuzz.com)
|
||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011.
|
||||
* @brief IMU3000 3-axis gyor functions from INS
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Project Includes */
|
||||
#include "pios.h"
|
||||
|
||||
#if defined(PIOS_INCLUDE_IMU3000)
|
||||
|
||||
/* Global Variables */
|
||||
|
||||
/* Local Variables */
|
||||
#define DEG_TO_RAD (M_PI / 180.0)
|
||||
static void PIOS_IMU3000_Config(struct pios_imu3000_cfg const * cfg);
|
||||
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);
|
||||
|
||||
#define PIOS_IMU3000_MAX_DOWNSAMPLE 10
|
||||
static int16_t pios_imu3000_buffer[PIOS_IMU3000_MAX_DOWNSAMPLE * sizeof(struct pios_imu3000_data)];
|
||||
static t_fifo_buffer pios_imu3000_fifo;
|
||||
|
||||
volatile bool imu3000_first_read = true;
|
||||
volatile bool imu3000_configured = false;
|
||||
volatile bool imu3000_cb_ready = true;
|
||||
|
||||
static struct pios_imu3000_cfg const * cfg;
|
||||
|
||||
/**
|
||||
* @brief Initialize the IMU3000 3-axis gyro sensor.
|
||||
* @return none
|
||||
*/
|
||||
void PIOS_IMU3000_Init(const struct pios_imu3000_cfg * new_cfg)
|
||||
{
|
||||
cfg = new_cfg;
|
||||
|
||||
fifoBuf_init(&pios_imu3000_fifo, (uint8_t *) pios_imu3000_buffer, sizeof(pios_imu3000_buffer));
|
||||
|
||||
/* Configure EOC pin as input floating */
|
||||
GPIO_Init(cfg->drdy.gpio, &cfg->drdy.init);
|
||||
|
||||
/* Configure the End Of Conversion (EOC) interrupt */
|
||||
SYSCFG_EXTILineConfig(cfg->eoc_exti.port_source, cfg->eoc_exti.pin_source);
|
||||
EXTI_Init(&cfg->eoc_exti.init);
|
||||
|
||||
/* Enable and set EOC EXTI Interrupt to the lowest priority */
|
||||
NVIC_Init(&cfg->eoc_irq.init);
|
||||
|
||||
/* Configure the IMU3000 Sensor */
|
||||
PIOS_IMU3000_Config(cfg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize the IMU3000 3-axis gyro sensor
|
||||
* \return none
|
||||
* \param[in] PIOS_IMU3000_ConfigTypeDef struct to be used to configure sensor.
|
||||
*
|
||||
*/
|
||||
static void PIOS_IMU3000_Config(struct pios_imu3000_cfg const * cfg)
|
||||
{
|
||||
imu3000_first_read = true;
|
||||
imu3000_cb_ready = true;
|
||||
|
||||
// Reset chip and fifo
|
||||
while (PIOS_IMU3000_Write(PIOS_IMU3000_USER_CTRL_REG, 0x01 | 0x02) != 0);
|
||||
PIOS_DELAY_WaituS(20);
|
||||
while (PIOS_IMU3000_Write(PIOS_IMU3000_USER_CTRL_REG, 0x00) != 0);
|
||||
|
||||
// FIFO storage
|
||||
while (PIOS_IMU3000_Write(PIOS_IMU3000_FIFO_EN_REG, cfg->Fifo_store) != 0);
|
||||
|
||||
// Sample rate divider
|
||||
while (PIOS_IMU3000_Write(PIOS_IMU3000_SMPLRT_DIV_REG, cfg->Smpl_rate_div) != 0) ;
|
||||
|
||||
// Digital low-pass filter and scale
|
||||
while (PIOS_IMU3000_Write(PIOS_IMU3000_DLPF_CFG_REG, cfg->filter | (cfg->range << 3)) != 0) ;
|
||||
|
||||
// Interrupt configuration
|
||||
while (PIOS_IMU3000_Write(PIOS_IMU3000_USER_CTRL_REG, cfg->User_ctl) != 0) ;
|
||||
|
||||
// Interrupt configuration
|
||||
while (PIOS_IMU3000_Write(PIOS_IMU3000_PWR_MGMT_REG, cfg->Pwr_mgmt_clk) != 0) ;
|
||||
|
||||
// Interrupt configuration
|
||||
while (PIOS_IMU3000_Write(PIOS_IMU3000_INT_CFG_REG, cfg->Interrupt_cfg) != 0) ;
|
||||
|
||||
imu3000_configured = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read current X, Z, Y values (in that order)
|
||||
* \param[out] int16_t array of size 3 to store X, Z, and Y magnetometer readings
|
||||
* \returns The number of samples remaining in the fifo
|
||||
*/
|
||||
int32_t PIOS_IMU3000_ReadGyros(struct pios_imu3000_data * data)
|
||||
{
|
||||
uint8_t buf[6];
|
||||
if(PIOS_IMU3000_Read(PIOS_IMU3000_GYRO_X_OUT_MSB, (uint8_t *) buf, sizeof(buf)) < 0)
|
||||
return -1;
|
||||
data->x = buf[0] << 8 | buf[1];
|
||||
data->y = buf[2] << 8 | buf[3];
|
||||
data->z = buf[4] << 8 | buf[5];
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Read the identification bytes from the IMU3000 sensor
|
||||
* \return ID read from IMU3000 or -1 if failure
|
||||
*/
|
||||
int32_t PIOS_IMU3000_ReadID()
|
||||
{
|
||||
uint8_t imu3000_id;
|
||||
if(PIOS_IMU3000_Read(0x00, (uint8_t *) &imu3000_id, 1) != 0)
|
||||
return -1;
|
||||
return imu3000_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Reads the data from the IMU3000 FIFO
|
||||
* \param[out] buffer destination buffer
|
||||
* \param[in] len maximum number of bytes which should be read
|
||||
* \note This returns the data as X, Y, Z the temperature
|
||||
* \return number of bytes transferred if operation was successful
|
||||
* \return -1 if error during I2C transfer
|
||||
*/
|
||||
int32_t PIOS_IMU3000_ReadFifo(struct pios_imu3000_data * buffer)
|
||||
{
|
||||
if(fifoBuf_getUsed(&pios_imu3000_fifo) < sizeof(*buffer))
|
||||
return -1;
|
||||
|
||||
fifoBuf_getData(&pios_imu3000_fifo, (uint8_t *) buffer, sizeof(*buffer));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads one or more bytes from IMU3000 into a buffer
|
||||
* \param[in] address IMU3000 register address (depends on size)
|
||||
* \param[out] buffer destination buffer
|
||||
* \param[in] len number of bytes which should be read
|
||||
* \return 0 if operation was successful
|
||||
* \return -1 if error during I2C transfer
|
||||
* \return -2 if unable to claim i2c device
|
||||
*/
|
||||
static int32_t PIOS_IMU3000_Read(uint8_t address, uint8_t * buffer, uint8_t len)
|
||||
{
|
||||
uint8_t addr_buffer[] = {
|
||||
address,
|
||||
};
|
||||
|
||||
const struct pios_i2c_txn txn_list[] = {
|
||||
{
|
||||
.info = __func__,
|
||||
.addr = PIOS_IMU3000_I2C_ADDR,
|
||||
.rw = PIOS_I2C_TXN_WRITE,
|
||||
.len = sizeof(addr_buffer),
|
||||
.buf = addr_buffer,
|
||||
}
|
||||
,
|
||||
{
|
||||
.info = __func__,
|
||||
.addr = PIOS_IMU3000_I2C_ADDR,
|
||||
.rw = PIOS_I2C_TXN_READ,
|
||||
.len = len,
|
||||
.buf = buffer,
|
||||
}
|
||||
};
|
||||
|
||||
return PIOS_I2C_Transfer(PIOS_I2C_GYRO_ADAPTER, txn_list, NELEMENTS(txn_list));
|
||||
}
|
||||
|
||||
// Must allocate on stack to be persistent
|
||||
static uint8_t cb_addr_buffer[] = {
|
||||
0,
|
||||
};
|
||||
static struct pios_i2c_txn cb_txn_list[] = {
|
||||
{
|
||||
.addr = PIOS_IMU3000_I2C_ADDR,
|
||||
.rw = PIOS_I2C_TXN_WRITE,
|
||||
.len = sizeof(cb_addr_buffer),
|
||||
.buf = cb_addr_buffer,
|
||||
}
|
||||
,
|
||||
{
|
||||
.addr = PIOS_IMU3000_I2C_ADDR,
|
||||
.rw = PIOS_I2C_TXN_READ,
|
||||
.len = 0,
|
||||
.buf = 0,
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
static int32_t PIOS_IMU3000_Read_Callback(uint8_t address, uint8_t * buffer, uint8_t len, void *callback)
|
||||
{
|
||||
cb_addr_buffer[0] = address;
|
||||
cb_txn_list[0].info = __func__,
|
||||
cb_txn_list[1].info = __func__;
|
||||
cb_txn_list[1].len = len;
|
||||
cb_txn_list[1].buf = buffer;
|
||||
|
||||
return PIOS_I2C_Transfer_Callback(PIOS_I2C_GYRO_ADAPTER, cb_txn_list, NELEMENTS(cb_txn_list), callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes one or more bytes to the IMU3000
|
||||
* \param[in] address Register address
|
||||
* \param[in] buffer source buffer
|
||||
* \return 0 if operation was successful
|
||||
* \return -1 if error during I2C transfer
|
||||
* \return -2 if unable to claim i2c device
|
||||
*/
|
||||
static int32_t PIOS_IMU3000_Write(uint8_t address, uint8_t buffer)
|
||||
{
|
||||
uint8_t data[] = {
|
||||
address,
|
||||
buffer,
|
||||
};
|
||||
|
||||
const struct pios_i2c_txn txn_list[] = {
|
||||
{
|
||||
.info = __func__,
|
||||
.addr = PIOS_IMU3000_I2C_ADDR,
|
||||
.rw = PIOS_I2C_TXN_WRITE,
|
||||
.len = sizeof(data),
|
||||
.buf = data,
|
||||
}
|
||||
,
|
||||
};
|
||||
|
||||
return PIOS_I2C_Transfer(PIOS_I2C_GYRO_ADAPTER, txn_list, NELEMENTS(txn_list));
|
||||
}
|
||||
|
||||
float PIOS_IMU3000_GetScale()
|
||||
{
|
||||
switch (cfg->range) {
|
||||
case PIOS_IMU3000_SCALE_250_DEG:
|
||||
return DEG_TO_RAD / 131.0;
|
||||
case PIOS_IMU3000_SCALE_500_DEG:
|
||||
return DEG_TO_RAD / 65.5;
|
||||
case PIOS_IMU3000_SCALE_1000_DEG:
|
||||
return DEG_TO_RAD / 32.8;
|
||||
case PIOS_IMU3000_SCALE_2000_DEG:
|
||||
return DEG_TO_RAD / 16.4;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* @brief Run self-test operation.
|
||||
* \return 0 if test succeeded
|
||||
* \return non-zero value if test succeeded
|
||||
*/
|
||||
uint8_t PIOS_IMU3000_Test(void)
|
||||
{
|
||||
/* Verify that ID matches (IMU3000 ID is 0x69) */
|
||||
int32_t imu3000_id = PIOS_IMU3000_ReadID();
|
||||
if(imu3000_id < 0)
|
||||
return -1;
|
||||
|
||||
if(imu3000_id != PIOS_IMU3000_I2C_ADDR)
|
||||
return -2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t imu3000_read_buffer[sizeof(struct pios_imu3000_data) + 2]; // Right now using ,Y,Z,fifo_footer
|
||||
static void imu3000_callback()
|
||||
{
|
||||
struct pios_imu3000_data data;
|
||||
|
||||
if(fifoBuf_getFree(&pios_imu3000_fifo) < sizeof(data))
|
||||
goto out;
|
||||
|
||||
if(imu3000_first_read) {
|
||||
data.temperature = imu3000_read_buffer[0] << 8 | imu3000_read_buffer[1];
|
||||
data.x = imu3000_read_buffer[2] << 8 | imu3000_read_buffer[3];
|
||||
data.y = imu3000_read_buffer[4] << 8 | imu3000_read_buffer[5];
|
||||
data.z = imu3000_read_buffer[6] << 8 | imu3000_read_buffer[7];
|
||||
|
||||
imu3000_first_read = false;
|
||||
} else {
|
||||
// First two bytes are left over fifo from last call
|
||||
data.temperature = imu3000_read_buffer[2] << 8 | imu3000_read_buffer[3];
|
||||
data.x = imu3000_read_buffer[4] << 8 | imu3000_read_buffer[5];
|
||||
data.y = imu3000_read_buffer[6] << 8 | imu3000_read_buffer[7];
|
||||
data.z = imu3000_read_buffer[8] << 8 | imu3000_read_buffer[9];
|
||||
}
|
||||
|
||||
fifoBuf_putData(&pios_imu3000_fifo, (uint8_t *) &data, sizeof(data));
|
||||
|
||||
out:
|
||||
imu3000_cb_ready = true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief IRQ Handler
|
||||
*/
|
||||
uint32_t imu3000_irq = 0;
|
||||
uint16_t fifo_level;
|
||||
uint8_t fifo_level_data[2];
|
||||
uint32_t cb_not_ready = 0;
|
||||
void PIOS_IMU3000_IRQHandler(void)
|
||||
{
|
||||
|
||||
imu3000_irq++;
|
||||
|
||||
if(!imu3000_configured)
|
||||
return;
|
||||
|
||||
//PIOS_Assert(imu3000_cb_ready);
|
||||
if(!imu3000_cb_ready) {
|
||||
PIOS_LED_Toggle(LED2);
|
||||
cb_not_ready++;
|
||||
return;
|
||||
}
|
||||
|
||||
// If at least one read doesnt succeed then the irq not reset and we will stall
|
||||
while(PIOS_IMU3000_Read(PIOS_IMU3000_FIFO_CNT_MSB, (uint8_t *) &fifo_level_data, sizeof(fifo_level_data)) != 0)
|
||||
PIOS_DELAY_WaituS(10);
|
||||
|
||||
fifo_level = (fifo_level_data[0] << 8) + fifo_level_data[1];
|
||||
|
||||
PIOS_DELAY_WaituS(10);
|
||||
|
||||
if(imu3000_first_read) {
|
||||
// Stupid system for IMU3000. If first read from buffer then we will read 4 sensors without fifo
|
||||
// footer. After this we will read out a fifo footer
|
||||
if(fifo_level < sizeof(imu3000_read_buffer))
|
||||
return;
|
||||
|
||||
imu3000_cb_ready = false;
|
||||
|
||||
// Leave footer in buffer
|
||||
PIOS_IMU3000_Read_Callback(PIOS_IMU3000_FIFO_REG, imu3000_read_buffer, sizeof(imu3000_read_buffer) - 2, imu3000_callback);
|
||||
|
||||
} else {
|
||||
// Stupid system for IMU3000. Ensure something is left in buffer
|
||||
if(fifo_level < (sizeof(imu3000_read_buffer) + 2))
|
||||
return;
|
||||
|
||||
imu3000_cb_ready = false;
|
||||
|
||||
// Leave footer in buffer
|
||||
PIOS_IMU3000_Read_Callback(PIOS_IMU3000_FIFO_REG, imu3000_read_buffer, sizeof(imu3000_read_buffer), imu3000_callback);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The physical IRQ handler
|
||||
* Soon this will be generic in pios_exti and the BMA180 will register
|
||||
* against it. Right now this is crap!
|
||||
*/
|
||||
void EXTI1_IRQHandler(void)
|
||||
{
|
||||
if (EXTI_GetITStatus(EXTI_Line1) != RESET)
|
||||
{
|
||||
PIOS_IMU3000_IRQHandler();
|
||||
EXTI_ClearITPendingBit(EXTI_Line1);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
@ -7,8 +7,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file pios_irq.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Thorsten Klose (tk@midibox.org) (tk@midibox.org)
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012
|
||||
* @brief IRQ Enable/Disable routines
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
|
@ -7,7 +7,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file pios_led.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief LED functions, init, toggle, on & off.
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
|
@ -7,7 +7,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file pios_mpu000.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011.
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief MPU6000 6-axis gyro and accel chip
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
@ -54,7 +54,7 @@ static struct pios_mpu6000_cfg const * cfg;
|
||||
#define GRAV 9.81f
|
||||
|
||||
/**
|
||||
* @brief Initialize the MPU6050 3-axis gyro sensor.
|
||||
* @brief Initialize the MPU6000 3-axis gyro sensor.
|
||||
* @return none
|
||||
*/
|
||||
void PIOS_MPU6000_Init(const struct pios_mpu6000_cfg * new_cfg)
|
||||
@ -63,7 +63,7 @@ void PIOS_MPU6000_Init(const struct pios_mpu6000_cfg * new_cfg)
|
||||
|
||||
fifoBuf_init(&pios_mpu6000_fifo, (uint8_t *) pios_mpu6000_buffer, sizeof(pios_mpu6000_buffer));
|
||||
|
||||
/* Configure the MPU6050 Sensor */
|
||||
/* Configure the MPU6000 Sensor */
|
||||
PIOS_SPI_SetPrescalar(pios_spi_gyro, SPI_BaudRatePrescaler_256);
|
||||
PIOS_MPU6000_Config(cfg);
|
||||
PIOS_SPI_SetPrescalar(pios_spi_gyro, SPI_BaudRatePrescaler_8);
|
||||
@ -81,7 +81,7 @@ void PIOS_MPU6000_Init(const struct pios_mpu6000_cfg * new_cfg)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize the MPU6050 3-axis gyro sensor
|
||||
* @brief Initialize the MPU6000 3-axis gyro sensor
|
||||
* \return none
|
||||
* \param[in] PIOS_MPU6000_ConfigTypeDef struct to be used to configure sensor.
|
||||
*
|
||||
@ -244,9 +244,9 @@ int32_t PIOS_MPU6000_ReadGyros(struct pios_mpu6000_data * data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read the identification bytes from the MPU6050 sensor
|
||||
* \return ID read from MPU6050 or -1 if failure
|
||||
/*
|
||||
* @brief Read the identification bytes from the MPU6000 sensor
|
||||
* \return ID read from MPU6000 or -1 if failure
|
||||
*/
|
||||
int32_t PIOS_MPU6000_ReadID()
|
||||
{
|
||||
@ -257,7 +257,7 @@ int32_t PIOS_MPU6000_ReadID()
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Reads the data from the MPU6050 FIFO
|
||||
* \brief Reads the data from the MPU6000 FIFO
|
||||
* \param[out] buffer destination buffer
|
||||
* \param[in] len maximum number of bytes which should be read
|
||||
* \note This returns the data as X, Y, Z the temperature
|
||||
@ -303,7 +303,7 @@ float PIOS_MPU6000_GetAccelScale()
|
||||
*/
|
||||
uint8_t PIOS_MPU6000_Test(void)
|
||||
{
|
||||
/* Verify that ID matches (MPU6050 ID is 0x69) */
|
||||
/* Verify that ID matches (MPU6000 ID is 0x69) */
|
||||
int32_t mpu6000_id = PIOS_MPU6000_ReadID();
|
||||
if(mpu6000_id < 0)
|
||||
return -1;
|
||||
|
@ -1,365 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_MPU6050 MPU6050 Functions
|
||||
* @brief Deals with the hardware interface to the 3-axis gyro
|
||||
* @{
|
||||
*
|
||||
* @file pios_mpu050.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011.
|
||||
* @brief MPU6050 3-axis gyor functions from INS
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Project Includes */
|
||||
#include "pios.h"
|
||||
|
||||
#if defined(PIOS_INCLUDE_MPU6050)
|
||||
|
||||
/* Global Variables */
|
||||
|
||||
/* Local Variables */
|
||||
#define DEG_TO_RAD (M_PI / 180.0)
|
||||
static void PIOS_MPU6050_Config(struct pios_mpu6050_cfg const * cfg);
|
||||
static int32_t PIOS_MPU6050_Read(uint8_t address, uint8_t * buffer, uint8_t len);
|
||||
static int32_t PIOS_MPU6050_Write(uint8_t address, uint8_t buffer);
|
||||
|
||||
#define PIOS_MPU6050_MAX_DOWNSAMPLE 10
|
||||
static int16_t pios_mpu6050_buffer[PIOS_MPU6050_MAX_DOWNSAMPLE * sizeof(struct pios_mpu6050_data)];
|
||||
static t_fifo_buffer pios_mpu6050_fifo;
|
||||
|
||||
volatile bool mpu6050_first_read = true;
|
||||
volatile bool mpu6050_configured = false;
|
||||
volatile bool mpu6050_cb_ready = true;
|
||||
|
||||
static struct pios_mpu6050_cfg const * cfg;
|
||||
|
||||
/**
|
||||
* @brief Initialize the MPU6050 3-axis gyro sensor.
|
||||
* @return none
|
||||
*/
|
||||
void PIOS_MPU6050_Init(const struct pios_mpu6050_cfg * new_cfg)
|
||||
{
|
||||
cfg = new_cfg;
|
||||
|
||||
fifoBuf_init(&pios_mpu6050_fifo, (uint8_t *) pios_mpu6050_buffer, sizeof(pios_mpu6050_buffer));
|
||||
|
||||
/* Configure EOC pin as input floating */
|
||||
GPIO_Init(cfg->drdy.gpio, &cfg->drdy.init);
|
||||
|
||||
/* Configure the End Of Conversion (EOC) interrupt */
|
||||
SYSCFG_EXTILineConfig(cfg->eoc_exti.port_source, cfg->eoc_exti.pin_source);
|
||||
EXTI_Init(&cfg->eoc_exti.init);
|
||||
|
||||
/* Enable and set EOC EXTI Interrupt to the lowest priority */
|
||||
NVIC_Init(&cfg->eoc_irq.init);
|
||||
|
||||
/* Configure the MPU6050 Sensor */
|
||||
PIOS_MPU6050_Config(cfg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize the MPU6050 3-axis gyro sensor
|
||||
* \return none
|
||||
* \param[in] PIOS_MPU6050_ConfigTypeDef struct to be used to configure sensor.
|
||||
*
|
||||
*/
|
||||
static void PIOS_MPU6050_Config(struct pios_mpu6050_cfg const * cfg)
|
||||
{
|
||||
mpu6050_first_read = true;
|
||||
mpu6050_cb_ready = true;
|
||||
|
||||
// Reset chip and fifo
|
||||
while (PIOS_MPU6050_Write(PIOS_MPU6050_USER_CTRL_REG, 0x01 | 0x02 | 0x04) != 0);
|
||||
PIOS_DELAY_WaituS(20);
|
||||
|
||||
// FIFO storage
|
||||
while (PIOS_MPU6050_Write(PIOS_MPU6050_FIFO_EN_REG, cfg->Fifo_store) != 0);
|
||||
|
||||
// Sample rate divider
|
||||
while (PIOS_MPU6050_Write(PIOS_MPU6050_SMPLRT_DIV_REG, cfg->Smpl_rate_div) != 0) ;
|
||||
|
||||
// Digital low-pass filter and scale
|
||||
while (PIOS_MPU6050_Write(PIOS_MPU6050_DLPF_CFG_REG, cfg->filter) != 0) ;
|
||||
|
||||
// Digital low-pass filter and scale
|
||||
while (PIOS_MPU6050_Write(PIOS_MPU6050_GYRO_CFG_REG, cfg->gyro_range) != 0) ;
|
||||
|
||||
// Interrupt configuration
|
||||
while (PIOS_MPU6050_Write(PIOS_MPU6050_USER_CTRL_REG, cfg->User_ctl) != 0) ;
|
||||
|
||||
// Interrupt configuration
|
||||
while (PIOS_MPU6050_Write(PIOS_MPU6050_PWR_MGMT_REG, cfg->Pwr_mgmt_clk) != 0) ;
|
||||
|
||||
// Interrupt configuration
|
||||
while (PIOS_MPU6050_Write(PIOS_MPU6050_INT_CFG_REG, cfg->interrupt_cfg) != 0) ;
|
||||
|
||||
// Interrupt configuration
|
||||
while (PIOS_MPU6050_Write(PIOS_MPU6050_INT_EN_REG, cfg->interrupt_en) != 0) ;
|
||||
|
||||
mpu6050_configured = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read current X, Z, Y values (in that order)
|
||||
* \param[out] int16_t array of size 3 to store X, Z, and Y magnetometer readings
|
||||
* \returns The number of samples remaining in the fifo
|
||||
*/
|
||||
int32_t PIOS_MPU6050_ReadGyros(struct pios_mpu6050_data * data)
|
||||
{
|
||||
uint8_t buf[6];
|
||||
if(PIOS_MPU6050_Read(PIOS_MPU6050_GYRO_X_OUT_MSB, (uint8_t *) buf, sizeof(buf)) < 0)
|
||||
return -1;
|
||||
data->gyro_x = buf[0] << 8 | buf[1];
|
||||
data->gyro_y = buf[2] << 8 | buf[3];
|
||||
data->gyro_z = buf[4] << 8 | buf[5];
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Read the identification bytes from the MPU6050 sensor
|
||||
* \return ID read from MPU6050 or -1 if failure
|
||||
*/
|
||||
int32_t PIOS_MPU6050_ReadID()
|
||||
{
|
||||
uint8_t mpu6050_id;
|
||||
if(PIOS_MPU6050_Read(PIOS_MPU6050_WHOAMI, (uint8_t *) &mpu6050_id, 1) != 0)
|
||||
return -1;
|
||||
return mpu6050_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Reads the data from the MPU6050 FIFO
|
||||
* \param[out] buffer destination buffer
|
||||
* \param[in] len maximum number of bytes which should be read
|
||||
* \note This returns the data as X, Y, Z the temperature
|
||||
* \return number of bytes transferred if operation was successful
|
||||
* \return -1 if error during I2C transfer
|
||||
*/
|
||||
int32_t PIOS_MPU6050_ReadFifo(struct pios_mpu6050_data * buffer)
|
||||
{
|
||||
if(fifoBuf_getUsed(&pios_mpu6050_fifo) < sizeof(*buffer))
|
||||
return -1;
|
||||
|
||||
fifoBuf_getData(&pios_mpu6050_fifo, (uint8_t *) buffer, sizeof(*buffer));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads one or more bytes from MPU6050 into a buffer
|
||||
* \param[in] address MPU6050 register address (depends on size)
|
||||
* \param[out] buffer destination buffer
|
||||
* \param[in] len number of bytes which should be read
|
||||
* \return 0 if operation was successful
|
||||
* \return -1 if error during I2C transfer
|
||||
* \return -2 if unable to claim i2c device
|
||||
*/
|
||||
static int32_t PIOS_MPU6050_Read(uint8_t address, uint8_t * buffer, uint8_t len)
|
||||
{
|
||||
uint8_t addr_buffer[] = {
|
||||
address,
|
||||
};
|
||||
|
||||
const struct pios_i2c_txn txn_list[] = {
|
||||
{
|
||||
.info = __func__,
|
||||
.addr = PIOS_MPU6050_I2C_ADDR,
|
||||
.rw = PIOS_I2C_TXN_WRITE,
|
||||
.len = sizeof(addr_buffer),
|
||||
.buf = addr_buffer,
|
||||
}
|
||||
,
|
||||
{
|
||||
.info = __func__,
|
||||
.addr = PIOS_MPU6050_I2C_ADDR,
|
||||
.rw = PIOS_I2C_TXN_READ,
|
||||
.len = len,
|
||||
.buf = buffer,
|
||||
}
|
||||
};
|
||||
|
||||
return PIOS_I2C_Transfer(PIOS_I2C_GYRO_ADAPTER, txn_list, NELEMENTS(txn_list));
|
||||
}
|
||||
|
||||
// Must allocate on stack to be persistent
|
||||
static uint8_t cb_addr_buffer[] = {
|
||||
0,
|
||||
};
|
||||
static struct pios_i2c_txn cb_txn_list[] = {
|
||||
{
|
||||
.addr = PIOS_MPU6050_I2C_ADDR,
|
||||
.rw = PIOS_I2C_TXN_WRITE,
|
||||
.len = sizeof(cb_addr_buffer),
|
||||
.buf = cb_addr_buffer,
|
||||
}
|
||||
,
|
||||
{
|
||||
.addr = PIOS_MPU6050_I2C_ADDR,
|
||||
.rw = PIOS_I2C_TXN_READ,
|
||||
.len = 0,
|
||||
.buf = 0,
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
static int32_t PIOS_MPU6050_Read_Callback(uint8_t address, uint8_t * buffer, uint8_t len, void *callback)
|
||||
{
|
||||
cb_addr_buffer[0] = address;
|
||||
cb_txn_list[0].info = __func__,
|
||||
cb_txn_list[1].info = __func__;
|
||||
cb_txn_list[1].len = len;
|
||||
cb_txn_list[1].buf = buffer;
|
||||
|
||||
return PIOS_I2C_Transfer_Callback(PIOS_I2C_GYRO_ADAPTER, cb_txn_list, NELEMENTS(cb_txn_list), callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes one or more bytes to the MPU6050
|
||||
* \param[in] address Register address
|
||||
* \param[in] buffer source buffer
|
||||
* \return 0 if operation was successful
|
||||
* \return -1 if error during I2C transfer
|
||||
* \return -2 if unable to claim i2c device
|
||||
*/
|
||||
static int32_t PIOS_MPU6050_Write(uint8_t address, uint8_t buffer)
|
||||
{
|
||||
uint8_t data[] = {
|
||||
address,
|
||||
buffer,
|
||||
};
|
||||
|
||||
const struct pios_i2c_txn txn_list[] = {
|
||||
{
|
||||
.info = __func__,
|
||||
.addr = PIOS_MPU6050_I2C_ADDR,
|
||||
.rw = PIOS_I2C_TXN_WRITE,
|
||||
.len = sizeof(data),
|
||||
.buf = data,
|
||||
}
|
||||
,
|
||||
};
|
||||
|
||||
return PIOS_I2C_Transfer(PIOS_I2C_GYRO_ADAPTER, txn_list, NELEMENTS(txn_list));
|
||||
}
|
||||
|
||||
float PIOS_MPU6050_GetScale()
|
||||
{
|
||||
switch (cfg->gyro_range) {
|
||||
case PIOS_MPU6050_SCALE_250_DEG:
|
||||
return 1.0f / 131.0f;
|
||||
case PIOS_MPU6050_SCALE_500_DEG:
|
||||
return 1.0f / 65.5f;
|
||||
case PIOS_MPU6050_SCALE_1000_DEG:
|
||||
return 1.0f / 32.8f;
|
||||
case PIOS_MPU6050_SCALE_2000_DEG:
|
||||
return 1.0f / 16.4f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* @brief Run self-test operation.
|
||||
* \return 0 if test succeeded
|
||||
* \return non-zero value if test succeeded
|
||||
*/
|
||||
uint8_t PIOS_MPU6050_Test(void)
|
||||
{
|
||||
/* Verify that ID matches (MPU6050 ID is 0x69) */
|
||||
int32_t mpu6050_id = PIOS_MPU6050_ReadID();
|
||||
if(mpu6050_id < 0)
|
||||
return -1;
|
||||
|
||||
if(mpu6050_id != PIOS_MPU6050_I2C_ADDR & 0xFE)
|
||||
return -2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t mpu6050_read_buffer[sizeof(struct pios_mpu6050_data)]; // Right now using ,Y,Z,fifo_footer
|
||||
static void MPU6050_callback()
|
||||
{
|
||||
struct pios_mpu6050_data data;
|
||||
|
||||
if(fifoBuf_getFree(&pios_mpu6050_fifo) < sizeof(data))
|
||||
goto out;
|
||||
|
||||
data.temperature = mpu6050_read_buffer[0] << 8 | mpu6050_read_buffer[1];
|
||||
data.gyro_x = mpu6050_read_buffer[2] << 8 | mpu6050_read_buffer[3];
|
||||
data.gyro_y = mpu6050_read_buffer[4] << 8 | mpu6050_read_buffer[5];
|
||||
data.gyro_z = mpu6050_read_buffer[6] << 8 | mpu6050_read_buffer[7];
|
||||
|
||||
fifoBuf_putData(&pios_mpu6050_fifo, (uint8_t *) &data, sizeof(data));
|
||||
|
||||
out:
|
||||
mpu6050_cb_ready = true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief IRQ Handler
|
||||
*/
|
||||
uint32_t mpu6050_irq = 0;
|
||||
uint16_t fifo_level;
|
||||
uint8_t fifo_level_data[2];
|
||||
uint32_t cb_not_ready = 0;
|
||||
void PIOS_MPU6050_IRQHandler(void)
|
||||
{
|
||||
|
||||
mpu6050_irq++;
|
||||
|
||||
if(!mpu6050_configured)
|
||||
return;
|
||||
|
||||
//PIOS_Assert(MPU6050_cb_ready);
|
||||
if(!mpu6050_cb_ready) {
|
||||
PIOS_LED_Toggle(LED2);
|
||||
cb_not_ready++;
|
||||
return;
|
||||
}
|
||||
|
||||
// Leave footer in buffer
|
||||
PIOS_MPU6050_Read_Callback(PIOS_MPU6050_FIFO_REG, mpu6050_read_buffer, sizeof(mpu6050_read_buffer), MPU6050_callback);
|
||||
}
|
||||
|
||||
#if defined(PIOS_INCLUDE_MPU6050)
|
||||
/**
|
||||
* The physical IRQ handler
|
||||
* Soon this will be generic in pios_exti and the BMA180 will register
|
||||
* against it. Right now this is crap!
|
||||
*/
|
||||
void EXTI1_IRQHandler(void)
|
||||
{
|
||||
if (EXTI_GetITStatus(EXTI_Line1) != RESET)
|
||||
{
|
||||
PIOS_MPU6050_IRQHandler();
|
||||
EXTI_ClearITPendingBit(EXTI_Line1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
@ -1,17 +1,17 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_BMP085 BMP085 Functions
|
||||
* @brief Hardware functions to deal with the altitude pressure sensor
|
||||
* @{
|
||||
*
|
||||
* @file pios_ms5611.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief MS5611 Pressure Sensor Routines
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
******************************************************************************/
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_MS5611 MS5611 Functions
|
||||
* @brief Hardware functions to deal with the altitude pressure sensor
|
||||
* @{
|
||||
*
|
||||
* @file pios_ms5611.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief MS5611 Pressure Sensor Routines
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
******************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -7,7 +7,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file pios_ppm.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief PPM Input functions (STM32 dependent)
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
|
@ -3,11 +3,11 @@
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_PWM PWM Input Functions
|
||||
* @brief Code to measure with PWM input
|
||||
* @brief Code to measure with PWM input
|
||||
* @{
|
||||
*
|
||||
* @file pios_pwm.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief PWM Input functions (STM32 dependent)
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
|
@ -7,7 +7,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file pios_pwm.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief PWM Input functions (STM32 dependent)
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
|
@ -7,7 +7,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file pios_servo.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief RC Servo routines (STM32 dependent)
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
|
@ -7,8 +7,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file pios_spi.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Thorsten Klose (tk@midibox.org) (tk@midibox.org)
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief Hardware Abstraction Layer for SPI ports of STM32
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @notes
|
||||
|
@ -8,8 +8,7 @@
|
||||
*
|
||||
* @file pios_sys.c
|
||||
* @author Michael Smith Copyright (C) 2011
|
||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Thorsten Klose (tk@midibox.org) (tk@midibox.org)
|
||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief Sets up basic STM32 system hardware, functions are called from Main.
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
|
@ -1,3 +1,34 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_TIM Timer Functions
|
||||
* @brief PIOS Timer control code
|
||||
* @{
|
||||
*
|
||||
* @file pios_tim.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief Sets up timers and ways to register callbacks on them
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
#include "pios.h"
|
||||
|
||||
#include "pios_tim.h"
|
||||
@ -454,3 +485,8 @@ static void PIOS_TIM_8_CC_irq_handler (void)
|
||||
{
|
||||
PIOS_TIM_generic_irq_handler (TIM8);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
@ -7,8 +7,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file pios_usart.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Thorsten Klose (tk@midibox.org) (tk@midibox.org)
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief USART commands. Inits USARTs, controls USARTs & Interupt handlers. (STM32 dependent)
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
|
@ -7,7 +7,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file pios_spi.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* Parts by Thorsten Klose (tk@midibox.org) (tk@midibox.org)
|
||||
* @brief Hardware Abstraction Layer for SPI ports of STM32
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
|
@ -1,8 +1,31 @@
|
||||
/**
|
||||
* @file startup.c
|
||||
* @brief Generic CortexM3 startup code for PiOS.
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
*
|
||||
* @file startup.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief C based startup of F4
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <stm32f4xx.h>
|
||||
|
||||
@ -119,3 +142,7 @@ struct cm3_vectors cpu_vectors __attribute((section(".cpu_vectors"))) = {
|
||||
xPortSysTickHandler,
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
@ -1,6 +1,28 @@
|
||||
/**
|
||||
* @file startup.c
|
||||
* @brief I/O peripheral vectors for STM32F4xx
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
*
|
||||
* @file vector_stm32f4xx.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief C based vectors for F4
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/** interrupt handler */
|
||||
@ -184,3 +206,7 @@ vector *io_vectors[] __attribute__((section(".io_vectors"))) = {
|
||||
HASH_RNG_IRQHandler, // Hash and Rng
|
||||
FPU_IRQHandler, // FPU
|
||||
};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
@ -1,12 +1,31 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_ADXL345 ADXL345 Functions
|
||||
* @brief Data from the ADXL345 sensors
|
||||
* @{
|
||||
* @file pios_adxl345.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief PiOS SPI ADXL345
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* pios_adxl345.h
|
||||
* OpenPilotOSX
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Created by James Cotton on 1/16/11.
|
||||
* Copyright 2011 OpenPilot. All rights reserved.
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef PIOS_ADXL345_H
|
||||
#define PIOS_ADXL345_H
|
||||
|
||||
@ -56,3 +75,8 @@ uint8_t PIOS_ADXL345_Read(struct pios_adxl345_data * data);
|
||||
uint8_t PIOS_ADXL345_FifoElements();
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
@ -7,8 +7,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file pios_bma180.h
|
||||
* @author David "Buzz" Carlson (buzz@chebuzz.com)
|
||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011.
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief PiOS BMA180 digital accelerometer driver.
|
||||
* - Driver for the BMA180 digital accelerometer on the SPI bus.
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
|
@ -7,7 +7,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file pios_bmp085.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief BMP085 functions header.
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
|
@ -7,7 +7,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file pios_hmc5843.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief HMC5843 functions header.
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
|
@ -7,8 +7,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file pios_hmc5883.h
|
||||
* @author David "Buzz" Carlson (buzz@chebuzz.com)
|
||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011.
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief HMC5883 functions header.
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
|
@ -1,152 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_IMU3000 IMU3000 Functions
|
||||
* @brief Deals with the hardware interface to the 3-axis gyro
|
||||
* @{
|
||||
*
|
||||
* @file pios_imu3000.h
|
||||
* @author David "Buzz" Carlson (buzz@chebuzz.com)
|
||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011.
|
||||
* @brief IMU3000 3-axis gyor function headers
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef PIOS_IMU3000_H
|
||||
#define PIOS_IMU3000_H
|
||||
|
||||
#include "pios.h"
|
||||
|
||||
/* IMU3000 Addresses */
|
||||
#define PIOS_IMU3000_I2C_ADDR 0x69
|
||||
#define PIOS_IMU3000_I2C_READ_ADDR 0xD2
|
||||
#define PIOS_IMU3000_I2C_WRITE_ADDR 0xD3
|
||||
#define PIOS_IMU3000_X_MSB_OFFSET_REG 0x0C
|
||||
#define PIOS_IMU3000_X_LSB_OFFSET_REG 0x0D
|
||||
#define PIOS_IMU3000_Y_MSB_OFFSET_REG 0x0E
|
||||
#define PIOS_IMU3000_Y_LSB_OFFSET_REG 0x0F
|
||||
#define PIOS_IMU3000_Z_MSB_OFFSET_REG 0x10
|
||||
#define PIOS_IMU3000_Z_LSB_OFFSET_REG 0x11
|
||||
#define PIOS_IMU3000_FIFO_EN_REG 0x12
|
||||
#define PIOS_IMU3000_SMPLRT_DIV_REG 0X15
|
||||
#define PIOS_IMU3000_DLPF_CFG_REG 0X16
|
||||
#define PIOS_IMU3000_INT_CFG_REG 0x17
|
||||
#define PIOS_IMU3000_INT_STATUS_REG 0x1A
|
||||
#define PIOS_IMU3000_TEMP_OUT_MSB 0x1B
|
||||
#define PIOS_IMU3000_TEMP_OUT_LSB 0x1C
|
||||
#define PIOS_IMU3000_GYRO_X_OUT_MSB 0x1D
|
||||
#define PIOS_IMU3000_GYRO_X_OUT_LSB 0x1E
|
||||
#define PIOS_IMU3000_GYRO_Y_OUT_MSB 0x1F
|
||||
#define PIOS_IMU3000_GYRO_Y_OUT_LSB 0x20
|
||||
#define PIOS_IMU3000_GYRO_Z_OUT_MSB 0x21
|
||||
#define PIOS_IMU3000_GYRO_Z_OUT_LSB 0x22
|
||||
#define PIOS_IMU3000_FIFO_CNT_MSB 0x3A
|
||||
#define PIOS_IMU3000_FIFO_CNT_LSB 0x3B
|
||||
#define PIOS_IMU3000_FIFO_REG 0x3C
|
||||
#define PIOS_IMU3000_USER_CTRL_REG 0x3D
|
||||
#define PIOS_IMU3000_PWR_MGMT_REG 0x3E
|
||||
|
||||
/* FIFO enable for storing different values */
|
||||
#define PIOS_IMU3000_FIFO_TEMP_OUT 0x80
|
||||
#define PIOS_IMU3000_FIFO_GYRO_X_OUT 0x40
|
||||
#define PIOS_IMU3000_FIFO_GYRO_Y_OUT 0x20
|
||||
#define PIOS_IMU3000_FIFO_GYRO_Z_OUT 0x10
|
||||
#define PIOS_IMU3000_FIFO_FOOTER 0x01
|
||||
|
||||
|
||||
/* Interrupt Configuration */
|
||||
#define PIOS_IMU3000_INT_ACTL 0x80
|
||||
#define PIOS_IMU3000_INT_OPEN 0x40
|
||||
#define PIOS_IMU3000_INT_LATCH_EN 0x20
|
||||
#define PIOS_IMU3000_INT_CLR_ANYRD 0x10
|
||||
#define PIOS_IMU3000_INT_IMU_RDY 0x04
|
||||
#define PIOS_IMU3000_INT_DATA_RDY 0x01
|
||||
|
||||
/* Interrupt status */
|
||||
#define PIOS_IMU3000_INT_STATUS_FIFO_FULL 0x80
|
||||
#define PIOS_IMU3000_INT_STATUS_IMU_RDY 0X04
|
||||
#define PIOS_IMU3000_INT_STATUS_DATA_RDY 0X01
|
||||
|
||||
/* User control functionality */
|
||||
#define PIOS_IMU3000_USERCTL_FIFO_EN 0X40
|
||||
#define PIOS_IMU3000_USERCTL_FIFO_RST 0X02
|
||||
#define PIOS_IMU3000_USERCTL_GYRO_RST 0X01
|
||||
|
||||
/* Power management and clock selection */
|
||||
#define PIOS_IMU3000_PWRMGMT_IMU_RST 0X80
|
||||
#define PIOS_IMU3000_PWRMGMT_INTERN_CLK 0X00
|
||||
#define PIOS_IMU3000_PWRMGMT_PLL_X_CLK 0X01
|
||||
#define PIOS_IMU3000_PWRMGMT_PLL_Y_CLK 0X02
|
||||
#define PIOS_IMU3000_PWRMGMT_PLL_Z_CLK 0X03
|
||||
#define PIOS_IMU3000_PWRMGMT_STOP_CLK 0X07
|
||||
|
||||
enum pios_imu3000_range {
|
||||
PIOS_IMU3000_SCALE_250_DEG = 0x00,
|
||||
PIOS_IMU3000_SCALE_500_DEG = 0x01,
|
||||
PIOS_IMU3000_SCALE_1000_DEG = 0x02,
|
||||
PIOS_IMU3000_SCALE_2000_DEG = 0x03
|
||||
};
|
||||
|
||||
enum pios_imu3000_filter {
|
||||
PIOS_IMU3000_LOWPASS_256_HZ = 0x00,
|
||||
PIOS_IMU3000_LOWPASS_188_HZ = 0x01,
|
||||
PIOS_IMU3000_LOWPASS_98_HZ = 0x02,
|
||||
PIOS_IMU3000_LOWPASS_42_HZ = 0x03,
|
||||
PIOS_IMU3000_LOWPASS_20_HZ = 0x04,
|
||||
PIOS_IMU3000_LOWPASS_10_HZ = 0x05,
|
||||
PIOS_IMU3000_LOWPASS_5_HZ = 0x06
|
||||
};
|
||||
|
||||
struct pios_imu3000_data {
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int16_t z;
|
||||
int16_t temperature;
|
||||
};
|
||||
|
||||
struct pios_imu3000_cfg {
|
||||
struct stm32_gpio drdy;
|
||||
struct stm32_exti eoc_exti;
|
||||
struct stm32_irq eoc_irq;
|
||||
|
||||
uint8_t Fifo_store; /* FIFO storage of different readings (See datasheet page 31 for more details) */
|
||||
uint8_t Smpl_rate_div; /* Sample rate divider to use (See datasheet page 32 for more details) */
|
||||
uint8_t Interrupt_cfg; /* Interrupt configuration (See datasheet page 35 for more details) */
|
||||
uint8_t User_ctl; /* User control settings (See datasheet page 41 for more details) */
|
||||
uint8_t Pwr_mgmt_clk; /* Power management and clock selection (See datasheet page 32 for more details) */
|
||||
enum pios_imu3000_range range;
|
||||
enum pios_imu3000_filter filter;
|
||||
};
|
||||
|
||||
/* Public Functions */
|
||||
extern void PIOS_IMU3000_Init(const struct pios_imu3000_cfg * cfg);
|
||||
extern int32_t PIOS_IMU3000_ReadFifo(struct pios_imu3000_data * buffer);
|
||||
extern int32_t PIOS_IMU3000_ReadGyros(struct pios_imu3000_data * buffer);
|
||||
extern int32_t PIOS_IMU3000_ReadID();
|
||||
extern uint8_t PIOS_IMU3000_Test();
|
||||
extern float PIOS_IMU3000_GetScale();
|
||||
|
||||
#endif /* PIOS_IMU3000_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
@ -2,14 +2,13 @@
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_MPU6000 MPU6050 Functions
|
||||
* @addtogroup PIOS_MPU6000 MPU6000 Functions
|
||||
* @brief Deals with the hardware interface to the 3-axis gyro
|
||||
* @{
|
||||
*
|
||||
* @file PIOS_MPU6000.h
|
||||
* @author David "Buzz" Carlson (buzz@chebuzz.com)
|
||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011.
|
||||
* @brief MPU6050 3-axis gyor function headers
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief MPU6000 3-axis gyor function headers
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
******************************************************************************
|
||||
@ -35,7 +34,7 @@
|
||||
|
||||
#include "pios.h"
|
||||
|
||||
/* MPU6050 Addresses */
|
||||
/* MPU6000 Addresses */
|
||||
#define PIOS_MPU6000_SMPLRT_DIV_REG 0X19
|
||||
#define PIOS_MPU6000_DLPF_CFG_REG 0X1A
|
||||
#define PIOS_MPU6000_GYRO_CFG_REG 0X1B
|
||||
|
@ -1,155 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_MPU6050 MPU6050 Functions
|
||||
* @brief Deals with the hardware interface to the 3-axis gyro
|
||||
* @{
|
||||
*
|
||||
* @file pios_MPU6050.h
|
||||
* @author David "Buzz" Carlson (buzz@chebuzz.com)
|
||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011.
|
||||
* @brief MPU6050 3-axis gyor function headers
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef PIOS_MPU6050_H
|
||||
#define PIOS_MPU6050_H
|
||||
|
||||
#include "pios.h"
|
||||
|
||||
/* MPU6050 Addresses */
|
||||
#define PIOS_MPU6050_I2C_ADDR 0x69
|
||||
#define PIOS_MPU6050_SMPLRT_DIV_REG 0X19
|
||||
#define PIOS_MPU6050_DLPF_CFG_REG 0X1A
|
||||
#define PIOS_MPU6050_GYRO_CFG_REG 0X1B
|
||||
#define PIOS_MPU6050_ACCEL_CFG_REG 0X1C
|
||||
#define PIOS_MPU6050_FIFO_EN_REG 0x23
|
||||
#define PIOS_MPU6050_INT_CFG_REG 0x37
|
||||
#define PIOS_MPU6050_INT_EN_REG 0x38
|
||||
#define PIOS_MPU6050_INT_STATUS_REG 0x3A
|
||||
#define PIOS_MPU6050_ACCEL_X_OUT_MSB 0x3B
|
||||
#define PIOS_MPU6050_ACCEL_X_OUT_LSB 0x3C
|
||||
#define PIOS_MPU6050_ACCEL_Y_OUT_MSB 0x3D
|
||||
#define PIOS_MPU6050_ACCEL_Y_OUT_LSB 0x3E
|
||||
#define PIOS_MPU6050_ACCEL_Z_OUT_MSB 0x3F
|
||||
#define PIOS_MPU6050_ACCEL_Z_OUT_LSB 0x40
|
||||
#define PIOS_MPU6050_TEMP_OUT_MSB 0x41
|
||||
#define PIOS_MPU6050_TEMP_OUT_LSB 0x42
|
||||
#define PIOS_MPU6050_GYRO_X_OUT_MSB 0x43
|
||||
#define PIOS_MPU6050_GYRO_X_OUT_LSB 0x44
|
||||
#define PIOS_MPU6050_GYRO_Y_OUT_MSB 0x45
|
||||
#define PIOS_MPU6050_GYRO_Y_OUT_LSB 0x46
|
||||
#define PIOS_MPU6050_GYRO_Z_OUT_MSB 0x47
|
||||
#define PIOS_MPU6050_GYRO_Z_OUT_LSB 0x48
|
||||
#define PIOS_MPU6050_USER_CTRL_REG 0x6A
|
||||
#define PIOS_MPU6050_PWR_MGMT_REG 0x6B
|
||||
#define PIOS_MPU6050_FIFO_CNT_MSB 0x72
|
||||
#define PIOS_MPU6050_FIFO_CNT_LSB 0x73
|
||||
#define PIOS_MPU6050_FIFO_REG 0x74
|
||||
#define PIOS_MPU6050_WHOAMI 0x75
|
||||
|
||||
/* FIFO enable for storing different values */
|
||||
#define PIOS_MPU6050_FIFO_TEMP_OUT 0x80
|
||||
#define PIOS_MPU6050_FIFO_GYRO_X_OUT 0x40
|
||||
#define PIOS_MPU6050_FIFO_GYRO_Y_OUT 0x20
|
||||
#define PIOS_MPU6050_FIFO_GYRO_Z_OUT 0x10
|
||||
#define PIOS_MPU6050_ACCEL_OUT 0x04
|
||||
|
||||
/* Interrupt Configuration */
|
||||
#define PIOS_MPU6050_INT_ACTL 0x80
|
||||
#define PIOS_MPU6050_INT_OPEN 0x40
|
||||
#define PIOS_MPU6050_INT_LATCH_EN 0x20
|
||||
#define PIOS_MPU6050_INT_CLR_ANYRD 0x10
|
||||
|
||||
#define PIOS_MPU6050_INTEN_OVERFLOW 0x10
|
||||
#define PIOS_MPU6050_INTEN_DATA_RDY 0x01
|
||||
|
||||
/* Interrupt status */
|
||||
#define PIOS_MPU6050_INT_STATUS_FIFO_FULL 0x80
|
||||
#define PIOS_MPU6050_INT_STATUS_IMU_RDY 0X04
|
||||
#define PIOS_MPU6050_INT_STATUS_DATA_RDY 0X01
|
||||
|
||||
/* User control functionality */
|
||||
#define PIOS_MPU6050_USERCTL_FIFO_EN 0X40
|
||||
#define PIOS_MPU6050_USERCTL_FIFO_RST 0X02
|
||||
#define PIOS_MPU6050_USERCTL_GYRO_RST 0X01
|
||||
|
||||
/* Power management and clock selection */
|
||||
#define PIOS_MPU6050_PWRMGMT_IMU_RST 0X80
|
||||
#define PIOS_MPU6050_PWRMGMT_INTERN_CLK 0X00
|
||||
#define PIOS_MPU6050_PWRMGMT_PLL_X_CLK 0X01
|
||||
#define PIOS_MPU6050_PWRMGMT_PLL_Y_CLK 0X02
|
||||
#define PIOS_MPU6050_PWRMGMT_PLL_Z_CLK 0X03
|
||||
#define PIOS_MPU6050_PWRMGMT_STOP_CLK 0X07
|
||||
|
||||
enum pios_mpu6050_range {
|
||||
PIOS_MPU6050_SCALE_250_DEG = 0x00,
|
||||
PIOS_MPU6050_SCALE_500_DEG = 0x08,
|
||||
PIOS_MPU6050_SCALE_1000_DEG = 0x10,
|
||||
PIOS_MPU6050_SCALE_2000_DEG = 0x18
|
||||
};
|
||||
|
||||
enum pios_mpu6050_filter {
|
||||
PIOS_MPU6050_LOWPASS_256_HZ = 0x00,
|
||||
PIOS_MPU6050_LOWPASS_188_HZ = 0x01,
|
||||
PIOS_MPU6050_LOWPASS_98_HZ = 0x02,
|
||||
PIOS_MPU6050_LOWPASS_42_HZ = 0x03,
|
||||
PIOS_MPU6050_LOWPASS_20_HZ = 0x04,
|
||||
PIOS_MPU6050_LOWPASS_10_HZ = 0x05,
|
||||
PIOS_MPU6050_LOWPASS_5_HZ = 0x06
|
||||
};
|
||||
|
||||
struct pios_mpu6050_data {
|
||||
int16_t gyro_x;
|
||||
int16_t gyro_y;
|
||||
int16_t gyro_z;
|
||||
int16_t temperature;
|
||||
};
|
||||
|
||||
struct pios_mpu6050_cfg {
|
||||
struct stm32_gpio drdy;
|
||||
struct stm32_exti eoc_exti;
|
||||
struct stm32_irq eoc_irq;
|
||||
|
||||
uint8_t Fifo_store; /* FIFO storage of different readings (See datasheet page 31 for more details) */
|
||||
uint8_t Smpl_rate_div; /* Sample rate divider to use (See datasheet page 32 for more details) */
|
||||
uint8_t interrupt_cfg; /* Interrupt configuration (See datasheet page 35 for more details) */
|
||||
uint8_t interrupt_en; /* Interrupt configuration (See datasheet page 35 for more details) */
|
||||
uint8_t User_ctl; /* User control settings (See datasheet page 41 for more details) */
|
||||
uint8_t Pwr_mgmt_clk; /* Power management and clock selection (See datasheet page 32 for more details) */
|
||||
enum pios_mpu6050_range gyro_range;
|
||||
enum pios_mpu6050_filter filter;
|
||||
};
|
||||
|
||||
/* Public Functions */
|
||||
extern void PIOS_MPU6050_Init(const struct pios_mpu6050_cfg * cfg);
|
||||
extern int32_t PIOS_MPU6050_ReadFifo(struct pios_mpu6050_data * buffer);
|
||||
extern int32_t PIOS_MPU6050_ReadGyros(struct pios_mpu6050_data * buffer);
|
||||
extern int32_t PIOS_MPU6050_ReadID();
|
||||
extern uint8_t PIOS_MPU6050_Test();
|
||||
extern float PIOS_MPU6050_GetScale();
|
||||
|
||||
#endif /* PIOS_MPU6050_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
@ -2,12 +2,12 @@
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_BMP085 BMP085 Functions
|
||||
* @addtogroup PIOS_MS5611 MS5611 Functions
|
||||
* @brief Hardware functions to deal with the altitude pressure sensor
|
||||
* @{
|
||||
*
|
||||
* @file pios_ms5611.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @brief MS5611 functions header.
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
|
@ -219,7 +219,6 @@
|
||||
65904ECC14613B6100FD9482 /* pios_hmc5883.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_hmc5883.c; sourceTree = "<group>"; };
|
||||
65904ECD14613B6100FD9482 /* pios_i2c.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_i2c.c; sourceTree = "<group>"; };
|
||||
65904ECE14613B6100FD9482 /* pios_iap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_iap.c; sourceTree = "<group>"; };
|
||||
65904ECF14613B6100FD9482 /* pios_imu3000.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_imu3000.c; sourceTree = "<group>"; };
|
||||
65904ED014613B6100FD9482 /* pios_irq.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_irq.c; sourceTree = "<group>"; };
|
||||
65904ED114613B6100FD9482 /* pios_led.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_led.c; sourceTree = "<group>"; };
|
||||
65904ED214613B6100FD9482 /* pios_ppm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_ppm.c; sourceTree = "<group>"; };
|
||||
@ -2870,7 +2869,6 @@
|
||||
65C35F6612F0DC2D004811C2 /* attitude.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = attitude.c; sourceTree = "<group>"; };
|
||||
65C35F6812F0DC2D004811C2 /* attitude.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = attitude.h; sourceTree = "<group>"; };
|
||||
65D1FBD413F504C9006374A6 /* pios_hmc5883.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_hmc5883.h; sourceTree = "<group>"; };
|
||||
65D1FBDA13F51AE1006374A6 /* pios_imu3000.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_imu3000.h; sourceTree = "<group>"; };
|
||||
65D1FBE713F53477006374A6 /* pios_bl_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_bl_helper.h; sourceTree = "<group>"; };
|
||||
65D2CA841248F9A400B1E7D6 /* mixersettings.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = mixersettings.xml; sourceTree = "<group>"; };
|
||||
65D2CA851248F9A400B1E7D6 /* mixerstatus.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = mixerstatus.xml; sourceTree = "<group>"; };
|
||||
@ -3331,14 +3329,12 @@
|
||||
65FA9B71147087020019A260 /* STM32F4xx_Revolution.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = STM32F4xx_Revolution.h; sourceTree = "<group>"; };
|
||||
65FA9B77147095D40019A260 /* attitude.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = attitude.c; sourceTree = "<group>"; };
|
||||
65FA9B79147095D40019A260 /* attitude.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = attitude.h; sourceTree = "<group>"; };
|
||||
65FA9B7A14709E700019A260 /* pios_mpu6050.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_mpu6050.c; sourceTree = "<group>"; };
|
||||
65FA9B7B14709E9E0019A260 /* pios_board_info.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_board_info.h; sourceTree = "<group>"; };
|
||||
65FA9B7C14709E9E0019A260 /* pios_gcsrcvr_priv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_gcsrcvr_priv.h; sourceTree = "<group>"; };
|
||||
65FA9B7D14709E9E0019A260 /* pios_hcsr04.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_hcsr04.h; sourceTree = "<group>"; };
|
||||
65FA9B7E14709E9E0019A260 /* pios_i2c_esc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_i2c_esc.h; sourceTree = "<group>"; };
|
||||
65FA9B7F14709E9E0019A260 /* pios_iap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_iap.h; sourceTree = "<group>"; };
|
||||
65FA9B8014709E9E0019A260 /* pios_initcall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_initcall.h; sourceTree = "<group>"; };
|
||||
65FA9B8114709E9E0019A260 /* pios_mpu6050.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_mpu6050.h; sourceTree = "<group>"; };
|
||||
65FA9B8214709E9E0019A260 /* pios_ppm_priv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_ppm_priv.h; sourceTree = "<group>"; };
|
||||
65FA9B8314709E9E0019A260 /* pios_tim_priv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_tim_priv.h; sourceTree = "<group>"; };
|
||||
65FA9B8414709E9F0019A260 /* pios_tim.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_tim.h; sourceTree = "<group>"; };
|
||||
@ -3913,11 +3909,9 @@
|
||||
65904ECC14613B6100FD9482 /* pios_hmc5883.c */,
|
||||
65904ECD14613B6100FD9482 /* pios_i2c.c */,
|
||||
65904ECE14613B6100FD9482 /* pios_iap.c */,
|
||||
65904ECF14613B6100FD9482 /* pios_imu3000.c */,
|
||||
65904ED014613B6100FD9482 /* pios_irq.c */,
|
||||
65904ED114613B6100FD9482 /* pios_led.c */,
|
||||
6534B5581474F7B1003DF47C /* pios_mpu6000.c */,
|
||||
65FA9B7A14709E700019A260 /* pios_mpu6050.c */,
|
||||
65FAB9071481F9F6000FF8B2 /* pios_ms5611.c */,
|
||||
65904ED214613B6100FD9482 /* pios_ppm.c */,
|
||||
65FAB8FD1480DA19000FF8B2 /* pios_pwm.c */,
|
||||
@ -8578,13 +8572,11 @@
|
||||
65E8F04311EFF25C00BBF654 /* pios_i2c.h */,
|
||||
65FA9B7E14709E9E0019A260 /* pios_i2c_esc.h */,
|
||||
6526645A122DF972006F9A3C /* pios_i2c_priv.h */,
|
||||
65D1FBDA13F51AE1006374A6 /* pios_imu3000.h */,
|
||||
65FA9B8014709E9E0019A260 /* pios_initcall.h */,
|
||||
65E8F04411EFF25C00BBF654 /* pios_irq.h */,
|
||||
65E8F04511EFF25C00BBF654 /* pios_led.h */,
|
||||
6534B55B1476D3A8003DF47C /* pios_ms5611.h */,
|
||||
6534B5571474F78B003DF47C /* pios_mpu6000.h */,
|
||||
65FA9B8114709E9E0019A260 /* pios_mpu6050.h */,
|
||||
65E8F04611EFF25C00BBF654 /* pios_opahrs.h */,
|
||||
65E8F04711EFF25C00BBF654 /* pios_opahrs_proto.h */,
|
||||
65E8F04811EFF25C00BBF654 /* pios_ppm.h */,
|
||||
|
Loading…
x
Reference in New Issue
Block a user