aboutsummaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* byteorder: Add a header file defining common byteswap functionsKevin O'Connor2018-05-211-0/+40
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Introduce and use gpio_out_toggle_noirq()Kevin O'Connor2018-05-1513-10/+46
| | | | | | | | | | | | | | | 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>
* linux: Convert linux SPI code to use the generic spicmds.c codeKevin O'Connor2018-05-073-11/+38
| | | | | | | | | | Use the generic spi send/receive code on Linux. Update the replicape code to use the updated command format. Also, update the replicape code to turn off the stepper motors on a shutdown event. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sam3x8e: Add SPI supportKevin O'Connor2018-05-074-1/+132
| | | | | Signed-off-by: Petri Honkala <cruwaller@gmail.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* spicmds: Rework SPI message transmissionKevin O'Connor2018-05-075-28/+203
| | | | | | | | | Improve the SPI message transmit system. Add support for bus speed and bus mode. Add support for sending SPI messages on shutdown. Signed-off-by: Petri Honkala <cruwaller@gmail.com> Signed-off-by: Douglas Hammond <wizhippo@gmail.com> 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>
* sam3x8e: Enable lcd chip supportKevin O'Connor2018-05-071-0/+1
| | | | | | Testing shows the hd44780 and st7920 chips do work on the Due. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Do not use Idle modeKevin O'Connor2018-04-282-9/+1
| | | | | | | | | | | | The AVR chips (bizarrely) start an ADC conversion when entering Idle mode. This behavior can cause the ADC to be busy when a sample is required. Worse, if a series of events cause the cpu to enter and leave Idle mode with a timing similar to the ADC checking rate then it can cause the ADC to show as busy for extended periods. This could cause high MCU load and possibly lead to a "Rescheduled timer in the past" shutdown. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Explicitly set ADCSRA on each conversion startKevin O'Connor2018-04-251-7/+10
| | | | | | | | Don't logically or the ADSC bit on the start of a conversion - explicitly set the full contents of the register. Also, clear the ADIF flag on each write. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Clean up serial port register aliasesKevin O'Connor2018-04-252-31/+38
| | | | | | | | Define unique register aliases for all of the hardware serial port definitions. This makes it easier to deal with the AVR chips that use different register names. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serial_irq: Add new generic/serial_irq.c codeKevin O'Connor2018-04-208-343/+166
| | | | | | | 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-098-0/+811
| | | | | | | | | | | | 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>
* lcd_hd44780: Add micro-controller code for the HD44780 LCD chipKevin O'Connor2018-03-062-1/+133
| | | | | | | Add support for passing messages to an HD44780 chip via a 4-bit bit-banging interface. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* lcd_st7920: Add micro-controller code for the ST7920 LCD chipKevin O'Connor2018-03-064-0/+126
| | | | | | | Add support for passing messages to an ST7920 chip via a SPI bit-banging interface. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Add at90usb646 supportDouglas Hammond2018-02-252-5/+9
| | | | Signed-off-by: Douglas Hammond wizhippo@gmail.com
* avr: Round hardware pwm clock ticks to nearest divisorKevin O'Connor2018-01-291-12/+12
| | | | | | | Instead of rounding down to the nearest supported pwm divisor, round to the nearest divisor. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Clear the TCNT1 register on timer startupKevin O'Connor2018-01-071-1/+2
| | | | | | Just to be safe, clear the TCNT1 register during init. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Clear the ADCSRA/ADCSRB registers on ADC initKevin O'Connor2018-01-071-2/+2
| | | | | | | When initializing the ADC, explicitly clear the registers (instead of logically or'ing them with their previous values). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Only use the avrdude "wiring" protocol on atmega2560 devicesKevin O'Connor2018-01-052-1/+7
| | | | | | | | It appears the most common type of avrdude protocol for devices other than the atmega2560 is the "arduino" protocol. Update the build to select a different protocol based on the avr processor type. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Interrupts must be disabled during setjmp() callKevin O'Connor2017-12-211-0/+3
| | | | | | | | | | On the AVR platform (and possibly others) the longjmp() call will restore the interrupt state saved during the setjmp() call. So, the setjmp() call must be invoked with interrupts disabled to ensure that shutdown handling is run with interrupts disabled. This fixes potential corruption of the shutdown processing on AVR. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gpiocmds: Clear SPF_NEXT_* flags on new schedule_soft_pwm_outKevin O'Connor2017-12-161-2/+2
| | | | | | | Properly handle the (unlikely) case that a schedule_soft_pwm_out command is received before a previous command is fully processed, Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* docs: Provide additional information on "make flash" failuresKevin O'Connor2017-12-112-2/+2
| | | | | | Add some additional information on "make flash" problems. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* linux: Remove unneeded includes from timer.cKevin O'Connor2017-10-231-2/+0
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Don't reset the ADC reset complete flag if a shutdown occursKevin O'Connor2017-10-181-1/+1
| | | | | | Only set the have_done_reset flag if the reset completes successfully. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* linux: Fix typo causing config_reset to not fully restartKevin O'Connor2017-10-151-1/+1
| | | | | | A typo in the code caused the wrong config_reset code to be run. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* linux: Open watchdog device after consoleKevin O'Connor2017-10-151-7/+5
| | | | | | | | Only open the watchdog device after the console has been opened. The machine should not reboot in the unlikely event the console can't be opened. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* linux: Make sure to close fd on analog/pca9685 init failureKevin O'Connor2017-10-142-11/+17
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pca9685: Fix missing devices_count incrementKevin O'Connor2017-10-131-0/+1
| | | | | | The devices_count was not being incremented on each device add. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pca9685: Support default valuesKevin O'Connor2017-10-121-21/+31
| | | | | | Allow the pwm pin to have a non-zero default value. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gpiocmds: Allow the start value for a pin to differ from the default_valueKevin O'Connor2017-10-122-14/+17
| | | | | | | | | Allow the start value to be different from the default/shutdown value for the pin. This will be useful for "heater fans" that should startup in the off state, and transition to full on in a shutdown state. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* adccmds: Continue to query analog inputs after a shutdownKevin O'Connor2017-10-122-2/+9
| | | | | | | | Continue to sample the ADC input pins even if the MCU goes into a shutdown state. This enables the printer to continue reporting temperatures even on an mcu error. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Don't shutdown on a "timer in the past" if already shutdownKevin O'Connor2017-10-124-6/+5
| | | | | | A shutdown will not help if the mcu is already in a shutdown state. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* endstop: Eliminate end_stop_set_oversample commandKevin O'Connor2017-10-121-21/+13
| | | | | | | | | | Pass the sample_ticks and sample_count parameters directly in the end_stop_home command instead. This simplifies the code. Also, simplify calculation of next wakeup time in end_stop_oversample_event(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Add support for atmega1284pKevin O'Connor2017-10-052-5/+13
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* endstop: Fix typo in commentKevin O'Connor2017-10-021-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* endstop: Support oversampling of the endstopKevin O'Connor2017-10-011-5/+45
| | | | | | | | Some printers can show occasional noise on the endstop pin. Support sampling the endstop pin multiple times to attempt to filter out this noise. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Update installation and flash scriptsKevin O'Connor2017-09-201-0/+4
| | | | | | | | | Update the scripts used to install and "flash" the pru micro-controller code. Also, add a "flash" script for the linux micro-controller code. This makes it easier to install Klipper on a Beaglebone board that uses a Replicape. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* linux: Add support for analog IIO devicesKevin O'Connor2017-09-205-2/+82
| | | | | | | | Add support for reading analog values via the standard Linux IIO interface. This can be used on Replicape boards to sample analog input pins. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* linux: Add support for spidev devicesKevin O'Connor2017-09-202-1/+69
| | | | | | | | Add support for sending SPI messages to devices via the standard Linux SPI interface. This can be used to configure the shift registers on Replicape boards. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* linux: Add support for pca9685 i2c pwm devicesKevin O'Connor2017-09-204-2/+210
| | | | | | | Add support for controlling pca9685 PWM drivers using the standard Linux I2C interface. The pca9685 device is found on Replicape boards. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* linux: Initial support for running Klipper in a Linux real-time processKevin O'Connor2017-09-209-1/+620
| | | | | | | Add support for compiling the Klipper micro-controller code as a real-time process capable of running on standard Linux systems. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Avoid calling "slp" instruction on pru0Kevin O'Connor2017-09-111-1/+3
| | | | | | | | If pru0 waits in sleep mode then a full beaglebone reboot is needed to reprogram the pru0 firmware. For now, avoid using the "slp" instruction as a workaround. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Batch outgoing writesKevin O'Connor2017-09-081-5/+31
| | | | | | | Allow pru0 to gather multiple outgoing message blocks into a single rpmsg. This can reduce communication overhead. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Fix race condition in clearing of irq flagsKevin O'Connor2017-09-081-2/+4
| | | | | | | | Each irq flag must only be cleared after it has been serviced. This fixes a race condition that could cause incoming commands to be delayed for extended period. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Provide some further help on common MCU shutdown errorsKevin O'Connor2017-09-053-3/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Check that FLASH_DEVICE is set on "make flash" commandKevin O'Connor2017-09-051-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Support config_reset command to manually reset mcuKevin O'Connor2017-09-035-2/+26
| | | | | | | Add support for resetting the MCU via a software only mechanism. This is useful on the PRU. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>