aboutsummaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* pru: Avoid calling "slp" instruction on pru0Kevin O'Connor2017-09-111-1/+3
| | | | | | | | If pru0 waits in sleep mode then a full beaglebone reboot is needed to reprogram the pru0 firmware. For now, avoid using the "slp" instruction as a workaround. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Batch outgoing writesKevin O'Connor2017-09-081-5/+31
| | | | | | | Allow pru0 to gather multiple outgoing message blocks into a single rpmsg. This can reduce communication overhead. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Fix race condition in clearing of irq flagsKevin O'Connor2017-09-081-2/+4
| | | | | | | | Each irq flag must only be cleared after it has been serviced. This fixes a race condition that could cause incoming commands to be delayed for extended period. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Provide some further help on common MCU shutdown errorsKevin O'Connor2017-09-053-3/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Check that FLASH_DEVICE is set on "make flash" commandKevin O'Connor2017-09-051-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Support config_reset command to manually reset mcuKevin O'Connor2017-09-035-2/+26
| | | | | | | Add support for resetting the MCU via a software only mechanism. This is useful on the PRU. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Only sleep the pru0 if the incoming queue is fully emptyKevin O'Connor2017-09-031-5/+7
| | | | | | | | It's possible for multiple blocks to be pending on the incoming "rpmsg" stream. Don't sleep unless the input is confirmed to be empty. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Compile the irq_poll() function with -O2 optimizationKevin O'Connor2017-08-151-1/+1
| | | | | | | | Compile the PRU binary with -Os optimization, but request that the timer dispatch code be compiled with -O2 optimization. This improves the performance of timers slightly. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Compile with -Os instead of -O2Kevin O'Connor2017-08-141-1/+1
| | | | | | | The gcc -Os option significantly reduces the size of the PRU binary and it has little impact on performance. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* command: Don't pass max_size to command_encodef()Kevin O'Connor2017-08-147-29/+24
| | | | | | | | | The command_encodef() can read the max_size parameter directly from the 'struct command_encoder' passed into it. Also, there is no need to check that a message will fit in a buffer if the buffer is declared to be MESSAGE_MAX in size. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* docs: Update Code_Overview.md with PRU and command_dispatch() changesKevin O'Connor2017-08-111-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Revert f8b0c884Kevin O'Connor2017-08-111-26/+25
| | | | | | | | Go back to scheduling the unstep time instead of busy waiting in the timer dispatch. With the unstep time increased to 2us, it no longer makes sense to spin while waiting for the unstep. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Make sure timer_high and timer_event() stay in syncKevin O'Connor2017-08-111-1/+5
| | | | | | Schedule the next wakeup time of timer_event() using timer_high. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* timer_irq: Rework timer irq handler to check for tasks pendingKevin O'Connor2017-08-091-24/+14
| | | | | | | | Allow timer_dispatch_many() to run for extended periods if there are no tasks pending. This reduces the amount of lost cpu time spent entering and exiting the irq handler. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Reduce the amount of time irqs are disabled in sleep checkKevin O'Connor2017-08-091-16/+19
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Write out a message on startupKevin O'Connor2017-08-081-0/+2
| | | | | | | Send a "startup" message after completing the mcu init functions. This may help detect mcu reboots during debugging. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Rework timer irq handler to check for tasks pendingKevin O'Connor2017-08-081-39/+33
| | | | | | | | Allow the timer dispatch irq handler to run for extended periods if there are no tasks pending. This reduces the amount of lost cpu time spent entering and exiting the irq handler. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Implement generic sleep mechanism based on tasks pendingKevin O'Connor2017-08-089-80/+60
| | | | | | | | | Track when tasks are pending and spin in irq_wait() when no tasks are pending. This improves the mechanism for sleeping the processor - it's simpler for the board specific code and it reduces the possibility of the processor sleeping when tasks are busy. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Introduce sched_wake_tasks() function to wake up tasksKevin O'Connor2017-08-087-4/+25
| | | | | | | | Add function to indicate when tasks need to be run. This will allow the scheduler code to know if there are any tasks that need to be processed. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Tune the low-level timer entry and exit heuristicsKevin O'Connor2017-08-081-2/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Implement internal avr specific timer to handle 16bit overflowsKevin O'Connor2017-08-085-26/+31
| | | | | | | | | | 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-087-44/+61
| | | | | | | | 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>
* sched: Don't count milliseconds in the periodic timerKevin O'Connor2017-08-084-37/+53
| | | | | | | It's not necessary to keep a millisecond counter. Replace the two users of sched_check_periodic() with explicit task wakeup flags. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sam3x8e: Fix watchdog timeout calculationKevin O'Connor2017-08-081-1/+1
| | | | | | | Fix error causing the watchdog to be set to an ~4ms timeout instead of 500ms. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Move prescaler and sleep initialization from timer.c to main.cKevin O'Connor2017-08-072-11/+21
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Enable watchdog code even on simulavrKevin O'Connor2017-08-071-1/+0
| | | | | | | | The simulavr simulator will warn when writing to the watchdog registers, but running code closer to what real hardware runs is worth a few extra warnings. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pwmcmds: Update event prototypes to use uint_fast8_tKevin O'Connor2017-08-061-2/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Improve comments in pru0.cKevin O'Connor2017-08-022-3/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* build: Allow boards to disable digital input/output supportKevin O'Connor2017-07-206-1/+17
| | | | | | | | 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>
* basecmd: Move low-level alloc code into basecmd.cKevin O'Connor2017-07-206-90/+74
| | | | | | | | Implement new dynmem_start() and dynmem_end() functions instead of alloc_chunk() and alloc_chunks() in the board code. This simplifies the board code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* irq: Support sleeping when mcu is idleKevin O'Connor2017-07-1712-8/+97
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Move peripheral init from pru0 to pru1Kevin O'Connor2017-07-173-45/+37
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Move ADC code from gpio.c to new file adc.cKevin O'Connor2017-07-123-66/+78
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Fix readl() typo in serial.cKevin O'Connor2017-07-121-1/+1
| | | | | | The code should have used a readb() call instead of readl(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Add support for "make flash" ruleKevin O'Connor2017-07-051-0/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Pass shutdown reason code via longjmp() parameterKevin O'Connor2017-07-041-5/+5
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Use a pointer when working with send_data array itemsKevin O'Connor2017-06-303-17/+14
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Add hack to shutdown the PRU from a simple command requestKevin O'Connor2017-06-301-0/+6
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Rework command processing so that most of it is done on pru0Kevin O'Connor2017-06-306-93/+214
| | | | | | | | Change the command dispatch and response generation so that most of the work is done on pru0 instead of pru1. This allows more code to fit into the limited space on pru1. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* command: Directly call command_sendf() for ack/nak messagesKevin O'Connor2017-06-291-2/+7
| | | | | | | Don't use the sendf() macro for ack and nak messages - directly call the command_sendf() code instead. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sam3x8e: Integrate serial console functionsKevin O'Connor2017-06-291-48/+30
| | | | | | | | Now that console_get_input(), console_pop_input(), console_get_output() and console_push_output() are local functions, integrate them into their callers. This simplifies the code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Integrate usb serial console functionsKevin O'Connor2017-06-291-32/+16
| | | | | | | | Now that console_get_input(), console_pop_input(), console_get_output() and console_push_output() are local functions, integrate them into their callers. This simplifies the code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Integrate serial console functionsKevin O'Connor2017-06-291-47/+28
| | | | | | | | Now that console_get_input(), console_pop_input(), console_get_output() and console_push_output() are local functions, integrate them into their callers. This simplifies the code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* command: Move low-level sendf transmission into board codeKevin O'Connor2017-06-298-40/+87
| | | | | | | | 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-298-39/+67
| | | | | | | | 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>
* command: Encode MESSAGE_MIN in command_parser->max_sizeKevin O'Connor2017-06-291-1/+1
| | | | | | | Add the message minimum into the stored constant so it does not need to be added at run-time. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* command: Refactor message block generationKevin O'Connor2017-06-291-70/+84
| | | | | | | Separate out the buffer management, message encoding, and message framing code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* command: Refactor the command reading taskKevin O'Connor2017-06-291-34/+38
| | | | | | | Refactor the code so that message block framing, command parsing, and command dispatch are distinct. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sam3x8e: Use readl/writel instead of readb/writeb() in serial.cKevin O'Connor2017-06-221-12/+12
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pru: Remove unnecessary barrier() callsKevin O'Connor2017-06-162-5/+0
| | | | | | The writel() call already implements a barrier() internally. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>