Commit Graph

143 Commits

Author SHA1 Message Date
Kevin O'Connor 3ac60b31a2 pru: Move peripheral init from pru0 to pru1
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-07-17 11:16:55 -04:00
Kevin O'Connor c105ff1c51 pru: Move ADC code from gpio.c to new file adc.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-07-12 23:03:14 -04:00
Kevin O'Connor ae9bc93ccc avr: Fix readl() typo in serial.c
The code should have used a readb() call instead of readl().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-07-12 23:03:12 -04:00
Kevin O'Connor b32ba3727b pru: Add support for "make flash" rule
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-07-05 12:50:54 -04:00
Kevin O'Connor 09140a51d5 sched: Pass shutdown reason code via longjmp() parameter
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-07-04 12:49:58 -04:00
Kevin O'Connor c8dca0a56c pru: Use a pointer when working with send_data array items
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-06-30 19:54:40 -04:00
Kevin O'Connor da3569c490 pru: Add hack to shutdown the PRU from a simple command request
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-06-30 19:54:33 -04:00
Kevin O'Connor e8356afa26 pru: Rework command processing so that most of it is done on pru0
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>
2017-06-30 19:53:04 -04:00
Kevin O'Connor c1bd628ce5 command: Directly call command_sendf() for ack/nak messages
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>
2017-06-29 13:33:59 -04:00
Kevin O'Connor 849096d5f3 sam3x8e: Integrate serial console functions
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>
2017-06-29 13:33:59 -04:00
Kevin O'Connor e681369a1a avr: Integrate usb serial console functions
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>
2017-06-29 13:33:59 -04:00
Kevin O'Connor faa29c8062 avr: Integrate serial console functions
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>
2017-06-29 13:33:58 -04:00
Kevin O'Connor 44f2a2a952 command: Move low-level sendf transmission into board code
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>
2017-06-29 13:33:58 -04:00
Kevin O'Connor 292453d306 command: Move command_task() to board specific code
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>
2017-06-29 13:33:58 -04:00
Kevin O'Connor 1ae78d08e9 command: Encode MESSAGE_MIN in command_parser->max_size
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>
2017-06-29 13:33:58 -04:00
Kevin O'Connor 1c3cbe9456 command: Refactor message block generation
Separate out the buffer management, message encoding, and message
framing code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-06-29 13:33:58 -04:00
Kevin O'Connor 88f4c38dca command: Refactor the command reading task
Refactor the code so that message block framing, command parsing, and
command dispatch are distinct.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-06-29 13:33:58 -04:00
Kevin O'Connor b310501970 sam3x8e: Use readl/writel instead of readb/writeb() in serial.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-06-22 10:51:49 -04:00
Kevin O'Connor bd48c3a083 pru: Remove unnecessary barrier() calls
The writel() call already implements a barrier() internally.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-06-16 14:26:37 -04:00
Kevin O'Connor c60e4aceed stepper: Increase the step delay time from 1us to 2us
Increase the step delay time so that it works with the common DRV8825
stepper drivers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-06-13 11:53:10 -04:00
Kevin O'Connor 46846d4297 avr: Enable CLEAR_PRESCALER by default on at90usb1286
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>
2017-06-09 18:42:40 -04:00
Kevin O'Connor b8094de129 avr: Support using serial instead of usb on AT90USB1286
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-06-05 12:30:49 -04:00
Kevin O'Connor 73207a12ba avr: Allow atmega328 to select a cpu speed of 20Mhz
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-05-29 14:24:18 -04:00
Kevin O'Connor 3af87e1c42 avr: Add SIMULAVR build option; don't show WATCHDOG or SERIAL_BAUD_U2X
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>
2017-05-28 11:04:59 -04:00
Kevin O'Connor d2547ce6b0 avr: Add support for atmega328 chip
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>
2017-05-28 10:45:32 -04:00
Kevin O'Connor 7e3d7e071f avr: Reorder Kconfig entries so that atmega2560 at 16mhz is default
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>
2017-05-28 09:59:51 -04:00
Kevin O'Connor d4bed025ed command: Store the command parsing information directly in array
Instead of defining an array of pointers, just define the array
directly.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-05-26 13:25:51 -04:00
Kevin O'Connor a82e949c00 build: Use compile_time_request system for init, tasks, and shutdown
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>
2017-05-26 12:39:34 -04:00
Kevin O'Connor ca9756413f sched: Allow shutdown_reason to be uint8
Store the shutdown_reason code in an 8-bit integer - this produces
better code on AVR.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-05-26 12:32:05 -04:00
Kevin O'Connor b9940f0e0d build: Avoid linker magic in compile_time_request.c unique id generation
Avoid generating unique ids via memory locations and linker scripts.
Instead, generate them using code produced by buildcommands.py.
Utilize gcc's ability to perform static string comparisons at compile
time to produce a unique id for each unique string.

