-
Notifications
You must be signed in to change notification settings - Fork 67
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
ATMega328P Support #11
Comments
Reading through the atmega328p.adtf, the patch YAML files, and the ATMega328 datasheet, I'm beginning to see relationships between their contents. For example, I see that the YAML files seem to target XML elements in their adtf files by There are a few things that are still mysterious, principally some of the underscore patch actions in the patch file. The following are ones I see in some of the YAML files: Neither of those are mentioned in the stm32-rs README. Where can I find documentation on their behavior? The At a higher level, it seems to me like the objective here is to add patches such that when applied to the atdf file, has an output that matches what's described in the datasheet. Is that roughly accurate? |
Yes
Unfortunately, I don't know of a document that outlines just the differences. I think, the best thing to do is looking at each patch for ATmega32U4 and checking the datasheet if it might apply. If it does, try including it and looking at the generated output (more specifically the rust documentation of the generated output).
Ah, that is not quite correct. The atdf files are first converted to svd using atdf2svd and the patches are then applied to the generated svd files. If you ran the generation once, you can find these svd files in
Those two were added by us, because upstream
They exist in the atdf file as well, but they are called
Well, the patches are applied to the generated svd, not directly to the atdf. Apart from that, you are correct: The intention is to fix wrong/missing information before generating rust definitions. That all said, I don't think it is necessary for you to dive deep and patch the whole thing, unless you really want to ... It is well enough if you take a look which of the common patches also apply to ATmega328P and maybe compare the generated output of the UART and I2C peripherals against the datasheet. (For that, look at the final generated rust crate's documentation, not the svd files as these are quite convoluted) |
@Rahix I've submitted a PR with the added patches. The only one left out is PLL which is apparently for USB which the 328p does not support.
I see no mention of either of those in the generated documentation. How would I perform that comparison? |
Reading through your comment on the avr-hal repo again, I see you draw a relationship between I2C and TWI. I'll read through that and try to verify that things match. As for UART, would I look at USART to compare? |
This commit adds patches for ATmega328P by copying the commons from ATmega32U4, omitting PLL because the 328p lacks that feature (#11)
@Rahix All of the registers for TWI look the same, however I'm unable to check the register address (?). The documentation lists the registers and their various bits, but don't actually declare their positions or masks. Is it necessary that I check that, and if so where would I find them? Still reading through USART. |
The addresses are most likely correct, I don't think you need to double check. For now, you can just leave the stuff in this repo as-is, unless you encounter errors while working on the For future reference: The register addresses are most easily visible in the "Register Summary" close to the end of the datasheet. |
@Rahix Okay good to know, I'll leave them. I see them in the datasheet, I'm wondering where to find them in the Rust docs though. |
@Rahix The registers and bit lists all look the same for USART as well, so all good. However there are a couple of sections where the descriptions from the datasheet didn't make it into the patches. If it's okay with you I'll open another PR with more of those descriptions added. |
Oh I did find one difference actually. For the enumerated values on the UCSZ0 bits, the value for |
Sounds good! If you can add those to the common patch, the other chips will benefit your work as well!
They are unfortunately not easily visible there because of the way svd works ... |
@Rahix I've opened PR #13 which fixes a couple of small things. It's not much, partly because some of the descriptions I thought were missing I just didn't know how to find. I've taken some other notes based on the datasheet as well that I'm less clear whether they need a solution, or even should have one.
|
Thanks for the PR! About your notes:
The bits in this table are separate, which means you unfortunately can't add an enum for them ...
I have already patched this enum to have useful names that are not specific to one of the three different modes. SVD does not have a way to model these kinds of constraint AFAIK.
Hmm, yes that should not be the case. What confused me a little is the fact that I seem to have a different version of the datasheet which has these bits documented. I'll take a closer look if I get some spare time. For now, it should be ok to just leave them in. |
I think the correct datasheet is this one. It has the bits in Anyway, I don't think we need to be concerned about this and can safely assume those bits exist. |
Great, thanks. I'll leave this issue open until I've been able to verify I can run code on my Uno and that there aren't any problems remaining here. |
Confirmed that at least two examples work, I consider this issue completed. Thanks for the direction @Rahix ! |
Opening another issue here for stuff specifically related to this repo
Related to: Rahix/avr-hal#2
@Rahix In your first comment on that issue you said the first place to start is working on the chip patch. I see that there is already an atmega328p patch file, but it has fewer _
include
s. My guess is that it's incomplete in its current form.That sounds good... the only issue is that I don't know where to find the differences between the 32u4 and the 328p. Is that info I can find in the data sheet? Or documented elsewhere on the Microchip website? Again please pardon my extreme ignorance here.
The text was updated successfully, but these errors were encountered: