-
Notifications
You must be signed in to change notification settings - Fork 7.3k
NXP S32 introduce support SENT #80117
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
base: main
Are you sure you want to change the base?
NXP S32 introduce support SENT #80117
Conversation
The following west manifest projects have changed revision in this Pull Request:
⛔ DNM label due to: 1 project with PR revision Note: This message is automatically posted and updated by the Manifest GitHub Action. |
ec62630
to
b483917
Compare
d00b883
to
23b01d3
Compare
23b01d3
to
55d6a35
Compare
@congnguyenhuu I'd suggest you to open an RFC (request for comments) and link it to this pr in order to involve community to review the proposal and reach consensus: https://docs.zephyrproject.org/latest/contribute/proposals_and_rfcs.html |
55d6a35
to
ec00dc8
Compare
c79ca4d
to
f2e3c0c
Compare
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 see the same concerns raised in the comments #79824 (comment) and #79824 (review) in this PR.
517311f
to
4fc328c
Compare
I addressed |
include/zephyr/drivers/sent/sent.h
Outdated
/** | ||
* @brief SENT frame structure | ||
*/ | ||
struct sent_frame { |
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.
Forgive me for not being very familiar with SENT, but it doesn't look very nice, is this the final solution?
(It's nested too much.)
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 improved the frame layout, merged the common fields
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.
frame.data
vs frame.slow_frame.data
doesn't read nice, the first could also be understood as slow data. Right now to interpret the frame, it's necessary the information obtained from the callback via enum sent_status
.
With the idea of keeping a single frame model for fast and slow frames, consider adding a frame type indicator and making fast and slow data self contained. Example:
enum sent_frame_type {
SENT_FAST_FRAME,
SENT_SLOW_FRAME
};
struct sent_frame {
enum sent_frame_type type;
union {
struct {
uint16_t id;
uint16_t data;
} slow;
struct {
uint32_t data;
} fast;
};
uint32_t timestamp;
uint8_t crc;
};
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.
Thanks for suggestion, I updated
This will need to go to architecture review when ready |
4fc328c
to
343b17d
Compare
343b17d
to
fc21bd8
Compare
fc21bd8
to
4e2740f
Compare
include/zephyr/drivers/sent/sent.h
Outdated
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.
The current implementation of the sent API only supports a central rx callback, whereas the low-level driver allows for the registration of separate callbacks for fast frames, serial frames, fast errors and serial errors. This design choice limits flexibility and could complicate future enhancements. I recommend revising the sent API to support multiple callbacks, aligning it more closely with the low-level driver's capabilities.
1 callback for fast frame and fast error + 1 callback for serial frame and serial error might be a good solution.
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.
1 callback for fast frame and fast error + 1 callback for serial frame and serial error might be a good solution.
agree, this could be a good compromise.
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.
thanks for your suggestion, I separated 2 specific callbacks for fast frame and serial frame
samples/drivers/sent/src/main.c
Outdated
void rx_cb(const struct device *dev, uint8_t channel_id, struct sent_frame *frame, | ||
enum sent_status status, void *user_data) | ||
{ | ||
LOG_INF("Rx channel %d completed\n", channel_id); |
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.
it would be better to print sensor data and associated information rather than just "completed", e.g. timestamp, channel id, read data, status, etc.
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 updated to add more information
samples/drivers/sent/src/main.c
Outdated
|
||
sent_start_rx(dev, SENT_CHANNEL); | ||
|
||
k_sleep(K_MSEC(100)); |
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'd add at least a couple of iterations or an infinite loop, instead of only waiting 100ms to receive data and exiting the sample
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 added an infinite loop for waiting to receive
include/zephyr/drivers/sent/sent.h
Outdated
enum sent_status { | ||
SENT_RX_SLOW_FRAME, | ||
SENT_RX_FAST_FRAME, | ||
SENT_RX_ERR, |
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.
With this design there's no way to distinguish between errors in slow channels and fast channels. I'd imagine it would require different level of actions whether the error occurs in one channel or the other, e.g. fast channel might be a critical impact whereas slow channel might affect only diagnostics.
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 separate 2 specific error statuses for serial and fast frame
include/zephyr/drivers/sent/sent.h
Outdated
/** | ||
* @brief SENT frame structure | ||
*/ | ||
struct sent_frame { |
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.
frame.data
vs frame.slow_frame.data
doesn't read nice, the first could also be understood as slow data. Right now to interpret the frame, it's necessary the information obtained from the callback via enum sent_status
.
With the idea of keeping a single frame model for fast and slow frames, consider adding a frame type indicator and making fast and slow data self contained. Example:
enum sent_frame_type {
SENT_FAST_FRAME,
SENT_SLOW_FRAME
};
struct sent_frame {
enum sent_frame_type type;
union {
struct {
uint16_t id;
uint16_t data;
} slow;
struct {
uint32_t data;
} fast;
};
uint32_t timestamp;
uint8_t crc;
};
f16f2bd
to
85b092f
Compare
85b092f
to
725d13d
Compare
725d13d
to
ac7a64c
Compare
Based on the suggestions from the Architecture WG meeting on March 4th, I have updated to the v1 changes. These updates include:
With the newly defined structure for RX callback configurations in
|
…iver This driver allows to communication (receive data) with SENT device Signed-off-by: Cong Nguyen Huu <[email protected]>
enable support SAEJ2716 SENT Signed-off-by: Cong Nguyen Huu <[email protected]>
Create test, sample for saej2716 driver Signed-off-by: Cong Nguyen Huu <[email protected]>
ac7a64c
to
2a89422
Compare
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.
Some comments regarding the DTS bindings and the API to be taken into account
|
||
properties: | ||
reg: | ||
type: array |
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.
This should be int
|
||
child-binding: | ||
|
||
compatible: "nxp,s32-saej2716-channel" |
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 don't think we need the compatible here
- 1024 | ||
- 2048 | ||
description: | | ||
Specifies the number of bus timeout cycles. This value determines the maximum number |
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.
Missing explanation for what does the 0
mean.
IMO this configuration can have a default value - 0
which means timeout is disabled
/** | ||
* @brief SAEJ2716 status | ||
*/ | ||
enum saej2716_status { |
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.
It looks to me from saej2716_frame_type
, application already knows the frame type. I don't think breaking the status for the frame type is necessary here
* @param channel The hardware channel of the driver instance. | ||
* @param status SAEJ2716 frame status. | ||
* @param num_frame Number of received frame. | ||
* @param user_data User data provided when the filter was added. |
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.
there is no filter
in SENT as far as i know
* @brief SAEJ2716 frame type | ||
*/ | ||
enum saej2716_frame_type { | ||
SAEJ2716_SERIAL_FRAME, |
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.
For serial frame, there are short format and enhanced format. Both should be supported. "SERIAL_FRAME" here is both?
base time unit for the system's timing operations, effectively setting the resolution | ||
of the timer. | ||
|
||
calib-method-low-latency: |
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.
There are two options for Successive Calibration Pulse Check Method: option 1 (preferred) and option 2.
Perhaps this could be successive-calib-pulse-method
with two supported value 1
and 2
?
Indicates whether the successive calibration pulse check method with low latency is enabled. | ||
This method ensures faster calibration by reducing the delay between successive pulses. | ||
|
||
calib-pulse-range-25: |
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.
This should be calib-pulse-tolerance-percent
, with two supported value 20
and 25
?
Indicates whether a 25% variation in the calibration pulse is acceptable. | ||
If not, a 20% variation is acceptable. | ||
|
||
pause-pulse-enable: |
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.
Perhaps pause-pulse-detect
description: | | ||
Indicates whether the channel is enabled to detect a pause pulse. | ||
|
||
crc-check-disable: |
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.
For CRC, as far as i understand:
- Fast Message: CRC is optional (can be enabled/disabled). If CRC is enabled, two main options:
- Legacy 4-bit CRC
- Recommended 4-bit CRC
- Short Serial Message: CRC seems always enabled, two options:
- Legacy 4-bit CRC
- Recommended 4-bit CRC
- Enhanced Serial Message: 6-bit CRC
Should we do something like:
- In dts bindings, create two properties for fast-crc and short-serial-crc
- Define macros for these options in a header file, which can be combined to configure the CRC
Introduce support Single Edge Nibble Transmission (SENT) driver using peripheral SENT receiver on S32Z. This driver allows to communication (read data) with SENT device.
The test result: SENT-RECEIVER-TESTING-RESULT.pptx
RFC: #83983