diff --git a/Motate b/Motate
index 41e5b92a9..ee04b276a 160000
--- a/Motate
+++ b/Motate
@@ -1 +1 @@
-Subproject commit 41e5b92a98de4b268d1804bf6eadf3333298fc75
+Subproject commit ee04b276a9301e4e4542471b2c461dc2532e0543
diff --git a/README.md b/README.md
index 85e41dd7e..bb96f933a 100644
--- a/README.md
+++ b/README.md
@@ -9,203 +9,139 @@ G2 [Edge](https://github.com/synthetos/g2/tree/edge) is the branch for beta test
That said, Edge is for the adventurous. It is not guaranteed to be stable, but we do our best to achieve this. For production uses we recommend using the [Master branch](https://github.com/synthetos/g2/tree/master).
-## Firmware Build 100 `{fb:100.xx}`
+## Firmware Build 101 `{fb:101.xx}`
### Feature Enhancements
-The fb:100 release is a major change from the fb:089 and earlier branches. It represents about a year of development and has many major feature enhancements summarized below. These are described in more detail in the rest of this readme and the linked wiki pages.
-- New Gcode and CNC features
-- 3d printing support, including [Marlin Compatibility](https://github.com/synthetos/g2/wiki/Marlin-Compatibility)
-- GPIO system enhancements
-- Planner enhancements and other operating improvements for high-speed operation
-- Intital support for new processors, including the ARM M7
+
+The fb:101 release is a mostly internal change from the fb:100 branches. Here are the highlights, more detailed on each item are further below:
+- Updated motion execution at the segment (smallest) level to be linear velocity instead of constant velocity, resulting in notably smoother motion and more faithful execution of the jerk limitations. (Incidentally, the sound of the motors is also slightly quieter and more "natural.")
+- Updated JT (Junction integration Time, a.k.a. "cornering") handling to be more optimized, and to treat the last move as a corner to a move with no active axes. This allows a non-zero stopping velocity based on the allowed jerk and active JT value.
+- Probing enhancements.
+- Added support for gQuintic (rev B) and fixed issues with gQuadratic board support. (This mostly happened in Motate.)
+- Temperature control enhancements
+ - Temperature inputs are configured differently at compile time. (Ongoing.)
+ - PID control has been adjusted to PID+FF (Proportional, Integral, and Derivative, with Feed Forward). In this case, the feed forward is a multiplier of the difference between the current temperature and the ambient temperature. Since there is no temperature sensor for ambient temperature at the moment, it uses an idealized room temperature of 21ºC.
+- More complete support for TMC2130 by adding more JSON controls for live feedback and configuration.
+- Initial support for Core XY kinematics.
+- Boards are in more control of the planner settings.
+- Experimental setting to have traverse (G0) use the 'high jerk' axis settings.
+- Outputs are now configured at board initialization (and later) to honor the settings more faithfully. This includes setting the pin high or low as soon as possible.
### Project Changes
-The project is now called g2core (even if the repo remains g2). As of this release the g2core code base is split from the TinyG code base. TinyG will continue to be supported for the Xmega 8-bit platform, and new features will be added, specifically as related to continued support for CNC milling applications. The g2core project will focus on various ARM platforms, as it currently does, and add functions that are not possible in the 8-bit platform.
-
-In this release the Motate hardware abstraction layer has been split into a separate project and is included in g2core as a git submodule. This release also provides better support for cross platform / cross target compilation. A summary of project changes is provided below, with details in this readme and linked wiki pages.
-- Motate submodule
-- Cross platform / cross target support
-- Multiple processor support - ARM M3, M4, M7 cores
-- Device tree / multiple motor types
-- Simplified host-to-board communication protocol (line mode)
-- NodeJS host module for host-to-board communications
-
-### More To Come
-The fb:100 release is the base for number of other enhancements in the works and planned, including:
-- Further enhancements to GPIO system
-- Additional JSON processing and UI support
-- Enhancements to 3d printer support, including a simplified g2 printer dialect
## Changelog for Edge Branch
-### Edge branch, Build 100.xx
-
-Build 100.xx has a number of changes, mostly related to extending Gcode support and supporting 3D printing using g2core. These include temperature controls, auto-bed leveling, planner performance improvements and active JSON comments in Gcode.
+### Edge branch, Build 101.xx
-Communications has advanced to support a linemode protocol to greatly simplify host communications and flow control for very rapid Gcode streams. Please read the Communications pages for details. Also see the NodeJS communications module docs if you are building a UI or host controller.
-
-Build 100.xx also significantly advances the project structure to support multiple processor architectures, hardware configurations and machine configurations in the same code base. Motate has been cleaved off into its own subproject. We recommend carefully reading the Dev pages if you are coding or compiling.
+This build is primarily focused on support for the new boards based on the Atmel SamS70 family, as well as refining the motion control and long awaited feature enhancements. This list will be added to as development proceed.s
#### Functional Changes:
-- **Gcode and CNC Changes**
- - Included `G10 L1`, `G10 L10`, `G43`, `G49` tool length offset and added 16 slot tool table (deferred until build 100.12)
- - Included `G10 L20` offset mode
- - Extended `G38.2` probing to also include `G38.3`, `G38.4`, `G38.5`
- - Homing can now be set to a non-zero switch. Homing will set to the travel value of the positive or negative switch, as determined by the search direction. This allows homing to home to a maximum - for example - and set the homed location to the non-zero switch.
- - [100.13] Fixes for dwells mixed with gcode moves.
- - [100.13] Minor planner refactoring to better handle commands and gcode mixed. (Forward-planning now looks past commands.)
- - [100.13] *Experimental!* Optioan `TRAVERSE_AT_HIGH_JERK` (defaults to off, set to 1 in a settings file to enable) will make traverse moves (`G0`) use the high-jerk settings instead of the normal jerk settings. This applies to all axes universally.
-
-- **Planner and Motion Changes**
- - Junction Integration Time - the [`{jt:...}`](https://github.com/synthetos/g2/wiki/Configuring-0.99-System-Groups#jt-junction-integration-time) parameter is now the way to set cornering velocity limits. Cornering now obeys full jerk limitation instead of the centripetal acceleration heuristic, making it much more accurate and more true to the jerk limits set for the machine. JT is a normalized scaled factor that is nominally set to 1.000. Set to less than 1 for slower cornering (less aggressive), greater than 1 (but probably less than 2) for more aggressive cornering. This parameter replaces Junction Acceleration `{ja:...}` and the axis Junction Deviation commands - e.g. `{xjd:0.01}`.
- - Deprecated `{ja:...}` global parameter. Will return error.
- - Deprecated `{_jd:...}` per-axis parameter. Will return error.
-
-
-- **3D Printing Support**
- - Planner improvements to handle extreme cases found in some 3DP slicer outputs
- - Added automatic bed leveling [{tram:t}](https://github.com/synthetos/g2/wiki/Configuring-0.99-3D-Printing-Extensions#tramt-tram-command) using 3 point probe and coordinate rotation
- - Added [`{he1:n}`, `{he2:n}`, `{he3:n}`](https://github.com/synthetos/g2/wiki/Configuring-0.99-3D-Printing-Extensions#heater-groups) heater control groups
- - Added `{pid1:n}`, `{pid2:n}`, `{pid3:n}` ADC PID groups
- - Note: The semantics of `{he:...}` and `{pid:...}` are still in development and may change.
-
-
-- **[GPIO Changes](https://github.com/synthetos/g2/wiki/Digital-IO)**
- - Changed configuration for [`{di1:n}` ... `{di12:n}`](https://github.com/synthetos/g2/wiki/Digital-IO#digital-inputs) somewhat
- - Added [`{do1:n}` ... `{do12:n}`](https://github.com/synthetos/g2/wiki/Digital-IO#digital-outputs) digital output controls for controlling general outputs such as fans
- - Added [`{out1:n}` ... `{out12:n}`](https://github.com/synthetos/g2/wiki/Digital-IO#digital-outputs) digital output state readers for reading the condition of do's
-
-
-- **Active JSON comments** - i.e. JSON called from Gcode
- - Added `M100 ({...})` active comment. Currently only supports temperature setting command.
- - Added `M101 ({...})` "wait-on-event" active comment. Currently only supports temperature wait command.
- - Additional note: `M101` will only wait on values that return `true` or `false`, and will only work if given `true` or `false`.
- - Valid example:
- ```
- M101 ({in1: true})
- ```
- - Using `0` or `1`, or anything except `true` or `false` will *not* work.
-
-- **System and Communications**
- - [100.13] **Important:** USB will only expose one virtal serial port by default.
- - This can be overridden in the settings file with:
+*Note: Click the header next to the arrow to expand and display the details.*
+
+Linear-Velocity Segment Execution
+
+ - The overall motion is still jerk-controlled and the computation of motion remains largely the same (although slightly simplified). At the smallest level above raw steps (what we call "segments," which are nominally 0.25ms to 1ms in duration) we previously executed the steps at a constant velocity. We now execute them with a linear change from a start velocity to an end velocity. This results in smoother motion that is more faithful to the planned jerk constraints.
+ - This changed the way the forward differences are used to compute the segment speeds as well. Previously, we were computing the curve at the midpoint (time-wise) of each segment in order to get the median velocity. Now that we want the start and end velocity of each segment we only compute the end (time-wise) of each segment, and use that again later as the start-point of the next segment.
+
+
+Probing enhancements
+
+ - Added `{"prbs":true}` to store the current position as if it were to position of a succesful probe.
+ - Added `{"prbr":true}` to enable and `{"prbr":false}` to enable and disable (respectively) the JSON `{prb:{...}}` report after a probe.
+
+
+gQuintic support
+
+ - Support for the gQuintic rev B was added. Support for rev D will come shortly.
+
+
+Temperature control enhancements
+
+ - Added the following settings defines:
+ - `HAS_TEMPERATURE_SENSOR_1`, `HAS_TEMPERATURE_SENSOR_2`, and `HAS_TEMPERATURE_SENSOR_3`
+ - `EXTRUDER_1_OUTPUT_PIN`, `EXTRUDER_2_OUTPUT_PIN`, and `BED_OUTPUT_PIN`
+ - Added `BED_OUTPUT_INIT` in order to control configuration of the Bed output pin settings.
+ - Defaults to `{kNormal, fet_pin3_freq}`.
+ - `EXTRUDER_1_FAN_PIN` for control of the temperature-enabled fan on extruder 1. (Only available on extruder 1 at the moment.)
+ - (*Experimental*) Analog input is now interpreted through one of various `ADCCircuit` objects.
+ - Three are provided currently: `ADCCircuitSimplePullup`, `ADCCircuitDifferentialPullup`, `ADCCircuitRawResistance`
+ - `Thermistor` and `PT100` objects no longer take the pullup value in their constructor, but instead take a pointer to an `ADCCircuit` object.
+ - `Thermistor` and `PT100` objects no longer assume an `ADCPin` is used, but now take the type that conforms to the `ADCPin` interface as a template argument.
+ - **TODO:** Make more of these configurable at runtime. Separate the ADC input from the consumer, and allow other things than temperature to read it.
+ - PID+FF control adds feed-forward (FF) to adjust the output to a reasonable minimum based on heat loss dues to room temperature.
+ - This can be effectively disabled, making the controller a PID controller, by setting the F value to `0.0`.
+ - **Warning** setting this value too high can cause thermal runaway. Set this value conservatively (low), since there's currently no ambient temperature, and the actual heat loss may be less than computed. This will be magnified by another heater (such as that on a heat bed of a 3D printer) in close proximity.
+
+
+
+TMC2130 JSON controls
+
+ - Added the following setting keys to the motors (`1` - `6`):
+ - `ts` - *(R)* get the value of the `TSTEP` register
+ - `pth` - *(R/W)* get/set the value of the `TPWMTHRS` register
+ - `cth` - *(R/W)* get/set the value of the `TCOOLTHRS` register
+ - `hth` - *(R/W)* get/set the value of the `THIGH` register
+ - `sgt` - *(R/W)* get/set the value of the `sgt` value of the `COOLCONF` register
+ - `sgr` - *(R)* get the `SG_RESULT` value of the `DRV_STATUS` register
+ - `csa` - *(R)* get the `CS_ACTUAL` value of the `DRV_STATUS` register
+ - `sgs` - *(R)* get the `stallGuard` value of the `DRV_STATUS` register
+ - `tbl` - *(R/W)* get/set the `TBL` value of the `CHOPCONF` register
+ - `pgrd` - *(R/W)* get/set the `PWM_GRAD` value of the `PWMCONF` register
+ - `pamp` - *(R/W)* get/set the `PWM_AMPL` value of the `PWMCONF` register
+ - `hend` - *(R/W)* get/set the `HEND_OFFSET` value of the `CHOPCONF` register
+ - `hsrt` - *(R/W)* get/set the `HSTRT/TFD012` value of the `CHOPCONF` register
+ - `smin` - *(R/W)* get/set the `semin` value of the `COOLCONF` register
+ - `smax` - *(R/W)* get/set the `semax` value of the `COOLCONF` register
+ - `sup` - *(R/W)* get/set the `seup` value of the `COOLCONF` register
+ - `sdn` - *(R/W)* get/set the `sedn` value of the `COOLCONF` register
+ - Note that all gets retrieve the last cached value.
+
+
+Core XY Kinematics Support
+
+ - Enabled at compile-time by setting the `KINEMATICS` define to `KINE_CORE_XY`
+ - The default (and only other valid value) for `KINEMATICS` is `KINE_CARTESIAN`
+ - Note that the X and Y axes must have the same settings, or the behavior is undefined.
+ - For the sake of motor mapping, the values `AXIS_COREXY_A` and `AXIS_COREXY_B` have been created.
+ - Example usage:
+ ```c++
+ #define M1_MOTOR_MAP AXIS_COREXY_A // 1ma
+ #define M2_MOTOR_MAP AXIS_COREXY_B // 2ma
+ ```
+
+
+Planner settings control from board files
+
+ - The defines `PLANNER_BUFFER_POOL_SIZE` and `MIN_SEGMENT_MS` are now set in the `board/*/hardware.h` files.
+ - `PLANNER_BUFFER_POOL_SIZE` sets the size of the planner buffer array.
+ - Default value if not defined: `48`
+ - `MIN_SEGMENT_MS` sets the minimum segment time (in milliseconds) and several other settings that are comuted based on it.
+ - Default values if not defined: `0.75`
+ - A few of the computed values are shown:
```c++
- // Valid options are 1 or 2 only!
- #define USB_SERIAL_PORTS_EXPOSED 1
+ #define NOM_SEGMENT_MS ((float)MIN_SEGMENT_MS*2.0) // nominal segment ms (at LEAST MIN_SEGMENT_MS * 2)
+ #define MIN_BLOCK_MS ((float)MIN_SEGMENT_MS*2.0) // minimum block (whole move) milliseconds
```
- - [100.13] Refactored XIO to handle `!`, `%`, `~`, and JSON commends intermixed with gcode better.
- - [100.13] Fixes to USB connection, initialization, and DMA operation for Sam3X-base machines.
- - Added `Linemode` communication protocol, and provide guidance to use linemode for much simpler and more reliable application-level flow control
- - Footer format has changed. Checksum is no longer supported and has been removed
- - Added `ENQ/ACK handshake`. If the host sends an ASCII `ENQ (0x05)` the board should respond with an `ACK (0x06)`. This is provided to facilitate low-level communications startup and automated testing
- - Added [`{fbs:n}`](https://github.com/synthetos/g2/wiki/Configuring-0.99-System-Groups#fbsn-firmware-build-string) as a read-only parameter to report the git commit used during compilation
- - Added [`{fbc:n}`](https://github.com/synthetos/g2/wiki/Configuring-0.99-System-Groups#fbcn-firmware-build-config-file) as a read-only parameter to report the configuration file used during compilation
- - Changes to [`{ej:1}`](https://github.com/synthetos/g2/wiki/Configuring-0.99-System-Groups#ej-enable-json-mode) Enable JSON parameter. JSON and text mode are now "sticky". Auto mode (old style) is also available
- - Added [`{Nsu:..}`](https://github.com/synthetos/g2/wiki/Configuring-0.99-Motors#1su-steps-per-unit) to directly set motor N's steps-per-unit value
- - Changes to [Status Codes](https://github.com/synthetos/g2/wiki/Status-Codes) (...or see error.h for source)
- - [Power Management](https://github.com/synthetos/g2/wiki/Power-Management) commands have been updated as of fb:100.11. Notably `{me:n}` and `{md:n}` are no longer valid commands - use `{me:0}` and `{md:0}` instead. Read the link for more changes.
- - Additional [`stat`](https://github.com/synthetos/g2/wiki/Status-Reports#stat-values) machine states
- - Removed `{cv:n}` configuration version tag
- - Removed `{js:...}` JSON syntax. Responses are now always Strict. Accepts Strict or Relaxed on input
- - Removed `{ec:...}` Expand CR to CRLF
- - Removed `{ee:...}` Echo command
- - Removed `{baud:...}` Set baud rate command
- - Removed `{ml:...}` Minimum line segment hidden parameter
- - Removed `{ma:...}` Minimum arc segment hidden parameter
- - Removed `{ms:...}` Minimum segment time hidden parameter
- - Exception reports now provide more information about the nature and location of the exception
- - Removed code for embedded tests. These were a holdover from the TinyGv8 codebase and were not functional in g2. The code is now removed from the project.
-
-
-- **[Project Structure and Motate](https://github.com/synthetos/g2/wiki/Project-Structure-and-Motate)**
- - Motate underpinnings and project structure have changed significantly to support multiple processor architectures, boards, and machine configurations cleanly in the same project. If this affects you please read up on the wiki.
-
-
-- **NodeJS g2core Communcications Module**
- - A pre-release of the NodeJS g2core communications module that uses Linemode protocol is available here. This will be superseded with the official release
-
-
-- **Automated Regression Testing**
- - A simple Python functional and regression test suite is available in [Githup/Synthetos/tg_pytest](https://github.com/synthetos/tg_pytest). Please feel free to use and extend, but be aware that we are not offering much support for this. If you are familiar with Python and JSON the Readme should have everything you need.
-
-
-#### Known Issues
-- Communications bug for high-speed transmission
-
-
-## Earlier Edges
-
-### Edge branch, build 083.07
-These changes are primarily fixes applied after testing
-- Fixes to spindle speed settings (082.11)
-- Fixes to build environments for Linux and other platforms
-- Fixes for reporting error in inches mode
-
-### Edge branch, build 082.10
-- **[Digital IO (GPIO)](Digital-IO-(GPIO))** introduces major changes to the way switches and other inputs are handled. The digital inputs are completed, the digital outputs have not been. In short, inputs are now just numbered inputs that are mapped to axes, functions, and motion behaviors (feedholds).
- - **Your configurations will need to change to accommodate these changes.** See settings/settings_shapeoko2.h for an example of setup and use - pay particular attention to `axis settings` and the new `inputs` section.
- - Typing `$`, `$x`, `$di`, `$in` at the command line is also informative. Of course, all these commands are available as JSON, but in text mode you get the human readable annotations.
- - These changes also rev the firmware version to 0.98 from 0.97, as a new configuration wiki page will need to be generated (not started yet).
- - {lim:0}, {lim:1} was added to allow a limit override to backing off switches when a limit is tripped
- - See also [Alarm Processing](Alarm-Processing), which is intimately related to these changes.
-
-- **[Alarm processing](Alarm-Processing)** has been significantly updated. There are now 3 alarm states:
- - [ALARM](Alarm-Processing#alarm) - used to support soft and hard limits, safety interlock behaviors (door open), and other conditions.
- - [SHUTDOWN](Alarm-Processing#shutdown) - used to support external ESTOP functions (the controller doe NOT do ESTOP - read the SHUTDOWN section as to why.
- - [PANIC](Alarm-Processing#panic) - shuts down the machine immediately if there is an assertion failure or some other unrecoverable error
- - [CLEAR](Alarm-Processing#clear) describes how to clear alarm states.
-
-- **[Job Exception Handling](Job-Exception-Handling)** has been refined. A new Job Kill has been introduced which is different than a queue flush (%), as these are actually 2 very different use cases.
-
-- **Homing** changes. Homing input switches are now configured differently.
- - The switch configurations have been removed from the axes and moved to the digital IO inputs.
- - Two new parameters have been added to the axis configs. All other parameters remain the same.
- - {xhd:1} - homing direction - 0=search-to-negative, 1=search-to-positive
- - {xhi:N} - homing input - 0=disable axis for homing, 1-N=enable homing for this input (switch)
- - Note that setting the homing input to a non-zero value (1) enables homing for this axis, and (2) overrides whatever settings for that input for the duration of homing. So it's possible to set di1 (Xmin) as a limit switch and a homing switch. When not in homing it will be used as a limit switch.
-
-- **Safety Interlock** added
- - An input configured for interlock will invoke a feedhold when the interlock becomes diseangaged and restart movement when re-engaged.
- - {saf:0}, {saf:1} was added to enable or disable the interlock system.
- - There are optional settings for spindle and coolant actions on feedhold. See below
-
-- **Spindle Changes** Expect updates to spindle behaviors in future branches. Here's where it is now:
- - The spindle can be paused on feedhold with the Spindle-pause-on-hold global setting {spph:1}. For now we recommend not using this {spph:0} as there is not yet a delay in spindle restart.
- - Spindle enable and direction polarity can now be set using the {spep: } and {spdp: } commands.
- - Spindle enable and direction state can be returned using {spe:n} and {spd:n}, and these can be configured in status reports
- - Spindle speed can be returned using {sps:n} and can be configured in status reports
-
-- **Coolant Changes** Expect coolant changes in future branches, in particular to accommodate changes in the digital outputs.
- - The coolant can be paused on feedhold with the Coolant-pause-on-hold global setting {coph:0}.
- - Flood and mist coolant polarity can now be set using the {cofp: } and {comp: } commands.
- - Flood and mist coolant state can be returned using {cof:n} and {com:n}, and these can be configured in status reports
- - In v9 the flood (M8) and mist (M7) commands are operative, but map the same pin. M9 clears them both, as expected. These should both be set to the same polarity for proper operation. On a Due or a platform with more output pins these can be separated - the code is written for this possibility. The changes should be limited to the pin mapping layers.
-
-- **Power Management** is fully working, as far as we can tell. See $1pm for settings
-
-- **Arc Changes** have been added. Please note any issues immediately. This is still under test.
- - Fixed bug on very large arcs
- - Fixed bug on G18 rotation direction
- - Added P parameter to allow for arcs > 360 degree rotation
-
-- **G10 L20** was added for easier offset setting
-
-- **Bug Fixes**
- - Fixed some units mode display errors for G20 mode (inches)
-
-- **Still To Go**
- - SD card persistence
- - Spindle restart dwell
- - Digital output generalization and changes
- - Still needs rigorous testing for very fast feedhold/resume and flush cycles
+
+
+Experimental traverse at high jerk
+
+ - The new define `TRAVERSE_AT_HIGH_JERK` can be set to `true`, making traverse (`G0`) moves (including `E`-only moves in Marlin-flavored gcode mode) will use the jerk-high (`jh`) settings.
+ - If set to `false` or undefined `G0` moves will continue to use the jerk-max (`jm`) settings that feed (`G1`) moves use.
+
-### Edge branch, build 071.02
+PID+FF - added feed forward
-* **No Persistence**. Most ARM chips (including the ATSAM3X8C on v9 and ATSAM3X8E on the Arduino Due) do not have persistence. This is the main reason the v9 has a microSD slot. But this has not been programmed yet. So your options are to either load the board each time you fire it up or reset it, or to build yourself a profile and compile your own settings as the defaults.
+ - There is a new JSON value `f` in each `pid`*`n`* object (read-only, for reporting) as well as an `f` setting in the `he`*`n`* objects (for control).
+ - This is controlled in the settings file via `H`*`n`*`_DEFAULT_F`, such as `H1_DEFAULT_F`. Default value is `0.0`.
+ - This is a value that is multiplied to by current temp - 21 and added to the current computed output.
+ - **Warning!** Setting this value too high can result in thermal runaway. Set it conservatively (low) or disable it completely if in doubt.
+ - Set the `he`*`n`*`f` value to `0.0` to effectively disable feed-forward.
-* **Still working on feedhold.** The serial communications runs a native USB on the ARM instead of through an FTDI USB-to-Serial adapter. We are still shing some bugs out of the single character commands such as feedhold (!), queue flush (%) and cycle start (~).
+
-* **Power Management needs work.** It doesn't always shut the motors off at the end of a cycle.
+Output setting as soon as possible
-* **Different Behaviors**. There are some behaviors that are different.
- * Feedhold / queue flush on v8 works with !%~ in one line. In g2 it requires a newline. Use !\n%\n This is due to using a USB stack that is partly on the chip and not being able to get at the individual characters that far upstream. This will probably not change in v9.
+ - At board initialization, the output value on each of the `out` objects is set to whatever the pin is configured to be "inactive." This is based on the settings file `DO`*n*`_MODE` setting.
+ - For example, if `DO10_MODE == IO_ACTIVE_LOW` then the pin at `DO10` is initialized as `HIGH` at board setup. This happen even before the `main()` function starts, shortly after the GPIO clocks are enabled for each port.
+
diff --git a/Resources/debug/mb.gdb b/Resources/debug/mb.gdb
index e57e15739..f3165887d 100644
--- a/Resources/debug/mb.gdb
+++ b/Resources/debug/mb.gdb
@@ -3,12 +3,13 @@ set logging overwrite on
set logging redirect on
set logging file mb.txt
set logging on
+print sizeof(mb.bf)/sizeof(mb.bf[0])
print mb.r
print mb.w
print mp.p
print mp.c
# generated with:
-# node -e 'for (i=0; i<48;i++) {console.log("print &mb.bf["+i+"]\nprint mb.bf["+i+"]");}'
+# node -e 'for (i=0; i<96;i++) {console.log("print &mb.bf["+i+"]\nprint mb.bf["+i+"]");}'
print &mb.bf[0]
print mb.bf[0]
print &mb.bf[1]
@@ -105,5 +106,101 @@ print &mb.bf[46]
print mb.bf[46]
print &mb.bf[47]
print mb.bf[47]
+print &mb.bf[48]
+print mb.bf[48]
+print &mb.bf[49]
+print mb.bf[49]
+print &mb.bf[50]
+print mb.bf[50]
+print &mb.bf[51]
+print mb.bf[51]
+print &mb.bf[52]
+print mb.bf[52]
+print &mb.bf[53]
+print mb.bf[53]
+print &mb.bf[54]
+print mb.bf[54]
+print &mb.bf[55]
+print mb.bf[55]
+print &mb.bf[56]
+print mb.bf[56]
+print &mb.bf[57]
+print mb.bf[57]
+print &mb.bf[58]
+print mb.bf[58]
+print &mb.bf[59]
+print mb.bf[59]
+print &mb.bf[60]
+print mb.bf[60]
+print &mb.bf[61]
+print mb.bf[61]
+print &mb.bf[62]
+print mb.bf[62]
+print &mb.bf[63]
+print mb.bf[63]
+print &mb.bf[64]
+print mb.bf[64]
+print &mb.bf[65]
+print mb.bf[65]
+print &mb.bf[66]
+print mb.bf[66]
+print &mb.bf[67]
+print mb.bf[67]
+print &mb.bf[68]
+print mb.bf[68]
+print &mb.bf[69]
+print mb.bf[69]
+print &mb.bf[70]
+print mb.bf[70]
+print &mb.bf[71]
+print mb.bf[71]
+print &mb.bf[72]
+print mb.bf[72]
+print &mb.bf[73]
+print mb.bf[73]
+print &mb.bf[74]
+print mb.bf[74]
+print &mb.bf[75]
+print mb.bf[75]
+print &mb.bf[76]
+print mb.bf[76]
+print &mb.bf[77]
+print mb.bf[77]
+print &mb.bf[78]
+print mb.bf[78]
+print &mb.bf[79]
+print mb.bf[79]
+print &mb.bf[80]
+print mb.bf[80]
+print &mb.bf[81]
+print mb.bf[81]
+print &mb.bf[82]
+print mb.bf[82]
+print &mb.bf[83]
+print mb.bf[83]
+print &mb.bf[84]
+print mb.bf[84]
+print &mb.bf[85]
+print mb.bf[85]
+print &mb.bf[86]
+print mb.bf[86]
+print &mb.bf[87]
+print mb.bf[87]
+print &mb.bf[88]
+print mb.bf[88]
+print &mb.bf[89]
+print mb.bf[89]
+print &mb.bf[90]
+print mb.bf[90]
+print &mb.bf[91]
+print mb.bf[91]
+print &mb.bf[92]
+print mb.bf[92]
+print &mb.bf[93]
+print mb.bf[93]
+print &mb.bf[94]
+print mb.bf[94]
+print &mb.bf[95]
+print mb.bf[95]
set logging off
shell python ../Resources/debug/mb_analyze.py mb.txt
diff --git a/Resources/debug/mb_analyze.py b/Resources/debug/mb_analyze.py
index 3e3368cb0..483cd9321 100644
--- a/Resources/debug/mb_analyze.py
+++ b/Resources/debug/mb_analyze.py
@@ -3,14 +3,14 @@
import sys
STATES = {
- 0 : 'EMPTY',
- 1 : 'PLANNING',
- 2 : 'QUEUED',
- 3 : 'PENDING',
- 4 : 'RUNNING'
+ 0: 'EMPTY',
+ 1: 'PLANNING',
+ 2: 'QUEUED',
+ 3: 'PENDING',
+ 4: 'RUNNING'
}
-TUMBLER = ['r', 'w', 'p', 'c']
+TUMBLER = ['size', 'r', 'w', 'p', 'c']
def load_pool(filename):
@@ -25,8 +25,15 @@ def load_pool(filename):
if buf:
current_buffer = int(buf.groups()[0], 16)
pool[TUMBLER[tumbler_pos]] = current_buffer
- print "TUMBLER[tumbler_pos]: %s=%i" % (TUMBLER[tumbler_pos], current_buffer)
- tumbler_pos += 1
+ print 'TUMBLER[tumbler_pos]: %s=%d' % (
+ TUMBLER[tumbler_pos], current_buffer
+ )
+ else:
+ buf = re.search(' = ([0-9]+)', line)
+ current_buffer = int(buf.groups()[0], 10)
+ pool[TUMBLER[tumbler_pos]] = current_buffer
+
+ tumbler_pos += 1
else:
buf = re.search('\(mpBuf_t\s\*\)\s(0x[0-9a-fA-F]+)', line)
if buf:
@@ -42,7 +49,9 @@ def load_pool(filename):
if current_buffer == pool['c']:
pool[current_buffer]['is_c'] = True
else:
- match = re.search('([a-zA-Z_]+)\s=\s((?:0x[0-9a-fA-F]+|[0-9.]+(?:e[-+][0-9]+)?|[A-Z_]+)|true|false)', line)
+ match = re.search('([a-zA-Z_]+)\s=\s((?:0x[0-9a-fA-F]+|'
+ '[0-9.]+(?:e[-+][0-9]+)?|[A-Z_]+)|true|'
+ 'false)', line)
if match:
# print "current_buffer: %s" % current_buffer
key, val = match.groups()
@@ -85,6 +94,7 @@ def load_pool(filename):
pool[current_buffer]['iterations'] = val
return pool
+
def check_integrity(pool):
key = pool.keys()[0]
buffers = set()
@@ -97,14 +107,16 @@ def check_integrity(pool):
count += 1
- if count != 48:
+ if count != pool['size']:
raise Exception("Buffer pool integrity is bad.")
+
def check_pool(filename):
pool = load_pool(filename)
check_integrity(pool)
return pool
+
def print_pool(pool):
for key in sorted(pool.keys()):
buffer = pool[key]
@@ -141,27 +153,29 @@ def print_pool(pool):
else:
junction_str = "!"
- print '0x%08x [%02d] : N%04d (%02dx) %-22s %-8s L% 8.2f Ti% 8.2f C% 10.2f %1s[% 10.2f] X% 10.2f %1s[% 10.2f] J%1s% 10.2f %5s %20s (%5.2f)' % (
- key,
- float(buffer['buffer_number']),
- float(buffer['linenum']),
- int(buffer['iterations']),
- buffer['buffer_state'].strip(),
- pointer,
- float(buffer['length']),
- float(buffer['move_time']),
- float(buffer['cruise_velocity']),
- cruise_str,
- float(buffer['cruise_vmax']),
- float(buffer['exit_velocity']),
- exit_str,
- float(buffer['exit_vmax']),
- junction_str,
- float(buffer['junction_vmax']),
- buffer['plannable'],
- buffer['hint'],
- float(buffer['jerk'])/1000000.0
- )
+ print '0x%08x [%02d] : N%06d (%02dx) %-22s %-8s L% 8.2f Ti% 8.2f '\
+ 'C% 10.2f %1s[% 10.2f] X% 10.2f %1s[% 10.2f] J%1s% 10.2f ' \
+ '%5s %20s (%5.2f)' % (
+ key,
+ float(buffer['buffer_number']), # []
+ float(buffer['linenum']), # N
+ int(buffer['iterations']), # ()
+ buffer['buffer_state'].strip(),
+ pointer, # (w,p,r)
+ float(buffer['length']), # L
+ float(buffer['move_time']), # Ti
+ float(buffer['cruise_velocity']), # C
+ cruise_str,
+ float(buffer['cruise_vmax']),
+ float(buffer['exit_velocity']), # X
+ exit_str,
+ float(buffer['exit_vmax']),
+ junction_str, # J
+ float(buffer['junction_vmax']),
+ buffer['plannable'],
+ buffer['hint'],
+ float(buffer['jerk'])/1000000.0
+ )
if __name__ == "__main__":
pool = check_pool(sys.argv[1])
diff --git a/Resources/generate_motors_cfgArray.js b/Resources/generate_motors_cfgArray.js
new file mode 100755
index 000000000..d41aee68b
--- /dev/null
+++ b/Resources/generate_motors_cfgArray.js
@@ -0,0 +1,38 @@
+#!/usr/bin/env node
+
+// Run this with no arguments, and get the motor code suitable for use in config_app.cpp
+
+for (n=1; n<=6; n++) {
+ console.log(`
+#if (MOTORS >= ${n})
+ { "${n}","${n}ma", _fip, 0, st_print_ma, get_ui8, st_set_ma, (float *)&st_cfg.mot[MOTOR_${n}].motor_map, M${n}_MOTOR_MAP },
+ { "${n}","${n}sa", _fip, 3, st_print_sa, get_flt, st_set_sa, (float *)&st_cfg.mot[MOTOR_${n}].step_angle, M${n}_STEP_ANGLE },
+ { "${n}","${n}tr", _fipc, 4, st_print_tr, get_flt, st_set_tr, (float *)&st_cfg.mot[MOTOR_${n}].travel_rev, M${n}_TRAVEL_PER_REV },
+ { "${n}","${n}mi", _fip, 0, st_print_mi, get_int, st_set_mi, (float *)&st_cfg.mot[MOTOR_${n}].microsteps, M${n}_MICROSTEPS },
+ { "${n}","${n}su", _fipi, 5, st_print_su, st_get_su,st_set_su, (float *)&st_cfg.mot[MOTOR_${n}].steps_per_unit, M${n}_STEPS_PER_UNIT },
+ { "${n}","${n}po", _fip, 0, st_print_po, get_ui8, set_01, (float *)&st_cfg.mot[MOTOR_${n}].polarity, M${n}_POLARITY },
+ { "${n}","${n}pm", _fip, 0, st_print_pm, st_get_pm,st_set_pm, (float *)&cs.null, M${n}_POWER_MODE },
+ { "${n}","${n}pl", _fip, 3, st_print_pl, get_flt, st_set_pl, (float *)&st_cfg.mot[MOTOR_${n}].power_level, M${n}_POWER_LEVEL },
+// { "${n}","${n}pi", _fip, 3, st_print_pi, get_flt, st_set_pi, (float *)&st_cfg.mot[MOTOR_${n}].power_idle, M${n}_POWER_IDLE },
+// { "${n}","${n}mt", _fip, 2, st_print_mt, get_flt, st_set_mt, (float *)&st_cfg.mot[MOTOR_${n}].motor_timeout, M${n}_MOTOR_TIMEOUT },
+#ifdef MOTOR_${n}_IS_TRINAMIC
+ { "${n}","${n}ts", _f0, 0, tx_print_nul, motor_${n}.get_ts_fn, set_ro, (float *)&motor_${n}, 0 },
+ { "${n}","${n}pth", _fip, 0, tx_print_nul, motor_${n}.get_pth_fn, motor_${n}.set_pth_fn, (float *)&motor_${n}, M${n}_TMC2130_TPWMTHRS },
+ { "${n}","${n}cth", _fip, 0, tx_print_nul, motor_${n}.get_cth_fn, motor_${n}.set_cth_fn, (float *)&motor_${n}, M${n}_TMC2130_TCOOLTHRS },
+ { "${n}","${n}hth", _fip, 0, tx_print_nul, motor_${n}.get_hth_fn, motor_${n}.set_hth_fn, (float *)&motor_${n}, M${n}_TMC2130_THIGH },
+ { "${n}","${n}sgt", _fip, 0, tx_print_nul, motor_${n}.get_sgt_fn, motor_${n}.set_sgt_fn, (float *)&motor_${n}, M${n}_TMC2130_SGT },
+ { "${n}","${n}sgr", _f0, 0, tx_print_nul, motor_${n}.get_sgr_fn, set_ro, (float *)&motor_${n}, 0 },
+ { "${n}","${n}csa", _f0, 0, tx_print_nul, motor_${n}.get_csa_fn, set_ro, (float *)&motor_${n}, 0 },
+ { "${n}","${n}sgs", _f0, 0, tx_print_nul, motor_${n}.get_sgs_fn, set_ro, (float *)&motor_${n}, 0 },
+ { "${n}","${n}tbl", _fip, 0, tx_print_nul, motor_${n}.get_tbl_fn, motor_${n}.set_tbl_fn, (float *)&motor_${n}, M${n}_TMC2130_TBL },
+ { "${n}","${n}pgrd",_fip, 0, tx_print_nul, motor_${n}.get_pgrd_fn,motor_${n}.set_pgrd_fn, (float *)&motor_${n}, M${n}_TMC2130_PWM_GRAD },
+ { "${n}","${n}pamp",_fip, 0, tx_print_nul, motor_${n}.get_pamp_fn,motor_${n}.set_pamp_fn, (float *)&motor_${n}, M${n}_TMC2130_PWM_AMPL },
+ { "${n}","${n}hend",_fip, 0, tx_print_nul, motor_${n}.get_hend_fn,motor_${n}.set_hend_fn, (float *)&motor_${n}, M${n}_TMC2130_HEND },
+ { "${n}","${n}hsrt",_fip, 0, tx_print_nul, motor_${n}.get_hsrt_fn,motor_${n}.set_hsrt_fn, (float *)&motor_${n}, M${n}_TMC2130_HSTRT },
+ { "${n}","${n}smin",_fip, 0, tx_print_nul, motor_${n}.get_smin_fn,motor_${n}.set_smin_fn, (float *)&motor_${n}, M${n}_TMC2130_SMIN },
+ { "${n}","${n}smax",_fip, 0, tx_print_nul, motor_${n}.get_smax_fn,motor_${n}.set_smax_fn, (float *)&motor_${n}, M${n}_TMC2130_SMAX },
+ { "${n}","${n}sup", _fip, 0, tx_print_nul, motor_${n}.get_sup_fn, motor_${n}.set_sup_fn, (float *)&motor_${n}, M${n}_TMC2130_SUP },
+ { "${n}","${n}sdn", _fip, 0, tx_print_nul, motor_${n}.get_sdn_fn, motor_${n}.set_sdn_fn, (float *)&motor_${n}, M${n}_TMC2130_SDN },
+#endif
+#endif`);
+}
diff --git a/Resources/generate_motors_default_config.js b/Resources/generate_motors_default_config.js
new file mode 100755
index 000000000..2d98a45da
--- /dev/null
+++ b/Resources/generate_motors_default_config.js
@@ -0,0 +1,50 @@
+#!/usr/bin/env node
+
+// Run this with no arguments, and get the motor code suitable for use in config_app.cpp
+
+console.log('// START Generated with ${PROJECT_ROOT}/Resources/generate_motors_default_config.js');
+for (n=1; n<=6; n++) {
+ console.log(
+`#ifndef M${n}_TMC2130_TPWMTHRS
+ #define M${n}_TMC2130_TPWMTHRS 1200 // ${n}pth
+#endif
+#ifndef M${n}_TMC2130_TCOOLTHRS
+ #define M${n}_TMC2130_TCOOLTHRS 1000 // ${n}cth
+#endif
+#ifndef M${n}_TMC2130_THIGH
+ #define M${n}_TMC2130_THIGH 10 // ${n}hth
+#endif
+#ifndef M${n}_TMC2130_SGT
+ #define M${n}_TMC2130_SGT 4 // ${n}sgt
+#endif
+#ifndef M${n}_TMC2130_TBL
+ #define M${n}_TMC2130_TBL 2 // ${n}tbl
+#endif
+#ifndef M${n}_TMC2130_PWM_GRAD
+ #define M${n}_TMC2130_PWM_GRAD 1 // ${n}pgrd
+#endif
+#ifndef M${n}_TMC2130_PWM_AMPL
+ #define M${n}_TMC2130_PWM_AMPL 200 // ${n}pamp
+#endif
+#ifndef M${n}_TMC2130_HEND
+ #define M${n}_TMC2130_HEND 0 // ${n}hend
+#endif
+#ifndef M${n}_TMC2130_HSTRT
+ #define M${n}_TMC2130_HSTRT 0 // ${n}hsrt
+#endif
+#ifndef M${n}_TMC2130_SMIN
+ #define M${n}_TMC2130_SMIN 5 // ${n}smin
+#endif
+#ifndef M${n}_TMC2130_SMAX
+ #define M${n}_TMC2130_SMAX 5 // ${n}smax
+#endif
+#ifndef M${n}_TMC2130_SUP
+ #define M${n}_TMC2130_SUP 2 // ${n}sup
+#endif
+#ifndef M${n}_TMC2130_SDN
+ #define M${n}_TMC2130_SDN 1 // ${n}sdn
+#endif
+`
+);
+}
+console.log('// END Generated');
diff --git a/g2core.atsln b/g2core.atsln
index 93cd6ae13..fbe1501b8 100644
--- a/g2core.atsln
+++ b/g2core.atsln
@@ -9,12 +9,15 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
G2v9k|ARM = G2v9k|ARM
+ gQuadratic on AxiDraw v3|ARM = gQuadratic on AxiDraw v3|ARM
+ gQuintic on AxiDraw v3|ARM = gQuintic on AxiDraw v3|ARM
gShield|ARM = gShield|ARM
Makeblock-v9|ARM = Makeblock-v9|ARM
Othermill|ARM = Othermill|ARM
PrintrbotSimple1403-printrboardG2v3|ARM = PrintrbotSimple1403-printrboardG2v3|ARM
PrintrbotSimple1608-printrboardG2v3|ARM = PrintrbotSimple1608-printrboardG2v3|ARM
ProbotixV90|ARM = ProbotixV90|ARM
+ Quintic-Ender|ARM = Quintic-Ender|ARM
sbv300|ARM = sbv300|ARM
Shapeoko2|ARM = Shapeoko2|ARM
shopbotShield|ARM = shopbotShield|ARM
@@ -23,11 +26,17 @@ Global
TestQuintic|ARM = TestQuintic|ARM
TestV9|ARM = TestV9|ARM
Ultimakerv9k|ARM = Ultimakerv9k|ARM
+ xcarve-extended|ARM = xcarve-extended|ARM
Zen7x12|ARM = Zen7x12|ARM
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{44EA8FEC-55D7-4149-8A78-A574FC26BF51}.G2v9k|ARM.ActiveCfg = G2v9k|ARM
{44EA8FEC-55D7-4149-8A78-A574FC26BF51}.G2v9k|ARM.Build.0 = G2v9k|ARM
+ {44EA8FEC-55D7-4149-8A78-A574FC26BF51}.G2v9k|ARM.Deploy.0 = G2v9k|ARM
+ {44EA8FEC-55D7-4149-8A78-A574FC26BF51}.gQuadratic on AxiDraw v3|ARM.ActiveCfg = gQuadratic on AxiDraw v3|ARM
+ {44EA8FEC-55D7-4149-8A78-A574FC26BF51}.gQuadratic on AxiDraw v3|ARM.Build.0 = gQuadratic on AxiDraw v3|ARM
+ {44EA8FEC-55D7-4149-8A78-A574FC26BF51}.gQuintic on AxiDraw v3|ARM.ActiveCfg = qQuintic on AxiDraw v3|ARM
+ {44EA8FEC-55D7-4149-8A78-A574FC26BF51}.gQuintic on AxiDraw v3|ARM.Build.0 = qQuintic on AxiDraw v3|ARM
{44EA8FEC-55D7-4149-8A78-A574FC26BF51}.gShield|ARM.ActiveCfg = gShield|ARM
{44EA8FEC-55D7-4149-8A78-A574FC26BF51}.gShield|ARM.Build.0 = gShield|ARM
{44EA8FEC-55D7-4149-8A78-A574FC26BF51}.Makeblock-v9|ARM.ActiveCfg = Makeblock-v9|ARM
@@ -40,6 +49,8 @@ Global
{44EA8FEC-55D7-4149-8A78-A574FC26BF51}.PrintrbotSimple1608-printrboardG2v3|ARM.Build.0 = PrintrbotSimple1608-printrboardG2v3|ARM
{44EA8FEC-55D7-4149-8A78-A574FC26BF51}.ProbotixV90|ARM.ActiveCfg = ProbotixV90|ARM
{44EA8FEC-55D7-4149-8A78-A574FC26BF51}.ProbotixV90|ARM.Build.0 = ProbotixV90|ARM
+ {44EA8FEC-55D7-4149-8A78-A574FC26BF51}.Quintic-Ender|ARM.ActiveCfg = qQuintic on AxiDraw v3|ARM
+ {44EA8FEC-55D7-4149-8A78-A574FC26BF51}.Quintic-Ender|ARM.Build.0 = qQuintic on AxiDraw v3|ARM
{44EA8FEC-55D7-4149-8A78-A574FC26BF51}.sbv300|ARM.ActiveCfg = sbv300|ARM
{44EA8FEC-55D7-4149-8A78-A574FC26BF51}.sbv300|ARM.Build.0 = sbv300|ARM
{44EA8FEC-55D7-4149-8A78-A574FC26BF51}.Shapeoko2|ARM.ActiveCfg = Shapeoko2|ARM
@@ -55,15 +66,21 @@ Global
{44EA8FEC-55D7-4149-8A78-A574FC26BF51}.TestV9|ARM.Build.0 = TestV9|ARM
{44EA8FEC-55D7-4149-8A78-A574FC26BF51}.Ultimakerv9k|ARM.ActiveCfg = Ultimakerv9k|ARM
{44EA8FEC-55D7-4149-8A78-A574FC26BF51}.Ultimakerv9k|ARM.Build.0 = Ultimakerv9k|ARM
+ {44EA8FEC-55D7-4149-8A78-A574FC26BF51}.xcarve-extended|ARM.ActiveCfg = PrintrbotPlay-v3|ARM
+ {44EA8FEC-55D7-4149-8A78-A574FC26BF51}.xcarve-extended|ARM.Build.0 = PrintrbotPlay-v3|ARM
{44EA8FEC-55D7-4149-8A78-A574FC26BF51}.Zen7x12|ARM.ActiveCfg = Zen7x12|ARM
{44EA8FEC-55D7-4149-8A78-A574FC26BF51}.Zen7x12|ARM.Build.0 = Zen7x12|ARM
{D7779B24-5CD6-4A1B-893C-2CAE8CF7A3A0}.G2v9k|ARM.ActiveCfg = Stub|ARM
+ {D7779B24-5CD6-4A1B-893C-2CAE8CF7A3A0}.gQuadratic on AxiDraw v3|ARM.ActiveCfg = Stub|ARM
+ {D7779B24-5CD6-4A1B-893C-2CAE8CF7A3A0}.gQuintic on AxiDraw v3|ARM.ActiveCfg = Stub|ARM
{D7779B24-5CD6-4A1B-893C-2CAE8CF7A3A0}.gShield|ARM.ActiveCfg = Stub|ARM
{D7779B24-5CD6-4A1B-893C-2CAE8CF7A3A0}.Makeblock-v9|ARM.ActiveCfg = Stub|ARM
{D7779B24-5CD6-4A1B-893C-2CAE8CF7A3A0}.Othermill|ARM.ActiveCfg = Stub|ARM
{D7779B24-5CD6-4A1B-893C-2CAE8CF7A3A0}.PrintrbotSimple1403-printrboardG2v3|ARM.ActiveCfg = Stub|ARM
{D7779B24-5CD6-4A1B-893C-2CAE8CF7A3A0}.PrintrbotSimple1608-printrboardG2v3|ARM.ActiveCfg = Stub|ARM
{D7779B24-5CD6-4A1B-893C-2CAE8CF7A3A0}.ProbotixV90|ARM.ActiveCfg = Stub|ARM
+ {D7779B24-5CD6-4A1B-893C-2CAE8CF7A3A0}.Quintic-Ender|ARM.ActiveCfg = Stub|ARM
+ {D7779B24-5CD6-4A1B-893C-2CAE8CF7A3A0}.Quintic-Ender|ARM.Build.0 = Stub|ARM
{D7779B24-5CD6-4A1B-893C-2CAE8CF7A3A0}.sbv300|ARM.ActiveCfg = Stub|ARM
{D7779B24-5CD6-4A1B-893C-2CAE8CF7A3A0}.Shapeoko2|ARM.ActiveCfg = Stub|ARM
{D7779B24-5CD6-4A1B-893C-2CAE8CF7A3A0}.shopbotShield|ARM.ActiveCfg = Stub|ARM
@@ -72,6 +89,8 @@ Global
{D7779B24-5CD6-4A1B-893C-2CAE8CF7A3A0}.TestQuintic|ARM.ActiveCfg = Stub|ARM
{D7779B24-5CD6-4A1B-893C-2CAE8CF7A3A0}.TestV9|ARM.ActiveCfg = Stub|ARM
{D7779B24-5CD6-4A1B-893C-2CAE8CF7A3A0}.Ultimakerv9k|ARM.ActiveCfg = Stub|ARM
+ {D7779B24-5CD6-4A1B-893C-2CAE8CF7A3A0}.xcarve-extended|ARM.ActiveCfg = Stub|ARM
+ {D7779B24-5CD6-4A1B-893C-2CAE8CF7A3A0}.xcarve-extended|ARM.Build.0 = Stub|ARM
{D7779B24-5CD6-4A1B-893C-2CAE8CF7A3A0}.Zen7x12|ARM.ActiveCfg = Stub|ARM
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
diff --git a/g2core/Makefile b/g2core/Makefile
index bdbb1848a..8a98eec86 100755
--- a/g2core/Makefile
+++ b/g2core/Makefile
@@ -49,14 +49,11 @@ SETTINGS_FILE ?= settings_default.h
NEEDS_PRINTF_FLOAT=1
-# Now invoke the Motate compile system
-include $(MOTATE_PATH)/Motate.mk
-
ifeq ($(DEBUG),0)
- DEVICE_DEFINES += DEBUG=0 IN_DEBUGGER=0
+DEVICE_DEFINES += DEBUG=0 IN_DEBUGGER=0
endif
ifeq ($(DEBUG),1)
- DEVICE_DEFINES += DEBUG=1 IN_DEBUGGER=0
+DEVICE_DEFINES += DEBUG=1 IN_DEBUGGER=0
endif
ifeq ($(DEBUG),2)
DEVICE_DEFINES += DEBUG=1 IN_DEBUGGER=1
@@ -65,4 +62,9 @@ ifeq ($(DEBUG),3)
DEVICE_DEFINES += DEBUG=1 IN_DEBUGGER=1 DEBUG_SEMIHOSTING=1
endif
+TOOLS_VERSION = "6.2u1"
+
+# Now invoke the Motate compile system
+include $(MOTATE_PATH)/Motate.mk
+
# *** EOF ***
diff --git a/g2core/board/Archim/hardware.cpp b/g2core/board/Archim/0_hardware.cpp
similarity index 100%
rename from g2core/board/Archim/hardware.cpp
rename to g2core/board/Archim/0_hardware.cpp
diff --git a/g2core/board/Archim/Archim-pinout.h b/g2core/board/Archim/Archim-pinout.h
index 1d49ac1af..77f61c234 100755
--- a/g2core/board/Archim/Archim-pinout.h
+++ b/g2core/board/Archim/Archim-pinout.h
@@ -49,11 +49,6 @@
#define INPUT12_AVAILABLE 1
#define INPUT13_AVAILABLE 0
-#define ADC0_AVAILABLE 0
-#define ADC1_AVAILABLE 0
-#define ADC2_AVAILABLE 0
-#define ADC3_AVAILABLE 0
-
#define XIO_HAS_USB 1
#define XIO_HAS_UART 1
#define XIO_HAS_SPI 0
@@ -223,21 +218,21 @@ pin_number kOutput14_PinNumber = -1; // 143;
pin_number kOutput15_PinNumber = -1; // 144;
pin_number kOutput16_PinNumber = -1; // 145;
-pin_number kADC0_PinNumber = 11; // Heated bed thermistor ADC
-pin_number kADC1_PinNumber = 10; // Extruder1_ADC
-pin_number kADC2_PinNumber = 8; // Extruder2_ADC
-pin_number kADC3_PinNumber = -1; // 153;
-pin_number kADC4_PinNumber = -1; // 154;
-pin_number kADC5_PinNumber = -1; // 155;
-pin_number kADC6_PinNumber = -1; // 156;
-pin_number kADC7_PinNumber = -1; // 157;
-pin_number kADC8_PinNumber = -1; // 158;
-pin_number kADC9_PinNumber = -1; // 159;
-pin_number kADC10_PinNumber = -1; // 160;
-pin_number kADC11_PinNumber = -1; // 161;
-pin_number kADC12_PinNumber = -1; // 162;
-pin_number kADC13_PinNumber = -1; // Not physially pinned out
+pin_number kADC1_PinNumber = 11; // Heated bed thermistor ADC
+pin_number kADC2_PinNumber = 10; // Extruder1_ADC
+pin_number kADC3_PinNumber = 8; // Extruder2_ADC
+pin_number kADC4_PinNumber = -1; // 153;
+pin_number kADC5_PinNumber = -1; // 154;
+pin_number kADC6_PinNumber = -1; // 155;
+pin_number kADC7_PinNumber = -1; // 156;
+pin_number kADC8_PinNumber = -1; // 157;
+pin_number kADC9_PinNumber = -1; // 158;
+pin_number kADC10_PinNumber = -1; // 159;
+pin_number kADC11_PinNumber = -1; // 160;
+pin_number kADC12_PinNumber = -1; // 161;
+pin_number kADC13_PinNumber = -1; // 162;
pin_number kADC14_PinNumber = -1; // Not physially pinned out
+pin_number kADC15_PinNumber = -1; // Not physially pinned out
// GRBL / gShield compatibility pins -- Due board ONLY
diff --git a/g2core/board/Archim/board_gpio.cpp b/g2core/board/Archim/board_gpio.cpp
new file mode 100644
index 000000000..4daf011d8
--- /dev/null
+++ b/g2core/board/Archim/board_gpio.cpp
@@ -0,0 +1,108 @@
+/*
+ * gpio.cpp - digital IO handling functions
+ * This file is part of the g2core project
+ *
+ * Copyright (c) 2015 - 2107 Alden S. Hart, Jr.
+ * Copyright (c) 2015 - 2017 Robert Giseburt
+ *
+ * This file ("the software") is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2 as published by the
+ * Free Software Foundation. You should have received a copy of the GNU General Public
+ * License, version 2 along with the software. If not, see .
+ *
+ * As a special exception, you may use this file as part of a software library without
+ * restriction. Specifically, if other files instantiate templates or use macros or
+ * inline functions from this file, or you compile this file and link it with other
+ * files to produce an executable, this file does not by itself cause the resulting
+ * executable to be covered by the GNU General Public License. This exception does not
+ * however invalidate any other reasons why the executable file might be covered by the
+ * GNU General Public License.
+ *
+ * THE SOFTWARE IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY
+ * WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+ * SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* Switch Modes
+ *
+ * The switches are considered to be homing switches when cycle_state is
+ * CYCLE_HOMING. At all other times they are treated as limit switches:
+ * - Hitting a homing switch puts the current move into feedhold
+ * - Hitting a limit switch causes the machine to shut down and go into lockdown until reset
+ *
+ * The normally open switch modes (NO) trigger an interrupt on the falling edge
+ * and lockout subsequent interrupts for the defined lockout period. This approach
+ * beats doing debouncing as an integration as switches fire immediately.
+ *
+ * The normally closed switch modes (NC) trigger an interrupt on the rising edge
+ * and lockout subsequent interrupts for the defined lockout period. Ditto on the method.
+ */
+
+#include "../../g2core.h" // #1
+#include "config.h" // #2
+#include "gpio.h"
+#include "hardware.h"
+#include "canonical_machine.h"
+
+#include "text_parser.h"
+#include "controller.h"
+#include "util.h"
+#include "report.h"
+#include "xio.h"
+
+#include "MotateTimers.h"
+
+/**** Setup Actual Objects ****/
+
+gpioDigitalInputPin> din1 {DI1_MODE, 1};
+gpioDigitalInputPin> din2 {DI2_MODE, 2};
+gpioDigitalInputPin> din3 {DI3_MODE, 3};
+gpioDigitalInputPin> din4 {DI4_MODE, 4};
+gpioDigitalInputPin> din5 {DI5_MODE, 5};
+gpioDigitalInputPin> din6 {DI6_MODE, 6};
+gpioDigitalInputPin> din7 {DI7_MODE, 7};
+gpioDigitalInputPin> din8 {DI8_MODE, 8};
+gpioDigitalInputPin> din9 {DI9_MODE, 9};
+// gpioDigitalInputPin> din10 {DI10_MODE, 10};
+// gpioDigitalInputPin> din11 {DI11_MODE, 11};
+// gpioDigitalInputPin> din12 {DI12_MODE, 12};
+
+gpioDigitalOutputPin> dout1 { DO1_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout2 { DO2_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout3 { DO3_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout4 { DO4_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout5 { DO5_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout6 { DO6_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout7 { DO7_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout8 { DO8_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout9 { DO9_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout10 { DO10_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout11 { DO11_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout12 { DO12_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout13 { DO13_MODE, (uint32_t)200000 };
+
+/**** Setup Arrays - these are extern and MUST match the board_gpio.h ****/
+
+gpioDigitalInput* const d_in[] = {&din1, &din2, &din3, &din4, &din5, &din6, &din7, &din8, &din9};
+gpioDigitalOutput* const d_out[] = {&dout1, &dout2, &dout3, &dout4, &dout5, &dout6, &dout7, &dout8, &dout9, &dout10, &dout11, &dout12, &dout13};
+// not yet used
+// gpioAnalogInput* a_in[A_IN_CHANNELS];
+// gpioAnalogOutput* a_out[A_OUT_CHANNELS];
+
+/************************************************************************************
+ **** CODE **************************************************************************
+ ************************************************************************************/
+/*
+ * gpio_reset() - reset inputs and outputs (no initialization)
+ */
+
+
+void outputs_reset(void) {
+ // nothing to do
+}
+
+void inputs_reset(void) {
+ // nothing to do
+}
diff --git a/g2core/board/Archim/board_gpio.h b/g2core/board/Archim/board_gpio.h
new file mode 100644
index 000000000..25a1cddcd
--- /dev/null
+++ b/g2core/board/Archim/board_gpio.h
@@ -0,0 +1,90 @@
+/*
+ * gpio.h - Digital IO handling functions
+ * This file is part of the g2core project
+ *
+ * Copyright (c) 2015 - 2017 Alden S. Hart, Jr.
+ * Copyright (c) 2015 - 2017 Robert Giseburt
+ *
+ * This file ("the software") is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2 as published by the
+ * Free Software Foundation. You should have received a copy of the GNU General Public
+ * License, version 2 along with the software. If not, see .
+ *
+ * As a special exception, you may use this file as part of a software library without
+ * restriction. Specifically, if other files instantiate templates or use macros or
+ * inline functions from this file, or you compile this file and link it with other
+ * files to produce an executable, this file does not by itself cause the resulting
+ * executable to be covered by the GNU General Public License. This exception does not
+ * however invalidate any other reasons why the executable file might be covered by the
+ * GNU General Public License.
+ *
+ * THE SOFTWARE IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY
+ * WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+ * SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef BOARD_GPIO_H_ONCE
+#define BOARD_GPIO_H_ONCE
+
+// this file is included from the bottom of gpio.h, but we do this for completeness
+#include "../../gpio.h"
+
+/*
+ * GPIO defines
+ */
+//--- change as required for board and switch hardware ---//
+
+#define D_IN_CHANNELS 9 // v9 // number of digital inputs supported
+#define D_OUT_CHANNELS 13 // number of digital outputs supported
+#define A_IN_CHANNELS 0 // number of analog inputs supported
+#define A_OUT_CHANNELS 0 // number of analog outputs supported
+
+#define INPUT_LOCKOUT_MS 10 // milliseconds to go dead after input firing
+
+/*
+ * The GPIO objects themselves - this must match up with board_gpio.cpp!
+ */
+
+extern gpioDigitalInput* const d_in[D_IN_CHANNELS];
+extern gpioDigitalOutput* const d_out[D_OUT_CHANNELS];
+// extern gpioAnalogInput* a_in[A_IN_CHANNELS];
+// extern gpioAnalogOutput* a_out[A_OUT_CHANNELS];
+
+// prepare the objects as externs (for config_app to not bloat)
+using Motate::IRQPin;
+using Motate::PWMOutputPin;
+using Motate::PWMLikeOutputPin;
+template
+using OutputType = typename std::conditional, PWMLikeOutputPin>::type;
+
+extern gpioDigitalInputPin> din1;
+extern gpioDigitalInputPin> din2;
+extern gpioDigitalInputPin> din3;
+extern gpioDigitalInputPin> din4;
+extern gpioDigitalInputPin> din5;
+extern gpioDigitalInputPin> din6;
+extern gpioDigitalInputPin> din7;
+extern gpioDigitalInputPin> din8;
+extern gpioDigitalInputPin> din9;
+// extern gpioDigitalInputPin> din10;
+// extern gpioDigitalInputPin> din11;
+// extern gpioDigitalInputPin> din12;
+
+extern gpioDigitalOutputPin> dout1;
+extern gpioDigitalOutputPin> dout2;
+extern gpioDigitalOutputPin> dout3;
+extern gpioDigitalOutputPin> dout4;
+extern gpioDigitalOutputPin> dout5;
+extern gpioDigitalOutputPin> dout6;
+extern gpioDigitalOutputPin> dout7;
+extern gpioDigitalOutputPin> dout8;
+extern gpioDigitalOutputPin> dout9;
+extern gpioDigitalOutputPin> dout10;
+extern gpioDigitalOutputPin> dout11;
+extern gpioDigitalOutputPin> dout12;
+extern gpioDigitalOutputPin> dout13;
+
+
+#endif // End of include guard: BOARD_GPIO_H_ONCE
diff --git a/g2core/board/Archim/board_xio.h b/g2core/board/Archim/board_xio.h
index 09f20fef8..ea0a3fa7b 100755
--- a/g2core/board/Archim/board_xio.h
+++ b/g2core/board/Archim/board_xio.h
@@ -37,10 +37,10 @@
#include "MotateUSBCDC.h"
#if USB_SERIAL_PORTS_EXPOSED == 1
-typedef Motate::USBDevice< Motate::USBCDC > XIOUSBDevice_t;
+typedef Motate::USBDevice< USBDeviceHardware, Motate::USBCDC > XIOUSBDevice_t;
#endif
#if USB_SERIAL_PORTS_EXPOSED == 2
-typedef Motate::USBDevice XIOUSBDevice_t;
+typedef Motate::USBDevice< USBDeviceHardware, Motate::USBCDC, Motate::USBCDC > XIOUSBDevice_t;
#endif
extern XIOUSBDevice_t usb;
diff --git a/g2core/board/Archim/hardware.h b/g2core/board/Archim/hardware.h
index e69d67ec9..928d20da5 100644
--- a/g2core/board/Archim/hardware.h
+++ b/g2core/board/Archim/hardware.h
@@ -121,7 +121,6 @@ using Motate::OutputPin;
//#define FREQUENCY_DDA 200000UL // Hz step frequency. Interrupts actually fire at 2x (400 KHz)
#define FREQUENCY_DDA 150000UL // Hz step frequency. Interrupts actually fire at 2x (300 KHz)
#define FREQUENCY_DWELL 1000UL
-#define FREQUENCY_SGI 200000UL // 200,000 Hz means software interrupts will fire 5 uSec after being called
/**** Motate Definitions ****/
diff --git a/g2core/board/ArduinoDue/hardware.cpp b/g2core/board/ArduinoDue/0_hardware.cpp
similarity index 100%
rename from g2core/board/ArduinoDue/hardware.cpp
rename to g2core/board/ArduinoDue/0_hardware.cpp
diff --git a/g2core/board/ArduinoDue/board_gpio.cpp b/g2core/board/ArduinoDue/board_gpio.cpp
new file mode 100644
index 000000000..4daf011d8
--- /dev/null
+++ b/g2core/board/ArduinoDue/board_gpio.cpp
@@ -0,0 +1,108 @@
+/*
+ * gpio.cpp - digital IO handling functions
+ * This file is part of the g2core project
+ *
+ * Copyright (c) 2015 - 2107 Alden S. Hart, Jr.
+ * Copyright (c) 2015 - 2017 Robert Giseburt
+ *
+ * This file ("the software") is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2 as published by the
+ * Free Software Foundation. You should have received a copy of the GNU General Public
+ * License, version 2 along with the software. If not, see .
+ *
+ * As a special exception, you may use this file as part of a software library without
+ * restriction. Specifically, if other files instantiate templates or use macros or
+ * inline functions from this file, or you compile this file and link it with other
+ * files to produce an executable, this file does not by itself cause the resulting
+ * executable to be covered by the GNU General Public License. This exception does not
+ * however invalidate any other reasons why the executable file might be covered by the
+ * GNU General Public License.
+ *
+ * THE SOFTWARE IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY
+ * WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+ * SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* Switch Modes
+ *
+ * The switches are considered to be homing switches when cycle_state is
+ * CYCLE_HOMING. At all other times they are treated as limit switches:
+ * - Hitting a homing switch puts the current move into feedhold
+ * - Hitting a limit switch causes the machine to shut down and go into lockdown until reset
+ *
+ * The normally open switch modes (NO) trigger an interrupt on the falling edge
+ * and lockout subsequent interrupts for the defined lockout period. This approach
+ * beats doing debouncing as an integration as switches fire immediately.
+ *
+ * The normally closed switch modes (NC) trigger an interrupt on the rising edge
+ * and lockout subsequent interrupts for the defined lockout period. Ditto on the method.
+ */
+
+#include "../../g2core.h" // #1
+#include "config.h" // #2
+#include "gpio.h"
+#include "hardware.h"
+#include "canonical_machine.h"
+
+#include "text_parser.h"
+#include "controller.h"
+#include "util.h"
+#include "report.h"
+#include "xio.h"
+
+#include "MotateTimers.h"
+
+/**** Setup Actual Objects ****/
+
+gpioDigitalInputPin> din1 {DI1_MODE, 1};
+gpioDigitalInputPin> din2 {DI2_MODE, 2};
+gpioDigitalInputPin> din3 {DI3_MODE, 3};
+gpioDigitalInputPin> din4 {DI4_MODE, 4};
+gpioDigitalInputPin> din5 {DI5_MODE, 5};
+gpioDigitalInputPin> din6 {DI6_MODE, 6};
+gpioDigitalInputPin> din7 {DI7_MODE, 7};
+gpioDigitalInputPin> din8 {DI8_MODE, 8};
+gpioDigitalInputPin> din9 {DI9_MODE, 9};
+// gpioDigitalInputPin> din10 {DI10_MODE, 10};
+// gpioDigitalInputPin> din11 {DI11_MODE, 11};
+// gpioDigitalInputPin> din12 {DI12_MODE, 12};
+
+gpioDigitalOutputPin> dout1 { DO1_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout2 { DO2_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout3 { DO3_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout4 { DO4_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout5 { DO5_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout6 { DO6_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout7 { DO7_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout8 { DO8_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout9 { DO9_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout10 { DO10_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout11 { DO11_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout12 { DO12_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout13 { DO13_MODE, (uint32_t)200000 };
+
+/**** Setup Arrays - these are extern and MUST match the board_gpio.h ****/
+
+gpioDigitalInput* const d_in[] = {&din1, &din2, &din3, &din4, &din5, &din6, &din7, &din8, &din9};
+gpioDigitalOutput* const d_out[] = {&dout1, &dout2, &dout3, &dout4, &dout5, &dout6, &dout7, &dout8, &dout9, &dout10, &dout11, &dout12, &dout13};
+// not yet used
+// gpioAnalogInput* a_in[A_IN_CHANNELS];
+// gpioAnalogOutput* a_out[A_OUT_CHANNELS];
+
+/************************************************************************************
+ **** CODE **************************************************************************
+ ************************************************************************************/
+/*
+ * gpio_reset() - reset inputs and outputs (no initialization)
+ */
+
+
+void outputs_reset(void) {
+ // nothing to do
+}
+
+void inputs_reset(void) {
+ // nothing to do
+}
diff --git a/g2core/board/ArduinoDue/board_gpio.h b/g2core/board/ArduinoDue/board_gpio.h
new file mode 100644
index 000000000..25a1cddcd
--- /dev/null
+++ b/g2core/board/ArduinoDue/board_gpio.h
@@ -0,0 +1,90 @@
+/*
+ * gpio.h - Digital IO handling functions
+ * This file is part of the g2core project
+ *
+ * Copyright (c) 2015 - 2017 Alden S. Hart, Jr.
+ * Copyright (c) 2015 - 2017 Robert Giseburt
+ *
+ * This file ("the software") is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2 as published by the
+ * Free Software Foundation. You should have received a copy of the GNU General Public
+ * License, version 2 along with the software. If not, see .
+ *
+ * As a special exception, you may use this file as part of a software library without
+ * restriction. Specifically, if other files instantiate templates or use macros or
+ * inline functions from this file, or you compile this file and link it with other
+ * files to produce an executable, this file does not by itself cause the resulting
+ * executable to be covered by the GNU General Public License. This exception does not
+ * however invalidate any other reasons why the executable file might be covered by the
+ * GNU General Public License.
+ *
+ * THE SOFTWARE IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY
+ * WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+ * SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef BOARD_GPIO_H_ONCE
+#define BOARD_GPIO_H_ONCE
+
+// this file is included from the bottom of gpio.h, but we do this for completeness
+#include "../../gpio.h"
+
+/*
+ * GPIO defines
+ */
+//--- change as required for board and switch hardware ---//
+
+#define D_IN_CHANNELS 9 // v9 // number of digital inputs supported
+#define D_OUT_CHANNELS 13 // number of digital outputs supported
+#define A_IN_CHANNELS 0 // number of analog inputs supported
+#define A_OUT_CHANNELS 0 // number of analog outputs supported
+
+#define INPUT_LOCKOUT_MS 10 // milliseconds to go dead after input firing
+
+/*
+ * The GPIO objects themselves - this must match up with board_gpio.cpp!
+ */
+
+extern gpioDigitalInput* const d_in[D_IN_CHANNELS];
+extern gpioDigitalOutput* const d_out[D_OUT_CHANNELS];
+// extern gpioAnalogInput* a_in[A_IN_CHANNELS];
+// extern gpioAnalogOutput* a_out[A_OUT_CHANNELS];
+
+// prepare the objects as externs (for config_app to not bloat)
+using Motate::IRQPin;
+using Motate::PWMOutputPin;
+using Motate::PWMLikeOutputPin;
+template
+using OutputType = typename std::conditional, PWMLikeOutputPin>::type;
+
+extern gpioDigitalInputPin> din1;
+extern gpioDigitalInputPin> din2;
+extern gpioDigitalInputPin> din3;
+extern gpioDigitalInputPin> din4;
+extern gpioDigitalInputPin> din5;
+extern gpioDigitalInputPin> din6;
+extern gpioDigitalInputPin> din7;
+extern gpioDigitalInputPin> din8;
+extern gpioDigitalInputPin> din9;
+// extern gpioDigitalInputPin> din10;
+// extern gpioDigitalInputPin> din11;
+// extern gpioDigitalInputPin> din12;
+
+extern gpioDigitalOutputPin> dout1;
+extern gpioDigitalOutputPin> dout2;
+extern gpioDigitalOutputPin> dout3;
+extern gpioDigitalOutputPin> dout4;
+extern gpioDigitalOutputPin> dout5;
+extern gpioDigitalOutputPin> dout6;
+extern gpioDigitalOutputPin> dout7;
+extern gpioDigitalOutputPin> dout8;
+extern gpioDigitalOutputPin> dout9;
+extern gpioDigitalOutputPin> dout10;
+extern gpioDigitalOutputPin> dout11;
+extern gpioDigitalOutputPin> dout12;
+extern gpioDigitalOutputPin> dout13;
+
+
+#endif // End of include guard: BOARD_GPIO_H_ONCE
diff --git a/g2core/board/ArduinoDue/board_xio.h b/g2core/board/ArduinoDue/board_xio.h
index 09f20fef8..ea0a3fa7b 100755
--- a/g2core/board/ArduinoDue/board_xio.h
+++ b/g2core/board/ArduinoDue/board_xio.h
@@ -37,10 +37,10 @@
#include "MotateUSBCDC.h"
#if USB_SERIAL_PORTS_EXPOSED == 1
-typedef Motate::USBDevice< Motate::USBCDC > XIOUSBDevice_t;
+typedef Motate::USBDevice< USBDeviceHardware, Motate::USBCDC > XIOUSBDevice_t;
#endif
#if USB_SERIAL_PORTS_EXPOSED == 2
-typedef Motate::USBDevice XIOUSBDevice_t;
+typedef Motate::USBDevice< USBDeviceHardware, Motate::USBCDC, Motate::USBCDC > XIOUSBDevice_t;
#endif
extern XIOUSBDevice_t usb;
diff --git a/g2core/board/ArduinoDue/gShield-pinout.h b/g2core/board/ArduinoDue/gShield-pinout.h
index 28267af27..0f82c4352 100644
--- a/g2core/board/ArduinoDue/gShield-pinout.h
+++ b/g2core/board/ArduinoDue/gShield-pinout.h
@@ -54,11 +54,6 @@
#define INPUT12_AVAILABLE 1
#define INPUT13_AVAILABLE 0
-#define ADC0_AVAILABLE 0
-#define ADC1_AVAILABLE 0
-#define ADC2_AVAILABLE 0
-#define ADC3_AVAILABLE 0
-
#define XIO_HAS_USB 1
#define XIO_HAS_UART 0
#define XIO_HAS_SPI 0
diff --git a/g2core/board/ArduinoDue/hardware.h b/g2core/board/ArduinoDue/hardware.h
index de822eadb..79a1ad29f 100644
--- a/g2core/board/ArduinoDue/hardware.h
+++ b/g2core/board/ArduinoDue/hardware.h
@@ -123,7 +123,6 @@ using Motate::OutputPin;
//#define FREQUENCY_DDA 200000UL // Hz step frequency. Interrupts actually fire at 2x (400 KHz)
#define FREQUENCY_DDA 150000UL // Hz step frequency. Interrupts actually fire at 2x (300 KHz)
#define FREQUENCY_DWELL 1000UL
-#define FREQUENCY_SGI 200000UL // 200,000 Hz means software interrupts will fire 5 uSec after being called
/**** Motate Definitions ****/
diff --git a/g2core/board/ArduinoDue/shopbotShield-pinout.h b/g2core/board/ArduinoDue/shopbotShield-pinout.h
index b9ba361ea..9b07c9bd3 100755
--- a/g2core/board/ArduinoDue/shopbotShield-pinout.h
+++ b/g2core/board/ArduinoDue/shopbotShield-pinout.h
@@ -47,11 +47,6 @@
#define INPUT12_AVAILABLE 0
#define INPUT13_AVAILABLE 0
-#define ADC0_AVAILABLE 0
-#define ADC1_AVAILABLE 0
-#define ADC2_AVAILABLE 0
-#define ADC3_AVAILABLE 0
-
#define XIO_HAS_USB 1
#define XIO_HAS_UART 0
#define XIO_HAS_SPI 0
diff --git a/g2core/board/G2v9/hardware.cpp b/g2core/board/G2v9/0_hardware.cpp
similarity index 100%
rename from g2core/board/G2v9/hardware.cpp
rename to g2core/board/G2v9/0_hardware.cpp
diff --git a/g2core/board/G2v9/G2v9k-pinout.h b/g2core/board/G2v9/G2v9k-pinout.h
index 71256d3f8..8c89cc8f9 100644
--- a/g2core/board/G2v9/G2v9k-pinout.h
+++ b/g2core/board/G2v9/G2v9k-pinout.h
@@ -81,11 +81,6 @@
#define INPUT12_AVAILABLE 0
#define INPUT13_AVAILABLE 0
-#define ADC0_AVAILABLE 1
-#define ADC1_AVAILABLE 1
-#define ADC2_AVAILABLE 0
-#define ADC3_AVAILABLE 0
-
#define XIO_HAS_USB 1
#define XIO_HAS_UART 0
#define XIO_HAS_SPI 0
@@ -165,8 +160,8 @@ _MAKE_MOTATE_PIN(kSocket1_Microstep_2PinNumber, 'B', 16); // Socket1_Microst
_MAKE_MOTATE_PIN(kSocket1_VrefPinNumber, 'B', 17); // Socket1_VrefPinNumber
_MAKE_MOTATE_PIN(kSocket2_VrefPinNumber, 'B', 18); // Socket2_VrefPinNumber
_MAKE_MOTATE_PIN(kSocket3_VrefPinNumber, 'B', 19); // Socket3_VrefPinNumber
-_MAKE_MOTATE_PIN(kADC0_PinNumber, 'B', 20); // Socket2_SPISlaveSelectPinNumber
-_MAKE_MOTATE_PIN(kADC1_PinNumber, 'B', 21); // Socket3_SPISlaveSelectPinNumber
+_MAKE_MOTATE_PIN(kADC1_PinNumber, 'B', 20); // Socket2_SPISlaveSelectPinNumber
+_MAKE_MOTATE_PIN(kADC2_PinNumber, 'B', 21); // Socket3_SPISlaveSelectPinNumber
_MAKE_MOTATE_PIN(kSocket4_EnablePinNumber, 'B', 22); // Socket4_EnablePinNumber
_MAKE_MOTATE_PIN(kSocket4_SPISlaveSelectPinNumber, 'B', 23); // Socket4_SPISlaveSelectPinNumber
_MAKE_MOTATE_PIN(kSocket4_DirPinNumber, 'B', 24); // Socket4_DirPinNumber
diff --git a/g2core/board/G2v9/board_gpio.cpp b/g2core/board/G2v9/board_gpio.cpp
new file mode 100644
index 000000000..4daf011d8
--- /dev/null
+++ b/g2core/board/G2v9/board_gpio.cpp
@@ -0,0 +1,108 @@
+/*
+ * gpio.cpp - digital IO handling functions
+ * This file is part of the g2core project
+ *
+ * Copyright (c) 2015 - 2107 Alden S. Hart, Jr.
+ * Copyright (c) 2015 - 2017 Robert Giseburt
+ *
+ * This file ("the software") is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2 as published by the
+ * Free Software Foundation. You should have received a copy of the GNU General Public
+ * License, version 2 along with the software. If not, see .
+ *
+ * As a special exception, you may use this file as part of a software library without
+ * restriction. Specifically, if other files instantiate templates or use macros or
+ * inline functions from this file, or you compile this file and link it with other
+ * files to produce an executable, this file does not by itself cause the resulting
+ * executable to be covered by the GNU General Public License. This exception does not
+ * however invalidate any other reasons why the executable file might be covered by the
+ * GNU General Public License.
+ *
+ * THE SOFTWARE IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY
+ * WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+ * SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* Switch Modes
+ *
+ * The switches are considered to be homing switches when cycle_state is
+ * CYCLE_HOMING. At all other times they are treated as limit switches:
+ * - Hitting a homing switch puts the current move into feedhold
+ * - Hitting a limit switch causes the machine to shut down and go into lockdown until reset
+ *
+ * The normally open switch modes (NO) trigger an interrupt on the falling edge
+ * and lockout subsequent interrupts for the defined lockout period. This approach
+ * beats doing debouncing as an integration as switches fire immediately.
+ *
+ * The normally closed switch modes (NC) trigger an interrupt on the rising edge
+ * and lockout subsequent interrupts for the defined lockout period. Ditto on the method.
+ */
+
+#include "../../g2core.h" // #1
+#include "config.h" // #2
+#include "gpio.h"
+#include "hardware.h"
+#include "canonical_machine.h"
+
+#include "text_parser.h"
+#include "controller.h"
+#include "util.h"
+#include "report.h"
+#include "xio.h"
+
+#include "MotateTimers.h"
+
+/**** Setup Actual Objects ****/
+
+gpioDigitalInputPin> din1 {DI1_MODE, 1};
+gpioDigitalInputPin> din2 {DI2_MODE, 2};
+gpioDigitalInputPin> din3 {DI3_MODE, 3};
+gpioDigitalInputPin> din4 {DI4_MODE, 4};
+gpioDigitalInputPin> din5 {DI5_MODE, 5};
+gpioDigitalInputPin> din6 {DI6_MODE, 6};
+gpioDigitalInputPin> din7 {DI7_MODE, 7};
+gpioDigitalInputPin> din8 {DI8_MODE, 8};
+gpioDigitalInputPin> din9 {DI9_MODE, 9};
+// gpioDigitalInputPin> din10 {DI10_MODE, 10};
+// gpioDigitalInputPin> din11 {DI11_MODE, 11};
+// gpioDigitalInputPin> din12 {DI12_MODE, 12};
+
+gpioDigitalOutputPin> dout1 { DO1_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout2 { DO2_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout3 { DO3_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout4 { DO4_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout5 { DO5_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout6 { DO6_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout7 { DO7_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout8 { DO8_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout9 { DO9_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout10 { DO10_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout11 { DO11_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout12 { DO12_MODE, (uint32_t)200000 };
+gpioDigitalOutputPin> dout13 { DO13_MODE, (uint32_t)200000 };
+
+/**** Setup Arrays - these are extern and MUST match the board_gpio.h ****/
+
+gpioDigitalInput* const d_in[] = {&din1, &din2, &din3, &din4, &din5, &din6, &din7, &din8, &din9};
+gpioDigitalOutput* const d_out[] = {&dout1, &dout2, &dout3, &dout4, &dout5, &dout6, &dout7, &dout8, &dout9, &dout10, &dout11, &dout12, &dout13};
+// not yet used
+// gpioAnalogInput* a_in[A_IN_CHANNELS];
+// gpioAnalogOutput* a_out[A_OUT_CHANNELS];
+
+/************************************************************************************
+ **** CODE **************************************************************************
+ ************************************************************************************/
+/*
+ * gpio_reset() - reset inputs and outputs (no initialization)
+ */
+
+
+void outputs_reset(void) {
+ // nothing to do
+}
+
+void inputs_reset(void) {
+ // nothing to do
+}
diff --git a/g2core/board/G2v9/board_gpio.h b/g2core/board/G2v9/board_gpio.h
new file mode 100644
index 000000000..25a1cddcd
--- /dev/null
+++ b/g2core/board/G2v9/board_gpio.h
@@ -0,0 +1,90 @@
+/*
+ * gpio.h - Digital IO handling functions
+ * This file is part of the g2core project
+ *
+ * Copyright (c) 2015 - 2017 Alden S. Hart, Jr.
+ * Copyright (c) 2015 - 2017 Robert Giseburt
+ *
+ * This file ("the software") is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2 as published by the
+ * Free Software Foundation. You should have received a copy of the GNU General Public
+ * License, version 2 along with the software. If not, see .
+ *
+ * As a special exception, you may use this file as part of a software library without
+ * restriction. Specifically, if other files instantiate templates or use macros or
+ * inline functions from this file, or you compile this file and link it with other
+ * files to produce an executable, this file does not by itself cause the resulting
+ * executable to be covered by the GNU General Public License. This exception does not
+ * however invalidate any other reasons why the executable file might be covered by the
+ * GNU General Public License.
+ *
+ * THE SOFTWARE IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY
+ * WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+ * SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef BOARD_GPIO_H_ONCE
+#define BOARD_GPIO_H_ONCE
+
+// this file is included from the bottom of gpio.h, but we do this for completeness
+#include "../../gpio.h"
+
+/*
+ * GPIO defines
+ */
+//--- change as required for board and switch hardware ---//
+
+#define D_IN_CHANNELS 9 // v9 // number of digital inputs supported
+#define D_OUT_CHANNELS 13 // number of digital outputs supported
+#define A_IN_CHANNELS 0 // number of analog inputs supported
+#define A_OUT_CHANNELS 0 // number of analog outputs supported
+
+#define INPUT_LOCKOUT_MS 10 // milliseconds to go dead after input firing
+
+/*
+ * The GPIO objects themselves - this must match up with board_gpio.cpp!
+ */
+
+extern gpioDigitalInput* const d_in[D_IN_CHANNELS];
+extern gpioDigitalOutput* const d_out[D_OUT_CHANNELS];
+// extern gpioAnalogInput* a_in[A_IN_CHANNELS];
+// extern gpioAnalogOutput* a_out[A_OUT_CHANNELS];
+
+// prepare the objects as externs (for config_app to not bloat)
+using Motate::IRQPin;
+using Motate::PWMOutputPin;
+using Motate::PWMLikeOutputPin;
+template
+using OutputType = typename std::conditional, PWMLikeOutputPin>::type;
+
+extern gpioDigitalInputPin> din1;
+extern gpioDigitalInputPin> din2;
+extern gpioDigitalInputPin> din3;
+extern gpioDigitalInputPin> din4;
+extern gpioDigitalInputPin> din5;
+extern gpioDigitalInputPin> din6;
+extern gpioDigitalInputPin> din7;
+extern gpioDigitalInputPin> din8;
+extern gpioDigitalInputPin> din9;
+// extern gpioDigitalInputPin> din10;
+// extern gpioDigitalInputPin> din11;
+// extern gpioDigitalInputPin> din12;
+
+extern gpioDigitalOutputPin> dout1;
+extern gpioDigitalOutputPin> dout2;
+extern gpioDigitalOutputPin> dout3;
+extern gpioDigitalOutputPin> dout4;
+extern gpioDigitalOutputPin> dout5;
+extern gpioDigitalOutputPin> dout6;
+extern gpioDigitalOutputPin> dout7;
+extern gpioDigitalOutputPin> dout8;
+extern gpioDigitalOutputPin> dout9;
+extern gpioDigitalOutputPin> dout10;
+extern gpioDigitalOutputPin> dout11;
+extern gpioDigitalOutputPin> dout12;
+extern gpioDigitalOutputPin> dout13;
+
+
+#endif // End of include guard: BOARD_GPIO_H_ONCE
diff --git a/g2core/board/G2v9/board_xio.h b/g2core/board/G2v9/board_xio.h
index 09f20fef8..ea0a3fa7b 100755
--- a/g2core/board/G2v9/board_xio.h
+++ b/g2core/board/G2v9/board_xio.h
@@ -37,10 +37,10 @@
#include "MotateUSBCDC.h"
#if USB_SERIAL_PORTS_EXPOSED == 1
-typedef Motate::USBDevice< Motate::USBCDC > XIOUSBDevice_t;
+typedef Motate::USBDevice< USBDeviceHardware, Motate::USBCDC > XIOUSBDevice_t;
#endif
#if USB_SERIAL_PORTS_EXPOSED == 2
-typedef Motate::USBDevice XIOUSBDevice_t;
+typedef Motate::USBDevice< USBDeviceHardware, Motate::USBCDC, Motate::USBCDC > XIOUSBDevice_t;
#endif
extern XIOUSBDevice_t usb;
diff --git a/g2core/board/G2v9/hardware.h b/g2core/board/G2v9/hardware.h
index ad586116f..5c3e77a8e 100644
--- a/g2core/board/G2v9/hardware.h
+++ b/g2core/board/G2v9/hardware.h
@@ -123,7 +123,6 @@ using Motate::OutputPin;
//#define FREQUENCY_DDA 200000UL // Hz step frequency. Interrupts actually fire at 2x (400 KHz)
#define FREQUENCY_DDA 150000UL // Hz step frequency. Interrupts actually fire at 2x (300 KHz)
#define FREQUENCY_DWELL 1000UL
-#define FREQUENCY_SGI 200000UL // 200,000 Hz means software interrupts will fire 5 uSec after being called
/**** Motate Definitions ****/
diff --git a/g2core/board/G2v9/motate_pin_assignments.h b/g2core/board/G2v9/motate_pin_assignments.h
index ff1adcd45..28091bc43 100644
--- a/g2core/board/G2v9/motate_pin_assignments.h
+++ b/g2core/board/G2v9/motate_pin_assignments.h
@@ -171,8 +171,10 @@ pin_number kGRBL_CommonEnablePinNumber = -1;
// g2ref extensions
// These first 5 may replace the Spindle and Coolant pins, above
-pin_number kOutput1_PinNumber = 130; // DO_1: Extruder1_PWM
-pin_number kOutput2_PinNumber = 131; // DO_2: Extruder2_PWM
+pin_number kHeaterOutput1_PinNumber = -1; // DO_1: Extruder1_PWM
+pin_number kHeaterOutput2_PinNumber = -1; // DO_2: Extruder2_PWM
+pin_number kOutput1_PinNumber = 130; // DO_1:
+pin_number kOutput2_PinNumber = 131; // DO_2:
pin_number kOutput3_PinNumber = 132; // DO_3: Fan1A_PWM
pin_number kOutput4_PinNumber = 133; // DO_4: Fan1B_PWM
pin_number kOutput5_PinNumber = 134; // DO_5: Fan2A_PWM
@@ -183,28 +185,29 @@ pin_number kOutput8_PinNumber = -1; // 137; // See Coolant Enable
pin_number kOutput9_PinNumber = 138; //
pin_number kOutput10_PinNumber = 139; // DO_10: Fan2B_PWM
-pin_number kOutput11_PinNumber = 140; // DO_11: Heated Bed FET
+pin_number kHeaterOutput11_PinNumber = -1; // DO_11: Heated Bed FET
+pin_number kOutput11_PinNumber = 140; // DO_11:
pin_number kOutput12_PinNumber = 141; // DO_12: Indicator_LED
pin_number kOutput13_PinNumber = -1; // 142;
pin_number kOutput14_PinNumber = -1; // 143;
pin_number kOutput15_PinNumber = -1; // 144;
pin_number kOutput16_PinNumber = -1; // 145;
-pin_number kADC0_PinNumber = 150; // Heated bed thermistor ADC
-pin_number kADC1_PinNumber = 151; // Extruder1_ADC
-pin_number kADC2_PinNumber = 152; // Extruder2_ADC
-pin_number kADC3_PinNumber = -1; // 153;
-pin_number kADC4_PinNumber = -1; // 154;
-pin_number kADC5_PinNumber = -1; // 155;
-pin_number kADC6_PinNumber = -1; // 156;
-pin_number kADC7_PinNumber = -1; // 157;
-pin_number kADC8_PinNumber = -1; // 158;
-pin_number kADC9_PinNumber = -1; // 159;
-pin_number kADC10_PinNumber = -1; // 160;
-pin_number kADC11_PinNumber = -1; // 161;
-pin_number kADC12_PinNumber = -1; // 162;
-pin_number kADC13_PinNumber = 163; // Not physially pinned out
-pin_number kADC14_PinNumber = 164; // Not physially pinned out
+pin_number kADC1_PinNumber = 150; // Heated bed thermistor ADC
+pin_number kADC2_PinNumber = 151; // Extruder1_ADC
+pin_number kADC3_PinNumber = 152; // Extruder2_ADC
+pin_number kADC4_PinNumber = -1; // 153;
+pin_number kADC5_PinNumber = -1; // 154;
+pin_number kADC6_PinNumber = -1; // 155;
+pin_number kADC7_PinNumber = -1; // 156;
+pin_number kADC8_PinNumber = -1; // 157;
+pin_number kADC9_PinNumber = -1; // 158;
+pin_number kADC10_PinNumber = -1; // 159;
+pin_number kADC11_PinNumber = -1; // 160;
+pin_number kADC12_PinNumber = -1; // 161;
+pin_number kADC13_PinNumber = -1; // 162;
+pin_number kADC14_PinNumber = 163; // Not physially pinned out
+pin_number kADC15_PinNumber = 164; // Not physially pinned out
// start next sequence at 170
diff --git a/g2core/board/g2_default.gdb b/g2core/board/g2_default.gdb
index dc505ef19..4f5064525 100644
--- a/g2core/board/g2_default.gdb
+++ b/g2core/board/g2_default.gdb
@@ -8,12 +8,15 @@ set history expansion on
set print pretty on
-monitor adapter_khz 5000
+# monitor adapter_khz 5000
-define reset
- boot_from_flash
- monitor reset init
-end
+#define reset
+# boot_from_flash
+# # for openocd
+# # monitor reset init
+# # for jlink
+# monitor reset
+#end
define flash
make
diff --git a/g2core/board/gquadratic.gdb b/g2core/board/gquadratic.gdb
index bd2e88282..2619f7e4a 100644
--- a/g2core/board/gquadratic.gdb
+++ b/g2core/board/gquadratic.gdb
@@ -1,12 +1,43 @@
# Open and connect to openocd with the ATMEL-ICE
-target remote | /usr/local/bin/openocd -c "set CHIPNAME ${CHIP}" -f ${MOTATE_PATH}/openocd.cfg -f ${MOTATE_PATH}/platform/atmel_sam/atmel_sam.cfg -c "gdb_port pipe; log_output openocd.log"
+#target remote | /usr/local/bin/openocd -c "set CHIPNAME ${CHIP}" -f ${MOTATE_PATH}/openocd.cfg -f ${MOTATE_PATH}/platform/atmel_sam/atmel_sam.cfg -c "gdb_port pipe; log_output openocd.log"
-monitor arm semihosting enable
+target extended-remote :2331
-source ./board/g2_default.gdb
+# Setup for non-wrapped lines and non-pages prints
+set width 0
+set height 0
+
+# Turn on history saving
+set history save on
+set history expansion on
+
+set print pretty on
+
+define reset_deep
+ monitor reset
+
+ # Reset peripheral (RSTC_CR)
+ set *0x400E1800 = 0xA5000004
+
+# # Initializing PC and stack pointer
+# mon reg sp = (0x20400000)
+# set *0x20400004 = *0x20400004 & 0xFFFFFFFE
+# mon reg pc=(0x20400004)
+ info reg
+end
+
+define flash
+ make
+ load
+ reset
+end
+
+define dump_mb
+ source ../Resources/debug/mb.gdb
+end
define boot_from_flash
- monitor atsamv gpnvm set 1
+ #monitor atsamv gpnvm set 1
end
source -s arm.gdb
diff --git a/g2core/board/gquadratic.mk b/g2core/board/gquadratic.mk
index 9527cdc11..35837519a 100755
--- a/g2core/board/gquadratic.mk
+++ b/g2core/board/gquadratic.mk
@@ -18,6 +18,12 @@ ifeq ("$(BOARD)","gquadratic-b")
DEVICE_DEFINES += SETTINGS_FILE=${SETTINGS_FILE}
endif
+ifeq ("$(BOARD)","gquadratic-c")
+ BASE_BOARD=gquadratic
+ DEVICE_DEFINES += MOTATE_BOARD="gquadratic-c"
+ DEVICE_DEFINES += SETTINGS_FILE=${SETTINGS_FILE}
+endif
+
##########
# The general gquadratic BASE_BOARD.
@@ -25,16 +31,16 @@ endif
ifeq ("$(BASE_BOARD)","gquadratic")
_BOARD_FOUND = 1
- DEVICE_DEFINES += MOTATE_CONFIG_HAS_USBSERIAL=0
+ DEVICE_DEFINES += MOTATE_CONFIG_HAS_USBSERIAL=1 ENABLE_TCM=1
- FIRST_LINK_SOURCES += $(sort $(wildcard ${MOTATE_PATH}/Atmel_sam_common/*.cpp)) $(sort $(wildcard ${MOTATE_PATH}/Atmel_sams70/*.cpp))
+ FIRST_LINK_SOURCES += $(sort $(wildcard ${MOTATE_PATH}/Atmel_sam_common/*.cpp)) $(sort $(wildcard ${MOTATE_PATH}/Atmel_sams70/*.cpp) $(wildcard ${BOARD_PATH}/*.cpp))
CHIP = SAMS70N19
export CHIP
CHIP_LOWERCASE = sams70n19
BOARD_PATH = ./board/gquadratic
- SOURCE_DIRS += ${BOARD_PATH} device/step_dir_driver device/step_dir_hobbyservo device/neopixel
+ SOURCE_DIRS += ${BOARD_PATH} device/trinamic device/step_dir_hobbyservo device/max31865 device/neopixel
PLATFORM_BASE = ${MOTATE_PATH}/platform/atmel_sam
include $(PLATFORM_BASE).mk
diff --git a/g2core/board/gquadratic/hardware.cpp b/g2core/board/gquadratic/0_hardware.cpp
similarity index 93%
rename from g2core/board/gquadratic/hardware.cpp
rename to g2core/board/gquadratic/0_hardware.cpp
index f40a7928a..465c7175d 100755
--- a/g2core/board/gquadratic/hardware.cpp
+++ b/g2core/board/gquadratic/0_hardware.cpp
@@ -39,6 +39,9 @@
//Motate::ClockOutputPin external_clk_pin {16000000}; // 16MHz optimally
//Motate::OutputPin external_clk_pin {Motate::kStartLow};
+#define EXPERIMENTAL_NEOPIXEL_SUPPORT 0
+
+#if EXPERIMENTAL_NEOPIXEL_SUPPORT == 1
#include "neopixel.h"
#include "canonical_machine.h"
@@ -68,6 +71,11 @@ namespace LEDs {
cmMachineState last_see_machine_state;
float old_x_pos = 0.0;
}
+#endif // EXPERIMENTAL_NEOPIXEL_SUPPORT
+
+#if QUADRATIC_REVISION == 'C'
+HOT_DATA SPIBus_used_t spiBus;
+#endif
/*
* hardware_init() - lowest level hardware init
@@ -78,11 +86,17 @@ void hardware_init()
board_hardware_init();
// external_clk_pin = 0; // Force external clock to 0 for now.
+#if QUADRATIC_REVISION == 'C'
+ spiBus.init();
+#endif
+
+#if EXPERIMENTAL_NEOPIXEL_SUPPORT == 1
for (uint8_t pixel = 0; pixel < LEDs::rgbw_leds.count; pixel++) {
LEDs::display_color[pixel].startTransition(100, 0, 0, 0);
LEDs::rgbw_leds.setPixel(pixel, LEDs::display_color[pixel]);
}
LEDs::rgbw_leds.update();
+#endif // EXPERIMENTAL_NEOPIXEL_SUPPORT
}
/*
@@ -91,14 +105,15 @@ void hardware_init()
stat_t hardware_periodic()
{
+#if EXPERIMENTAL_NEOPIXEL_SUPPORT == 1
float x_pos = cm_get_work_position(ACTIVE_MODEL, AXIS_X);
- if (fabs(LEDs::old_x_pos - x_pos) > 0.01) {
+ if (std::abs(LEDs::old_x_pos - x_pos) > 0.01) {
LEDs::old_x_pos = x_pos;
float led_pos = x_pos * ((float)(LEDs::rgbw_leds.count-1) / 40);
for (uint8_t pixel = 0; pixel < LEDs::rgbw_leds.count; pixel++) {
- float value = fabs(led_pos - (float)pixel);
+ float value = std::abs(led_pos - (float)pixel);
if (value < 1.001) {
value = 1.0 - value;
if (LEDs::display_color[pixel].red < value) {
@@ -120,6 +135,7 @@ stat_t hardware_periodic()
}
LEDs::rgbw_leds.update();
+#endif // EXPERIMENTAL_NEOPIXEL_SUPPORT
return STAT_OK;
}
diff --git a/g2core/board/gquadratic/board_gpio.cpp b/g2core/board/gquadratic/board_gpio.cpp
new file mode 100644
index 000000000..614f4e0e6
--- /dev/null
+++ b/g2core/board/gquadratic/board_gpio.cpp
@@ -0,0 +1,89 @@
+/*
+ * gpio.cpp - digital IO handling functions
+ * This file is part of the g2core project
+ *
+ * Copyright (c) 2015 - 2107 Alden S. Hart, Jr.
+ * Copyright (c) 2015 - 2017 Robert Giseburt
+ *
+ * This file ("the software") is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2 as published by the
+ * Free Software Foundation. You should have received a copy of the GNU General Public
+ * License, version 2 along with the software. If not, see .
+ *
+ * As a special exception, you may use this file as part of a software library without
+ * restriction. Specifically, if other files instantiate templates or use macros or
+ * inline functions from this file, or you compile this file and link it with other
+ * files to produce an executable, this file does not by itself cause the resulting
+ * executable to be covered by the GNU General Public License. This exception does not
+ * however invalidate any other reasons why the executable file might be covered by the
+ * GNU General Public License.
+ *
+ * THE SOFTWARE IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY
+ * WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+ * SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* Switch Modes
+ *
+ * The switches are considered to be homing switches when cycle_state is
+ * CYCLE_HOMING. At all other times they are treated as limit switches:
+ * - Hitting a homing switch puts the current move into feedhold
+ * - Hitting a limit switch causes the machine to shut down and go into lockdown until reset
+ *
+ * The normally open switch modes (NO) trigger an interrupt on the falling edge
+ * and lockout subsequent interrupts for the defined lockout period. This approach
+ * beats doing debouncing as an integration as switches fire immediately.
+ *
+ * The normally closed switch modes (NC) trigger an interrupt on the rising edge
+ * and lockout subsequent interrupts for the defined lockout period. Ditto on the method.
+ */
+
+#include "../../g2core.h" // #1
+#include "config.h" // #2
+#include "gpio.h"
+#include "hardware.h"
+#include "canonical_machine.h"
+
+#include "text_parser.h"
+#include "controller.h"
+#include "util.h"
+#include "report.h"
+#include "xio.h"
+
+#include "MotateTimers.h"
+
+/**** Setup Actual Objects ****/
+
+gpioDigitalInputPin> din1 {DI1_ENABLED, DI1_POLARITY, 1, DI1_EXTERNAL_NUMBER};
+gpioDigitalInputPin> din2 {DI2_ENABLED, DI2_POLARITY, 2, DI2_EXTERNAL_NUMBER};
+gpioDigitalInputPin> din3 {DI3_ENABLED, DI3_POLARITY, 3, DI3_EXTERNAL_NUMBER};
+gpioDigitalInputPin> din4 {DI4_ENABLED, DI4_POLARITY, 4, DI4_EXTERNAL_NUMBER};
+
+gpioDigitalOutputPin> dout1 { DO1_ENABLED, DO1_POLARITY, DO1_EXTERNAL_NUMBER, (uint32_t)200000 };
+gpioDigitalOutputPin> dout2 { DO2_ENABLED, DO2_POLARITY, DO2_EXTERNAL_NUMBER, (uint32_t)200000 };
+
+/**** Setup Arrays - these are extern and MUST match the board_gpio.h ****/
+
+gpioDigitalInput* const d_in[] = {&din1, &din2, &din3, &din4};
+gpioDigitalOutput* const d_out[] = {&dout1, &dout2};
+// not yet used
+// gpioAnalogInput* a_in[A_IN_CHANNELS];
+// gpioAnalogOutput* a_out[A_OUT_CHANNELS];
+
+/************************************************************************************
+ **** CODE **************************************************************************
+ ************************************************************************************/
+/*
+ * gpio_reset() - reset inputs and outputs (no initialization)
+ */
+
+
+void outputs_reset(void) {
+ // nothing to do
+}
+
+void inputs_reset(void) {
+ // nothing to do
+}
diff --git a/g2core/board/gquadratic/board_gpio.h b/g2core/board/gquadratic/board_gpio.h
new file mode 100644
index 000000000..c596fc545
--- /dev/null
+++ b/g2core/board/gquadratic/board_gpio.h
@@ -0,0 +1,71 @@
+/*
+ * gpio.h - Digital IO handling functions
+ * This file is part of the g2core project
+ *
+ * Copyright (c) 2015 - 2017 Alden S. Hart, Jr.
+ * Copyright (c) 2015 - 2017 Robert Giseburt
+ *
+ * This file ("the software") is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2 as published by the
+ * Free Software Foundation. You should have received a copy of the GNU General Public
+ * License, version 2 along with the software. If not, see .
+ *
+ * As a special exception, you may use this file as part of a software library without
+ * restriction. Specifically, if other files instantiate templates or use macros or
+ * inline functions from this file, or you compile this file and link it with other
+ * files to produce an executable, this file does not by itself cause the resulting
+ * executable to be covered by the GNU General Public License. This exception does not
+ * however invalidate any other reasons why the executable file might be covered by the
+ * GNU General Public License.
+ *
+ * THE SOFTWARE IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY
+ * WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+ * SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef BOARD_GPIO_H_ONCE
+#define BOARD_GPIO_H_ONCE
+
+// this file is included from the bottom of gpio.h, but we do this for completeness
+#include "../../gpio.h"
+
+/*
+ * GPIO defines
+ */
+//--- change as required for board and switch hardware ---//
+
+#define D_IN_CHANNELS 4 // number of digital inputs supported
+#define D_OUT_CHANNELS 2 // number of digital outputs supported
+#define A_IN_CHANNELS 0 // number of analog inputs supported
+#define A_OUT_CHANNELS 0 // number of analog outputs supported
+
+#define INPUT_LOCKOUT_MS 10 // milliseconds to go dead after input firing
+
+/*
+ * The GPIO objects themselves - this must match up with board_gpio.cpp!
+ */
+
+extern gpioDigitalInput* const d_in[D_IN_CHANNELS];
+extern gpioDigitalOutput* const d_out[D_OUT_CHANNELS];
+// extern gpioAnalogInput* a_in[A_IN_CHANNELS];
+// extern gpioAnalogOutput* a_out[A_OUT_CHANNELS];
+
+// prepare the objects as externs (for config_app to not bloat)
+using Motate::IRQPin;
+using Motate::PWMOutputPin;
+using Motate::PWMLikeOutputPin;
+template
+using OutputType = typename std::conditional, PWMLikeOutputPin>::type;
+
+extern gpioDigitalInputPin> din1;
+extern gpioDigitalInputPin> din2;
+extern gpioDigitalInputPin> din3;
+extern gpioDigitalInputPin> din4;
+
+extern gpioDigitalOutputPin> dout1;
+extern gpioDigitalOutputPin> dout2;
+
+
+#endif // End of include guard: BOARD_GPIO_H_ONCE
diff --git a/g2core/board/gquadratic/board_stepper.cpp b/g2core/board/gquadratic/board_stepper.cpp
index bc927558a..cfe461447 100755
--- a/g2core/board/gquadratic/board_stepper.cpp
+++ b/g2core/board/gquadratic/board_stepper.cpp
@@ -2,8 +2,8 @@
* board_stepper.cpp - board-specific code for stepper.cpp
* This file is part of the g2core project
*
- * Copyright (c) 2016 Alden S. Hart, Jr.
- * Copyright (c) 2016 Robert Giseburt
+ * Copyright (c) 2016-2018 Alden S. Hart, Jr.
+ * Copyright (c) 2016-2018 Robert Giseburt
*
* This file ("the software") is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 as published by the
@@ -29,54 +29,48 @@
#include "board_stepper.h"
// These are identical to board_stepper.h, except for the word "extern"
-StepDirStepper
- motor_1{};
+ motor_1 {};
-StepDirStepper
- motor_2{};
+ motor_2 {};
+#endif // QUADRATIC_REVISION == 'B'
-StepDirHobbyServo motor_3;
+#if QUADRATIC_REVISION == 'C'
+#warning setting up trinamics
+// Motate::SPIChipSelectPin motor_1_cs;
+HOT_DATA Trinamic2130
+ motor_1 {spiBus, Motate::SPIChipSelectPin{}};
-// StepDirStepper<
-// Motate::kSocket4_StepPinNumber,
-// Motate::kSocket4_DirPinNumber,
-// Motate::kSocket4_EnablePinNumber,
-// Motate::kSocket4_Microstep_0PinNumber,
-// Motate::kSocket4_Microstep_1PinNumber,
-// Motate::kSocket4_Microstep_2PinNumber,
-// Motate::kSocket4_VrefPinNumber> motor_4 {};
-//
-// StepDirStepper<
-// Motate::kSocket5_StepPinNumber,
-// Motate::kSocket5_DirPinNumber,
-// Motate::kSocket5_EnablePinNumber,
-// Motate::kSocket5_Microstep_0PinNumber,
-// Motate::kSocket5_Microstep_1PinNumber,
-// Motate::kSocket5_Microstep_2PinNumber,
-// Motate::kSocket5_VrefPinNumber> motor_5 {};
+// Motate::SPIChipSelectPin motor_2_cs;
+HOT_DATA Trinamic2130
+ motor_2 {spiBus, Motate::SPIChipSelectPin{}};
+#endif // QUADRATIC_REVISION == 'C'
-// StepDirStepper<
-// Motate::kSocket6_StepPinNumber,
-// Motate::kSocket6_DirPinNumber,
-// Motate::kSocket6_EnablePinNumber,
-// Motate::kSocket6_Microstep_0PinNumber,
-// Motate::kSocket6_Microstep_1PinNumber,
-// Motate::kSocket6_Microstep_2PinNumber,
-// Motate::kSocket6_VrefPinNumber> motor_6 {};
-Stepper* Motors[MOTORS] = {&motor_1, &motor_2, &motor_3};
+HOT_DATA StepDirHobbyServo motor_3;
+
+
+Stepper* const Motors[MOTORS] = {&motor_1, &motor_2, &motor_3};
void board_stepper_init() {
for (uint8_t motor = 0; motor < MOTORS; motor++) { Motors[motor]->init(); }
diff --git a/g2core/board/gquadratic/board_stepper.h b/g2core/board/gquadratic/board_stepper.h
index 6e044efa3..8072ff338 100755
--- a/g2core/board/gquadratic/board_stepper.h
+++ b/g2core/board/gquadratic/board_stepper.h
@@ -29,9 +29,9 @@
#define BOARD_STEPPER_H_ONCE
#include "hardware.h" // for MOTORS
-#include "step_dir_driver.h"
-#include "step_dir_hobbyservo.h"
+#if QUADRATIC_REVISION == 'B'
+#include "step_dir_driver.h"
extern StepDirStepper
motor_2;
+#endif // QUADRATIC_REVISION == 'B'
- extern StepDirHobbyServo motor_3;
+#if QUADRATIC_REVISION == 'C'
+#include "tmc2130.h"
+extern Trinamic2130
+ motor_1;
+extern Trinamic2130
+ motor_2;
+#endif // QUADRATIC_REVISION == 'C'
-// extern StepDirStepper<
-// Motate::kSocket5_StepPinNumber,
-// Motate::kSocket5_DirPinNumber,
-// Motate::kSocket5_EnablePinNumber,
-// Motate::kSocket5_Microstep_0PinNumber,
-// Motate::kSocket5_Microstep_1PinNumber,
-// Motate::kSocket5_Microstep_2PinNumber,
-// Motate::kSocket5_VrefPinNumber> motor_5;
-//
-// extern StepDirStepper<
-// Motate::kSocket6_StepPinNumber,
-// Motate::kSocket6_DirPinNumber,
-// Motate::kSocket6_EnablePinNumber,
-// Motate::kSocket6_Microstep_0PinNumber,
-// Motate::kSocket6_Microstep_1PinNumber,
-// Motate::kSocket6_Microstep_2PinNumber,
-// Motate::kSocket6_VrefPinNumber> motor_6 {};
+#include "step_dir_hobbyservo.h"
+extern StepDirHobbyServo motor_3;
-extern Stepper* Motors[MOTORS];
+extern Stepper* const Motors[MOTORS];
void board_stepper_init();
diff --git a/g2core/board/gquadratic/board_xio.cpp b/g2core/board/gquadratic/board_xio.cpp
index c48356be1..d05ce1ff8 100755
--- a/g2core/board/gquadratic/board_xio.cpp
+++ b/g2core/board/gquadratic/board_xio.cpp
@@ -71,6 +71,7 @@ void board_hardware_init(void) // called 1st
#if XIO_HAS_USB
// Init USB
usb.attach();
+ usb.handleVbusChange(/*force:*/ true);
#endif // XIO_HAS_USB
}
diff --git a/g2core/board/gquadratic/board_xio.h b/g2core/board/gquadratic/board_xio.h
index 09f20fef8..659f68a4a 100755
--- a/g2core/board/gquadratic/board_xio.h
+++ b/g2core/board/gquadratic/board_xio.h
@@ -36,11 +36,13 @@
#include "MotateUSB.h"
#include "MotateUSBCDC.h"
+typedef Motate::USBDeviceHardwareVBus> USBDeviceHardware_t;
+
#if USB_SERIAL_PORTS_EXPOSED == 1
-typedef Motate::USBDevice< Motate::USBCDC > XIOUSBDevice_t;
+typedef Motate::USBDevice< USBDeviceHardware_t, Motate::USBCDC > XIOUSBDevice_t;
#endif
#if USB_SERIAL_PORTS_EXPOSED == 2
-typedef Motate::USBDevice XIOUSBDevice_t;
+typedef Motate::USBDevice< USBDeviceHardware_t, Motate::USBCDC, Motate::USBCDC > XIOUSBDevice_t;
#endif
extern XIOUSBDevice_t usb;
diff --git a/g2core/board/gquadratic/gquadratic-b-pinout.h b/g2core/board/gquadratic/gquadratic-b-pinout.h
index 0eaa3c5d2..7eb8946bb 100755
--- a/g2core/board/gquadratic/gquadratic-b-pinout.h
+++ b/g2core/board/gquadratic/gquadratic-b-pinout.h
@@ -2,8 +2,8 @@
* gquadratic-b-pinout.h - board pinout specification
* This file is part of the g2core project
*
- * Copyright (c) 2016 Robert Giseburt
- * Copyright (c) 2016 Alden S. Hart Jr.
+ * Copyright (c) 2016-2018 Robert Giseburt
+ * Copyright (c) 2016-2018 Alden S. Hart Jr.
*
* This file is part of the Motate Library.
*
@@ -83,12 +83,6 @@
#define INPUT12_AVAILABLE 0
#define INPUT13_AVAILABLE 0
-
-#define ADC0_AVAILABLE 0
-#define ADC1_AVAILABLE 0
-#define ADC2_AVAILABLE 0
-#define ADC3_AVAILABLE 0
-
#define XIO_HAS_USB 1
#define XIO_HAS_UART 1
#define XIO_HAS_SPI 0
@@ -114,6 +108,8 @@
#define OUTPUT12_PWM 0 // Unused
#define OUTPUT13_PWM 0 // Unused
+#define QUADRATIC_REVISION 'B'
+
namespace Motate {
// Arduino pin name & function
diff --git a/g2core/board/gquadratic/gquadratic-c-pinout.h b/g2core/board/gquadratic/gquadratic-c-pinout.h
new file mode 100644
index 000000000..8c77c9d35
--- /dev/null
+++ b/g2core/board/gquadratic/gquadratic-c-pinout.h
@@ -0,0 +1,205 @@
+/*
+ * gquadratic-c-pinout.h - board pinout specification
+ * This file is part of the g2core project
+ *
+ * Copyright (c) 2018 Robert Giseburt
+ * Copyright (c) 2018 Alden S. Hart Jr.
+ *
+ * This file is part of the Motate Library.
+ *
+ * This file ("the software") is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2 as published by the
+ * Free Software Foundation. You should have received a copy of the GNU General Public
+ * License, version 2 along with the software. If not, see .
+ *
+ * As a special exception, you may use this file as part of a software library without
+ * restriction. Specifically, if other files instantiate templates or use macros or
+ * inline functions from this file, or you compile this file and link it with other
+ * files to produce an executable, this file does not by itself cause the resulting
+ * executable to be covered by the GNU General Public License. This exception does not
+ * however invalidate any other reasons why the executable file might be covered by the
+ * GNU General Public License.
+ *
+ * THE SOFTWARE IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY
+ * WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+ * SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef GQUADRATIC_C_PINOUT_H
+#define GQUADRATIC_C_PINOUT_H
+
+/*
+ * USAGE NOTES
+ *
+ * Read this first:
+ * https://github.com/synthetos/g2/wiki/Adding-a-new-G2-board-(or-revision)-to-G2#making-a-new-pin-assignment
+ *
+ * USAGE:
+ *
+ * This file is lays out all the pin capabilities of the SAM3X8C organized by pin number.
+ * Each pin has its associated functions listed at the bottom of the file, and is essentially
+ * immutable for each processor.
+ *
+ * To use, assign Motate pin numbers to the first value in the _MAKE_MOTATE_PIN() macro.
+ * ALL PINS MUST BE ASSIGNED A NUMBER, even if they are not used. There will NOT be a
+ * code-size or speed penalty for unused pins, but the WILL be a compiler-failure for
+ * unassigned pins. This new restriction allows for simplification of linkages deep in
+ * Motate.
+ */
+/* See motate_pin_assignments.h for pin names to be used int he rest of the G2 code.
+ * EXAMPLES:
+ *
+ * *** Vanilla pin example ***
+ *
+ * _MAKE_MOTATE_PIN(4, A, 'A', 27); // SPI0_SCKPinNumber
+ *
+ * This assigns Motate pin 4 to Port A, pin 27 (A27)
+ * Look in motate_pin_assignments.h to see that this is kSPI_SCKPinNumber
+ *
+ * ** Other pin functions ***
+ *
+ * Please look in /platform/atmel_sam/motate_chip_pin_functions.h
+ */
+
+
+#include
+
+// We don't have all of the inputs, so we have to indicate as much:
+#define INPUT1_AVAILABLE 1
+#define INPUT2_AVAILABLE 1
+#define INPUT3_AVAILABLE 1
+#define INPUT4_AVAILABLE 1
+#define INPUT5_AVAILABLE 0
+#define INPUT6_AVAILABLE 0
+#define INPUT7_AVAILABLE 0
+#define INPUT8_AVAILABLE 0
+#define INPUT9_AVAILABLE 0
+#define INPUT10_AVAILABLE 0
+#define INPUT11_AVAILABLE 0
+#define INPUT12_AVAILABLE 0
+#define INPUT13_AVAILABLE 0
+
+#define XIO_HAS_USB 1
+#define XIO_HAS_UART 1
+#define XIO_HAS_SPI 0
+#define XIO_HAS_I2C 0
+
+#define TEMPERATURE_OUTPUT_ON 0 // NO ADC yet
+
+// Some pins, if the PWM capability is turned on, it will cause timer conflicts.
+// So we have to explicitly enable them as PWM pins.
+// Generated with:
+// perl -e 'for($i=1;$i<14;$i++) { print "#define OUTPUT${i}_PWM 0\n";}'
+#define OUTPUT1_PWM 1 // TC0.0
+#define OUTPUT2_PWM 1 // PWM0.0
+#define OUTPUT3_PWM 1 // TC0.1
+#define OUTPUT4_PWM 1 // PWM1.3
+#define OUTPUT5_PWM 0 // unused
+#define OUTPUT6_PWM 0 // unused
+#define OUTPUT7_PWM 0 // unused
+#define OUTPUT8_PWM 0 // unused
+#define OUTPUT9_PWM 0 // unused
+#define OUTPUT10_PWM 0 // unused
+#define OUTPUT11_PWM 0 // unused
+#define OUTPUT12_PWM 0 // Unused
+#define OUTPUT13_PWM 0 // Unused
+
+#define QUADRATIC_REVISION 'C'
+
+namespace Motate {
+
+// Arduino pin name & function
+_MAKE_MOTATE_PIN(kOutput1_PinNumber, 'A', 0); // TC0.0 or PWM0
+_MAKE_MOTATE_PIN(kOutput2_PinNumber, 'A', 1); // TC0.1 or PWM1
+_MAKE_MOTATE_PIN(kUnassigned1, 'A', 2); // PWM1
+_MAKE_MOTATE_PIN(kI2C1_SDAPinNumber, 'A', 3); //
+_MAKE_MOTATE_PIN(kI2C1_SCLPinNumber, 'A', 4); //
+_MAKE_MOTATE_PIN(kSocket2_StepPinNumber, 'A', 5); //
+_MAKE_MOTATE_PIN(kUnassigned2, 'A', 6); // Missing in 100-pin package
+_MAKE_MOTATE_PIN(kUnassigned3, 'A', 7); //
+_MAKE_MOTATE_PIN(kUnassigned4, 'A', 8); //
+_MAKE_MOTATE_PIN(kSerial_RXPinNumber, 'A', 9); //
+_MAKE_MOTATE_PIN(kSerial_TXPinNumber, 'A', 10); //
+_MAKE_MOTATE_PIN(kSocket1_StepPinNumber, 'A', 11); //
+_MAKE_MOTATE_PIN(kUnassigned5, 'A', 12); //
+_MAKE_MOTATE_PIN(kUnassigned6, 'A', 13); //
+_MAKE_MOTATE_PIN(kUnassigned7, 'A', 14); //
+_MAKE_MOTATE_PIN(kUnassigned8, 'A', 15); //
+_MAKE_MOTATE_PIN(kUnassigned9, 'A', 16); //
+_MAKE_MOTATE_PIN(kUnassigned10, 'A', 17); //
+_MAKE_MOTATE_PIN(kUnassigned11, 'A', 18); //
+_MAKE_MOTATE_PIN(kUnassigned12, 'A', 19); //
+_MAKE_MOTATE_PIN(kUnassigned13, 'A', 20); //
+_MAKE_MOTATE_PIN(kUnassigned14, 'A', 21); //
+_MAKE_MOTATE_PIN(kUnassigned15, 'A', 22); //
+_MAKE_MOTATE_PIN(kUnassigned16, 'A', 23); //
+_MAKE_MOTATE_PIN(kInput5_PinNumber, 'A', 24); // DIAG0
+_MAKE_MOTATE_PIN(kUnassigned17, 'A', 25); //
+_MAKE_MOTATE_PIN(kSocket1_DirPinNumber, 'A', 26); //
+_MAKE_MOTATE_PIN(kSocket2_EnablePinNumber, 'A', 27); // TC2.1
+_MAKE_MOTATE_PIN(kSerial_CTSPinNumber, 'A', 28); //
+_MAKE_MOTATE_PIN(kUnassigned18, 'A', 29); // Missing in 100-pin package
+_MAKE_MOTATE_PIN(kServo1_PinNumber, 'A', 30); // PWM2 - kOutput4_PinNumber
+_MAKE_MOTATE_PIN(kInput4_PinNumber, 'A', 31); //
+
+_MAKE_MOTATE_PIN(kUnassigned19, 'B', 0); //
+_MAKE_MOTATE_PIN(kUnassigned20, 'B', 1); //
+_MAKE_MOTATE_PIN(kSocket3_SPISlaveSelectPinNumber, 'B', 2); //
+_MAKE_MOTATE_PIN(kUnassigned21, 'B', 3); //
+//_MAKE_MOTATE_PIN( , 'B', 4); // TDI
+//_MAKE_MOTATE_PIN( , 'B', 5); // TRACESDO
+//_MAKE_MOTATE_PIN( , 'B', 6); // SWDIO
+//_MAKE_MOTATE_PIN( , 'B', 7); // SWDCLK
+//_MAKE_MOTATE_PIN( , 'B', 8); // XOUT
+//_MAKE_MOTATE_PIN( , 'B', 9); // XIN
+//_MAKE_MOTATE_PIN( , 'B', 10); // USB_D-
+//_MAKE_MOTATE_PIN( , 'B', 11); // USB_D+
+//_MAKE_MOTATE_PIN( , 'B', 12); // ERASE
+_MAKE_MOTATE_PIN(kUnassigned22, 'B', 13); //
+
+_MAKE_MOTATE_PIN(kUSBVBUS_PinNumber, 'D', 0); // USB_VBUS
+_MAKE_MOTATE_PIN(kInput1_PinNumber, 'D', 1); //
+_MAKE_MOTATE_PIN(kInput2_PinNumber, 'D', 2); //
+_MAKE_MOTATE_PIN(kUnassigned23, 'D', 3); //
+_MAKE_MOTATE_PIN(kUnassigned24, 'D', 4); //
+_MAKE_MOTATE_PIN(kUnassigned25, 'D', 5); //
+_MAKE_MOTATE_PIN(kInput3_PinNumber, 'D', 6); //
+_MAKE_MOTATE_PIN(kSerial_RTSPinNumber, 'D', 7); //
+_MAKE_MOTATE_PIN(kOutput5_PinNumber, 'D', 8); // INTERRUPT_OUT
+_MAKE_MOTATE_PIN(kUnassigned26, 'D', 9); //
+_MAKE_MOTATE_PIN(kUnassigned27, 'D', 10); //
+_MAKE_MOTATE_PIN(kLED_RGBWPixelPinNumber, 'D', 11); // PWM0 - kOutput3_PinNumber
+_MAKE_MOTATE_PIN(kSocket4_SPISlaveSelectPinNumber, 'D', 12); //
+_MAKE_MOTATE_PIN(kUnassigned28, 'D', 13); //
+_MAKE_MOTATE_PIN(kUnassigned29, 'D', 14); //
+_MAKE_MOTATE_PIN(kOutputSAFE_PinNumber, 'D', 15); //
+_MAKE_MOTATE_PIN(kUnassigned30, 'D', 16); //
+_MAKE_MOTATE_PIN(kUnassigned31, 'D', 17); //
+_MAKE_MOTATE_PIN(kUnassigned32, 'D', 18); //
+_MAKE_MOTATE_PIN(kUnassigned33, 'D', 19); //
+_MAKE_MOTATE_PIN(kSPI0_MISOPinNumber, 'D', 20); //
+_MAKE_MOTATE_PIN(kSPI0_MOSIPinNumber, 'D', 21); //
+_MAKE_MOTATE_PIN(kSPI0_SCKPinNumber, 'D', 22); //
+_MAKE_MOTATE_PIN(kUnassigned34, 'D', 23); // Missing in 100-pin package
+_MAKE_MOTATE_PIN(kInput6_PinNumber, 'D', 24); // DIAG1
+_MAKE_MOTATE_PIN(kSocket1_SPISlaveSelectPinNumber, 'D', 25); //
+_MAKE_MOTATE_PIN(kSocket1_EnablePinNumber, 'D', 26); //
+_MAKE_MOTATE_PIN(kSocket2_SPISlaveSelectPinNumber, 'D', 27); //
+_MAKE_MOTATE_PIN(kSocket2_DirPinNumber, 'D', 28); //
+_MAKE_MOTATE_PIN(kUnassigned35, 'D', 29); // Missing in 100-pin package
+_MAKE_MOTATE_PIN(kLEDPWM_PinNumber, 'D', 30); //
+_MAKE_MOTATE_PIN(kUnassigned36, 'D', 31); //
+
+} // namespace Motate
+
+// We then allow each chip-type to have it's onw function definitions
+// that will refer to these pin assignments.
+#include "motate_chip_pin_functions.h"
+
+#endif
+
+// GQUADRATIC_C_PINOUT_H
diff --git a/g2core/board/gquadratic/hardware.h b/g2core/board/gquadratic/hardware.h
index 82abb8bc0..827346fb4 100644
--- a/g2core/board/gquadratic/hardware.h
+++ b/g2core/board/gquadratic/hardware.h
@@ -29,6 +29,7 @@
*/
#include "config.h"
+#include "settings.h"
#include "error.h"
#ifndef HARDWARE_H_ONCE
@@ -58,7 +59,7 @@ enum hwPlatform {
#define AXES 6 // number of axes supported in this version
#define HOMING_AXES 4 // number of axes that can be homed (assumes Zxyabc sequence)
-#define MOTORS 2 // number of motors on the board
+#define MOTORS 3 // number of motors on the board
#define COORDS 6 // number of supported coordinate systems (index starts at 1)
#define PWMS 2 // number of supported PWM channels
#define TOOLS 32 // number of entries in tool table (index starts at 1)
@@ -70,6 +71,11 @@ enum hwPlatform {
// ARM specific code start here
#include "MotatePins.h"
+#if QUADRATIC_REVISION == 'C'
+#define MOTOR_1_IS_TRINAMIC
+#define MOTOR_2_IS_TRINAMIC
+#include "MotateSPI.h"
+#endif
#include "MotateTimers.h" // for TimerChanel<> and related...
#include "MotateServiceCall.h" // for ServiceCall<>
@@ -89,63 +95,38 @@ using Motate::OutputPin;
#define SYS_ID_DIGITS 12 // actual digits in system ID (up to 16)
#define SYS_ID_LEN 24 // total length including dashes and NUL
-/************************************************************************************
- **** ARM SAM3X8E SPECIFIC HARDWARE *************************************************
- ************************************************************************************/
-
-/**** Resource Assignment via Motate ****
- *
- * This section defines resource usage for pins, timers, PWM channels, communications
- * and other resources. Please refer to /motate/utility/SamPins.h, SamTimers.h and
- * other files for pinouts and other configuration details.
- *
- * Commenting out or #ifdef'ing out definitions below will cause the compiler to
- * drop references to these resources from the compiled code. This will reduce
- * compiled code size and runtime CPU cycles. E.g. if you are compiling for a 3 motor,
- * XYZ axis config commenting out the higher motors and axes here will remove them
- * from later code (using the motate .isNull() test).
- */
-
-/* Interrupt usage and priority
- *
- * The following interrupts are defined w/indicated priorities
- *
- * 0 DDA_TIMER (9) for step pulse generation
- * 1 DWELL_TIMER (10) for dwell timing
- * 2 LOADER software generated interrupt (STIR / SGI)
- * 3 Serial read character interrupt
- * 4 EXEC software generated interrupt (STIR / SGI)
- * 5 Serial write character interrupt
- */
-
/**** Stepper DDA and dwell timer settings ****/
//#define FREQUENCY_DDA 200000UL // Hz step frequency. Interrupts actually fire at 2x (400 KHz)
-#define FREQUENCY_DDA 150000UL // Hz step frequency. Interrupts actually fire at 2x (300 KHz)
+#define FREQUENCY_DDA 400000UL // Hz step frequency. Interrupts actually fire at 2x (300 KHz)
#define FREQUENCY_DWELL 1000UL
-#define FREQUENCY_SGI 200000UL // 200,000 Hz means software interrupts will fire 5 uSec after being called
+
+#define MIN_SEGMENT_MS ((float)0.125) // S70 can handle much much smaller segements
+
+#define PLANNER_BUFFER_POOL_SIZE (60)
/**** Motate Definitions ****/
// Timer definitions. See stepper.h and other headers for setup
-typedef TimerChannel<9, 0> dda_timer_type; // stepper pulse generation in stepper.cpp
-typedef TimerChannel<10, 0> load_timer_type; // request load timer in stepper.cpp
-typedef ServiceCall<1> exec_timer_type; // request exec timer in stepper.cpp
-typedef ServiceCall<2> fwd_plan_timer_type; // request exec timer in stepper.cpp
+typedef TimerChannel<9, 0> dda_timer_type; // stepper pulse generation in stepper.cpp
+typedef TimerChannel<10, 0> exec_timer_type; // request exec timer in stepper.cpp
+typedef TimerChannel<11, 0> fwd_plan_timer_type; // request exec timer in stepper.cpp
// Pin assignments
-
pin_number indicator_led_pin_num = Motate::kLEDPWM_PinNumber;
static OutputPin IndicatorLed;
+/**** SPI Setup ****/
+#if QUADRATIC_REVISION == 'C'
+Motate::service_call_number kSPI_ServiceCallNumber = 3;
+
+typedef Motate::SPIBus SPIBus_used_t;
+extern SPIBus_used_t spiBus;
+
+#endif
+
/**** Motate Global Pin Allocations ****/
-// static OutputPin spi_ss1_pin;
-// static OutputPin spi_ss2_pin;
-// static OutputPin spi_ss3_pin;
-// static OutputPin spi_ss4_pin;
-// static OutputPin spi_ss5_pin;
-// static OutputPin spi_ss6_pin;
static OutputPin kinen_sync_pin;
static OutputPin grbl_reset_pin;
@@ -153,14 +134,12 @@ static OutputPin grbl_feedhold_pin;
static OutputPin grbl_cycle_start_pin;
static OutputPin motor_common_enable_pin;
-static OutputPin spindle_enable_pin;
-static OutputPin spindle_dir_pin;
-
-// NOTE: In the v9 and the Due the flood and mist coolants are mapped to a the same pin
-// static OutputPin coolant_enable_pin;
-static OutputPin flood_enable_pin;
-static OutputPin mist_enable_pin;
+#define SPINDLE_OUTPUT_NUMBER 1 // drive our primary output as a spindle
+#define SPINDLE_ENABLE_OUTPUT_NUMBER 2 // use output 2 as the enable line for the spindle
+#define SPINDLE_DIRECTION_OUTPUT_NUMBER 0 // no direction control
+#define MIST_ENABLE_OUTPUT_NUMBER 0 // no mist
+#define FLOOD_ENABLE_OUTPUT_NUMBER 0 // no flood
// Input pins are defined in gpio.cpp
/********************************
diff --git a/g2core/board/gquadratic/motate_pin_assignments.h b/g2core/board/gquadratic/motate_pin_assignments.h
index 9cc268e7a..57c099bb0 100755
--- a/g2core/board/gquadratic/motate_pin_assignments.h
+++ b/g2core/board/gquadratic/motate_pin_assignments.h
@@ -157,13 +157,14 @@ pin_number kDebug3_PinNumber = -1; // 116; //e Not the out-of-order numbering &
pin_number kDebug4_PinNumber = -1; // 114;
// END DEBUG PINS
-pin_number kLED_USBRXPinNumber = 117;
-pin_number kLED_USBTXPinNumber = 118;
-pin_number kSD_CardDetectPinNumber = 119;
-pin_number kSD_ChipSelectPinNumber = 120;
-pin_number kInterlock_InPinNumber = 121;
-pin_number kOutputSAFE_PinNumber = 122; // SAFE signal
-pin_number kLEDPWM_PinNumber = 123;
+pin_number kLED_USBRXPinNumber = 117;
+pin_number kLED_USBTXPinNumber = 118;
+pin_number kSD_CardDetectPinNumber = -1;
+pin_number kSD_ChipSelectPinNumber = -1;
+pin_number kUSBVBUS_PinNumber = 119;
+pin_number kInterlock_InPinNumber = 121;
+pin_number kOutputSAFE_PinNumber = 122; // SAFE signal
+pin_number kLEDPWM_PinNumber = 123;
pin_number kOutputInterrupt_PinNumber = 124; // to-host interrupt signal
pin_number kLED_RGBWPixelPinNumber = 125; // 117;
@@ -176,8 +177,10 @@ pin_number kGRBL_CommonEnablePinNumber = -1;
// g2ref extensions
// These first 5 may replace the Spindle and Coolant pins, above
-pin_number kOutput1_PinNumber = 130; // DO_1: Extruder1_PWM
-pin_number kOutput2_PinNumber = 131; // DO_2: Extruder2_PWM
+pin_number kHeaterOutput1_PinNumber = -1; // DO_1: Extruder1_PWM
+pin_number kHeaterOutput2_PinNumber = -1; // DO_2: Extruder2_PWM
+pin_number kOutput1_PinNumber = 130; // DO_1:
+pin_number kOutput2_PinNumber = 131; // DO_2:
pin_number kOutput3_PinNumber = 132; // DO_3: Fan1A_PWM
pin_number kOutput4_PinNumber = 133; // DO_4: Fan1B_PWM
pin_number kOutput5_PinNumber = 134; // DO_5: Fan2A_PWM
@@ -188,28 +191,29 @@ pin_number kOutput8_PinNumber = 137; // See Coolant Enable
pin_number kOutput9_PinNumber = 138; // SAFE signal
pin_number kOutput10_PinNumber = 139; // DO_10: Fan2B_PWM
-pin_number kOutput11_PinNumber = 140; // DO_11: Heated Bed FET
+pin_number kHeaterOutput11_PinNumber = -1; // DO_11: Heated Bed FET
+pin_number kOutput11_PinNumber = 140; // DO_11:
pin_number kOutput12_PinNumber = 141; // DO_12: Indicator_LED
pin_number kOutput13_PinNumber = -1; // 142;
pin_number kOutput14_PinNumber = -1; // 143;
pin_number kOutput15_PinNumber = -1; // 144;
pin_number kOutput16_PinNumber = -1; // 145;
-pin_number kADC0_PinNumber = 150; // Heated bed thermistor ADC
-pin_number kADC1_PinNumber = 151; // Extruder1_ADC
-pin_number kADC2_PinNumber = 152; // Extruder2_ADC
-pin_number kADC3_PinNumber = 153; // Aux ADC
-pin_number kADC4_PinNumber = 154; // Not physically pinned out
-pin_number kADC5_PinNumber = 155; // Not physically pinned out
-pin_number kADC6_PinNumber = 156; // Not physically pinned out
-pin_number kADC7_PinNumber = 157; // Not physically pinned out
-pin_number kADC8_PinNumber = 158; // Not physically pinned out
-pin_number kADC9_PinNumber = 159; // Not physically pinned out
-pin_number kADC10_PinNumber = 160; // Not physically pinned out
-pin_number kADC11_PinNumber = 161; // Not physically pinned out
-pin_number kADC12_PinNumber = 162; // Not physically pinned out
-pin_number kADC13_PinNumber = 163; // Not physically pinned out
-pin_number kADC14_PinNumber = 164; // Not physically pinned out
+pin_number kADC1_PinNumber = 150; // Heated bed thermistor ADC
+pin_number kADC2_PinNumber = 151; // Extruder1_ADC
+pin_number kADC3_PinNumber = 152; // Extruder2_ADC
+pin_number kADC4_PinNumber = 153; // Aux ADC
+pin_number kADC5_PinNumber = 154; // Not physically pinned out
+pin_number kADC6_PinNumber = 155; // Not physically pinned out
+pin_number kADC7_PinNumber = 156; // Not physically pinned out
+pin_number kADC8_PinNumber = 157; // Not physically pinned out
+pin_number kADC9_PinNumber = 158; // Not physically pinned out
+pin_number kADC10_PinNumber = 159; // Not physically pinned out
+pin_number kADC11_PinNumber = 160; // Not physically pinned out
+pin_number kADC12_PinNumber = 161; // Not physically pinned out
+pin_number kADC13_PinNumber = 162; // Not physically pinned out
+pin_number kADC14_PinNumber = 163; // Not physically pinned out
+pin_number kADC15_PinNumber = 164; // Not physically pinned out
pin_number kExternalClock1_PinNumber = 170; // External pins for exporting a clock signal (for Trinamics)
@@ -222,6 +226,8 @@ pin_number kServo3_PinNumber = 173; //
// blank spots for unassigned pins - all unassigned pins need a unique number (do not re-use numbers)
+pin_number kUnassigned40 = 215;
+pin_number kUnassigned39 = 216;
pin_number kUnassigned38 = 217;
pin_number kUnassigned37 = 218;
pin_number kUnassigned36 = 219;
diff --git a/g2core/board/gquintic.gdb b/g2core/board/gquintic.gdb
index 864a9f89a..2619f7e4a 100644
--- a/g2core/board/gquintic.gdb
+++ b/g2core/board/gquintic.gdb
@@ -1,10 +1,43 @@
# Open and connect to openocd with the ATMEL-ICE
-target remote | /usr/local/bin/openocd -c "set CHIPNAME ${CHIP}" -f ${MOTATE_PATH}/openocd.cfg -f ${MOTATE_PATH}/platform/atmel_sam/atmel_sam.cfg -c "gdb_port pipe; log_output openocd.log"
+#target remote | /usr/local/bin/openocd -c "set CHIPNAME ${CHIP}" -f ${MOTATE_PATH}/openocd.cfg -f ${MOTATE_PATH}/platform/atmel_sam/atmel_sam.cfg -c "gdb_port pipe; log_output openocd.log"
-source ./board/g2_default.gdb
+target extended-remote :2331
+
+# Setup for non-wrapped lines and non-pages prints
+set width 0
+set height 0
+
+# Turn on history saving
+set history save on
+set history expansion on
+
+set print pretty on
+
+define reset_deep
+ monitor reset
+
+ # Reset peripheral (RSTC_CR)
+ set *0x400E1800 = 0xA5000004
+
+# # Initializing PC and stack pointer
+# mon reg sp = (0x20400000)
+# set *0x20400004 = *0x20400004 & 0xFFFFFFFE
+# mon reg pc=(0x20400004)
+ info reg
+end
+
+define flash
+ make
+ load
+ reset
+end
+
+define dump_mb
+ source ../Resources/debug/mb.gdb
+end
define boot_from_flash
- monitor atsamv gpnvm set 1
+ #monitor atsamv gpnvm set 1
end
source -s arm.gdb
diff --git a/g2core/board/gquintic.mk b/g2core/board/gquintic.mk
index ab60f6cb0..3c5f8d622 100755
--- a/g2core/board/gquintic.mk
+++ b/g2core/board/gquintic.mk
@@ -18,6 +18,18 @@ ifeq ("$(BOARD)","gquintic-b")
DEVICE_DEFINES += SETTINGS_FILE=${SETTINGS_FILE}
endif
+ifeq ("$(BOARD)","gquintic-c")
+ BASE_BOARD=gquintic
+ DEVICE_DEFINES += MOTATE_BOARD="gquintic-c"
+ DEVICE_DEFINES += SETTINGS_FILE=${SETTINGS_FILE}
+endif
+
+ifeq ("$(BOARD)","gquintic-d")
+BASE_BOARD=gquintic
+DEVICE_DEFINES += MOTATE_BOARD="gquintic-d"
+DEVICE_DEFINES += SETTINGS_FILE=${SETTINGS_FILE}
+endif
+
##########
# The general gquintic BASE_BOARD.
@@ -26,16 +38,16 @@ endif
ifeq ("$(BASE_BOARD)","gquintic")
_BOARD_FOUND = 1
- DEVICE_DEFINES += MOTATE_CONFIG_HAS_USBSERIAL=1
+ DEVICE_DEFINES += MOTATE_CONFIG_HAS_USBSERIAL=1 ENABLE_TCM=1
- FIRST_LINK_SOURCES += $(sort $(wildcard ${MOTATE_PATH}/Atmel_sam_common/*.cpp)) $(sort $(wildcard ${MOTATE_PATH}/Atmel_sams70/*.cpp))
+ FIRST_LINK_SOURCES += $(sort $(wildcard ${MOTATE_PATH}/Atmel_sam_common/*.cpp)) $(sort $(wildcard ${MOTATE_PATH}/Atmel_sams70/*.cpp) $(wildcard ${BOARD_PATH}/*.cpp))
CHIP = SAMS70N19
export CHIP
CHIP_LOWERCASE = sams70n19
BOARD_PATH = ./board/gquintic
- SOURCE_DIRS += ${BOARD_PATH} device/trinamic
+ SOURCE_DIRS += ${BOARD_PATH} device/trinamic device/step_dir_hobbyservo device/max31865
PLATFORM_BASE = ${MOTATE_PATH}/platform/atmel_sam
include $(PLATFORM_BASE).mk
diff --git a/g2core/board/gquintic/hardware.cpp b/g2core/board/gquintic/0_hardware.cpp
similarity index 98%
rename from g2core/board/gquintic/hardware.cpp
rename to g2core/board/gquintic/0_hardware.cpp
index e11d595c0..1ab8ffc7a 100755
--- a/g2core/board/gquintic/hardware.cpp
+++ b/g2core/board/gquintic/0_hardware.cpp
@@ -39,12 +39,16 @@
//Motate::ClockOutputPin external_clk_pin {16000000}; // 16MHz optimally
Motate::OutputPin external_clk_pin {Motate::kStartLow};
+HOT_DATA SPI_CS_PinMux_used_t spiCSPinMux;
+HOT_DATA SPIBus_used_t spiBus;
+
/*
* hardware_init() - lowest level hardware init
*/
void hardware_init()
{
+ spiBus.init();
board_hardware_init();
external_clk_pin = 0; // Force external clock to 0 for now.
}
diff --git a/g2core/board/gquintic/board_gpio.cpp b/g2core/board/gquintic/board_gpio.cpp
new file mode 100644
index 000000000..76f1ed70f
--- /dev/null
+++ b/g2core/board/gquintic/board_gpio.cpp
@@ -0,0 +1,143 @@
+/*
+ * gpio.cpp - digital IO handling functions
+ * This file is part of the g2core project
+ *
+ * Copyright (c) 2015 - 2107 Alden S. Hart, Jr.
+ * Copyright (c) 2015 - 2017 Robert Giseburt
+ *
+ * This file ("the software") is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2 as published by the
+ * Free Software Foundation. You should have received a copy of the GNU General Public
+ * License, version 2 along with the software. If not, see .
+ *
+ * As a special exception, you may use this file as part of a software library without
+ * restriction. Specifically, if other files instantiate templates or use macros or
+ * inline functions from this file, or you compile this file and link it with other
+ * files to produce an executable, this file does not by itself cause the resulting
+ * executable to be covered by the GNU General Public License. This exception does not
+ * however invalidate any other reasons why the executable file might be covered by the
+ * GNU General Public License.
+ *
+ * THE SOFTWARE IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY
+ * WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+ * SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* Switch Modes
+ *
+ * The switches are considered to be homing switches when cycle_state is
+ * CYCLE_HOMING. At all other times they are treated as limit switches:
+ * - Hitting a homing switch puts the current move into feedhold
+ * - Hitting a limit switch causes the machine to shut down and go into lockdown until reset
+ *
+ * The normally open switch modes (NO) trigger an interrupt on the falling edge
+ * and lockout subsequent interrupts for the defined lockout period. This approach
+ * beats doing debouncing as an integration as switches fire immediately.
+ *
+ * The normally closed switch modes (NC) trigger an interrupt on the rising edge
+ * and lockout subsequent interrupts for the defined lockout period. Ditto on the method.
+ */
+
+#include "../../g2core.h" // #1
+#include "config.h" // #2
+#include "gpio.h"
+#include "hardware.h"
+#include "canonical_machine.h"
+
+#include "text_parser.h"
+#include "controller.h"
+#include "util.h"
+#include "report.h"
+#include "xio.h"
+
+#include "MotateTimers.h"
+
+/**** Setup Actual Objects ****/
+
+gpioDigitalInputPin> din1 {DI1_ENABLED, DI1_POLARITY, 1, DI1_EXTERNAL_NUMBER};
+gpioDigitalInputPin> din2 {DI2_ENABLED, DI2_POLARITY, 2, DI2_EXTERNAL_NUMBER};
+gpioDigitalInputPin> din3 {DI3_ENABLED, DI3_POLARITY, 3, DI3_EXTERNAL_NUMBER};
+gpioDigitalInputPin> din4 {DI4_ENABLED, DI4_POLARITY, 4, DI4_EXTERNAL_NUMBER};
+gpioDigitalInputPin> din5 {DI5_ENABLED, DI5_POLARITY, 5, DI5_EXTERNAL_NUMBER};
+gpioDigitalInputPin> din6 {DI6_ENABLED, DI6_POLARITY, 6, DI6_EXTERNAL_NUMBER};
+gpioDigitalInputPin> din7 {DI7_ENABLED, DI7_POLARITY, 7, DI7_EXTERNAL_NUMBER};
+gpioDigitalInputPin> din8 {DI8_ENABLED, DI8_POLARITY, 8, DI8_EXTERNAL_NUMBER};
+gpioDigitalInputPin> din9 {DI9_ENABLED, DI9_POLARITY, 9, DI9_EXTERNAL_NUMBER};
+// gpioDigitalInputPin> din10 {DI10ENABLEDE, DI10_POLARITY, 10, DI10_EXTERNAL_NUMBER};
+// gpioDigitalInputPin> din11 {DI11ENABLEDE, DI11_POLARITY, 11, DI11_EXTERNAL_NUMBER};
+// gpioDigitalInputPin> din12 {DI12ENABLEDE, DI12_POLARITY, 12, DI12_EXTERNAL_NUMBER};
+
+gpioDigitalInput* const d_in[] = {&din1, &din2, &din3, &din4, &din5, &din6, &din7, &din8, &din9};
+
+
+gpioDigitalOutputPin> dout1 { DO1_ENABLED, DO1_POLARITY, DO1_EXTERNAL_NUMBER, (uint32_t)200000 };
+gpioDigitalOutputPin> dout2 { DO2_ENABLED, DO2_POLARITY, DO2_EXTERNAL_NUMBER, (uint32_t)200000 };
+gpioDigitalOutputPin> dout3 { DO3_ENABLED, DO3_POLARITY, DO3_EXTERNAL_NUMBER, (uint32_t)200000 };
+gpioDigitalOutputPin> dout4 { DO4_ENABLED, DO4_POLARITY, DO4_EXTERNAL_NUMBER, (uint32_t)200000 };
+gpioDigitalOutputPin> dout5 { DO5_ENABLED, DO5_POLARITY, DO5_EXTERNAL_NUMBER, (uint32_t)200000 };
+gpioDigitalOutputPin> dout6 { DO6_ENABLED, DO6_POLARITY, DO6_EXTERNAL_NUMBER, (uint32_t)200000 };
+gpioDigitalOutputPin> dout7 { DO7_ENABLED, DO7_POLARITY, DO7_EXTERNAL_NUMBER, (uint32_t)200000 };
+gpioDigitalOutputPin> dout8 { DO8_ENABLED, DO8_POLARITY, DO8_EXTERNAL_NUMBER, (uint32_t)200000 };
+gpioDigitalOutputPin> dout9 { DO9_ENABLED, DO9_POLARITY, DO9_EXTERNAL_NUMBER, (uint32_t)200000 };
+gpioDigitalOutputPin> dout10 { DO10_ENABLED, DO10_POLARITY, DO10_EXTERNAL_NUMBER, (uint32_t)200000 };
+gpioDigitalOutputPin> dout11 { DO11_ENABLED, DO11_POLARITY, DO11_EXTERNAL_NUMBER, (uint32_t)200000 };
+gpioDigitalOutputPin> dout12 { DO12_ENABLED, DO12_POLARITY, DO12_EXTERNAL_NUMBER, (uint32_t)200000 };
+gpioDigitalOutputPin> dout13 { DO13_ENABLED, DO13_POLARITY, DO13_EXTERNAL_NUMBER, (uint32_t)200000 };
+
+gpioDigitalOutput* const d_out[] = {&dout1, &dout2, &dout3, &dout4, &dout5, &dout6, &dout7, &dout8, &dout9, &dout10, &dout11, &dout12, &dout13};
+
+
+#if QUINTIC_REVISION == 'C'
+
+gpioAnalogInputPin> ai1 {AI1_ENABLED, gpioAnalogInput::AIN_TYPE_EXTERNAL, 1, AI1_EXTERNAL_NUMBER, spiBus, spiCSPinMux.getCS(5)};
+gpioAnalogInputPin> ai2 {AI2_ENABLED, gpioAnalogInput::AIN_TYPE_EXTERNAL, 2, AI2_EXTERNAL_NUMBER, spiBus, spiCSPinMux.getCS(6)};
+gpioAnalogInputPin> ai3 {AI3_ENABLED, gpioAnalogInput::AIN_TYPE_INTERNAL, 3, AI3_EXTERNAL_NUMBER};
+gpioAnalogInputPin> ai4 {AI4_ENABLED, gpioAnalogInput::AIN_TYPE_INTERNAL, 4, AI4_EXTERNAL_NUMBER};
+
+gpioAnalogInput* const a_in[] = {&ain1, &ain2, &ain3, &ain4};
+
+#endif // 'C'
+
+#if QUINTIC_REVISION == 'D'
+
+gpioAnalogInputPin> ai1 {AI1_ENABLED, gpioAnalogInput::AIN_TYPE_INTERNAL, 1, AI1_EXTERNAL_NUMBER};
+gpioAnalogInputPin> ai2 {AI2_ENABLED, gpioAnalogInput::AIN_TYPE_INTERNAL, 2, AI2_EXTERNAL_NUMBER};
+gpioAnalogInputPin> ai3 {AI3_ENABLED, gpioAnalogInput::AIN_TYPE_INTERNAL, 3, AI3_EXTERNAL_NUMBER};
+gpioAnalogInputPin> ai4 {AI4_ENABLED, gpioAnalogInput::AIN_TYPE_INTERNAL, 4, AI4_EXTERNAL_NUMBER};
+
+gpioAnalogInput* const a_in[] = {&ai1, &ai2, &ai3, &ai4};
+
+#endif // 'D'
+
+
+/************************************************************************************
+ **** CODE **************************************************************************
+ ************************************************************************************/
+
+
+ // Register a SysTick event to call start_sampling every temperature_sample_freq ms
+ const int16_t ain_sample_freq = 10;
+ int16_t ain_sample_counter = ain_sample_freq;
+ Motate::SysTickEvent ain_tick_event {[&] {
+ if (!--ain_sample_counter) {
+ ai1.startSampling();
+ ai2.startSampling();
+ ai3.startSampling();
+ ai4.startSampling();
+ ain_sample_counter = ain_sample_freq;
+ }
+ }, nullptr};
+
+/*
+ * gpio_reset() - reset inputs and outputs (no initialization)
+ */
+
+void outputs_reset(void) {
+ // nothing to do
+}
+
+void inputs_reset(void) {
+ SysTickTimer.registerEvent(&ain_tick_event);
+}
diff --git a/g2core/board/gquintic/board_gpio.h b/g2core/board/gquintic/board_gpio.h
new file mode 100644
index 000000000..1dedb7ad8
--- /dev/null
+++ b/g2core/board/gquintic/board_gpio.h
@@ -0,0 +1,197 @@
+/*
+ * gpio.h - Digital IO handling functions
+ * This file is part of the g2core project
+ *
+ * Copyright (c) 2015 - 2017 Alden S. Hart, Jr.
+ * Copyright (c) 2015 - 2017 Robert Giseburt
+ *
+ * This file ("the software") is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2 as published by the
+ * Free Software Foundation. You should have received a copy of the GNU General Public
+ * License, version 2 along with the software. If not, see .
+ *
+ * As a special exception, you may use this file as part of a software library without
+ * restriction. Specifically, if other files instantiate templates or use macros or
+ * inline functions from this file, or you compile this file and link it with other
+ * files to produce an executable, this file does not by itself cause the resulting
+ * executable to be covered by the GNU General Public License. This exception does not
+ * however invalidate any other reasons why the executable file might be covered by the
+ * GNU General Public License.
+ *
+ * THE SOFTWARE IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY
+ * WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+ * SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef BOARD_GPIO_H_ONCE
+#define BOARD_GPIO_H_ONCE
+
+// this file is included from the bottom of gpio.h, but we do this for completeness
+#include "../../gpio.h"
+#include "hardware.h"
+
+/*
+ * GPIO defines
+ */
+//--- change as required for board and switch hardware ---//
+
+#define INPUT_LOCKOUT_MS 10 // milliseconds to go dead after input firing
+
+/*
+ * The GPIO objects themselves - this must match up with board_gpio.cpp!
+ */
+
+// prepare the objects as externs (for config_app to not bloat)
+using Motate::IRQPin;
+using Motate::PWMOutputPin;
+using Motate::PWMLikeOutputPin;
+using Motate::ADCPin;
+using Motate::ADCDifferentialPair;
+template
+using OutputType = typename std::conditional, PWMLikeOutputPin