1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-27 16:54:15 +01:00

Got CC running again although with altitude and bmp085 disabled as well as the

CC3D drivers.
This commit is contained in:
James Cotton 2012-01-24 10:32:42 -06:00
parent be50c00b7c
commit 486cdb5dbb
6 changed files with 49 additions and 37 deletions

View File

@ -118,7 +118,6 @@ SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c
SRC += $(PIOSCOMMON)/pios_board_info.c SRC += $(PIOSCOMMON)/pios_board_info.c
SRC += $(PIOSCOMMON)/pios_com_msg.c SRC += $(PIOSCOMMON)/pios_com_msg.c
SRC += $(PIOSCOMMON)/pios_bl_helper.c SRC += $(PIOSCOMMON)/pios_bl_helper.c
SRC += $(PIOSCOMMON)/pios_iap.c
SRC += $(PIOSCOMMON)/printf-stdarg.c SRC += $(PIOSCOMMON)/printf-stdarg.c
## Libraries for flight calculations ## Libraries for flight calculations

View File

@ -65,7 +65,7 @@ endif
FLASH_TOOL = OPENOCD FLASH_TOOL = OPENOCD
# List of modules to include # List of modules to include
OPTMODULES = CameraStab ComUsbBridge Altitude OPTMODULES = CameraStab ComUsbBridge # Altitude
ifeq ($(USE_GPS), YES) ifeq ($(USE_GPS), YES)
OPTMODULES += GPS OPTMODULES += GPS
endif endif
@ -225,11 +225,11 @@ SRC += $(PIOSCOMMON)/pios_crc.c
SRC += $(PIOSCOMMON)/pios_flashfs_objlist.c SRC += $(PIOSCOMMON)/pios_flashfs_objlist.c
SRC += $(PIOSCOMMON)/pios_flash_w25x.c SRC += $(PIOSCOMMON)/pios_flash_w25x.c
SRC += $(PIOSCOMMON)/pios_adxl345.c SRC += $(PIOSCOMMON)/pios_adxl345.c
SRC += $(PIOSCOMMON)/pios_l3gd20.c #SRC += $(PIOSCOMMON)/pios_l3gd20.c
SRC += $(PIOSCOMMON)/pios_bma180.c #SRC += $(PIOSCOMMON)/pios_bma180.c
SRC += $(PIOSCOMMON)/pios_com.c SRC += $(PIOSCOMMON)/pios_com.c
SRC += $(PIOSCOMMON)/pios_i2c_esc.c #SRC += $(PIOSCOMMON)/pios_i2c_esc.c
SRC += $(PIOSCOMMON)/pios_bmp085.c #SRC += $(PIOSCOMMON)/pios_bmp085.c
SRC += $(PIOSCOMMON)/pios_rcvr.c SRC += $(PIOSCOMMON)/pios_rcvr.c
SRC += $(PIOSCOMMON)/pios_gcsrcvr.c SRC += $(PIOSCOMMON)/pios_gcsrcvr.c
SRC += $(PIOSCOMMON)/printf-stdarg.c SRC += $(PIOSCOMMON)/printf-stdarg.c

View File

@ -36,10 +36,10 @@
/* Enable/Disable PiOS Modules */ /* Enable/Disable PiOS Modules */
#define PIOS_INCLUDE_ADC #define PIOS_INCLUDE_ADC
#define PIOS_INCLUDE_DELAY #define PIOS_INCLUDE_DELAY
#if defined(USE_I2C) //#if defined(USE_I2C)
#define PIOS_INCLUDE_I2C //#define PIOS_INCLUDE_I2C
#define PIOS_INCLUDE_I2C_ESC //#define PIOS_INCLUDE_I2C_ESC
#endif //#endif
#define PIOS_INCLUDE_IRQ #define PIOS_INCLUDE_IRQ
#define PIOS_INCLUDE_LED #define PIOS_INCLUDE_LED
#define PIOS_INCLUDE_IAP #define PIOS_INCLUDE_IAP
@ -75,11 +75,14 @@
#define PIOS_INCLUDE_BL_HELPER #define PIOS_INCLUDE_BL_HELPER
#define PIOS_INCLUDE_ADXL345 #define PIOS_INCLUDE_ADXL345
#define PIOS_INCLUDE_FLASH
/*
#define PIOS_INCLUDE_BMA180 #define PIOS_INCLUDE_BMA180
#define PIOS_INCLUDE_L3GD20 #define PIOS_INCLUDE_L3GD20
#define PIOS_INCLUDE_FLASH */
/*
#define PIOS_INCLUDE_BMP085 #define PIOS_INCLUDE_BMP085
*/
/* A really shitty setting saving implementation */ /* A really shitty setting saving implementation */
#define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS #define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS

View File

