-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Add SAM E70 support #5366
Add SAM E70 support #5366
Conversation
Signed-off-by: Alex Maclean <monkeh@monkeh.net>
Thanks. At a high-level, it looks good to me. I did notice a couple of minor things:
Not a blocker for merging, but I also noticed this code adds several -Kevin |
Signed-off-by: Alex Maclean <monkeh@monkeh.net>
Unfortunately yes, several deprecated defines are used by the USB driver and the SAM3 headers do not contain the new style.
I felt that resulted in excessive cluttering (over 50 lines of it for USB, for example), but I can do so if you're certain that's better.
Clipped that out, will send a PR once someone is able to test properly.
I've asked several people to chime in.
The gpio.c bit was particularly ugly, my apologies for that. Have refactored with more caffeine. Where else looked like a candidate for culling? |
I'm leery of large include files with dependencies that aren't clear. If you think the defines are too much for sam3_usb.c then perhaps create a same70_usb.h file with just its usb redefinitions. (Along with a comment that the header is just for register compatibility.)
I'll send a separate message with some examples. Again, nothing critical. -Kevin |
src/atsam/Kconfig
Outdated
config MACH_SAME70Q20B | ||
bool "SAME70Q20B (Duet 3 6HC)" | ||
select MACH_SAME70Q |
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.
Why does kconfig report "same70" to the user, while the lib directory is same70b
, while the define here is same70q
?
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 includes are for revision B (SAME70xxxB), revision A is not (readily?) supportable with the same binary. The 6HC is revision B and I think it unlikely anyone will develop a controller using any revision A part. Q(xxx) is the package, and I simply haven't checked if any peripherals have jumped pin on the 100-pin (N), although it's not likely. We're.. not likely to see the 64-pin (J), the USB peripheral on it doesn't function.
I could just drop the Q, and express it as SAME70xxxB in Kconfig?
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 MACH_SAME70Q20B
seems fine to me. The MACH_SAME70Q
seems odd. I'd have thought the families would be SAM3
, SAM4
, or SAME70
. Not a big deal either way - just curious.
-Kevin
src/atsam/sam4e_afec.c
Outdated
#if CONFIG_MACH_SAM4E | ||
afec->AFE_MR = AFE_MR_ANACH_ALLOWED | \ | ||
AFE_MR_PRESCAL(pclk / (2 * ADC_FREQ_MAX) - 1) | \ | ||
AFE_MR_SETTLING_AST3 | \ | ||
AFE_MR_TRACKTIM(2) | \ | ||
AFE_MR_TRANSFER(1) | \ | ||
AFE_MR_STARTUP_SUT64; | ||
#elif CONFIG_MACH_SAME70Q | ||
afec->AFE_MR = AFEC_MR_ONE | \ | ||
AFE_MR_PRESCAL (pclk / (ADC_FREQ_MAX) -1) | \ | ||
AFE_MR_TRANSFER(2) | \ | ||
AFE_MR_STARTUP_SUT64; | ||
#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.
Could be merged with existing AFEC1_START #ifdef, by creating a new CFG_AFEC_MR.
src/atsam/sam4e_afec.c
Outdated
#if CONFIG_MACH_SAME70Q | ||
afec->AFE_ACR = AFE_ACR_IBCTL(1) | AFEC_ACR_PGA0EN | AFEC_ACR_PGA1EN; | ||
#else | ||
afec->AFE_ACR = AFE_ACR_IBCTL(1); | ||
#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.
Same.
src/atsam/sam4e_afec.c
Outdated
afec->AFE_IDR = 0xDF00803F; | ||
#if CONFIG_MACH_SAM4E | ||
afec->AFE_IDR = 0xDF00FFFF; | ||
#elif CONFIG_MACH_SAME70Q | ||
afec->AFE_IDR = 0x47000FFF; | ||
#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.
Same. Or, could be if (CONFIG_MACH_SAM4E) ... else ...
.
src/atsam/sam4e_afec.c
Outdated
#if CONFIG_MACH_SAM4E | ||
reg |= 1 << (2 * afec_chan); | ||
#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.
if (CONFIG_MACH_SAM4E)
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.
On a second look I think I should just remove that entirely and leave both bits cleared on either target. DIFFx is explicitly cleared, so there should be no need to set GAINx to 1 on SAM4E. Will verify, I have that hardware.
src/atsam/sam4e_afec.c
Outdated
#if CONFIG_MACH_SAM4E | ||
afec->AFE_COCR = (0x800 & AFE_COCR_AOFF_Msk); | ||
#elif CONFIG_MACH_SAME70Q | ||
afec->AFE_COCR = (0x200 & AFE_COCR_AOFF_Msk); | ||
#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.
if (CONFIG_MACH_SAM4E)
or create a new define in previous #ifdef .
src/atsam/sam3_usb.c
Outdated
#if CONFIG_MACH_SAM3 | ||
UOTGHS->UOTGHS_CTRL = (UOTGHS_CTRL_UIMOD | UOTGHS_CTRL_OTGPADE | ||
| UOTGHS_CTRL_USBE); | ||
#elif CONFIG_MACH_SAME70Q | ||
UOTGHS->UOTGHS_CTRL = (UOTGHS_CTRL_UIMOD | UOTGHS_CTRL_USBE); | ||
#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.
Can create a new #define CFG_UOTGHS_CTRL
in existing #if CONFIG_MACH_SAME70
block.
Signed-off-by: Alex Maclean <monkeh@monkeh.net>
Signed-off-by: Alex Maclean <monkeh@monkeh.net>
Signed-off-by: Alex Maclean <monkeh@monkeh.net>
Signed-off-by: Alex Maclean <monkeh@monkeh.net>
Hi, @eamaclean @KevinOConnor I am trying to setup Klipper using DUET3MB6HC. Very appreciated your effort make this possible. I am having a issue that, when I trying to configure TMC5160, the SPI wire diagram make me hard to follow the configuration tutorial, I don't know how to configure the |
For each driver you will need a:
Just increment chain_position for each driver. See https://www.klipper3d.org/Config_Reference.html#tmc5160 |
Hi ! I try to port the FW to SAM E70Q21A-AN CPU but failed. I have custom made printer control board (working with other a custom FW).
The error is:
Thank You! |
That looks similar to an error reported at #6094 for a different board - you can look at that PR to see how that submitter fixed the issue. -Kevin |
This adds support for the SAME70Q20B used on the Duet 3 6HC.
Lightly tested by users in Discord, but a blind port without personal hardware.
Currently PWM1 is not supported as hard PWM support seems little used, and to my knowledge PWM and TC are both untested.