From: Joseph Coffland Date: Thu, 31 Dec 2015 03:43:16 +0000 (-0800) Subject: More cleanup X-Git-Url: https://git.buildbotics.com/?a=commitdiff_plain;h=c24240fdf9080be3a9621376a8ff87b5da3ef5c9;p=bbctrl-firmware More cleanup --- diff --git a/src/hardware.c b/src/hardware.c index df7ac08..8827f67 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -28,7 +28,7 @@ #include // 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" @@ -36,43 +36,34 @@ #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 diff --git a/src/hardware.h b/src/hardware.h index 0061ddf..0cf848f 100644 --- a/src/hardware.h +++ b/src/hardware.h @@ -52,20 +52,20 @@ /*--- 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<. - * - * 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 -#include -#include - -#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 index cf8022d..0000000 --- a/src/system.h +++ /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 . - * - * 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<