Skip to content

Add resource for LPUART #13306

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

Merged
merged 3 commits into from
Mar 27, 2024
Merged

Conversation

haslinghuis
Copy link
Member

@haslinghuis haslinghuis commented Jan 17, 2024

# resource
resource SERIAL_TX 1 A09
resource SERIAL_TX 2 B03
resource SERIAL_TX 4 C10
resource SERIAL_RX 1 A10
resource SERIAL_RX 2 B04
resource SERIAL_RX 3 B09
resource SERIAL_RX 4 C11
resource LPUART_TX 1 A09
resource LPUART_RX 1 A10

# serial
serial 20 1 115200 57600 0 115200
serial 0 0 115200 57600 0 115200
serial 1 0 115200 57600 0 115200
serial 2 0 115200 57600 0 115200
serial 3 0 115200 57600 0 115200
serial 40 0 115200 57600 0 115200

In documentation we have

ID's 0-19 reserved for UARTS 1-20 
ID's 20-29 reserved for USB 1-10
ID's 30-39 reserved for SoftSerial 1-10
ID's 40-49 reserved for LPUART 1-10
Other devices can be added starting from id 50.

There is an issue when assigning UART 11 on KAKUTEH7MINI we get - as there is no LPUART here:

image

Copy link

Do you want to test this code? You can flash it directly from Betaflight Configurator:

  • Simply put #13306 (this pull request number) in the Select commit field of the Configurator firmware flasher tab (you need to Enable expert mode, Show release candidates and Development).

WARNING: It may be unstable. Use only for testing!

@haslinghuis haslinghuis force-pushed the add-lpuart-resource branch 2 times, most recently from 27ebbd2 to e39279f Compare January 18, 2024 00:26
@ctzsnooze
Copy link
Member

I think it would definitely be good to categorise LPUART separately in RESOURCES.

I would approve this PR if it is technically the right way to do it.

Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within a week.

@github-actions github-actions bot added the Inactive Automatically detected and labeled, will be closed after another week of inactivity. label Feb 17, 2024
@haslinghuis haslinghuis removed the Inactive Automatically detected and labeled, will be closed after another week of inactivity. label Feb 17, 2024
@haslinghuis haslinghuis added this to the 4.5 milestone Feb 18, 2024
@HThuren
Copy link
Member

HThuren commented Feb 18, 2024

Are we sure no more need for more LPUART ports, maybe give room for more than 1 new port ie.

ID's 40-54 reserved for LPUART 1-15
Other devices can be added starting from id 55.

I think an update of documentation are important.

@haslinghuis
Copy link
Member Author

Our current targets do not have a second LPUART port. If needed it can be extended.

@HThuren
Copy link
Member

HThuren commented Feb 20, 2024

Our current targets do not have a second LPUART port. If needed it can be extended.

yes, of course, but then also documentation etc etc, but no big issue .-)

DEFA( OWNER_SERIAL_TX, PG_SERIAL_PIN_CONFIG, serialPinConfig_t, ioTagTx[0], SERIAL_PORT_MAX_INDEX ),
DEFA( OWNER_SERIAL_RX, PG_SERIAL_PIN_CONFIG, serialPinConfig_t, ioTagRx[0], SERIAL_PORT_MAX_INDEX ),
DEFA( OWNER_SERIAL_TX, PG_SERIAL_PIN_CONFIG, serialPinConfig_t, ioTagTx[0], SERIAL_PORT_MAX_INDEX - SERIAL_LPUART_MAX_INDEX),
DEFA( OWNER_SERIAL_RX, PG_SERIAL_PIN_CONFIG, serialPinConfig_t, ioTagRx[0], SERIAL_PORT_MAX_INDEX - SERIAL_LPUART_MAX_INDEX),
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it better to define serialPinConfig_t { ioTagTx[SERIAL_PORT_MAX_INDEX + SERIAL_LPUART_MAX_INDEX]; ... }

Copy link
Member Author

Choose a reason for hiding this comment

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

Subtracting SERIAL_LPUART_MAX_INDEX (1) from SERIAL_PORT_MAX_INDEX (11) to have 10 UARTs and 1 LPUART.

Copy link
Contributor

Choose a reason for hiding this comment

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

But you must change both, or it will break.

But a lot of hardwired problems will surface if you change it, so keeping change minimal may be better

#endif
#ifdef USE_LPUART1
DEFA( OWNER_LPUART_TX, PG_SERIAL_PIN_CONFIG, serialPinConfig_t, ioTagTx[SERIAL_PORT_MAX_INDEX], SERIAL_LPUART_MAX_INDEX ),
DEFA( OWNER_LPUART_TX, PG_SERIAL_PIN_CONFIG, serialPinConfig_t, ioTagRx[SERIAL_PORT_MAX_INDEX], SERIAL_LPUART_MAX_INDEX ),
Copy link
Contributor

Choose a reason for hiding this comment

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

no inverter for LPUART?

Copy link
Member Author

@haslinghuis haslinghuis Feb 26, 2024

Choose a reason for hiding this comment

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

Yes was not sure - reverted

@@ -113,4 +113,6 @@ const char * const ownerNames[OWNER_TOTAL_COUNT] = {
"RX_SPI_EXPRESSLRS_BUSY",
"SOFTSERIAL_TX",
"SOFTSERIAL_RX",
"LPUART_TX",
Copy link
Contributor

Choose a reason for hiding this comment

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

(maybe refactor all lines into designated initializers:

Suggested change
"LPUART_TX",
[OWNER_LPUART_TX] = "LPUART_TX",

Copy link
Member Author

@haslinghuis haslinghuis Feb 26, 2024

Choose a reason for hiding this comment

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

Done - but further refactoring should be done in 4.6 as we are in RC phase.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ledvinap please approve if you are okay with the changes. We can refactor remaining items after release.

@haslinghuis haslinghuis requested review from KarateBrot and ledvinap and removed request for KarateBrot February 26, 2024 21:30
@haslinghuis haslinghuis force-pushed the add-lpuart-resource branch from 74f2341 to bf082ff Compare March 10, 2024 22:26
@sugaarK
Copy link
Member

sugaarK commented Mar 15, 2024

if this is am improvement not a bug fix it shouldn't be in 4.5. I use the lpuarts on my race builds on the airbot Fenix aios for the my elrs so I can use the provided plugs for my radio gear ( means I can have spare rx's ready to go ) it currently performs perfectly fine so this close to release would rather leave as is. I'd be a lot more comfortable with @DieHertz taking a look as he was behind the LPuart implementation, but he's still moving around a lot I thinks

@haslinghuis
Copy link
Member Author

haslinghuis commented Mar 16, 2024

This PR fixes inconsistency between softserial and lpuart. Agree further improvements could be made in next version. Don't mind if this PR skips release as scope is limited. Rebased on master (for testing).

@haslinghuis haslinghuis force-pushed the add-lpuart-resource branch from bf082ff to 086788a Compare March 16, 2024 20:15
@ctzsnooze
Copy link
Member

@haslinghuis
How should we test this one?

@haslinghuis
Copy link
Member Author

@ctzsnooze You would need a board with LPUART

image

@nerdCopter
Copy link
Member

only flashed, no real testing:
image

Copy link
Member

@ctzsnooze ctzsnooze left a comment

Choose a reason for hiding this comment

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

I'll approve on the basis that the only way to get wide testing is to get this into master. Seems that only G4 boards have LPUART. I don't have any of those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: COMPLETED
Development

Successfully merging this pull request may close these issues.

6 participants