-
Notifications
You must be signed in to change notification settings - Fork 8k
RFC: drivers: rfid: add CR95HF driver with SPI support #91254
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?
Conversation
This commit introduces a basic RFID API and a new driver for the STMicroelectronics CR95HF RFID chip. The driver currently supports SPI communication only and implements the following functionality: 1. Chip initialization 2. Entering Tag Detection mode 3. Reading the UID of detected tags UART communication is not yet implemented. The driver is the first implementation of the new generic RFID API. Signed-off-by: Conny Marco Menebröcker <c-m-m@gmx.de>
This commit introduces a basic RFID API and a new driver for the STMicroelectronics CR95HF RFID chip. The driver currently supports SPI communication only and implements the following functionality: 1. Chip initialization 2. Entering Tag Detection mode 3. Reading the UID of detected tags UART communication is not yet implemented. The driver is the first implementation of the new generic RFID API. Signed-off-by: Conny Marco Menebröcker <c-m-m@gmx.de>
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.
Not really against using tools what so ever, but this seems to be heavily LLM generated, with very obvious blunders. 😉
If I recall correctly an RFID API was discussed several times in the past (I think @pdgendt was involved at some point). Maybe it would make sense to first check the requirements of the API, discuss it's design and then dive into implementing a sample driver.
Besides that its also missing a build_all test of sorts, none of these things are currently tested by CI.
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'm missing an API to execute the activation sequence and collision loop.
Some method like this in the driver API:
rfid_select_mode(RFID_FIELD_ON);
rfid_command(RFID_REQA);
....
And something in this direction in a subsys API:
struct picc_context;
const struct device dev* = DT_DEVICE_GET(reader);
rfid_int(dev, &picc_context);
while(true) {
int ret = rfid_detect(&picc_context);
// somehow check if correct card and exit
}
That hurts...LLM was only used for the comments and for analyzing the ISO 14443...
I am open for discussions. Currently I focused on what I need, which is only reading the UID.
I first wanted to see how my proposal would be received before putting more work into it. If the driver and API have a chance, I’ll also work on tests and additional features. |
For the CR95HF there is not 'Field on' command. The field is switched on if the user selects a protocol.
In my application I have currently the following in a loop:
There I can check if the uid is correct. But sure, I could write a detect function which is doing this. |
This commit includes changes related to the review comments. Signed-off-by: Conny Marco Menebröcker <c-m-m@gmx.de>
This commit includes changes related to further review comments. Signed-off-by: Conny Marco Menebröcker <c-m-m@gmx.de>
I actually expected more discussion regarding the API. So far, only @alexanderwachter has provided feedback. The features he requested are, in principle, already included in my API, but implemented differently than he expected. Below is a brief comparison:
I see pros and cons on both sides. Fundamentally, the driver should handle as much of the work as possible while still remaining flexible. I think combining REQA and anti-collision makes sense. Or are there situations where one would need to call them individually? As for RATS, APDU, etc., I’m personally not a fan of requiring |
The main reason why I prefer a split into subsys and driver is to keep the driver as simple as possible. |
As I understand it, I have already defined a subsystem — namely with the functions: rfid_select_mode(), rfid_protocol_select(), rfid_get_uid()... My CR95HF driver then implements these functions. From my perspective, the only difference is that our interface definitions diverge slightly. The question now is which concept is the better one. Perhaps it would even be best to take the best parts from both concepts. Since this is my first time working with RFID at all, it's difficult for me to make well-informed decisions. For my application, I simply need to read the UID, which I have managed to do with my approach. Before I start a major refactoring effort, I would really appreciate hearing some more opinions. Otherwise, I would prefer to leave my driver as it is for now. Of course, I’ll address the last review findings and add documentation beforehand. |
This commit introduces initial tests. Testing is performed against emulated SPI commands of a CR95HF chip. Signed-off-by: Conny Marco Menebröcker <c-m-m@gmx.de>
This commit includes changes related to further review comments and some fixes regarding coding guidelines. Signed-off-by: Conny Marco Menebröcker <c-m-m@gmx.de>
|
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.
So, this needs some more housekeeping, the commits should be created as per the contribution guidelines.
The major part that is missing here, is documentation. Introducing a new subsystem requires a dedicated documentation section to provide users with the hows/whys/whats/...
Also introducing a new subsystem will need to be presented at the Architecture Working Group at some point.
Definitely going in the right direction now! |
This commit includes changes related to the documentation Signed-off-by: Conny Marco Menebröcker <c-m-m@gmx.de>
This commit includes changes related to the cr95hf emulation for testing. Signed-off-by: Conny Marco Menebröcker <c-m-m@gmx.de>
Introduction of sleep mode. Signed-off-by: Conny Marco Menebröcker <c-m-m@gmx.de>
@cmm1981 any chance you'd be available tomorrow at 17h CEST to discuss this in the Architecture WG meeting? otherwise next Tuesday perhaps? |
Sorry, I did not read your message earlier. Next Tuesday is not possible for me. Tuesdays are unfortunately always difficult for me. I’ll try to join the following week. |
OK. What I'll do is bring it up briefly tomorrow and then let you know of the outcome to see if we need your input. Would you be able to join on a Thursday at the same time? |
Yes, Thursday would work better for me. Regarding the RFID API, @pdgendt could also be helpful since it’s a takeover from him. I adapted my CR95HF driver to his API definition. |
Fix timing issue which occurs if debug logging is off. Signed-off-by: Conny Marco Menebröcker <c-m-m@gmx.de>
|
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.
Just a few inital comments. Thanks for your work!
I'm assuming you're going to squash the commits down and get it in a reviewable state by the time you're ready to take it out of RFC.
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.
Aliases are generally only used by samples for things like LEDS, buttons, etc. that are shared across boards.
Suggest DT_NODELABEL(cr95hf) -- that aligns better with your example anyway.
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 default y
here?
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.
Magic node label plus single instance? Needs fixing before we take this out of RFC.
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.
E.g. note you have a multi instance emulator driver but a hard-code IRQ line -- that's a problem
Thanks for the review! I’ll wait for the architecture review feedback, then push a final update and squash the commits. |
Do you mean you're discussing this in the architecture WG meeting and waiting for that discussion to settle down? If so, that makes sense, but if you're hoping for people to approve an architecture just from this RFC, it's a bit too messy for that in its current state, at least in my opinion. |
Yes, that’s how I imagined it. What do you find too messy — the many changes that made it hard to follow, or the code in general? |
There are a dozen commits in this RFC and most of them look like fixup commits. Please review the contribution guidelines in the zephyr documentation for what is expected from a clean history. @carlescufi and I gave a shorter talk about this a few years ago if you don't have time for that: https://www.youtube.com/watch?v=mnVNLM7ynMQ |
This pull request introduces a new RFID API and a driver for the STMicroelectronics CR95HF RFID chip.
🔧 Current capabilities:
🚧 Limitations:
Signed-off-by: Conny Marco Menebröcker c-m-m@gmx.de