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

[Feature Request] Adafruit BLE UART Friend support (refinement and re-open #10674) #22495

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

orumin
Copy link

@orumin orumin commented Nov 18, 2023

Description

Add driver support for Adafruit BLE UART friends , and add non-blocking read API to AVR UART driver.

The function required from YANG's HHKB BLE mod.
HHKB BLE mod is already merged to master branch, but this code base is cannot build with BLUETOOTH_ENABLE at all time due to lack of feature support for Adafruit BLE UART. HHKB BLE mod's code calls non exist API.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Related issues

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

Acknowledgments

some code reference to @naoki-mizuno 's code within kanru#3 and originally PR by @kanru
thank you for your contributions and knowledgements.

@github-actions github-actions bot added core dd Data Driven Changes labels Nov 18, 2023
@@ -31,6 +31,7 @@ void uart_init(uint32_t baud);
void uart_write(uint8_t data);

uint8_t uart_read(void);
int16_t uart_read2(void); // non-blocking
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addition here would be invalid, as it creates inconsistencies in what is meant to be a generic API.

The net result is your change would only successfully compile on AVR.

Copy link
Author

@orumin orumin Nov 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thank you for your reviews.
I will re-refine and re-think strategy to support Adafruit BLE UART friends.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function can also be implemented using the existing APIs:

int16_t uart_read_nonblock() {
    if (uart_available()) {
        return uart_read();
    } else {
        return -1;
    }
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, it works! thank you for your advice

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed unecessary changes about generic UART driver's code and re-pushed. thank you.

@zvecr zvecr changed the base branch from master to develop November 18, 2023 18:16
@orumin
Copy link
Author

orumin commented Nov 18, 2023

this PR is still lack of test code/coverage for added function, but i don't know how to add test/mock for driver in QMK.
could you help me?

@orumin
Copy link
Author

orumin commented Nov 18, 2023

code rebased to change target branch (master -> develop)

builddefs/common_features.mk Outdated Show resolved Hide resolved
@silvinor
Copy link
Contributor

Would be nice to make this cross MCU .. rn it's using AVR specific functions like memcmp_P & snprintf_P. If these drivers would work on STM32's or RP2040's ... that would be awesome.

@elpekenin
Copy link
Contributor

elpekenin commented Dec 22, 2023

using AVR-specific

https://github.com/qmk/qmk_firmware/blob/master/platforms/progmem.h already defines a lot of similar functions as alias to "regular" functions on non-AVR controllers, adding a couple of them should be enough make the code cross-platform (#define memcmp_P(s1, s2) memcmp(s1, s2) and the like)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core dd Data Driven Changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants