aboutsummaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* thermocouple: Minor fixesKevin O'Connor2018-07-251-6/+5
| | | | | | | | | | Send the temperature before checking for an out of range error (that makes it easier to debug). The query_thermocouple clock parameter is unpredictable and a value of zero can't be used to disable the query - use rest_ticks instead. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* thermocouple: Add support for MAX6675 chipRicardo Amezquita2018-07-241-3/+21
| | | | | | | The MAX6675 chip has a different read sequence than the MAX31855 chip. Signed-off-by: Ricardo Amézquita <ramezquitao@cihologramas.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* thermocouple: Add initial support for common SPI temperature sensing chipsKevin O'Connor2018-07-244-2/+197
| | | | | Signed-off-by: Petri Honkala <cruwaller@gmail.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* linux: Add support for bi-directional SPI communicationRicardo Amezquita2018-07-242-5/+33
| | | | | Signed-off-by: Ricardo Amézquita <ramezquitao@cihologramas.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* lpc176x: Add support for SPIKevin O'Connor2018-07-184-0/+91
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* atmega1284p: Add choice between UART0 or UART1 to KconfigPascal Albert2018-07-131-1/+12
| | | | Signed-off-by: Pascal Albert <lucky@foxserver.org>
* spidev: Minor rework to spidev_transfer()Kevin O'Connor2018-07-111-7/+7
| | | | | | | Gcc does a better job of inlining code if spidev_transfer() is reworked slightly. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sam3x8e: Configure spi transfer in spi_prepare()Kevin O'Connor2018-07-111-2/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Configure spi transfer in spi_prepare()Kevin O'Connor2018-07-111-4/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* simulator: Rework dummy simulator code to user timer_irq / serial_irqKevin O'Connor2018-07-116-109/+165
| | | | | | | | | Change the simulator to use the generic timer_irq.c and serial_irq.c code for (dummy) timer and io handling. This is just to make the code a better example for other developers (most micro-controllers will use the timer_irq.c and serial_irq.c code). 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-0811-0/+30
| | | | | | | | | | | | | | | | 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>
* sam3x8e: Read from the SPI_RDR on SPI send even if no data neededKevin O'Connor2018-07-051-8/+9
| | | | | | Be sure to read the SPI_RDR as that clears the RDRF flag. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* adccmds: Add support for min/max temperature check filteringKevin O'Connor2018-07-021-3/+12
| | | | | | | | | | | Extend the ADC out of range check so that it is possible to sample multiple times before going into a shutdown state. This reduces the chance that measurement noise will cause an error. In an actual over temperature (or under temperature event) it is expected that the sensor will consistently report the problem, so extra checks for an additional second or two should not substantially increase risk. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* buttons: Add initial support for detecting button pressesKevin O'Connor2018-06-302-1/+161
| | | | | | | Add mcu support for periodically polling for a button press. Add host code support for registering buttons and invoking callbacks for them. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcp4451: Add initial support for programming the mcp4451 on lpc176xKevin O'Connor2018-06-292-1/+101
| | | | | | Add support for programming smoothieboard current. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* build: Cleanup whitespace errorsKevin O'Connor2018-06-281-4/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* 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>
* gpiocmds: Add update_digital_out commandKevin O'Connor2018-06-271-0/+15
| | | | | | | Add a command that can immediately set the value of a digital output pin created with config_digital_out. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Don't set SS high on spi_init()Kevin O'Connor2018-06-271-1/+3
| | | | | | | | | | The AVR requires that the SS pin be an output pin for correct SPI operation. Some boards use the SS pin to control devices separate from SPI, however. Don't change the output level if the pin is already an output, and prefer setting it low if it is not already an output pin. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Disable ADC reading directly from the PRUKevin O'Connor2018-06-271-1/+1
| | | | | | | | The PRU code size has grown too close to the maximum - remove the ADC code to reduce its overall size. (On the beaglebone, the Linux process can, and typically does, do the ADC reading.) Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* lcd_st7920: Use a longer delay at the start of each command/dataKevin O'Connor2018-06-221-9/+27
| | | | | | | | | | | It appears the st7920 requires a longer delay when switching from command to data mode (and vice-versa). Slower MCUs don't show a problem because the klipper command processing time results in a sufficient delay. However, some of the faster MCUs can process klipper commands fast enough that the next st7920 transfer is sent too fast. Add an additional delay to account for this. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* lpc176x: Build with LCD supportKevin O'Connor2018-06-181-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* basecmd: Rename get_status to get_clockKevin O'Connor2018-05-291-3/+3
| | | | | | | | | | | | Change the get_status command to get_clock. Don't report the shutdown status in the new get_clock command. The primary purpose of this change is to force the host code to report a firmware version mismatch with older firmwares as recent changes (namely the ordering of message block acks) have subtle incompatibilities if different host/mcu code is used. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Do not automatically restart MCU with new config if it is shutdownKevin O'Connor2018-05-291-2/+2
| | | | | | | Normally, the MCU is restarted on a config change. However, that should not be done automatically if the MCU is in a shutdown state. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Limit message transmission to available receive buffer sizeKevin O'Connor2018-05-281-1/+4
| | | | | | | | | If the mcu is using a traditional serial port, then only send a new message block if there is space available in the mcu receive buffer. This should make it significantly less likely that high load on the mcu will result in retransmits. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* command: Wait to send ack until after processing commandsKevin O'Connor2018-05-284-4/+18
| | | | | | | Send the ack after processing commands - this gives the host code more information on serial buffer utilization. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* command: Add command_find_and_dispatch() helperKevin O'Connor2018-05-285-10/+17
| | | | | | | Add a helper function that calls command_find_block() followed by command_dispatch(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* command: Add a command_encode_and_frame() helperKevin O'Connor2018-05-286-9/+17
| | | | | | | Add a helper function that calls command_encodef() followed by command_add_frame(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* command: Prefer uint8_t* for buffers; prefer uint8_fast_t for lengthsKevin O'Connor2018-05-2811-78/+71
| | | | | | | | | Prefer using 'uint8_t' buffers as it is too easy to run into C sign extension problems with 'char' buffers. Prefer using 'uint_fast8_t' for buffer lengths as gcc does a better job compiling them on 32bit mcus. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* lpc176x: Add a dummy "make flash" command to advise users on how to flashKevin O'Connor2018-05-251-0/+8
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* lpc176x: Add build rules for smoothieware bootloader supportKevin O'Connor2018-05-252-1/+10
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* lpc176x: Initial support for serial over usbKevin O'Connor2018-05-258-1/+961
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* lpc176x: Add ADC supportKevin O'Connor2018-05-253-0/+100
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* lpc176x: Enable watchdogKevin O'Connor2018-05-251-0/+23
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* lpc176x: Add support for GPIO pinsKevin O'Connor2018-05-253-1/+115
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* lpc176x: Add initial support for LPC176x processorsKevin O'Connor2018-05-258-0/+283
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* 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>