Commit Graph

909 Commits

Author SHA1 Message Date
Kevin O'Connor 95eb00740b stm32: Avoid read+write modify instructions in can.c
Prefer explicitly setting the hardware registers and avoid using C
read and modify instructions where possible.  This avoids race
conditions where an interrupt or hardware change could cause subtle
corruption of the register state.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-02 15:17:14 -05:00
Kevin O'Connor c0371c94c8 stm32: Introduce new can_set_filter() helper function in can.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-02 15:17:14 -05:00
Kevin O'Connor 901ccfcb9d stm32: Update can.c to use more consistent indentation
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-02 15:17:14 -05:00
Alan Lord 7d4df65920
ds18b20: new module for 1-wire temperature sensor (#3462)
Initial commit of code to support 1-wire (Dallas) sensors such
as the DS18B20. Requires Linux kernel drivers to create a file
in /sysfs which is read by this module, and temperature
typically returned to a temperature_fan.

Signed-off-by: Alan Lord <alanslists@gmail.com>
Signed-off-by: Josh Headapohl <joshhead@gmail.com>
2021-02-02 14:34:56 -05:00
Kevin O'Connor 55185e9a7e atsamd: Fix bug in sercom_pads mapping on samd21 in sercom.c
Reported by @tech2077.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-01 10:55:38 -05:00
smark- ef4d9c3abd
stm32: Support for STM32F401 (#3853)
This module adds support for the STM32F401 microcontrollers

Signed-off-by: Marco D'Alessio <marco@wrecklab.com>
2021-01-31 19:41:53 -05:00
Matt Shepcar ccaf58a02c
stm32f1: Fix for using 16MHz external crystal (#3814)
Signed-off-by: Matt Shepcar <matt@shepcar.co.uk>
2021-01-24 10:24:11 -05:00
Kevin O'Connor 28bca7da77 stm32: Support setting the stm32f0 internal clock trim value
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-18 12:49:41 -05:00
Kevin O'Connor cc39beba0e stm32: Add support for spi4 bus on stm32f446 chip
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-01-04 01:54:41 -05:00
Kevin O'Connor f3c5be0f00 gpiocmds: Merge digital output and soft pwm code
The digital output commands implement a subset of the software pwm
commands.  Change the host code to just use the software pwm commands
and simplify the micro-controller code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-10 12:06:26 -05:00
Kevin O'Connor 39a04eac5f stm32: Only use the HSI48 clock when doing "usb clock recovery"
The HSI48 clock on the stm32f042 isn't as accurate as the main HSI
clock.  So, only use the HSI48 clock when using USB to synchronize
that clock.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-08 09:00:47 -05:00
Kevin O'Connor 9e293be5e0 pca9685: Use move queue for pwm updates
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-04 16:10:13 -05:00
Kevin O'Connor 19a96346a8 gpiocmds: Use move queue for software pwm
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-04 16:10:13 -05:00
Pascal Pieper 9cdf9bb6ec gpiocmds: Use move queue for digital output pins
Signed-off-by: Pascal Pieper <accounts@pascalpieper.de>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-04 16:10:13 -05:00
Pascal Pieper e8ec1801ff pwmcmds: Use move queue for hard PWM
Signed-off-by: Pascal Pieper <accounts@pascalpieper.de>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-04 16:10:13 -05:00
Kevin O'Connor 697412d25c stepper: Use a reusable interface to the "move queue"
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-04 16:10:13 -05:00
Kevin O'Connor 3b9412513e basecmd: Change "move queue empty" error to "move queue overflow"
Use a more clear error message.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-04 16:10:13 -05:00
Kevin O'Connor 086f0fafde gpiocmds: Send soft pwm cycle_time separately from schedule_soft_pwm_out
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-04 16:10:13 -05:00
Kevin O'Connor 7b28cdbae5 pru: Disable gpio mux configuration code
The code isn't actually capable of altering the mux registers due to
hardware checks enforced by the chip.  Disable that code to save a few
bytes in the final binary.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-04 16:10:13 -05:00
Kevin O'Connor 123908ac7a neopixel: Fix neopixel_result message so that it contains an oid
In order for commit 82156170 to work properly, the neopixel_result
message must contain the oid.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-11-05 11:40:34 -05:00
Kevin O'Connor a560432041 command: Fix handling of buffer passing in args[] on 64bit mcu
If the buffer pointer can't fit in a uint32_t then pass a relative
buffer offset instead.  This fixes buffer handling on 64bit linux
mcus.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-10-30 14:04:12 -04:00
Kevin O'Connor 473828ca6a command: Add command_decode_ptr() helper
Add a helper function to convert from a string buffer passed in the
args[] parameter to an actual pointer.  This avoids all the callers
needing to perfrom pointer manipulation.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-10-30 14:04:08 -04:00
Kevin O'Connor 2bb30265b5 neopixel: Increase the maximum LED chain length
Rework neopixel updates to use an mcu buffer so that more than 18 LEDs
can be in a chain.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-10-29 11:59:15 -04:00
Kevin O'Connor be4ad29fa3 atsamd: Support reading chip based temperature sensor
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-10-29 11:55:06 -04:00
Kevin O'Connor 9142200b3a stm32: Support reading chip based temperature sensor on stm32f0
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-10-29 11:55:06 -04:00
Kevin O'Connor a8069e9ba8 stm32: Reduce adc_pins storage size in stm32f0_adc.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-10-29 11:55:06 -04:00
Kevin O'Connor d985b53ccb stm32: Support reading chip based temperature sensor on stm32f1/2/4
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-10-29 11:55:06 -04:00
Kevin O'Connor d9b7891133 atsam: Support reading chip based temperature sensor on sam4e
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-10-29 11:55:06 -04:00
Kevin O'Connor 97d49105b7 atsam: Support reading chip based temperature sensor on sam3/sam4s
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-10-29 11:55:06 -04:00
Kevin O'Connor ed5ce9cb37 linux: Fix spi handling with more than one spi device
Reported by @opensource-alt.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-10-25 10:14:15 -04:00
Kevin O'Connor 2885a4c728 stm32: Don't default to HID bootloader in Kconfig
Restore the default of an 8KiB bootloader for stm32f103 and a 32KiB
bootloader for stm32f207/stm32f407.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-10-13 14:25:17 -04:00
bondus 387fceb453 stm32: Fixed CAN bus for STM32F4, there were syntax errors that prevented compilation
Signed-off-by: Pontus Borg <liquidpontus@yahoo.se>
2020-10-11 11:24:05 -04:00
Guy Shapira 27cefb2b38 gpiocmds: Add soft-pwm frequency modulation support
Signed-off-by: Guy Shapira <gayuha@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-09-26 20:51:38 -04:00
Kevin O'Connor 1cdf0d474d sensor_adxl345: Remove unused stop_time parameter
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-09-05 09:18:59 -04:00
Kevin O'Connor 3405095f0a adxl345: Add support for adxl345 accelerometer
Add support for taking measurements from an adxl345 accelerometer via
SPI interface.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-09-05 09:11:04 -04:00
Cabia Rangris 15853da28c
config: Added TronXY X5SA support (#3265)
Added printer-tronxy-x5sa-v6 config.
Added "chitu" bootloader option to stm32 Kconfig.
Added chitu_crypt.

Signed-off-by: Vladimir Serov <me@cab404.ru>
2020-08-30 12:59:28 -04:00
bondus 35d28e880d
stm32: Improvements to CAN bus ID generation. And added a small fast hash library (#3165)
Improved CAM bus ID generation, there were issues with ID collisions.
Added a small fast hash library.

Signed-off-by: Pontus Borg <liquidpontus@yahoo.se>
2020-08-09 21:07:59 -04:00
Kevin O'Connor 0f3b1bce66 linux: Set the SPI mode in spidev.c
Fix omission causing the SPI mode to not be set on the linux mcu.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-07-31 23:18:46 -04:00
Kevin O'Connor 5f2cb5436c linux: Disable hardware pwm when it is set to zero
Only write "1" to the "enable" file when a non-zero pwm width is
requested.  Write "0" to the "enable" file when a zero pwm width is
requested.

This fixes a problem on the replicape servo lines that prevented them
from being fully disabled.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-07-20 22:18:28 -04:00
Kevin O'Connor c83688b7bc lpc176x: Fix spi mode bits
The lpc176x hardware spi initialization code was swapping the CPOL and
CPHA bits.  This caused the MAX31865 and MAX31856 chips to not work
correctly.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-07-10 16:08:18 -04:00
bondus 7a8e9591e3
stm32: Improved CAN support for STM32 (#2976)
Reworked the STM32F0 CAN bus implementation. It's more robust and higher performance.

Added support for function remapping to different pins.  API is emulating an STM32F0.

Improved and ported CAN bus to STM32F0, F1 and F4.

Signed-off-by: Pontus Borg <glpontus@gmail.com>
2020-06-24 18:59:38 -04:00
combolek 7cab732ae9
stm32: Initial support for stm32f2 (#3001)
Initial support for stm32f2 in general and STM32F207 in particular.

Boots up and communicates on STM32F207VC.

Signed-off-by: Boleslaw Ciesielski <combolek@users.noreply.github.com>
2020-06-23 10:52:15 -04:00
kianusch a4c31bafb0
stm32: Support for 20KiB bootloader offset. (#3008)
Signed-off-by: Kianusch Sayah Karadji <kianusch@gmail.com>
2020-06-20 13:30:10 -04:00
Kevin O'Connor 722770f62f generic: Minor header cleanup to generic/irq.h
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-06-07 21:18:04 -04:00
Kevin O'Connor 06437c5892 linux: Wait in timer dispatch for up to 2us
Use 2us in the linux timer dispatch code to unify linux timer dispatch
logic with the common timer_irq.c code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-06-07 09:17:51 -04:00
Lucio Tarantino b7699d374a
linux: Ability to use multiple GPIO chips (#2935)
Signed-off-by: Lucio Tarantino <lucio.tarantino@gmail.com>
2020-06-06 12:47:11 -04:00
Kevin O'Connor 38772492f9 Kconfig: Only show the "usb ids" menu if low-level options are enabled
It's rare to customize the usb ids, so make it a "low-level" option.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-31 21:05:04 -04:00
Kevin O'Connor ea9eac6c38 Kconfig: Change the default usb vendor/product id
Change the product/vendor id to 0x1d50/0x614e, which has been reserved
for Klipper (thanks to the openmoko project).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-31 21:05:04 -04:00
Kevin O'Connor 634dcc7387 lcd_hd44780: Only calibrate cmd_wait_ticks on mcus with strict timing
The calibration isn't valid on the linux mcu, so make it dependent on
CONFIG_HAVE_STRICT_TIMING.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-31 14:57:06 -04:00
Kevin O'Connor 0cbb8fdc9a lcd_st7920: Only calibrate wait ticks on mcus with strict timing
The calibration isn't valid on the linux mcu, so make it dependent on
CONFIG_HAVE_STRICT_TIMING.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-31 14:57:06 -04:00
Kevin O'Connor 98192d710f stepper: Make toggling the step gpio after timer read conditional
On the Linux mcu, toggling the pin after the time is read is not
valid.  Make that optimization dependent on CONFIG_HAVE_STRICT_TIMING.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-31 14:57:06 -04:00
Kevin O'Connor 835ec3513d Kconfig: Add a new CONFIG_HAVE_STRICT_TIMING build definition
Add a new build definition to note micro-controllers that have strict
timing.  The Linux mcu code does not have strict timing - all other
targets currently do.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-31 14:57:06 -04:00
Kevin O'Connor b80d2f7706 stm32: Fix typo causing internal clock to always be used on stm32f042
Reported by Pontus Borg.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-28 15:56:22 -04:00
Arksine ab87af90a3 stm32f4: Add support for HID bootloader
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-05-28 14:44:51 -04:00
Arksine 05efccc874 stm32f1: Add support for HID Bootloader
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2020-05-28 14:44:51 -04:00
andryblack 8fd330c54e linux: userspace GPIO control
Allow use host GPIO pins for non-realtime purposes.

Signed-off-by: Andrey Kunitsyn <blackicebox@gmail.com>
2020-05-17 22:17:15 -04:00
Arksine 72b3ab8b29 stm32: add support for i2c read
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-05-05 11:44:19 -04:00
Lucio Tarantino dac42efbd9
htu21d: Support for HTI21D family sensor on I2C bus (#2803)
Signed-off-by: Lucio Tarantino <lucio.tarantino@gmail.com>
2020-05-03 18:47:24 -04:00
Arksine f8649b4ba9 stm32: Wait for setup complete to enable ep0 rx in usbotg.c
Endpoint 0 OUT needs to NAK everything until the core signals that the
setup stage is complete.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-03 12:00:47 -04:00
Kevin O'Connor e93c188766 stm32: Wait for setup complete notification in usbotg.c
A setup packet is only valid after receiving the "setup complete"
notification.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-03 11:27:43 -04:00
Janne Grunau 0aa78ec76e
linux: Adapt servo0 channels for beagleboard kernel 4.14.108-ti (#2746)
The beagleboard TI kernel 4.14 and 4.19 contain a commit which change
the device names ("pwm: Create device class for pwm channels") from
pwmN to pwm-${chip}:N. This commit was never merged into the upstream
kernel.

Decrease the number of pwm channels to a more reasonable 16. Increase
the number of pwm chips to 8 since the replicape servo pwm outputs are
on pwmchip4.

Update replicape code to detect appropriate channel.

Signed-off-by: Janne Grunau <janne-gh@jannau.net>
2020-05-03 11:24:42 -04:00
andryblack db732e58db linux: change clock frequency
Increase timer resolution for linux mcu

Signed-off-by: Andrey Kunitsyn <blackicebox@gmail.com>
2020-05-02 16:38:56 -04:00
Kevin O'Connor b6ebf5cb09 stm32: Slow ADC frequency to 4.5Mhz
There are reports that SKR mini boards have more stable ADC results
when running the ADC at a slower frequency.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-04-30 19:47:23 -04:00
Kevin O'Connor 8ac81fed67 lpc176x: Add support for additional i2c buses
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-04-21 16:11:39 -04:00
Kevin O'Connor c5e7985740 neopixel: Make sure there is a minimum low duration after a long pulse
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-04-21 13:12:56 -04:00
Kevin O'Connor 0ae20421d1 neopixel: Allow host software to configure neopixel timing
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-04-15 13:29:43 -04:00
Kevin O'Connor a7f7cc5075 neopixel: Use names for key timing values
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-04-15 12:11:57 -04:00
Kevin O'Connor 91a27ef083 stm32: Add support for 64KiB bootloader on stm32f103
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-03-24 10:02:21 -04:00
Kevin O'Connor 886530e777 stm32: Explicitly reset peripheral clocks on stm32f1
It appears some bootloaders do not properly reset some peripherals.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-03-24 10:00:45 -04:00
clearchris f87e29c775 armcm_boot: Additional code for broken bootloaders
Explicitly disable the SysTick interrupt and explicitly set the stack
pointer, as some bootloaders aren't handling this correctly.

Signed-off-by: Chris Lombardi <clearchris@hotmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-03-04 19:50:56 -05:00
Kevin O'Connor 79e2376993 stm32: Add support for a bootloader on stm32f0
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-03-04 19:50:56 -05:00
Kevin O'Connor 121249c999 stm32: Revert "stm32: performance improvement for spi on stm32f0"
This reverts commit a2c309a2b0.

The above commit is causing crashes on the stm32f103xb chip when spi
is in use.  It's unclear what the cause of the regression is, but the
optimization isn't required so revert it until the root cause can be
determined.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-03-04 18:33:34 -05:00
Kevin O'Connor e9e0f59204 stepper: Add some comments on s->position tracking
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-03-04 14:30:41 -05:00
Kevin O'Connor 31b2c3ea7a stm32: Fix broken clock setup on stm32f1
Commit bd6c25c9 introduced a typo that caused the clock divisors to
not be set correctly on stm32f1.

Reported by @brianrjones69.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-02-29 13:14:12 -05:00
Kevin O'Connor 98c7c7603e basecmd: No need for finalize_config command to send "config" response
The host code always issues a get_config command immediately after
finalize_config, so there is no need to send the two config response
messages.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-02-20 12:01:21 -05:00
Kevin O'Connor b5c967acd8 stm32: The stm32f1 can only reach 64Mhz when using an internal clock
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-02-14 12:11:50 -05:00
Kevin O'Connor 6f4822fe96 stm32: Fix typo that broke selection of alternate serial port pin
Fix a typo in commit aea15250.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-02-09 12:01:43 -05:00
Kevin O'Connor 502e83725b stm32: Reset adc calibration prior to starting calibration
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-01-25 11:23:58 -05:00
Kevin O'Connor bf3fa979f9 stm32: Increase adc sample time
Increase the sample time register from 3 to 4 (which adds about ~1.5us
to each adc sample).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-01-25 10:50:29 -05:00
Kevin O'Connor aea15250ae stm32: Only declare alternate usart2 on stm32f0
Also, try to improve the structure of the #if/#else/#endif layout in
serial.c.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-01-23 11:39:40 -05:00
Kevin O'Connor c8a93cb3bf stm32: Don't export spi1a/spi2a on stm32f1
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-01-23 11:36:28 -05:00
Arne Jansen 0cd4d5d5ea stm32: add alternate pinout for USART2
Added to both generic stm32 and stm32f0

Signed-off-by: Arne Jansen <arne@die-jansens.de>
2020-01-23 11:10:39 -05:00
Arne Jansen 5ce86bd005 stm32: add alternate pinouts for spi1/2
In addition to spi3, spi1 and spi2 also have alternate pins. Add them as
spi1a and spi2a, similar to spi3.

Signed-off-by: Arne Jansen <arne@die-jansens.de>
2020-01-23 11:10:39 -05:00
Arne Jansen a2c309a2b0 stm32: performance improvement for spi on stm32f0
The stm32 has a small queue for spi tx/rx. The current code only uses the
spi with a single byte buffer, effectively waiting for each byte to complete
before starting the next transfer.
This patch changes the structure of spi_transfer() to make use of the queue
and achieve back-to-back transfer of bytes on spi.

Signed-off-by: Arne Jansen <arne@die-jansens.de>
2020-01-23 11:10:39 -05:00
Arne Jansen ce35ee45d6 stm32: fix spi_transfer for stm32f0
The current code accesses the DR as 32 bit. This enabled data packing mode,
effectively adding a 00 byte between each sent byte. The receive side had
similar problems.
To prevent this, all accesses are 8 bit now, even though this is not
necessary on stmf[14].

Signed-off-by: Arne Jansen <arne@die-jansens.de>
2020-01-23 11:10:39 -05:00
akatik b3c3b61387 lpc176x: Add support for ssp1 (#2393)
Signed-off-by: Andrey Kovalev <aka@pxe.ru>
2020-01-14 22:06:29 -05:00
Eug Krashtan b70416167b stm32f0: Remove hal based stm32f0 implementation
Signed-off-by: Eug Krashtan <eug.krashtan@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-01-14 17:08:01 -05:00
Eug Krashtan a34dbc7029 stm32: STM32F0 CAN feature
Signed-off-by: Eug Krashtan <eug.krashtan@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-01-14 17:05:28 -05:00
Eug Krashtan 5238c3f872 stm32: HSI selection fix; Pin swap rename; Add CAN selection
Signed-off-by: Eug Krashtan <eug.krashtan@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-01-14 17:05:28 -05:00
Arksine 20ba396466 linux: implement i2c
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-01-13 22:29:50 -05:00
Arksine 5fe9dd5a50 avr: implement i2c_read
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-01-13 22:29:50 -05:00
Tobias Weiß 58abd2925e config: Fysetc S6 generic configuration (#2220)
Signed-off-by: Tobias Weiß <t.weiss@bk.ru>
2019-12-18 11:13:25 -05:00
Kevin O'Connor 73e84abaff atsam: Fix typo causing chipid to not be fully read
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-27 14:33:20 -05:00
Kevin O'Connor ef2c7cb363 stm32: Fix typo in setting of SMPR1 register on stm32f103
Only the stm32f4 has a SMP18 field; it's not present on the stm32f103.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-27 11:26:17 -05:00
Kevin O'Connor fc476f22b6 stm32: Fix typo in adc startup delay
Fix (harmless) typo and add comments on adc timing.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-27 11:16:41 -05:00
Kevin O'Connor 43dfb3c9ad lcd_hd44780: Minor change to timing delays
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-26 09:49:43 -05:00
Kevin O'Connor fb485e862d lcd_hd44780: Add proper timing delays around gpio updates
A fast micro-controller may update the gpio pins faster than the
hd44780 chip can handle.  Add in the appropriate delays.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-26 09:37:30 -05:00
Kevin O'Connor 35de9b8e55 lpc176x: Move chip id code from usbserial.c to new file chipid.c
Add a chipid.c file - this makes the code layout more similar to the
other arm boards.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-26 08:54:40 -05:00
Kevin O'Connor e80ced5568 usb_cdc: Report MCU type on all boards
Always report the "product id" as the MCU type (instead of as "Klipper
firmware").

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-26 08:45:20 -05:00
Kevin O'Connor 401f7a879c atsam: Enable chipid as usb serial number
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-26 08:42:14 -05:00
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
Kevin O'Connor 8f6efe5a7b stm32: Enable chipid as usb serial number
Signed-off-by: Matt Baker <baker.matt.j@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-25 19:30:31 -05:00
Kevin O'Connor f76cb92b15 usb_cdc: Add a usb_fill_serial() helper function
Add a helper function to fill the usb serial string descriptor.  Use
it in the lpc176x code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-25 18:32:52 -05:00
Kevin O'Connor bd6c25c9f8 stm32: Allow external crystal speed to be customized in Kconfig
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-25 14:04:26 -05:00
Kevin O'Connor 430b8d0e52 usb_cdc: Report the MCU name instead of "Klipper firmware"
Change the "product id" from the redundant "Klipper firmware" to the
CONFIG_MCU value.  For now, only make this change on boards that have
CONFIG_HAVE_CHIPID set.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-21 11:56:31 -05:00
Kevin O'Connor d8b6ff5c5e lpc176x: Minor rework of HAVE_CHIPID kconfig
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-21 11:54:46 -05:00
Matt Baker bab27651a1 lpc176x: read chip id and use as usb serial. (#2184)
Signed-off-by: Matt Baker <baker.matt.j@gmail.com>
2019-11-21 11:54:20 -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 9ff4f1bb2f stm32f0: Initial support for i2c on stm32f0
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-14 15:54:28 -05:00
clearchris 009d14fc3e stm32: adc for new stm32f0 common code (#2120)
Derived from stm32/adc.c and stm32f0/adc.c with additional changes.

Tested on Monoprice Mini Delta (malyan) stm32f070xb board.

Signed-off-by: Chris Lombardi <clearchris@hotmail.com>
2019-11-05 10:08:32 -05:00
Kevin O'Connor cf6e8a2eee stm32: Define PGx pins on stm32f103
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-02 11:35:27 -04: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 5131ec5eb0 stm32: Add support for flashing over usb on stm32f042
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-26 17:11:04 -04:00
Kevin O'Connor 2ecc8d8f62 stm32: stm32f4 usb boot check only needed when CONFIG_USBSERIAL
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-26 16:56:33 -04:00
Kevin O'Connor 5da6a62759 stm32f4: Add support for flashing over USB
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-26 13:24:59 -04:00
Kevin O'Connor 081c24326d atsam: sysio support is only available on sam4s
Fix sam4e build error introduced in commit f723a314.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-24 22:21:47 -04:00
Kevin O'Connor f723a3141e atsam: Allow PB4-PB7,PB10-PB12 to be used as gpio on sam4
A separate "sysio" register must be set in order to use some port B
pins on the sam4 mcu.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-24 22:02:29 -04:00
Kevin O'Connor 9a11286327 stm32: Implement armcm_main() in arch specific code
Move armcm_main() to stm32f0.c, stm32f1.c, and stm32f4.c.  This gives
the arch specific code more control on the early boot setup.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-24 11:35:18 -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 0b0c47c566 stm32: Support PA11/PA12 pin remap on stm32f042 tsop20 chip
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-23 21:34:48 -04:00
Kevin O'Connor a6d90bb95e stm32: Support stm32f042 build from stm32/ directory
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-23 21:34:48 -04:00
Kevin O'Connor 2c535106ee stm32: Initial support for stm32f070
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-23 21:19:03 -04:00
Kevin O'Connor 7b792e40d5 stm32f0: Rename internal build symbol from MACH_STM32F0 to MACH_STM32F0_HAL
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-23 21:16:35 -04:00
Kevin O'Connor a46244057c stm32: Support 16bit packet memory access on usbfs controller
The stm32f0 line uses 16bit packet memory reads/writes (as opposed to
the goofy 32bit accesses required on the stm32f103).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-23 21:16:35 -04:00
Kevin O'Connor c2881f7d15 stm32: Be explicit in layout of gpio banks in digital_regs variable
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-23 21:16:35 -04:00
Kevin O'Connor 40d076cce5 stm32: Use stm32f103xe header for stm32f103 line
Use the "e" revision so that the SPI3 device is available for use.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-23 15:49:00 -04:00
Kevin O'Connor 1e8582e3f6 stm32: Make sure to turn on the usb clock before writing to the packet memory
The USB clock needs to be enabled prior to writing to the USB packet
memory.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-10-13 14:33:23 -04:00
Kevin O'Connor bbf6f87de0 avr: List 20Mhz option below 16Mhz option in Kconfig
When enabling "low level options" in Kconfig, selecting a chip that is
20Mhz capable would result in 20Mhz being the default.  A 16Mhz speed
is the preferred default, so list that first in the menu.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-30 10:05:02 -04:00
Kevin O'Connor e90d9c33eb lpc176x: Use FIOPIN to set start value on gpio_out_reset()
The FIOSET and FIOCLR registers may not set an initial value if the
pin is not in an output mode.  So, use FIOPIN to set the initial
value.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-29 17:02:39 -04:00
Kevin O'Connor 626cb71428 stm32: Only prompt for a bootloader on stm32f103 and stm32f407
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-18 12:11:52 -04:00
Kevin O'Connor 9e2c17f468 atsam: No need to call SystemInit() from main()
The SystemInit() is already called from armcm_boot.c.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-18 11:59:43 -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 80e17b1e53 stm32: Move VTOR fixup from main() to chip specific code
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-18 11:59:43 -04:00
Kevin O'Connor 8cb3d09484 stm32: Move usb_request_bootloader() to chip specific code
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-18 11:59:43 -04:00
Kevin O'Connor 4f889ecd93 stm32: Fix usbfs rx buffer sizing
The usbfs receive buffers must also have space for the 2 byte crc at
the end of a transmission.  This fixes an error that could lead to
lost messages from mcu to host (resulting in bytes_invalid increasing
in stats) on the stm32f103.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-16 19:33:06 -04:00
Kevin O'Connor 045c938a61 stm32: Use official defines for EPR bits
Use the standard definitions for the endpoint register bits.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-16 18:39:54 -04:00
Kevin O'Connor 86cf361486 stm32: Rename USB_BTABLE to EPM in usbfs.c
Rename the internal definition so it isn't in conflict with the
USB_BTABLE register.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-16 18:39:47 -04:00
Kevin O'Connor c780537c57 atsam: Add missing PB21 pin to ADC module
Reported by @mental405.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-16 10:50:24 -04:00
Kevin O'Connor 60ae92d143 stm32: Disable usb irqs in usbotg handlers
It appears the usbotg controller can get confused if the usb irq
handler runs while processing a usb request.  Disable usb irqs during
usb processing to avoid this.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-12 08:12:51 -04:00
Kevin O'Connor 8d4a5c16be atsam: Enable flash loop caching optimization on sam4s
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-08 09:11:41 -04:00
Kevin O'Connor 4fa41d9c61 stm32: Rework usbotg transmit interrupts
Use the XFRC interrupt instead of TXFE.  Don't mask/unmask the tx
interrupts during runtime.  This fixes some race conditions where a tx
notification may have previously gotten lost.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-08 00:07:16 -04:00
Kevin O'Connor dc9f9ea1d6 stm32: Add support for SPI3 bus on alternate PC11,PC12,PC10 pins
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-05 22:42:48 -04:00
Kevin O'Connor 4097a02585 tmcuart: Fix typo in function name
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-09-01 14:56:09 -04:00
Kevin O'Connor 7031202e7c stm32: Add support for SPI1 and SPI3 busses
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-31 19:55:30 -04:00
Kevin O'Connor 017a4d8321 stm32: Fix gpio enumerations (each bank has 16 pins, not 32)
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-31 18:35:01 -04:00
Kevin O'Connor c380d4639b stm32: Work around stm32f407 usbotg chip errata
It appears bogus entries can get placed on the rxqueue - detect and
clear them.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-31 15:16:46 -04:00
Kevin O'Connor 9335cc4804 stm32: Configure and enable usbotg endpoint0 during setup
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-30 12:15:45 -04:00
Kevin O'Connor 4a178824aa stm32: Disable and flush usbotg bulk transmit pipe on usb_set_configure()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-30 12:15:45 -04:00
Kevin O'Connor 7eba063ac8 stm32: Perform usbotg endpoint init during usb_set_configure()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-30 12:15:45 -04:00
Kevin O'Connor 917fd51057 stm32: Discard usbotg tx data until usb is ready
If the usb interface is not ready, just discard messages.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-30 12:15:45 -04:00
Kevin O'Connor 5e3acff8c7 stm32: No need to clear the usbotg address on reset
The controller automatically clears the address.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-30 12:15:45 -04:00
Kevin O'Connor 7229680227 stm32: Enable usbotg bulk reads during endpoint configuration
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-30 12:15:32 -04:00
Kevin O'Connor c95209bf7a atsam: ADC pins need to be in input mode with pullups disabled
The ADC pins (on at least the sam3x8e) need to be configured in input
mode with the internal pullups disabled in order to get accurate ADC
readings.

Reported by @bryanboettcher.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-28 13:45:01 -04:00
Kevin O'Connor 8f5c15d4dc buildcommands: Match DECL_X names to the actual C macro names
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-22 13:26:30 -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 ff7be3e026 ctr: Encode negative integers in normal hex notation
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-22 13:06:44 -04:00
Kevin O'Connor 7d014933ce command: Allow count parameter of DECL_ENUMERATION_RANGE() to be an expression
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-22 12:22:51 -04:00
Kevin O'Connor 84fd89b8cf ctr: Add support for multiple integers in DECL_CTR_INT
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-22 12:22:51 -04:00
Kevin O'Connor e59d875256 ctr: Encode integers in hex
Replace the custom encoding with a hex encoding.  This makes it a
little easier to inspect the CTR conversions.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-22 11:08:51 -04:00
Kevin O'Connor 69fc1e63b4 Makefile: Translate null characters to newline characters in ctr requests
Store the CTR requests in compile_time_request.txt with the null
characters removed.  This makes it slightly easier to inspect the CTR
conversions.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-22 10:35:26 -04:00
Kevin O'Connor 1022729a2a lpc176x: Update code to use armcm_boot mechanism
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-22 09:58:58 -04:00
Kevin O'Connor 6409eda058 lpc176x: 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 44f862388f atsam: Update code to use armcm_boot mechanism
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-22 09:58:58 -04:00
Kevin O'Connor fc879456db atsam: 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 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 4ef53ab095 stm32: Update code to use armcm_boot mechanism
Replace the stm32 provided assembler 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 a44bc950a3 stm32: 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 2a2cf1f536 armcm_boot: Add generic code for early board init on armcm machines
Add basic ARM Cortex-M C init code and build linker scripts to
src/generic/ code.  This can be used to simplify the various ARM board
code.

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 9c15f00e60 armcm_timer: Fix typo in comment in armcm_timer.h
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-21 12:05:13 -04:00
Kevin O'Connor 078d278611 stm32: Initial support for i2c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-20 19:39:58 -04:00
Kevin O'Connor e32be928dc stm32: Add support for configuring open drain output mode
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-20 19:39:49 -04:00
Kevin O'Connor c930fc392b stm32: Make sure to enable the gpio clock prior to setting the first value
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-20 01:10:14 -04:00
Kevin O'Connor 6c908952bd spi_software: Remove unused include file
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-17 13:49:03 -04:00
Kevin O'Connor 8aca7764c3 stm32: Simplify usbotg packet reading and writing
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-16 21:03:47 -04:00
Kevin O'Connor 4ec6db7a87 stm32: Add support for additional ADC3 ports on stm32f4
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-15 23:21:41 -04:00
Kevin O'Connor aac51bdb0a stm32: Initial support for USB On-The-Go (OTG) driver on stm32f4
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-15 22:26:49 -04:00
Kevin O'Connor 841150ff00 stm32: Enable 48Mhz USB clock on stm32f446
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-14 19:33:11 -04:00
Kevin O'Connor effe6f6ddd lcd_st7920: Add brief delay around gpio toggle calls on fast MCUs
On fast MCUs (like the SAMD51) it is possible for the gpio to toggle
faster than the st7920 can accept.  Add a small delay around the clock
rise signal.

Signed-off-by: Lars R. Hansen <popshansen@hotmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-10 11:45:15 -04:00
Kevin O'Connor a70055a625 stm32: Add support for the 32KiB bootloader on the SKR Pro
Signed-off-by: Gerrit Sturm <gsturm16@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-09 20:37:31 -04:00
Kevin O'Connor 96ff54e143 stm32: Add serial USART serial port option for port PD9/PD8
Signed-off-by: Gerrit Sturm <gsturm16@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-09 20:32:46 -04:00
Kevin O'Connor f6d1ab2ea2 neopixel: Rework timing so that it works on AVR micro-controllers
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-07 15:37:05 -04:00
Kevin O'Connor 8712648370 stm32: Fix memory sizing for STM32F405/7 chips
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-06 23:35:45 -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 3d0f7188df stm32: Automatically disable SWD if PA13/PA14 is used on stm32f103
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-05 11:39:42 -04:00
Kevin O'Connor 36217f27aa stm32f1: Remove now unused src/stm32f1/ directory
Now that the stm32f1 code has been merged into the stm32 code, there
is no longer a need to keep the stm32f1/ directory.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-05 11:25:40 -04:00
Kevin O'Connor fe065d72d0 stm32: Rename clock.c to stm32f4.c
Rename the clock.c file to stm32f4.c to make it more clear that the
code is specific to the stm32f4 chips.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-05 11:25:40 -04:00
Kevin O'Connor 8b9cc62359 stm32: Rename stm32f4/ directory to stm32/
Now that the code in stm32f4/ can handle both stm32f1 and stm32f4
chips, rename the directory to just "stm32".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-05 11:25:40 -04:00
Kevin O'Connor ec3d865b51 stm32f4: Add support for USB on stm32f103
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-05 11:25:40 -04:00
Kevin O'Connor 7efc53ff59 stm32f4: Add support for STM32F103
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-08-05 11:25:40 -04:00
Kevin O'Connor c176b66f29 stm32f4: Allow the USART serial port to be configured
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-28 22:55:48 -04:00
Kevin O'Connor e6ffef9a9f stm32f4: Make using the internal clock source a low level option
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-28 22:55:48 -04:00
Kevin O'Connor 9bc3a29ee4 stm32f4: Add support for full range of GPIO pins
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-28 22:55:48 -04:00
Kevin O'Connor bc9c8cd7a0 stm32f4: Only enable peripherals once
Add is_enabled_pclock() and only initialize spi and adc once during
configuration.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-28 17:57:02 -04:00
Kevin O'Connor ef0784afe6 stm32f4: Encode mode/func into single parameter of gpio_peripheral
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-28 11:32:56 -04:00
Kevin O'Connor 92c2fbdce4 armcm_timer: Improve comments on wrap_timer code
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-27 22:05:50 -04:00
Kevin O'Connor 7bc0a261ab stm32f4: Automatically calculate dynmem start/end
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-27 21:32:04 -04:00
Kevin O'Connor 16616662ed stm32f4: Add Kconfig build rules for STM32F405/7
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-27 21:32:04 -04:00
Kevin O'Connor 961d13ee1a stm32f4: Add support for SPI
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-27 21:01:01 -04:00
Kevin O'Connor d79f99b188 stm32f4: Add support for ADC
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-27 10:58:28 -04:00
Kevin O'Connor 73709984b0 stm32f4: Add support for watchdog
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-26 08:36:11 -04:00
Kevin O'Connor 899b6726fa stm32f4: Improve serial baud rate calculation
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-26 08:01:31 -04:00
Kevin O'Connor f3d7287a28 stm32f4: Add support for external 8Mhz crystal
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-26 07:51:12 -04:00
Kevin O'Connor 1487f8a257 stm32f4: Add support for GPIO
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-25 18:13:06 -04:00
Kevin O'Connor d501ca6b0b stm32f4: Add initial support for STM32F446 chip
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-25 18:08:28 -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 634ec46813 initial_pins: Only build when CONFIG_HAVE_GPIO is enabled
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-24 01:09:45 -04:00
Kevin O'Connor 79bd13dba7 armcm_timer: Support micro-controllers faster than 160Mhz
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-24 01:08:18 -04:00
Kevin O'Connor 4e5ddff00b neopixel: Update to more flexible bit-banging timing
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-23 22:00:12 -04:00
Kevin O'Connor 893acdb56b lib: Update stm32f1 code to version 1.8.0
Update the stm32f1 code to the latest from ST.  Merge the
lib/cmsis-stm32f1/ and lib/hal-stm32f1/ into a single lib/stm32f1/
directory.  Document all the differences from the pristine upstream
code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-21 22:40:56 -04:00
Kevin O'Connor 1a387ad509 stm32f0: Remove trailing tab from Makefile
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-21 21:49:22 -04:00
Kevin O'Connor d5cc2a7b7b neopixel: Improve timing of gpio bit-banging
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-17 16:36:28 -04:00
Kevin O'Connor 0af5b9ff6d neopixel: Be sure to set the line low on a failed write
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-13 00:00:57 -04:00
Kevin O'Connor be2d0abbab neopixel: Optimize the update loop
Optimize the transmit code so it can run on some slower ARM cpus.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-12 23:39:00 -04:00
Kevin O'Connor b7bc96c3b2 neopixel: Add initial support for "neopixel" leds
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-12 21:44:01 -04:00
Kevin O'Connor 28aa2f507a endstop: Rename mcu end_stop commands to endstop
Rename the commands.

The main reason for this change is to force a micro-controller code
updated (due to important bugfix in 7fefe52d).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-12 08:10:53 -04:00
Kevin O'Connor 7fefe52df7 stepper: Don't update SF_LAST_DIR if SF_NEED_RESET
If the move is not added to the move queue, then the SF_LAST_DIR
setting must not be changed.  Otherwise, it could result in an
incorrect direction being set on the stepper after a homing operation.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-12 07:54:24 -04:00
Kevin O'Connor b77375e955 lpc176x: Reset LPC_UART0->FDR when using serial
The popular "LPC17xx-DFU-Bootloader" alters the LPC_UART0->FDR
register, so be sure to reset it back to its default when using serial
in Klipper.

Reported by @b-vs.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-10 20:00:58 -04:00
Arksine 0f1d42466b buttons: initialize mcu buttons based on inverted state
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2019-07-05 20:01:07 -04:00
Kevin O'Connor 8951dc3d51 lpc176x: Add more filtering to workaround adc hardware defect
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-06-20 08:57:24 -04:00
Kevin O'Connor 8d029ad652 lpc176x: Fix adc clock divisor
Commit 1096075d changed CONFIG_CLOCK_FREQ to the actual cpu frequency,
but that commit failed to update adc.c accordingly.  That made the adc
run 4 times slower.  Make the corresponding change to adc.c.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-06-19 21:21:01 -04:00
Kevin O'Connor 700e35c6ac armcm_timer: Unify udelay() implementation
Move the udelay() code from various arm board directories into the
src/generic/armcm_timer.c code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-06-09 20:27:57 -04:00
Kevin O'Connor 3910a44cc9 atsam: Add support for "timer" controlled hardware pwm pins
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-06-02 10:59:33 -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 8532e2123e gpiocmds: Specify soft pwm duration in clock ticks
Improve the precision of soft pwm pulses by allowing the host to
directly specify the clock duration of the pulse.  This improvement in
precision may be noticeable when controller servos (and bltouch).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-05-26 11:09:32 -04:00
Kevin O'Connor 2469356861 stm32f1: Add support for building with a 0x7000 code offset
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-05-23 13:36:15 -04:00
Kevin O'Connor edb679b83d atsam: Enable pullup on i2c SDA line
The internal pullup helps ensure i2c errors are detected properly.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-05-23 09:32:10 -04:00
Kevin O'Connor 24b1638c25 atsam: Improve i2c timeout detection
Unify timeout detection in i2c_write() and i2c_read().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-05-23 09:32:10 -04:00
Kevin O'Connor 5fe5f09244 atsam: Minor whitespace changes to i2c.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-05-23 09:13:55 -04:00
Kevin O'Connor bcfd101867 spi_software: Minor simplification to spi_software_prepare()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-05-22 11:40:30 -04:00
Kevin O'Connor ab5238317b avr: Simplify spi mode setting
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-05-07 23:02:20 -04:00
Matt Baker c95705ba3a spi_software: save mode setting in config structure.
Signed-off-by: Matt Baker <baker.matt.j@gmail.com>
2019-05-07 00:03:17 -04:00
Matt Baker 38f3d65ac5 lpc176x: refactor usbserial to use udelay helper.
Signed-off-by: Matt Baker <baker.matt.j@gmail.com>
2019-04-06 20:53:15 -04:00
Matt Baker e83071c9fe lpc176x: force minimum usb disconnect time
Fixes GitHub Issue #1499. Resolves USB hang by forcing a minimum
USB disconnection time at boot.

Signed-off-by: Matt Baker <baker.matt.j@gmail.com>
2019-04-06 20:53:15 -04:00
Janne Grunau aab89e7f85 linux: add support for Linux hardware PWM
The replicape servo pins (P9_14/P9_16) are muxed to the SOCs hardware
PWM unit driven by a 13MHz GP timer. They have to be driven by the
linux host mcu. This commits adds hardware PWM support using the linux
sysfs user space interface.

Signed-off-by: Janne Grunau <janne-3d@jannau.net>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-04-05 19:06:15 -04:00
Janne Grunau e6c3eeafd7 pwmcmds: allow 16-bit resolution
Signed-off-by: Janne Grunau <janne-3d@jannau.net>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-04-05 19:02:48 -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 f8bde6b1ef linux: Convert SPI to use enumerations
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-04-04 18:29:31 -04:00
Kevin O'Connor 3e71a57f67 lpc176x: 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 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 7e8ecfe177 atsam: 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 7765653d83 avr: 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 4c3d50693e bus: Change bus parameter in config_spi/config_i2c
Be explicit when using an spi_bus vs i2c_bus in the parameter name.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-04-04 18:29:31 -04:00
Kevin O'Connor 2c851e1621 avr: Add enumerations for the atmega168/328 analog only pins
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-03-31 21:47:27 -04:00
smark- eedc773d69 stm32f1: Fix ADC (#1474)
The sampling time of the ADC was too slow (239 ADC clock cycles), causing the reading of the next ADC channel to have cross talk as per issue #1261. Sampling time updated to 41 ADC clock cycles.

Signed-off-by: Marco D'Alessio <marco@wrecklab.com>
2019-03-31 14:32:27 -04:00
Kevin O'Connor d1eefba453 pru: The TMR_CNT is cleared by writing all ones
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-03-31 13:48:50 -04:00