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
undefined reference to `i2c_start' when trying to use mbed I2C #28
Comments
|
Hi! @maxgerhardt, its like below:
|
I can't reproduce this with an I2C slave sketch #include <Arduino.h>
#include <Wire.h>
void I2C_ReveiceCB(int numBytes)
{
int I2C_OnOff = Wire.read();
if (I2C_OnOff == 1)
{
digitalWrite(LED_BUILTIN, HIGH);
}
else if (I2C_OnOff == 0)
{
digitalWrite(LED_BUILTIN, LOW);
}
}
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
Wire.begin(1);
Wire.onReceive(I2C_ReveiceCB);
}
void loop() { delay(1000); }
|
Hi! I realize that I might not have been clear; I use the mbed I2C.h/I2Cslave.h implementation, not Wire.h. So I am instead using i2c_start and other of But the implementation of i2c_start seems to be missing. It is commonly used in other contexts, and it seems Wire.h also uses it in some way, but have some own implementation, which seem hidden. Additionally, by going lower level, I might also find out what is wrong with Wire.h inside requests. |
Can you post a minimal piece of code that reproduces the compiler error? You might just have a problem as simple as forgetting to |
I am realizing that I am having trouble resetting everything to that state, I just moved all MCU:s around here and did some inventive branching. :-) |
Ok, now for some reason the RPI Pico won't give a serial connection in pio test with unity for some reason. I will try and solve that and then get back on this one. |
Non-existing USB serial port could also be an indication that the (test) firmware straight up crashed the board. Does it still work in an absolute minimal project? |
Yeah, I am looking into that now. |
@maxgerhardt I just remembered that running unit testing on the RPI was problematic, and that I had to use a custom runner because the mbed runner conflicted. |
With the Arduino-Pico core, which is the entire point of this repo, it works without problems when you wait for Serial connection to be established Just create #include <Arduino.h>
#include <unity.h>
void setUp(void) {
// set stuff up here
}
void tearDown(void) {
// clean stuff up here
}
int function_under_test(int a, int b) {
return a + b;
}
void test_calculator_addition(void) {
TEST_ASSERT_EQUAL(32, function_under_test(25, 7));
}
void setup() {
UNITY_BEGIN();
// wait for serial monitor to be connected, however long it may take.
while(!Serial) delay(10);
RUN_TEST(test_calculator_addition);
UNITY_END();
}
void loop() {
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
delay(100);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
}
|
Let me double check mbed, because I know there was platformio/platformio-core#3980. |
That's where it was! I have fought with so many platforms and boards lately that I've started to mix them up. :-) |
Wow I may have Alzheimers, the Pico in Arduino-Pico and ArduinoCore-mbed unit testing core issues we've already discussed there last month, so it should still work. |
OK. For some reason, that fix seems to have stopped working for me. |
It was parts of the testing suites that caused it to crash. Also the RPI Pico W seems to crash my other modules, not sure how it does it yet, power draw is one possibility. Anyway, back on the subject; I still get the undefined reference to i2c_start when I call mbed::I2C start();
I have tried without start(), but it doesn't seem to send things properly then. Basically I am trying to use I2C.h in .platformio/framework-arduino-mbed/cores/arduino/mbed/drivers/include/drivers/I2C.h Edit: Interestingly, stop() seems to be implemented. |
Yeah I can reproduce that error. #include <Arduino.h>
#include "mbed/mbed.h"
#include "mbed_wait_api.h"
using namespace mbed;
void setup() {
I2C* i2c_master = new I2C(p8, p9); //GP8, GP9
i2c_master->start();
}
void loop() {
} [env]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
framework = arduino
board_build.filesystem_size = 1m
[env:pico_arduino_mbed]
board = pico You can see the ArduinoCore-mbed's When So the issue is clear form the C++ code above: The void setup() {
I2C* i2c_master = new I2C(p8, p9); //GP8, GP9
uint8_t data[] = {0x13, 0x37};
i2c_master->write(0xAB, (const char*) data, (int) sizeof(data));
} For I2C salves, the void setup() {
I2CSlave* i2c_slave = new I2CSlave(p8, p9); //GP8, GP9
i2c_slave->address(0x12);
} |
That is not that API, that is thread.start() I believe?
Actually I haven't gotten the RPI Pico to work properly with Wire now for some reason. |
Right, that's a remnant from the edit, I thought that in the beginning but recognized otherwise afterwards. The And since you got Wire working I think we can close the issue. |
I actually haven't got that working, the slave responses aren't reaching the master, however that is probably another issue, this is about me not being able to use wire for my purposes and therefore using the mbed implementation. I understand that you might not feel that is a part of the offering, so to say, but if there is no way forward, there is no point in having it open. |
Hi!
I am having problems with using the event based implementation in wire.h, mainly I have problems getting the slave/peripheral on an Raspberry Pi Pico W (Arduino) replying to the ESP32 master/controllers request. All other directions work but that doesn't. Also the interrupt-event-based implementation makes the timing difficult and a more generalized implementation messy.
So now I am trying to use the mbed I2C/I2Cslave implementation which seems quite nifty (no sure what Wire.h actually brings except from the interrupt-events and some minor abstractions) but something seem to be missing.
I am getting this error when building:
Any ideas?
The text was updated successfully, but these errors were encountered: