Skip to content

This library implement Stream over UART based on STM32CubeMX HAL Driver

License

Notifications You must be signed in to change notification settings

Ali-Mirghasemi/UARTStream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

UART Stream Library

This library implement Stream over UART based on STM32CubeMX HAL Driver

How to use

Following instructions shows how to use it for USART1

  1. Configure UART in CubeMX and generate the code

    UART Must be in IT or DMA mode

  2. Define your UARTStream variable and initialize in main after UART init

    Global Area

    uint8_t rxBuf1[128];
    uint8_t txBuf1[128];
    UARTStream uart1;

    Main Function

    UARTStream_init(
        &uart1, &huart1,
        rxBuf1, sizeof(rxBuf1),
        txBuf1, sizeof(txBuf1)
    );
  3. Add UARTStream handle into callbacks

    void HAL_UART_RxCpltCallback(UART_HandleTypeDef* huart) {
        switch ((uint32_t) huart->Instance) {
            case USART1_BASE:
                UARTStream_rxHandle(&uart1);
                break;
            // you can add more UART here
        }
    }
    
    void HAL_UART_TxCpltCallback(UART_HandleTypeDef* huart) {
        switch ((uint32_t) huart->Instance) {
            case USART1_BASE:
                UARTStream_txHandle(&uart1);
                break;
            // you can add more UART here
        }
    }
  4. Start receive stream

    IStream_receive(&uart1.In);

References

Stream Library

About

This library implement Stream over UART based on STM32CubeMX HAL Driver

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages