aboutsummaryrefslogtreecommitdiffstats
path: root/src/stm32f1
Commit message (Collapse)AuthorAgeFilesLines
* stm32f1: Remove now unused src/stm32f1/ directoryKevin O'Connor2019-08-0511-1138/+0
| | | | | | | 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>
* lib: Update stm32f1 code to version 1.8.0Kevin O'Connor2019-07-212-11/+6
| | | | | | | | | 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>
* armcm_timer: Unify udelay() implementationKevin O'Connor2019-06-093-16/+1
| | | | | | | 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>
* stm32f1: Add support for building with a 0x7000 code offsetKevin O'Connor2019-05-231-0/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: Fix ADC (#1474)smark-2019-03-311-1/+1
| | | | | 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>
* stm32f1: Use enumerations for pin mappingsKevin O'Connor2019-03-171-0/+6
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* command: Always pass a string to the DECL_CONSTANT() macroKevin O'Connor2019-03-172-2/+2
| | | | | | | | 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>
* flash_usb: Run dfu-util via sudoKevin O'Connor2019-03-111-1/+1
| | | | | | | Default to running dfu-util via sudo as most machines will not have the user setup with permissions to access the raw usb device. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: Add support for entering the bootloader via USBKevin O'Connor2019-03-083-2/+17
| | | | | | | | | | | | Add support for entering the "stm32duino" bootloader via the arduino 1200 baud USB request. Add supprot for flashing over USB via the "make flash" command. Rename the existing "make flash" command to "make serialflash". Default to using a bootloader in Kconfig. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Makefile: Reduce use of $^ in build rulesKevin O'Connor2019-03-021-2/+2
| | | | | | | 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>
* Makefile: Fix lpc176x and stm32f1 buildsKevin O'Connor2019-03-021-7/+6
| | | | | | | | | Commit e18501d0 broke the build for targets that added objects to klipper.elf via adding dependencies. Rework the build so that it is possible to add objects to klipper.elf via a new OBJS_klipper.elf makefile variable. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: Wrap code to 80 columnsKevin O'Connor2019-02-273-3/+6
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pins: Add support for pull down resistorsKevin O'Connor2019-02-271-1/+2
| | | | | | | Add initial support for selecting pull down resistors (for micro-controllers that support it). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: Convert code to use armcm_timerKevin O'Connor2019-02-064-123/+5
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: Use internal functions for early USB gpio toggleKevin O'Connor2019-02-063-6/+24
| | | | | | | Avoid using the "low-level" library timing utilities. This is in preparation for using SysTick as part of the timer implementation. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Kconfig: Move SERIAL_BAUD to src/Kconfig and show with LOW_LEVEL_OPTIONSKevin O'Connor2019-01-251-4/+0
| | | | | | | | 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>
* stm32f1: It's only necessary to program the CR1 register during SPI initKevin O'Connor2019-01-073-11/+9
| | | | | | Only set the CR1 register during spi_prepare(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* usb_cdc: Add support for detecting a USB level Arduino bootloader requestKevin O'Connor2018-12-241-0/+5
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: Always read SPI receive bufferYannic Schroeder2018-12-141-2/+3
| | | | | | | Otherwise the first byte read via SPI may be the last byte of the previous transfer Signed-off-by: Yannic Schroeder <schroeder@ibr.cs.tu-bs.de>
* spicmds: Check for an incorrect mode in spicmds.cKevin O'Connor2018-11-301-2/+0
| | | | | | | Check the mode parameter in spicmds.c so that the mcu code does not need to check it. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: Move ADC and SPI code from gpio.c to spi.c and adc.cKevin O'Connor2018-11-305-217/+238
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: Use __always_inline on timer_read_timeKevin O'Connor2018-10-111-1/+1
| | | | | | | | Some older versions of gcc need the __always_inline directive in order to inline timer_read_time. Inlining that function is important for performance on the stm32f1. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: Use -O2 optimization and inline timer_read_time()Kevin O'Connor2018-10-112-2/+1
| | | | | | | | As long as timer_read_time() is inlined, I get better performance with gcc -O2 optimization. The binary is also dramatically smaller and O2 better matches the other platforms. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: Use the main lib/cmsis-core directory for cmsis includesKevin O'Connor2018-10-111-2/+2
| | | | | | Use the main cmsis header files with stm32f1. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: Add support for building with bootloader supportKevin O'Connor2018-10-114-2/+136
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: Move assembler build rules togetherKevin O'Connor2018-10-111-10/+9
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: Pull the USB D+ line low briefly to signal a device connectKevin O'Connor2018-10-111-0/+8
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: Initial support for serial over USBKevin O'Connor2018-10-113-1/+286
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: Serial should have a higher irq priority than timersKevin O'Connor2018-10-112-3/+2
| | | | | | | | | It's possible for the code to stay in the timer irq for up to 100ms, so serial irqs should have a higher irq priority to prevent them from being starved. (The timer code disables irqs during event dispatch, so serial irqs would only be permitted between events anyway.) Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: Add support for gpio_x_reset()Kevin O'Connor2018-08-272-12/+28
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Kconfig: Rename HAVE_USER_INTERFACE to HAVE_GPIO_BITBANGINGKevin O'Connor2018-08-271-1/+1
| | | | | | | Rename the HAVE_USER_INTERFACE definition in preparation for other "bit banging" interfaces. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: implement spi_prepareGrigori Goronzy2018-07-081-3/+2
| | | | | | | | | | | | | | | | | | Implement spi_prepare to fix the undefined behavior on SPI transaction start. Tested with the following command sequence: allocate_oids count=2 config_spi oid=0 bus=0 pin=PA8 mode=3 rate=1000000 shutdown_msg= config_spi oid=1 bus=0 pin=PA8 mode=1 rate=1000000 shutdown_msg= spi_send oid=0 data=30313233343536373839 spi_transfer oid=1 data=3031 Discussion about this here: https://github.com/KevinOConnor/klipper/pull/453#issuecomment-403131149 Signed-off-by: Grigori Goronzy <greg@chown.ath.cx>
* SPI: introduce spi_prepare functionGrigori Goronzy2018-07-082-0/+6
| | | | | | | | | | | | | | | | The SPI interface needs to be enabled and configured to the correct settings of a given oid before CS is asserted. The new function spi_prepare() allows ports to do that. This port only introduces the new function in all ports with no implementation and adds the call to the Klipper generic firmware code. That means everything still works as before. Ports need to be changed to fix the underlying issue. Discussion about the motivation here: https://github.com/KevinOConnor/klipper/pull/453#issuecomment-403131149 Signed-off-by: Grigori Goronzy <greg@chown.ath.cx>
* stm32f1: add SPI supportGrigori Goronzy2018-07-074-0/+118
| | | | | | | | | Add basic SPI support and associated documentation. v2: remove baud rate check, fix baud rate calculations v3: finish transaction with BSY check, disable SPI when not in use Signed-off-by: Grigori Goronzy <greg@chown.ath.cx>
* stm32f1: fix ADC pin listGrigori Goronzy2018-06-271-1/+1
| | | | | | | For some reason, the upper two pin definitions were missing. Found while writing the port documentation. Signed-off-by: Grigori Goronzy <greg@chown.ath.cx>
* stepper: Introduce and use gpio_out_toggle_noirq()Kevin O'Connor2018-05-152-1/+10
| | | | | | | | | | | | | | | The gpio_out_toggle() function in the sam3x8e and stm32f1 code was only valid if it was called with irqs disabled. Commits 018c5daa and 9c52ad43 enabled the lcd code which called gpio_out_toggle() with irqs enabled. This could cause corruption of the gpio state. Introduce a gpio_out_toggle_noirq() function that will only be invoked with irqs disabled, and fix gpio_out_toggle() on sam3x8e and stm32f1 so that it safe to call even if irqs are enabled. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: Enable lcd chip supportKevin O'Connor2018-05-071-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serial_irq: Add new generic/serial_irq.c codeKevin O'Connor2018-04-202-115/+13
| | | | | | | Extract out common code from avr/serial.c, sam3x8e/serial.c, and stm32f1/serial.c into a new generic/serial_irq.c file. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: Use generic timer_irq.c dispatch codeKevin O'Connor2018-04-201-62/+3
| | | | | | | | | With the optimized timer_read_time() it is no longer necessary to implement custom timer dispatch code - use the generic mechanism in timer_irq.c. This simplifies the code and provides a small performance increase. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: Use different method for handling 16bit -> 32bit timer conversionKevin O'Connor2018-04-201-47/+39
| | | | | | | Implement 32bit timer conversion without disabling interrupts. This uses the 16th bit of timer_high as a rollover detection flag. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32f1: Prefer uint32_t over uint16_t in timer.cKevin O'Connor2018-04-201-6/+6
| | | | | | | The ARM architecture handles 32bit values faster than 16bit values - use uint32_t where possible. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Add STM32F103 portGrigori Goronzy2018-04-097-0/+808
Add a fully functional STM32F1 port, currently mostly targeting STM32F103 microcontrollers. This requires an 8 MHz XTAL. The maximum possible step rate is around 282K steps per second. This uses stm32flash to burn the firmware. The bootloader needs to be started by setting BOOT0 to 1 and resetting the MCU. There is no automatic bootloader, unlike on Arduino. Signed-off-by: Grigori Goronzy <greg@kinoho.net>