aboutsummaryrefslogtreecommitdiffstats
path: root/src/simulator
Commit message (Collapse)AuthorAgeFilesLines
* command: Fix handling of buffer passing in args[] on 64bit mcuKevin O'Connor2020-10-301-0/+6
| | | | | | | | If the buffer pointer can't fit in a uint32_t then pass a relative buffer offset instead. This fixes buffer handling on 64bit linux mcus. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* simulator: Wrap code to 80 columnsKevin O'Connor2019-02-271-1/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* simulator: Fix simulator buildKevin O'Connor2019-01-251-0/+3
| | | | | | Commit b6ccd268 inadvertently broke the simulator build - fix it. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Kconfig: Move SERIAL_BAUD to src/Kconfig and show with LOW_LEVEL_OPTIONSKevin O'Connor2019-01-251-4/+0
| | | | | | | | Move the definition of SERIAL_BAUD to the main src/Kconfig file. Only show this as an option if the user selects the ability to configure low-level options. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* simulator: Add support for gpio_x_reset()Kevin O'Connor2018-08-271-0/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* simulator: Rework dummy simulator code to user timer_irq / serial_irqKevin O'Connor2018-07-115-109/+163
| | | | | | | | | 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>
* SPI: introduce spi_prepare functionGrigori Goronzy2018-07-081-0/+4
| | | | | | | | | | | | | | | | 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>
* stepper: Introduce and use gpio_out_toggle_noirq()Kevin O'Connor2018-05-151-0/+2
| | | | | | | | | | | | | | | 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>
* spicmds: Rework SPI message transmissionKevin O'Connor2018-05-071-2/+8
| | | | | | | | | 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>
* avr: Implement internal avr specific timer to handle 16bit overflowsKevin O'Connor2017-08-081-5/+0
| | | | | | | | | | Don't rely on the generic scheduler code to always have a timer no more than 1ms in the future. Instead, create an avr specific timer that will be called every 0x8000 ticks. This simplifies the generic code and it reduces the amount of code that needs to be run every millisecond. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Support adding timers to the start of timer_listKevin O'Connor2017-08-081-4/+9
| | | | | | | | If sched_add_timer() is called on a timer that would make it the new head of the list, then add it and signal the board code that the timer should be rescheduled. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* build: Allow boards to disable digital input/output supportKevin O'Connor2017-07-201-0/+8
| | | | | | | | Allow the micro-controller code to be built without support for regular gpio pins. In this case, the code for endstops, steppers, and gpiocmds will be disabled. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* irq: Support sleeping when mcu is idleKevin O'Connor2017-07-171-0/+5
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* command: Move low-level sendf transmission into board codeKevin O'Connor2017-06-291-9/+2
| | | | | | | | Export a new console_sendf() function from the board code instead of console_get_output() and console_push_output(). This enables more flexibility in how the board specific code produces output. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* command: Move command_task() to board specific codeKevin O'Connor2017-06-291-13/+0
| | | | | | | | Move the command_task() code from the generic code to the board specific code. This enables more flexibility in how the board specific code processes input. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* build: Use compile_time_request system for init, tasks, and shutdownKevin O'Connor2017-05-261-1/+1
| | | | | | | | 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>
* irq: Add an irq_poll() stub for board codeKevin O'Connor2017-05-151-0/+5
| | | | | | | Allow the board specific code to run checks prior to running each task. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Move timer dispatch loop to board codeKevin O'Connor2017-03-301-6/+0
| | | | | | | | 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: Be explicit with loading of the waketime variableKevin O'Connor2017-03-261-1/+1
| | | | | | | | | 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>
* timer: Allow board code to define its own timer_is_before implementationKevin O'Connor2017-03-261-0/+6
| | | | | | | | | | | | 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>
* sched: Avoid rescheduling the currently active timerKevin O'Connor2017-03-101-6/+0
| | | | | | | | | 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>
* gpio: Merge gpio_adc_sample_time() into gpio_adc_sample()Kevin O'Connor2016-11-021-6/+3
| | | | | | | 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>
* irq: Allow boards to define the return type of irq_save()Kevin O'Connor2016-06-131-6/+10
| | | | | | | | 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>
* Makefile: Move listing of directories to create to board makefilesKevin O'Connor2016-06-131-0/+2
| | | | | | Rename DIRS to dirs-y and populate it in the per-board Makefile rules. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* generic: Move simulator/gpio.h to generic/gpio.hKevin O'Connor2016-06-132-38/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* generic: Move simulator/irq.h to new file generic/irq.hKevin O'Connor2016-06-133-44/+32
| | | | | | | 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-131-12/+0
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* generic: Create generic board infrastructure and move misc.h to itKevin O'Connor2016-06-132-21/+1
| | | | | | | 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: Change sched_from_ms() to sched_from_us()Kevin O'Connor2016-06-022-2/+2
| | | | | | | Some code may require micro-second precision so update sched_from_ms() to use micro-seconds. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Initial commit of source code.Kevin O'Connor2016-05-259-0/+274
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>