uchiy1320
(Keigo Uchiyama)
November 25, 2020, 10:13am
1
Hi, I’m about to connect raspberry pi 4 as master and MAX32630FTHR as slave with I2C.
However, in MAX32630FTHR, it was outputted the message ; “Error: Identifier “I2CSlave” is undefined in “main.cpp”, Line: 14, Col: 2”.
I wrote definitely “#include “mbed.h””.
The photograph below is the error message.
targets device : MAX32630FTHR (as slave)
version of Mbed OS : 5.11.5 (online compiler)
Do you know anything about it?
JohnnyK
(Jan Kamidra)
November 25, 2020, 10:44am
2
Hello,
how you can see below, this feature is not enabled for this target for some reason. That mean "I2CSalve"
is missing under tag "device_has"
.
"core": "Cortex-M4F",
"macros": [
"__SYSTEM_HFX=96000000",
"TARGET=MAX32630",
"TARGET_REV=0x4132",
"BLE_HCI_UART",
"OPEN_DRAIN_LEDS"
],
"extra_labels": ["Maxim", "MAX32630"],
"supported_toolchains": ["GCC_ARM", "IAR", "ARM"],
"device_has": [
"ANALOGIN",
"I2C",
"INTERRUPTIN",
"LPTICKER",
"PORTIN",
"PORTINOUT",
"PORTOUT",
"PWMOUT",
"SERIAL",
"SERIAL_FC",
You can try to add that via the mbed_app.json via
{
"target_overrides": {
"*": {
"target.device_has_add": ["I2CSlave"]
}
}
}
but if it is not supported/ implemented, that will not help you.
BR, Jan
1 Like
uchiy1320
(Keigo Uchiyama)
November 25, 2020, 12:36pm
3
Thank you very much for kind reply.
I tried to add the mbeda_app.json that your advice.
However, the same error occurs. Maybe it is unsupported by the online compiler I’m using?
JohnnyK
(Jan Kamidra)
November 25, 2020, 1:44pm
4
I do not think that issue is in the context with the Online compiler.
A piece of code, what connect Mbed I2CSlave API with Maxim’s HAL drivers, is probably missing from Maxim’s side.
BR, Jan
uchiy1320
(Keigo Uchiyama)
December 1, 2020, 6:37am
5
Could it be that I have no choice but to give up…?
uchiy1320
(Keigo Uchiyama)
December 9, 2020, 11:43am
7
Thank you very much for kind reply, BR, Jan.
I have tried to do based on your advice as slave as Arduino Nano Every and master as MAX32630FTHR. It’s i2c ommunication properly . However, Communication exceeding 128 bytes happened character corruption.
Below are the errors at that time. (Screen Commands)
I want to communicate beyond 128 bytes, is there a better way?
main.cpp (MAX32630FTHR)
#include "mbed.h"
#include "max32630fthr.h"
#include <stdio.h>
#define SDA P5_7
#define SCL P6_0
MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
I2C i2c(SDA, SCL);
int main()
{
printf("---------------------------------------------------\r\n");
int ArduinoAddress7bit = 0x08; //arduinoIDE内のarudinoのアドレス
int ArduinoAddress8bit = ArduinoAddress7bit << 1; // ArduinoAddress7bit * 2 mbed内のarduinoのアドレス
printf("ArduinoAddress8bit : %d\r\n", ArduinoAddress8bit); // 0x08なら16
int val;
int key;
printf("I2CProgramm Start\r\n");
char buff[256];
while(1) {
key = getchar();
printf("input key:%c\r\n", key);
i2c.read(ArduinoAddress8bit,buff,sizeof(buff));
//printf("%d, ",buff[0]);
//printf("%d \r\n",buff[1]);
printf("%d \r\n", sizeof(buff));
printf("%s \r\n", buff);
wait(1);
}
}
I2C_Slave.ino (Arduino Nano Every)
//SDA = A4
//SCL = A5
#include <Arduino.h>
#include <Wire.h>
#define THIS_ADDRESS 0x08
static byte sendmsg[] = "{'id': '01', 'class': 'human_front', 'avg_num': 2.2, 'date': '1605364660851.57', 'temperature_min': 14.87, 'temperature_max': 32.42}";
static int sendmsgsize = 0;
void setup() {
Wire.begin(THIS_ADDRESS);
pinMode(A4, INPUT); // disable pullup
pinMode(A5, INPUT); // disable pullup
Wire.onRequest(requestEvent);
Serial.begin(9600);
Serial.println("STARTUP -- OK!");
}
void loop() {
// delay(1000);
}
void requestEvent() {
sendmsgsize = sizeof(sendmsg);
Serial.print("sendmsgsize : ");
Serial.println(sendmsgsize);
for(int i = 0; i < sizeof(sendmsg); i++){
Wire.write(sendmsg[i]);
}
}