This fixes a build failure on ARM introduced in 142b92b8.  It also
reduces the complexity of the build.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-05-26 12:32:02 -04:00
Kevin O'Connor c9b6662138 pru: Add support for ADC input
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-05-17 19:46:12 -04:00
Kevin O'Connor b85755c0ff pru: Move communication code to second PRU
Perform input and output in the second PRU so that more space is
available in the primary PRU.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-05-17 10:46:38 -04:00
Kevin O'Connor 2255176228 pru: Initial support for the Beaglebone PRU
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-05-15 15:15:52 -04:00
Kevin O'Connor 969ee4c8f9 irq: Add an irq_poll() stub for board code
Allow the board specific code to run checks prior to running each
task.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-05-15 15:00:45 -04:00
Kevin O'Connor c35278e217 build: Avoid using noinline in common code
It's not necessary to use noinline for parsef() and stop_steppers().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-05-15 14:02:59 -04:00
Kevin O'Connor 039d3f0523 stepper: It is not necessary to ensure gpio_out_write value is 0 or 1
The gpio_out_write() and gpio_out_setup() calls will check for zero
and non-zero, so it is not necessary to explicitly convert to 0/1 in
the stepper.c code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-05-15 14:02:59 -04:00
Kevin O'Connor d56f8407a5 debugcmds: Move debugging commands from basecmd.c to new file
Move the implementation of debug commands to their own file.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-05-15 14:02:59 -04:00
Kevin O'Connor 142b92b883 command: Use "i" instead of "m" constraint in _DECL_REQUEST_ID
On some architectures, gcc will allocate a register for inline
assembler with an "m" constraint.  Use "i" to avoid that.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-05-15 14:02:59 -04:00
Kevin O'Connor c292006421 gpiocmds: Change MAX_SOFT_PWM from 255 to 256
Change the range of values used for software PWM to avoid doing an
integer division in the main code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-05-15 14:02:59 -04:00
Kevin O'Connor 5c4cc0d646 pwmcmds: Export the maximum PWM value
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>
2017-05-15 14:02:59 -04:00
Kevin O'Connor a361b92184 gpio: Fix off-by-one in declaration of ADC_MAX
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>
2017-05-15 14:02:59 -04:00
Kevin O'Connor 37572bc217 command: Only implement 16bit signed conversion on AVR
On regular 32bit machines there is no need to implement explicit
signed conversion on 16bit integers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-05-15 14:02:04 -04:00
Kevin O'Connor 450c14b286 build: Rename makefile CFLAGS-y to CFLAGS and LDFLAGS-y to CFLAGS_klipper.elf
Rename some makefile variables.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-05-15 14:01:56 -04:00
Kevin O'Connor 33dfc386c9 avr: Merge misc.c into main.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-05-11 13:56:21 -04:00
Kevin O'Connor f331936969 basecmd: Avoid calling malloc() from main code
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>
2017-05-11 13:56:21 -04:00
Kevin O'Connor 1878da228d build: Add workaround to suppress broken avr-gcc "misspelled" warnings
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>
2017-04-24 08:54:10 -04:00
Kevin O'Connor 37865d69a2 basecmd: Add debugging commands for testing communication
Add "debug_ping" and "debug_nop" testing commands.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-23 13:37:49 -04:00
Kevin O'Connor 83eba902a3 build: Support makefile rule with default flashing commands
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>
2017-04-21 11:01:07 -04:00
Kevin O'Connor 7a7b98cc31 sam3x8e: Rework adc pin search to be more clear
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-11 10:01:22 -04:00
Kevin O'Connor 15d5837322 avr: Rework adc and pwm pin search to be more clear
Rework the pin search loop.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-11 10:01:22 -04:00