@ -1233,11 +1233,12 @@ void PIOS_Board_Init(void) {
/* Delay system */ /* Delay system */
PIOS_DELAY_Init(); PIOS_DELAY_Init();
#if defined(PIOS_INCLUDE_SPI)
/* Set up the SPI interface to the serial flash */ /* Set up the SPI interface to the serial flash */
if (PIOS_SPI_Init(&pios_spi_flash_accel_id, &pios_spi_flash_accel_cfg)) { if (PIOS_SPI_Init(&pios_spi_flash_accel_id, &pios_spi_flash_accel_cfg)) {
PIOS_Assert(0); PIOS_Assert(0);
} }
#endif
PIOS_Flash_W25X_Init(pios_spi_flash_accel_id, 1); PIOS_Flash_W25X_Init(pios_spi_flash_accel_id, 1);
PIOS_FLASHFS_Init(); PIOS_FLASHFS_Init();
@ -1733,18 +1734,19 @@ void PIOS_Board_Init(void) {
case 0x01: case 0x01:
// Revision 1 with invensense gyros, start the ADC // Revision 1 with invensense gyros, start the ADC
PIOS_ADC_Init(); PIOS_ADC_Init();
#if defined(PIOS_INCLUDE_ADXL345)
PIOS_ADXL345_Init(pios_spi_flash_accel_id, 0); PIOS_ADXL345_Init(pios_spi_flash_accel_id, 0);
#endif
break; break;
case 0x02: case 0x02:
// Revision 2 with L3GD20 gyros, start a SPI interface and connect to it // Revision 2 with L3GD20 gyros, start a SPI interface and connect to it
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
#if defined(PIOS_INCLUDE_L3GD20)
// Set up the SPI interface to the serial flash // Set up the SPI interface to the serial flash
if (PIOS_SPI_Init(&pios_spi_gyro_id, &pios_spi_gyro_cfg)) { if (PIOS_SPI_Init(&pios_spi_gyro_id, &pios_spi_gyro_cfg)) {
PIOS_Assert(0); PIOS_Assert(0);
} }
#if defined(PIOS_INCLUDE_L3GD20)
PIOS_L3GD20_Attach(pios_spi_gyro_id); PIOS_L3GD20_Attach(pios_spi_gyro_id);
PIOS_L3GD20_Init(&pios_l3gd20_cfg); PIOS_L3GD20_Init(&pios_l3gd20_cfg);
#endif /* PIOS_INCLUDE_L3GD20 */ #endif /* PIOS_INCLUDE_L3GD20 */

View File

@ -345,22 +345,24 @@ static int32_t updateSensors(AccelsData * accels, GyrosData * gyros)
* @param[in] attitudeRaw Populate the UAVO instead of saving right here * @param[in] attitudeRaw Populate the UAVO instead of saving right here
* @return 0 if successfull, -1 if not * @return 0 if successfull, -1 if not
*/ */
struct pios_bma180_data accel;
struct pios_l3gd20_data gyro;
static int32_t updateSensorsCC3D(AccelsData * accelsData, GyrosData * gyrosData) static int32_t updateSensorsCC3D(AccelsData * accelsData, GyrosData * gyrosData)
{ {
static portTickType lastSysTime; static portTickType lastSysTime;
int32_t read_good; uint32_t accel_samples = 0;
int32_t count = 0; uint32_t gyro_samples = 0;
bool error = false;
uint32_t accel_samples;
uint32_t gyro_samples;
int32_t accel_accum[3] = {0, 0, 0}; int32_t accel_accum[3] = {0, 0, 0};
int32_t gyro_accum[3] = {0,0,0}; int32_t gyro_accum[3] = {0,0,0};
float gyro_scaling; float gyro_scaling = 1;
float accel_scaling; float accel_scaling = 1;
while((read_good = PIOS_BMA180_ReadFifo(&accel)) != 0 && !error) #if defined(PIOS_INCLUDE_BMA180)
accel_samples = 0;
bool error = false;
int32_t accel_read_good;
struct pios_bma180_data accel;
while((accel_read_good = PIOS_BMA180_ReadFifo(&accel)) != 0 && !error)
error = ((xTaskGetTickCount() - lastSysTime) > 5) ? true : error; error = ((xTaskGetTickCount() - lastSysTime) > 5) ? true : error;
if (error) { if (error) {
// Unfortunately if the BMA180 ever misses getting read, then it will not // Unfortunately if the BMA180 ever misses getting read, then it will not
@ -372,33 +374,37 @@ static int32_t updateSensorsCC3D(AccelsData * accelsData, GyrosData * gyrosData)
return -1; return -1;
} }
while(read_good == 0) { while(accel_read_good == 0) {
count++; accel_samples++;
accel_accum[0] += accel.x; accel_accum[0] += accel.x;
accel_accum[1] += accel.y; accel_accum[1] += accel.y;
accel_accum[2] += accel.z; accel_accum[2] += accel.z;
read_good = PIOS_BMA180_ReadFifo(&accel); accel_read_good = PIOS_BMA180_ReadFifo(&accel);
} }
accel_samples = count;
accel_scaling = PIOS_BMA180_GetScale(); accel_scaling = PIOS_BMA180_GetScale();
#endif
count = 0; #if defined(PIOS_INCLUDE_L3GD20)
while((read_good = PIOS_L3GD20_ReadFifo(&gyro)) != 0 && !error) int32_t gyro_read_good;
error = ((xTaskGetTickCount() - lastSysTime) > 5) ? true : error; gyro_samples = 0;
while(read_good == 0) { struct pios_l3gd20_data gyro;
count++; bool gyro_error = false;
while(gyro_read_good = PIOS_L3GD20_ReadFifo(&gyro)) != 0 && !gyro_error)
gyro_error = ((xTaskGetTickCount() - lastSysTime) > 5) ? true : gyro_error;
while(gyro_read_good == 0) {
gyro_samples++;
gyro_accum[0] += gyro.gyro_x; gyro_accum[0] += gyro.gyro_x;
gyro_accum[1] += gyro.gyro_y; gyro_accum[1] += gyro.gyro_y;
gyro_accum[2] += gyro.gyro_z; gyro_accum[2] += gyro.gyro_z;
read_good = PIOS_L3GD20_ReadFifo(&gyro); gyro_read_good = PIOS_L3GD20_ReadFifo(&gyro);
} }
gyro_samples = count;
gyro_scaling = PIOS_L3GD20_GetScale(); gyro_scaling = PIOS_L3GD20_GetScale();
#endif
float accels[3] = {(float) accel_accum[1] / accel_samples, (float) accel_accum[0] / accel_samples, -(float) accel_accum[2] / accel_samples}; float accels[3] = {(float) accel_accum[1] / accel_samples, (float) accel_accum[0] / accel_samples, -(float) accel_accum[2] / accel_samples};

View File

@ -3059,6 +3059,7 @@
65E8F0EE11EFF25C00BBF654 /* startup_stm32f10x_HD.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = startup_stm32f10x_HD.S; path = ../../PiOS/STM32F10x/startup_stm32f10x_HD.S; sourceTree = SOURCE_ROOT; }; 65E8F0EE11EFF25C00BBF654 /* startup_stm32f10x_HD.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = startup_stm32f10x_HD.S; path = ../../PiOS/STM32F10x/startup_stm32f10x_HD.S; sourceTree = SOURCE_ROOT; };
65E8F0F111EFF25C00BBF654 /* startup_stm32f10x_MD.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = startup_stm32f10x_MD.S; path = ../../PiOS/STM32F10x/startup_stm32f10x_MD.S; sourceTree = SOURCE_ROOT; }; 65E8F0F111EFF25C00BBF654 /* startup_stm32f10x_MD.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = startup_stm32f10x_MD.S; path = ../../PiOS/STM32F10x/startup_stm32f10x_MD.S; sourceTree = SOURCE_ROOT; };
65EA2E171273C55200636061 /* ratedesired.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = ratedesired.xml; sourceTree = "<group>"; }; 65EA2E171273C55200636061 /* ratedesired.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = ratedesired.xml; sourceTree = "<group>"; };
65EC1DE214CF0D6A00EBE144 /* pios_gcsrcvr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_gcsrcvr.c; sourceTree = "<group>"; };
65F53D2E14984BB300A62D5D /* insgps_helper.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = insgps_helper.c; sourceTree = "<group>"; }; 65F53D2E14984BB300A62D5D /* insgps_helper.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = insgps_helper.c; sourceTree = "<group>"; };
65F53D2F14984BB300A62D5D /* insgps13state.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = insgps13state.c; sourceTree = "<group>"; }; 65F53D2F14984BB300A62D5D /* insgps13state.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = insgps13state.c; sourceTree = "<group>"; };
65F53D3014984BB300A62D5D /* insgps16state.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = insgps16state.c; sourceTree = "<group>"; }; 65F53D3014984BB300A62D5D /* insgps16state.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = insgps16state.c; sourceTree = "<group>"; };
@ -8390,6 +8391,7 @@
65E8F03011EFF25C00BBF654 /* Common */ = { 65E8F03011EFF25C00BBF654 /* Common */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
65EC1DE214CF0D6A00EBE144 /* pios_gcsrcvr.c */,
6528CCB412E406B800CF5144 /* pios_adxl345.c */, 6528CCB412E406B800CF5144 /* pios_adxl345.c */,
65FB1E6614CDBE26009C52B9 /* pios_bma180.c */, 65FB1E6614CDBE26009C52B9 /* pios_bma180.c */,
65FB1E6714CDBE26009C52B9 /* pios_bmp085.c */, 65FB1E6714CDBE26009C52B9 /* pios_bmp085.c */,