More cleanup
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Thu, 31 Dec 2015 03:43:16 +0000 (19:43 -0800)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Thu, 31 Dec 2015 03:43:16 +0000 (19:43 -0800)
src/hardware.c
src/hardware.h
src/main.c
src/system.c [deleted file]
src/system.h [deleted file]

index df7ac0827fc9c39771f90bfed60a72defaa6635b..8827f676779e2a85e9c2f8178efd780c0f06593c 100644 (file)
@@ -28,7 +28,7 @@
 #include <avr/wdt.h>            // used for software reset
 
 #include "tinyg.h"        // #1
-#include "config.h"        // #2
+#include "config.h"       // #2
 #include "hardware.h"
 #include "switch.h"
 #include "controller.h"
 #include "xmega/xmega_init.h"
 #include "xmega/xmega_rtc.h"
 
-/*
- * _port_bindings  - bind XMEGA ports to hardware - these changed at board revision 7
- * hardware_init() - lowest level hardware init
- */
 
-static void _port_bindings(float hw_version)
-{
-    hw.st_port[0] = &PORT_MOTOR_1;
-    hw.st_port[1] = &PORT_MOTOR_2;
-    hw.st_port[2] = &PORT_MOTOR_3;
-    hw.st_port[3] = &PORT_MOTOR_4;
-
-    hw.sw_port[0] = &PORT_SWITCH_X;
-    hw.sw_port[1] = &PORT_SWITCH_Y;
-    hw.sw_port[2] = &PORT_SWITCH_Z;
-    hw.sw_port[3] = &PORT_SWITCH_A;
-
-    if (hw_version > 6.9) {
-        hw.out_port[0] = &PORT_OUT_V7_X;
-        hw.out_port[1] = &PORT_OUT_V7_Y;
-        hw.out_port[2] = &PORT_OUT_V7_Z;
-        hw.out_port[3] = &PORT_OUT_V7_A;
-        } else {
-        hw.out_port[0] = &PORT_OUT_V6_X;
-        hw.out_port[1] = &PORT_OUT_V6_Y;
-        hw.out_port[2] = &PORT_OUT_V6_Z;
-        hw.out_port[3] = &PORT_OUT_V6_A;
-    }
+/// Bind XMEGA ports to hardware
+static void _port_bindings() {
+  hw.st_port[0] = &PORT_MOTOR_1;
+  hw.st_port[1] = &PORT_MOTOR_2;
+  hw.st_port[2] = &PORT_MOTOR_3;
+  hw.st_port[3] = &PORT_MOTOR_4;
+
+  hw.sw_port[0] = &PORT_SWITCH_X;
+  hw.sw_port[1] = &PORT_SWITCH_Y;
+  hw.sw_port[2] = &PORT_SWITCH_Z;
+  hw.sw_port[3] = &PORT_SWITCH_A;
+
+  hw.out_port[0] = &PORT_OUT_V7_X;
+  hw.out_port[1] = &PORT_OUT_V7_Y;
+  hw.out_port[2] = &PORT_OUT_V7_Z;
+  hw.out_port[3] = &PORT_OUT_V7_A;
 }
 
-void hardware_init()
-{
-    xmega_init();                            // set system clock
-    _port_bindings(TINYG_HARDWARE_VERSION);
-    rtc_init();                                // real time counter
+
+/// Lowest level hardware init
+void hardware_init() {
+  xmega_init();                            // set system clock
+  _port_bindings();
+  rtc_init();                              // real time counter
 }
 
+
 /*
  * _get_id() - get a human readable signature
  *
@@ -83,42 +74,40 @@ void hardware_init()
  *    The alpha is the low 5 bits of wafer number and XY coords in printable ASCII
  *    Refer to NVM_PROD_SIGNATURES_t in iox192a3.h for details.
  */
-
 enum {
-    LOTNUM0=8,  // Lot Number Byte 0, ASCII
-    LOTNUM1,    // Lot Number Byte 1, ASCII
-    LOTNUM2,    // Lot Number Byte 2, ASCII
-    LOTNUM3,    // Lot Number Byte 3, ASCII
-    LOTNUM4,    // Lot Number Byte 4, ASCII
-    LOTNUM5,    // Lot Number Byte 5, ASCII
-    WAFNUM =16, // Wafer Number
-    COORDX0=18, // Wafer Coordinate X Byte 0
-    COORDX1,    // Wafer Coordinate X Byte 1
-    COORDY0,    // Wafer Coordinate Y Byte 0
-    COORDY1,    // Wafer Coordinate Y Byte 1
+  LOTNUM0 = 8,  // Lot Number Byte 0, ASCII
+  LOTNUM1,      // Lot Number Byte 1, ASCII
+  LOTNUM2,      // Lot Number Byte 2, ASCII
+  LOTNUM3,      // Lot Number Byte 3, ASCII
+  LOTNUM4,      // Lot Number Byte 4, ASCII
+  LOTNUM5,      // Lot Number Byte 5, ASCII
+  WAFNUM = 16,  // Wafer Number
+  COORDX0 = 18, // Wafer Coordinate X Byte 0
+  COORDX1,      // Wafer Coordinate X Byte 1
+  COORDY0,      // Wafer Coordinate Y Byte 0
+  COORDY1,      // Wafer Coordinate Y Byte 1
 };
 
-static void _get_id(char_t *id)
-{
-    char printable[33] = {"ABCDEFGHJKLMNPQRSTUVWXYZ23456789"};
-    uint8_t i;
-
-    NVM_CMD = NVM_CMD_READ_CALIB_ROW_gc;     // Load NVM Command register to read the calibration row
-
-    for (i=0; i<6; i++) {
-        id[i] = pgm_read_byte(LOTNUM0 + i);
-    }
-    id[i++] = '-';
-    id[i++] = printable[(pgm_read_byte(WAFNUM) & 0x1F)];
-    id[i++] = printable[(pgm_read_byte(COORDX0) & 0x1F)];
-//    id[i++] = printable[(pgm_read_byte(COORDX1) & 0x1F)];
-    id[i++] = printable[(pgm_read_byte(COORDY0) & 0x1F)];
-//    id[i++] = printable[(pgm_read_byte(COORDY1) & 0x1F)];
-    id[i] = 0;
-
-    NVM_CMD = NVM_CMD_NO_OPERATION_gc;          // Clean up NVM Command register
+
+static void _get_id(char_t *id) {
+  char printable[33] = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
+  uint8_t i;
+
+  NVM_CMD = NVM_CMD_READ_CALIB_ROW_gc;     // Load NVM Command register to read the calibration row
+
+  for (i = 0; i < 6; i++)
+    id[i] = pgm_read_byte(LOTNUM0 + i);
+
+  id[i++] = '-';
+  id[i++] = printable[(pgm_read_byte(WAFNUM) & 0x1F)];
+  id[i++] = printable[(pgm_read_byte(COORDX0) & 0x1F)];
+  id[i++] = printable[(pgm_read_byte(COORDY0) & 0x1F)];
+  id[i] = 0;
+
+  NVM_CMD = NVM_CMD_NO_OPERATION_gc;          // Clean up NVM Command register
 }
 
+
 /*
  * Hardware Reset Handlers
  *
@@ -126,20 +115,19 @@ static void _get_id(char_t *id)
  * hw_hard_reset()            - hard reset using watchdog timer
  * hw_hard_reset_handler()    - controller's rest handler
  */
-void hw_request_hard_reset() { cs.hard_reset_requested = true; }
+void hw_request_hard_reset() {cs.hard_reset_requested = true;}
+
 
-void hw_hard_reset()            // software hard reset using the watchdog timer
-{
-    wdt_enable(WDTO_15MS);
-    while (true);                    // loops for about 15ms then resets
+void hw_hard_reset() {            // software hard reset using the watchdog timer
+  wdt_enable(WDTO_15MS);
+  while (true);                    // loops for about 15ms then resets
 }
 
-stat_t hw_hard_reset_handler()
-{
-    if (cs.hard_reset_requested == false)
-        return STAT_NOOP;
-    hw_hard_reset();                // hard reset - identical to hitting RESET button
-    return STAT_EAGAIN;
+
+stat_t hw_hard_reset_handler() {
+  if (cs.hard_reset_requested == false) return STAT_NOOP;
+  hw_hard_reset();                // hard reset - identical to hitting RESET button
+  return STAT_EAGAIN;
 }
 
 /*
@@ -148,66 +136,47 @@ stat_t hw_hard_reset_handler()
  * hw_request_bootloader()
  * hw_request_bootloader_handler() - executes a software reset using CCPWrite
  */
+void hw_request_bootloader() {cs.bootloader_requested = true;}
+
 
-void hw_request_bootloader() { cs.bootloader_requested = true;}
+stat_t hw_bootloader_handler() {
+  if (cs.bootloader_requested == false)
+    return STAT_NOOP;
 
-stat_t hw_bootloader_handler()
-{
-    if (cs.bootloader_requested == false)
-        return STAT_NOOP;
-    cli();
-    CCPWrite(&RST.CTRL, RST_SWRST_bm);  // fire a software reset
+  cli();
+  CCPWrite(&RST.CTRL, RST_SWRST_bm);  // fire a software reset
 
-    return STAT_EAGAIN;                // never gets here but keeps the compiler happy
+  return STAT_EAGAIN;                // never gets here but keeps the compiler happy
 }
 
-/***** END OF SYSTEM FUNCTIONS *****/
 
+/// hw_get_id() - get device ID (signature)
+stat_t hw_get_id(nvObj_t *nv) {
+  char_t tmp[SYS_ID_LEN];
+  _get_id(tmp);
+  nv->valuetype = TYPE_STRING;
+  ritorno(nv_copy_string(nv, tmp));
+  return STAT_OK;
+}
 
-/***********************************************************************************
- * CONFIGURATION AND INTERFACE FUNCTIONS
- * Functions to get and set variables from the cfgArray table
- ***********************************************************************************/
 
-/*
- * hw_get_id() - get device ID (signature)
- */
-
-stat_t hw_get_id(nvObj_t *nv)
-{
-    char_t tmp[SYS_ID_LEN];
-    _get_id(tmp);
-    nv->valuetype = TYPE_STRING;
-    ritorno(nv_copy_string(nv, tmp));
-    return STAT_OK;
+/// hw_run_boot() - invoke boot form the cfgArray
+stat_t hw_run_boot(nvObj_t *nv) {
+  hw_request_bootloader();
+  return(STAT_OK);
 }
 
-/*
- * hw_run_boot() - invoke boot form the cfgArray
- */
-stat_t hw_run_boot(nvObj_t *nv)
-{
-    hw_request_bootloader();
-    return(STAT_OK);
-}
 
-/*
- * hw_set_hv() - set hardware version number
- */
-stat_t hw_set_hv(nvObj_t *nv)
-{
-    if (nv->value > TINYG_HARDWARE_VERSION_MAX)
-        return STAT_INPUT_EXCEEDS_MAX_VALUE;
-    set_flt(nv);                    // record the hardware version
-    _port_bindings(nv->value);        // reset port bindings
-    switch_init();                    // re-initialize the GPIO ports
-    return STAT_OK;
-}
+/// hw_set_hv() - set hardware version number
+stat_t hw_set_hv(nvObj_t *nv) {
+  if (nv->value > TINYG_HARDWARE_VERSION_MAX)
+    return STAT_INPUT_EXCEEDS_MAX_VALUE;
 
-/***********************************************************************************
- * TEXT MODE SUPPORT
- * Functions to print variables from the cfgArray table
- ***********************************************************************************/
+  set_flt(nv);                    // record the hardware version
+  _port_bindings(nv->value);        // reset port bindings
+  switch_init();                    // re-initialize the GPIO ports
+  return STAT_OK;
+}
 
 #ifdef __TEXT_MODE
 
@@ -217,10 +186,10 @@ static const char fmt_hp[] PROGMEM = "[hp]  hardware platform%15.2f\n";
 static const char fmt_hv[] PROGMEM = "[hv]  hardware version%16.2f\n";
 static const char fmt_id[] PROGMEM = "[id]  TinyG ID%30s\n";
 
-void hw_print_fb(nvObj_t *nv) { text_print_flt(nv, fmt_fb);}
-void hw_print_fv(nvObj_t *nv) { text_print_flt(nv, fmt_fv);}
-void hw_print_hp(nvObj_t *nv) { text_print_flt(nv, fmt_hp);}
-void hw_print_hv(nvObj_t *nv) { text_print_flt(nv, fmt_hv);}
-void hw_print_id(nvObj_t *nv) { text_print_str(nv, fmt_id);}
+void hw_print_fb(nvObj_t *nv) {text_print_flt(nv, fmt_fb);}
+void hw_print_fv(nvObj_t *nv) {text_print_flt(nv, fmt_fv);}
+void hw_print_hp(nvObj_t *nv) {text_print_flt(nv, fmt_hp);}
+void hw_print_hv(nvObj_t *nv) {text_print_flt(nv, fmt_hv);}
+void hw_print_id(nvObj_t *nv) {text_print_str(nv, fmt_id);}
 
 #endif //__TEXT_MODE
index 0061ddf05250fa4a3dd22ac69f1e9f859d21dde5..0cf848ff2e43a0d7abcce67b539f35e1bad050c7 100644 (file)
 /*--- Hardware platform enumerations ---*/
 
 enum hwPlatform {
-    HM_PLATFORM_NONE = 0,
+  HM_PLATFORM_NONE = 0,
 
-    HW_PLATFORM_TINYG_XMEGA,    // TinyG code base on Xmega boards.
-                                //    hwVersion 7 = TinyG v7 and earlier
-                                //    hwVersion 8 = TinyG v8
+  HW_PLATFORM_TINYG_XMEGA,    // TinyG code base on Xmega boards.
+  //    hwVersion 7 = TinyG v7 and earlier
+  //    hwVersion 8 = TinyG v8
 
-    HW_PLATFORM_G2_DUE,            // G2 code base on native Arduino Due
+  HW_PLATFORM_G2_DUE,            // G2 code base on native Arduino Due
 
-    HW_PLATFORM_TINYG_V9        // G2 code base on v9 boards
-                                //  hwVersion 0 = v9c
-                                //  hwVersion 1 = v9d
-                                //  hwVersion 2 = v9f
-                                //  hwVersion 3 = v9h
-                                //  hwVersion 4 = v9i
+  HW_PLATFORM_TINYG_V9        // G2 code base on v9 boards
+  //  hwVersion 0 = v9c
+  //  hwVersion 1 = v9d
+  //  hwVersion 2 = v9f
+  //  hwVersion 3 = v9h
+  //  hwVersion 4 = v9i
 };
 
 #define HW_VERSION_TINYGV6        6
@@ -140,14 +140,14 @@ enum hwPlatform {
 #define MOTOR_PORT_DIR_gm 0x3F    // dir settings: lower 6 out, upper 2 in
 
 enum cfgPortBits {            // motor control port bit positions
-    STEP_BIT_bp = 0,        // bit 0
-    DIRECTION_BIT_bp,        // bit 1
-    MOTOR_ENABLE_BIT_bp,    // bit 2
-    MICROSTEP_BIT_0_bp,        // bit 3
-    MICROSTEP_BIT_1_bp,        // bit 4
-    GPIO1_OUT_BIT_bp,        // bit 5 (4 gpio1 output bits; 1 from each axis)
-    SW_MIN_BIT_bp,            // bit 6 (4 input bits for homing/limit switches)
-    SW_MAX_BIT_bp            // bit 7 (4 input bits for homing/limit switches)
+  STEP_BIT_bp = 0,        // bit 0
+  DIRECTION_BIT_bp,        // bit 1
+  MOTOR_ENABLE_BIT_bp,    // bit 2
+  MICROSTEP_BIT_0_bp,        // bit 3
+  MICROSTEP_BIT_1_bp,        // bit 4
+  GPIO1_OUT_BIT_bp,        // bit 5 (4 gpio1 output bits; 1 from each axis)
+  SW_MIN_BIT_bp,            // bit 6 (4 input bits for homing/limit switches)
+  SW_MAX_BIT_bp            // bit 7 (4 input bits for homing/limit switches)
 };
 
 #define STEP_BIT_bm            (1<<STEP_BIT_bp)
@@ -222,21 +222,21 @@ enum cfgPortBits {            // motor control port bit positions
 
 /**** Device singleton - global structure to allow iteration through similar devices ****/
 /*
-    Ports are shared between steppers and GPIO so we need a global struct.
-    Each xmega port has 3 bindings; motors, switches and the output bit
+  Ports are shared between steppers and GPIO so we need a global struct.
+  Each xmega port has 3 bindings; motors, switches and the output bit
 
-    The initialization sequence is important. the order is:
-        - sys_init()    binds all ports to the device struct
-        - st_init()     sets IO directions and sets stepper VPORTS and stepper specific functions
+  The initialization sequence is important. the order is:
+  - sys_init()    binds all ports to the device struct
+  - st_init()     sets IO directions and sets stepper VPORTS and stepper specific functions
 
-    Care needs to be taken in routines that use ports not to write to bits that are
-    not assigned to the designated function - ur unpredicatable results will occur
+  Care needs to be taken in routines that use ports not to write to bits that are
+  not assigned to the designated function - ur unpredicatable results will occur
 */
 
 typedef struct hmSingleton {
-    PORT_t *st_port[MOTORS];        // bindings for stepper motor ports (stepper.c)
-    PORT_t *sw_port[MOTORS];        // bindings for switch ports (GPIO2)
-    PORT_t *out_port[MOTORS];        // bindings for output ports (GPIO1)
+  PORT_t *st_port[MOTORS];        // bindings for stepper motor ports (stepper.c)
+  PORT_t *sw_port[MOTORS];        // bindings for switch ports (GPIO2)
+  PORT_t *out_port[MOTORS];        // bindings for output ports (GPIO1)
 } hwSingleton_t;
 hwSingleton_t hw;
 
index b7610b79383c2c4bf53c9c15002873e8904e0300..0f8a1b7a1f080bd858dd35d716445b44b765877e 100644 (file)
@@ -61,14 +61,14 @@ static void init() {
   canonical_machine_init();       // canonical machine                - must follow config_init()
 
   // now bring up the interrupts and get started
-  PMIC_SetVectorLocationToApplication();// as opposed to boot ROM
+  PMIC_SetVectorLocationToApplication(); // as opposed to boot ROM
   PMIC_EnableHighLevel();         // all levels are used, so don't bother to abstract them
   PMIC_EnableMediumLevel();
   PMIC_EnableLowLevel();
 
   sei();                          // enable global interrupts
 
-  rpt_print_system_ready_message();// (LAST) announce system is ready
+  rpt_print_system_ready_message(); // (LAST) announce system is ready
 }
 
 
diff --git a/src/system.c b/src/system.c
deleted file mode 100644 (file)
index 6154f1b..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * system.c - general hardware support functions
- * Part of TinyG project
- *
- * Copyright (c) 2011 - 2012 Alden S. Hart Jr.
- *
- * 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 <http://www.gnu.org/licenses/>.
- *
- * 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.
- *
- * ------
- * Notes:
- *    - add full interrupt tables and dummy interrupt routine (maybe)
- *    - add crystal oscillator failover
- *    - add watchdog timer functions
- *
- */
-
-#include <stdio.h>
-#include <stddef.h> 
-#include <avr/pgmspace.h> 
-
-#include "tinyg.h"
-#include "system.h"
-#include "xmega/xmega_init.h"
-
-/*
- * sys_init() - lowest level hardware init
- */
-
-void sys_init() 
-{
-    xmega_init();        // set system clock
-    sys_port_bindings(8);
-}
-
-void sys_port_bindings(float hw_version)
-{
-    device.st_port[0] = &PORT_MOTOR_1;
-    device.st_port[1] = &PORT_MOTOR_2;
-    device.st_port[2] = &PORT_MOTOR_3;
-    device.st_port[3] = &PORT_MOTOR_4;
-
-    device.sw_port[0] = &PORT_SWITCH_X;
-    device.sw_port[1] = &PORT_SWITCH_Y;
-    device.sw_port[2] = &PORT_SWITCH_Z;
-    device.sw_port[3] = &PORT_SWITCH_A;
-
-    if (hw_version > 6.9) {
-        device.out_port[0] = &PORT_OUT_V7_X;
-        device.out_port[1] = &PORT_OUT_V7_Y;
-        device.out_port[2] = &PORT_OUT_V7_Z;
-        device.out_port[3] = &PORT_OUT_V7_A;
-    } else {
-        device.out_port[0] = &PORT_OUT_V6_X;
-        device.out_port[1] = &PORT_OUT_V6_Y;
-        device.out_port[2] = &PORT_OUT_V6_Z;
-        device.out_port[3] = &PORT_OUT_V6_A;
-    }
-}
-
-uint8_t sys_read_calibration_byte(uint8_t index)
-{ 
-    NVM_CMD = NVM_CMD_READ_CALIB_ROW_gc;     // Load NVM Command register to read the calibration row
-    uint8_t result = pgm_read_byte(index); 
-    NVM_CMD = NVM_CMD_NO_OPERATION_gc;          // Clean up NVM Command register 
-    return(result); 
-}
-
-/*
- * sys_get_id() - get a human readable signature
- *
- *    Produces a unique deviceID based on the factory calibration data. Format is:
- *        123456-ABC
- *
- *    The number part is a direct readout of the 6 digit lot number
- *    The alpha is the lo 5 bits of wafer number and XY coords in printable ASCII
- *    Refer to NVM_PROD_SIGNATURES_t in iox192a3.h for details.
- */
-enum { 
-    LOTNUM0=8,  // Lot Number Byte 0, ASCII 
-    LOTNUM1,    // Lot Number Byte 1, ASCII 
-    LOTNUM2,    // Lot Number Byte 2, ASCII 
-    LOTNUM3,    // Lot Number Byte 3, ASCII 
-    LOTNUM4,    // Lot Number Byte 4, ASCII 
-    LOTNUM5,    // Lot Number Byte 5, ASCII 
-    WAFNUM =16, // Wafer Number 
-    COORDX0=18, // Wafer Coordinate X Byte 0 
-    COORDX1,    // Wafer Coordinate X Byte 1 
-    COORDY0,    // Wafer Coordinate Y Byte 0 
-    COORDY1,    // Wafer Coordinate Y Byte 1 
-}; 
-
-void sys_get_id(char *id)
-{
-    char printable[33] = {"ABCDEFGHJKLMNPQRSTUVWXYZ23456789"};
-    uint8_t i;
-
-    NVM_CMD = NVM_CMD_READ_CALIB_ROW_gc;     // Load NVM Command register to read the calibration row
-
-    for (i=0; i<6; i++) {
-        id[i] = pgm_read_byte(LOTNUM0 + i);
-    }
-    id[i++] = '-';
-    id[i++] = printable[(pgm_read_byte(WAFNUM) & 0x1F)];
-    id[i++] = printable[(pgm_read_byte(COORDX0) & 0x1F)];
-//    id[i++] = printable[(pgm_read_byte(COORDX1) & 0x1F)];
-    id[i++] = printable[(pgm_read_byte(COORDY0) & 0x1F)];
-//    id[i++] = printable[(pgm_read_byte(COORDY1) & 0x1F)];
-    id[i] = 0;
-
-    NVM_CMD = NVM_CMD_NO_OPERATION_gc;          // Clean up NVM Command register 
-}
diff --git a/src/system.h b/src/system.h
deleted file mode 100644 (file)
index cf8022d..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * system.h - system hardware device configuration values 
- * Part of TinyG project
- *
- * Copyright (c) 2010 - 2012 Alden S. Hart Jr.
- *
- * 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 <http://www.gnu.org/licenses/>.
- *
- * 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.
- */
-/*
- * INTERRUPT USAGE - TinyG uses a lot of them all over the place
- *
- *    HI    Stepper DDA pulse generation         (set in stepper.h)
- *    HI    Stepper load routine SW interrupt    (set in stepper.h)
- *    HI    Dwell timer counter                  (set in stepper.h)
- *    LO    Segment execution SW interrupt       (set in stepper.h)
- *   MED    GPIO1 switch port                    (set in gpio.h)
- *   MED    Serial RX                            (set in usart.c)
- *    LO    Serial TX                            (set in usart.c)
- *    LO    Real time clock interrupt            (set in xmega_rtc.h)
- */
-#ifndef system_h
-#define system_h
-
-void sys_init();                    // master hardware init
-void sys_port_bindings(float hw_version);
-void sys_get_id(char *id);
-
-#define SYS_ID_LEN 12                    // length of system ID string from sys_get_id()
-
-// Clock Crystal Config. Pick one:
-//#define __CLOCK_INTERNAL_32MHZ TRUE    // use internal oscillator
-//#define __CLOCK_EXTERNAL_8MHZ    TRUE    // uses PLL to provide 32 MHz system clock
-#define __CLOCK_EXTERNAL_16MHZ TRUE        // uses PLL to provide 32 MHz system clock
-
-/*** Motor, output bit & switch port assignments ***
- *** These are not all the same, and must line up in multiple places in gpio.h ***
- * Sorry if this is confusing - it's a board routing issue
- */
-#define PORT_MOTOR_1    PORTA            // motors mapped to ports
-#define PORT_MOTOR_2     PORTF
-#define PORT_MOTOR_3    PORTE
-#define PORT_MOTOR_4    PORTD
-
-#define PORT_SWITCH_X     PORTA            // Switch axes mapped to ports
-#define PORT_SWITCH_Y     PORTD
-#define PORT_SWITCH_Z     PORTE
-#define PORT_SWITCH_A     PORTF
-
-#define PORT_OUT_V7_X    PORTA            // v7 mapping - Output bits mapped to ports
-#define PORT_OUT_V7_Y     PORTF
-#define PORT_OUT_V7_Z    PORTD
-#define PORT_OUT_V7_A    PORTE
-
-#define PORT_OUT_V6_X    PORTA            // v6 and earlier mapping - Output bits mapped to ports
-#define PORT_OUT_V6_Y     PORTF
-#define PORT_OUT_V6_Z    PORTE
-#define PORT_OUT_V6_A    PORTD
-
-// These next four must be changed when the PORT_MOTOR_* definitions change!
-#define PORTCFG_VP0MAP_PORT_MOTOR_1_gc PORTCFG_VP0MAP_PORTA_gc
-#define PORTCFG_VP1MAP_PORT_MOTOR_2_gc PORTCFG_VP1MAP_PORTF_gc
-#define PORTCFG_VP2MAP_PORT_MOTOR_3_gc PORTCFG_VP2MAP_PORTE_gc
-#define PORTCFG_VP3MAP_PORT_MOTOR_4_gc PORTCFG_VP3MAP_PORTD_gc
-
-#define PORT_MOTOR_1_VPORT    VPORT0
-#define PORT_MOTOR_2_VPORT    VPORT1
-#define PORT_MOTOR_3_VPORT    VPORT2
-#define PORT_MOTOR_4_VPORT    VPORT3
-
-/*
- * Port setup - Stepper / Switch Ports:
- *    b0    (out) step            (SET is step,  CLR is rest)
- *    b1    (out) direction        (CLR = Clockwise)
- *    b2    (out) motor enable     (CLR = Enabled)
- *    b3    (out) microstep 0 
- *    b4    (out) microstep 1
- *    b5    (out) output bit for GPIO port1
- *    b6    (in) min limit switch on GPIO 2 (note: motor controls and GPIO2 port mappings are not the same)
- *    b7    (in) max limit switch on GPIO 2 (note: motor controls and GPIO2 port mappings are not the same)
- */
-#define MOTOR_PORT_DIR_gm 0x3F    // dir settings: lower 6 out, upper 2 in
-
-enum cfgPortBits {            // motor control port bit positions
-    STEP_BIT_bp = 0,        // bit 0
-    DIRECTION_BIT_bp,        // bit 1
-    MOTOR_ENABLE_BIT_bp,    // bit 2
-    MICROSTEP_BIT_0_bp,        // bit 3
-    MICROSTEP_BIT_1_bp,        // bit 4
-    GPIO1_OUT_BIT_bp,        // bit 5 (4 gpio1 output bits; 1 from each axis)
-    SW_MIN_BIT_bp,            // bit 6 (4 input bits for homing/limit switches)
-    SW_MAX_BIT_bp            // bit 7 (4 input bits for homing/limit switches)
-};
-
-#define STEP_BIT_bm            (1<<STEP_BIT_bp)
-#define DIRECTION_BIT_bm    (1<<DIRECTION_BIT_bp)
-#define MOTOR_ENABLE_BIT_bm (1<<MOTOR_ENABLE_BIT_bp)
-#define MICROSTEP_BIT_0_bm    (1<<MICROSTEP_BIT_0_bp)
-#define MICROSTEP_BIT_1_bm    (1<<MICROSTEP_BIT_1_bp)
-#define GPIO1_OUT_BIT_bm    (1<<GPIO1_OUT_BIT_bp)    // spindle and coolant output bits
-#define SW_MIN_BIT_bm        (1<<SW_MIN_BIT_bp)        // minimum switch inputs
-#define SW_MAX_BIT_bm        (1<<SW_MAX_BIT_bp)        // maximum switch inputs
-
-/* Bit assignments for GPIO1_OUTs for spindle, PWM and coolant */
-
-#define SPINDLE_BIT            0x08        // spindle on/off
-#define SPINDLE_DIR            0x04        // spindle direction, 1=CW, 0=CCW
-#define SPINDLE_PWM            0x02        // spindle PWMs output bit
-#define MIST_COOLANT_BIT    0x01        // coolant on/off - these are the same due to limited ports
-#define FLOOD_COOLANT_BIT    0x01        // coolant on/off
-
-#define SPINDLE_LED            0
-#define SPINDLE_DIR_LED        1
-#define SPINDLE_PWM_LED        2
-#define COOLANT_LED            3
-
-#define INDICATOR_LED        SPINDLE_DIR_LED    // can use the spindle direction as an indicator LED
-
-/* Timer assignments - see specific modules for details) */
-
-#define TIMER_DDA            TCC0        // DDA timer     (see stepper.h)
-#define TIMER_DWELL             TCD0        // Dwell timer    (see stepper.h)
-#define TIMER_LOAD            TCE0        // Loader timer    (see stepper.h)
-#define TIMER_EXEC            TCF0        // Exec timer    (see stepper.h)
-#define TIMER_5                TCC1        // unallocated timer
-#define TIMER_PWM1            TCD1        // PWM timer #1 (see pwm.c)
-#define TIMER_PWM2            TCE1        // PWM timer #2    (see pwm.c)
-
-
-/**** Device singleton - global structure to allow iteration through similar devices ****/
-/*
-    Ports are shared between steppers and GPIO so we need a global struct.
-    Each xmega port has 3 bindings; motors, switches and the output bit
-
-    The initialization sequence is important. the order is:
-        - sys_init()    binds all ports to the device struct
-        - st_init()     sets IO directions and sets stepper VPORTS and stepper specific functions
-
-    Care needs to be taken in routines that use ports not to write to bits that are 
-    not assigned to the designated function - ur unpredicatable results will occur
-*/
-
-typedef struct deviceSingleton {
-    PORT_t *st_port[MOTORS];    // bindings for stepper motor ports (stepper.c)
-    PORT_t *sw_port[MOTORS];    // bindings for switch ports (GPIO2)
-    PORT_t *out_port[MOTORS];    // bindings for output ports (GPIO1)
-} deviceSingleton_t;
-deviceSingleton_t device;
-
-#endif