It appears the PRU timer will not trigger on a match of exactly zero.
If the next timer happened to be set to exactly zero, it could cause
software timers to get stuck and result in "move queue empty" errors.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Make it clear that the name of the constant being defined is a string.
When the value being defined is also a string, use a new
DECL_CONSTANT_STR() macro.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It's rare to use all of a target's prerequisites in a recipe - replace
most cases with $< (the target's first prerequisite).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The PRU code size has grown too close to the maximum - remove the ADC
code to reduce its overall size. (On the beaglebone, the Linux
process can, and typically does, do the ADC reading.)
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Send the ack after processing commands - this gives the host code more
information on serial buffer utilization.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Prefer using 'uint8_t' buffers as it is too easy to run into C sign
extension problems with 'char' buffers. Prefer using 'uint_fast8_t'
for buffer lengths as gcc does a better job compiling them on 32bit
mcus.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>