device-os icon indicating copy to clipboard operation
device-os copied to clipboard

RTL872x: Implement HAL event group for UART

Open XuGuohui opened this issue 2 years ago • 0 comments

Problem

For platforms, like TrackerM, rely on the UART HAL event group APIs, but they are not implemented yet.

Solution

Implements the UART HAL event group APIs. This PR also implements the UART HAL sleep API.

Example App

This test app is for verifying the HAL sleep API.

#include "Particle.h"

SYSTEM_MODE(MANUAL);
SYSTEM_THREAD(ENABLED);

#define SERIAL                  Serial2
#define SERIAL_INTERFACE        HAL_USART_SERIAL2

void setup() {
    SERIAL.begin(115200);
    pinMode(D11, INPUT_PULLUP);
}

void loop() {
    if (digitalRead(D11) == LOW) {
        delay(1s);
        SERIAL.printlnf("available1: %d", SERIAL.available());
        hal_usart_sleep(SERIAL_INTERFACE, true, nullptr);
        while (digitalRead(D11) == LOW);
        hal_usart_sleep(SERIAL_INTERFACE, false, nullptr);
        delay(1s);
        SERIAL.printlnf("available2: %d", SERIAL.available());
        while (SERIAL.available()) {
            SERIAL.write(SERIAL.read());
        }
        SERIAL.println(" ");
    }

    SERIAL.println("This is loop()");
    delay(1s);
}

References

N/A


Completeness

  • [x] User is totes amazing for contributing!
  • [x] Contributor has signed CLA (Info here)
  • [ ] Problem and Solution clearly stated
  • [ ] Run unit/integration/application tests on device
  • [ ] Added documentation
  • [ ] Added to CHANGELOG.md after merging (add links to docs and issues)

XuGuohui avatar Jul 27 '22 14:07 XuGuohui