aboutsummaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* sched: Move functions within sched.cKevin O'Connor2017-03-111-40/+38
| | | | | | Just code movement - no code changes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Rename sched_timer() to sched_add_timer()Kevin O'Connor2017-03-118-12/+12
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Don't overwrite shutdown reason if shutdown called while shutdownKevin O'Connor2017-03-101-1/+2
| | | | | | | If a shutdown occurs while the machine is already shutdown, then keep the original shutdown reason code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Avoid rescheduling the currently active timerKevin O'Connor2017-03-105-90/+53
| | | | | | | | | It's tricky to reschedule the timer irq correctly (due to race conditions with the irq) and in practice it's very rarely needed. Handle the special cases in the generic sched.c code so that the board code doesn't have to handle it. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Use a sentinel timer at the end of the timer_listKevin O'Connor2017-03-101-9/+29
| | | | | | | | Introduce a dummy sentinel timer object that is always the last item on timer_list. This optimizes the timer_list walking code as it no longer needs to check for NULL when traversing the list. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Optimize 16bit timer upscalingKevin O'Connor2017-03-101-22/+24
| | | | | | | The hardware timer overflow bit can be used to optimize the conversion from 16bit timers to 32bit timers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Introduce stepper_get_position command and remove from endstop.cKevin O'Connor2017-03-093-15/+31
| | | | | | | | Move the logic to calculate and report the stepper's current position from endstop.c to stepper.c. This localizes the stepper code into stepper.c. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* endstop: No need to store pin_valueKevin O'Connor2017-03-091-5/+5
| | | | | | The pin_value can be stored in the existing flags variable. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* basecmd: Remove unimplemented command_reset()Kevin O'Connor2017-03-091-7/+0
| | | | | | | It's better to not have the unimplemented command defined so that the host can detect when it is actually implemented. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* basecmd: Use oid_ prefix for the oid manipulation functionsKevin O'Connor2017-03-097-36/+36
| | | | | | | Consistently use an "oid_" prefix on the oid functions - this makes them similar to other functions with a common prefix. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* basecmd: Generalize the "move queue" runtime storageKevin O'Connor2017-03-083-40/+84
| | | | | | | | | Detect the maximum size of each "move queue" item during the configuration phase instead of using the stepper move struct. This allows the stepper code to be contained entirely in stepper.c and it allows for future run time allocations from other types of objects. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sam3x8e: Fix typo in gpio_in_setup() shutdown messageKevin O'Connor2017-03-081-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialhdl: Load the mcu's 64bit clock at start of connectionKevin O'Connor2017-03-031-4/+16
| | | | | | | | Store a full 64bit uptime in the mcu and query it at the start of each connection. This ensures the host's 64bit clock is always in synch with the mcu's clock. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* armcm_irq: Move ARM Cortex-M irq handling to new fileKevin O'Connor2017-02-197-59/+64
| | | | | | | | The irq handling in sam3x8e isn't specific to the sam3x8e proccessor - it's generic for all armcm type machines. So, move the definitions into a new file generic/armcm-irq.c Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sam3x8e/timer: Be careful of races in timer_set_next()Kevin O'Connor2017-02-141-4/+16
| | | | | | | | | | | | | | It's possible for sched_del_timer() to be called on a timer that fires just after sched_del_timer disables irqs but before the next timer is scheduled. In this case be sure to clear the irq pending status flag after scheduling the next timer so that a delayed irq doesn't cause the wrong timer to be run. For the same reason, make sure to check the irq pending status flag at the start of the timer irq. Also, as a safety check, make sure timer_set_next() isn't called from within the timer irq dispatch loop. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* io.h: read/write[bwl] should use barrierKevin O'Connor2017-02-023-9/+13
| | | | | | | Add barrier() calls to low-level read/write io calls so that their callers don't need to. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serial: Be careful with comparison of transmit_max to transmit_posKevin O'Connor2017-01-142-2/+2
| | | | | | | | There is a small possibility that a shutdown could occur between clearing transmit_max and clearing transmit_pos - so make sure to handle the case where transmit_pos > transmit_max. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Minor change - remove unneeded header filesKevin O'Connor2017-01-144-5/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* command: No need to disable irqs in sendf reentrant checkKevin O'Connor2017-01-143-14/+16
| | | | | | | | | As long as the code is careful when writing the in_sendf variable it should be safe to update it without having to disable irqs. Also, make sure in_sendf is cleared on shutdown. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>