From 1cc80c09b4e1be725de7c9909b4b10f9ef1e0eed Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Tue, 29 Dec 2015 19:40:58 -0800 Subject: [PATCH] Removed dead code --- Makefile | 2 +- src/canonical_machine.c | 47 +---- src/canonical_machine.h | 11 +- src/config.c | 19 +-- src/config.h | 8 - src/config_app.c | 53 +----- src/config_app.h | 8 - src/controller.c | 95 +---------- src/controller.h | 8 - src/cycle_homing.c | 101 +---------- src/cycle_jogging.c | 19 --- src/encoder.c | 25 --- src/encoder.h | 8 - src/gcode_parser.c | 19 --- src/gcode_parser.h | 8 - src/gpio.c | 15 +- src/hardware.c | 50 +----- src/help.c | 8 - src/help.h | 8 - src/json_parser.c | 8 - src/json_parser.h | 8 - src/kinematics.c | 38 ----- src/kinematics.h | 12 -- src/main.c | 68 +------- src/persistence.c | 63 +------ src/plan_arc.c | 98 +---------- src/plan_exec.c | 9 +- src/plan_line.c | 16 +- src/planner.c | 42 +---- src/planner.h | 12 +- src/pwm.c | 51 +----- src/pwm.h | 12 +- src/report.c | 30 +--- src/report.h | 9 - src/settings.h | 1 - src/spindle.c | 23 +-- src/spindle.h | 12 -- src/stepper.c | 370 +--------------------------------------- src/stepper.h | 11 +- src/switch.c | 183 +------------------- src/test.h | 22 +-- src/text_parser.c | 8 - src/text_parser.h | 8 - src/tinyg.h | 85 +-------- src/util.c | 54 +----- src/util.h | 22 --- src/xio.c | 4 +- src/xio.h | 1 - 48 files changed, 61 insertions(+), 1731 deletions(-) diff --git a/Makefile b/Makefile index 2ff9b88..d986f95 100755 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ COMMON = -mmcu=$(MCU) CFLAGS += $(COMMON) CFLAGS += -gdwarf-2 -std=gnu99 -Wall -DF_CPU=$(CLOCK)UL -Os -funsigned-char CFLAGS += -funsigned-bitfields -fpack-struct -fshort-enums -CFLAGS += -MD -MP -MT $(*F).o -MF build/dep/$(@F).d +CFLAGS += -MD -MP -MT $@ -MF build/dep/$(@F).d # Linker flags LDFLAGS += $(COMMON) -Wl,-u,vfprintf -lprintf_flt -lm -Wl,-Map=$(PROJECT).map diff --git a/src/canonical_machine.c b/src/canonical_machine.c index 94fa711..986c57e 100755 --- a/src/canonical_machine.c +++ b/src/canonical_machine.c @@ -101,11 +101,7 @@ #include "hardware.h" #include "util.h" #include "xio.h" // for serial queue flush -/* -#ifdef __cplusplus -extern "C"{ -#endif -*/ + /*********************************************************************************** **** STRUCTURE ALLOCATIONS ******************************************************** ***********************************************************************************/ @@ -379,10 +375,8 @@ void cm_update_model_position_from_runtime() { copy_vector(cm.gmx.position, mr.g stat_t cm_deferred_write_callback() { if ((cm.cycle_state == CYCLE_OFF) && (cm.deferred_write_flag == true)) { -#ifdef __AVR - if (xio_isbusy()) return (STAT_OK); // don't write back if serial RX is not empty -#endif - cm.deferred_write_flag = false; + if (xio_isbusy()) return (STAT_OK); // don't write back if serial RX is not empty + cm.deferred_write_flag = false; nvObj_t nv; for (uint8_t i=1; i<=COORDS; i++) { for (uint8_t j=0; jindex = 0; // this will read the first record in NVM read_persistent_value(nv); @@ -141,7 +130,6 @@ void config_init() } sr_init_status_report(); } -#endif } /* @@ -488,7 +476,6 @@ uint8_t nv_get_type(nvObj_t *nv) * * On the AVR this will save a little static RAM. The "msg" string will occupy flash * as an initializer and be instantiated in stack RAM when the function executes. - * On the ARM (however) this will put the string into flash and skip RAM allocation. */ void nv_get_nvObj(nvObj_t *nv) @@ -716,7 +703,3 @@ void nv_dump_nv(nvObj_t *nv) nv->token, (char *)nv->stringp); } - -#ifdef __cplusplus -} -#endif // __cplusplus diff --git a/src/config.h b/src/config.h index ffc80cb..1ec7da8 100755 --- a/src/config.h +++ b/src/config.h @@ -32,10 +32,6 @@ #include "config_app.h" // is present at the end of this file */ -#ifdef __cplusplus -extern "C"{ -#endif - /**** Config System Overview and Usage *** * * --- Config objects and the config list --- @@ -373,8 +369,4 @@ void nv_dump_nv(nvObj_t *nv); *********************************************************************************************/ #include "config_app.h" -#ifdef __cplusplus -} -#endif - #endif // End of include guard: CONFIG_H_ONCE diff --git a/src/config_app.c b/src/config_app.c index be7d08f..3a84c50 100755 --- a/src/config_app.c +++ b/src/config_app.c @@ -45,10 +45,6 @@ #include "network.h" #include "xio.h" -#ifdef __cplusplus -extern "C"{ -#endif - /*** structures ***/ cfgParameters_t cfg; // application specific configuration parameters @@ -212,9 +208,6 @@ const cfgItem_t cfgArray[] PROGMEM = { { "1","1mi",_fip, 0, st_print_mi, get_ui8, st_set_mi, (float *)&st_cfg.mot[MOTOR_1].microsteps, M1_MICROSTEPS }, { "1","1po",_fip, 0, st_print_po, get_ui8, set_01, (float *)&st_cfg.mot[MOTOR_1].polarity, M1_POLARITY }, { "1","1pm",_fip, 0, st_print_pm, get_ui8, st_set_pm, (float *)&st_cfg.mot[MOTOR_1].power_mode, M1_POWER_MODE }, -#ifdef __ARM - { "1","1pl",_fip, 3, st_print_pl, get_flt, st_set_pl, (float *)&st_cfg.mot[MOTOR_1].power_level,M1_POWER_LEVEL }, -#endif #if (MOTORS >= 2) { "2","2ma",_fip, 0, st_print_ma, get_ui8, set_ui8, (float *)&st_cfg.mot[MOTOR_2].motor_map, M2_MOTOR_MAP }, { "2","2sa",_fip, 3, st_print_sa, get_flt, st_set_sa, (float *)&st_cfg.mot[MOTOR_2].step_angle, M2_STEP_ANGLE }, @@ -222,9 +215,6 @@ const cfgItem_t cfgArray[] PROGMEM = { { "2","2mi",_fip, 0, st_print_mi, get_ui8, st_set_mi, (float *)&st_cfg.mot[MOTOR_2].microsteps, M2_MICROSTEPS }, { "2","2po",_fip, 0, st_print_po, get_ui8, set_01, (float *)&st_cfg.mot[MOTOR_2].polarity, M2_POLARITY }, { "2","2pm",_fip, 0, st_print_pm, get_ui8, st_set_pm, (float *)&st_cfg.mot[MOTOR_2].power_mode, M2_POWER_MODE }, -#ifdef __ARM - { "2","2pl",_fip, 3, st_print_pl, get_flt, st_set_pl, (float *)&st_cfg.mot[MOTOR_2].power_level,M2_POWER_LEVEL}, -#endif #endif #if (MOTORS >= 3) { "3","3ma",_fip, 0, st_print_ma, get_ui8, set_ui8, (float *)&st_cfg.mot[MOTOR_3].motor_map, M3_MOTOR_MAP }, @@ -233,9 +223,6 @@ const cfgItem_t cfgArray[] PROGMEM = { { "3","3mi",_fip, 0, st_print_mi, get_ui8, st_set_mi, (float *)&st_cfg.mot[MOTOR_3].microsteps, M3_MICROSTEPS }, { "3","3po",_fip, 0, st_print_po, get_ui8, set_01, (float *)&st_cfg.mot[MOTOR_3].polarity, M3_POLARITY }, { "3","3pm",_fip, 0, st_print_pm, get_ui8, st_set_pm, (float *)&st_cfg.mot[MOTOR_3].power_mode, M3_POWER_MODE }, -#ifdef __ARM - { "3","3pl",_fip, 3, st_print_pl, get_flt, st_set_pl, (float *)&st_cfg.mot[MOTOR_3].power_level,M3_POWER_LEVEL }, -#endif #endif #if (MOTORS >= 4) { "4","4ma",_fip, 0, st_print_ma, get_ui8, set_ui8, (float *)&st_cfg.mot[MOTOR_4].motor_map, M4_MOTOR_MAP }, @@ -244,9 +231,6 @@ const cfgItem_t cfgArray[] PROGMEM = { { "4","4mi",_fip, 0, st_print_mi, get_ui8, st_set_mi, (float *)&st_cfg.mot[MOTOR_4].microsteps, M4_MICROSTEPS }, { "4","4po",_fip, 0, st_print_po, get_ui8, set_01, (float *)&st_cfg.mot[MOTOR_4].polarity, M4_POLARITY }, { "4","4pm",_fip, 0, st_print_pm, get_ui8, st_set_pm, (float *)&st_cfg.mot[MOTOR_4].power_mode, M4_POWER_MODE }, -#ifdef __ARM - { "4","4pl",_fip, 3, st_print_pl, get_flt, st_set_pl, (float *)&st_cfg.mot[MOTOR_4].power_level,M4_POWER_LEVEL }, -#endif #endif #if (MOTORS >= 5) { "5","5ma",_fip, 0, st_print_ma, get_ui8, set_ui8, (float *)&st_cfg.mot[MOTOR_5].motor_map, M5_MOTOR_MAP }, @@ -255,9 +239,6 @@ const cfgItem_t cfgArray[] PROGMEM = { { "5","5mi",_fip, 0, st_print_mi, get_ui8, st_set_mi, (float *)&st_cfg.mot[MOTOR_5].microsteps, M5_MICROSTEPS }, { "5","5po",_fip, 0, st_print_po, get_ui8, set_01, (float *)&st_cfg.mot[MOTOR_5].polarity, M5_POLARITY }, { "5","5pm",_fip, 0, st_print_pm, get_ui8, st_set_pm, (float *)&st_cfg.mot[MOTOR_5].power_mode, M5_POWER_MODE }, -#ifdef __ARM - { "5","5pl",_fip, 3, st_print_pl, get_flt, st_set_pl, (float *)&st_cfg.mot[MOTOR_5].power_level,M5_POWER_LEVEL }, -#endif #endif #if (MOTORS >= 6) { "6","6ma",_fip, 0, st_print_ma, get_ui8, set_ui8, (float *)&st_cfg.mot[MOTOR_6].motor_map, M6_MOTOR_MAP }, @@ -266,9 +247,6 @@ const cfgItem_t cfgArray[] PROGMEM = { { "6","6mi",_fip, 0, st_print_mi, get_ui8, st_set_mi, (float *)&st_cfg.mot[MOTOR_6].microsteps, M6_MICROSTEPS }, { "6","6po",_fip, 0, st_print_po, get_ui8, set_01, (float *)&st_cfg.mot[MOTOR_6].polarity, M6_POLARITY }, { "6","6pm",_fip, 0, st_print_pm, get_ui8, st_set_pm, (float *)&st_cfg.mot[MOTOR_6].power_mode, M6_POWER_MODE }, -#ifdef __ARM - { "6","6pl",_fip, 3, st_print_pl, get_flt, st_set_pl, (float *)&st_cfg.mot[MOTOR_6].power_level,M6_POWER_LEVEL }, -#endif #endif // Axis parameters { "x","xam",_fip, 0, cm_print_am, cm_get_am, cm_set_am, (float *)&cm.a[AXIS_X].axis_mode, X_AXIS_MODE }, @@ -348,15 +326,6 @@ const cfgItem_t cfgArray[] PROGMEM = { { "b","bjm",_fip, 0, cm_print_jm, get_flt, cm_set_xjm,(float *)&cm.a[AXIS_B].jerk_max, B_JERK_MAX }, { "b","bjd",_fip, 0, cm_print_jd, get_flt, set_flt, (float *)&cm.a[AXIS_B].junction_dev, B_JUNCTION_DEVIATION }, { "b","bra",_fipc, 3, cm_print_ra, get_flt, set_flt, (float *)&cm.a[AXIS_B].radius, B_RADIUS }, -#ifdef __ARM // B axis extended parameters - { "b","asn",_fip, 0, cm_print_sn, get_ui8, sw_set_sw, (float *)&sw.s[AXIS_B][SW_MIN].mode, B_SWITCH_MODE_MIN }, - { "b","asx",_fip, 0, cm_print_sx, get_ui8, sw_set_sw, (float *)&sw.s[AXIS_B][SW_MAX].mode, B_SWITCH_MODE_MAX }, - { "b","bsv",_fip, 0, cm_print_sv, get_flt, set_flt, (float *)&cm.a[AXIS_B].search_velocity,B_SEARCH_VELOCITY }, - { "b","blv",_fip, 0, cm_print_lv, get_flt, set_flt, (float *)&cm.a[AXIS_B].latch_velocity, B_LATCH_VELOCITY }, - { "b","blb",_fip, 3, cm_print_lb, get_flt, set_flt, (float *)&cm.a[AXIS_B].latch_backoff, B_LATCH_BACKOFF }, - { "b","bzb",_fip, 3, cm_print_zb, get_flt, set_flt, (float *)&cm.a[AXIS_B].zero_backoff, B_ZERO_BACKOFF }, - { "b","bjh",_fip, 0, cm_print_jh, get_flt, cm_set_xjh,(float *)&cm.a[AXIS_B].jerk_homing, B_JERK_HOMING }, -#endif { "c","cam",_fip, 0, cm_print_am, cm_get_am, cm_set_am, (float *)&cm.a[AXIS_C].axis_mode, C_AXIS_MODE }, { "c","cvm",_fip, 0, cm_print_vm, get_flt, set_flt, (float *)&cm.a[AXIS_C].velocity_max, C_VELOCITY_MAX }, @@ -366,15 +335,6 @@ const cfgItem_t cfgArray[] PROGMEM = { { "c","cjm",_fip, 0, cm_print_jm, get_flt, cm_set_xjm,(float *)&cm.a[AXIS_C].jerk_max, C_JERK_MAX }, { "c","cjd",_fip, 0, cm_print_jd, get_flt, set_flt, (float *)&cm.a[AXIS_C].junction_dev, C_JUNCTION_DEVIATION }, { "c","cra",_fipc, 3, cm_print_ra, get_flt, set_flt, (float *)&cm.a[AXIS_C].radius, C_RADIUS }, -#ifdef __ARM // C axis extended parameters - { "c","csn",_fip, 0, cm_print_sn, get_ui8, sw_set_sw, (float *)&sw.s[AXIS_C][SW_MIN].mode, C_SWITCH_MODE_MIN }, - { "c","csx",_fip, 0, cm_print_sx, get_ui8, sw_set_sw, (float *)&sw.s[AXIS_C][SW_MAX].mode, C_SWITCH_MODE_MAX }, - { "c","csv",_fip, 0, cm_print_sv, get_flt, set_flt, (float *)&cm.a[AXIS_C].search_velocity,C_SEARCH_VELOCITY }, - { "c","clv",_fip, 0, cm_print_lv, get_flt, set_flt, (float *)&cm.a[AXIS_C].latch_velocity, C_LATCH_VELOCITY }, - { "c","clb",_fip, 3, cm_print_lb, get_flt, set_flt, (float *)&cm.a[AXIS_C].latch_backoff, C_LATCH_BACKOFF }, - { "c","czb",_fip, 3, cm_print_zb, get_flt, set_flt, (float *)&cm.a[AXIS_C].zero_backoff, C_ZERO_BACKOFF }, - { "c","cjh",_fip, 0, cm_print_jh, get_flt, cm_set_xjh,(float *)&cm.a[AXIS_C].jerk_homing, C_JERK_HOMING }, -#endif // PWM settings { "p1","p1frq",_fip, 0, pwm_print_p1frq, get_flt, set_flt,(float *)&pwm.c[PWM_1].frequency, P1_PWM_FREQUENCY }, @@ -901,16 +861,9 @@ static stat_t set_ex(nvObj_t *nv) // enable XON/XOFF or RTS/CTS flow control static stat_t get_rx(nvObj_t *nv) { -#ifdef __AVR - nv->value = (float)xio_get_usb_rx_free(); - nv->valuetype = TYPE_INTEGER; - return (STAT_OK); -#endif -#ifdef __ARM - nv->value = (float)254; // ARM always says the serial buffer is available (max) + nv->value = (float)xio_get_usb_rx_free(); nv->valuetype = TYPE_INTEGER; return (STAT_OK); -#endif } /* run_sx() - send XOFF, XON --- test only @@ -988,7 +941,3 @@ void cfg_print_net(nvObj_t *nv) { text_print_ui8(nv, fmt_net);} void cfg_print_rx(nvObj_t *nv) { text_print_ui8(nv, fmt_rx);} #endif // __TEXT_MODE - -#ifdef __cplusplus -} -#endif diff --git a/src/config_app.h b/src/config_app.h index 8b5eeaa..ef29374 100755 --- a/src/config_app.h +++ b/src/config_app.h @@ -21,10 +21,6 @@ #ifndef CONFIG_APP_H_ONCE #define CONFIG_APP_H_ONCE -#ifdef __cplusplus -extern "C"{ -#endif - /*********************************************************************************** **** APPLICATION_SPECIFIC DEFINITIONS AND SETTINGS ******************************** ***********************************************************************************/ @@ -103,8 +99,4 @@ uint8_t job_report_callback(); #endif // __TEXT_MODE -#ifdef __cplusplus -} -#endif // __cplusplus - #endif //End of include guard: CONFIG_APP_H_ONCE diff --git a/src/controller.c b/src/controller.c index 9a6fb3b..b692de3 100755 --- a/src/controller.c +++ b/src/controller.c @@ -46,10 +46,6 @@ #include "util.h" #include "xio.h" -#ifdef __ARM -#include "Reset.h" -#endif - /*********************************************************************************** **** STRUCTURE ALLOCATIONS ********************************************************* ***********************************************************************************/ @@ -89,19 +85,12 @@ void controller_init(uint8_t std_in, uint8_t std_out, uint8_t std_err) cs.fw_version = TINYG_FIRMWARE_VERSION; cs.hw_platform = TINYG_HARDWARE_PLATFORM; // NB: HW version is set from EEPROM -#ifdef __AVR - cs.state = CONTROLLER_STARTUP; // ready to run startup lines + cs.state = CONTROLLER_STARTUP; // ready to run startup lines xio_set_stdin(std_in); xio_set_stdout(std_out); xio_set_stderr(std_err); cs.default_src = std_in; tg_set_primary_source(cs.default_src); -#endif - -#ifdef __ARM - cs.state = CONTROLLER_NOT_CONNECTED; // find USB next - IndicatorLed.setFrequency(100000); -#endif } /* @@ -182,10 +171,8 @@ static void _controller_HSM() DISPATCH(_sync_to_planner()); // ensure there is at least one free buffer in planning queue DISPATCH(_sync_to_tx_buffer()); // sync with TX buffer (pseudo-blocking) -#ifdef __AVR - DISPATCH(set_baud_callback()); // perform baud rate update (must be after TX sync) -#endif - DISPATCH(_command_dispatch()); // read and execute next command + DISPATCH(set_baud_callback()); // perform baud rate update (must be after TX sync) + DISPATCH(_command_dispatch()); // read and execute next command DISPATCH(_normal_idler()); // blink LEDs slowly to show everything is OK } @@ -200,8 +187,7 @@ static void _controller_HSM() static stat_t _command_dispatch() { -#ifdef __AVR - stat_t status; + stat_t status; // read input line or return if not a completed line // xio_gets() is a non-blocking workalike of fgets() @@ -221,31 +207,6 @@ static stat_t _command_dispatch() } return (status); // Note: STAT_EAGAIN, errors, etc. will drop through } -#endif // __AVR -#ifdef __ARM - // detect USB connection and transition to disconnected state if it disconnected - if (SerialUSB.isConnected() == false) cs.state = CONTROLLER_NOT_CONNECTED; - - // read input line and return if not a completed line - if (cs.state == CONTROLLER_READY) { - if (read_line(cs.in_buf, &cs.read_index, sizeof(cs.in_buf)) != STAT_OK) { - cs.bufp = cs.in_buf; - return (STAT_OK); // This is an exception: returns OK for anything NOT OK, so the idler always runs - } - } else if (cs.state == CONTROLLER_NOT_CONNECTED) { - if (SerialUSB.isConnected() == false) return (STAT_OK); - cm_request_queue_flush(); - rpt_print_system_ready_message(); - cs.state = CONTROLLER_STARTUP; - - } else if (cs.state == CONTROLLER_STARTUP) { // run startup code - cs.state = CONTROLLER_READY; - - } else { - return (STAT_OK); - } - cs.read_index = 0; -#endif // __ARM // set up the buffers cs.linelen = strlen(cs.in_buf)+1; // linelen only tracks primary input @@ -254,7 +215,7 @@ static stat_t _command_dispatch() // dispatch the new text line switch (toupper(*cs.bufp)) { // first char - case '!': { cm_request_feedhold(); break; } // include for AVR diagnostics and ARM serial + case '!': { cm_request_feedhold(); break; } // include for diagnostics case '%': { cm_request_queue_flush(); break; } case '~': { cm_request_cycle_start(); break; } @@ -312,51 +273,7 @@ static stat_t _shutdown_idler() static stat_t _normal_idler() { -#ifdef __ARM - /* - * S-curve heartbeat code. Uses forward-differencing math from the stepper code. - * See plan_line.cpp for explanations. - * Here, the "velocity" goes from 0.0 to 1.0, then back. - * t0 = 0, t1 = 0, t2 = 0.5, and we'll complete the S in 100 segments. - */ - - // These are statics, and the assignments will only evaluate once. - static float indicator_led_value = 0.0; - static float indicator_led_forward_diff_1 = 50.0 * square(1.0/100.0); - static float indicator_led_forward_diff_2 = indicator_led_forward_diff_1 * 2.0; - - - if (SysTickTimer.getValue() > cs.led_timer) { - cs.led_timer = SysTickTimer.getValue() + LED_NORMAL_TIMER / 100; - - indicator_led_value += indicator_led_forward_diff_1; - if (indicator_led_value > 100.0) - indicator_led_value = 100.0; - - if ((indicator_led_forward_diff_2 > 0.0 && indicator_led_value >= 50.0) || (indicator_led_forward_diff_2 < 0.0 && indicator_led_value <= 50.0)) { - indicator_led_forward_diff_2 = -indicator_led_forward_diff_2; - } - else if (indicator_led_value <= 0.0) { - indicator_led_value = 0.0; - - // Reset to account for rounding errors - indicator_led_forward_diff_1 = 50.0 * square(1.0/100.0); - } else { - indicator_led_forward_diff_1 += indicator_led_forward_diff_2; - } - - IndicatorLed = indicator_led_value/100.0; - } -#endif -#ifdef __AVR -/* - if (SysTickTimer_getValue() > cs.led_timer) { - cs.led_timer = SysTickTimer_getValue() + LED_NORMAL_TIMER; -// IndicatorLed_toggle(); - } -*/ -#endif - return (STAT_OK); + return (STAT_OK); } /* diff --git a/src/controller.h b/src/controller.h index d079391..f18a530 100755 --- a/src/controller.h +++ b/src/controller.h @@ -28,10 +28,6 @@ #ifndef CONTROLLER_H_ONCE #define CONTROLLER_H_ONCE -#ifdef __cplusplus -extern "C"{ -#endif - #define INPUT_BUFFER_LEN 255 // text buffer size (255 max) #define SAVED_BUFFER_LEN 100 // saved buffer size (for reporting only) #define OUTPUT_BUFFER_LEN 512 // text buffer size @@ -101,8 +97,4 @@ void tg_reset_source(void); void tg_set_primary_source(uint8_t dev); void tg_set_secondary_source(uint8_t dev); -#ifdef __cplusplus -} -#endif - #endif // End of include guard: CONTROLLER_H_ONCE diff --git a/src/cycle_homing.c b/src/cycle_homing.c index db6d75e..ecf20f1 100755 --- a/src/cycle_homing.c +++ b/src/cycle_homing.c @@ -35,10 +35,6 @@ #include "switch.h" #include "report.h" -#ifdef __cplusplus -extern "C"{ -#endif - /**** Homing singleton structure ****/ struct hmHomingSingleton { // persistent homing runtime variables @@ -211,24 +207,6 @@ static stat_t _set_homing_func(stat_t (*func)(int8_t axis)) return (STAT_EAGAIN); } -/* UNUSED - -static void _trigger_feedhold(switch_t *s) -{ - cm_request_feedhold(); -} - -static void _bind_switch_settings(switch_t *s) -{ - hm.switch_saved_on_trailing = s->on_trailing; - s->on_trailing = _trigger_feedhold; // bind feedhold to trailing edge -} - -static void _restore_switch_settings(switch_t *s) -{ - s->on_trailing = hm.switch_saved_on_trailing; -} -*/ static stat_t _homing_axis_start(int8_t axis) { // get the first or next axis @@ -484,22 +462,7 @@ static stat_t _homing_finalize_exit(int8_t axis) // third part of return to ho static int8_t _get_next_axis(int8_t axis) { #if (HOMING_AXES <= 4) -// uint8_t axis; -// for(axis = AXIS_X; axis < HOMING_AXES; axis++) -// if(fp_TRUE(cm.gf.target[axis])) break; -// if(axis >= HOMING_AXES) return -2; -// switch(axis) { -// case -1: if (fp_TRUE(cm.gf.target[AXIS_Z])) return (AXIS_Z); -// case AXIS_Z: if (fp_TRUE(cm.gf.target[AXIS_X])) return (AXIS_X); -// case AXIS_X: if (fp_TRUE(cm.gf.target[AXIS_Y])) return (AXIS_Y); -// case AXIS_Y: if (fp_TRUE(cm.gf.target[AXIS_A])) return (AXIS_A); -//#if (HOMING_AXES > 4) -// case AXIS_A: if (fp_TRUE(cm.gf.target[AXIS_B])) return (AXIS_B); -// case AXIS_B: if (fp_True(cm.gf.target[AXIS_C])) return (AXIS_C); -//#endif -// default: return -1; -// } - if (axis == -1) { // inelegant brute force solution + if (axis == -1) { // inelegant brute force solution if (fp_TRUE(cm.gf.target[AXIS_Z])) return (AXIS_Z); if (fp_TRUE(cm.gf.target[AXIS_X])) return (AXIS_X); if (fp_TRUE(cm.gf.target[AXIS_Y])) return (AXIS_Y); @@ -552,65 +515,3 @@ static int8_t _get_next_axis(int8_t axis) #endif } - -/* - * _get_next_axes() - return next axis in sequence based on axis in arg - * - * Accepts "axis" arg as the current axis; or -1 to retrieve the first axis - * Returns next axis based on "axis" argument - * Returns -1 when all axes have been processed - * Returns -2 if no axes are specified (Gcode calling error) - * - * hm.axis2 is set to the secondary axis if axis is a dual axis - * hm.axis2 is set to -1 otherwise - * - * Isolating this function facilitates implementing more complex and - * user-specified axis homing orders - * - * Note: the logic to test for disabled or inhibited axes will allow the - * following condition to occur: A single axis is specified but it is - * disabled or inhibited - homing will say that it was successfully homed. - */ - -// _run_homing_dual_axis() - kernal routine for running homing on a dual axis -//static stat_t _run_homing_dual_axis(int8_t axis) { return (STAT_OK);} - -/* -int8_t _get_next_axes(int8_t axis) -{ - int8_t next_axis; - hm.axis2 = -1; - - // Scan target vector for case where no valid axes are specified - for (next_axis = 0; next_axis < AXES; next_axis++) { - if ((fp_TRUE(cm.gf.target[next_axis])) && - (cm.a[next_axis].axis_mode != AXIS_INHIBITED) && - (cm.a[next_axis].axis_mode != AXIS_DISABLED)) { - break; - } - } - if (next_axis == AXES) { -// fprintf_P(stderr, PSTR("***** Homing failed: none or disabled/inhibited axes specified\n")); - return (-2); // didn't find any axes to process - } - - // Scan target vector from the current axis to find next axis or the end - for (next_axis = ++axis; next_axis < AXES; next_axis++) { - if (fp_TRUE(cm.gf.target[next_axis])) { - if ((cm.a[next_axis].axis_mode == AXIS_INHIBITED) || - (cm.a[next_axis].axis_mode == AXIS_DISABLED)) { // Skip if axis disabled or inhibited - continue; - } - break; // got a good one - } - return (-1); // you are done - } - - // Got a valid axis. Find out if it's a dual - return (STAT_OK); -} -*/ - -#ifdef __cplusplus -} -#endif diff --git a/src/cycle_jogging.c b/src/cycle_jogging.c index 5ee177f..496bd5b 100755 --- a/src/cycle_jogging.c +++ b/src/cycle_jogging.c @@ -32,10 +32,6 @@ #include "planner.h" #include "util.h" -#ifdef __cplusplus -extern "C"{ -#endif - /**** Jogging singleton structure ****/ struct jmJoggingSingleton { // persistent jogging runtime variables @@ -208,18 +204,3 @@ static stat_t _jogging_finalize_exit(int8_t axis) // finish a jog printf("{\"jog\":0}\n"); return (STAT_OK); } - -/* -static stat_t _jogging_error_exit(int8_t axis) -{ - // Generate the warning message. Since the error exit returns via the jogging callback - // - and not the main controller - it requires its own display processing -// nv_reset_nv_list(); - _jogging_finalize_exit(axis); // clean up - return (STAT_JOGGING_CYCLE_FAILED); // jogging state -} -*/ - -#ifdef __cplusplus -} -#endif diff --git a/src/encoder.c b/src/encoder.c index 8418673..779c6ae 100755 --- a/src/encoder.c +++ b/src/encoder.c @@ -29,17 +29,10 @@ #include "config.h" #include "encoder.h" -#ifdef __cplusplus -extern "C"{ -#endif - /**** Allocate Structures ****/ enEncoders_t en; -/************************************************************************************ - **** CODE ************************************************************************** - ************************************************************************************/ /* * encoder_init() - initialize encoders @@ -96,21 +89,3 @@ float en_read_encoder(uint8_t motor) { return((float)en.en[motor].encoder_steps); } - -/*********************************************************************************** - * CONFIGURATION AND INTERFACE FUNCTIONS - * Functions to get and set variables from the cfgArray table - ***********************************************************************************/ - -/*********************************************************************************** - * TEXT MODE SUPPORT - * Functions to print variables from the cfgArray table - ***********************************************************************************/ - -#ifdef __TEXT_MODE - -#endif // __TEXT_MODE - -#ifdef __cplusplus -} -#endif diff --git a/src/encoder.h b/src/encoder.h index 2570943..572a774 100755 --- a/src/encoder.h +++ b/src/encoder.h @@ -88,10 +88,6 @@ #ifndef ENCODER_H_ONCE #define ENCODER_H_ONCE -#ifdef __cplusplus -extern "C"{ -#endif - /**** Configs and Constants ****/ /**** Macros ****/ @@ -128,7 +124,3 @@ void en_set_encoder_steps(uint8_t motor, float steps); float en_read_encoder(uint8_t motor); #endif // End of include guard: ENCODER_H_ONCE - -#ifdef __cplusplus -} -#endif diff --git a/src/gcode_parser.c b/src/gcode_parser.c index 2e30ed4..31be692 100755 --- a/src/gcode_parser.c +++ b/src/gcode_parser.c @@ -25,10 +25,6 @@ #include "util.h" #include "xio.h" // for char definitions -#ifdef __cplusplus -extern "C"{ -#endif - struct gcodeParserSingleton { // struct to manage globals uint8_t modals[MODAL_GROUP_COUNT];// collects modal groups in a block }; struct gcodeParserSingleton gp; @@ -530,18 +526,3 @@ stat_t gc_run_gc(nvObj_t *nv) { return(gc_gcode_parser(*nv->stringp)); } - -/*********************************************************************************** - * TEXT MODE SUPPORT - * Functions to print variables from the cfgArray table - ***********************************************************************************/ - -#ifdef __TEXT_MODE - -// no text mode functions here. Move along - -#endif // __TEXT_MODE - -#ifdef __cplusplus -} -#endif diff --git a/src/gcode_parser.h b/src/gcode_parser.h index 5b0ef09..0796fdb 100755 --- a/src/gcode_parser.h +++ b/src/gcode_parser.h @@ -20,10 +20,6 @@ #ifndef GCODE_PARSER_H_ONCE #define GCODE_PARSER_H_ONCE -#ifdef __cplusplus -extern "C"{ -#endif - /* * Global Scope Functions */ @@ -31,8 +27,4 @@ stat_t gc_gcode_parser(char_t *block); stat_t gc_get_gc(nvObj_t *nv); stat_t gc_run_gc(nvObj_t *nv); -#ifdef __cplusplus -} -#endif - #endif // End of include guard: GCODE_PARSER_H_ONCE diff --git a/src/gpio.c b/src/gpio.c index fa29ba8..6551e19 100755 --- a/src/gpio.c +++ b/src/gpio.c @@ -53,7 +53,6 @@ #include "config.h" #include "controller.h" #include "hardware.h" -//#include "switch.h" #include "gpio.h" #include "canonical_machine.h" #include "xio.h" // signals @@ -97,12 +96,7 @@ void IndicatorLed_toggle() void gpio_led_on(uint8_t led) { -// if (led == 0) return (gpio_set_bit_on(0x08)); -// if (led == 1) return (gpio_set_bit_on(0x04)); -// if (led == 2) return (gpio_set_bit_on(0x02)); -// if (led == 3) return (gpio_set_bit_on(0x01)); - - if (led == 0) gpio_set_bit_on(0x08); else + if (led == 0) gpio_set_bit_on(0x08); else if (led == 1) gpio_set_bit_on(0x04); else if (led == 2) gpio_set_bit_on(0x02); else if (led == 3) gpio_set_bit_on(0x01); @@ -110,12 +104,7 @@ void gpio_led_on(uint8_t led) void gpio_led_off(uint8_t led) { -// if (led == 0) return (gpio_set_bit_off(0x08)); -// if (led == 1) return (gpio_set_bit_off(0x04)); -// if (led == 2) return (gpio_set_bit_off(0x02)); -// if (led == 3) return (gpio_set_bit_off(0x01)); - - if (led == 0) gpio_set_bit_off(0x08); else + if (led == 0) gpio_set_bit_off(0x08); else if (led == 1) gpio_set_bit_off(0x04); else if (led == 2) gpio_set_bit_off(0x02); else if (led == 3) gpio_set_bit_off(0x01); diff --git a/src/hardware.c b/src/hardware.c index 380d1f1..4cbc537 100755 --- a/src/hardware.c +++ b/src/hardware.c @@ -25,9 +25,7 @@ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifdef __AVR #include // used for software reset -#endif #include "tinyg.h" // #1 #include "config.h" // #2 @@ -35,14 +33,8 @@ #include "switch.h" #include "controller.h" #include "text_parser.h" -#ifdef __AVR #include "xmega/xmega_init.h" #include "xmega/xmega_rtc.h" -#endif - -#ifdef __cplusplus -extern "C"{ -#endif /* * _port_bindings - bind XMEGA ports to hardware - these changed at board revision 7 @@ -51,8 +43,7 @@ extern "C"{ static void _port_bindings(float hw_version) { -#ifdef __AVR - hw.st_port[0] = &PORT_MOTOR_1; + 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; @@ -73,43 +64,26 @@ static void _port_bindings(float hw_version) hw.out_port[2] = &PORT_OUT_V6_Z; hw.out_port[3] = &PORT_OUT_V6_A; } -#endif } void hardware_init() { -#ifdef __AVR - xmega_init(); // set system clock + xmega_init(); // set system clock _port_bindings(TINYG_HARDWARE_VERSION); rtc_init(); // real time counter -#endif } /* * _get_id() - get a human readable signature * - * FOR AVR: * Produce 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 low 5 bits of wafer number and XY coords in printable ASCII * Refer to NVM_PROD_SIGNATURES_t in iox192a3.h for details. - * - * FOR ARM: - * Currently not implemented */ -/* UNUSED -static uint8_t _read_calibration_byte(uint8_t index) -{ - NVM_CMD = NVM_NV_READ_CALIB_ROW_gc; // Load NVM Command register to read the calibration row - uint8_t result = pgm_read_byte(index); - NVM_CMD = NVM_NV_NO_OPERATION_gc; // Clean up NVM Command register - return(result); -} -*/ - enum { LOTNUM0=8, // Lot Number Byte 0, ASCII LOTNUM1, // Lot Number Byte 1, ASCII @@ -126,8 +100,7 @@ enum { static void _get_id(char_t *id) { -#ifdef __AVR - char printable[33] = {"ABCDEFGHJKLMNPQRSTUVWXYZ23456789"}; + char printable[33] = {"ABCDEFGHJKLMNPQRSTUVWXYZ23456789"}; uint8_t i; NVM_CMD = NVM_CMD_READ_CALIB_ROW_gc; // Load NVM Command register to read the calibration row @@ -144,7 +117,6 @@ static void _get_id(char_t *id) id[i] = 0; NVM_CMD = NVM_CMD_NO_OPERATION_gc; // Clean up NVM Command register -#endif } /* @@ -158,10 +130,8 @@ void hw_request_hard_reset() { cs.hard_reset_requested = true; } void hw_hard_reset(void) // software hard reset using the watchdog timer { -#ifdef __AVR - wdt_enable(WDTO_15MS); + wdt_enable(WDTO_15MS); while (true); // loops for about 15ms then resets -#endif } stat_t hw_hard_reset_handler(void) @@ -183,12 +153,11 @@ void hw_request_bootloader() { cs.bootloader_requested = true;} stat_t hw_bootloader_handler(void) { -#ifdef __AVR - if (cs.bootloader_requested == false) + if (cs.bootloader_requested == false) return (STAT_NOOP); cli(); CCPWrite(&RST.CTRL, RST_SWRST_bm); // fire a software reset -#endif + return (STAT_EAGAIN); // never gets here but keeps the compiler happy } @@ -232,8 +201,7 @@ stat_t hw_set_hv(nvObj_t *nv) set_flt(nv); // record the hardware version _port_bindings(nv->value); // reset port bindings switch_init(); // re-initialize the GPIO ports -//++++ gpio_init(); // re-initialize the GPIO ports - return (STAT_OK); + return (STAT_OK); } /*********************************************************************************** @@ -256,7 +224,3 @@ 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 - -#ifdef __cplusplus -} -#endif diff --git a/src/help.c b/src/help.c index 086efdd..d390809 100755 --- a/src/help.c +++ b/src/help.c @@ -22,10 +22,6 @@ #include "report.h" #include "help.h" -#ifdef __cplusplus -extern "C"{ -#endif - // help helper functions (snicker) stat_t help_stub(nvObj_t *nv) {return (STAT_OK);} @@ -166,7 +162,3 @@ return(STAT_OK); } #endif // __HELP_SCREENS - -#ifdef __cplusplus -} -#endif diff --git a/src/help.h b/src/help.h index a8ef7d6..396b65a 100755 --- a/src/help.h +++ b/src/help.h @@ -20,10 +20,6 @@ #ifndef HELP_H_ONCE #define HELP_H_ONCE -#ifdef __cplusplus -extern "C"{ -#endif - #ifdef __HELP_SCREENS stat_t help_general(nvObj_t *nv); @@ -43,8 +39,4 @@ extern "C"{ #endif // __HELP_SCREENS -#ifdef __cplusplus -} -#endif - #endif // End of include guard: HELP_H_ONCE diff --git a/src/json_parser.c b/src/json_parser.c index befa3d4..5f547e0 100755 --- a/src/json_parser.c +++ b/src/json_parser.c @@ -35,10 +35,6 @@ #include "util.h" #include "xio.h" // for char definitions -#ifdef __cplusplus -extern "C"{ -#endif - /**** Allocation ****/ jsSingleton_t js; @@ -604,7 +600,3 @@ void js_print_js(nvObj_t *nv) { text_print_ui8(nv, fmt_js);} void js_print_fs(nvObj_t *nv) { text_print_ui8(nv, fmt_fs);} #endif // __TEXT_MODE - -#ifdef __cplusplus -} -#endif // __cplusplus diff --git a/src/json_parser.h b/src/json_parser.h index 80dfe47..9b73f06 100755 --- a/src/json_parser.h +++ b/src/json_parser.h @@ -28,10 +28,6 @@ #ifndef _JSON_PARSER_H_ONCE #define _JSON_PARSER_H_ONCE -#ifdef __cplusplus -extern "C"{ -#endif - /**** Configs, Definitions and Structures ****/ /* JSON array definitions / revisions */ @@ -110,8 +106,4 @@ stat_t json_set_jv(nvObj_t *nv); #endif // __TEXT_MODE -#ifdef __cplusplus -} -#endif - #endif // End of include guard: JSON_PARSER_H_ONCE diff --git a/src/kinematics.c b/src/kinematics.c index d737e88..806d892 100755 --- a/src/kinematics.c +++ b/src/kinematics.c @@ -31,11 +31,6 @@ #include "stepper.h" #include "kinematics.h" -#ifdef __cplusplus -extern "C"{ -#endif - -//static void _inverse_kinematics(float travel[], float joint[]); /* * ik_kinematics() - wrapper routine for inverse kinematics @@ -72,38 +67,5 @@ void ik_kinematics(const float travel[], float steps[]) if (st_cfg.mot[MOTOR_6].motor_map == axis) { steps[MOTOR_6] = joint[axis] * st_cfg.mot[MOTOR_6].steps_per_unit;} #endif } - -/* The above is a loop unrolled version of this: - for (uint8_t axis=0; axis #include "xmega/xmega_interrupts.h" -#endif // __AVR - -#ifdef __ARM -#include "MotateTimers.h" -using Motate::delay; - -#ifdef __cplusplus -extern "C"{ -#endif // __cplusplus void _init() __attribute__ ((weak)); void _init() {;} void __libc_init_array(void); -#ifdef __cplusplus -} -#endif // __cplusplus -#endif // __ARM - /******************** Application Code ************************/ - -#ifdef __ARM -const Motate::USBSettings_t Motate::USBSettings = { - /*gVendorID = */ 0x1d50, - /*gProductID = */ 0x606d, - /*gProductVersion = */ TINYG_FIRMWARE_VERSION, - /*gAttributes = */ kUSBConfigAttributeSelfPowered, - /*gPowerConsumption = */ 500 -}; - /*gProductVersion = */ //0.1, - -Motate::USBDevice< Motate::USBCDC > usb; -//Motate::USBDevice< Motate::USBCDC, Motate::USBCDC > usb; - -typeof usb._mixin_0_type::Serial &SerialUSB = usb._mixin_0_type::Serial; -//typeof usb._mixin_1_type::Serial &SerialUSB1 = usb._mixin_1_type::Serial; - -MOTATE_SET_USB_VENDOR_STRING( {'S' ,'y', 'n', 't', 'h', 'e', 't', 'o', 's'} ) -MOTATE_SET_USB_PRODUCT_STRING( {'T', 'i', 'n', 'y', 'G', ' ', 'v', '2'} ) -MOTATE_SET_USB_SERIAL_NUMBER_STRING( {'0','0','1'} ) - -Motate::SPI spi; -#endif - -/* - * _system_init() - */ - -void _system_init(void) -{ -#ifdef __ARM - SystemInit(); - - // Disable watchdog - WDT->WDT_MR = WDT_MR_WDDIS; - - // Initialize C library - __libc_init_array(); - - usb.attach(); // USB setup - delay(1000); -#endif -} - -/* - * _application_init() - */ - static void _application_init(void) { // There are a lot of dependencies in the order of these inits. @@ -149,10 +86,7 @@ static void _application_init(void) int main(void) { - // system initialization - _system_init(); - - // TinyG application setup + // TinyG application setup _application_init(); run_canned_startup(); // run any pre-loaded commands diff --git a/src/persistence.c b/src/persistence.c index 718cf78..10471f9 100755 --- a/src/persistence.c +++ b/src/persistence.c @@ -29,33 +29,16 @@ #include "report.h" #include "canonical_machine.h" #include "util.h" - -#ifdef __AVR #include "xmega/xmega_eeprom.h" -#endif - -/*********************************************************************************** - **** STRUCTURE ALLOCATIONS ******************************************************** - ***********************************************************************************/ nvmSingleton_t nvm; -/*********************************************************************************** - **** GENERIC STATIC FUNCTIONS AND VARIABLES *************************************** - ***********************************************************************************/ - - -/*********************************************************************************** - **** CODE ************************************************************************* - ***********************************************************************************/ void persistence_init() { -#ifdef __AVR - nvm.base_addr = NVM_BASE_ADDR; + nvm.base_addr = NVM_BASE_ADDR; nvm.profile_base = 0; -#endif - return; + return; } /************************************************************************************ @@ -65,7 +48,6 @@ void persistence_init() * It's the responsibility of the caller to make sure the index does not exceed range */ -#ifdef __AVR stat_t read_persistent_value(nvObj_t *nv) { nvm.address = nvm.profile_base + (nv->index * NVM_VALUE_LEN); @@ -73,29 +55,12 @@ stat_t read_persistent_value(nvObj_t *nv) memcpy(&nv->value, &nvm.byte_array, NVM_VALUE_LEN); return (STAT_OK); } -#endif // __AVR - -#ifdef __ARM -stat_t read_persistent_value(nvObj_t *nv) -{ - nv->value = 0; - return (STAT_OK); -} -#endif // __ARM -#ifdef __AVR stat_t write_persistent_value(nvObj_t *nv) { if (cm.cycle_state != CYCLE_OFF) return(rpt_exception(STAT_FILE_NOT_OPEN)); // can't write when machine is moving - -/* not needed - if (nv->valuetype == TYPE_FLOAT) { - if (isnan((double)nv->value)) return(rpt_exception(STAT_FLOAT_IS_NAN)); // bad floating point value - if (isinf((double)nv->value)) return(rpt_exception(STAT_FLOAT_IS_INFINITE));// bad floating point value - } -*/ - nvm.tmp_value = nv->value; + nvm.tmp_value = nv->value; ritorno(read_persistent_value(nv)); if ((isnan((double)nv->value)) || (isinf((double)nv->value)) || (fp_NE(nv->value, nvm.tmp_value))) { memcpy(&nvm.byte_array, &nvm.tmp_value, NVM_VALUE_LEN); @@ -105,25 +70,3 @@ stat_t write_persistent_value(nvObj_t *nv) nv->value =nvm.tmp_value; // always restore value return (STAT_OK); } -#endif // __AVR - -#ifdef __ARM -stat_t write_persistent_value(nvObj_t *nv) -{ - if (cm.cycle_state != CYCLE_OFF) - return(rpt_exception(STAT_FILE_NOT_OPEN)); // can't write when machine is moving - -/* not needed - if (nv->valuetype == TYPE_FLOAT) { - if (isnan((double)nv->value)) return(rpt_exception(STAT_FLOAT_IS_NAN)); // bad floating point value - if (isinf((double)nv->value)) return(rpt_exception(STAT_FLOAT_IS_INFINITE));// bad floating point value - } -*/ - return (STAT_OK); -} -#endif // __ARM - -#ifdef __cplusplus -} -#endif - diff --git a/src/plan_arc.c b/src/plan_arc.c index 68b3e1e..0e7d54c 100755 --- a/src/plan_arc.c +++ b/src/plan_arc.c @@ -167,15 +167,7 @@ stat_t cm_arc_feed(float target[], float flags[], // arc endpoints return (STAT_MINIMUM_LENGTH_MOVE); // trap zero length arcs that _compute_arc can throw } -/* // test arc soft limits - stat_t status = _test_arc_soft_limits(); - if (status != STAT_OK) { - cm.gm.motion_mode = MOTION_MODE_CANCEL_MOTION_MODE; - copy_vector(cm.gm.target, cm.gmx.position); // reset model position - return (cm_soft_alarm(status)); - } -*/ - cm_cycle_start(); // if not already started + cm_cycle_start(); // if not already started arc.run_state = MOVE_RUN; // enable arc to be run from the callback cm_finalize_move(); return (STAT_OK); @@ -470,91 +462,3 @@ static void _estimate_arc_time () arc.arc_time = max(arc.arc_time, fabs(arc.linear_travel/cm.a[arc.linear_axis].feedrate_max)); } } - -/* - * _test_arc_soft_limits() - return error status if soft limit is exceeded - * - * Test if arc extends beyond arc plane boundaries set in soft limits. - * - * The arc starting position (P) and target (T) define 2 points that divide the - * arc plane into 9 rectangles. The center of the arc is (C). P and T define the - * endpoints of two possible arcs; one that is less than or equal to 180 degrees (acute) - * and one that is greater than 180 degrees (obtuse), depending on the location of (C). - * - * ------------------------------- plane boundaries in X and Y - * | | | | - * | 1 | 2 | 3 | - * | | | - * --------- P ------------------- - * | | | - * | 4 | 5 | 6 | - * | | | - * ------------------- T --------- - * | C| | C shows one of many possible center locations - * | 7 | 8 | 9 | - * | | | | - * ------------------------------- - * - * C will fall along a diagonal bisecting 7, 5 and 3, but there is some tolerance in the - * circle algorithm that allows C to deviate from the centerline slightly. As the centerline - * approaches the line connecting S and T the acute arcs will be "above" S and T in sections - * 5 or 3, and the obtuse arcs will be "below" in sections 5 or 7. But it's simpler, because - * we know that the arc is > 180 degrees (obtuse) if the angular travel value is > pi. - * - * The example below only tests the X axis (0 plane axis), but testing the other axes is similar - * - * (1) If Cx <= Px and arc is acute; no test is needed - * - * (2) If Cx <= Px and arc is obtuse; test if the radius is greater than - * the distance from Cx to the negative X boundary - * - * (3) If Px < Cx < Tx and arc is acute; test if the radius is greater than - * the distance from Cx to the positive X boundary - * - * (4) If Px < Cx < Tx and arc is obtuse; test if the radius is greater than - * the distance from Cx to the positive X boundary - * - * The arc plane is defined by 0 and 1 depending on G17/G18/G19 plane selected, - * corresponding to arc planes XY, XZ, YZ, respectively. - * - * Must be called with all the following set in the arc struct - * - arc starting position (arc.position) - * - arc ending position (arc.gm.target) - * - arc center (arc.center_0, arc.center_1) - * - arc.radius (arc.radius) - * - arc angular travel in radians (arc.angular_travel) - * - max and min travel in axis 0 and axis 1 (in cm struct) - */ -/* UNUSED -static stat_t _test_arc_soft_limit_plane_axis(float center, uint8_t plane_axis) -{ - if (center <= arc.position[plane_axis]) { - if (arc.angular_travel < M_PI) { // case (1) - return (STAT_OK); - } - if ((center - arc.radius) < cm.a[plane_axis].travel_min) { // case (2) - return (STAT_SOFT_LIMIT_EXCEEDED); - } - } - if ((center + arc.radius) > cm.a[plane_axis].travel_max) { // cases (3) and (4) - return (STAT_SOFT_LIMIT_EXCEEDED); - } - return(STAT_OK); -} - -static stat_t _test_arc_soft_limits() -{ - if (cm.soft_limit_enable == true) { - - // Test if target falls outside boundaries. This is a 3 dimensional test - // so it also checks the linear axis of the arc (helix axis) - ritorno(cm_test_soft_limits(arc.gm.target)); - - // test arc extents - ritorno(_test_arc_soft_limit_plane_axis(arc.center_0, arc.plane_axis_0)); - ritorno(_test_arc_soft_limit_plane_axis(arc.center_1, arc.plane_axis_1)); - } - return(STAT_OK); -} - -*/ \ No newline at end of file diff --git a/src/plan_exec.c b/src/plan_exec.c index 127df52..7454d54 100755 --- a/src/plan_exec.c +++ b/src/plan_exec.c @@ -34,11 +34,7 @@ #include "encoder.h" #include "report.h" #include "util.h" -/* -#ifdef __cplusplus -extern "C"{ -#endif -*/ + // execute routines (NB: These are all called from the LO interrupt) static stat_t _exec_aline_head(void); static stat_t _exec_aline_body(void); @@ -353,9 +349,6 @@ static void _init_forward_diffs(float Vi, float Vt) // F = Vi float h = 1/(mr.segments); -// float h_3 = h * h * h; -// float h_4 = h_3 * h; -// float h_5 = h_4 * h; float Ah_5 = A * h * h * h * h * h; float Bh_4 = B * h * h * h * h; diff --git a/src/plan_line.c b/src/plan_line.c index cea791b..400cda2 100755 --- a/src/plan_line.c +++ b/src/plan_line.c @@ -655,20 +655,8 @@ stat_t mp_plan_hold_callback() // examine and process mr buffer mr_available_length = get_axis_vector_length(mr.target, mr.position); -/* mr_available_length = - (sqrt(square(mr.endpoint[AXIS_X] - mr.position[AXIS_X]) + - square(mr.endpoint[AXIS_Y] - mr.position[AXIS_Y]) + - square(mr.endpoint[AXIS_Z] - mr.position[AXIS_Z]) + - square(mr.endpoint[AXIS_A] - mr.position[AXIS_A]) + - square(mr.endpoint[AXIS_B] - mr.position[AXIS_B]) + - square(mr.endpoint[AXIS_C] - mr.position[AXIS_C]))); - -*/ - - // compute next_segment velocity -// braking_velocity = mr.segment_velocity; -// if (mr.section != SECTION_BODY) { braking_velocity += mr.forward_diff_1;} - braking_velocity = _compute_next_segment_velocity(); + // compute next_segment velocity + braking_velocity = _compute_next_segment_velocity(); braking_length = mp_get_target_length(braking_velocity, 0, bp); // bp is OK to use here // Hack to prevent Case 2 moves for perfect-fit decels. Happens in homing situations diff --git a/src/planner.c b/src/planner.c index e959345..3286a73 100755 --- a/src/planner.c +++ b/src/planner.c @@ -61,13 +61,8 @@ #include "encoder.h" #include "report.h" #include "util.h" -/* -#ifdef __cplusplus -extern "C"{ -#endif -*/ -// Allocate planner structures +// Allocate planner structures mpBufferPool_t mb; // move buffer queue mpMoveMasterSingleton_t mm; // context for line planning mpMoveRuntimeSingleton_t mr; // context for line runtime @@ -444,38 +439,3 @@ void mp_copy_buffer(mpBuf_t *bf, const mpBuf_t *bp) bf->nx = nx; // restore pointers bf->pv = pv; } - -/* -// currently this routine is only used by debug routines -uint8_t mp_get_buffer_index(mpBuf_t *bf) -{ - mpBuf_t *b = bf; // temp buffer pointer - - for (uint8_t i=0; i < PLANNER_BUFFER_POOL_SIZE; i++) { - if (b->pv > b) { - return (i); - } - b = b->pv; - } - return(cm_hard_alarm(PLANNER_BUFFER_POOL_SIZE)); // should never happen -} -*/ - -/**************************** - * END OF PLANNER FUNCTIONS * - ****************************/ - -/*********************************************************************************** - * CONFIGURATION AND INTERFACE FUNCTIONS - * Functions to get and set variables from the cfgArray table - ***********************************************************************************/ - -/*********************************************************************************** - * TEXT MODE SUPPORT - * Functions to print variables from the cfgArray table - ***********************************************************************************/ -/* -#ifdef __cplusplus -} -#endif -*/ diff --git a/src/planner.h b/src/planner.h index 142f2c9..3dbcfa0 100755 --- a/src/planner.h +++ b/src/planner.h @@ -30,11 +30,7 @@ #define PLANNER_H_ONCE #include "canonical_machine.h" // used for GCodeState_t -/* -#ifdef __cplusplus -extern "C"{ -#endif -*/ + enum moveType { // bf->move_type values MOVE_TYPE_NULL = 0, // null move - does a no-op MOVE_TYPE_ALINE, // acceleration planned line @@ -322,9 +318,5 @@ float mp_get_target_velocity(const float Vi, const float L, const mpBuf_t *bf); // plan_exec.c functions stat_t mp_exec_move(void); stat_t mp_exec_aline(mpBuf_t *bf); -/* -#ifdef __cplusplus -} -#endif -*/ + #endif // End of include Guard: PLANNER_H_ONCE diff --git a/src/pwm.c b/src/pwm.c index bafb413..d0c4498 100755 --- a/src/pwm.c +++ b/src/pwm.c @@ -32,13 +32,7 @@ #include "gpio.h" #include "pwm.h" -#ifdef __AVR #include -#endif - -#ifdef __cplusplus -extern "C"{ -#endif /***** PWM defines, structures and memory allocation *****/ @@ -85,8 +79,7 @@ pwmSingleton_t pwm; */ void pwm_init() { -#ifdef __AVR - gpio_set_bit_off(SPINDLE_PWM); + gpio_set_bit_off(SPINDLE_PWM); // setup PWM channel 1 memset(&pwm.p[PWM_1], 0, sizeof(pwmChannel_t)); // clear parent structure @@ -101,13 +94,11 @@ void pwm_init() pwm.p[PWM_2].ctrla = PWM2_CTRLA_CLKSEL; pwm.p[PWM_2].timer->CTRLB = PWM2_CTRLB; pwm.p[PWM_2].timer->INTCTRLB = PWM2_INTCTRLB; -#endif // __AVR } /* * ISRs for PWM timers */ -#ifdef __AVR ISR(PWM1_ISR_vect) { return; @@ -117,21 +108,7 @@ ISR(PWM2_ISR_vect) { return; } -#endif // __AVR -/* -#ifdef __ARM -MOTATE_TIMER_INTERRUPT -ISR(PWM1_ISR_vect) -{ - return; -} -ISR(PWM2_ISR_vect) -{ - return; -} -#endif // __ARM -*/ /* * pwm_set_freq() - set PWM channel frequency * @@ -148,8 +125,7 @@ stat_t pwm_set_freq(uint8_t chan, float freq) if (freq > PWM_MAX_FREQ) { return (STAT_INPUT_EXCEEDS_MAX_VALUE);} if (freq < PWM_MIN_FREQ) { return (STAT_INPUT_LESS_THAN_MIN_VALUE);} -#ifdef __AVR - // set the period and the prescaler + // set the period and the prescaler float prescale = F_CPU/65536/freq; // optimal non-integer prescaler value if (prescale <= 1) { pwm.p[chan].timer->PER = F_CPU/freq; @@ -167,15 +143,6 @@ stat_t pwm_set_freq(uint8_t chan, float freq) pwm.p[chan].timer->PER = F_CPU/64/freq; pwm.p[chan].timer->CTRLA = TC_CLKSEL_DIV64_gc; } -#endif // __AVR - -#ifdef __ARM - if (chan == PWM_1) { - spindle_pwm_pin.setFrequency(freq); - } else if (chan == PWM_2) { - secondary_pwm_pin.setFrequency(freq); - } -#endif // __ARM return (STAT_OK); } @@ -198,20 +165,10 @@ stat_t pwm_set_duty(uint8_t chan, float duty) if (duty < 0.0) { return (STAT_INPUT_LESS_THAN_MIN_VALUE);} if (duty > 1.0) { return (STAT_INPUT_EXCEEDS_MAX_VALUE);} - #ifdef __AVR // Ffrq = Fper/(2N(CCA+1)) // Fpwm = Fper/((N(PER+1)) float period_scalar = pwm.p[chan].timer->PER; pwm.p[chan].timer->CCB = (uint16_t)(period_scalar * duty) + 1; - #endif // __AVR - - #ifdef __ARM - if (chan == PWM_1) { - spindle_pwm_pin = duty; - } else if (chan == PWM_2) { - secondary_pwm_pin = duty; - } - #endif // __ARM return (STAT_OK); } @@ -255,7 +212,3 @@ void pwm_print_p1wph(nvObj_t *nv) { text_print_flt(nv, fmt_p1wph);} void pwm_print_p1pof(nvObj_t *nv) { text_print_flt(nv, fmt_p1pof);} #endif //__TEXT_MODE - -#ifdef __cplusplus -} -#endif diff --git a/src/pwm.h b/src/pwm.h index c1ae0d2..4723afa 100755 --- a/src/pwm.h +++ b/src/pwm.h @@ -28,10 +28,6 @@ #ifndef PWM_H_ONCE #define PWM_H_ONCE -#ifdef __cplusplus -extern "C"{ -#endif - typedef struct pwmConfigChannel { float frequency; // base frequency for PWM driver, in Hz float cw_speed_lo; // minimum clockwise spindle speed [0..N] @@ -47,9 +43,7 @@ typedef struct pwmConfigChannel { typedef struct pwmChannel { uint8_t ctrla; // byte needed to active CTRLA (it's dynamic - rest are static) -#ifdef __AVR - TC1_t *timer; // assumes TC1 flavor timers used for PWM channels -#endif + TC1_t *timer; // assumes TC1 flavor timers used for PWM channels } pwmChannel_t; typedef struct pwmSingleton { @@ -93,8 +87,4 @@ stat_t pwm_set_duty(uint8_t channel, float duty); #endif // __TEXT_MODE -#ifdef __cplusplus -} -#endif - #endif // End of include guard: PWM_H_ONCE diff --git a/src/report.c b/src/report.c index 444c443..92d04c8 100755 --- a/src/report.c +++ b/src/report.c @@ -36,10 +36,6 @@ #include "util.h" #include "xio.h" -#ifdef __cplusplus -extern "C"{ -#endif - /**** Allocation ****/ srSingleton_t sr; @@ -247,23 +243,13 @@ stat_t sr_set_status_report(nvObj_t *nv) */ stat_t sr_request_status_report(uint8_t request_type) { -#ifdef __ARM - if (request_type == SR_IMMEDIATE_REQUEST) { - sr.status_report_systick = SysTickTimer.getValue(); - } - if ((request_type == SR_TIMED_REQUEST) && (sr.status_report_requested == false)) { - sr.status_report_systick = SysTickTimer.getValue() + sr.status_report_interval; - } -#endif -#ifdef __AVR - if (request_type == SR_IMMEDIATE_REQUEST) { + if (request_type == SR_IMMEDIATE_REQUEST) { sr.status_report_systick = SysTickTimer_getValue(); } if ((request_type == SR_TIMED_REQUEST) && (sr.status_report_requested == false)) { sr.status_report_systick = SysTickTimer_getValue() + sr.status_report_interval; } -#endif - sr.status_report_requested = true; + sr.status_report_requested = true; return (STAT_OK); } @@ -279,14 +265,8 @@ stat_t sr_status_report_callback() // called by controller dispatcher if (sr.status_report_requested == false) return (STAT_NOOP); -#ifdef __ARM - if (SysTickTimer.getValue() < sr.status_report_systick) + if (SysTickTimer_getValue() < sr.status_report_systick) return (STAT_NOOP); -#endif -#ifdef __AVR - if (SysTickTimer_getValue() < sr.status_report_systick) - return (STAT_NOOP); -#endif sr.status_report_requested = false; // disable reports until requested again @@ -683,7 +663,3 @@ void qr_print_qo(nvObj_t *nv) { text_print_int(nv, fmt_qo);} void qr_print_qv(nvObj_t *nv) { text_print_ui8(nv, fmt_qv);} #endif // __TEXT_MODE - -#ifdef __cplusplus -} -#endif diff --git a/src/report.h b/src/report.h index 2aeb730..0c3960e 100755 --- a/src/report.h +++ b/src/report.h @@ -28,10 +28,6 @@ #ifndef REPORT_H_ONCE #define REPORT_H_ONCE -#ifdef __cplusplus -extern "C"{ -#endif - /**** Configs, Definitions and Structures ****/ // // Notes: @@ -118,7 +114,6 @@ stat_t sr_run_text_status_report(void); stat_t sr_get(nvObj_t *nv); stat_t sr_set(nvObj_t *nv); stat_t sr_set_si(nvObj_t *nv); -//void sr_print_sr(nvObj_t *nv); void qr_init_queue_report(void); void qr_request_queue_report(int8_t buffers); @@ -153,8 +148,4 @@ stat_t qo_get(nvObj_t *nv); #endif // __TEXT_MODE -#ifdef __cplusplus -} -#endif - #endif // End of include guard: REPORT_H_ONCE diff --git a/src/settings.h b/src/settings.h index e6cd1c9..9e13a9e 100755 --- a/src/settings.h +++ b/src/settings.h @@ -51,7 +51,6 @@ // MOTOR_POWERED_ONLY_WHEN_MOVING (3) #define MOTOR_IDLE_TIMEOUT 2.00 // seconds to maintain motor at full power before idling -#define MOTOR_POWER_LEVEL 0.25 // default motor power level (0,000 - 1.000, ARM only) // Communications and reporting settings #define COMM_MODE JSON_MODE // one of: TEXT_MODE, JSON_MODE diff --git a/src/spindle.c b/src/spindle.c index f67ea9a..cc24d88 100755 --- a/src/spindle.c +++ b/src/spindle.c @@ -33,10 +33,6 @@ #include "hardware.h" #include "pwm.h" -#ifdef __cplusplus -extern "C"{ -#endif - static void _exec_spindle_control(float *value, float *flag); static void _exec_spindle_speed(float *value, float *flag); @@ -101,8 +97,7 @@ static void _exec_spindle_control(float *value, float *flag) uint8_t spindle_mode = (uint8_t)value[0]; cm_set_spindle_mode(MODEL, spindle_mode); - #ifdef __AVR - if (spindle_mode == SPINDLE_CW) { + if (spindle_mode == SPINDLE_CW) { gpio_set_bit_on(SPINDLE_BIT); gpio_set_bit_off(SPINDLE_DIR); } else if (spindle_mode == SPINDLE_CCW) { @@ -111,18 +106,6 @@ static void _exec_spindle_control(float *value, float *flag) } else { gpio_set_bit_off(SPINDLE_BIT); // failsafe: any error causes stop } -#endif // __AVR -#ifdef __ARM - if (spindle_mode == SPINDLE_CW) { - spindle_enable_pin.set(); - spindle_dir_pin.clear(); - } else if (spindle_mode == SPINDLE_CCW) { - spindle_enable_pin.set(); - spindle_dir_pin.set(); - } else { - spindle_enable_pin.clear(); // failsafe: any error causes stop - } -#endif // __ARM // PWM spindle control pwm_set_duty(PWM_1, cm_get_spindle_pwm(spindle_mode) ); @@ -153,7 +136,3 @@ static void _exec_spindle_speed(float *value, float *flag) cm_set_spindle_speed_parameter(MODEL, value[0]); pwm_set_duty(PWM_1, cm_get_spindle_pwm(cm.gm.spindle_mode) ); // update spindle speed if we're running } - -#ifdef __cplusplus -} -#endif diff --git a/src/spindle.h b/src/spindle.h index e25d9bf..731cd91 100755 --- a/src/spindle.h +++ b/src/spindle.h @@ -28,14 +28,6 @@ #ifndef SPINDLE_H_ONCE #define SPINDLE_H_ONCE -#ifdef __cplusplus -extern "C"{ -#endif - -/* - * Global Scope Functions - */ - void cm_spindle_init(); stat_t cm_set_spindle_speed(float speed); // S parameter @@ -44,8 +36,4 @@ void cm_exec_spindle_speed(float speed); // callback for above stat_t cm_spindle_control(uint8_t spindle_mode); // M3, M4, M5 integrated spindle control void cm_exec_spindle_control(uint8_t spindle_mode); // callback for above -#ifdef __cplusplus -} -#endif - #endif // End of include guard: SPINDLE_H_ONCE diff --git a/src/stepper.c b/src/stepper.c index b3954dc..a64fc36 100755 --- a/src/stepper.c +++ b/src/stepper.c @@ -49,132 +49,10 @@ static stRunSingleton_t st_run; static void _load_move(void); static void _request_load_move(void); -#ifdef __ARM -static void _set_motor_power_level(const uint8_t motor, const float power_level); -#endif // handy macro #define _f_to_period(f) (uint16_t)((float)F_CPU / (float)f) -/**** Setup motate ****/ - -#ifdef __ARM -using namespace Motate; - -OutputPin common_enable; // shorter form of the above -OutputPin dda_debug_pin1; -OutputPin dda_debug_pin2; -OutputPin dda_debug_pin3; - -// Example with prefixed name:: -//Motate::Timer dda_timer(kTimerUpToMatch, FREQUENCY_DDA);// stepper pulse generation -Timer dda_timer(kTimerUpToMatch, FREQUENCY_DDA); // stepper pulse generation -Timer dwell_timer(kTimerUpToMatch, FREQUENCY_DWELL); // dwell timer -Timer load_timer; // triggers load of next stepper segment -Timer exec_timer; // triggers calculation of next+1 stepper segment - -// Motor structures -template - -struct Stepper { - /* stepper pin assignments */ - - OutputPin step; - OutputPin dir; - OutputPin enable; - OutputPin ms0; - OutputPin ms1; - OutputPin ms2; - PWMOutputPin vref; - - /* stepper default values */ - - // sets default pwm freq for all motor vrefs (comment line also sets HiZ) - Stepper(const uint32_t frequency = 500000) : vref(frequency) {}; -// Stepper(const uint32_t frequency = 100000) : vref(kDriveLowOnly, frequency) {}; - - /* functions bound to stepper structures */ - - void setMicrosteps(const uint8_t microsteps) - { - switch (microsteps) { - case ( 1): { ms2=0; ms1=0; ms0=0; break; } - case ( 2): { ms2=0; ms1=0; ms0=1; break; } - case ( 4): { ms2=0; ms1=1; ms0=0; break; } - case ( 8): { ms2=0; ms1=1; ms0=1; break; } - case (16): { ms2=1; ms1=0; ms0=0; break; } - case (32): { ms2=1; ms1=0; ms0=1; break; } - } - }; - - void energize(const uint8_t motor) - { - if (st_cfg.mot[motor].power_mode != MOTOR_DISABLED) { - enable.clear(); - st_run.mot[motor].power_state = MOTOR_POWER_TIMEOUT_START; - } - }; -}; - -Stepper motor_1; - -Stepper motor_2; - -Stepper motor_3; - -Stepper motor_4; - -Stepper motor_5; - -Stepper motor_6; - -#endif // __ARM - -/************************************************************************************ - **** CODE ************************************************************************** - ************************************************************************************/ /* * stepper_init() - initialize stepper motor subsystem * @@ -201,8 +79,7 @@ void stepper_init() memset(&st_run, 0, sizeof(st_run)); // clear all values, pointers and status stepper_init_assertions(); -#ifdef __AVR - // Configure virtual ports + // Configure virtual ports PORTCFG.VPCTRLA = PORTCFG_VP0MAP_PORT_MOTOR_1_gc | PORTCFG_VP1MAP_PORT_MOTOR_2_gc; PORTCFG.VPCTRLB = PORTCFG_VP2MAP_PORT_MOTOR_3_gc | PORTCFG_VP3MAP_PORT_MOTOR_4_gc; @@ -235,30 +112,6 @@ void stepper_init() st_pre.buffer_state = PREP_BUFFER_OWNED_BY_EXEC; st_reset(); // reset steppers to known state -#endif // __AVR - -#ifdef __ARM - // setup DDA timer (see FOOTNOTE) - dda_timer.setInterrupts(kInterruptOnOverflow | kInterruptOnMatchA | kInterruptPriorityHighest); - dda_timer.setDutyCycleA(0.25); - - // setup DWELL timer - dwell_timer.setInterrupts(kInterruptOnOverflow | kInterruptPriorityHighest); - - // setup software interrupt load timer - load_timer.setInterrupts(kInterruptOnSoftwareTrigger | kInterruptPriorityLow); - - // setup software interrupt exec timer & initial condition - exec_timer.setInterrupts(kInterruptOnSoftwareTrigger | kInterruptPriorityLowest); - st_pre.buffer_state = PREP_BUFFER_OWNED_BY_EXEC; - - // setup motor power levels and apply power level to stepper drivers - for (uint8_t motor=0; motor 0) { - motor_1.step.set(); // turn step bit on - st_run.mot[MOTOR_1].substep_accumulator -= st_run.dda_ticks_X_substeps; - INCREMENT_ENCODER(MOTOR_1); - } - if (!motor_2.step.isNull() && (st_run.mot[MOTOR_2].substep_accumulator += st_run.mot[MOTOR_2].substep_increment) > 0) { - motor_2.step.set(); - st_run.mot[MOTOR_2].substep_accumulator -= st_run.dda_ticks_X_substeps; - INCREMENT_ENCODER(MOTOR_2); - } - if (!motor_3.step.isNull() && (st_run.mot[MOTOR_3].substep_accumulator += st_run.mot[MOTOR_3].substep_increment) > 0) { - motor_3.step.set(); - st_run.mot[MOTOR_3].substep_accumulator -= st_run.dda_ticks_X_substeps; - INCREMENT_ENCODER(MOTOR_3); - } - if (!motor_4.step.isNull() && (st_run.mot[MOTOR_4].substep_accumulator += st_run.mot[MOTOR_4].substep_increment) > 0) { - motor_4.step.set(); - st_run.mot[MOTOR_4].substep_accumulator -= st_run.dda_ticks_X_substeps; - INCREMENT_ENCODER(MOTOR_4); - } - if (!motor_5.step.isNull() && (st_run.mot[MOTOR_5].substep_accumulator += st_run.mot[MOTOR_5].substep_increment) > 0) { - motor_5.step.set(); - st_run.mot[MOTOR_5].substep_accumulator -= st_run.dda_ticks_X_substeps; - INCREMENT_ENCODER(MOTOR_5); - } - if (!motor_6.step.isNull() && (st_run.mot[MOTOR_6].substep_accumulator += st_run.mot[MOTOR_6].substep_increment) > 0) { - motor_6.step.set(); - st_run.mot[MOTOR_6].substep_accumulator -= st_run.dda_ticks_X_substeps; - INCREMENT_ENCODER(MOTOR_6); - } - - } else if (interrupt_cause == kInterruptOnMatchA) { -// dda_debug_pin2 = 1; - motor_1.step.clear(); // turn step bits off - motor_2.step.clear(); - motor_3.step.clear(); - motor_4.step.clear(); - motor_5.step.clear(); - motor_6.step.clear(); - - if (--st_run.dda_ticks_downcount != 0) return; - - // process end of segment - dda_timer.stop(); // turn it off or it will keep stepping out the last segment - _load_move(); // load the next move at the current interrupt level -// dda_debug_pin2 = 0; - } -// dda_debug_pin1 = 0; -} // MOTATE_TIMER_INTERRUPT -} // namespace Motate -#endif // __ARM /***** Dwell Interrupt Service Routine ************************************************** * ISR - DDA timer interrupt routine - service ticks from DDA timer */ -#ifdef __AVR ISR(TIMER_DWELL_ISR_vect) { // DWELL timer interrupt if (--st_run.dda_ticks_downcount == 0) { TIMER_DWELL.CTRLA = STEP_TIMER_DISABLE; // disable DWELL timer _load_move(); } } -#endif -#ifdef __ARM -namespace Motate { // Must define timer interrupts inside the Motate namespace -MOTATE_TIMER_INTERRUPT(dwell_timer_num) -{ - dwell_timer.getInterruptCause(); // read SR to clear interrupt condition - if (--st_run.dda_ticks_downcount == 0) { - dwell_timer.stop(); - _load_move(); - } -} -} // namespace Motate -#endif /**************************************************************************************** * Exec sequencing code - computes and prepares next load segment @@ -641,7 +361,6 @@ MOTATE_TIMER_INTERRUPT(dwell_timer_num) * exec_timer interrupt - interrupt handler for calling exec function */ -#ifdef __AVR void st_request_exec_move() { if (st_pre.buffer_state == PREP_BUFFER_OWNED_BY_EXEC) {// bother interrupting @@ -661,30 +380,6 @@ ISR(TIMER_EXEC_ISR_vect) { // exec move SW interrupt } } } -#endif // __AVR - -#ifdef __ARM -void st_request_exec_move() -{ - if (st_pre.buffer_state == PREP_BUFFER_OWNED_BY_EXEC) {// bother interrupting - exec_timer.setInterruptPending(); - } -} - -namespace Motate { // Define timer inside Motate namespace - MOTATE_TIMER_INTERRUPT(exec_timer_num) // exec move SW interrupt - { - exec_timer.getInterruptCause(); // clears the interrupt condition - if (st_pre.buffer_state == PREP_BUFFER_OWNED_BY_EXEC) { - if (mp_exec_move() != STAT_NOOP) { - st_pre.buffer_state = PREP_BUFFER_OWNED_BY_LOADER; // flip it back - _request_load_move(); - } - } - } -} // namespace Motate - -#endif // __ARM /**************************************************************************************** * Loader sequencing code @@ -696,7 +391,6 @@ namespace Motate { // Define timer inside Motate namespace * request a load (see st_request_load_move()) */ -#ifdef __AVR static void _request_load_move() { if (st_runtime_isbusy()) { @@ -712,27 +406,7 @@ ISR(TIMER_LOAD_ISR_vect) { // load steppers SW interrupt TIMER_LOAD.CTRLA = LOAD_TIMER_DISABLE; // disable SW interrupt timer _load_move(); } -#endif // __AVR - -#ifdef __ARM -static void _request_load_move() -{ - if (st_runtime_isbusy()) { - return; // don't request a load if the runtime is busy - } - if (st_pre.buffer_state == PREP_BUFFER_OWNED_BY_LOADER) { // bother interrupting - load_timer.setInterruptPending(); - } -} -namespace Motate { // Define timer inside Motate namespace - MOTATE_TIMER_INTERRUPT(load_timer_num) // load steppers SW interrupt - { - load_timer.getInterruptCause(); // read SR to clear interrupt condition - _load_move(); - } -} // namespace Motate -#endif // __ARM /**************************************************************************************** * _load_move() - Dequeue move and load into stepper struct @@ -746,8 +420,6 @@ namespace Motate { // Define timer inside Motate namespace * - If axis has 0 steps the direction setting can be omitted * - If axis has 0 steps the motor must not be enabled to support power mode = 1 */ -/****** WARNING - THIS CODE IS SPECIFIC TO AVR. SEE G2 FOR ARM CODE ******/ - static void _load_move() { // Be aware that dda_ticks_downcount must equal zero for the loader to run. @@ -756,10 +428,7 @@ static void _load_move() return; // exit if the runtime is busy } if (st_pre.buffer_state != PREP_BUFFER_OWNED_BY_LOADER) { // if there are no moves to load... -// for (uint8_t motor = MOTOR_1; motor < MOTORS; motor++) { -// st_run.mot[motor].power_state = MOTOR_POWER_TIMEOUT_START; // ...start motor power timeouts -// } - return; + return; } // handle aline loads first (most common case) if (st_pre.move_type == MOVE_TYPE_ALINE) { @@ -1107,18 +776,7 @@ void st_prep_dwell(float microseconds) static void _set_hw_microsteps(const uint8_t motor, const uint8_t microsteps) { -#ifdef __ARM - switch (motor) { - if (!motor_1.enable.isNull()) case (MOTOR_1): { motor_1.setMicrosteps(microsteps); break; } - if (!motor_2.enable.isNull()) case (MOTOR_2): { motor_2.setMicrosteps(microsteps); break; } - if (!motor_3.enable.isNull()) case (MOTOR_3): { motor_3.setMicrosteps(microsteps); break; } - if (!motor_4.enable.isNull()) case (MOTOR_4): { motor_4.setMicrosteps(microsteps); break; } - if (!motor_5.enable.isNull()) case (MOTOR_5): { motor_5.setMicrosteps(microsteps); break; } - if (!motor_6.enable.isNull()) case (MOTOR_6): { motor_6.setMicrosteps(microsteps); break; } - } -#endif //__ARM -#ifdef __AVR - if (microsteps == 8) { + if (microsteps == 8) { hw.st_port[motor]->OUTSET = MICROSTEP_BIT_0_bm; hw.st_port[motor]->OUTSET = MICROSTEP_BIT_1_bm; } else if (microsteps == 4) { @@ -1131,7 +789,6 @@ static void _set_hw_microsteps(const uint8_t motor, const uint8_t microsteps) hw.st_port[motor]->OUTCLR = MICROSTEP_BIT_0_bm; hw.st_port[motor]->OUTCLR = MICROSTEP_BIT_1_bm; } -#endif // __AVR } @@ -1214,20 +871,7 @@ stat_t st_set_pm(nvObj_t *nv) // motor power mode */ stat_t st_set_pl(nvObj_t *nv) // motor power level { -#ifdef __ARM - if (nv->value < (float)0.0) nv->value = 0.0; - if (nv->value > (float)1.0) { - if (nv->value > (float)100) nv->value = 1; - nv->value /= 100; // accommodate old 0-100 inputs - } - set_flt(nv); // set power_setting value in the motor config struct (st) - - uint8_t m = _get_motor(nv); - st_cfg.mot[m].power_level_scaled = (nv->value * POWER_LEVEL_SCALE_FACTOR); - st_run.mot[m].power_level_dynamic = (st_cfg.mot[m].power_level_scaled); - _set_motor_power_level(m, st_cfg.mot[m].power_level_scaled); -#endif - return(STAT_OK); + return(STAT_OK); } /* diff --git a/src/stepper.h b/src/stepper.h index cf83690..f2fd196 100755 --- a/src/stepper.h +++ b/src/stepper.h @@ -56,8 +56,7 @@ * * At 50 KHz constant clock rate we have 20 uSec between pulse timer (DDA) interrupts. * On the Xmega we consume <10 uSec in the interrupt - a whopping 50% of available cycles - * going into pulse generation. On the ARM this is less of an issue, and we run a - * 100 Khz (or higher) pulse rate. + * going into pulse generation. * * - Pulse timing is also helped by minimizing the time spent loading the next move * segment. The time budget for the load is less than the time remaining before the @@ -272,11 +271,6 @@ enum cmMotorPowerMode { MOTOR_POWER_MODE_MAX_VALUE // for input range checking }; -// Stepper power management settings (applicable to ARM only) -#define Vcc 3.3 // volts -#define MaxVref 2.25 // max vref for driver circuit. Our ckt is 2.25 volts -#define POWER_LEVEL_SCALE_FACTOR ((MaxVref/Vcc)) // scale power level setting for voltage range - // Min/Max timeouts allowed for motor disable. Allow for inertial stop; must be non-zero #define MOTOR_TIMEOUT_SECONDS_MIN (float)0.1 // seconds !!! SHOULD NEVER BE ZERO !!! #define MOTOR_TIMEOUT_SECONDS_MAX (float)4294967 // (4294967295/1000) -- for conversion to uint32_t @@ -299,8 +293,6 @@ enum cmMotorPowerMode { * 0.90 == a safety factor used to reduce the result from theoretical maximum * * The number is about 8.5 million for the Xmega running a 50 KHz DDA with 5 millisecond segments - * The ARM is about 1/4 that (or less) as the DDA clock rate is 4x higher. Decreasing the nominal - * segment time increases the number precision. */ #define DDA_SUBSTEPS ((MAX_LONG * 0.90) / (FREQUENCY_DDA * (NOM_SEGMENT_TIME * 60))) @@ -365,7 +357,6 @@ typedef struct stRunMotor { // one per controlled motor int32_t substep_accumulator; // DDA phase angle accumulator uint8_t power_state; // state machine for managing motor power uint32_t power_systick; // sys_tick for next motor power state transition - float power_level_dynamic; // power level for this segment of idle (ARM only) } stRunMotor_t; typedef struct stRunSingleton { // Stepper static values and axis parameters diff --git a/src/switch.c b/src/switch.c index ebd4282..b47cd06 100755 --- a/src/switch.c +++ b/src/switch.c @@ -61,15 +61,11 @@ static void _switch_isr_helper(uint8_t sw_num); * regardless of board type but are extraneous for v7 boards. */ #define PIN_MODE PORT_OPC_PULLUP_gc // pin mode. see iox192a3.h for details -//#define PIN_MODE PORT_OPC_TOTEM_gc // alternate pin mode for v7 boards void switch_init(void) { for (uint8_t i=0; iDIRCLR = SW_MIN_BIT_bm; // set min input - see 13.14.14 hw.sw_port[i]->PIN6CTRL = (PIN_MODE | PORT_ISC_BOTHEDGES_gc); @@ -141,7 +137,6 @@ void switch_rtc_callback(void) if (sw.count[i] == 0) { // trigger point sw.sw_num_thrown = i; // record number of thrown switch sw.debounce[i] = SW_LOCKOUT; -// sw_show_switch(); // only called if __DEBUG enabled if ((cm.cycle_state == CYCLE_HOMING) || (cm.cycle_state == CYCLE_PROBE)) { // regardless of switch type cm_request_feedhold(); @@ -207,20 +202,6 @@ uint8_t read_switch(uint8_t sw_num) } } -/* - * _show_switch() - simple display routine - */ -/* -void sw_show_switch(void) -{ - fprintf_P(stderr, PSTR("Limit Switch Thrown Xmin %d Xmax %d Ymin %d Ymax %d \ - Zmin %d Zmax %d Amin %d Amax %d\n"), - sw.state[SW_MIN_X], sw.state[SW_MAX_X], - sw.state[SW_MIN_Y], sw.state[SW_MAX_Y], - sw.state[SW_MIN_Z], sw.state[SW_MAX_Z], - sw.state[SW_MIN_A], sw.state[SW_MAX_A]); -} -*/ /*********************************************************************************** * CONFIGURATION AND INTERFACE FUNCTIONS @@ -254,166 +235,4 @@ stat_t sw_set_sw(nvObj_t *nv) // switch setting static const char fmt_st[] PROGMEM = "[st] switch type%18d [0=NO,1=NC]\n"; void sw_print_st(nvObj_t *nv) { text_print_ui8(nv, fmt_st);} -//static const char fmt_ss[] PROGMEM = "Switch %s state: %d\n"; -//void sw_print_ss(nvObj_t *nv) { fprintf(stderr, fmt_ss, nv->token, (uint8_t)nv->value);} - -/* -static const char msg_sw0[] PROGMEM = "Disabled"; -static const char msg_sw1[] PROGMEM = "NO homing"; -static const char msg_sw2[] PROGMEM = "NO homing & limit"; -static const char msg_sw3[] PROGMEM = "NC homing"; -static const char msg_sw4[] PROGMEM = "NC homing & limit"; -static const char *const msg_sw[] PROGMEM = { msg_sw0, msg_sw1, msg_sw2, msg_sw3, msg_sw4 }; -*/ - - #endif - -/*============== G2 switch code - completely different, for now =================== - -#include "tinyg2.h" -#include "switch.h" -#include "hardware.h" -#include "canonical_machine.h" - -// Allocate switch array structure -switches_t sw; - -static void _no_action(switch_t *s); -static void _led_on(switch_t *s); -static void _led_off(switch_t *s); -static void _trigger_feedhold(switch_t *s); -static void _trigger_cycle_start(switch_t *s); - - * - * switch_init() - initialize homing/limit switches - * - * This function assumes all Motate pins have been set up and that - * SW_PAIRS and SW_POSITIONS is accurate - * - * Note: `type` and `mode` are not initialized as they should be set from configuration - * - -void switch_init(void) -{ -// sw.type = SW_NORMALLY_OPEN; // set from config - - switch_t *s; // shorthand - - for (uint8_t axis=0; axistype = sw.type; // propagate type from global type -// s->mode = SW_MODE_DISABLED; // set from config - s->state = false; - s->edge = SW_NO_EDGE; - s->debounce_ticks = SW_LOCKOUT_TICKS; - s->debounce_timeout = 0; - - // functions bound to each switch - s->when_open = _no_action; - s->when_closed = _no_action; - s->on_leading = _trigger_feedhold; - s->on_trailing = _trigger_cycle_start; - } - } - // functions bound to individual switches - // - // sw.s[AXIS_X][SW_MIN].when_open = _led_off; - // sw.s[AXIS_X][SW_MIN].when_closed = _led_on; -} - -static void _no_action(switch_t *s) { return; } -static void _led_on(switch_t *s) { IndicatorLed.clear(); } -static void _led_off(switch_t *s) { IndicatorLed.set(); } - - * - * poll_switches() - run a polling cycle on all switches - * - -stat_t poll_switches() -{ - read_switch(&sw.s[AXIS_X][SW_MIN], axis_X_min_pin); - read_switch(&sw.s[AXIS_X][SW_MAX], axis_X_max_pin); - read_switch(&sw.s[AXIS_Y][SW_MIN], axis_Y_min_pin); - read_switch(&sw.s[AXIS_Y][SW_MAX], axis_Y_max_pin); - read_switch(&sw.s[AXIS_Z][SW_MIN], axis_Z_min_pin); - read_switch(&sw.s[AXIS_Z][SW_MAX], axis_Z_max_pin); - read_switch(&sw.s[AXIS_A][SW_MIN], axis_A_min_pin); - read_switch(&sw.s[AXIS_A][SW_MAX], axis_A_max_pin); - read_switch(&sw.s[AXIS_B][SW_MIN], axis_B_min_pin); - read_switch(&sw.s[AXIS_B][SW_MAX], axis_B_max_pin); - read_switch(&sw.s[AXIS_C][SW_MIN], axis_C_min_pin); - read_switch(&sw.s[AXIS_C][SW_MAX], axis_C_max_pin); - return (STAT_OK); -} - - * - * read_switch() - read switch with NO/NC, debouncing and edge detection - * - * Returns true if switch state changed - e.g. leading or falling edge detected - * Assumes pin_value input = 1 means open, 0 is closed. Pin sense is adjusted to mean: - * 0 = open for both NO and NC switches - * 1 = closed for both NO and NC switches - * -uint8_t read_switch(switch_t *s, uint8_t pin_value) -{ - // instant return conditions: switch disabled or in a lockout period - if (s->mode == SW_MODE_DISABLED) { - return (false); - } - if (s->debounce_timeout > GetTickCount()) { - return (false); - } - // return if no change in state - uint8_t pin_sense_corrected = (pin_value ^ (s->type ^ 1)); // correct for NO or NC mode - if ( s->state == pin_sense_corrected) { - s->edge = SW_NO_EDGE; - if (s->state == SW_OPEN) { - s->when_open(s); - } else { - s->when_closed(s); - } - return (false); - } - // the switch legitimately changed state - process edges - if ((s->state = pin_sense_corrected) == SW_OPEN) { - s->edge = SW_TRAILING; - s->on_trailing(s); - } else { - s->edge = SW_LEADING; - s->on_leading(s); - } - s->debounce_timeout = (GetTickCount() + s->debounce_ticks); - return (true); -} - -static void _trigger_feedhold(switch_t *s) -{ - IndicatorLed.toggle(); - cm_request_feedhold(); - -// if (cm.cycle_state == CYCLE_HOMING) { // regardless of switch type -// cm.request_feedhold = true; -// } else if (s->mode & SW_LIMIT_BIT) { // set flag if it's a limit switch -// cm.limit_tripped_flag = true; -// } - -} - -static void _trigger_cycle_start(switch_t *s) -{ - IndicatorLed.toggle(); - cm_request_cycle_start(); -} - - * - * switch_get_switch_mode() - return switch mode setting - * switch_get_limit_thrown() - return true if a limit was tripped - * switch_get_sw_num() - return switch number most recently thrown - * - -uint8_t get_switch_mode(uint8_t sw_num) { return (0);} // ++++ - -*/ diff --git a/src/test.h b/src/test.h index 8a56745..a24148a 100755 --- a/src/test.h +++ b/src/test.h @@ -19,8 +19,6 @@ #ifndef test_h #define test_h -//#include // needed for FILE def'n - uint8_t run_test(nvObj_t *nv); void run_canned_startup(void); @@ -106,11 +104,6 @@ struct mpSegmentLog { uint32_t segments; float velocity; float microseconds; -// float position_x; -// float target_x; -// float step_x; -// float move_time; -// float accel_time; }; struct mpSegmentLog sl[SEGMENT_LOGGER_MAX]; uint16_t sl_index; @@ -122,25 +115,12 @@ void segment_logger(uint8_t move_state, uint32_t segment_count, float velocity, float microseconds -// float position_x, -// float target_x, -// float step_x, -// float move_time, -// float accel_time - ); + ); #define SEGMENT_LOGGER segment_logger(bf->move_state, \ mr.linenum, mr.segments, mr.segment_count, \ mr.segment_velocity, \ mr.microseconds); -/* - mr.microseconds, \ - mr.position[X], \ - mr.target[X], \ - steps[X], \ - mr.segment_move_time, \ - mr.segment_accel_time); -*/ #else #define SEGMENT_LOGGER #endif // __SEGMENT_LOGGER diff --git a/src/text_parser.c b/src/text_parser.c index 554a07e..d6b1fc4 100755 --- a/src/text_parser.c +++ b/src/text_parser.c @@ -35,10 +35,6 @@ #include "util.h" #include "xio.h" // for ASCII char definitions -#ifdef __cplusplus -extern "C"{ -#endif - txtSingleton_t txt; // declare the singleton for either __TEXT_MODE setting #ifndef __TEXT_MODE @@ -282,7 +278,3 @@ void tx_print_tv(nvObj_t *nv) { text_print_ui8(nv, fmt_tv);} #endif // __TEXT_MODE - -#ifdef __cplusplus -} -#endif // __cplusplus diff --git a/src/text_parser.h b/src/text_parser.h index 12dbf40..b9e3e57 100755 --- a/src/text_parser.h +++ b/src/text_parser.h @@ -28,10 +28,6 @@ #ifndef TEXT_PARSER_H_ONCE #define TEXT_PARSER_H_ONCE -#ifdef __cplusplus -extern "C"{ -#endif - enum textVerbosity { TV_SILENT = 0, // no response is provided TV_VERBOSE // response is provided. Error responses ech message and failed commands @@ -103,8 +99,4 @@ stat_t text_parser_stub(char_t *str); void text_response_stub(const stat_t status, char_t *buf); void text_print_list_stub(stat_t status, uint8_t flags); -#ifdef __cplusplus -} -#endif - #endif // End of include guard: TEXT_PARSER_H_ONCE diff --git a/src/tinyg.h b/src/tinyg.h index 98ad637..62a46a7 100755 --- a/src/tinyg.h +++ b/src/tinyg.h @@ -40,8 +40,6 @@ #include #include -//#include "MotatePins.h" - /****** REVISIONS ******/ #ifndef TINYG_FIRMWARE_BUILD @@ -71,26 +69,9 @@ //#define __DEBUG_SETTINGS // special settings. See settings.h //#define __CANNED_STARTUP // run any canned startup moves -//#ifndef WEAK -//#define WEAK __attribute__ ((weak)) -//#endif - -/************************************************************************************ - ***** PLATFORM COMPATIBILITY ******************************************************* - ************************************************************************************/ -#undef __AVR -#define __AVR -//#undef __ARM -//#define __ARM - -/********************* - * AVR Compatibility * - *********************/ -#ifdef __AVR - #include // defines PROGMEM and PSTR -typedef char char_t; // ARM/C++ version uses uint8_t as char_t +typedef char char_t; // gets rely on nv->index having been set #define GET_TABLE_WORD(a) pgm_read_word(&cfgArray[nv->index].a) // get word value from cfgArray @@ -115,70 +96,6 @@ typedef char char_t; // ARM/C++ version uses uint8_t as char_t // String compatibility #define strtof strtod // strtof is not in the AVR lib -#endif // __AVR - -/********************* - * ARM Compatibility * - *********************/ -#ifdef __ARM - // Use macros to fake out AVR's PROGMEM and other AVRisms. -#define PROGMEM // ignore PROGMEM declarations in ARM/GCC++ -#define PSTR (const char *) // AVR macro is: PSTR(s) ((const PROGMEM char *)(s)) - -typedef char char_t; // In the ARM/GCC++ version char_t is typedef'd to uint8_t - // because in C++ uint8_t and char are distinct types and - // we want chars to behave as uint8's - - // gets rely on nv->index having been set -#define GET_TABLE_WORD(a) cfgArray[nv->index].a // get word value from cfgArray -#define GET_TABLE_BYTE(a) cfgArray[nv->index].a // get byte value from cfgArray -#define GET_TABLE_FLOAT(a) cfgArray[nv->index].a // get byte value from cfgArray -#define GET_TOKEN_BYTE(i,a) (char_t)cfgArray[i].a // get token byte value from cfgArray - -#define GET_TOKEN_STRING(i,a) cfgArray[(index_t)i].a -//#define GET_TOKEN_STRING(i,a) (char_t)cfgArray[i].token)// populate the token string given the index - -#define GET_TEXT_ITEM(b,a) b[a] // get text from an array of strings in flash -#define GET_UNITS(a) msg_units[cm_get_units_mode(a)] - -// IO settings -#define DEV_STDIN 0 // STDIO defaults - stdio is not yet used in the ARM version -#define DEV_STDOUT 0 -#define DEV_STDERR 0 - -/* String compatibility - * - * The ARM stdio functions we are using still use char as input and output. The macros - * below do the casts for most cases, but not all. Vararg functions like the printf() - * family need special handling. These like char * as input and require casts as per: - * - * printf((const char *)"Good Morning Hoboken!\n"); - * - * The AVR also has "_P" variants that take PROGMEM strings as args. - * On the ARM/GCC++ the _P functions are just aliases of the non-P variants. - */ -#define strncpy(d,s,l) (char_t *)strncpy((char *)d, (char *)s, l) -#define strpbrk(d,s) (char_t *)strpbrk((char *)d, (char *)s) -#define strcpy(d,s) (char_t *)strcpy((char *)d, (char *)s) -#define strcat(d,s) (char_t *)strcat((char *)d, (char *)s) -#define strstr(d,s) (char_t *)strstr((char *)d, (char *)s) -#define strchr(d,s) (char_t *)strchr((char *)d, (char)s) -#define strcmp(d,s) strcmp((char *)d, (char *)s) -#define strtod(d,p) strtod((char *)d, (char **)p) -#define strtof(d,p) strtof((char *)d, (char **)p) -#define strlen(s) strlen((char *)s) -#define isdigit(c) isdigit((char)c) -#define isalnum(c) isalnum((char)c) -#define tolower(c) (char_t)tolower((char)c) -#define toupper(c) (char_t)toupper((char)c) - -#define printf_P printf // these functions want char * as inputs, not char_t * -#define fprintf_P fprintf // just sayin' -#define sprintf_P sprintf -#define strcpy_P strcpy - -#endif // __ARM - /****************************************************************************** ***** TINYG APPLICATION DEFINITIONS ****************************************** ******************************************************************************/ diff --git a/src/util.c b/src/util.c index c8cc9cf..8dc4338 100755 --- a/src/util.c +++ b/src/util.c @@ -33,13 +33,7 @@ #include "tinyg.h" #include "util.h" -#ifdef __AVR #include "xmega/xmega_rtc.h" -#endif - -#ifdef __cplusplus -extern "C"{ -#endif /**** Vector utilities **** * copy_vector() - copy vector of arbitrary length @@ -51,12 +45,6 @@ extern "C"{ float vector[AXES]; // statically allocated global for vector utilities -/* -void copy_vector(float dst[], const float src[]) -{ - memcpy(dst, src, sizeof(dst)); -} -*/ uint8_t vector_equal(const float a[], const float b[]) { @@ -164,17 +152,6 @@ float max4(float x1, float x2, float x3, float x4) * escape_string() - add escapes to a string - currently for quotes only */ -/* -uint8_t * strcpy_U( uint8_t * dst, const uint8_t * src ) -{ - uint16_t index = 0; - do { - dst[index] = src[index]; - } while (src[index++] != 0); - return dst; -} -*/ - uint8_t isnumber(char_t c) { if (c == '.') { return (true); } @@ -196,25 +173,15 @@ char_t *escape_string(char_t *dst, char_t *src) } /* - * pstr2str() - return an AVR style progmem string as a RAM string. No effect on ARMs + * pstr2str() - return an AVR style progmem string as a RAM string. * - * This function deals with FLASH memory string confusion between the AVR serias and ARMs. - * AVRs typically have xxxxx_P() functions which take strings from FLASH as args. - * On ARMs there is no need for this as strings are handled identically in FLASH and RAM. - * - * This function copies a string from FLASH to a pre-allocated RAM buffer - see main.c for - * allocation and max length. On the ARM it's a pass through that just returns the address - * of the input string + * This function copies a string from FLASH to a pre-allocated RAM buffer - + * see main.c for allocation and max length. */ char_t *pstr2str(const char *pgm_string) { -#ifdef __AVR - strncpy_P(global_string_buf, pgm_string, MESSAGE_LEN); + strncpy_P(global_string_buf, pgm_string, MESSAGE_LEN); return (global_string_buf); -#endif -#ifdef __ARM - return ((char_t *)pgm_string); -#endif } /* @@ -269,20 +236,7 @@ uint16_t compute_checksum(char_t const *string, const uint16_t length) * SysTickTimer_getValue() - this is a hack to get around some compatibility problems */ -#ifdef __AVR uint32_t SysTickTimer_getValue() { return (rtc.sys_ticks); } -#endif // __AVR - -#ifdef __ARM -uint32_t SysTickTimer_getValue() -{ - return (SysTickTimer.getValue()); -} -#endif // __ARM - -#ifdef __cplusplus -} -#endif diff --git a/src/util.h b/src/util.h index 540181d..c9039e8 100755 --- a/src/util.h +++ b/src/util.h @@ -35,18 +35,6 @@ #ifndef UTIL_H_ONCE #define UTIL_H_ONCE -#ifdef __ARM -//#include -//#include "sam.h" -#include "MotateTimers.h" -using Motate::delay; -using Motate::SysTickTimer; -#endif - -#ifdef __cplusplus -extern "C"{ -#endif - /****** Global Scope Variables and Functions ******/ //*** vector utilities *** @@ -71,10 +59,6 @@ float max4(float x1, float x2, float x3, float x4); //*** string utilities *** -//#ifdef __ARM -//char_t * strcpy_U( char_t * dst, const char_t * src ); -//#endif - uint8_t isnumber(char_t c); char_t *escape_string(char_t *dst, char_t *src); char_t *pstr2str(const char *pgm_string); @@ -143,14 +127,8 @@ uint32_t SysTickTimer_getValue(void); #define uSec(a) ((float)(a * MICROSECONDS_PER_MINUTE)) #define RADIAN (57.2957795) -// M_PI is pi as defined in math.h -// M_SQRT2 is radical2 as defined in math.h #ifndef M_SQRT3 #define M_SQRT3 (1.73205080756888) #endif -#ifdef __cplusplus -} -#endif - #endif // End of include guard: UTIL_H_ONCE diff --git a/src/xio.c b/src/xio.c index c5639b5..bd536b0 100755 --- a/src/xio.c +++ b/src/xio.c @@ -134,9 +134,7 @@ uint8_t xio_test_assertions() if (ds[XIO_DEV_SPI1].magic_end != MAGICNUM) return (STAT_XIO_ASSERTION_FAILURE); if (ds[XIO_DEV_SPI2].magic_start != MAGICNUM) return (STAT_XIO_ASSERTION_FAILURE); if (ds[XIO_DEV_SPI2].magic_end != MAGICNUM) return (STAT_XIO_ASSERTION_FAILURE); -// if (ds[XIO_DEV_PGM].magic_start != MAGICNUM) return (STAT_XIO_ASSERTION_FAILURE); -// if (ds[XIO_DEV_PGM].magic_end != MAGICNUM) return (STAT_XIO_ASSERTION_FAILURE); - if (stderr != xio.stderr_shadow) return (STAT_XIO_ASSERTION_FAILURE); + if (stderr != xio.stderr_shadow) return (STAT_XIO_ASSERTION_FAILURE); return (STAT_OK); } diff --git a/src/xio.h b/src/xio.h index 14c6a89..4ad9e79 100755 --- a/src/xio.h +++ b/src/xio.h @@ -282,7 +282,6 @@ enum xioSignals { #define CHAR_FEEDHOLD (char)'!' #define CHAR_CYCLE_START (char)'~' #define CHAR_QUEUE_FLUSH (char)'%' -//#define CHAR_BOOTLOADER ESC /* XIO return codes * These codes are the "inner nest" for the STAT_ return codes. -- 2.27.0