aboutsummaryrefslogtreecommitdiffstats
path: root/src/generic/misc.h
Commit message (Collapse)AuthorAgeFilesLines
* command: Prefer uint8_t* for buffers; prefer uint8_fast_t for lengthsKevin O'Connor2018-05-281-1/+1
| | | | | | | | | 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>
* avr: Implement internal avr specific timer to handle 16bit overflowsKevin O'Connor2017-08-081-1/+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-0/+1
| | | | | | | | 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>
* basecmd: Move low-level alloc code into basecmd.cKevin O'Connor2017-07-201-2/+2
| | | | | | | | 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>
* command: Move low-level sendf transmission into board codeKevin O'Connor2017-06-291-2/+3
| | | | | | | | 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-2/+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>
* basecmd: Avoid calling malloc() from main codeKevin O'Connor2017-05-111-1/+2
| | | | | | | | Introduce a new board function alloc_chunk() to allocate dynamic memory. This allows the board code to implement memory allocations without using the standard malloc() interface. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Move timer dispatch loop to board codeKevin O'Connor2017-03-301-1/+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-1/+2
| | | | | | | | | | | | 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-1/+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>
* generic: Move board timer.h files into generic/misc.hKevin O'Connor2016-06-131-0/+6
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* generic: Create generic board infrastructure and move misc.h to itKevin O'Connor2016-06-131-0/+16
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>