aboutsummaryrefslogtreecommitdiffstats
path: root/src/avr
Commit message (Collapse)AuthorAgeFilesLines
...
* avr: Do not use Idle modeKevin O'Connor2018-04-282-9/+1
| | | | | | | | | | | | The AVR chips (bizarrely) start an ADC conversion when entering Idle mode. This behavior can cause the ADC to be busy when a sample is required. Worse, if a series of events cause the cpu to enter and leave Idle mode with a timing similar to the ADC checking rate then it can cause the ADC to show as busy for extended periods. This could cause high MCU load and possibly lead to a "Rescheduled timer in the past" shutdown. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Explicitly set ADCSRA on each conversion startKevin O'Connor2018-04-251-7/+10
| | | | | | | | Don't logically or the ADSC bit on the start of a conversion - explicitly set the full contents of the register. Also, clear the ADIF flag on each write. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Clean up serial port register aliasesKevin O'Connor2018-04-252-31/+38
| | | | | | | | Define unique register aliases for all of the hardware serial port definitions. This makes it easier to deal with the AVR chips that use different register names. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serial_irq: Add new generic/serial_irq.c codeKevin O'Connor2018-04-202-112/+11
| | | | | | | Extract out common code from avr/serial.c, sam3x8e/serial.c, and stm32f1/serial.c into a new generic/serial_irq.c file. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* lcd_st7920: Add micro-controller code for the ST7920 LCD chipKevin O'Connor2018-03-061-0/+1
| | | | | | | Add support for passing messages to an ST7920 chip via a SPI bit-banging interface. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Add at90usb646 supportDouglas Hammond2018-02-252-5/+9
| | | | Signed-off-by: Douglas Hammond wizhippo@gmail.com
* avr: Round hardware pwm clock ticks to nearest divisorKevin O'Connor2018-01-291-12/+12
| | | | | | | Instead of rounding down to the nearest supported pwm divisor, round to the nearest divisor. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Clear the TCNT1 register on timer startupKevin O'Connor2018-01-071-1/+2
| | | | | | Just to be safe, clear the TCNT1 register during init. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Clear the ADCSRA/ADCSRB registers on ADC initKevin O'Connor2018-01-071-2/+2
| | | | | | | When initializing the ADC, explicitly clear the registers (instead of logically or'ing them with their previous values). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Only use the avrdude "wiring" protocol on atmega2560 devicesKevin O'Connor2018-01-052-1/+7
| | | | | | | | It appears the most common type of avrdude protocol for devices other than the atmega2560 is the "arduino" protocol. Update the build to select a different protocol based on the avr processor type. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* docs: Provide additional information on "make flash" failuresKevin O'Connor2017-12-111-1/+1
| | | | | | Add some additional information on "make flash" problems. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sched: Don't shutdown on a "timer in the past" if already shutdownKevin O'Connor2017-10-121-1/+1
| | | | | | A shutdown will not help if the mcu is already in a shutdown state. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Add support for atmega1284pKevin O'Connor2017-10-052-5/+13
| | | | 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>
* command: Don't pass max_size to command_encodef()Kevin O'Connor2017-08-142-15/+10
| | | | | | | | | 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>
* 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>
* 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-081-22/+1
| | | | | | | | | 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-082-1/+6
| | | | | | | | 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-081-7/+25
| | | | | | | | | | 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-9/+7
| | | | | | | | 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>
* 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>
* build: Allow boards to disable digital input/output supportKevin O'Connor2017-07-201-0/+1
| | | | | | | | 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-201-24/+9
| | | | | | | | 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-172-1/+29
| | | | 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>
* 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-292-5/+34
| | | | | | | | 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-292-4/+32
| | | | | | | | 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>
* avr: Enable CLEAR_PRESCALER by default on at90usb1286Kevin O'Connor2017-06-091-1/+1
| | | | | | | It appears this option is commonly needed on the at90usb1286 avr chip (the printrboard requires it), so default it on. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Support using serial instead of usb on AT90USB1286Kevin O'Connor2017-06-052-16/+28
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Allow atmega328 to select a cpu speed of 20MhzKevin O'Connor2017-05-291-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Add SIMULAVR build option; don't show WATCHDOG or SERIAL_BAUD_U2XKevin O'Connor2017-05-281-3/+17
| | | | | | | | | | | Add a CONFIG_SIMULAVR option to the Kbuild menus and don't directly prompt users for CONFIG_WATCHDOG or CONFIG_SERIAL_BAUD_U2X. The only reason to disable these options would be if one were running on simulavr. This simplifies the user visible menu options. Also, only show CONFIG_CLEAR_PRESCALER for at90usb1286 chips. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Add support for atmega328 chipKevin O'Connor2017-05-282-3/+6
| | | | | | | | The atmega328 is basically the same as the atmega168 - it just adds some additional memory. Allow the chip to be selected during the build. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Reorder Kconfig entries so that atmega2560 at 16mhz is defaultKevin O'Connor2017-05-281-12/+13
| | | | | | | | | | | | | Reorder the MCU list so that newer chips are at the top of the list. This causes the very popular atmega2560 to be the default chip selected. Reorder the frequency list so that higher frequencies are at the top of the list. Restrict the 20Mhz frequency to only chips that support that speed. This causes the popular 16Mhz frequency to be the default speed on AVR. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* build: Use compile_time_request system for init, tasks, and shutdownKevin O'Connor2017-05-265-8/+8
| | | | | | | | 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/+3
| | | | | | | Allow the board specific code to run checks prior to running each task. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* pwmcmds: Export the maximum PWM valueKevin O'Connor2017-05-151-0/+2
| | | | | | | Instead of assuming the maximum PWM value is 255, export a constant from the firmware to the host with the maximum value. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* gpio: Fix off-by-one in declaration of ADC_MAXKevin O'Connor2017-05-151-1/+1
| | | | | | | The maximum value for the ADC is 1023 for 10bit samples and 4095 for 12bit samples. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* build: Rename makefile CFLAGS-y to CFLAGS and LDFLAGS-y to CFLAGS_klipper.elfKevin O'Connor2017-05-151-2/+2
| | | | | | Rename some makefile variables. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Merge misc.c into main.cKevin O'Connor2017-05-113-56/+55
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* basecmd: Avoid calling malloc() from main codeKevin O'Connor2017-05-111-10/+27
| | | | | | | | 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>
* build: Add workaround to suppress broken avr-gcc "misspelled" warningsKevin O'Connor2017-04-241-0/+3
| | | | | | | Detect avr gcc v4.8.1 and then disable warnings during the klipper.o linking to suppress bogus "misspelled signal handler" warnings. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* build: Support makefile rule with default flashing commandsKevin O'Connor2017-04-211-0/+4
| | | | | | | Support a "make flash FLASH_DEVICE=/dev/ttyACM0" rule with the default commands for flashing a device. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Rework adc and pwm pin search to be more clearKevin O'Connor2017-04-111-59/+65
| | | | | | Rework the pin search loop. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Move code around in gpio.cKevin O'Connor2017-04-111-102/+110
| | | | | | | Move the PWM, ADC, and SPI pin tables closer to their corresponding code. This is code movement only - no code changes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* avr: Fix irqstatus_t typo in gpio_pwm_setupKevin O'Connor2017-04-111-1/+1
| | | | | | The flags and cs variables should be uint8_t not irqstatus_t. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>