0
votes

I need to know how to use UART interrupt in MicroEJ(when data receive ,do my job) . I dont want use a thread with while(true) (forever loop) to read input stream. we have these functions in C

LLCOMM_UART_callback and LLCOMM_BUFFERED_CONNECTION_dataReceived

//main uart interrupt

void USART6_IRQHandler(void)
{
    LLCOMM_UART_callback(&LLCOMM_UARTs[UART6_INDEX]);
}
/* Interrupt callback --------------------------------------------------------*/
void LLCOMM_UART_callback(LLCOMM_UART* llcomm)
{
    // retrieve LLCOM environment for given comIndex
    LLCOMM_BUFFERED_CONNECTION* env = &llcomm->header;
    UART_HandleTypeDef* handle = &llcomm->hal_uart_handle;

    uint8_t leave = interrupt_enter();

    // check RX
    if (__HAL_UART_GET_IT(handle, UART_IT_RXNE))
    {
        // read data, clear the interrupt and send data to MicroEJ framework
        LLCOMM_BUFFERED_CONNECTION_dataReceived(env, handle->Instance->RDR);
    }
}

but i cant find how to implement these interface to java ?

the 2nd part is how to use input pins interrupt and interface them to java? is there any API for this??

Thanks

1
There are several libraries for the use of serial ports in java. See: stackoverflow.com/questions/900950/…B.Letz
Sry, I guess I misread your question. Hope you'll get helpful answers soon.B.Letz
No pb , do you know to how to use interface(like what we have in java classes) in c to call a java interface? @B.LetzBiftor

1 Answers

2
votes

Implementing the LLCOM_UART native interface will allow you to use ECOM COMM in Java.

The UART interrupt is handled by the underlying BSP (in C) caching the data received in a buffer until the Java thread is awake to get back the data of the read. So there is no choice between an interrupt handling or a "loop forever", it is:

  • interrupt handling in C, data read then cached into a buffer
  • Java thread periodically waking up and checking if there is data in the buffer

Pins configuration and interrupts handling for UART are not done in Java but in C at the BSP level, using the UART in Java only as a Java stream.

You can find an example of use of the Java comm connectors in our GitHub [1].

As for implementing the LL_UART C side you can take a look at how it was done for an existing platform [2]. Inside the archive you will find an implementation of BSP for STM32F7476G-DISCO, this BSP contains a LL_UART implementation (in platformSource\STM32F746GDISCO-846SI-platformSource.zip\STM32F746GDISCO-846SI-3.1.5-bsp\Projects\STM32746G-Discovery\Applications\MicroEJ\src-comm).

For GPIOs a HAL library exists [3].

Gaëtan

[1] https://github.com/MicroEJ/Example-Standalone-Foundation-Libraries/tree/master/com.microej.example.foundation.ecom.reader

[2] http://developer.microej.com/packages/referenceimplementations/846SI/3.1.5/STM32F746GDISCO-846SI-fullPackaging-eval-3.1.5.zip

[3] https://developer.microej.com/javadoc/microej_4.1/foundation/ej/hal/gpio/package-summary.html