aboutsummaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* build: Use compile_time_request system for init, tasks, and shutdownKevin O'Connor2017-05-2623-107/+54
| | | | | | | | Avoid using linker magic to define the init, task, and shutdown functions. Instead, use the compile_time_request system. This simplifies the build and produces more efficient code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Allow shutdown_reason to be uint8Kevin O'Connor2017-05-264-16/+17
| | | | | | | Store the shutdown_reason code in an 8-bit integer - this produces better code on AVR. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* build: Avoid linker magic in compile_time_request.c unique id generationKevin O'Connor2017-05-264-45/+43
| | | | | | | | | | | | Avoid generating unique ids via memory locations and linker scripts. Instead, generate them using code produced by buildcommands.py. Utilize gcc's ability to perform static string comparisons at compile time to produce a unique id for each unique string. This fixes a build failure on ARM introduced in 142b92b8. It also reduces the complexity of the build. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Add support for ADC inputKevin O'Connor2017-05-176-4/+156
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Move communication code to second PRUKevin O'Connor2017-05-175-137/+200
| | | | | | | Perform input and output in the second PRU so that more space is available in the primary PRU. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Initial support for the Beaglebone PRUKevin O'Connor2017-05-1510-0/+643
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* irq: Add an irq_poll() stub for board codeKevin O'Connor2017-05-156-0/+17
| | | | | | | Allow the board specific code to run checks prior to running each task. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* build: Avoid using noinline in common codeKevin O'Connor2017-05-152-2/+2
| | | | | | It's not necessary to use noinline for parsef() and stop_steppers(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: It is not necessary to ensure gpio_out_write value is 0 or 1Kevin O'Connor2017-05-151-2/+2
| | | | | | | | The gpio_out_write() and gpio_out_setup() calls will check for zero and non-zero, so it is not necessary to explicitly convert to 0/1 in the stepper.c code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* debugcmds: Move debugging commands from basecmd.c to new fileKevin O'Connor2017-05-153-91/+100
| | | | | | Move the implementation of debug commands to their own file. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* command: Use "i" instead of "m" constraint in _DECL_REQUEST_IDKevin O'Connor2017-05-151-1/+1
| | | | | | | On some architectures, gcc will allocate a register for inline assembler with an "m" constraint. Use "i" to avoid that. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gpiocmds: Change MAX_SOFT_PWM from 255 to 256Kevin O'Connor2017-05-151-6/+5
| | | | | | | Change the range of values used for software PWM to avoid doing an integer division in the main code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pwmcmds: Export the maximum PWM valueKevin O'Connor2017-05-153-6/+11
| | | | | | | Instead of assuming the maximum PWM value is 255, export a constant from the firmware to the host with the maximum value. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gpio: Fix off-by-one in declaration of ADC_MAXKevin O'Connor2017-05-152-2/+2
| | | | | | | The maximum value for the ADC is 1023 for 10bit samples and 4095 for 12bit samples. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* command: Only implement 16bit signed conversion on AVRKevin O'Connor2017-05-151-1/+1
| | | | | | | On regular 32bit machines there is no need to implement explicit signed conversion on 16bit integers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* build: Rename makefile CFLAGS-y to CFLAGS and LDFLAGS-y to CFLAGS_klipper.elfKevin O'Connor2017-05-152-8/+8
| | | | | | Rename some makefile variables. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Merge misc.c into main.cKevin O'Connor2017-05-113-56/+55
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* basecmd: Avoid calling malloc() from main codeKevin O'Connor2017-05-116-45/+66
| | | | | | | | Introduce a new board function alloc_chunk() to allocate dynamic memory. This allows the board code to implement memory allocations without using the standard malloc() interface. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* build: Add workaround to suppress broken avr-gcc "misspelled" warningsKevin O'Connor2017-04-241-0/+3
| | | | | | | Detect avr gcc v4.8.1 and then disable warnings during the klipper.o linking to suppress bogus "misspelled signal handler" warnings. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* basecmd: Add debugging commands for testing communicationKevin O'Connor2017-04-231-0/+15
| | | | | | Add "debug_ping" and "debug_nop" testing commands. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* build: Support makefile rule with default flashing commandsKevin O'Connor2017-04-212-0/+9
| | | | | | | Support a "make flash FLASH_DEVICE=/dev/ttyACM0" rule with the default commands for flashing a device. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sam3x8e: Rework adc pin search to be more clearKevin O'Connor2017-04-111-16/+22
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Rework adc and pwm pin search to be more clearKevin O'Connor2017-04-111-59/+65
| | | | | | Rework the pin search loop. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Move code around in gpio.cKevin O'Connor2017-04-111-102/+110
| | | | | | | Move the PWM, ADC, and SPI pin tables closer to their corresponding code. This is code movement only - no code changes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Fix irqstatus_t typo in gpio_pwm_setupKevin O'Connor2017-04-111-1/+1
| | | | | | The flags and cs variables should be uint8_t not irqstatus_t. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* endstop: Support halting more than one stepper on triggerKevin O'Connor2017-04-031-9/+31
| | | | | | | | Extend the endstop code so that more than one stepper can be halted during endstop homing. Some kinematic setups (eg, corexy) require an endstop to support this. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Invert diff in timer checksKevin O'Connor2017-04-031-8/+6
| | | | | | Minor optimization on avr. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Implement reset commandKevin O'Connor2017-04-021-2/+22
| | | | | | | Support restarting the mcu using the watchdog feature of AVR chips via a new reset command. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sam3x8e: Implement reset commandKevin O'Connor2017-04-021-0/+7
| | | | | | Support restarting the mcu via a new reset command. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Do not use --relax linker optionKevin O'Connor2017-04-021-1/+0
| | | | | | | | | | | The relax option corrupts the compilation on at least some versions of gcc/binutils (eg, on fedora's avr-gcc 6.2.0 / binutils 2.27) due to corruption of switch tables that use jump offsets. This issue is also the root cause that resulted in commit d67f962a. Since the --relax option provides minimal size / performance improvements it can simply be dropped. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* timer: Remove dup timer_shutdown codeKevin O'Connor2017-03-311-10/+0
| | | | | | | Commmit a1c61563 renamed timer_shutdown() to timer_reset() but neglected to delete timer_shutdown(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Fix bug causing timer_read_time() to not be in sync with schedulerKevin O'Connor2017-03-311-10/+19
| | | | | | | | | | | | | | | Commit 16e3dbb1 changed the avr implementation of timer_read_time(). Unfortunately, it raised the possibility for timer_read_time() to be out of sync with the scheduler's understanding of the current time. In particular, it was common for the timer irq to overflow the 16bit hardware counter once at startup, and this would lead to timer_read_time() always returning a time ~4ms ahead of the scheduler on 16Mhz chips. This resulted in "Move queue empty" errors. To resolve this issue, only increment timer_high from timer_periodic() and make sure the timer irqs start immediately after timer_init(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sam3x8e: Align the TC0_Handler timer irq handlerKevin O'Connor2017-03-301-1/+1
| | | | | | | | | | The code alignment of the TC0_Handler function seems to noticeably impact performance benchmarks. Set the function alignment to 16 bytes to improve testing consistency. An alignment of 16 doesn't necessarily improve performance, but it seems to improve testing consistency on code changes unrelated to timer dispatch. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* timer_irq: Integrate timer_try_set_next() into timer_dispatch_many()Kevin O'Connor2017-03-303-57/+40
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* timer_irq: Rename generic/timer.c to generic/timer_irq.cKevin O'Connor2017-03-304-4/+9
| | | | | | | Rename the file to make it clear that the code is helper functions for boards with irq based timers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Integrate timer_try_set_next() into the irq handlerKevin O'Connor2017-03-301-43/+30
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Move timer dispatch loop to board codeKevin O'Connor2017-03-307-46/+59
| | | | | | | | Rename sched_timer_kick() to sched_timer_dispatch() and move its loop into its callers in the board code. This eliminates the need to export timer_try_set_next() from the board code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Rename reschedule_timer() to insert_timer() and use in sched_add_timer()Kevin O'Connor2017-03-301-29/+23
| | | | | | | Use the same code in both rescheduling of a timer and adding a new timer. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* timer: Make sure to reset the timer repeat checks on a shutdownKevin O'Connor2017-03-302-9/+17
| | | | | | | Reset the timer repeat checks on shutdown, otherwise it is possible to get into an infinite shutdown loop. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Improve performance of scheduled unstepsKevin O'Connor2017-03-301-25/+26
| | | | | | | | | On faster MCUs where a delay is needed between step and unstep use a "busy loop" in the scheduler instead of trying to schedule to the unstep time. This reduces the chance of jitter in the scheduler accumulating. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Remove F_CPU compile time definitionKevin O'Connor2017-03-303-5/+7
| | | | | | | | Directly use the Kconfig defined CONFIG_CLOCK_FREQ in the code and avoid defining F_CPU. Also, remove the unnecessary O2 option - that is already the default from the main makefile. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Minor optimization for timer_read_time() / timer_periodic()Kevin O'Connor2017-03-271-2/+2
| | | | | | Tell the compiler that the TOV1 bit is rarely set. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Be explicit with loading of the waketime variableKevin O'Connor2017-03-266-26/+26
| | | | | | | | | Explicilty load the timer waketime variable into local variables in sched_timer_kick(). Change the optimization level from Os to O2. This helps gcc to avoid unnecessary reloads from memory in the common stepper_event() case. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Introduce optimized timer_is_before()Kevin O'Connor2017-03-262-9/+22
| | | | | | | | | Provide hand-coded assembler for timer_is_before() on AVR as that code is used frequently in the time-critical timer dispatch loop and gcc doesn't do a good job at compiling that comparison code. Remove the no longer needed waketime+1 hack from reschedule_timer(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* timer: Allow board code to define its own timer_is_before implementationKevin O'Connor2017-03-269-47/+48
| | | | | | | | | | | | Move sched_is_before() from sched.c to timer_is_before() in the board specific timer code. This allows the board code to provide its own definition. Also, remove the sched_from_us() and sched_read_time() wrapper functions and change the callers to directly invoke timer_from_us() / timer_read_time(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* timer: Organize timer_try_set_next() with priority for repeat timersKevin O'Connor2017-03-261-19/+26
| | | | | | Organize the code flow to optimize for repeat timers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* command: Simplify sendf() switchKevin O'Connor2017-03-261-9/+10
| | | | | | | | Commit f28eb902 reworked the switch to fix int16 encoding. However, at least one version of avr gcc doesn't like that switch layout (it uses a jump table). Reorg the switch to avoid that issue. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* command: Fix encoding of 16bit signed integersKevin O'Connor2017-03-241-7/+9
| | | | | | | The code wasn't properly sign-extending 16bit integers which caused int16_t reports in output() to appear as uint16_t. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Report the time of a shutdownKevin O'Connor2017-03-241-1/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* generic: Move generic parts of sam3x8e timer.c to generic directoryKevin O'Connor2017-03-116-90/+106
| | | | | | | | Most of sam3x8e/timer.c is going to be platform agnostic for any board with standard irq handling. Move the generic code into a new file generic/timer.c. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>