You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am new to Betaflight. I want to use a board that I built myself some time ago. But to do this, I need to add a gyro driver for the a3g4250d. I am using Betaflight 4.5.0-RC2 and have tried the following so far:
I added accgyro_a3g4250d.c/h in src/main/drivers/accgyro and added the neccessary define USE_GYRO_A3G4250D. In these files there are 3 functions. a3g4250dInit, a3g4250dRead and a3g4250dDetect.
In gyro_init.c I added a switch case in the gyroDetect function in order to call the a3g4250dDetect function for my driver:
#ifdef USE_GYRO_A3G4250D
case GYRO_A3G4250D:
if (a3g4250dDetect(dev)) {
gyroHardware = GYRO_A3G4250D;
break;
}
FALLTHROUGH;
#endif
I also added USE_GYRO_A3G4250D in the enum of the supported gyros.
This is my config.h for my custom board:
/*
* This file is part of Betaflight.
*
* Betaflight is free software. You can redistribute this software
* and/or modify this software 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.
*
* Betaflight 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 software.
*
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#define FC_TARGET_MCU STM32F411
#define BOARD_NAME IBRNODE
#define MANUFACTURER_ID IBR
#define USE_ACC
#define USE_ACC_SPI_MPU6000
#define USE_GYRO
#define USE_GYRO_SPI_MPU6000
#define USE_GYRO_A3G4250D
#define UART1_TX_PIN PA9
#define UART1_RX_PIN PA10
#define UART2_TX_PIN PA2
#define UART2_RX_PIN PA3
#define I2C1_SCL_PIN PB8
#define I2C1_SDA_PIN PB9
#define SPI1_SCK_PIN PA5
#define SPI1_SDI_PIN PA6
#define SPI1_SDO_PIN PA7
#define TIMER_PIN_MAPPING \
TIMER_PIN_MAP( 0, PA3 , 3, -1) \
TIMER_PIN_MAP( 1, PB4 , 1, 0) \
TIMER_PIN_MAP( 2, PB5 , 1, 0) \
TIMER_PIN_MAP( 3, PB6 , 1, 0) \
TIMER_PIN_MAP( 4, PB7 , 1, 0) \
TIMER_PIN_MAP( 5, PB3 , 1, 0) \
TIMER_PIN_MAP( 6, PB10, 1, 0) \
TIMER_PIN_MAP( 7, PA0 , 2, 0) \
TIMER_PIN_MAP( 8, PA2 , 2, 0) \
TIMER_PIN_MAP( 9, PA8 , 1, 0)
#define SYSTEM_HSE_MHZ 8
#define MSP_UART SERIAL_PORT_USART2
There is not much there at the moment, just the necessary instructions to make the gyro work. (I think so :D) I left the define for the MPU6000 in there because if I remove it, I get build errors:
%% (optimised) ./src/main/drivers/stm32/dma_reqmap_mcu.c
./src/main/drivers/accgyro/accgyro_mpu.c:157:13: error: static declaration of 'mpuIntExtiHandler' follows non-static declaration
157 | static void mpuIntExtiHandler(extiCallbackRec_t *cb)
| ^~~~~~~~~~~~~~~~~
In file included from ./src/main/drivers/accgyro/accgyro.h:30,
from ./src/main/drivers/accgyro/accgyro_mpu.c:45:
./src/main/drivers/accgyro/accgyro_mpu.h:236:6: note: previous declaration of 'mpuIntExtiHandler' was here
236 | void mpuIntExtiHandler(extiCallbackRec_t *cb);
| ^~~~~~~~~~~~~~~~~
%% (optimised) ./src/main/drivers/stm32/dma_stm32f4xx.c
make[1]: *** [Makefile:439: obj/main/STM32F411_IBRNODE/drivers/accgyro/accgyro_mpu.o] Error 1
make[1]: *** Waiting for unfinished jobs....
%% (optimised) ./src/main/drivers/stm32/dshot_bitbang.c
make[1]: Leaving directory '/home/riot/Desktop/betaflight-4.5.0-RC2'
make: *** [Makefile:556: hex] Error 2
The next question is, how can I set a specific pin to low? On my board is a STM32F411RET6 and I want to set PORTC 11 to low. I have tryed that: GPIO_WriteBit(GPIOC, GPIO_Pin_11, Bit_RESET); so far (as you can see above in the a3g4250dInit function). I need to do this because a mosfet is turning the a3g4250d on if this pin is low. If it's high, it is off.
Building the project runs without errors, but the gyroscope is not recognised in Betaflight. What am I doing wrong, or what am I overlooking? Maybe the problem is just switching on the pin and then everything works... Any help is very appreciated.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I am new to Betaflight. I want to use a board that I built myself some time ago. But to do this, I need to add a gyro driver for the a3g4250d. I am using Betaflight 4.5.0-RC2 and have tried the following so far:
I added accgyro_a3g4250d.c/h in src/main/drivers/accgyro and added the neccessary define
USE_GYRO_A3G4250D
. In these files there are 3 functions. a3g4250dInit, a3g4250dRead and a3g4250dDetect.My a3g4250dInit function looks like this:
Since I don't want to add this target to the repository and only use it for myself, I statically defined the I2CDEV_1 in here.
My a3g4250dDetect function looks like this:
In gyro_init.c I added a switch case in the
gyroDetect
function in order to call the a3g4250dDetect function for my driver:I also added
USE_GYRO_A3G4250D
in the enum of the supported gyros.This is my config.h for my custom board:
There is not much there at the moment, just the necessary instructions to make the gyro work. (I think so :D) I left the define for the MPU6000 in there because if I remove it, I get build errors:
The next question is, how can I set a specific pin to low? On my board is a STM32F411RET6 and I want to set PORTC 11 to low. I have tryed that:
GPIO_WriteBit(GPIOC, GPIO_Pin_11, Bit_RESET);
so far (as you can see above in the a3g4250dInit function). I need to do this because a mosfet is turning the a3g4250d on if this pin is low. If it's high, it is off.Building the project runs without errors, but the gyroscope is not recognised in Betaflight. What am I doing wrong, or what am I overlooking? Maybe the problem is just switching on the pin and then everything works... Any help is very appreciated.
Beta Was this translation helpful? Give feedback.
All reactions