Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MatekF411/Tyro79 - i2c2 works on betaflight but not emuflight #702

Open
MATH3U5 opened this issue Sep 11, 2021 · 5 comments
Open

MatekF411/Tyro79 - i2c2 works on betaflight but not emuflight #702

MATH3U5 opened this issue Sep 11, 2021 · 5 comments

Comments

@MATH3U5
Copy link

MATH3U5 commented Sep 11, 2021

I working on Tyro79FC , is a Eachine STRM32F411ce flight controller. It is full compatible with the MatekF411 target, but SDA and SCL pins are not exposed on the board. I would like to add a BMP280 barometer for altitude hold .According to the datasheet I should be able to use the S5 pad from PB03 as i2c2 SDA; and the S6 pad from PB10 as i2c2 SCL.

I know my wiring and port numbers are correct and get sucess in getting the barometer to working on i2c2 using these pins in betaflight with the stock MatekF411 firmware and remaping the pins using betaflight's resource mapping.

I get sucess in betaflight with this commands, and response all ok in status and sensors output:

betaflight sucess steps for barometer.txt

resource I2C_SCL 2 B10
resource I2C_SDA 2 B03
set baro_i2c_device = 2
set baro_hardware = BMP280
and get baro for confirm

In Emufligh, barometer does not detect any barometer. Even defining barometer to BMP280. i2c speeds no makes any difference.

I tested all versions of Emuflight until the last one and all firmwares until the last, but all giving me the same result, no baro.

Betaflight with status,resource and dump:

[BTFL_cli_M_20210910_231257.txt]
(https://github.com/emuflight/EmuFlight/files/7147058/BTFL_cli_M_20210910_231257.txt)

Emuflight with status,resource,dump and get baro:

[EMUF_cli_20210910_232249.txt]
(https://github.com/emuflight/EmuFlight/files/7147062/EMUF_cli_20210910_232249.txt)

Thanks in advance for any help you can offer.

Also wanted to say thanks to all person was work so hard to make Emuflight. Is incredible how this is so smooth in my quads, movements and maneuvers is executed with class!

@nerdCopter
Copy link
Member

nerdCopter commented Sep 15, 2021

@MATH3U5 , you could try this... no guarantees. I hard-coded those resources you listed. if it works, this is not really a solution that we can merge to master-code.

EmuFlight_0.4.0_MATEKF411_Build_uncommitted_20210915CDT__hard_coded_baro.hex.zip

or maybe this one: EmuFlight_0.4.0_MATEKF411_Build_uncommitted_20210915CDT__another_attempt__hard_coded_baro.hex.zip

p.s. Emu does not have altitude hold.

nerdCopter added a commit to nerdCopter/EmuFlight_nerdRepo that referenced this issue Sep 15, 2021
nerdCopter added a commit to nerdCopter/EmuFlight_nerdRepo that referenced this issue Sep 15, 2021
@MATH3U5
Copy link
Author

MATH3U5 commented Sep 20, 2021

Oh, thanks, in this days i learned some of build custom targets, and solved the problem, but i I forgot to send here rsrs, i will upload, but is the same code basicly, no difference, yet anyway thanks, but it's a pity and sad, the emuflight is the best firmware we i use( i am want not fawning over, but is the reality), and have the best results in my quads, and the most static hover, detail, without any GPS, equal a dji phantom or Mavic, but the unique variation is of alt hold, is interessing the implementation of alt hold, I leave this as a suggestion, because the inav is a little complicated os configure and use, is much information.

EmuFlight_0.4.0_MATEKF411_Build_uncommitted_20210912-03.zip

and annexing target.h because is more useful for community

MATEKF411-target.h.zip

@nerdCopter
Copy link
Member

nerdCopter commented Sep 20, 2021

@MATH3U5 , Do you think this code is valid for only your issue, or should it be part of master-code?
if the latter, then could you make a pull-request with the modified file?

-#define USE_I2C_DEVICE_1
-#define I2C_DEVICE              (I2CDEV_1)
-#define I2C1_SCL                PB8        // SCL pad
-#define I2C1_SDA                PB9        // SDA pad
-#define BARO_I2C_INSTANCE       (I2CDEV_1)
+#define USE_I2C_DEVICE_2
+#define I2C_DEVICE              (I2CDEV_2)
+#define I2C2_SCL                PB10        // SCL pad
+#define I2C2_SDA                PB3        // SDA pad
+#define BARO_I2C_INSTANCE       (I2CDEV_2)

@nerdCopter
Copy link
Member

nerdCopter commented Sep 20, 2021

i wonder if both I2C1 & i2C2 could be defined at the same time, would this also solve the problem?

@Kaiowarez , any insight on this?

@MATH3U5
Copy link
Author

MATH3U5 commented Oct 26, 2021

@nerdCopter Hello again, after lot of days of all time rain, i stopped with test and codes, returning now, I believe it has to be part of the master code, because nobody use a FC with only 2 uarts for a hex, this tyro79 controller is very limited, only rx, smartaudio and at most a gps, nothing else.

I tested setting it at the same time, in the same way as your lines of code, but barometer was not recognized, it is only recognized using I2C2,

./src/main/target/MATEKF411/target.h:73: warning: "I2C_DEVICE" redefined
73 | #define I2C_DEVICE (I2CDEV_1)
|
./src/main/target/MATEKF411/target.h:67: note: this is the location of the previous definition
67 | #define I2C_DEVICE (I2CDEV_2)
|
./src/main/target/MATEKF411/target.h:76: warning: "BARO_I2C_INSTANCE" redefined
76 | #define BARO_I2C_INSTANCE (I2CDEV_1)
|
./src/main/target/MATEKF411/target.h:70: note: this is the location of the previous definition
70 | #define BARO_I2C_INSTANCE (I2CDEV_2)

A little log of the cygwin compilation, every compilation is a loop of these messages, but it was compiled, but as I said, it was not recognized by Emuf. I will make a pull request of this problem, but before that, I wanted to see something if I don't know if it is a bug in the program or something soft, when I define the smart audio to the RSSI pad to leave the UART2 free for gps, setting the RX and TX pins of the softserial 1 via code with these settings

#define USE_SOFTSERIAL1
#define SOFTSERIAL_1_TX_PIN PA2
#define SOFTSERIAL_1_RX_PIN PA3

is not recognized and does not appear in the ports tab, but when I redefine by CLI with resource SERIAL_TX 11 A00, it works successfully, everything appears in the ports tab.

Happy Hacktoberfest!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants