aboutsummaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* command: Check for reentrant calls to sendf()Kevin O'Connor2017-01-131-1/+14
| | | | | | | | | Allow sendf() to be called from irq and timer context - check for the case where sendf() is called while already in sendf() and simply discard those messages. This makes it safe to use output() debugging calls even in irq and timer context. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* basecmd: Improve accuracy of stats "sumsq" variableKevin O'Connor2017-01-091-2/+13
| | | | | | | | | | | | Use a base of 256 instead of 65536 when calculating the sum of the square of the clock differences in the stats. This makes the calculation more accurate. Export the new base via DECL_CONSTANT for the host to access. Use DIV_ROUND_UP() when adjusting for the base to ensure no lost ticks. Do the division after multiplication in the common case where the time between stats_task() invocations is less than 64K ticks. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gpio: Fix sam38xe ADC startup checkKevin O'Connor2017-01-011-1/+1
| | | | | | The status register needs to be inspected, not the enable register. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sam3x8e: Add support for ADC pinsKevin O'Connor2016-12-234-1/+90
| | | | | | Support analog-to-digital inputs. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Obtain the maximum adc value from the firmwareKevin O'Connor2016-12-231-0/+2
| | | | | | | Don't assume the hardware ADC has 10bit resultion - instead have the firmware define a constant and read that constant in the host. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* build: Define DECL_CONSTANT mechanism for defining exported constantsKevin O'Connor2016-12-236-4/+21
| | | | | | | | | Add a DECL_CONSTANT macro to allow the firmware to define constants that are to be exported to the host during the "identify" phase. This replaces the existing hardcoded mechanism of scanning the Kconfig header file for certain constants. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Reset the next step time on a stepper stopKevin O'Connor2016-11-141-0/+1
| | | | | | | | | Automatically reset the next step time to zero on a stepper_stop() call. This makes the host code simpler as it no longer needs to schedule an explicit reset_step_clock command on the step after a homing operation. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Default to a high direction pin meaning positive directionKevin O'Connor2016-11-081-2/+2
| | | | | | | | | Invert the default meaning of the stepper direction pin. Instead of treating a low value as position motion, treat a high value as positive motion. This matches what other firmwares do, and it matches what common stepper motor drivers document. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gpio: Merge gpio_adc_sample_time() into gpio_adc_sample()Kevin O'Connor2016-11-025-34/+29
| | | | | | | Return the number of clock ticks to wait directly from gpio_adc_sample(). This simplifies the ADC interface. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sam3x8e: Rework timer priority code to use time instead of event countKevin O'Connor2016-10-311-11/+14
| | | | | | | | | Rework the timer prioritization code so that is compares against the current time instead of the number of repeat timers in a given interrupt. This makes the code slightly faster and it should provide better protection against task starvation. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sam3x8e: Clear all bits of PSR register when clearing IRQ statusKevin O'Connor2016-10-311-3/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Improve AVR optimization of reschedule_timer()Kevin O'Connor2016-10-191-7/+11
| | | | | | | | Tweak the AVR register pressure optimization in reschedule_timer() to optimize it further. This improves the performance of AVR timers when there are several pending timers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* timer: Rework AVR timer priority code to use time instead of event countKevin O'Connor2016-10-191-11/+23
| | | | | | | | | Rework the timer prioritization code so that is compares against the current time instead of the number of repeat timers in a given interrupt. This makes the code slightly faster and it should provide better protection against task starvation. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serial: Increase AVR serial receive bufferKevin O'Connor2016-10-181-3/+2
| | | | | | | | Increase the size of the serial receive buffer. With transmit rates of 250000 baud, it only takes a little over a millisecond to overflow the existing buffer. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Disable "no next step" check for some count=1 queue_step commandsKevin O'Connor2016-09-221-5/+16
| | | | | | | | | It's possible for a "count=1" stepper move immediately after a set_next_step_dir or reset_step_clock command to be valid and have an interval less than min_stop_interval. Make sure this case does not result in a shutdown. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* build: Avoid objcopy --dump-section flagKevin O'Connor2016-07-101-3/+0
| | | | | | | | | Commit da305e6b changed the objcopy command to use the --dump-section flag. However, the 2.24 version of avr-objcopy (which is common on raspbian installs) does not support this flag. Avoid using --dump-section and continue to use the -j option instead. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sam3x8e: Add initial support for Arduino Due boardsKevin O'Connor2016-06-149-2/+599
| | | | | | | This adds basic support for running on the Atmel SAM3x8e micro-controllers that are found in the Arudino Due boards. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Support rescheduling of step events on faster MCUsKevin O'Connor2016-06-143-19/+80
| | | | | | | | | | On faster MCUs the step and unstep events may be too close for the stepper motor driver. Add a CONFIG_NO_UNSTEP_DELAY build option and support the case where it is not set. This allows faster MCUs to schedule two events for each step (one for the step and one for the unstep). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* build: Update declfuncs.lds.S to only use progmem sections on AVRKevin O'Connor2016-06-142-5/+16
| | | | | | | On non-avr platforms the declfunc stuff still needs to be in the binary in a rodata section. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr/serial: Separate out low-level hardware manipulation to its own functionKevin O'Connor2016-06-141-3/+9
| | | | | | | Introduce enable_tx_irq() for manipulating the AVR hardware. This keeps the low-level hardware code together. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* build: Default to O2 optimizationKevin O'Connor2016-06-141-1/+1
| | | | | | | Default to O2 and set Os in the AVR makefile. Platforms besides AVR are likely to produce better code with O2 so make that the default. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Use 'unsigned int' instead of 'uint16_t' for shutdown reasonKevin O'Connor2016-06-142-4/+4
| | | | | | | Use 'unsigned int' instead of 'uint16_t' as is faster on some platforms. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Use uint_fast8_t for return type of timersKevin O'Connor2016-06-147-14/+14
| | | | | | | | Some architectures are faster passing regular integers than 8bit integers. Use uint_fast8_t so that the architecture chooses the appropriate type. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* irq: Allow boards to define the return type of irq_save()Kevin O'Connor2016-06-138-25/+33
| | | | | | | | The AVR wants a uint8_t return type for irq_save(), but other architectures will generally prefer int. Allow the board to configure the size of the flag by introducing an irqstatus_t typedef. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* irq: Prefer irq_disable/enable instead of irq_save/restore in cmds/tasksKevin O'Connor2016-06-134-13/+13
| | | | | | | | Task and command handlers always run with irqs enabled, so it is not necessary to save/restore the irq state when disabling irqs in these handlers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pwmcmds: Add Kconfig option to allow boards to disable hardware PWM commandsKevin O'Connor2016-06-135-70/+85
| | | | | | | | Some boards may not support hardware based PWM. Update the build so that those commands do not need to be compiled if they are not available. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* spicmds: Add Kconfig option to allow boards to disable SPI commandsKevin O'Connor2016-06-133-1/+6
| | | | | | | Some boards may not support SPI transfers. Update the build so that those commands do not need to be compiled if they are not available. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gpiocmds: Add Kconfig option to allow boards to disable ADC commandsKevin O'Connor2016-06-135-111/+132
| | | | | | | | Some boards may not support the ADC hardware. Update the build so that those commands do not need to be compiled if they are not available. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* compiler.h: Check if __aligned and __section macros are already definedKevin O'Connor2016-06-131-0/+4
| | | | | | | Don't define these macros if they are already - doing so causes compiler warnings. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Makefile: Move listing of directories to create to board makefilesKevin O'Connor2016-06-132-0/+4
| | | | | | Rename DIRS to dirs-y and populate it in the per-board Makefile rules. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* generic: Add new file generic/io.h and move read/writeb() to itKevin O'Connor2016-06-133-19/+26
| | | | | | | | Move the definitions of the readb() style functions to a new header generic/io.h. This eliminates the dependency of stdint.h on compiler.h. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* generic: Move simulator/gpio.h to generic/gpio.hKevin O'Connor2016-06-132-3/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* generic: Move simulator/irq.h to new file generic/irq.hKevin O'Connor2016-06-134-34/+46
| | | | | | | Move the generic irq definitions into generic/irq.h and move the simulator irq code into main.c. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* generic: Move board timer.h files into generic/misc.hKevin O'Connor2016-06-135-26/+8
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* generic: Create generic board infrastructure and move misc.h to itKevin O'Connor2016-06-1310-68/+69
| | | | | | | Instead of creating a misc.h file in each board directory, create a generic board directory and declare misc.h there. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Optimize timer list handlingKevin O'Connor2016-06-131-39/+50
| | | | | | Rework the timer list rescheduling to be more optimized. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Optimize for case where add is zeroKevin O'Connor2016-06-131-11/+15
| | | | | | | At high rates, the "add" field is frequently zero. It's possible to optimize for that case. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gpio: Fix off-by-one bug in check for the maximum gpio portKevin O'Connor2016-06-131-2/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Add config option to clear the CPU prescalerKevin O'Connor2016-06-052-0/+23
| | | | | | | Some AVR chips ship with a 1/8th clock divisor set. Add a compile time option to manually clear this field at startup. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>