Commit Graph

50 Commits

Author SHA1 Message Date
Kevin O'Connor d7ec5505a6 atsamd: Enable chipid as usb serial number
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-25 19:30:31 -05:00
Lars R. Hansen 524ebbc7b3 atsamd: Add support for SAMD51 overclocking
Signed-off-by: Lars R. Hansen <popshansen@hotmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-18 12:39:04 -05:00
Kevin O'Connor 1a69f38e6e flash_usb: Pass -t $CONFIG_MCU to flash_usb on all targets
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-26 18:48:00 -04:00
Kevin O'Connor 538d6ac3a2 flash_usb: Use "-s" option to specify flash offset on atsamd
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-26 18:33:00 -04:00
Kevin O'Connor faeaa54925 armcm_boot: Use armcm_main() instead of main() to start board code
The main() function has a special meaning to gcc and using it can
result in different code generation.  Use armcm_main() to avoid that.

Also, invoke SystemInit() from the board specific armcm_main() code.
This gives the board code more control over board initialization.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-24 11:16:10 -04:00
Kevin O'Connor 9b70c052cc armcm_boot: Export MCU definition from armcm_boot
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-18 11:59:43 -04:00
Kevin O'Connor 1c6a8267f9 armcm_reset: Add a new helper file defining command_reset()
Add a generic ARM Cortex-M implementation of the "reset" command.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-18 11:59:43 -04:00
Kevin O'Connor caeb610bb9 armcm_link: Rename armcm_boot.lds.S to armcm_link.lds.S
Rename the linker script so the build does not have any conflicts with
the armcm_boot.d dependency file.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-22 13:18:24 -04:00
Kevin O'Connor 6338f6a5f0 atsamd: Update code to use armcm_boot mechanism
Replace the custom linker scripts with the src/generic/armcm_boot.c
mechanism.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-22 09:58:58 -04:00
Kevin O'Connor 4990fe814d atsamd: Move irq handler code above irq setup
Only code movement.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-22 09:58:58 -04:00
Kevin O'Connor 351910c5ac Makefile: Add generic rule for precompiling linker scripts
Add a general build rule to precompile *.lds.S files to *.ld files.
Remove the custom rules in src/atsamd/Makefile and src/stm32/Makefile.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-21 12:31:12 -04:00
Kevin O'Connor c2a08962b7 spicmds: Rework spi config commands
Rework the spi_config commands so that bus configuration and shutdown
message configuration is done separately from the main "config_spi"
command.  This makes the spi configuration more flexible.  It's now
possible to use software spi without a CS pin.  It's now possible to
define multiple SPI messages to send on a shutdown event.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-06 18:56:53 -04:00
Kevin O'Connor 52dd6f0b57 atsamd: Fix comment typo in serial.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-25 12:18:21 -04:00
Kevin O'Connor e2e4a5d4e6 atsamd: Add build support for SAMD21E15 chip
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-06-01 13:43:37 -04:00
Kevin O'Connor 9e7ef3cf89 atsamd: Reduce the compile size of the hard_pwm pin list
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-05-30 14:05:31 -04:00
Kevin O'Connor e6157c1600 atsamd: Minor whitespace changes to sercom.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-04-04 18:30:05 -04:00
Kevin O'Connor bc9fd03dab atsamd: Use enumerations for buses and reserve pins
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-04-04 18:29:31 -04:00
Kevin O'Connor 7e2c0ffa91 atsamd: Use enumerations for pin mappings
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-03-17 19:38:18 -04:00
Kevin O'Connor b28e95ca1a command: Always pass a string to the DECL_CONSTANT() macro
Make it clear that the name of the constant being defined is a string.
When the value being defined is also a string, use a new
DECL_CONSTANT_STR() macro.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-03-17 19:38:18 -04:00
Kevin O'Connor 6a16e1f4c5 atsamd: Add support to "make flash" to automatically enter the bootloader
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-03-08 22:22:41 -05:00
Kevin O'Connor 399d539969 Makefile: Reduce use of $^ in build rules
It's rare to use all of a target's prerequisites in a recipe - replace
most cases with $< (the target's first prerequisite).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-03-02 12:01:44 -05:00
Kevin O'Connor 309a47c781 atsamd: Reduce memory for have_run_init in spi/i2c
Some of the samd21 chips have limited memory - change the code to
reduce the size of global variables.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-03-01 19:31:18 -05:00
Kevin O'Connor 946eb6b7ae atsamd: Add definitions for SAMD21E18 chip
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-03-01 19:05:00 -05:00
Kevin O'Connor 0b33e0b427 atsamd: Implement custom memory allocation functions
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-03-01 19:05:00 -05:00
Kevin O'Connor fbef144e7b atsamd: Use CONFIG_MCU in Makefile
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-03-01 19:03:34 -05:00
Kevin O'Connor d57bc79513 atsamd: Use the full micro-controller name for CONFIG_MCU
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-03-01 19:03:34 -05:00
Kevin O'Connor d33c4820bd atsamd: Use local linker script
Use a local linker script instead of the linker script provided by
Atmel.  This will allow Klipper to use dynamic memory allocation.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-03-01 19:03:34 -05:00
Kevin O'Connor c8d7e28a35 atsamd: Add support for programming SERCOM pins
Signed-off-by: Florian Heilmann <Florian.Heilmann@gmx.net>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-03-01 00:40:44 -05:00
Kevin O'Connor 7b3331ff52 atsamd: Wrap code to 80 columns
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-02-27 14:20:15 -05:00
Kevin O'Connor 9e8077009e atsamd: Default to using an external 32Khz crystal
Most samd boards have the crystal and it does improve the clock
accuracy, so default to enabling it.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-02-24 00:37:03 -05:00
Kevin O'Connor da68da7a63 atsamd: Add support for reference clock selection to SAMD21
Add support for using the internal clocks (with USB clock recovery
mode if available) on the SAMD21.  Don't use the internal clock if the
external crystal is requested (instead use the PLL synced to the
external 32Khz signal).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-02-22 09:07:26 -05:00
Kevin O'Connor d452a1de48 atsamd: Update SAMD51 clock configuration
Add support for USB clock recovery mode if an external 32Khz crystal
is not in use.  If using an external crystal, then don't use the
internal 48Mhz DFLL48Mhz clock (just use the PLLs synced to the
external 32Khz signal).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-02-22 09:02:04 -05:00
Kevin O'Connor 7a32860455 atsamd: Increase ADC frequency on SAMD51
The SAMD51 ADC is only clocked on rising edges (vs both rising and
falling edges on the SAMD21) and it has a greater minimum frequency
than the SAMD21.  So, increase the ADC clock.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-02-22 08:56:44 -05:00
Kevin O'Connor ebc80ecea4 atsamd: Only support 8KiB bootloader on SAMD21
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-02-22 08:51:46 -05:00
Kevin O'Connor 37797c8128 atsamd: Add a GET_FUSE() helper macro
Add a helper macro for accessing the non-volatile factory-calibrated
"fuse" values.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-02-22 08:51:46 -05:00
Kevin O'Connor a090b31713 atsamd: Fix samd51 get_clock() sync bit check
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-02-16 08:03:28 -05:00
Kevin O'Connor 52eef84228 atsamd: Fix typo in Makefile
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-02-16 07:57:30 -05:00
Kevin O'Connor b33ad59e25 atsamd: Do not generate 200M/100M interal clocks
Now that the internal DWT timer is used for software timers, there is
no need to clock the peripherals at a higher clock speed.  Clock all
peripherals at 48Mhz and simplify the clock generation code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-02-16 07:57:24 -05:00
Kevin O'Connor a00657d2ae atsamd: Don't clear the watchdog if a clear is still in progress
Clearing the watchdog while it is in progress can cause bus stalls on
the SAMD21.  It appears that clearing the watchdog on the SAMD51 can
cause lockups of the watchdog device.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-02-15 22:13:28 -05:00
Kevin O'Connor 00e0a70a94 atsamd: Move watchdog code to its own files
Move the watchdog code from main.c to watchdog.c and
samd51_watchdog.c.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-02-15 22:10:41 -05:00
Kevin O'Connor d1d19d03f3 atsamd: Fix typo in header guard
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-02-13 09:32:06 -05:00
Florian Heilmann af0d292e23 atsamd: Enable ADC support for samd51 devices (#1204)
* adc: Enable ADC support for samd51 devices

Signed-off-by: Florian Heilmann <Florian.Heilmann@gmx.net>
2019-02-08 12:02:32 -05:00
Kevin O'Connor 26fb421d59 atsamd: Convert SAMD51 to use armcm_timer
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-02-06 22:03:09 -05:00
Kevin O'Connor 8cd83b4c2d atsamd: Initial support for SAMD51
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-01-28 20:02:16 -05:00
Kevin O'Connor c5fc264a07 atsamd: Add a get_pclock_frequency() helper function
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-01-28 20:02:16 -05:00
Kevin O'Connor 8f763d80b7 atsamd: Select the 8K bootloader by default
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-01-28 20:02:16 -05:00
Kevin O'Connor 40b5de1680 atsamd: Pass the power management id to enable_pclock()
Pass the power management id instead of the APBCMASK bit to the
enable_pclock() function.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-01-28 20:02:16 -05:00
Kevin O'Connor ed1334c24b atsamd: Clarify clock generation code
Implement gen_clock() and route_pclock() helpers in an effort to make
the code more readable.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-01-28 20:02:16 -05:00
Kevin O'Connor b6ccd2682c Kconfig: Move SERIAL_BAUD to src/Kconfig and show with LOW_LEVEL_OPTIONS
Move the definition of SERIAL_BAUD to the main src/Kconfig file.  Only
show this as an option if the user selects the ability to configure
low-level options.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-01-25 18:02:03 -05:00
Florian Heilmann 6256599a6d src: Rename source folders for atsam and atsamd architectures
Signed-off-by: Florian Heilmann <Florian.Heilmann@gmx.net>
2019-01-12 20:14:50 -05:00