Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rtl872x] SPI and UART HAL minor fix. #2757

Merged
merged 1 commit into from
Mar 13, 2024
Merged

Conversation

XuGuohui
Copy link
Member

@XuGuohui XuGuohui commented Mar 13, 2024

Problem

  1. SPI slave is busy once enabled
  2. Providing unaligned ring buffer for UART will result initialization failure

Solution

  1. Only check the busy status for SPI master mode
  2. Make sure the aligned size is smaller than the given buffer size

Steps to Test

  1. wiring/no_fixture_spi
  2. Run the attached test app

Example App

#include <iostream>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <memory>
#include <cstring>
#include <chrono>

uint8_t __attribute__((aligned(4))) buf[168];
size_t bufLen = sizeof(buf);

int main(int argc, char* argv[]) {
    void* pBuf = buf;
    size_t alignment = 32;
    size_t size = bufLen;
    
    void* newPtr = std::align(alignment, size, pBuf, bufLen);
    printf("PTR: %08X -> %08X, %d\r\n", (uint32_t)buf, (uint32_t)newPtr, (uint8_t*)newPtr - (uint8_t*)buf);
    printf("After aligned: %d\r\n", bufLen);

    size = bufLen - alignment;
    newPtr = std::align(alignment, size, pBuf, bufLen);
    printf("PTR: %08X -> %08X, %d\r\n", (uint32_t)buf, (uint32_t)newPtr, (uint8_t*)newPtr - (uint8_t*)buf);
    printf("After aligned: %d\r\n", bufLen);
    return 0;
}

References

N/A


Completeness

  • User is totes amazing for contributing!
  • 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 XuGuohui added this to the 5.8.0 milestone Mar 13, 2024
@XuGuohui XuGuohui requested a review from avtolstoy March 13, 2024 10:00
@XuGuohui XuGuohui merged commit f9bc898 into develop Mar 13, 2024
13 checks passed
@XuGuohui XuGuohui deleted the fix/rtl872x-spi-uart-hal branch March 13, 2024 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants