-
Notifications
You must be signed in to change notification settings - Fork 3k
STM32s Serial: Correct handling of parity bits #4216
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What is missing? How did you test this changeset? This is for STM32F0, what about other families? Do they have the same problem? |
/morph test |
Thanks for this PR. OK for me. |
@0xc0170 Honestly, I don't own a STM32F0 so I couldn't test it on real hardware. I could do a unit test that runs on the host if you point me in the direction of some documentation. I tried mbed test in a "mbed-os-example-blinky" project but that didn't work. Regarding the other families, that's why I marked it as "IN DEVELOPMENT" I admit I didn't look at all the STM32 targets but STM32F0, STM32F3 and STM32F4, at least, have this problem. I think with a little bit more effort a great deal of the code in serial_api.c of each family could be consolidated into a general STM32::serial_api.c The idea of this PR was to at least get a feeling if this was the desired behaviour. |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
That would be ideal if possible. This shall be good to go or shall we wait for fixing all STM32? |
I can try and push something later tonight but can't make any hard promises. I'd like to look at some more datasheets, especially for the other families to check it's also the case for the STM32L variants as well. Regarding testing I only have a STM32F4 nucleo board where I can test it. I'm guessing your CI tests will test some other HW, is that correct? |
Looks to be the same for the STM32L family.
|
23cd698
to
9f779f4
Compare
I've updated the PR moving serial_format() and init_uart() into a common source file for all STM targets. I've built all STM targets successfully (some failed but failed the same for the master branch so that's material for another issue). I used the function in a blinky example and it built fine, flashed the binary to my STM32F4 nucleo board and it runs but unfortunately I don't have a serial-to-usb at home so I couldn't really test it. Maybe someone can volunteer to try it? Regarding the file names I got inspiration from similar already existing files but if the names aren't right please let me know. I look forward to your comments. |
@bcostm @LMESTM please review, and can you verify these changes? |
init_uart(obj); | ||
} | ||
|
||
#endif /* DEVICE_SERIAL */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please always add a newline at the end of the file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange... I thought I did maybe something happened in one of the rebases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the github viewer might be ignoring the last line. If I click edit this file I can see line 123 being a blank line. Also on the file information on top it says "123 lines (111 sloc) 4.19 KB" but on the viewer lines are only numbered 1 to 122. Have you checked out the change and see if the line is actually there? I can't do it now at work otherwise it'll have to wait until I have a moment at home. But I think the line is there. Same happens with the header file, different line count obviously.
targets/TARGET_STM/serial_api_hal.h
Outdated
|
||
extern UART_HandleTypeDef uart_handlers[]; | ||
|
||
void init_uart(serial_t *obj); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be good to have this function documented here (use doxygen comments as other API)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely right, I forgot that.
@0xc0170 Pushed changes addressing your two comments |
/morph test |
@0xc0170 is there a test in mbed-os test suite checking various serial format ? |
I am not aware of it yet, would need to be implemented. I was thinking about checking with analyzer that this changes do not introduce any regression. |
@0xc0170 If I need to make sure there is no regression on all STM32 targets, I'd rather use an automated test than checking manually :-) |
that would be the best. @fmanno Are you familiar with host tests? Here is a snippet for one host test that is used in some tests: https://github.com/ARMmbed/mbed-os/blob/master/TESTS/host_tests/timing_drift_auto.py. @LMESTM what do you think? |
Having a test with host and device using a few formats to be tested sounds good indeed. I remember there was such a test in MBED2 at least, testing a different baudrate (115200kbps) than the default one (9600). That is the exact same idea. Do we have this test as well in MEBD5? |
Please resolve the conflicts here
I would say yes as it was already tested with number of devices, and no regression found. We used to had one HAL serial test where we tested parity (2 uarts connected , no host test part needed in that case.). |
I created #4348 to track the new test case creation |
@fmanno @LMESTM Normal policy would be to not accept this kind of change without the associated test case so that we can add that to our CI and ensure we have testing covered going forward. However this one has been hanging around for quite a while now so I think we can get it in as long as the test is forthcoming relatively soon :) Although looks like a rebase is now required! |
@adbridge I would argue that the MBED HAL already provides this feature from very long time .... $ git commit 5c20760 we're just fixing an issue for STM targets here, not introducing the feature. |
@LMESTM You're right there should have already been a basic test for this functionality which could have then just been updated to make sure it tested this change as well. There are still some areas where we know the test coverage needs to improve. Unfortunately this seems to be one of them, so currently we have no way of testing if this all works correctly and thus we appreciate the addition of tests as it improves the quality for everyone :) |
There's a conflict, please rebase @fmanno |
I've now rebased it. Sorry it took me a bit long. |
oh, another conflict |
I'll try to get it tonight. |
Reworked the serial_format() function for STM32F0x devices to take the format in the form: data_bits - parity - stop_bits E.g. 8 - N - 1 where data_bits exclude the parity bit. Added a case for 7 bits data as at least the chips STM32F0x1/STM32F0x2/STM32F0x8 support 7 bits data. Consolidated serial_format() and uart_init() functions into a general TARGET_STM serial_api.c file since the functions are common to all STM targets. Fixes ARMmbed#4189
/morph test |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
} | ||
#endif | ||
|
||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a newline
Reviewed locally, the newlines are there. |
Description
Reworked the serial_format() function for STM32F0x devices to take the format in the form:
data_bits - parity - stop_bits
(E.g. 8 - N - 1) where data_bits exclude the parity bit.
Added a case for 7 bits data as at least STM32F0x1/STM32F0x2/STM32F0x8 support 7 bits data.
Consolidated serial_format() and uart_init() functions into a general TARGET_STM serial_api.c file since the functions are common to all STM targets.
Status
DONE
Migrations
YES
After this is merged, behaviour for STM32s will be consistent with the API behaviour for other manufacturers. Users won't be able to specify 9bits data + (parity != none). Users will have to review their applications to ensure the way they specify their format takes into account that the parity bit is no longer included in the data_bits count.
Fixes #4189