Serial::RxIrq doesn't work

I want to display my terminal via Nucleo-32 f303k8.
So I wrote my code as below.

#include "mbed.h"

Serial pc(USBTX, USBRX  ); // tx, rx
Serial device(D5, D4 );  // tx, rx
 
void pc_rx () {
    pc.printf("pc_rx\n\r");
    device.putc(pc.getc());
}
 
void dev_rx () {
    pc.printf("dev_rx\n\r");
    pc.putc(device.getc());
}

int main() {
    
    pc.attach(pc_rx, Serial::RxIrq);
    device.attach(dev_rx, Serial::RxIrq);
    
    while(1);
    
}

I thought that it works as below when I put “c”

pc_rx
dev_rx
c

But, there is displayed only

pc_rx

I think that RxIrq is not working.

I changed Serial to RawSerial with reference to [Serial callback not working], but it was not working too.

How can I work RxIrq…

I changed my code as below.

#include "mbed.h"
#include "Serial.h"

RawSerial pc(USBTX, USBRX  ); // tx, rx
RawSerial device(D5, D4 );  // tx, rx
 
void dev_rx () {
    pc.printf("dev_rx\n\r");
    pc.putc(device.getc());
}

int main() {
    device.attach( &dev_rx, Serial::RxIrq);   
    while(1) device.putc(pc.getc());
    
}

But, It is not working…

Also, I changed ( D5 , D4 ) to (D1 , D0 ).
But, It is also not working…

Can’t GPIO_PIN use RxIrq…?

Ahoj,
I not understand what exactly you want to achieve and how you have it connected but…

Your “device” I connected to a ftdi usb ttl converter. Both (The Nucleo and The FTDI) I connected to the PC via USB and on the desktop I have open terminal for each one.

From my point of view code working well and exactly how it was written.
The “dev_rx” will occur only when a data will come from your “device”. In my case, when I send a char from The FTDI to the Nucleo. The “pc_rx” will occur when it will be vice versa, from the Nucleo to the FTDI. The sended char will be always on the opposite side.

BR, Jan

PS: The Serial callback issue occurs only with full Mbed OS5 and not with the Mbed OS5 bare metal profile (that is without RTOS functionality and that mean no mutexes are applied). Bare metal is the only one possibility how is possible to use NUCLEO-F303K8 with latest version of the MbedOS5, because the board have not enough of memory.

Thanks JohnnyK.

“Bare metal is the only one possibility how is possible to use NUCLEO-F303K8 with latest version of the MbedOS5, because the board have not enough of memory.”
is what I wanted to know.

I want to try the implementation in Bare Metal.