├── inc ├── inc ├── jog.h ├── eeprom.h ├── limits.h ├── coolant_control.h ├── probe.h ├── print.h ├── tool.h ├── protocol.h ├── stm32eeprom.h ├── serial.h ├── stepper.h ├── motion_control.h ├── spindle_control.h ├── stm32f10x_conf.h ├── nuts_bolts.h ├── report.h ├── grbl.h └── settings.h ├── src ├── src ├── jog.c ├── probe.c ├── nuts_bolts.c └── print.c ├── .metadata ├── meta └── version.ini ├── usb ├── CVS │ ├── Root │ ├── Repository │ ├── Entries.Extra │ ├── Entries.Extra.Old │ ├── Entries │ └── Entries.Old ├── platform_config.h ├── stbool.h ├── usb_pwr.h ├── hw_config.h ├── stm32f10x_it.h ├── usb_desc.h ├── usb_endp.c.bak ├── usb_prop.h ├── usb_istr.h ├── usb_endp.c └── hw_config.c ├── Libraries ├── CMSIS │ ├── index.htm │ ├── CMSIS END USER LICENCE AGREEMENT.pdf │ ├── Include │ │ └── arm_common_tables.h │ ├── README.txt │ └── Device │ │ └── ST │ │ └── STM32F10x │ │ └── Include │ │ ├── system_stm32f10x.h │ │ └── stm32f10x_conf.h └── STM32F10x_StdPeriph_Driver │ ├── inc │ ├── stm32f10x_crc.h │ ├── stm32f10x_wwdg.h │ ├── stm32f10x_dbgmcu.h │ ├── stm32f10x_iwdg.h │ ├── stm32f10x_rtc.h │ └── stm32f10x_pwr.h │ └── src │ ├── stm32f10x_crc.c │ ├── stm32f10x_iwdg.c │ └── stm32f10x_dbgmcu.c ├── K40MiddlemenSG_2019-04-29.zip ├── doc ├── log │ ├── commit_log_v0.9j.txt │ └── commit_log_v1.0b.txt └── csv │ ├── build_option_codes_en_US.csv │ ├── alarm_codes_en_US.csv │ ├── error_codes_en_US.csv │ └── setting_codes_en_US.csv ├── .project ├── stm_usb_fs_lib ├── inc │ ├── usb_int.h │ ├── usb_mem.h │ ├── usb_sil.h │ ├── usb_lib.h │ ├── usb_init.h │ ├── usb_type.h │ └── usb_def.h └── src │ ├── usb_lib.h │ ├── usb_init.c │ ├── usb_mem.c │ ├── usb_sil.c │ └── usb_int.c ├── README.md ├── .code_review_properties └── stm32_flash.ld /inc/inc: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/src: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.metadata/meta: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /usb/CVS/Root: -------------------------------------------------------------------------------- 1 | :local:E:/CVSRep 2 | -------------------------------------------------------------------------------- /usb/CVS/Repository: -------------------------------------------------------------------------------- 1 | Code/grbl1.0d/stm32grbl/usb 2 | -------------------------------------------------------------------------------- /Libraries/CMSIS/index.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulusjacobus/SuperGerbil/HEAD/Libraries/CMSIS/index.htm -------------------------------------------------------------------------------- /K40MiddlemenSG_2019-04-29.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulusjacobus/SuperGerbil/HEAD/K40MiddlemenSG_2019-04-29.zip -------------------------------------------------------------------------------- /.metadata/version.ini: -------------------------------------------------------------------------------- 1 | #Thu Jan 17 17:20:36 AEDT 2019 2 | org.eclipse.core.runtime=2 3 | org.eclipse.platform=4.6.1.v20160907-1200 4 | -------------------------------------------------------------------------------- /Libraries/CMSIS/CMSIS END USER LICENCE AGREEMENT.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulusjacobus/SuperGerbil/HEAD/Libraries/CMSIS/CMSIS END USER LICENCE AGREEMENT.pdf -------------------------------------------------------------------------------- /usb/platform_config.h: -------------------------------------------------------------------------------- 1 | #ifndef __PLATFORM_CONFIG_H 2 | #define __PLATFORM_CONFIG_H 3 | 4 | #include "stm32f10x.h" 5 | 6 | #endif /* __PLATFORM_CONFIG_H */ 7 | 8 | -------------------------------------------------------------------------------- /usb/CVS/Entries.Extra: -------------------------------------------------------------------------------- 1 | /usb_pwr.h///1468199674/ 2 | /usb_prop.h///1468199675/ 3 | /usb_istr.h///1468199675/ 4 | /usb_desc.h///1468199675/ 5 | /usb_conf.h///1468199675/ 6 | /stm32f10x_it.h///1468199675/ 7 | /platform_config.h///1468199675/ 8 | /hw_config.h///1468199675/ 9 | /usb_pwr.c///1468199675/ 10 | /usb_desc.c///1468199675/ 11 | /hw_config.c///1468199675/ 12 | /usb_istr.c///1468199675/ 13 | /usb_endp.c///1471019589/ 14 | /usb_prop.c///1468199675/ 15 | -------------------------------------------------------------------------------- /usb/CVS/Entries.Extra.Old: -------------------------------------------------------------------------------- 1 | /usb_pwr.h///1468199674/ 2 | /usb_prop.h///1468199675/ 3 | /usb_istr.h///1468199675/ 4 | /usb_desc.h///1468199675/ 5 | /usb_conf.h///1468199675/ 6 | /stm32f10x_it.h///1468199675/ 7 | /platform_config.h///1468199675/ 8 | /hw_config.h///1468199675/ 9 | /usb_pwr.c///1468199675/ 10 | /usb_prop.c///1468199675/ 11 | /usb_desc.c///1468199675/ 12 | /hw_config.c///1468199675/ 13 | /usb_istr.c///1468199675/ 14 | /usb_endp.c///1471019589/ 15 | -------------------------------------------------------------------------------- /doc/log/commit_log_v0.9j.txt: -------------------------------------------------------------------------------- 1 | ---------------- 2 | Date: 2015-08-14 3 | Author: Sonny Jeon 4 | Subject: Individual control pin invert compile-option. 5 | 6 | - Control pins may be individually inverted through a 7 | CONTROL_INVERT_MASK macro. This mask is define in the cpu_map.h file. 8 | 9 | 10 | ---------------- 11 | Date: 2015-07-17 12 | Author: Sonny Jeon 13 | Subject: Version bump to v0.9j 14 | 15 | - Version bump requested by OEMs to easily determine whether the 16 | firmware supports the new EEPROM reset feature. Other than that, no 17 | significant changes. 18 | -------------------------------------------------------------------------------- /usb/CVS/Entries: -------------------------------------------------------------------------------- 1 | /usb_pwr.h/1.1/Sat Mar 19 10:14:24 2011// 2 | /usb_prop.h/1.1/Sat Mar 19 10:14:24 2011// 3 | /usb_istr.h/1.1/Sat Mar 19 10:14:24 2011// 4 | /usb_desc.h/1.1/Fri Mar 30 21:03:34 2012// 5 | /usb_conf.h/1.1/Sat Mar 19 10:14:24 2011// 6 | /stm32f10x_it.h/1.1/Sat Mar 19 10:14:24 2011// 7 | /platform_config.h/1.1/Tue Mar 1 04:44:10 2016// 8 | /hw_config.h/1.1/Wed Jun 1 01:57:17 2016// 9 | /usb_pwr.c/1.1/Sat Mar 19 10:14:26 2011// 10 | /usb_desc.c/1.1/Wed Jun 1 01:53:39 2016// 11 | /hw_config.c/1.1/Sat Nov 19 06:07:40 2016// 12 | /usb_istr.c/1.1/Wed Nov 16 07:23:56 2016// 13 | /usb_endp.c/1.3/Mon Nov 21 06:19:40 2016// 14 | /usb_prop.c/1.1/Mon Nov 21 07:52:24 2016// 15 | D 16 | -------------------------------------------------------------------------------- /usb/CVS/Entries.Old: -------------------------------------------------------------------------------- 1 | /usb_pwr.h/1.1/Sat Mar 19 10:14:24 2011// 2 | /usb_prop.h/1.1/Sat Mar 19 10:14:24 2011// 3 | /usb_istr.h/1.1/Sat Mar 19 10:14:24 2011// 4 | /usb_desc.h/1.1/Fri Mar 30 21:03:34 2012// 5 | /usb_conf.h/1.1/Sat Mar 19 10:14:24 2011// 6 | /stm32f10x_it.h/1.1/Sat Mar 19 10:14:24 2011// 7 | /platform_config.h/1.1/Tue Mar 1 04:44:10 2016// 8 | /hw_config.h/1.1/Wed Jun 1 01:57:17 2016// 9 | /usb_pwr.c/1.1/Sat Mar 19 10:14:26 2011// 10 | /usb_prop.c/1.1/Sat Mar 31 16:25:44 2012// 11 | /usb_desc.c/1.1/Wed Jun 1 01:53:39 2016// 12 | /hw_config.c/1.1/Sat Nov 19 06:07:40 2016// 13 | /usb_istr.c/1.1/Wed Nov 16 07:23:56 2016// 14 | /usb_endp.c/1.3/Mon Nov 21 06:19:40 2016// 15 | D 16 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | stm32grbl11 4 | 5 | 6 | stm32grbl11 7 | 8 | 9 | 10 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 11 | clean,full,incremental, 12 | 13 | 14 | 15 | 16 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 17 | full,incremental, 18 | 19 | 20 | 21 | 22 | 23 | org.eclipse.cdt.core.cnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /doc/csv/build_option_codes_en_US.csv: -------------------------------------------------------------------------------- 1 | "OPT: Code"," Build-Option Description","State" 2 | "V","Variable spindle","Enabled" 3 | "N","Line numbers","Enabled" 4 | "M","Mist coolant M7","Enabled" 5 | "C","CoreXY","Enabled" 6 | "P","Parking motion","Enabled" 7 | "Z","Homing force origin","Enabled" 8 | "H","Homing single axis commands","Enabled" 9 | "T","Two limit switches on axis","Enabled" 10 | "A","Allow feed rate overrides in probe cycles","Enabled" 11 | "D","Use spindle direction as enable pin","Enabled" 12 | "0","Spindle enable off when speed is zero","Enabled" 13 | "S","Software limit pin debouncing","Enabled" 14 | "R","Parking override control","Enabled" 15 | "*","Restore all EEPROM command","Disabled" 16 | "$","Restore EEPROM `$` settings command","Disabled" 17 | "#","Restore EEPROM parameter data command","Disabled" 18 | "I","Build info write user string command","Disabled" 19 | "E","Force sync upon EEPROM write","Disabled" 20 | "W","Force sync upon work coordinate offset change","Disabled" 21 | "L","Homing initialization auto-lock","Disabled" -------------------------------------------------------------------------------- /inc/jog.h: -------------------------------------------------------------------------------- 1 | /* 2 | jog.h - Jogging methods 3 | Part of Grbl 4 | 5 | Copyright (c) 2016 Sungeun K. Jeon for Gnea Research LLC 6 | 7 | Grbl is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | Grbl is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Grbl. If not, see . 19 | */ 20 | 21 | #ifndef jog_h 22 | #define jog_h 23 | 24 | #include "gcode.h" 25 | 26 | // System motion line numbers must be zero. 27 | #define JOG_LINE_NUMBER 0 28 | 29 | // Sets up valid jog motion received from g-code parser, checks for soft-limits, and executes the jog. 30 | uint8_t jog_execute(plan_line_data_t *pl_data, parser_block_t *gc_block); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /doc/csv/alarm_codes_en_US.csv: -------------------------------------------------------------------------------- 1 | "Alarm Code in v1.1+"," Alarm Message in v1.0-"," Alarm Description" 2 | "1","Hard limit","Hard limit has been triggered. Machine position is likely lost due to sudden halt. Re-homing is highly recommended." 3 | "2","Soft limit","Soft limit alarm. G-code motion target exceeds machine travel. Machine position retained. Alarm may be safely unlocked." 4 | "3","Abort during cycle","Reset while in motion. Machine position is likely lost due to sudden halt. Re-homing is highly recommended." 5 | "4","Probe fail","Probe fail. Probe is not in the expected initial state before starting probe cycle when G38.2 and G38.3 is not triggered and G38.4 and G38.5 is triggered." 6 | "5","Probe fail","Probe fail. Probe did not contact the workpiece within the programmed travel for G38.2 and G38.4." 7 | "6","Homing fail","Homing fail. The active homing cycle was reset." 8 | "7","Homing fail","Homing fail. Safety door was opened during homing cycle." 9 | "8","Homing fail","Homing fail. Pull off travel failed to clear limit switch. Try increasing pull-off setting or check wiring." 10 | "9","Homing fail","Homing fail. Could not find limit switch within search distances. Try increasing max travel, decreasing pull-off distance, or check wiring." 11 | -------------------------------------------------------------------------------- /inc/eeprom.h: -------------------------------------------------------------------------------- 1 | /* 2 | eeprom.h - EEPROM methods 3 | Part of Grbl 4 | 5 | Copyright (c) 2009-2011 Simen Svale Skogsrud 6 | 7 | Grbl is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | Grbl is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Grbl. If not, see . 19 | */ 20 | 21 | #ifndef eeprom_h 22 | #define eeprom_h 23 | #if defined(WIN32) || defined (STM32F103C8) 24 | void eeprom_init(); 25 | #endif 26 | unsigned char eeprom_get_char(unsigned int addr); 27 | void eeprom_put_char(unsigned int addr, unsigned char new_value); 28 | void memcpy_to_eeprom_with_checksum(unsigned int destination, char *source, unsigned int size); 29 | int memcpy_from_eeprom_with_checksum(char *destination, unsigned int source, unsigned int size); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /Libraries/CMSIS/Include/arm_common_tables.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. 3 | * 4 | * $Date: 11. November 2010 5 | * $Revision: V1.0.2 6 | * 7 | * Project: CMSIS DSP Library 8 | * Title: arm_common_tables.h 9 | * 10 | * Description: This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions 11 | * 12 | * Target Processor: Cortex-M4/Cortex-M3 13 | * 14 | * Version 1.0.2 2010/11/11 15 | * Documentation updated. 16 | * 17 | * Version 1.0.1 2010/10/05 18 | * Production release and review comments incorporated. 19 | * 20 | * Version 1.0.0 2010/09/20 21 | * Production release and review comments incorporated. 22 | * -------------------------------------------------------------------- */ 23 | 24 | #ifndef _ARM_COMMON_TABLES_H 25 | #define _ARM_COMMON_TABLES_H 26 | 27 | #include "arm_math.h" 28 | 29 | extern uint16_t armBitRevTable[256]; 30 | extern q15_t armRecipTableQ15[64]; 31 | extern q31_t armRecipTableQ31[64]; 32 | extern const q31_t realCoefAQ31[1024]; 33 | extern const q31_t realCoefBQ31[1024]; 34 | 35 | #endif /* ARM_COMMON_TABLES_H */ 36 | -------------------------------------------------------------------------------- /inc/limits.h: -------------------------------------------------------------------------------- 1 | /* 2 | limits.h - code pertaining to limit-switches and performing the homing cycle 3 | Part of Grbl 4 | 5 | Copyright (c) 2012-2016 Sungeun K. Jeon for Gnea Research LLC 6 | Copyright (c) 2009-2011 Simen Svale Skogsrud 7 | 8 | Grbl is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Grbl is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Grbl. If not, see . 20 | */ 21 | 22 | #ifndef limits_h 23 | #define limits_h 24 | 25 | 26 | // Initialize the limits module 27 | void limits_init(); 28 | 29 | // Disables hard limits. 30 | void limits_disable(); 31 | 32 | // Returns limit state as a bit-wise uint8 variable. 33 | uint8_t limits_get_state(); 34 | 35 | // Perform one portion of the homing cycle based on the input settings. 36 | void limits_go_home(uint8_t cycle_mask); 37 | 38 | // Check for soft limit violations 39 | void limits_soft_check(float *target); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /usb/stbool.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** 2 | * File Name : hw_config.h 3 | * Author : MCD Application Team 4 | * Version : V3.3.0 5 | * Date : 21-March-2011 6 | * Description : Hardware Configuration & Setup 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | 18 | 19 | // file : myboolean.h 20 | #ifndef STBOOL_H 21 | #define STBOOL_H 22 | 23 | #define false 0 24 | #define true 1 25 | typedef int bool; // or #define bool int 26 | 27 | 28 | /* External variables --------------------------------------------------------*/ 29 | 30 | #endif /*__HW_CONFIG_H*/ 31 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 32 | -------------------------------------------------------------------------------- /Libraries/CMSIS/README.txt: -------------------------------------------------------------------------------- 1 | * ------------------------------------------------------------------- 2 | * Copyright (C) 2011 ARM Limited. All rights reserved. 3 | * 4 | * Date: 25 July 2011 5 | * Revision: V2.10 6 | * 7 | * Project: Cortex Microcontroller Software Interface Standard (CMSIS) 8 | * Title: Release Note for CMSIS 9 | * 10 | * ------------------------------------------------------------------- 11 | 12 | 13 | NOTE - Open the index.html file to access CMSIS documentation 14 | 15 | 16 | The Cortex Microcontroller Software Interface Standard (CMSIS) provides a single standard across all 17 | Cortex-Mx processor series vendors. It enables code re-use and code sharing across software projects 18 | and reduces time-to-market for new embedded applications. 19 | 20 | CMSIS is released under the terms of the end user license agreement ("CMSIS END USER LICENCE AGREEMENT.pdf"). 21 | Any user of the software package is bound to the terms and conditions of the end user license agreement. 22 | 23 | 24 | You will find the following sub-directories: 25 | 26 | Documentation - Contains CMSIS documentation. 27 | 28 | DSP_Lib - MDK project files, Examples and source files etc.. to build the 29 | CMSIS DSP Software Library for Cortex-M0, Cortex-M3, Cortex-M4 processors. 30 | 31 | Include - CMSIS Core Support and CMSIS DSP Include Files. 32 | 33 | Lib - CMSIS DSP Binaries 34 | --- -------------------------------------------------------------------------------- /inc/coolant_control.h: -------------------------------------------------------------------------------- 1 | /* 2 | coolant_control.h - spindle control methods 3 | Part of Grbl 4 | 5 | Copyright (c) 2012-2016 Sungeun K. Jeon for Gnea Research LLC 6 | 7 | Grbl is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | Grbl is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Grbl. If not, see . 19 | */ 20 | 21 | #ifndef coolant_control_h 22 | #define coolant_control_h 23 | 24 | #define COOLANT_NO_SYNC false 25 | #define COOLANT_FORCE_SYNC true 26 | 27 | #define COOLANT_STATE_DISABLE 0 // Must be zero 28 | #define COOLANT_STATE_FLOOD bit(0) 29 | #define COOLANT_STATE_MIST bit(1) 30 | 31 | 32 | // Initializes coolant control pins. 33 | void coolant_init(); 34 | 35 | // Returns current coolant output state. Overrides may alter it from programmed state. 36 | uint8_t coolant_get_state(); 37 | 38 | // Immediately disables coolant pins. 39 | void coolant_stop(); 40 | 41 | // Sets the coolant pins according to state specified. 42 | void coolant_set_state(uint8_t mode); 43 | 44 | // G-code parser entry-point for setting coolant states. Checks for and executes additional conditions. 45 | void coolant_sync(uint8_t mode); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /inc/probe.h: -------------------------------------------------------------------------------- 1 | /* 2 | probe.h - code pertaining to probing methods 3 | Part of Grbl 4 | 5 | Copyright (c) 2014-2016 Sungeun K. Jeon for Gnea Research LLC 6 | 7 | Grbl is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | Grbl is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Grbl. If not, see . 19 | */ 20 | 21 | #ifndef probe_h 22 | #define probe_h 23 | 24 | // Values that define the probing state machine. 25 | #define PROBE_OFF 0 // Probing disabled or not in use. (Must be zero.) 26 | #define PROBE_ACTIVE 1 // Actively watching the input pin. 27 | 28 | // Probe pin initialization routine. 29 | void probe_init(); 30 | 31 | // Called by probe_init() and the mc_probe() routines. Sets up the probe pin invert mask to 32 | // appropriately set the pin logic according to setting for normal-high/normal-low operation 33 | // and the probing cycle modes for toward-workpiece/away-from-workpiece. 34 | void probe_configure_invert_mask(uint8_t is_probe_away); 35 | 36 | // Returns probe pin state. Triggered = true. Called by gcode parser and probe state monitor. 37 | uint8_t probe_get_state(); 38 | 39 | // Monitors probe pin state and records the system position when detected. Called by the 40 | // stepper ISR per ISR tick. 41 | void probe_state_monitor(); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /stm_usb_fs_lib/inc/usb_int.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** 2 | * File Name : usb_int.h 3 | * Author : MCD Application Team 4 | * Version : V3.2.1 5 | * Date : 07/05/2010 6 | * Description : Endpoint CTR (Low and High) interrupt's service routines 7 | * prototypes 8 | ******************************************************************************** 9 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 10 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 11 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 12 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 13 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 14 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 15 | *******************************************************************************/ 16 | 17 | /* Define to prevent recursive inclusion -------------------------------------*/ 18 | #ifndef __USB_INT_H 19 | #define __USB_INT_H 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | /* Exported types ------------------------------------------------------------*/ 23 | /* Exported constants --------------------------------------------------------*/ 24 | /* Exported macro ------------------------------------------------------------*/ 25 | /* Exported functions ------------------------------------------------------- */ 26 | void CTR_LP(void); 27 | void CTR_HP(void); 28 | 29 | /* External variables --------------------------------------------------------*/ 30 | 31 | #endif /* __USB_INT_H */ 32 | 33 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 34 | -------------------------------------------------------------------------------- /inc/print.h: -------------------------------------------------------------------------------- 1 | /* 2 | print.h - Functions for formatting output strings 3 | Part of Grbl 4 | 5 | Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC 6 | Copyright (c) 2009-2011 Simen Svale Skogsrud 7 | 8 | Grbl is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Grbl is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Grbl. If not, see . 20 | */ 21 | 22 | #ifndef print_h 23 | #define print_h 24 | 25 | 26 | void printString(const char *s); 27 | 28 | void printPgmString(const char *s); 29 | 30 | void printInteger(long n); 31 | 32 | void print_uint32_base10(uint32_t n); 33 | 34 | // Prints an uint8 variable in base 10. 35 | void print_uint8_base10(uint8_t n); 36 | 37 | // Prints an uint8 variable in base 2 with desired number of desired digits. 38 | void print_uint8_base2_ndigit(uint8_t n, uint8_t digits); 39 | 40 | void printFloat(float n, uint8_t decimal_places); 41 | 42 | // Floating value printing handlers for special variables types used in Grbl. 43 | // - CoordValue: Handles all position or coordinate values in inches or mm reporting. 44 | // - RateValue: Handles feed rate and current velocity in inches or mm reporting. 45 | void printFloat_CoordValue(float n); 46 | void printFloat_RateValue(float n); 47 | 48 | // Debug tool to print free memory in bytes at the called point. Not used otherwise. 49 | void printFreeMemory(); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /stm_usb_fs_lib/inc/usb_mem.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** 2 | * File Name : usb_mem.h 3 | * Author : MCD Application Team 4 | * Version : V3.2.1 5 | * Date : 07/05/2010 6 | * Description : Utility prototypes functions for memory/PMA transfers 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __USB_MEM_H 18 | #define __USB_MEM_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | /* Exported types ------------------------------------------------------------*/ 22 | /* Exported constants --------------------------------------------------------*/ 23 | /* Exported macro ------------------------------------------------------------*/ 24 | /* Exported functions ------------------------------------------------------- */ 25 | void UserToPMABufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes); 26 | void PMAToUserBufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes); 27 | 28 | /* External variables --------------------------------------------------------*/ 29 | 30 | #endif /*__USB_MEM_H*/ 31 | 32 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 33 | -------------------------------------------------------------------------------- /src/jog.c: -------------------------------------------------------------------------------- 1 | /* 2 | jog.h - Jogging methods 3 | Part of Grbl 4 | 5 | Copyright (c) 2016 Sungeun K. Jeon for Gnea Research LLC 6 | 7 | Grbl is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | Grbl is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Grbl. If not, see . 19 | */ 20 | 21 | #include "grbl.h" 22 | 23 | 24 | // Sets up valid jog motion received from g-code parser, checks for soft-limits, and executes the jog. 25 | uint8_t jog_execute(plan_line_data_t *pl_data, parser_block_t *gc_block) 26 | { 27 | // Initialize planner data struct for jogging motions. 28 | // NOTE: Spindle and coolant are allowed to fully function with overrides during a jog. 29 | pl_data->feed_rate = gc_block->values.f; 30 | pl_data->condition |= PL_COND_FLAG_NO_FEED_OVERRIDE; 31 | #ifdef USE_LINE_NUMBERS 32 | pl_data->line_number = gc_block->values.n; 33 | #endif 34 | 35 | if (bit_istrue(settings.flags, BITFLAG_SOFT_LIMIT_ENABLE)) { 36 | if (system_check_travel_limits(gc_block->values.xyz)) { return(STATUS_TRAVEL_EXCEEDED); } 37 | } 38 | 39 | // Valid jog command. Plan, set state, and execute. 40 | mc_line(gc_block->values.xyz, pl_data); 41 | if (sys.state == STATE_IDLE) { 42 | if (plan_get_current_block() != NULL) { // Check if there is a block to execute. 43 | sys.state = STATE_JOG; 44 | st_prep_buffer(); 45 | st_wake_up(); // NOTE: Manual start. No state machine required. 46 | } 47 | } 48 | 49 | return(STATUS_OK); 50 | } 51 | -------------------------------------------------------------------------------- /stm_usb_fs_lib/inc/usb_sil.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** 2 | * File Name : usb_sil.h 3 | * Author : MCD Application Team 4 | * Version : V3.2.1 5 | * Date : 07/05/2010 6 | * Description : Simplified Interface Layer function prototypes. 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __USB_SIL_H 18 | #define __USB_SIL_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | /* Exported types ------------------------------------------------------------*/ 22 | /* Exported constants --------------------------------------------------------*/ 23 | /* Exported macro ------------------------------------------------------------*/ 24 | /* Exported functions ------------------------------------------------------- */ 25 | 26 | uint32_t USB_SIL_Init(void); 27 | uint32_t USB_SIL_Write(uint8_t bEpAddr, uint8_t* pBufferPointer, uint32_t wBufferSize); 28 | uint32_t USB_SIL_Read(uint8_t bEpAddr, uint8_t* pBufferPointer); 29 | 30 | /* External variables --------------------------------------------------------*/ 31 | 32 | #endif /* __USB_SIL_H */ 33 | 34 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 35 | -------------------------------------------------------------------------------- /inc/tool.h: -------------------------------------------------------------------------------- 1 | /* 2 | tool_control.h - spindle control methods 3 | Part of Grbl 4 | 5 | Copyright (c) 2012-2016 Sungeun K. Jeon for Gnea Research LLC 6 | 7 | Grbl is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | Grbl is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Grbl. If not, see . 19 | */ 20 | 21 | #ifndef tool_h 22 | #define tool_h 23 | 24 | #define TOOL_NO_SYNC false 25 | #define TOOL_FORCE_SYNC true 26 | 27 | #define TOOL_T_DISABLE 0 // Must be zero 28 | #define TOOL_M6_DISABLE 1 // 29 | #define TOOL_T_ENABLE bit(1) // tool is being changed 30 | #define TOOL_M6_ENABLE bit(2) // tool valve is enable 31 | 32 | 33 | // Initializes tool control pins. 34 | void tool_init(); 35 | 36 | // Returns current tool output state. Overrides may alter it from programmed state. 37 | uint8_t tool_get_state(); 38 | 39 | // Immediately disables tool pins. 40 | void tool_stop(); 41 | // stepper ISR timing for duration of the toggle Tn pulse 42 | void tool_stop_tn(); 43 | // stepper ISR timing for duration of the M6 command 44 | void tool_stop_m6(); 45 | 46 | // Sets the tool pins according to state specified. 47 | void tool_set_m6_state(uint8_t mode); 48 | 49 | void tool_set_t_state(uint8_t mode); 50 | 51 | // G-code parser entry-point for setting tool states. Checks for and executes additional conditions. 52 | void tool_t_sync(uint8_t mode); 53 | void tool_m6_sync(uint8_t mode); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /inc/protocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | protocol.h - controls Grbl execution protocol and procedures 3 | Part of Grbl 4 | 5 | Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC 6 | Copyright (c) 2009-2011 Simen Svale Skogsrud 7 | 8 | Grbl is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Grbl is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Grbl. If not, see . 20 | */ 21 | 22 | #ifndef protocol_h 23 | #define protocol_h 24 | 25 | // Line buffer size from the serial input stream to be executed. 26 | // NOTE: Not a problem except for extreme cases, but the line buffer size can be too small 27 | // and g-code blocks can get truncated. Officially, the g-code standards support up to 256 28 | // characters. In future versions, this will be increased, when we know how much extra 29 | // memory space we can invest into here or we re-write the g-code parser not to have this 30 | // buffer. 31 | #ifndef LINE_BUFFER_SIZE 32 | #define LINE_BUFFER_SIZE 80 33 | #endif 34 | 35 | // Starts Grbl main loop. It handles all incoming characters from the serial port and executes 36 | // them as they complete. It is also responsible for finishing the initialization procedures. 37 | void protocol_main_loop(); 38 | 39 | // Checks and executes a realtime command at various stop points in main program 40 | void protocol_execute_realtime(); 41 | void protocol_exec_rt_system(); 42 | 43 | // Executes the auto cycle feature, if enabled. 44 | void protocol_auto_cycle_start(); 45 | 46 | // Block until all buffered steps are executed 47 | void protocol_buffer_synchronize(); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /inc/stm32eeprom.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file EEPROM_Emulation/inc/eeprom.h 4 | * @author MCD Application Team 5 | * @version V3.1.0 6 | * @date 07/27/2009 7 | * @brief This file contains all the functions prototypes for the EEPROM 8 | * emulation firmware library. 9 | ****************************************************************************** 10 | * @copy 11 | * 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 18 | * 19 | *

© COPYRIGHT 2009 STMicroelectronics

20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __EEPROM_H 24 | #define __EEPROM_H 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | #include "stm32f10x_flash.h" 28 | 29 | /* Exported constants --------------------------------------------------------*/ 30 | /* Define the STM32F10Xxx Flash page size depending on the used STM32 device */ 31 | #if defined (STM32F10X_LD) || defined (STM32F10X_MD) 32 | #define PAGE_SIZE (uint16_t)0x400 /* Page size = 1KByte */ 33 | #elif defined (STM32F10X_HD) || defined (STM32F10X_CL) 34 | #define PAGE_SIZE (uint16_t)0x800 /* Page size = 2KByte */ 35 | #endif 36 | 37 | /* EEPROM start address in Flash */ 38 | #define EEPROM_START_ADDRESS ((uint32_t)0x0801fc00) /* EEPROM emulation start address: 39 | after 64KByte of used Flash memory */ 40 | 41 | #endif /* __EEPROM_H */ 42 | 43 | /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ 44 | -------------------------------------------------------------------------------- /stm_usb_fs_lib/inc/usb_lib.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** 2 | * File Name : usb_lib.h 3 | * Author : MCD Application Team 4 | * Version : V3.2.1 5 | * Date : 07/05/2010 6 | * Description : USB library include files 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __USB_LIB_H 18 | #define __USB_LIB_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "stm32f10x.h" 22 | #include "usb_type.h" 23 | #include "usb_regs.h" 24 | #include "usb_def.h" 25 | #include "usb_core.h" 26 | #include "usb_init.h" 27 | #ifndef STM32F10X_CL 28 | #include "usb_mem.h" 29 | #include "usb_int.h" 30 | #endif /* STM32F10X_CL */ 31 | 32 | #include "usb_sil.h" 33 | 34 | #ifdef STM32F10X_CL 35 | #include "otgd_fs_cal.h" 36 | #include "otgd_fs_pcd.h" 37 | #include "otgd_fs_dev.h" 38 | #include "otgd_fs_int.h" 39 | #endif /* STM32F10X_CL */ 40 | 41 | 42 | /* Exported types ------------------------------------------------------------*/ 43 | /* Exported constants --------------------------------------------------------*/ 44 | /* Exported macro ------------------------------------------------------------*/ 45 | /* Exported functions ------------------------------------------------------- */ 46 | /* External variables --------------------------------------------------------*/ 47 | 48 | #endif /* __USB_LIB_H */ 49 | 50 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 51 | -------------------------------------------------------------------------------- /stm_usb_fs_lib/src/usb_lib.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** 2 | * File Name : usb_lib.h 3 | * Author : MCD Application Team 4 | * Version : V3.2.1 5 | * Date : 07/05/2010 6 | * Description : USB library include files 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __USB_LIB_H 18 | #define __USB_LIB_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "stm32f10x.h" 22 | #include "usb_type.h" 23 | #include "usb_regs.h" 24 | #include "usb_def.h" 25 | #include "usb_core.h" 26 | #include "usb_init.h" 27 | #ifndef STM32F10X_CL 28 | #include "usb_mem.h" 29 | #include "usb_int.h" 30 | #endif /* STM32F10X_CL */ 31 | 32 | #include "usb_sil.h" 33 | 34 | #ifdef STM32F10X_CL 35 | #include "otgd_fs_cal.h" 36 | #include "otgd_fs_pcd.h" 37 | #include "otgd_fs_dev.h" 38 | #include "otgd_fs_int.h" 39 | #endif /* STM32F10X_CL */ 40 | 41 | 42 | /* Exported types ------------------------------------------------------------*/ 43 | /* Exported constants --------------------------------------------------------*/ 44 | /* Exported macro ------------------------------------------------------------*/ 45 | /* Exported functions ------------------------------------------------------- */ 46 | /* External variables --------------------------------------------------------*/ 47 | 48 | #endif /* __USB_LIB_H */ 49 | 50 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 51 | -------------------------------------------------------------------------------- /usb/usb_pwr.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** 2 | * File Name : usb_pwr.h 3 | * Author : MCD Application Team 4 | * Version : V3.3.0 5 | * Date : 21-March-2011 6 | * Description : Connection/disconnection & power management header 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __USB_PWR_H 18 | #define __USB_PWR_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | /* Exported types ------------------------------------------------------------*/ 22 | typedef enum _RESUME_STATE 23 | { 24 | RESUME_EXTERNAL, 25 | RESUME_INTERNAL, 26 | RESUME_LATER, 27 | RESUME_WAIT, 28 | RESUME_START, 29 | RESUME_ON, 30 | RESUME_OFF, 31 | RESUME_ESOF 32 | } RESUME_STATE; 33 | 34 | typedef enum _DEVICE_STATE 35 | { 36 | UNCONNECTED, 37 | ATTACHED, 38 | POWERED, 39 | SUSPENDED, 40 | ADDRESSED, 41 | CONFIGURED 42 | } DEVICE_STATE; 43 | 44 | /* Exported constants --------------------------------------------------------*/ 45 | /* Exported macro ------------------------------------------------------------*/ 46 | /* Exported functions ------------------------------------------------------- */ 47 | void Suspend(void); 48 | void Resume_Init(void); 49 | void Resume(RESUME_STATE eResumeSetVal); 50 | RESULT PowerOn(void); 51 | RESULT PowerOff(void); 52 | 53 | /* External variables --------------------------------------------------------*/ 54 | extern __IO uint32_t bDeviceState; /* USB device status */ 55 | extern __IO bool fSuspendEnabled; /* true when suspend is possible */ 56 | 57 | #endif /*__USB_PWR_H*/ 58 | 59 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 60 | -------------------------------------------------------------------------------- /inc/serial.h: -------------------------------------------------------------------------------- 1 | /* 2 | serial.c - Low level functions for sending and recieving bytes via the serial port 3 | Part of Grbl 4 | 5 | Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC 6 | Copyright (c) 2009-2011 Simen Svale Skogsrud 7 | 8 | Grbl is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Grbl is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Grbl. If not, see . 20 | */ 21 | 22 | #ifndef serial_h 23 | #define serial_h 24 | 25 | #ifdef AVRTARGET 26 | #ifndef RX_BUFFER_SIZE 27 | #define RX_BUFFER_SIZE 128 28 | #endif 29 | #ifndef TX_BUFFER_SIZE 30 | #ifdef USE_LINE_NUMBERS 31 | #define TX_BUFFER_SIZE 112 32 | #else 33 | #define TX_BUFFER_SIZE 104 34 | #endif 35 | #endif 36 | #else 37 | #define RX_BUFFER_SIZE 254//254 38 | #ifndef WIN32 39 | #define TX_BUFFER_SIZE 128 //128 // Do not try 256 it will not work for STM32. 40 | #else 41 | #define TX_BUFFER_SIZE 254 42 | #endif 43 | #endif 44 | 45 | #define SERIAL_NO_DATA 0xff 46 | 47 | #ifdef WIN32 48 | void winserial_init(char *pPort); 49 | #endif 50 | 51 | void serial_init(); 52 | 53 | // Writes one byte to the TX serial buffer. Called by main program. 54 | void serial_write(uint8_t data); 55 | 56 | // Fetches the first byte in the serial read buffer. Called by main program. 57 | uint8_t serial_read(); 58 | 59 | // Reset and empty data in read buffer. Used by e-stop and reset. 60 | void serial_reset_read_buffer(); 61 | 62 | // Returns the number of bytes available in the RX serial buffer. 63 | uint16_t serial_get_rx_buffer_available(); 64 | 65 | // Returns the number of bytes used in the RX serial buffer. 66 | // NOTE: Deprecated. Not used unless classic status reports are enabled in config.h. 67 | uint8_t serial_get_rx_buffer_count(); 68 | 69 | // Returns the number of bytes used in the TX serial buffer. 70 | // NOTE: Not used except for debugging and ensuring no TX bottlenecks. 71 | uint8_t serial_get_tx_buffer_count(); 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /usb/hw_config.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** 2 | * File Name : hw_config.h 3 | * Author : MCD Application Team 4 | * Version : V3.3.0 5 | * Date : 21-March-2011 6 | * Description : Hardware Configuration & Setup 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __HW_CONFIG_H 18 | #define __HW_CONFIG_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "usb_type.h" 22 | 23 | /* Exported types ------------------------------------------------------------*/ 24 | /* Exported constants --------------------------------------------------------*/ 25 | /* Exported macro ------------------------------------------------------------*/ 26 | /* Exported define -----------------------------------------------------------*/ 27 | #define MASS_MEMORY_START 0x04002000 28 | #define BULK_MAX_PACKET_SIZE 0x00000040 29 | #define LED_ON 0xF0 30 | #define LED_OFF 0xFF 31 | 32 | #define USART_RX_DATA_SIZE (64) 33 | /* Exported functions ------------------------------------------------------- */ 34 | void Set_System(void); 35 | void Set_USBClock(void); 36 | void Enter_LowPowerMode(void); 37 | void Leave_LowPowerMode(void); 38 | void USB_Interrupts_Config(void); 39 | void USB_Cable_Config(FunctionalState NewState); 40 | void USART_Config_Default(void); 41 | bool USART_Config(void); 42 | void OnUsbDataRx(uint8_t* data_buffer, uint8_t Nb_bytes); 43 | void Get_SerialNum(void); 44 | 45 | /* External variables --------------------------------------------------------*/ 46 | 47 | #endif /*__HW_CONFIG_H*/ 48 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 49 | -------------------------------------------------------------------------------- /inc/stepper.h: -------------------------------------------------------------------------------- 1 | /* 2 | stepper.h - stepper motor driver: executes motion plans of planner.c using the stepper motors 3 | Part of Grbl 4 | 5 | Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC 6 | Copyright (c) 2009-2011 Simen Svale Skogsrud 7 | 8 | Grbl is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Grbl is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Grbl. If not, see . 20 | */ 21 | 22 | #ifndef stepper_h 23 | #define stepper_h 24 | 25 | #ifndef SEGMENT_BUFFER_SIZE 26 | #ifndef AVRTARGET 27 | #define SEGMENT_BUFFER_SIZE 32 // 6 28 | #else 29 | #define SEGMENT_BUFFER_SIZE 10 // paul 30 | #endif 31 | #endif 32 | 33 | // Initialize and setup the stepper motor subsystem 34 | void stepper_init(); 35 | 36 | // Enable steppers, but cycle does not start unless called by motion control or realtime command. 37 | void st_wake_up(); 38 | 39 | // Immediately disables steppers 40 | void st_go_idle(); 41 | 42 | // Generate the step and direction port invert masks. 43 | void st_generate_step_dir_invert_masks(); 44 | 45 | // Reset the stepper subsystem variables 46 | void st_reset(); 47 | 48 | // Changes the run state of the step segment buffer to execute the special parking motion. 49 | void st_parking_setup_buffer(); 50 | 51 | // Restores the step segment buffer to the normal run state after a parking motion. 52 | void st_parking_restore_buffer(); 53 | 54 | // Reloads step segment buffer. Called continuously by realtime execution system. 55 | void st_prep_buffer(); 56 | 57 | // Called by planner_recalculate() when the executing block is updated by the new plan. 58 | void st_update_plan_block_parameters(); 59 | 60 | // Called by realtime status reporting if realtime rate reporting is enabled in config.h. 61 | float st_get_realtime_rate(); 62 | 63 | extern const PORTPINDEF step_pin_mask[N_AXIS]; 64 | extern const PORTPINDEF direction_pin_mask[N_AXIS]; 65 | extern const PORTPINDEF limit_pin_mask[N_AXIS]; 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /usb/stm32f10x_it.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** 2 | * File Name : stm32f10x_it.h 3 | * Author : MCD Application Team 4 | * Version : V3.3.0 5 | * Date : 21-March-2011 6 | * Description : This file contains the headers of the interrupt handlers. 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __STM32F10x_IT_H 18 | #define __STM32F10x_IT_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "stm32f10x.h" 22 | 23 | /* Exported types ------------------------------------------------------------*/ 24 | /* Exported constants --------------------------------------------------------*/ 25 | /* Exported macro ------------------------------------------------------------*/ 26 | /* Exported functions ------------------------------------------------------- */ 27 | 28 | void NMI_Handler(void); 29 | void HardFault_Handler(void); 30 | void MemManage_Handler(void); 31 | void BusFault_Handler(void); 32 | void UsageFault_Handler(void); 33 | void SVC_Handler(void); 34 | void DebugMon_Handler(void); 35 | void PendSV_Handler(void); 36 | void SysTick_Handler(void); 37 | 38 | #ifndef STM32F10X_CL 39 | void USB_LP_CAN1_RX0_IRQHandler(void); 40 | #endif /* STM32F10X_CL */ 41 | 42 | #if defined (USE_STM3210B_EVAL) || defined (USE_STM3210E_EVAL) 43 | void USART1_IRQHandler(void); 44 | #endif /* USE_STM3210B_EVAL or USE_STM3210E_EVAL */ 45 | 46 | #ifdef USE_STM3210C_EVAL 47 | void USART2_IRQHandler(void); 48 | #endif /* USE_STM3210C_EVAL */ 49 | 50 | #ifdef STM32F10X_CL 51 | void OTG_FS_IRQHandler(void); 52 | #endif /* STM32F10X_CL */ 53 | 54 | #endif /* __STM32F10x_IT_H */ 55 | 56 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 57 | -------------------------------------------------------------------------------- /stm_usb_fs_lib/inc/usb_init.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** 2 | * File Name : usb_init.h 3 | * Author : MCD Application Team 4 | * Version : V3.2.1 5 | * Date : 07/05/2010 6 | * Description : Initialization routines & global variables 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __USB_INIT_H 18 | #define __USB_INIT_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | /* Exported types ------------------------------------------------------------*/ 22 | /* Exported constants --------------------------------------------------------*/ 23 | /* Exported macro ------------------------------------------------------------*/ 24 | /* Exported functions ------------------------------------------------------- */ 25 | void USB_Init(void); 26 | 27 | /* External variables --------------------------------------------------------*/ 28 | /* The number of current endpoint, it will be used to specify an endpoint */ 29 | extern uint8_t EPindex; 30 | /* The number of current device, it is an index to the Device_Table */ 31 | /*extern uint8_t Device_no; */ 32 | /* Points to the DEVICE_INFO structure of current device */ 33 | /* The purpose of this register is to speed up the execution */ 34 | extern DEVICE_INFO* pInformation; 35 | /* Points to the DEVICE_PROP structure of current device */ 36 | /* The purpose of this register is to speed up the execution */ 37 | extern DEVICE_PROP* pProperty; 38 | /* Temporary save the state of Rx & Tx status. */ 39 | /* Whenever the Rx or Tx state is changed, its value is saved */ 40 | /* in this variable first and will be set to the EPRB or EPRA */ 41 | /* at the end of interrupt process */ 42 | extern USER_STANDARD_REQUESTS *pUser_Standard_Requests; 43 | 44 | extern uint16_t SaveState ; 45 | extern uint16_t wInterrupt_Mask; 46 | 47 | #endif /* __USB_INIT_H */ 48 | 49 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 50 | -------------------------------------------------------------------------------- /Libraries/CMSIS/Device/ST/STM32F10x/Include/system_stm32f10x.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f10x.h 4 | * @author MCD Application Team 5 | * @version V3.6.1 6 | * @date 09-March-2012 7 | * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /** @addtogroup CMSIS 29 | * @{ 30 | */ 31 | 32 | /** @addtogroup stm32f10x_system 33 | * @{ 34 | */ 35 | 36 | /** 37 | * @brief Define to prevent recursive inclusion 38 | */ 39 | #ifndef __SYSTEM_STM32F10X_H 40 | #define __SYSTEM_STM32F10X_H 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /** @addtogroup STM32F10x_System_Includes 47 | * @{ 48 | */ 49 | 50 | /** 51 | * @} 52 | */ 53 | 54 | 55 | /** @addtogroup STM32F10x_System_Exported_types 56 | * @{ 57 | */ 58 | 59 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 60 | 61 | /** 62 | * @} 63 | */ 64 | 65 | /** @addtogroup STM32F10x_System_Exported_Constants 66 | * @{ 67 | */ 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @addtogroup STM32F10x_System_Exported_Macros 74 | * @{ 75 | */ 76 | 77 | /** 78 | * @} 79 | */ 80 | 81 | /** @addtogroup STM32F10x_System_Exported_Functions 82 | * @{ 83 | */ 84 | 85 | extern void SystemInit(void); 86 | extern void SystemCoreClockUpdate(void); 87 | /** 88 | * @} 89 | */ 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | 95 | #endif /*__SYSTEM_STM32F10X_H */ 96 | 97 | /** 98 | * @} 99 | */ 100 | 101 | /** 102 | * @} 103 | */ 104 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 105 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SuperGerbil 2 | STM32 driven ARM Grbl firmware 3 | ![GitHub Logo](https://awesome.tech/wp-content/uploads/2018/11/20181030_103220-1-e1547624499622.jpg) 4 | 5 | *** 6 | Latest firmware (SG_stm32grbl11.hex) for the Super Gerbil CNC controller is available here 7 | *** 8 | For the insights of ARM Grbl, please visit this page [click here] https://awesome.tech/grbl-demystified/ 9 | 10 | -Github repo grbl-1 is for Coocoox CoIde compiler 11 | -Github repo SuperGerbil is for Atollic compiler (preferred) 12 | 13 | Grbl is a no-compromise, high performance, low cost alternative to parallel-port-based motion control for CNC milling. This version of Grbl runs on a STM32F10x processor. For the appropriate boards see our website https://awesome.tech/buy-gerbil/ 14 | 15 | The controller is written in highly optimized C utilizing every clever feature of the STM32-chips to achieve precise timing and asynchronous operation. It is able to maintain up to 100kHz of stable, jitter free control pulses and PWM up to 80kHz. See specifications [click here] https://awesome.tech/new-super-gerbil-cnc/ 16 | 17 | It accepts standards-compliant g-code and has been tested with the output of several CAM tools with no problems. Arcs, circles and helical motion are fully supported, as well as, all other primary g-code commands. Macro functions, variables, and most canned cycles are not supported, but we think GUIs can do a much better job at translating them into straight g-code anyhow. 18 | 19 | Grbl includes full acceleration management with look ahead. That means the controller will look up to 16 motions into the future and plan its velocities ahead to deliver smooth acceleration and jerk-free cornering. 20 | 21 | * [Licensing](https://github.com/gnea/grbl/wiki/Licensing): Grbl is free software, released under the GPLv3 license. 22 | 23 | * For more information and help, check out our **[Wiki pages!](https://github.com/gnea/grbl/wiki)** and (https://awesome.tech) If you find that the information is out-dated, please to help us keep it updated by editing it or notifying our community! Thanks! 24 | 25 | * Lead Developer Gnea: Sungeun "Sonny" Jeon, Ph.D. (USA) aka @chamnit 26 | 27 | * Lead Developer Awesome.tech Super Gerbil: Paul "Laserboy" de Groot (AU) aka @paulusjacobus 28 | 29 | * Built on the wonderful Grbl v0.6 (2011) AND v1.1f firmware written by Simen Svale Skogsrud (Norway). 30 | 31 | *** 32 | 33 | ------------- 34 | Grbl is an open-source project and fueled by the free-time of our intrepid administrators and altruistic users. If you'd like to donate to @chamnit, all proceeds will be used to help him fund supporting hardware and testing equipment or support us Awesome.tech by buying our boards. Thank you! 35 | 36 | [![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CUGXJHXA36BYW) 37 | -------------------------------------------------------------------------------- /Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_crc.h 4 | * @author MCD Application Team 5 | * @version V3.6.1 6 | * @date 05-March-2012 7 | * @brief This file contains all the functions prototypes for the CRC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2012 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F10x_CRC_H 31 | #define __STM32F10x_CRC_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f10x.h" 39 | 40 | /** @addtogroup STM32F10x_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup CRC 45 | * @{ 46 | */ 47 | 48 | /** @defgroup CRC_Exported_Types 49 | * @{ 50 | */ 51 | 52 | /** 53 | * @} 54 | */ 55 | 56 | /** @defgroup CRC_Exported_Constants 57 | * @{ 58 | */ 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | /** @defgroup CRC_Exported_Macros 65 | * @{ 66 | */ 67 | 68 | /** 69 | * @} 70 | */ 71 | 72 | /** @defgroup CRC_Exported_Functions 73 | * @{ 74 | */ 75 | 76 | void CRC_ResetDR(void); 77 | uint32_t CRC_CalcCRC(uint32_t Data); 78 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength); 79 | uint32_t CRC_GetCRC(void); 80 | void CRC_SetIDRegister(uint8_t IDValue); 81 | uint8_t CRC_GetIDRegister(void); 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | #endif /* __STM32F10x_CRC_H */ 88 | /** 89 | * @} 90 | */ 91 | 92 | /** 93 | * @} 94 | */ 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 101 | -------------------------------------------------------------------------------- /inc/motion_control.h: -------------------------------------------------------------------------------- 1 | /* 2 | motion_control.h - high level interface for issuing motion commands 3 | Part of Grbl 4 | 5 | Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC 6 | Copyright (c) 2009-2011 Simen Svale Skogsrud 7 | 8 | Grbl is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Grbl is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Grbl. If not, see . 20 | */ 21 | 22 | #ifndef motion_control_h 23 | #define motion_control_h 24 | 25 | 26 | // System motion commands must have a line number of zero. 27 | #define HOMING_CYCLE_LINE_NUMBER 0 28 | #define PARKING_MOTION_LINE_NUMBER 0 29 | 30 | #define HOMING_CYCLE_ALL 0 // Must be zero. 31 | #define HOMING_CYCLE_X bit(X_AXIS) 32 | #define HOMING_CYCLE_Y bit(Y_AXIS) 33 | #define HOMING_CYCLE_Z bit(Z_AXIS) 34 | #define HOMING_CYCLE_A bit(A_AXIS) 35 | #define HOMING_CYCLE_B bit(B_AXIS) 36 | 37 | // Execute linear motion in absolute millimeter coordinates. Feed rate given in millimeters/second 38 | // unless invert_feed_rate is true. Then the feed_rate means that the motion should be completed in 39 | // (1 minute)/feed_rate time. 40 | void mc_line(float *target, plan_line_data_t *pl_data); 41 | 42 | // Execute an arc in offset mode format. position == current xyz, target == target xyz, 43 | // offset == offset from current xyz, axis_XXX defines circle plane in tool space, axis_linear is 44 | // the direction of helical travel, radius == circle radius, is_clockwise_arc boolean. Used 45 | // for vector transformation direction. 46 | void mc_arc(float *target, plan_line_data_t *pl_data, float *position, float *offset, float radius, 47 | uint8_t axis_0, uint8_t axis_1, uint8_t axis_linear, uint8_t is_clockwise_arc); 48 | 49 | // Dwell for a specific number of seconds 50 | void mc_dwell(float seconds); 51 | 52 | // Perform homing cycle to locate machine zero. Requires limit switches. 53 | void mc_homing_cycle(uint8_t cycle_mask); 54 | 55 | // Perform tool length probe cycle. Requires probe switch. 56 | uint8_t mc_probe_cycle(float *target, plan_line_data_t *pl_data, uint8_t parser_flags); 57 | 58 | // Handles updating the override control state. 59 | void mc_override_ctrl_update(uint8_t override_state); 60 | 61 | // Plans and executes the single special motion case for parking. Independent of main planner buffer. 62 | void mc_parking_motion(float *parking_target, plan_line_data_t *pl_data); 63 | 64 | // Performs system reset. If in motion state, kills all motion and sets system alarm. 65 | void mc_reset(); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /stm_usb_fs_lib/inc/usb_type.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** 2 | * File Name : usb_type.h 3 | * Author : MCD Application Team 4 | * Version : V3.2.1 5 | * Date : 07/05/2010 6 | * Description : Type definitions used by the USB Library 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __USB_TYPE_H 18 | #define __USB_TYPE_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "usb_conf.h" 22 | 23 | /* Exported types ------------------------------------------------------------*/ 24 | /* Exported constants --------------------------------------------------------*/ 25 | #ifndef NULL 26 | #define NULL ((void *)0) 27 | #endif 28 | 29 | typedef signed long s32; 30 | typedef signed short s16; 31 | typedef signed char s8; 32 | 33 | typedef volatile signed long vs32; 34 | typedef volatile signed short vs16; 35 | typedef volatile signed char vs8; 36 | 37 | typedef unsigned long u32; 38 | typedef unsigned short u16; 39 | typedef unsigned char u8; 40 | 41 | typedef unsigned long const uc32; /* Read Only */ 42 | typedef unsigned short const uc16; /* Read Only */ 43 | typedef unsigned char const uc8; /* Read Only */ 44 | 45 | typedef volatile unsigned long vu32; 46 | typedef volatile unsigned short vu16; 47 | typedef volatile unsigned char vu8; 48 | 49 | typedef volatile unsigned long const vuc32; /* Read Only */ 50 | typedef volatile unsigned short const vuc16; /* Read Only */ 51 | typedef volatile unsigned char const vuc8; /* Read Only */ 52 | 53 | #define FALSE 0 54 | #define TRUE 1 55 | typedef int bool; 56 | 57 | #ifndef __STM32F10x_H 58 | typedef enum { RESET = 0, SET = !RESET } FlagStatus, ITStatus; 59 | 60 | typedef enum { DISABLE = 0, ENABLE = !DISABLE} FunctionalState; 61 | 62 | typedef enum { ERROR = 0, SUCCESS = !ERROR} ErrorStatus; 63 | #endif 64 | /* Exported macro ------------------------------------------------------------*/ 65 | /* Exported functions ------------------------------------------------------- */ 66 | /* External variables --------------------------------------------------------*/ 67 | 68 | #endif /* __USB_TYPE_H */ 69 | 70 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 71 | -------------------------------------------------------------------------------- /usb/usb_desc.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** 2 | * File Name : usb_desc.h 3 | * Author : MCD Application Team 4 | * Version : V3.3.0 5 | * Date : 21-March-2011 6 | * Description : Descriptor Header for Virtual COM Port Device 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __USB_DESC_H 18 | #define __USB_DESC_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | /* Exported types ------------------------------------------------------------*/ 22 | /* Exported constants --------------------------------------------------------*/ 23 | /* Exported macro ------------------------------------------------------------*/ 24 | /* Exported define -----------------------------------------------------------*/ 25 | #define USB_DEVICE_DESCRIPTOR_TYPE 0x01 26 | #define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02 27 | #define USB_STRING_DESCRIPTOR_TYPE 0x03 28 | #define USB_INTERFACE_DESCRIPTOR_TYPE 0x04 29 | #define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05 30 | 31 | #define VIRTUAL_COM_PORT_DATA_SIZE 64 32 | #define VIRTUAL_COM_PORT_INT_SIZE 8 33 | 34 | #define VIRTUAL_COM_PORT_SIZ_DEVICE_DESC 18 35 | #define VIRTUAL_COM_PORT_SIZ_CONFIG_DESC 67 36 | #define VIRTUAL_COM_PORT_SIZ_STRING_LANGID 4 37 | #define VIRTUAL_COM_PORT_SIZ_STRING_VENDOR 22 38 | #define VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT 28 39 | #define VIRTUAL_COM_PORT_SIZ_STRING_SERIAL 26 40 | 41 | #define STANDARD_ENDPOINT_DESC_SIZE 0x09 42 | 43 | /* Exported functions ------------------------------------------------------- */ 44 | extern const uint8_t Virtual_Com_Port_DeviceDescriptor[VIRTUAL_COM_PORT_SIZ_DEVICE_DESC]; 45 | extern const uint8_t Virtual_Com_Port_ConfigDescriptor[VIRTUAL_COM_PORT_SIZ_CONFIG_DESC]; 46 | 47 | extern const uint8_t Virtual_Com_Port_StringLangID[VIRTUAL_COM_PORT_SIZ_STRING_LANGID]; 48 | extern const uint8_t Virtual_Com_Port_StringVendor[VIRTUAL_COM_PORT_SIZ_STRING_VENDOR]; 49 | extern const uint8_t Virtual_Com_Port_StringProduct[VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT]; 50 | extern uint8_t Virtual_Com_Port_StringSerial[VIRTUAL_COM_PORT_SIZ_STRING_SERIAL]; 51 | 52 | #endif /* __USB_DESC_H */ 53 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 54 | -------------------------------------------------------------------------------- /stm_usb_fs_lib/inc/usb_def.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** 2 | * File Name : usb_def.h 3 | * Author : MCD Application Team 4 | * Version : V3.2.1 5 | * Date : 07/05/2010 6 | * Description : Definitions related to USB Core 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __USB_DEF_H 18 | #define __USB_DEF_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | /* Exported types ------------------------------------------------------------*/ 22 | typedef enum _RECIPIENT_TYPE 23 | { 24 | DEVICE_RECIPIENT, /* Recipient device */ 25 | INTERFACE_RECIPIENT, /* Recipient interface */ 26 | ENDPOINT_RECIPIENT, /* Recipient endpoint */ 27 | OTHER_RECIPIENT 28 | } RECIPIENT_TYPE; 29 | 30 | 31 | typedef enum _STANDARD_REQUESTS 32 | { 33 | GET_STATUS = 0, 34 | CLEAR_FEATURE, 35 | RESERVED1, 36 | SET_FEATURE, 37 | RESERVED2, 38 | SET_ADDRESS, 39 | GET_DESCRIPTOR, 40 | SET_DESCRIPTOR, 41 | GET_CONFIGURATION, 42 | SET_CONFIGURATION, 43 | GET_INTERFACE, 44 | SET_INTERFACE, 45 | TOTAL_sREQUEST, /* Total number of Standard request */ 46 | SYNCH_FRAME = 12 47 | } STANDARD_REQUESTS; 48 | 49 | /* Definition of "USBwValue" */ 50 | typedef enum _DESCRIPTOR_TYPE 51 | { 52 | DEVICE_DESCRIPTOR = 1, 53 | CONFIG_DESCRIPTOR, 54 | STRING_DESCRIPTOR, 55 | INTERFACE_DESCRIPTOR, 56 | ENDPOINT_DESCRIPTOR 57 | } DESCRIPTOR_TYPE; 58 | 59 | /* Feature selector of a SET_FEATURE or CLEAR_FEATURE */ 60 | typedef enum _FEATURE_SELECTOR 61 | { 62 | ENDPOINT_STALL, 63 | DEVICE_REMOTE_WAKEUP 64 | } FEATURE_SELECTOR; 65 | 66 | /* Exported constants --------------------------------------------------------*/ 67 | /* Definition of "USBbmRequestType" */ 68 | #define REQUEST_TYPE 0x60 /* Mask to get request type */ 69 | #define STANDARD_REQUEST 0x00 /* Standard request */ 70 | #define CLASS_REQUEST 0x20 /* Class request */ 71 | #define VENDOR_REQUEST 0x40 /* Vendor request */ 72 | 73 | #define RECIPIENT 0x1F /* Mask to get recipient */ 74 | 75 | /* Exported macro ------------------------------------------------------------*/ 76 | /* Exported functions ------------------------------------------------------- */ 77 | 78 | #endif /* __USB_DEF_H */ 79 | 80 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 81 | -------------------------------------------------------------------------------- /usb/usb_endp.c.bak: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** 2 | * File Name : usb_endp.c 3 | * Author : MCD Application Team 4 | * Version : V3.3.0 5 | * Date : 21-March-2011 6 | * Description : Endpoint routines 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | #include "usb_lib.h" 17 | #include "usb_desc.h" 18 | #include "usb_mem.h" 19 | #include "hw_config.h" 20 | #include "usb_istr.h" 21 | #include "usb_pwr.h" 22 | #include "serial.h" 23 | uint8_t USB_Rx_Buffer[VIRTUAL_COM_PORT_DATA_SIZE]; 24 | 25 | extern uint8_t serial_tx_buffer[]; 26 | extern uint8_t serial_tx_buffer_head; 27 | extern volatile uint8_t serial_tx_buffer_tail; 28 | 29 | void EP3_OUT_Callback(void) 30 | { 31 | uint16_t USB_Rx_Cnt; 32 | 33 | /* Get the received data buffer and update the counter */ 34 | USB_Rx_Cnt = USB_SIL_Read(EP3_OUT, USB_Rx_Buffer); 35 | 36 | /* USB data will be immediately processed, this allow next USB traffic being 37 | NAKed till the end of the USART Xfer */ 38 | 39 | OnUsbDataRx(USB_Rx_Buffer, USB_Rx_Cnt); 40 | 41 | /* Enable the receive of data on EP3 */ 42 | SetEPRxValid(ENDP3); 43 | } 44 | 45 | void EP1_IN_Callback (void) 46 | { 47 | if (serial_tx_buffer_head != serial_tx_buffer_tail) 48 | { 49 | uint16_t USB_Tx_length; 50 | 51 | if (serial_tx_buffer_head > serial_tx_buffer_tail) 52 | USB_Tx_length = serial_tx_buffer_head - serial_tx_buffer_tail; 53 | else 54 | { 55 | USB_Tx_length = TX_BUFFER_SIZE - serial_tx_buffer_tail; 56 | } 57 | 58 | if (USB_Tx_length != 0) 59 | { 60 | if (USB_Tx_length > 64) 61 | USB_Tx_length = 64; 62 | 63 | UserToPMABufferCopy(serial_tx_buffer + serial_tx_buffer_tail, ENDP1_TXADDR, USB_Tx_length); 64 | serial_tx_buffer_tail += USB_Tx_length; 65 | if (serial_tx_buffer_tail == TX_BUFFER_SIZE) 66 | serial_tx_buffer_tail = 0; 67 | 68 | SetEPTxCount(ENDP1, USB_Tx_length); 69 | SetEPTxValid(ENDP1); 70 | } 71 | } 72 | } 73 | 74 | 75 | /* \brief Start Of Frame (SOF) callback 76 | */ 77 | void SOF_Callback(void) 78 | { 79 | if(bDeviceState == CONFIGURED) 80 | { 81 | /* Check the data to be sent through IN pipe */ 82 | if (_GetEPTxStatus(ENDP1) == EP_TX_NAK) 83 | { 84 | EP1_IN_Callback(); 85 | } 86 | } 87 | } 88 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 89 | 90 | -------------------------------------------------------------------------------- /doc/csv/error_codes_en_US.csv: -------------------------------------------------------------------------------- 1 | "Error Code in v1.1+","Error Message in v1.0-","Error Description" 2 | "1","Expected command letter","G-code words consist of a letter and a value. Letter was not found." 3 | "2","Bad number format","Missing the expected G-code word value or numeric value format is not valid." 4 | "3","Invalid statement","Grbl '$' system command was not recognized or supported." 5 | "4","Value < 0","Negative value received for an expected positive value." 6 | "5","Setting disabled","Homing cycle failure. Homing is not enabled via settings." 7 | "6","Value < 3 usec","Minimum step pulse time must be greater than 3usec." 8 | "7","EEPROM read fail. Using defaults","An EEPROM read failed. Auto-restoring affected EEPROM to default values." 9 | "8","Not idle","Grbl '$' command cannot be used unless Grbl is IDLE. Ensures smooth operation during a job." 10 | "9","G-code lock","G-code commands are locked out during alarm or jog state." 11 | "10","Homing not enabled","Soft limits cannot be enabled without homing also enabled." 12 | "11","Line overflow","Max characters per line exceeded. Received command line was not executed." 13 | "12","Step rate > 30kHz","Grbl '$' setting value cause the step rate to exceed the maximum supported." 14 | "13","Check Door","Safety door detected as opened and door state initiated." 15 | "14","Line length exceeded","Build info or startup line exceeded EEPROM line length limit. Line not stored." 16 | "15","Travel exceeded","Jog target exceeds machine travel. Jog command has been ignored." 17 | "16","Invalid jog command","Jog command has no '=' or contains prohibited g-code." 18 | "17","Setting disabled","Laser mode requires PWM output." 19 | "20","Unsupported command","Unsupported or invalid g-code command found in block." 20 | "21","Modal group violation","More than one g-code command from same modal group found in block." 21 | "22","Undefined feed rate","Feed rate has not yet been set or is undefined." 22 | "23","Invalid gcode ID:23","G-code command in block requires an integer value." 23 | "24","Invalid gcode ID:24","More than one g-code command that requires axis words found in block." 24 | "25","Invalid gcode ID:25","Repeated g-code word found in block." 25 | "26","Invalid gcode ID:26","No axis words found in block for g-code command or current modal state which requires them." 26 | "27","Invalid gcode ID:27","Line number value is invalid." 27 | "28","Invalid gcode ID:28","G-code command is missing a required value word." 28 | "29","Invalid gcode ID:29","G59.x work coordinate systems are not supported." 29 | "30","Invalid gcode ID:30","G53 only allowed with G0 and G1 motion modes." 30 | "31","Invalid gcode ID:31","Axis words found in block when no command or current modal state uses them." 31 | "32","Invalid gcode ID:32","G2 and G3 arcs require at least one in-plane axis word." 32 | "33","Invalid gcode ID:33","Motion command target is invalid." 33 | "34","Invalid gcode ID:34","Arc radius value is invalid." 34 | "35","Invalid gcode ID:35","G2 and G3 arcs require at least one in-plane offset word." 35 | "36","Invalid gcode ID:36","Unused value words found in block." 36 | "37","Invalid gcode ID:37","G43.1 dynamic tool length offset is not assigned to configured tool length axis." 37 | "38","Invalid gcode ID:38","Tool number greater than max supported value." -------------------------------------------------------------------------------- /stm_usb_fs_lib/src/usb_init.c: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** 2 | * File Name : usb_init.c 3 | * Author : MCD Application Team 4 | * Version : V3.2.1 5 | * Date : 07/05/2010 6 | * Description : Initialization routines & global variables 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Includes ------------------------------------------------------------------*/ 17 | #include "usb_lib.h" 18 | 19 | /* Private typedef -----------------------------------------------------------*/ 20 | /* Private define ------------------------------------------------------------*/ 21 | /* Private macro -------------------------------------------------------------*/ 22 | /* Private variables ---------------------------------------------------------*/ 23 | /* The number of current endpoint, it will be used to specify an endpoint */ 24 | uint8_t EPindex; 25 | /* The number of current device, it is an index to the Device_Table */ 26 | /* uint8_t Device_no; */ 27 | /* Points to the DEVICE_INFO structure of current device */ 28 | /* The purpose of this register is to speed up the execution */ 29 | DEVICE_INFO *pInformation; 30 | /* Points to the DEVICE_PROP structure of current device */ 31 | /* The purpose of this register is to speed up the execution */ 32 | DEVICE_PROP *pProperty; 33 | /* Temporary save the state of Rx & Tx status. */ 34 | /* Whenever the Rx or Tx state is changed, its value is saved */ 35 | /* in this variable first and will be set to the EPRB or EPRA */ 36 | /* at the end of interrupt process */ 37 | uint16_t SaveState ; 38 | uint16_t wInterrupt_Mask; 39 | DEVICE_INFO Device_Info; 40 | USER_STANDARD_REQUESTS *pUser_Standard_Requests; 41 | 42 | /* Extern variables ----------------------------------------------------------*/ 43 | /* Private function prototypes -----------------------------------------------*/ 44 | /* Private functions ---------------------------------------------------------*/ 45 | 46 | /******************************************************************************* 47 | * Function Name : USB_Init 48 | * Description : USB system initialization 49 | * Input : None. 50 | * Output : None. 51 | * Return : None. 52 | *******************************************************************************/ 53 | void USB_Init(void) 54 | { 55 | pInformation = &Device_Info; 56 | pInformation->ControlState = 2; 57 | pProperty = &Device_Property; 58 | pUser_Standard_Requests = &User_Standard_Requests; 59 | /* Initialize devices one by one */ 60 | pProperty->Init(); 61 | } 62 | 63 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 64 | -------------------------------------------------------------------------------- /inc/spindle_control.h: -------------------------------------------------------------------------------- 1 | /* 2 | spindle_control.h - spindle control methods 3 | Part of Grbl 4 | 5 | Copyright (c) 2012-2016 Sungeun K. Jeon for Gnea Research LLC 6 | Copyright (c) 2009-2011 Simen Svale Skogsrud 7 | 8 | Grbl is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Grbl is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Grbl. If not, see . 20 | */ 21 | 22 | #ifndef spindle_control_h 23 | #define spindle_control_h 24 | 25 | #define SPINDLE_NO_SYNC false 26 | #define SPINDLE_FORCE_SYNC true 27 | 28 | #define SPINDLE_STATE_DISABLE 0 // Must be zero. 29 | #define SPINDLE_STATE_CW bit(0) 30 | #define SPINDLE_STATE_CCW bit(1) 31 | 32 | 33 | // Initializes spindle pins and hardware PWM, if enabled. 34 | //void spindle_init(); 35 | void spindle_init(uint8_t pwm_mode); //modified to take a value (prototype specification) 36 | 37 | // Returns current spindle output state. Overrides may alter it from programmed states. 38 | uint8_t spindle_get_state(); 39 | 40 | // Called by g-code parser when setting spindle state and requires a buffer sync. 41 | // Immediately sets spindle running state with direction and spindle rpm via PWM, if enabled. 42 | // Called by spindle_sync() after sync and parking motion/spindle stop override during restore. 43 | #ifdef VARIABLE_SPINDLE 44 | //#ifdef STM32F103C8 45 | #define SPINDLE_PWM_TYPE uint16_t 46 | //#else 47 | // #define SPINDLE_PWM_TYPE uint8_t 48 | //#endif 49 | 50 | // Called by g-code parser when setting spindle state and requires a buffer sync. 51 | void spindle_sync(uint8_t state, float rpm); 52 | 53 | // Sets spindle running state with direction, enable, and spindle PWM. 54 | void spindle_set_state(uint8_t state, float rpm); 55 | 56 | // Author Paul 57 | // measures the difference between the current rpm and the new rpm. If difference 58 | // too high then soft increase to rpm 59 | // 60 | uint16_t current_pwm; 61 | void differentiate_spindle_speed(SPINDLE_PWM_TYPE set_pwm_value, SPINDLE_PWM_TYPE pwm_value); 62 | 63 | // Sets spindle PWM quickly for stepper ISR. Also called by spindle_set_state(). 64 | // NOTE: 328p PWM register is 8-bit. 65 | void spindle_set_speed(SPINDLE_PWM_TYPE pwm_value); 66 | 67 | // Computes 328p-specific PWM register value for the given RPM for quick updating. 68 | SPINDLE_PWM_TYPE spindle_compute_pwm_value(float rpm); 69 | 70 | #else 71 | 72 | // Called by g-code parser when setting spindle state and requires a buffer sync. 73 | #define spindle_sync(state, rpm) _spindle_sync(state) 74 | void _spindle_sync(uint8_t state); 75 | 76 | // Sets spindle running state with direction and enable. 77 | #define spindle_set_state(state, rpm) _spindle_set_state(state) 78 | void _spindle_set_state(uint8_t state); 79 | 80 | #endif 81 | 82 | // Stop and start spindle routines. Called by all spindle routines and stepper ISR. 83 | void spindle_stop(); 84 | 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /Libraries/CMSIS/Device/ST/STM32F10x/Include/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file RTC/Calendar/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.4.0 6 | * @date 10/15/2010 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @copy 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2010 STMicroelectronics

19 | */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F10x_CONF_H 23 | #define __STM32F10x_CONF_H 24 | 25 | /* Includes ------------------------------------------------------------------*/ 26 | /* Uncomment the line below to enable peripheral header file inclusion */ 27 | /* #include "stm32f10x_adc.h" */ 28 | /* #include "stm32f10x_bkp.h" */ 29 | /* #include "stm32f10x_can.h" */ 30 | /* #include "stm32f10x_cec.h" */ 31 | /* #include "stm32f10x_crc.h" */ 32 | /* #include "stm32f10x_dac.h" */ 33 | /* #include "stm32f10x_dbgmcu.h" */ 34 | /* #include "stm32f10x_dma.h" */ 35 | /* #include "stm32f10x_exti.h" */ 36 | /* #include "stm32f10x_flash.h" */ 37 | /* #include "stm32f10x_fsmc.h" */ 38 | #include "stm32f10x_gpio.h" 39 | /* #include "stm32f10x_i2c.h" */ 40 | /* #include "stm32f10x_iwdg.h" */ 41 | /* #include "stm32f10x_pwr.h" */ 42 | #include "stm32f10x_rcc.h" 43 | /* #include "stm32f10x_rtc.h" */ 44 | /* #include "stm32f10x_sdio.h" */ 45 | /* #include "stm32f10x_spi.h" */ 46 | #include "stm32f10x_tim.h" 47 | #include "stm32f10x_usart.h" 48 | /* #include "stm32f10x_wwdg.h" */ 49 | #include "misc.h" /*High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 50 | 51 | 52 | /* Exported types ------------------------------------------------------------*/ 53 | /* Exported constants --------------------------------------------------------*/ 54 | /* Uncomment the line below to expanse the "assert_param" macro in the 55 | Standard Peripheral Library drivers code */ 56 | /* #define USE_FULL_ASSERT 1 */ 57 | 58 | /* Exported macro ------------------------------------------------------------*/ 59 | #ifdef USE_FULL_ASSERT 60 | 61 | /** 62 | * @brief The assert_param macro is used for function's parameters check. 63 | * @param expr: If expr is false, it calls assert_failed function 64 | * which reports the name of the source file and the source 65 | * line number of the call that failed. 66 | * If expr is true, it returns no value. 67 | * @retval None 68 | */ 69 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 70 | /* Exported functions ------------------------------------------------------- */ 71 | void assert_failed(uint8_t* file, uint32_t line); 72 | #else 73 | #define assert_param(expr) ((void)0) 74 | #endif /* USE_FULL_ASSERT */ 75 | 76 | #endif /* __STM32F10x_CONF_H */ 77 | 78 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 79 | -------------------------------------------------------------------------------- /inc/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 08-April-2011 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_CONF_H 24 | #define __STM32F10x_CONF_H 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | /* Uncomment/Comment the line below to enable/disable peripheral header file inclusion */ 28 | #include "stm32f10x_adc.h" 29 | #include "stm32f10x_bkp.h" 30 | #include "stm32f10x_can.h" 31 | #include "stm32f10x_cec.h" 32 | #include "stm32f10x_crc.h" 33 | #include "stm32f10x_dac.h" 34 | #include "stm32f10x_dbgmcu.h" 35 | #include "stm32f10x_dma.h" 36 | #include "stm32f10x_exti.h" 37 | #include "stm32f10x_flash.h" 38 | #include "stm32f10x_fsmc.h" 39 | #include "stm32f10x_gpio.h" 40 | #include "stm32f10x_i2c.h" 41 | #include "stm32f10x_iwdg.h" 42 | #include "stm32f10x_pwr.h" 43 | #include "stm32f10x_rcc.h" 44 | #include "stm32f10x_rtc.h" 45 | #include "stm32f10x_sdio.h" 46 | #include "stm32f10x_spi.h" 47 | #include "stm32f10x_tim.h" 48 | #include "stm32f10x_usart.h" 49 | #include "stm32f10x_wwdg.h" 50 | #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 51 | 52 | /* Exported types ------------------------------------------------------------*/ 53 | /* Exported constants --------------------------------------------------------*/ 54 | /* Uncomment the line below to expanse the "assert_param" macro in the 55 | Standard Peripheral Library drivers code */ 56 | /* #define USE_FULL_ASSERT 1 */ 57 | 58 | /* Exported macro ------------------------------------------------------------*/ 59 | #ifdef USE_FULL_ASSERT 60 | 61 | /** 62 | * @brief The assert_param macro is used for function's parameters check. 63 | * @param expr: If expr is false, it calls assert_failed function which reports 64 | * the name of the source file and the source line number of the call 65 | * that failed. If expr is true, it returns no value. 66 | * @retval None 67 | */ 68 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 69 | /* Exported functions ------------------------------------------------------- */ 70 | void assert_failed(uint8_t* file, uint32_t line); 71 | #else 72 | #define assert_param(expr) ((void)0) 73 | #endif /* USE_FULL_ASSERT */ 74 | 75 | #endif /* __STM32F10x_CONF_H */ 76 | 77 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /src/probe.c: -------------------------------------------------------------------------------- 1 | /* 2 | probe.c - code pertaining to probing methods 3 | Part of Grbl 4 | 5 | Copyright (c) 2014-2016 Sungeun K. Jeon for Gnea Research LLC 6 | 7 | Grbl is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | Grbl is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Grbl. If not, see . 19 | */ 20 | 21 | #include "grbl.h" 22 | 23 | 24 | // Inverts the probe pin state depending on user settings and probing cycle mode. 25 | uint8_t probe_invert_mask; 26 | 27 | 28 | // Probe pin initialization routine. 29 | void probe_init() 30 | { 31 | #ifdef AVRTARGET 32 | PROBE_DDR &= ~(PROBE_MASK); // Configure as input pins 33 | #ifdef DISABLE_PROBE_PIN_PULL_UP 34 | PROBE_PORT &= ~(PROBE_MASK); // Normal low operation. Requires external pull-down. 35 | #else 36 | PROBE_PORT |= PROBE_MASK; // Enable internal pull-up resistors. Normal high operation. 37 | #endif 38 | #endif 39 | #ifdef STM32F103C8 40 | // GPIO_InitTypeDef GPIO_InitStructure; 41 | // RCC_APB2PeriphClockCmd(RCC_PROBE_PORT, ENABLE); 42 | // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; 43 | #ifdef DISABLE_PROBE_PIN_PULL_UP 44 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; 45 | #else 46 | // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; 47 | #endif 48 | // GPIO_InitStructure.GPIO_Pin = PROBE_MASK; 49 | // GPIO_Init(PROBE_PORT, &GPIO_InitStructure); 50 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); 51 | //debug 52 | //GPIO_PinLockConfig(PROBE_PORT,PROBE_MASK); 53 | // 54 | #endif 55 | probe_configure_invert_mask(false); // Initialize invert mask. 56 | } 57 | 58 | 59 | // Called by probe_init() and the mc_probe() routines. Sets up the probe pin invert mask to 60 | // appropriately set the pin logic according to setting for normal-high/normal-low operation 61 | // and the probing cycle modes for toward-workpiece/away-from-workpiece. 62 | void probe_configure_invert_mask(uint8_t is_probe_away) 63 | { 64 | probe_invert_mask = 0; // Initialize as zero. 65 | if (bit_isfalse(settings.flags,BITFLAG_INVERT_PROBE_PIN)) { probe_invert_mask ^= PROBE_MASK; } 66 | if (is_probe_away) { probe_invert_mask ^= PROBE_MASK; } 67 | } 68 | 69 | 70 | // Returns the probe pin state. Triggered = true. Called by gcode parser and probe state monitor. 71 | // Use G38.2 Z-5 F1 to engage the probe , Paul 72 | uint8_t probe_get_state() 73 | { 74 | #ifdef AVRTARGET 75 | return((PROBE_PIN & PROBE_MASK) ^ probe_invert_mask); 76 | #endif 77 | #ifdef WIN32 78 | return 0; 79 | #endif 80 | #ifdef STM32F103C8 81 | return ((GPIO_ReadInputData(PROBE_PORT) & PROBE_MASK) ^ probe_invert_mask) != 0; 82 | #endif 83 | } 84 | 85 | 86 | // Monitors probe pin state and records the system position when detected. Called by the 87 | // stepper ISR per ISR tick. 88 | // NOTE: This function must be extremely efficient as to not bog down the stepper ISR. 89 | void probe_state_monitor() 90 | { 91 | if (probe_get_state()) { 92 | sys_probe_state = PROBE_OFF; 93 | memcpy(sys_probe_position, sys_position, sizeof(sys_position)); 94 | bit_true(sys_rt_exec_state, EXEC_MOTION_CANCEL); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /inc/nuts_bolts.h: -------------------------------------------------------------------------------- 1 | /* 2 | nuts_bolts.h - Header file for shared definitions, variables, and functions 3 | Part of Grbl 4 | 5 | Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC 6 | Copyright (c) 2009-2011 Simen Svale Skogsrud 7 | 8 | Grbl is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Grbl is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Grbl. If not, see . 20 | */ 21 | 22 | #ifndef nuts_bolts_h 23 | #define nuts_bolts_h 24 | #ifdef STM32F103C8 25 | #include "stm32f10x_rcc.h" 26 | #endif 27 | #include "float.h" 28 | #define false 0 29 | #define true 1 30 | 31 | #define SOME_LARGE_VALUE FLT_MAX 32 | 33 | // Axis array index values. Must start with 0 and be continuous. 34 | #define N_AXIS 5 // Number of axes, from 3 to 5 35 | #define X_AXIS 0 // Axis indexing value. 36 | #define Y_AXIS 1 37 | #define Z_AXIS 2 38 | #define A_AXIS 3 // should be fine, belive this to be just an index pointer andnot a port, Paul 39 | #define B_AXIS 4 // 2nd additional axis 40 | 41 | // CoreXY motor assignments. DO NOT ALTER. 42 | // NOTE: If the A and B motor axis bindings are changed, this effects the CoreXY equations. 43 | #ifdef COREXY 44 | #define A_MOTOR X_AXIS // Must be X_AXIS 45 | #define B_MOTOR Y_AXIS // Must be Y_AXIS 46 | #endif 47 | 48 | // Conversions 49 | #define MM_PER_INCH (25.40f) 50 | #define INCH_PER_MM (0.0393701f) 51 | #define TICKS_PER_MICROSECOND (F_CPU/1000000) 52 | #ifdef WIN32 53 | extern LARGE_INTEGER Win32Frequency; 54 | #define F_CPU Win32Frequency.QuadPart 55 | #endif 56 | #ifdef STM32F103C8 57 | #define F_CPU SystemCoreClock 58 | #endif 59 | #define DELAY_MODE_DWELL 0 60 | #define DELAY_MODE_SYS_SUSPEND 1 61 | 62 | // Useful macros 63 | #define clear_vector(a) memset(a, 0, sizeof(a)) 64 | #define clear_vector_float(a) memset(a, 0.0, sizeof(float)*N_AXIS) 65 | // #define clear_vector_long(a) memset(a, 0.0, sizeof(long)*N_AXIS) 66 | #define max(a,b) (((a) > (b)) ? (a) : (b)) 67 | #define min(a,b) (((a) < (b)) ? (a) : (b)) 68 | #define isequal_position_vector(a,b) !(memcmp(a, b, sizeof(float)*N_AXIS)) 69 | 70 | // Bit field and masking macros 71 | #define bit(n) (1 << n) 72 | #define bit_true(x,mask) (x) |= (mask) 73 | #define bit_false(x,mask) (x) &= ~(mask) 74 | #define bit_istrue(x,mask) ((x & mask) != 0) 75 | #define bit_isfalse(x,mask) ((x & mask) == 0) 76 | 77 | // Read a floating point value from a string. Line points to the input buffer, char_counter 78 | // is the indexer pointing to the current character of the line, while float_ptr is 79 | // a pointer to the result variable. Returns true when it succeeds 80 | uint8_t read_float(char *line, uint8_t *char_counter, float *float_ptr); 81 | 82 | // Non-blocking delay function used for general operation and suspend features. 83 | void delay_sec(float seconds, uint8_t mode); 84 | 85 | // Delays variable-defined milliseconds. Compiler compatibility fix for _delay_ms(). 86 | void delay_ms(uint16_t ms); 87 | 88 | 89 | // Computes hypotenuse, avoiding avr-gcc's bloated version and the extra error checking. 90 | float hypot_f(float x, float y); 91 | 92 | float convert_delta_vector_to_unit_vector(float *vector); 93 | float limit_value_by_axis_maximum(float *max_value, float *unit_vec); 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /stm_usb_fs_lib/src/usb_mem.c: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** 2 | * File Name : usb_mem.c 3 | * Author : MCD Application Team 4 | * Version : V3.2.1 5 | * Date : 07/05/2010 6 | * Description : Utility functions for memory transfers to/from PMA 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | #ifndef STM32F10X_CL 16 | 17 | /* Includes ------------------------------------------------------------------*/ 18 | #include "usb_lib.h" 19 | 20 | /* Private typedef -----------------------------------------------------------*/ 21 | /* Private define ------------------------------------------------------------*/ 22 | /* Private macro -------------------------------------------------------------*/ 23 | /* Private variables ---------------------------------------------------------*/ 24 | /* Extern variables ----------------------------------------------------------*/ 25 | /* Private function prototypes -----------------------------------------------*/ 26 | /* Private functions ---------------------------------------------------------*/ 27 | /******************************************************************************* 28 | * Function Name : UserToPMABufferCopy 29 | * Description : Copy a buffer from user memory area to packet memory area (PMA) 30 | * Input : - pbUsrBuf: pointer to user memory area. 31 | * - wPMABufAddr: address into PMA. 32 | * - wNBytes: no. of bytes to be copied. 33 | * Output : None. 34 | * Return : None . 35 | *******************************************************************************/ 36 | void UserToPMABufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes) 37 | { 38 | uint32_t n = (wNBytes + 1) >> 1; /* n = (wNBytes + 1) / 2 */ 39 | uint32_t i, temp1; 40 | uint16_t *pdwVal; 41 | pdwVal = (uint16_t *)(wPMABufAddr * 2 + PMAAddr); 42 | for (i = n; i != 0; i--) 43 | { 44 | temp1 = (uint16_t) * pbUsrBuf; 45 | pbUsrBuf++; 46 | *pdwVal++ = temp1 | (uint16_t) * pbUsrBuf << 8; 47 | pdwVal++; 48 | pbUsrBuf++; 49 | } 50 | } 51 | /******************************************************************************* 52 | * Function Name : PMAToUserBufferCopy 53 | * Description : Copy a buffer from user memory area to packet memory area (PMA) 54 | * Input : - pbUsrBuf = pointer to user memory area. 55 | * - wPMABufAddr = address into PMA. 56 | * - wNBytes = no. of bytes to be copied. 57 | * Output : None. 58 | * Return : None. 59 | *******************************************************************************/ 60 | void PMAToUserBufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes) 61 | { 62 | uint32_t n = (wNBytes + 1) >> 1;/* /2*/ 63 | uint32_t i; 64 | uint32_t *pdwVal; 65 | pdwVal = (uint32_t *)(wPMABufAddr * 2 + PMAAddr); 66 | for (i = n; i != 0; i--) 67 | { 68 | *(uint16_t*)pbUsrBuf++ = *pdwVal++; 69 | pbUsrBuf++; 70 | } 71 | } 72 | 73 | #endif /* STM32F10X_CL */ 74 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 75 | -------------------------------------------------------------------------------- /usb/usb_prop.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** 2 | * File Name : usb_prop.h 3 | * Author : MCD Application Team 4 | * Version : V3.3.0 5 | * Date : 21-March-2011 6 | * Description : All processing related to Virtual COM Port Demo (Endpoint 0) 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __usb_prop_H 18 | #define __usb_prop_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | /* Exported types ------------------------------------------------------------*/ 22 | typedef struct 23 | { 24 | uint32_t bitrate; 25 | uint8_t format; 26 | uint8_t paritytype; 27 | uint8_t datatype; 28 | }LINE_CODING; 29 | 30 | /* Exported constants --------------------------------------------------------*/ 31 | /* Exported macro ------------------------------------------------------------*/ 32 | /* Exported define -----------------------------------------------------------*/ 33 | 34 | #define Virtual_Com_Port_GetConfiguration NOP_Process 35 | //#define Virtual_Com_Port_SetConfiguration NOP_Process 36 | #define Virtual_Com_Port_GetInterface NOP_Process 37 | #define Virtual_Com_Port_SetInterface NOP_Process 38 | #define Virtual_Com_Port_GetStatus NOP_Process 39 | #define Virtual_Com_Port_ClearFeature NOP_Process 40 | #define Virtual_Com_Port_SetEndPointFeature NOP_Process 41 | #define Virtual_Com_Port_SetDeviceFeature NOP_Process 42 | //#define Virtual_Com_Port_SetDeviceAddress NOP_Process 43 | 44 | #define SEND_ENCAPSULATED_COMMAND 0x00 45 | #define GET_ENCAPSULATED_RESPONSE 0x01 46 | #define SET_COMM_FEATURE 0x02 47 | #define GET_COMM_FEATURE 0x03 48 | #define CLEAR_COMM_FEATURE 0x04 49 | #define SET_LINE_CODING 0x20 50 | #define GET_LINE_CODING 0x21 51 | #define SET_CONTROL_LINE_STATE 0x22 52 | #define SEND_BREAK 0x23 53 | 54 | /* Exported functions ------------------------------------------------------- */ 55 | void Virtual_Com_Port_init(void); 56 | void Virtual_Com_Port_Reset(void); 57 | void Virtual_Com_Port_SetConfiguration(void); 58 | void Virtual_Com_Port_SetDeviceAddress (void); 59 | void Virtual_Com_Port_Status_In (void); 60 | void Virtual_Com_Port_Status_Out (void); 61 | RESULT Virtual_Com_Port_Data_Setup(uint8_t); 62 | RESULT Virtual_Com_Port_NoData_Setup(uint8_t); 63 | RESULT Virtual_Com_Port_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting); 64 | uint8_t *Virtual_Com_Port_GetDeviceDescriptor(uint16_t ); 65 | uint8_t *Virtual_Com_Port_GetConfigDescriptor(uint16_t); 66 | uint8_t *Virtual_Com_Port_GetStringDescriptor(uint16_t); 67 | bool Virtual_Com_Port_IsHostPortOpen(void); 68 | 69 | 70 | uint8_t *Virtual_Com_Port_GetLineCoding(uint16_t Length); 71 | uint8_t *Virtual_Com_Port_SetLineCoding(uint16_t Length); 72 | 73 | #endif /* __usb_prop_H */ 74 | 75 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 76 | 77 | -------------------------------------------------------------------------------- /Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_wwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_wwdg.h 4 | * @author MCD Application Team 5 | * @version V3.6.1 6 | * @date 05-March-2012 7 | * @brief This file contains all the functions prototypes for the WWDG firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2012 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F10x_WWDG_H 31 | #define __STM32F10x_WWDG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f10x.h" 39 | 40 | /** @addtogroup STM32F10x_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup WWDG 45 | * @{ 46 | */ 47 | 48 | /** @defgroup WWDG_Exported_Types 49 | * @{ 50 | */ 51 | 52 | /** 53 | * @} 54 | */ 55 | 56 | /** @defgroup WWDG_Exported_Constants 57 | * @{ 58 | */ 59 | 60 | /** @defgroup WWDG_Prescaler 61 | * @{ 62 | */ 63 | 64 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000) 65 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080) 66 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100) 67 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180) 68 | #define IS_WWDG_PRESCALER(PRESCALER) (((PRESCALER) == WWDG_Prescaler_1) || \ 69 | ((PRESCALER) == WWDG_Prescaler_2) || \ 70 | ((PRESCALER) == WWDG_Prescaler_4) || \ 71 | ((PRESCALER) == WWDG_Prescaler_8)) 72 | #define IS_WWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0x7F) 73 | #define IS_WWDG_COUNTER(COUNTER) (((COUNTER) >= 0x40) && ((COUNTER) <= 0x7F)) 74 | 75 | /** 76 | * @} 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @defgroup WWDG_Exported_Macros 84 | * @{ 85 | */ 86 | /** 87 | * @} 88 | */ 89 | 90 | /** @defgroup WWDG_Exported_Functions 91 | * @{ 92 | */ 93 | 94 | void WWDG_DeInit(void); 95 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler); 96 | void WWDG_SetWindowValue(uint8_t WindowValue); 97 | void WWDG_EnableIT(void); 98 | void WWDG_SetCounter(uint8_t Counter); 99 | void WWDG_Enable(uint8_t Counter); 100 | FlagStatus WWDG_GetFlagStatus(void); 101 | void WWDG_ClearFlag(void); 102 | 103 | #ifdef __cplusplus 104 | } 105 | #endif 106 | 107 | #endif /* __STM32F10x_WWDG_H */ 108 | 109 | /** 110 | * @} 111 | */ 112 | 113 | /** 114 | * @} 115 | */ 116 | 117 | /** 118 | * @} 119 | */ 120 | 121 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 122 | -------------------------------------------------------------------------------- /doc/csv/setting_codes_en_US.csv: -------------------------------------------------------------------------------- 1 | "$-Code"," Setting"," Units"," Setting Description" 2 | "0","Step pulse time","microseconds","Sets time length per step. Minimum 3usec." 3 | "1","Step idle delay","milliseconds","Sets a short hold delay when stopping to let dynamics settle before disabling steppers. Value 255 keeps motors enabled with no delay." 4 | "2","Step pulse invert","mask","Inverts the step signal. Set axis bit to invert (00000ZYX)." 5 | "3","Step direction invert","mask","Inverts the direction signal. Set axis bit to invert (00000ZYX)." 6 | "4","Invert step enable pin","boolean","Inverts the stepper driver enable pin signal." 7 | "5","Invert limit pins","boolean","Inverts the all of the limit input pins." 8 | "6","Invert probe pin","boolean","Inverts the probe input pin signal." 9 | "10","Status report options","mask","Alters data included in status reports." 10 | "11","Junction deviation","millimeters","Sets how fast Grbl travels through consecutive motions. Lower value slows it down." 11 | "12","Arc tolerance","millimeters","Sets the G2 and G3 arc tracing accuracy based on radial error. Beware: A very small value may effect performance." 12 | "13","Report in inches","boolean","Enables inch units when returning any position and rate value that is not a settings value." 13 | "20","Soft limits enable","boolean","Enables soft limits checks within machine travel and sets alarm when exceeded. Requires homing." 14 | "21","Hard limits enable","boolean","Enables hard limits. Immediately halts motion and throws an alarm when switch is triggered." 15 | "22","Homing cycle enable","boolean","Enables homing cycle. Requires limit switches on all axes." 16 | "23","Homing direction invert","mask","Homing searches for a switch in the positive direction. Set axis bit (00000ZYX) to search in negative direction." 17 | "24","Homing locate feed rate","mm/min","Feed rate to slowly engage limit switch to determine its location accurately." 18 | "25","Homing search seek rate","mm/min","Seek rate to quickly find the limit switch before the slower locating phase." 19 | "26","Homing switch debounce delay","milliseconds","Sets a short delay between phases of homing cycle to let a switch debounce." 20 | "27","Homing switch pull-off distance","millimeters","Retract distance after triggering switch to disengage it. Homing will fail if switch isn't cleared." 21 | "30","Maximum spindle speed","RPM","Maximum spindle speed. Sets PWM to 100% duty cycle." 22 | "31","Minimum spindle speed","RPM","Minimum spindle speed. Sets PWM to 0.4% or lowest duty cycle." 23 | "32","Laser-mode enable","boolean","Enables laser mode. Consecutive G1/2/3 commands will not halt when spindle speed is changed." 24 | "100","X-axis travel resolution","step/mm","X-axis travel resolution in steps per millimeter." 25 | "101","Y-axis travel resolution","step/mm","Y-axis travel resolution in steps per millimeter." 26 | "102","Z-axis travel resolution","step/mm","Z-axis travel resolution in steps per millimeter." 27 | "110","X-axis maximum rate","mm/min","X-axis maximum rate. Used as G0 rapid rate." 28 | "111","Y-axis maximum rate","mm/min","Y-axis maximum rate. Used as G0 rapid rate." 29 | "112","Z-axis maximum rate","mm/min","Z-axis maximum rate. Used as G0 rapid rate." 30 | "120","X-axis acceleration","mm/sec^2","X-axis acceleration. Used for motion planning to not exceed motor torque and lose steps." 31 | "121","Y-axis acceleration","mm/sec^2","Y-axis acceleration. Used for motion planning to not exceed motor torque and lose steps." 32 | "122","Z-axis acceleration","mm/sec^2","Z-axis acceleration. Used for motion planning to not exceed motor torque and lose steps." 33 | "130","X-axis maximum travel","millimeters","Maximum X-axis travel distance from homing switch. Determines valid machine space for soft-limits and homing search distances." 34 | "131","Y-axis maximum travel","millimeters","Maximum Y-axis travel distance from homing switch. Determines valid machine space for soft-limits and homing search distances." 35 | "132","Z-axis maximum travel","millimeters","Maximum Z-axis travel distance from homing switch. Determines valid machine space for soft-limits and homing search distances." 36 | -------------------------------------------------------------------------------- /usb/usb_istr.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** 2 | * File Name : usb_istr.h 3 | * Author : MCD Application Team 4 | * Version : V3.3.0 5 | * Date : 21-March-2011 6 | * Description : This file includes the peripherals header files in the 7 | * user application. 8 | ******************************************************************************** 9 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 10 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 11 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 12 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 13 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 14 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 15 | *******************************************************************************/ 16 | 17 | /* Define to prevent recursive inclusion -------------------------------------*/ 18 | #ifndef __USB_ISTR_H 19 | #define __USB_ISTR_H 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "usb_conf.h" 23 | 24 | /* Exported types ------------------------------------------------------------*/ 25 | /* Exported constants --------------------------------------------------------*/ 26 | /* Exported macro ------------------------------------------------------------*/ 27 | /* Exported functions ------------------------------------------------------- */ 28 | 29 | #ifndef STM32F10X_CL 30 | void USB_Istr(void); 31 | #else /* STM32F10X_CL */ 32 | u32 STM32_PCD_OTG_ISR_Handler(void); 33 | #endif /* STM32F10X_CL */ 34 | 35 | /* function prototypes Automatically built defining related macros */ 36 | 37 | void EP1_IN_Callback(void); 38 | void EP2_IN_Callback(void); 39 | void EP3_IN_Callback(void); 40 | void EP4_IN_Callback(void); 41 | void EP5_IN_Callback(void); 42 | void EP6_IN_Callback(void); 43 | void EP7_IN_Callback(void); 44 | 45 | void EP1_OUT_Callback(void); 46 | void EP2_OUT_Callback(void); 47 | void EP3_OUT_Callback(void); 48 | void EP4_OUT_Callback(void); 49 | void EP5_OUT_Callback(void); 50 | void EP6_OUT_Callback(void); 51 | void EP7_OUT_Callback(void); 52 | 53 | #ifndef STM32F10X_CL 54 | 55 | #ifdef CTR_CALLBACK 56 | void CTR_Callback(void); 57 | #endif 58 | 59 | #ifdef DOVR_CALLBACK 60 | void DOVR_Callback(void); 61 | #endif 62 | 63 | #ifdef ERR_CALLBACK 64 | void ERR_Callback(void); 65 | #endif 66 | 67 | #ifdef WKUP_CALLBACK 68 | void WKUP_Callback(void); 69 | #endif 70 | 71 | #ifdef SUSP_CALLBACK 72 | void SUSP_Callback(void); 73 | #endif 74 | 75 | #ifdef RESET_CALLBACK 76 | void RESET_Callback(void); 77 | #endif 78 | 79 | #ifdef SOF_CALLBACK 80 | void SOF_Callback(void); 81 | #endif 82 | 83 | #ifdef ESOF_CALLBACK 84 | void ESOF_Callback(void); 85 | #endif 86 | 87 | #else /* STM32F10X_CL */ 88 | 89 | /* Interrupt subroutines user callbacks prototypes. 90 | These callbacks are called into the respective interrupt subroutine functions 91 | and can be tailored for various user application purposes. 92 | Note: Make sure that the correspondent interrupt is enabled through the 93 | definition in usb_conf.h file */ 94 | void INTR_MODEMISMATCH_Callback(void); 95 | void INTR_SOFINTR_Callback(void); 96 | void INTR_RXSTSQLVL_Callback(void); 97 | void INTR_NPTXFEMPTY_Callback(void); 98 | void INTR_GINNAKEFF_Callback(void); 99 | void INTR_GOUTNAKEFF_Callback(void); 100 | void INTR_ERLYSUSPEND_Callback(void); 101 | void INTR_USBSUSPEND_Callback(void); 102 | void INTR_USBRESET_Callback(void); 103 | void INTR_ENUMDONE_Callback(void); 104 | void INTR_ISOOUTDROP_Callback(void); 105 | void INTR_EOPFRAME_Callback(void); 106 | void INTR_EPMISMATCH_Callback(void); 107 | void INTR_INEPINTR_Callback(void); 108 | void INTR_OUTEPINTR_Callback(void); 109 | void INTR_INCOMPLISOIN_Callback(void); 110 | void INTR_INCOMPLISOOUT_Callback(void); 111 | void INTR_WKUPINTR_Callback(void); 112 | 113 | /* Isochronous data update */ 114 | void INTR_RXSTSQLVL_ISODU_Callback(void); 115 | 116 | #endif /* STM32F10X_CL */ 117 | 118 | 119 | #endif /*__USB_ISTR_H*/ 120 | 121 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 122 | -------------------------------------------------------------------------------- /Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_crc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_crc.c 4 | * @author MCD Application Team 5 | * @version V3.6.1 6 | * @date 05-March-2012 7 | * @brief This file provides all the CRC firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f10x_crc.h" 30 | 31 | /** @addtogroup STM32F10x_StdPeriph_Driver 32 | * @{ 33 | */ 34 | 35 | /** @defgroup CRC 36 | * @brief CRC driver modules 37 | * @{ 38 | */ 39 | 40 | /** @defgroup CRC_Private_TypesDefinitions 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @} 46 | */ 47 | 48 | /** @defgroup CRC_Private_Defines 49 | * @{ 50 | */ 51 | 52 | /** 53 | * @} 54 | */ 55 | 56 | /** @defgroup CRC_Private_Macros 57 | * @{ 58 | */ 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | /** @defgroup CRC_Private_Variables 65 | * @{ 66 | */ 67 | 68 | /** 69 | * @} 70 | */ 71 | 72 | /** @defgroup CRC_Private_FunctionPrototypes 73 | * @{ 74 | */ 75 | 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup CRC_Private_Functions 81 | * @{ 82 | */ 83 | 84 | /** 85 | * @brief Resets the CRC Data register (DR). 86 | * @param None 87 | * @retval None 88 | */ 89 | void CRC_ResetDR(void) 90 | { 91 | /* Reset CRC generator */ 92 | CRC->CR = CRC_CR_RESET; 93 | } 94 | 95 | /** 96 | * @brief Computes the 32-bit CRC of a given data word(32-bit). 97 | * @param Data: data word(32-bit) to compute its CRC 98 | * @retval 32-bit CRC 99 | */ 100 | uint32_t CRC_CalcCRC(uint32_t Data) 101 | { 102 | CRC->DR = Data; 103 | 104 | return (CRC->DR); 105 | } 106 | 107 | /** 108 | * @brief Computes the 32-bit CRC of a given buffer of data word(32-bit). 109 | * @param pBuffer: pointer to the buffer containing the data to be computed 110 | * @param BufferLength: length of the buffer to be computed 111 | * @retval 32-bit CRC 112 | */ 113 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength) 114 | { 115 | uint32_t index = 0; 116 | 117 | for(index = 0; index < BufferLength; index++) 118 | { 119 | CRC->DR = pBuffer[index]; 120 | } 121 | return (CRC->DR); 122 | } 123 | 124 | /** 125 | * @brief Returns the current CRC value. 126 | * @param None 127 | * @retval 32-bit CRC 128 | */ 129 | uint32_t CRC_GetCRC(void) 130 | { 131 | return (CRC->DR); 132 | } 133 | 134 | /** 135 | * @brief Stores a 8-bit data in the Independent Data(ID) register. 136 | * @param IDValue: 8-bit value to be stored in the ID register 137 | * @retval None 138 | */ 139 | void CRC_SetIDRegister(uint8_t IDValue) 140 | { 141 | CRC->IDR = IDValue; 142 | } 143 | 144 | /** 145 | * @brief Returns the 8-bit data stored in the Independent Data(ID) register 146 | * @param None 147 | * @retval 8-bit value of the ID register 148 | */ 149 | uint8_t CRC_GetIDRegister(void) 150 | { 151 | return (CRC->IDR); 152 | } 153 | 154 | /** 155 | * @} 156 | */ 157 | 158 | /** 159 | * @} 160 | */ 161 | 162 | /** 163 | * @} 164 | */ 165 | 166 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 167 | -------------------------------------------------------------------------------- /.code_review_properties: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | property.default.description 5 | 6 | 1970-01-01 :: 00:00:00:000 GMT-10:00 7 | review 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /usb/usb_endp.c: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** 2 | * File Name : usb_endp.c 3 | * Author : MCD Application Team 4 | * Version : V3.3.0 5 | * Date : 21-March-2011 6 | * Description : Endpoint routines 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | #include "usb_lib.h" 17 | #include "usb_desc.h" 18 | #include "usb_mem.h" 19 | #include "hw_config.h" 20 | #include "usb_istr.h" 21 | #include "usb_pwr.h" 22 | #include "serial.h" 23 | uint8_t USB_Rx_Buffer[VIRTUAL_COM_PORT_DATA_SIZE]; 24 | extern uint8_t setflagmessage; 25 | extern uint8_t serial_tx_buffer[]; 26 | extern uint8_t serial_tx_buffer_head; 27 | extern volatile uint8_t serial_tx_buffer_tail; 28 | 29 | void EP3_OUT_Callback(void) 30 | { 31 | uint16_t USB_Rx_Cnt; 32 | 33 | /* Get the received data buffer and update the counter */ 34 | USB_Rx_Cnt = USB_SIL_Read(EP3_OUT, USB_Rx_Buffer); 35 | 36 | /* USB data will be immediately processed, this allow next USB traffic being 37 | NAKed till the end of the USART Xfer */ 38 | 39 | OnUsbDataRx(USB_Rx_Buffer, USB_Rx_Cnt); 40 | 41 | /* Enable the receive of data on EP3 */ 42 | SetEPRxValid(ENDP3); 43 | } 44 | 45 | void set_init_msg_flag (void) 46 | { 47 | // set_init_msg_report(); 48 | } 49 | 50 | 51 | void EP1_IN_Callback (void) 52 | { 53 | if (serial_tx_buffer_head != serial_tx_buffer_tail && (_GetEPTxStatus(ENDP1) == EP_TX_NAK)) 54 | { 55 | uint16_t USB_Tx_length; 56 | 57 | if (serial_tx_buffer_head > serial_tx_buffer_tail) 58 | USB_Tx_length = serial_tx_buffer_head - serial_tx_buffer_tail; 59 | else 60 | { 61 | USB_Tx_length = TX_BUFFER_SIZE - serial_tx_buffer_tail + serial_tx_buffer_head; 62 | } 63 | 64 | if (USB_Tx_length != 0) 65 | { 66 | if (USB_Tx_length > 64) 67 | USB_Tx_length = 64; 68 | 69 | // UserToPMABufferCopy(&serial_tx_buffer[serial_tx_buffer_tail], ENDP1_TXADDR, USB_Tx_length); 70 | { 71 | uint8_t *pbUsrBuf = serial_tx_buffer + serial_tx_buffer_tail; 72 | uint32_t n = (USB_Tx_length + 1) >> 1; /* n = (wNBytes + 1) / 2 */ 73 | uint32_t i, temp1; 74 | uint16_t *pdwVal; 75 | pdwVal = (uint16_t *)(ENDP1_TXADDR * 2 + PMAAddr); 76 | for (i = n; i != 0; i--) 77 | { 78 | temp1 = (uint16_t) * pbUsrBuf; 79 | pbUsrBuf++; 80 | if (pbUsrBuf - serial_tx_buffer == TX_BUFFER_SIZE) 81 | pbUsrBuf = serial_tx_buffer; 82 | 83 | *pdwVal++ = temp1 | (uint16_t) * pbUsrBuf << 8; 84 | pdwVal++; 85 | pbUsrBuf++; 86 | if (pbUsrBuf - serial_tx_buffer == TX_BUFFER_SIZE) 87 | pbUsrBuf = serial_tx_buffer; 88 | } 89 | } 90 | 91 | SetEPTxCount(ENDP1, USB_Tx_length); 92 | SetEPTxValid(ENDP1); 93 | 94 | serial_tx_buffer_tail += USB_Tx_length; 95 | if (serial_tx_buffer_tail >= TX_BUFFER_SIZE) 96 | serial_tx_buffer_tail -= TX_BUFFER_SIZE; 97 | } 98 | } 99 | } 100 | 101 | 102 | /* \brief Start Of Frame (SOF) callback 103 | */ 104 | void SOF_Callback(void) 105 | { 106 | if(bDeviceState == CONFIGURED) 107 | { 108 | /* Check the data to be sent through IN pipe */ 109 | EP1_IN_Callback(); 110 | } 111 | } 112 | 113 | void RESET_Callback(void) 114 | { 115 | uint8_t setflagmessage = 1; 116 | //set_init_msg_flag(); 117 | 118 | } 119 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 120 | 121 | -------------------------------------------------------------------------------- /Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_dbgmcu.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_dbgmcu.h 4 | * @author MCD Application Team 5 | * @version V3.6.1 6 | * @date 05-March-2012 7 | * @brief This file contains all the functions prototypes for the DBGMCU 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2012 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F10x_DBGMCU_H 31 | #define __STM32F10x_DBGMCU_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f10x.h" 39 | 40 | /** @addtogroup STM32F10x_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup DBGMCU 45 | * @{ 46 | */ 47 | 48 | /** @defgroup DBGMCU_Exported_Types 49 | * @{ 50 | */ 51 | 52 | /** 53 | * @} 54 | */ 55 | 56 | /** @defgroup DBGMCU_Exported_Constants 57 | * @{ 58 | */ 59 | 60 | #define DBGMCU_SLEEP ((uint32_t)0x00000001) 61 | #define DBGMCU_STOP ((uint32_t)0x00000002) 62 | #define DBGMCU_STANDBY ((uint32_t)0x00000004) 63 | #define DBGMCU_IWDG_STOP ((uint32_t)0x00000100) 64 | #define DBGMCU_WWDG_STOP ((uint32_t)0x00000200) 65 | #define DBGMCU_TIM1_STOP ((uint32_t)0x00000400) 66 | #define DBGMCU_TIM2_STOP ((uint32_t)0x00000800) 67 | #define DBGMCU_TIM3_STOP ((uint32_t)0x00001000) 68 | #define DBGMCU_TIM4_STOP ((uint32_t)0x00002000) 69 | #define DBGMCU_CAN1_STOP ((uint32_t)0x00004000) 70 | #define DBGMCU_I2C1_SMBUS_TIMEOUT ((uint32_t)0x00008000) 71 | #define DBGMCU_I2C2_SMBUS_TIMEOUT ((uint32_t)0x00010000) 72 | #define DBGMCU_TIM8_STOP ((uint32_t)0x00020000) 73 | #define DBGMCU_TIM5_STOP ((uint32_t)0x00040000) 74 | #define DBGMCU_TIM6_STOP ((uint32_t)0x00080000) 75 | #define DBGMCU_TIM7_STOP ((uint32_t)0x00100000) 76 | #define DBGMCU_CAN2_STOP ((uint32_t)0x00200000) 77 | #define DBGMCU_TIM15_STOP ((uint32_t)0x00400000) 78 | #define DBGMCU_TIM16_STOP ((uint32_t)0x00800000) 79 | #define DBGMCU_TIM17_STOP ((uint32_t)0x01000000) 80 | #define DBGMCU_TIM12_STOP ((uint32_t)0x02000000) 81 | #define DBGMCU_TIM13_STOP ((uint32_t)0x04000000) 82 | #define DBGMCU_TIM14_STOP ((uint32_t)0x08000000) 83 | #define DBGMCU_TIM9_STOP ((uint32_t)0x10000000) 84 | #define DBGMCU_TIM10_STOP ((uint32_t)0x20000000) 85 | #define DBGMCU_TIM11_STOP ((uint32_t)0x40000000) 86 | 87 | #define IS_DBGMCU_PERIPH(PERIPH) ((((PERIPH) & 0x800000F8) == 0x00) && ((PERIPH) != 0x00)) 88 | /** 89 | * @} 90 | */ 91 | 92 | /** @defgroup DBGMCU_Exported_Macros 93 | * @{ 94 | */ 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /** @defgroup DBGMCU_Exported_Functions 101 | * @{ 102 | */ 103 | 104 | uint32_t DBGMCU_GetREVID(void); 105 | uint32_t DBGMCU_GetDEVID(void); 106 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState); 107 | 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | 112 | #endif /* __STM32F10x_DBGMCU_H */ 113 | /** 114 | * @} 115 | */ 116 | 117 | /** 118 | * @} 119 | */ 120 | 121 | /** 122 | * @} 123 | */ 124 | 125 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 126 | -------------------------------------------------------------------------------- /Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_iwdg.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_iwdg.h 4 | * @author MCD Application Team 5 | * @version V3.6.1 6 | * @date 05-March-2012 7 | * @brief This file contains all the functions prototypes for the IWDG 8 | * firmware library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2012 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F10x_IWDG_H 31 | #define __STM32F10x_IWDG_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f10x.h" 39 | 40 | /** @addtogroup STM32F10x_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup IWDG 45 | * @{ 46 | */ 47 | 48 | /** @defgroup IWDG_Exported_Types 49 | * @{ 50 | */ 51 | 52 | /** 53 | * @} 54 | */ 55 | 56 | /** @defgroup IWDG_Exported_Constants 57 | * @{ 58 | */ 59 | 60 | /** @defgroup IWDG_WriteAccess 61 | * @{ 62 | */ 63 | 64 | #define IWDG_WriteAccess_Enable ((uint16_t)0x5555) 65 | #define IWDG_WriteAccess_Disable ((uint16_t)0x0000) 66 | #define IS_IWDG_WRITE_ACCESS(ACCESS) (((ACCESS) == IWDG_WriteAccess_Enable) || \ 67 | ((ACCESS) == IWDG_WriteAccess_Disable)) 68 | /** 69 | * @} 70 | */ 71 | 72 | /** @defgroup IWDG_prescaler 73 | * @{ 74 | */ 75 | 76 | #define IWDG_Prescaler_4 ((uint8_t)0x00) 77 | #define IWDG_Prescaler_8 ((uint8_t)0x01) 78 | #define IWDG_Prescaler_16 ((uint8_t)0x02) 79 | #define IWDG_Prescaler_32 ((uint8_t)0x03) 80 | #define IWDG_Prescaler_64 ((uint8_t)0x04) 81 | #define IWDG_Prescaler_128 ((uint8_t)0x05) 82 | #define IWDG_Prescaler_256 ((uint8_t)0x06) 83 | #define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_Prescaler_4) || \ 84 | ((PRESCALER) == IWDG_Prescaler_8) || \ 85 | ((PRESCALER) == IWDG_Prescaler_16) || \ 86 | ((PRESCALER) == IWDG_Prescaler_32) || \ 87 | ((PRESCALER) == IWDG_Prescaler_64) || \ 88 | ((PRESCALER) == IWDG_Prescaler_128)|| \ 89 | ((PRESCALER) == IWDG_Prescaler_256)) 90 | /** 91 | * @} 92 | */ 93 | 94 | /** @defgroup IWDG_Flag 95 | * @{ 96 | */ 97 | 98 | #define IWDG_FLAG_PVU ((uint16_t)0x0001) 99 | #define IWDG_FLAG_RVU ((uint16_t)0x0002) 100 | #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || ((FLAG) == IWDG_FLAG_RVU)) 101 | #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF) 102 | /** 103 | * @} 104 | */ 105 | 106 | /** 107 | * @} 108 | */ 109 | 110 | /** @defgroup IWDG_Exported_Macros 111 | * @{ 112 | */ 113 | 114 | /** 115 | * @} 116 | */ 117 | 118 | /** @defgroup IWDG_Exported_Functions 119 | * @{ 120 | */ 121 | 122 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess); 123 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler); 124 | void IWDG_SetReload(uint16_t Reload); 125 | void IWDG_ReloadCounter(void); 126 | void IWDG_Enable(void); 127 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG); 128 | 129 | #ifdef __cplusplus 130 | } 131 | #endif 132 | 133 | #endif /* __STM32F10x_IWDG_H */ 134 | /** 135 | * @} 136 | */ 137 | 138 | /** 139 | * @} 140 | */ 141 | 142 | /** 143 | * @} 144 | */ 145 | 146 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 147 | -------------------------------------------------------------------------------- /Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_rtc.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_rtc.h 4 | * @author MCD Application Team 5 | * @version V3.6.1 6 | * @date 05-March-2012 7 | * @brief This file contains all the functions prototypes for the RTC firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2012 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F10x_RTC_H 31 | #define __STM32F10x_RTC_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f10x.h" 39 | 40 | /** @addtogroup STM32F10x_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup RTC 45 | * @{ 46 | */ 47 | 48 | /** @defgroup RTC_Exported_Types 49 | * @{ 50 | */ 51 | 52 | /** 53 | * @} 54 | */ 55 | 56 | /** @defgroup RTC_Exported_Constants 57 | * @{ 58 | */ 59 | 60 | /** @defgroup RTC_interrupts_define 61 | * @{ 62 | */ 63 | 64 | #define RTC_IT_OW ((uint16_t)0x0004) /*!< Overflow interrupt */ 65 | #define RTC_IT_ALR ((uint16_t)0x0002) /*!< Alarm interrupt */ 66 | #define RTC_IT_SEC ((uint16_t)0x0001) /*!< Second interrupt */ 67 | #define IS_RTC_IT(IT) ((((IT) & (uint16_t)0xFFF8) == 0x00) && ((IT) != 0x00)) 68 | #define IS_RTC_GET_IT(IT) (((IT) == RTC_IT_OW) || ((IT) == RTC_IT_ALR) || \ 69 | ((IT) == RTC_IT_SEC)) 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup RTC_interrupts_flags 75 | * @{ 76 | */ 77 | 78 | #define RTC_FLAG_RTOFF ((uint16_t)0x0020) /*!< RTC Operation OFF flag */ 79 | #define RTC_FLAG_RSF ((uint16_t)0x0008) /*!< Registers Synchronized flag */ 80 | #define RTC_FLAG_OW ((uint16_t)0x0004) /*!< Overflow flag */ 81 | #define RTC_FLAG_ALR ((uint16_t)0x0002) /*!< Alarm flag */ 82 | #define RTC_FLAG_SEC ((uint16_t)0x0001) /*!< Second flag */ 83 | #define IS_RTC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFFF0) == 0x00) && ((FLAG) != 0x00)) 84 | #define IS_RTC_GET_FLAG(FLAG) (((FLAG) == RTC_FLAG_RTOFF) || ((FLAG) == RTC_FLAG_RSF) || \ 85 | ((FLAG) == RTC_FLAG_OW) || ((FLAG) == RTC_FLAG_ALR) || \ 86 | ((FLAG) == RTC_FLAG_SEC)) 87 | #define IS_RTC_PRESCALER(PRESCALER) ((PRESCALER) <= 0xFFFFF) 88 | 89 | /** 90 | * @} 91 | */ 92 | 93 | /** 94 | * @} 95 | */ 96 | 97 | /** @defgroup RTC_Exported_Macros 98 | * @{ 99 | */ 100 | 101 | /** 102 | * @} 103 | */ 104 | 105 | /** @defgroup RTC_Exported_Functions 106 | * @{ 107 | */ 108 | 109 | void RTC_ITConfig(uint16_t RTC_IT, FunctionalState NewState); 110 | void RTC_EnterConfigMode(void); 111 | void RTC_ExitConfigMode(void); 112 | uint32_t RTC_GetCounter(void); 113 | void RTC_SetCounter(uint32_t CounterValue); 114 | void RTC_SetPrescaler(uint32_t PrescalerValue); 115 | void RTC_SetAlarm(uint32_t AlarmValue); 116 | uint32_t RTC_GetDivider(void); 117 | void RTC_WaitForLastTask(void); 118 | void RTC_WaitForSynchro(void); 119 | FlagStatus RTC_GetFlagStatus(uint16_t RTC_FLAG); 120 | void RTC_ClearFlag(uint16_t RTC_FLAG); 121 | ITStatus RTC_GetITStatus(uint16_t RTC_IT); 122 | void RTC_ClearITPendingBit(uint16_t RTC_IT); 123 | 124 | #ifdef __cplusplus 125 | } 126 | #endif 127 | 128 | #endif /* __STM32F10x_RTC_H */ 129 | /** 130 | * @} 131 | */ 132 | 133 | /** 134 | * @} 135 | */ 136 | 137 | /** 138 | * @} 139 | */ 140 | 141 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 142 | -------------------------------------------------------------------------------- /inc/report.h: -------------------------------------------------------------------------------- 1 | /* 2 | report.h - reporting and messaging methods 3 | Part of Grbl 4 | 5 | Copyright (c) 2012-2016 Sungeun K. Jeon for Gnea Research LLC 6 | 7 | Grbl is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | Grbl is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Grbl. If not, see . 19 | */ 20 | #ifndef report_h 21 | #define report_h 22 | 23 | // Define Grbl status codes. Valid values (0-255) 24 | #define STATUS_OK 0 25 | #define STATUS_EXPECTED_COMMAND_LETTER 1 26 | #define STATUS_BAD_NUMBER_FORMAT 2 27 | #define STATUS_INVALID_STATEMENT 3 28 | #define STATUS_NEGATIVE_VALUE 4 29 | #define STATUS_SETTING_DISABLED 5 30 | #define STATUS_SETTING_STEP_PULSE_MIN 6 31 | #define STATUS_SETTING_READ_FAIL 7 32 | #define STATUS_IDLE_ERROR 8 33 | #define STATUS_SYSTEM_GC_LOCK 9 34 | #define STATUS_SOFT_LIMIT_ERROR 10 35 | #define STATUS_OVERFLOW 11 36 | #define STATUS_MAX_STEP_RATE_EXCEEDED 12 37 | #define STATUS_CHECK_DOOR 13 38 | #define STATUS_LINE_LENGTH_EXCEEDED 14 39 | #define STATUS_TRAVEL_EXCEEDED 15 40 | #define STATUS_INVALID_JOG_COMMAND 16 41 | #define STATUS_SETTING_DISABLED_LASER 17 42 | 43 | //Paul added fault monitoring 21/01/19 44 | #define STATUS_SETTING_DISABLED_FAULT 18 45 | 46 | #define STATUS_GCODE_UNSUPPORTED_COMMAND 20 47 | #define STATUS_GCODE_MODAL_GROUP_VIOLATION 21 48 | #define STATUS_GCODE_UNDEFINED_FEED_RATE 22 49 | #define STATUS_GCODE_COMMAND_VALUE_NOT_INTEGER 23 50 | #define STATUS_GCODE_AXIS_COMMAND_CONFLICT 24 51 | #define STATUS_GCODE_WORD_REPEATED 25 52 | #define STATUS_GCODE_NO_AXIS_WORDS 26 53 | #define STATUS_GCODE_INVALID_LINE_NUMBER 27 54 | #define STATUS_GCODE_VALUE_WORD_MISSING 28 55 | #define STATUS_GCODE_UNSUPPORTED_COORD_SYS 29 56 | #define STATUS_GCODE_G53_INVALID_MOTION_MODE 30 57 | #define STATUS_GCODE_AXIS_WORDS_EXIST 31 58 | #define STATUS_GCODE_NO_AXIS_WORDS_IN_PLANE 32 59 | #define STATUS_GCODE_INVALID_TARGET 33 60 | #define STATUS_GCODE_ARC_RADIUS_ERROR 34 61 | #define STATUS_GCODE_NO_OFFSETS_IN_PLANE 35 62 | #define STATUS_GCODE_UNUSED_WORDS 36 63 | #define STATUS_GCODE_G43_DYNAMIC_AXIS_ERROR 37 64 | #define STATUS_GCODE_MAX_VALUE_EXCEEDED 38 65 | 66 | // Define Grbl alarm codes. Valid values (1-255). 0 is reserved. 67 | #define ALARM_HARD_LIMIT_ERROR EXEC_ALARM_HARD_LIMIT 68 | #define ALARM_SOFT_LIMIT_ERROR EXEC_ALARM_SOFT_LIMIT 69 | #define ALARM_ABORT_CYCLE EXEC_ALARM_ABORT_CYCLE 70 | #define ALARM_PROBE_FAIL_INITIAL EXEC_ALARM_PROBE_FAIL_INITIAL 71 | #define ALARM_PROBE_FAIL_CONTACT EXEC_ALARM_PROBE_FAIL_CONTACT 72 | #define ALARM_HOMING_FAIL_RESET EXEC_ALARM_HOMING_FAIL_RESET 73 | #define ALARM_HOMING_FAIL_DOOR EXEC_ALARM_HOMING_FAIL_DOOR 74 | #define ALARM_HOMING_FAIL_PULLOFF EXEC_ALARM_HOMING_FAIL_PULLOFF 75 | #define ALARM_HOMING_FAIL_APPROACH EXEC_ALARM_HOMING_FAIL_APPROACH 76 | 77 | // Define Grbl feedback message codes. Valid values (0-255). 78 | #define MESSAGE_CRITICAL_EVENT 1 79 | #define MESSAGE_ALARM_LOCK 2 80 | #define MESSAGE_ALARM_UNLOCK 3 81 | #define MESSAGE_ENABLED 4 82 | #define MESSAGE_DISABLED 5 83 | #define MESSAGE_SAFETY_DOOR_AJAR 6 84 | #define MESSAGE_CHECK_LIMITS 7 85 | #define MESSAGE_PROGRAM_END 8 86 | #define MESSAGE_RESTORE_DEFAULTS 9 87 | #define MESSAGE_SPINDLE_RESTORE 10 88 | #define MESSAGE_SLEEP_MODE 11 89 | 90 | // Prints system status messages. 91 | void report_status_message(uint8_t status_code); 92 | 93 | // Prints system alarm messages. 94 | void report_alarm_message(uint8_t alarm_code); 95 | 96 | // Prints miscellaneous feedback messages. 97 | void report_feedback_message(uint8_t message_code); 98 | 99 | // Prints welcome message 100 | void report_init_message(); 101 | 102 | // Prints Grbl help and current global settings 103 | void report_grbl_help(); 104 | 105 | // Prints Grbl global settings 106 | void report_grbl_settings(); 107 | 108 | // Prints an echo of the pre-parsed line received right before execution. 109 | void report_echo_line_received(char *line); 110 | 111 | // Prints realtime status report 112 | void report_realtime_status(); 113 | 114 | // Prints recorded probe position 115 | void report_probe_parameters(); 116 | 117 | // Prints Grbl NGC parameters (coordinate offsets, probe) 118 | void report_ngc_parameters(); 119 | 120 | // Prints current g-code parser mode state 121 | void report_gcode_modes(); 122 | 123 | // Prints startup line when requested and executed. 124 | void report_startup_line(uint8_t n, char *line); 125 | void report_execute_startup_message(char *line, uint8_t status_code); 126 | 127 | // Prints build info and user info 128 | void report_build_info(char *line); 129 | 130 | #ifdef DEBUG 131 | void report_realtime_debug(); 132 | #endif 133 | 134 | #endif 135 | -------------------------------------------------------------------------------- /Libraries/STM32F10x_StdPeriph_Driver/inc/stm32f10x_pwr.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_pwr.h 4 | * @author MCD Application Team 5 | * @version V3.6.1 6 | * @date 05-March-2012 7 | * @brief This file contains all the functions prototypes for the PWR firmware 8 | * library. 9 | ****************************************************************************** 10 | * @attention 11 | * 12 | *

© COPYRIGHT 2012 STMicroelectronics

13 | * 14 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 | * You may not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at: 17 | * 18 | * http://www.st.com/software_license_agreement_liberty_v2 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | * 26 | ****************************************************************************** 27 | */ 28 | 29 | /* Define to prevent recursive inclusion -------------------------------------*/ 30 | #ifndef __STM32F10x_PWR_H 31 | #define __STM32F10x_PWR_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Includes ------------------------------------------------------------------*/ 38 | #include "stm32f10x.h" 39 | 40 | /** @addtogroup STM32F10x_StdPeriph_Driver 41 | * @{ 42 | */ 43 | 44 | /** @addtogroup PWR 45 | * @{ 46 | */ 47 | 48 | /** @defgroup PWR_Exported_Types 49 | * @{ 50 | */ 51 | 52 | /** 53 | * @} 54 | */ 55 | 56 | /** @defgroup PWR_Exported_Constants 57 | * @{ 58 | */ 59 | 60 | /** @defgroup PVD_detection_level 61 | * @{ 62 | */ 63 | 64 | #define PWR_PVDLevel_2V2 ((uint32_t)0x00000000) 65 | #define PWR_PVDLevel_2V3 ((uint32_t)0x00000020) 66 | #define PWR_PVDLevel_2V4 ((uint32_t)0x00000040) 67 | #define PWR_PVDLevel_2V5 ((uint32_t)0x00000060) 68 | #define PWR_PVDLevel_2V6 ((uint32_t)0x00000080) 69 | #define PWR_PVDLevel_2V7 ((uint32_t)0x000000A0) 70 | #define PWR_PVDLevel_2V8 ((uint32_t)0x000000C0) 71 | #define PWR_PVDLevel_2V9 ((uint32_t)0x000000E0) 72 | #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLevel_2V2) || ((LEVEL) == PWR_PVDLevel_2V3)|| \ 73 | ((LEVEL) == PWR_PVDLevel_2V4) || ((LEVEL) == PWR_PVDLevel_2V5)|| \ 74 | ((LEVEL) == PWR_PVDLevel_2V6) || ((LEVEL) == PWR_PVDLevel_2V7)|| \ 75 | ((LEVEL) == PWR_PVDLevel_2V8) || ((LEVEL) == PWR_PVDLevel_2V9)) 76 | /** 77 | * @} 78 | */ 79 | 80 | /** @defgroup Regulator_state_is_STOP_mode 81 | * @{ 82 | */ 83 | 84 | #define PWR_Regulator_ON ((uint32_t)0x00000000) 85 | #define PWR_Regulator_LowPower ((uint32_t)0x00000001) 86 | #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_Regulator_ON) || \ 87 | ((REGULATOR) == PWR_Regulator_LowPower)) 88 | /** 89 | * @} 90 | */ 91 | 92 | /** @defgroup STOP_mode_entry 93 | * @{ 94 | */ 95 | 96 | #define PWR_STOPEntry_WFI ((uint8_t)0x01) 97 | #define PWR_STOPEntry_WFE ((uint8_t)0x02) 98 | #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPEntry_WFI) || ((ENTRY) == PWR_STOPEntry_WFE)) 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | /** @defgroup PWR_Flag 105 | * @{ 106 | */ 107 | 108 | #define PWR_FLAG_WU ((uint32_t)0x00000001) 109 | #define PWR_FLAG_SB ((uint32_t)0x00000002) 110 | #define PWR_FLAG_PVDO ((uint32_t)0x00000004) 111 | #define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \ 112 | ((FLAG) == PWR_FLAG_PVDO)) 113 | 114 | #define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB)) 115 | /** 116 | * @} 117 | */ 118 | 119 | /** 120 | * @} 121 | */ 122 | 123 | /** @defgroup PWR_Exported_Macros 124 | * @{ 125 | */ 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | /** @defgroup PWR_Exported_Functions 132 | * @{ 133 | */ 134 | 135 | void PWR_DeInit(void); 136 | void PWR_BackupAccessCmd(FunctionalState NewState); 137 | void PWR_PVDCmd(FunctionalState NewState); 138 | void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel); 139 | void PWR_WakeUpPinCmd(FunctionalState NewState); 140 | void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry); 141 | void PWR_EnterSTANDBYMode(void); 142 | FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG); 143 | void PWR_ClearFlag(uint32_t PWR_FLAG); 144 | 145 | #ifdef __cplusplus 146 | } 147 | #endif 148 | 149 | #endif /* __STM32F10x_PWR_H */ 150 | /** 151 | * @} 152 | */ 153 | 154 | /** 155 | * @} 156 | */ 157 | 158 | /** 159 | * @} 160 | */ 161 | 162 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 163 | -------------------------------------------------------------------------------- /stm_usb_fs_lib/src/usb_sil.c: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** 2 | * File Name : usb_sil.c 3 | * Author : MCD Application Team 4 | * Version : V3.2.1 5 | * Date : 07/05/2010 6 | * Description : Simplified Interface Layer for Global Initialization and 7 | * Endpoint Rea/Write operations. 8 | ******************************************************************************** 9 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 10 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 11 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 12 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 13 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 14 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 15 | *******************************************************************************/ 16 | 17 | /* Includes ------------------------------------------------------------------*/ 18 | #include "usb_lib.h" 19 | 20 | /* Private typedef -----------------------------------------------------------*/ 21 | /* Private define ------------------------------------------------------------*/ 22 | /* Private macro -------------------------------------------------------------*/ 23 | /* Private variables ---------------------------------------------------------*/ 24 | /* Extern variables ----------------------------------------------------------*/ 25 | /* Private function prototypes -----------------------------------------------*/ 26 | /* Private functions ---------------------------------------------------------*/ 27 | 28 | /******************************************************************************* 29 | * Function Name : USB_SIL_Init 30 | * Description : Initialize the USB Device IP and the Endpoint 0. 31 | * Input : None. 32 | * Output : None. 33 | * Return : Status. 34 | *******************************************************************************/ 35 | uint32_t USB_SIL_Init(void) 36 | { 37 | #ifndef STM32F10X_CL 38 | 39 | /* USB interrupts initialization */ 40 | /* clear pending interrupts */ 41 | _SetISTR(0); 42 | wInterrupt_Mask = IMR_MSK; 43 | /* set interrupts mask */ 44 | _SetCNTR(wInterrupt_Mask); 45 | 46 | #else 47 | 48 | /* Perform OTG Device initialization procedure (including EP0 init) */ 49 | OTG_DEV_Init(); 50 | 51 | #endif /* STM32F10X_CL */ 52 | 53 | return 0; 54 | } 55 | 56 | /******************************************************************************* 57 | * Function Name : USB_SIL_Write 58 | * Description : Write a buffer of data to a selected endpoint. 59 | * Input : - bEpAddr: The address of the non control endpoint. 60 | * - pBufferPointer: The pointer to the buffer of data to be written 61 | * to the endpoint. 62 | * - wBufferSize: Number of data to be written (in bytes). 63 | * Output : None. 64 | * Return : Status. 65 | *******************************************************************************/ 66 | uint32_t USB_SIL_Write(uint8_t bEpAddr, uint8_t* pBufferPointer, uint32_t wBufferSize) 67 | { 68 | #ifndef STM32F10X_CL 69 | 70 | /* Use the memory interface function to write to the selected endpoint */ 71 | UserToPMABufferCopy(pBufferPointer, GetEPTxAddr(bEpAddr & 0x7F), wBufferSize); 72 | 73 | /* Update the data length in the control register */ 74 | SetEPTxCount((bEpAddr & 0x7F), wBufferSize); 75 | 76 | #else 77 | 78 | /* Use the PCD interface layer function to write to the selected endpoint */ 79 | PCD_EP_Write (bEpAddr, pBufferPointer, wBufferSize); 80 | 81 | #endif /* STM32F10X_CL */ 82 | 83 | return 0; 84 | } 85 | 86 | /******************************************************************************* 87 | * Function Name : USB_SIL_Read 88 | * Description : Write a buffer of data to a selected endpoint. 89 | * Input : - bEpAddr: The address of the non control endpoint. 90 | * - pBufferPointer: The pointer to which will be saved the 91 | * received data buffer. 92 | * Output : None. 93 | * Return : Number of received data (in Bytes). 94 | *******************************************************************************/ 95 | uint32_t USB_SIL_Read(uint8_t bEpAddr, uint8_t* pBufferPointer) 96 | { 97 | uint32_t DataLength = 0; 98 | 99 | #ifndef STM32F10X_CL 100 | 101 | /* Get the number of received data on the selected Endpoint */ 102 | DataLength = GetEPRxCount(bEpAddr & 0x7F); 103 | 104 | /* Use the memory interface function to write to the selected endpoint */ 105 | PMAToUserBufferCopy(pBufferPointer, GetEPRxAddr(bEpAddr & 0x7F), DataLength); 106 | 107 | #else 108 | 109 | USB_OTG_EP *ep; 110 | 111 | /* Get the structure pointer of the selected Endpoint */ 112 | ep = PCD_GetOutEP(bEpAddr); 113 | 114 | /* Get the number of received data */ 115 | DataLength = ep->xfer_len; 116 | 117 | /* Use the PCD interface layer function to read the selected endpoint */ 118 | PCD_EP_Read (bEpAddr, pBufferPointer, DataLength); 119 | 120 | #endif /* STM32F10X_CL */ 121 | 122 | /* Return the number of received data */ 123 | return DataLength; 124 | } 125 | 126 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 127 | -------------------------------------------------------------------------------- /doc/log/commit_log_v1.0b.txt: -------------------------------------------------------------------------------- 1 | ---------------- 2 | Date: 2015-09-30 3 | Author: Sonny Jeon 4 | Subject: Bug fixes. 5 | 6 | - G38.x was not printing correctly in the $G g-code state reports. Now 7 | fixed. 8 | 9 | - When investigating the above issue, it was noticed that G38.x 10 | wouldn’t show at all, but instead a G0 would be printed. This was 11 | unlike the v0.9j master build. It turned out volatile variables do not 12 | like to be defined inside a C struct. These are undefined on how to be 13 | handled. Once pulled out, all weird issues went away. 14 | 15 | - Also changed two ‘sizeof()’ statements in the mc_probe() and 16 | probe_state_monitor() functions to be more robust later on. 17 | 18 | - Updated the commit logs to individual files for each minor release. 19 | Forgot to update the generating script to account for this. 20 | 21 | 22 | ---------------- 23 | Date: 2015-09-30 24 | Author: Sonny Jeon 25 | Subject: Minor bug fixes. 26 | 27 | - G38.x was not printing correctly in the $G g-code state reports. Now 28 | fixed. 29 | 30 | - Potential bug regarding volatile variables inside a struct. It has 31 | never been a problem in v0.9, but ran into this during v1.0 32 | development. Just to be safe, the fixes are applied here. 33 | 34 | - Updated pre-built firmwares with these two bug fixes. 35 | 36 | 37 | ---------------- 38 | Date: 2015-09-24 39 | Author: Sonny Jeon 40 | Subject: Updated G28/G30 intermediate motion behavior. 41 | 42 | - G28 and G30’s behavior has been updated from the old NIST g-code 43 | standard to LinuxCNC’s. Previously when an intermediate motion was 44 | programmed, the NIST standard would move all axes to the final G28/30 45 | stored coordinates. LinuxCNC states it only moves the axes specified in 46 | the command. 47 | 48 | For example, suppose G28’s stored position is (x,y,z) = (1,2,3) for 49 | simplicity, and we want to do an automated z-axis tool retraction and 50 | then park at the x,y location. `G28 G91 Z5` will first move the Z axis 51 | 5mm(or inches) up, then move Z to position 3 in machine coordinates. 52 | Next, the command `G28 G91 X0 Y0` would skip the intermediate move 53 | since distance is zero, but then move only the x and y axes to machine 54 | coordinates 1 and 2, respectively. The z-axis wouldn’t move in this 55 | case, since it wasn’t specified. 56 | 57 | This change is intended to make Grbl more LinuxCNC compatible while 58 | making commands, like the shown tool retraction, much easier to 59 | implement. 60 | 61 | 62 | ---------------- 63 | Date: 2015-09-05 64 | Author: Sonny Jeon 65 | Subject: Parking motion bug fix. 66 | 67 | - Parking motion would intermittently complete the queued tool path 68 | upon resuming in certain scenarios. Now fixed. 69 | 70 | 71 | ---------------- 72 | Date: 2015-08-29 73 | Author: Sonny Jeon 74 | Subject: Optional line number reporting bug fix. 75 | 76 | - Fixed a bug where it would not compile when USE_LINE_NUMBERS was 77 | enabled. 78 | 79 | 80 | ---------------- 81 | Date: 2015-08-27 82 | Author: Sonny Jeon 83 | Subject: Update README 84 | 85 | 86 | ---------------- 87 | Date: 2015-08-27 88 | Author: Sonny Jeon 89 | Subject: v1.0 Beta Release. 90 | 91 | - Tons of new stuff in this release, which is fairly stable and well 92 | tested. However, much more is coming soon! 93 | 94 | - Real-time parking motion with safety door. When this compile option 95 | is enabled, an opened safety door will cause Grbl to automatically feed 96 | hold, retract, de-energize the spindle/coolant, and parks near Z max. 97 | After the door is closed and resume is commanded, this reverses and the 98 | program continues as if nothing happened. This is also highly 99 | configurable. See config.h for details. 100 | 101 | - New spindle max and min rpm ‘$’ settings! This has been requested 102 | often. Grbl will output 5V when commanded to turn on the spindle at its 103 | max rpm, and 0.02V with min rpm. The voltage and the rpm range are 104 | linear to each other. This should help users tweak their settings to 105 | get close to true rpm’s. 106 | 107 | - If the new max rpm ‘$’ setting is set = 0 or less than min rpm, the 108 | spindle speed PWM pin will act like a regular on/off spindle enable 109 | pin. On pin D11. 110 | 111 | - BEWARE: Your old EEPROM settings will be wiped! The new spindle rpm 112 | settings require a new settings version, so Grbl will automatically 113 | wipe and restore the EEPROM with the new defaults. 114 | 115 | - Control pin can now be inverted individually with a 116 | CONTROL_INVERT_MASK in the cpu_map header file. Not typical for users 117 | to need this, but handy to have. 118 | 119 | - Fixed bug when Grbl receive too many characters in a line and 120 | overflows. Previously it would respond with an error per overflow 121 | character and another acknowledge upon an EOL character. This broke the 122 | streaming protocol. Now fixed to only respond with an error after an 123 | EOL character. 124 | 125 | - Fixed a bug with the safety door during an ALARM mode. You now can’t 126 | home or unlock the axes until the safety door has been closed. This is 127 | for safety reasons (obviously.) 128 | 129 | - Tweaked some the Mega2560 cpu_map settings . Increased segment buffer 130 | size and fixed the spindle PWM settings to output at a higher PWM 131 | frequency. 132 | 133 | - Generalized the delay function used by G4 delay for use by parking 134 | motion. Allows non-blocking status reports and real-time control during 135 | re-energizing of the spindle and coolant. 136 | 137 | - Added spindle rpm max and min defaults to default.h files. 138 | 139 | - Added a new print float for rpm values. 140 | 141 | -------------------------------------------------------------------------------- /src/nuts_bolts.c: -------------------------------------------------------------------------------- 1 | /* 2 | nuts_bolts.c - Shared functions 3 | Part of Grbl 4 | 5 | Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC 6 | Copyright (c) 2009-2011 Simen Svale Skogsrud 7 | 8 | Grbl is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Grbl is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Grbl. If not, see . 20 | */ 21 | 22 | #include "grbl.h" 23 | 24 | 25 | #define MAX_INT_DIGITS 8 // Maximum number of digits in int32 (and float) 26 | 27 | 28 | // Extracts a floating point value from a string. The following code is based loosely on 29 | // the avr-libc strtod() function by Michael Stumpf and Dmitry Xmelkov and many freely 30 | // available conversion method examples, but has been highly optimized for Grbl. For known 31 | // CNC applications, the typical decimal value is expected to be in the range of E0 to E-4. 32 | // Scientific notation is officially not supported by g-code, and the 'E' character may 33 | // be a g-code word on some CNC systems. So, 'E' notation will not be recognized. 34 | // NOTE: Thanks to Radu-Eosif Mihailescu for identifying the issues with using strtod(). 35 | uint8_t read_float(char *line, uint8_t *char_counter, float *float_ptr) 36 | { 37 | char *ptr = line + *char_counter; 38 | unsigned char c; 39 | 40 | // Grab first character and increment pointer. No spaces assumed in line. 41 | c = *ptr++; 42 | 43 | // Capture initial positive/minus character 44 | bool isnegative = false; 45 | if (c == '-') { 46 | isnegative = true; 47 | c = *ptr++; 48 | } else if (c == '+') { 49 | c = *ptr++; 50 | } 51 | 52 | // Extract number into fast integer. Track decimal in terms of exponent value. 53 | uint32_t intval = 0; 54 | int8_t exp = 0; 55 | uint8_t ndigit = 0; 56 | bool isdecimal = false; 57 | while(1) { 58 | c -= '0'; 59 | if (c <= 9) { 60 | ndigit++; 61 | if (ndigit <= MAX_INT_DIGITS) { 62 | if (isdecimal) { exp--; } 63 | intval = (((intval << 2) + intval) << 1) + c; // intval*10 + c 64 | } else { 65 | if (!(isdecimal)) { exp++; } // Drop overflow digits 66 | } 67 | } else if (c == (('.'-'0') & 0xff) && !(isdecimal)) { 68 | isdecimal = true; 69 | } else { 70 | break; 71 | } 72 | c = *ptr++; 73 | } 74 | 75 | // Return if no digits have been read. 76 | if (!ndigit) { return(false); }; 77 | 78 | // Convert integer into floating point. 79 | float fval; 80 | fval = (float)intval; 81 | 82 | // Apply decimal. Should perform no more than two floating point multiplications for the 83 | // expected range of E0 to E-4. 84 | if (fval != 0) { 85 | while (exp <= -2) { 86 | fval *= 0.01f; 87 | exp += 2; 88 | } 89 | if (exp < 0) { 90 | fval *= 0.1f; 91 | } else if (exp > 0) { 92 | do { 93 | fval *= 10.0f; 94 | } while (--exp > 0); 95 | } 96 | } 97 | 98 | // Assign floating point value with correct sign. 99 | if (isnegative) { 100 | *float_ptr = -fval; 101 | } else { 102 | *float_ptr = fval; 103 | } 104 | 105 | *char_counter = ptr - line - 1; // Set char_counter to next statement 106 | 107 | return(true); 108 | } 109 | 110 | 111 | // Non-blocking delay function used for general operation and suspend features. 112 | void delay_sec(float seconds, uint8_t mode) 113 | { 114 | uint16_t i = (uint16_t)ceilf(1000 / DWELL_TIME_STEP*seconds); 115 | while (i-- > 0) { 116 | if (sys.abort) { return; } 117 | if (mode == DELAY_MODE_DWELL) { 118 | protocol_execute_realtime(); 119 | } else { // DELAY_MODE_SYS_SUSPEND 120 | // Execute rt_system() only to avoid nesting suspend loops. 121 | protocol_exec_rt_system(); 122 | if (sys.suspend & SUSPEND_RESTART_RETRACT) { return; } // Bail, if safety door reopens. 123 | } 124 | _delay_ms(DWELL_TIME_STEP); // Delay DWELL_TIME_STEP increment 125 | } 126 | } 127 | 128 | 129 | // Delays variable defined milliseconds. Compiler compatibility fix for _delay_ms(), 130 | // which only accepts constants in future compiler releases. 131 | void delay_ms(uint16_t ms) 132 | { 133 | while ( ms-- ) { _delay_ms(1); } 134 | } 135 | 136 | 137 | // Simple hypotenuse computation function. 138 | //float hypot_f(float x, float y) { return(sqrtf(x*x + y*y)); } 139 | float hypot_f(float x, float y) { return(sqrt(x*x + y*y)); } 140 | 141 | float convert_delta_vector_to_unit_vector(float *vector) 142 | { 143 | uint8_t idx; 144 | float magnitude = 0.0f; 145 | for (idx=0; idxCurrent_Configuration != 0) 68 | { 69 | /* Device configured */ 70 | bDeviceState = CONFIGURED; 71 | } 72 | else 73 | { 74 | bDeviceState = ATTACHED; 75 | } 76 | } 77 | 78 | /******************************************************************************* 79 | * Description : Configures the USB interrupts 80 | *******************************************************************************/ 81 | void USB_Interrupts_Config(void) 82 | { 83 | NVIC_InitTypeDef NVIC_InitStructure; 84 | 85 | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); 86 | 87 | NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn; 88 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; 89 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; 90 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 91 | NVIC_Init(&NVIC_InitStructure); 92 | // Added by Paul 93 | NVIC_InitStructure.NVIC_IRQChannel = USBWakeUp_IRQn; 94 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; 95 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; 96 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 97 | NVIC_Init(&NVIC_InitStructure); 98 | } 99 | 100 | /******************************************************************************* 101 | * Description : Software Connection/Disconnection of USB Cable 102 | *******************************************************************************/ 103 | void USB_Cable_Config(FunctionalState NewState) 104 | { 105 | } 106 | 107 | /******************************************************************************* 108 | * Description : Create the serial number string descriptor. 109 | *******************************************************************************/ 110 | void Get_SerialNum(void) 111 | { 112 | uint32_t Device_Serial0, Device_Serial1, Device_Serial2; 113 | 114 | Device_Serial0 = *(__IO uint32_t*) (0x1FFFF7E8); 115 | Device_Serial1 = *(__IO uint32_t*) (0x1FFFF7EC); 116 | Device_Serial2 = *(__IO uint32_t*) (0x1FFFF7F0); 117 | 118 | Device_Serial0 += Device_Serial2; 119 | 120 | if (Device_Serial0 != 0) 121 | { 122 | IntToUnicode(Device_Serial0, &Virtual_Com_Port_StringSerial[2], 8); 123 | IntToUnicode(Device_Serial1, &Virtual_Com_Port_StringSerial[18], 4); 124 | } 125 | } 126 | 127 | /******************************************************************************* 128 | * Description : Convert Hex 32Bits value into char. 129 | *******************************************************************************/ 130 | static void IntToUnicode(uint32_t value, uint8_t *pbuf, uint8_t len) 131 | { 132 | uint8_t idx = 0; 133 | 134 | for (idx = 0; idx < len; idx++) 135 | { 136 | if (((value >> 28)) < 0xA) 137 | { 138 | pbuf[2 * idx] = (value >> 28) + '0'; 139 | } 140 | else 141 | { 142 | pbuf[2 * idx] = (value >> 28) + 'A' - 10; 143 | } 144 | 145 | value = value << 4; 146 | 147 | pbuf[2 * idx + 1] = 0; 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_iwdg.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_iwdg.c 4 | * @author MCD Application Team 5 | * @version V3.6.1 6 | * @date 05-March-2012 7 | * @brief This file provides all the IWDG firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f10x_iwdg.h" 30 | 31 | /** @addtogroup STM32F10x_StdPeriph_Driver 32 | * @{ 33 | */ 34 | 35 | /** @defgroup IWDG 36 | * @brief IWDG driver modules 37 | * @{ 38 | */ 39 | 40 | /** @defgroup IWDG_Private_TypesDefinitions 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @} 46 | */ 47 | 48 | /** @defgroup IWDG_Private_Defines 49 | * @{ 50 | */ 51 | 52 | /* ---------------------- IWDG registers bit mask ----------------------------*/ 53 | 54 | /* KR register bit mask */ 55 | #define KR_KEY_Reload ((uint16_t)0xAAAA) 56 | #define KR_KEY_Enable ((uint16_t)0xCCCC) 57 | 58 | /** 59 | * @} 60 | */ 61 | 62 | /** @defgroup IWDG_Private_Macros 63 | * @{ 64 | */ 65 | 66 | /** 67 | * @} 68 | */ 69 | 70 | /** @defgroup IWDG_Private_Variables 71 | * @{ 72 | */ 73 | 74 | /** 75 | * @} 76 | */ 77 | 78 | /** @defgroup IWDG_Private_FunctionPrototypes 79 | * @{ 80 | */ 81 | 82 | /** 83 | * @} 84 | */ 85 | 86 | /** @defgroup IWDG_Private_Functions 87 | * @{ 88 | */ 89 | 90 | /** 91 | * @brief Enables or disables write access to IWDG_PR and IWDG_RLR registers. 92 | * @param IWDG_WriteAccess: new state of write access to IWDG_PR and IWDG_RLR registers. 93 | * This parameter can be one of the following values: 94 | * @arg IWDG_WriteAccess_Enable: Enable write access to IWDG_PR and IWDG_RLR registers 95 | * @arg IWDG_WriteAccess_Disable: Disable write access to IWDG_PR and IWDG_RLR registers 96 | * @retval None 97 | */ 98 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess) 99 | { 100 | /* Check the parameters */ 101 | assert_param(IS_IWDG_WRITE_ACCESS(IWDG_WriteAccess)); 102 | IWDG->KR = IWDG_WriteAccess; 103 | } 104 | 105 | /** 106 | * @brief Sets IWDG Prescaler value. 107 | * @param IWDG_Prescaler: specifies the IWDG Prescaler value. 108 | * This parameter can be one of the following values: 109 | * @arg IWDG_Prescaler_4: IWDG prescaler set to 4 110 | * @arg IWDG_Prescaler_8: IWDG prescaler set to 8 111 | * @arg IWDG_Prescaler_16: IWDG prescaler set to 16 112 | * @arg IWDG_Prescaler_32: IWDG prescaler set to 32 113 | * @arg IWDG_Prescaler_64: IWDG prescaler set to 64 114 | * @arg IWDG_Prescaler_128: IWDG prescaler set to 128 115 | * @arg IWDG_Prescaler_256: IWDG prescaler set to 256 116 | * @retval None 117 | */ 118 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler) 119 | { 120 | /* Check the parameters */ 121 | assert_param(IS_IWDG_PRESCALER(IWDG_Prescaler)); 122 | IWDG->PR = IWDG_Prescaler; 123 | } 124 | 125 | /** 126 | * @brief Sets IWDG Reload value. 127 | * @param Reload: specifies the IWDG Reload value. 128 | * This parameter must be a number between 0 and 0x0FFF. 129 | * @retval None 130 | */ 131 | void IWDG_SetReload(uint16_t Reload) 132 | { 133 | /* Check the parameters */ 134 | assert_param(IS_IWDG_RELOAD(Reload)); 135 | IWDG->RLR = Reload; 136 | } 137 | 138 | /** 139 | * @brief Reloads IWDG counter with value defined in the reload register 140 | * (write access to IWDG_PR and IWDG_RLR registers disabled). 141 | * @param None 142 | * @retval None 143 | */ 144 | void IWDG_ReloadCounter(void) 145 | { 146 | IWDG->KR = KR_KEY_Reload; 147 | } 148 | 149 | /** 150 | * @brief Enables IWDG (write access to IWDG_PR and IWDG_RLR registers disabled). 151 | * @param None 152 | * @retval None 153 | */ 154 | void IWDG_Enable(void) 155 | { 156 | IWDG->KR = KR_KEY_Enable; 157 | } 158 | 159 | /** 160 | * @brief Checks whether the specified IWDG flag is set or not. 161 | * @param IWDG_FLAG: specifies the flag to check. 162 | * This parameter can be one of the following values: 163 | * @arg IWDG_FLAG_PVU: Prescaler Value Update on going 164 | * @arg IWDG_FLAG_RVU: Reload Value Update on going 165 | * @retval The new state of IWDG_FLAG (SET or RESET). 166 | */ 167 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG) 168 | { 169 | FlagStatus bitstatus = RESET; 170 | /* Check the parameters */ 171 | assert_param(IS_IWDG_FLAG(IWDG_FLAG)); 172 | if ((IWDG->SR & IWDG_FLAG) != (uint32_t)RESET) 173 | { 174 | bitstatus = SET; 175 | } 176 | else 177 | { 178 | bitstatus = RESET; 179 | } 180 | /* Return the flag status */ 181 | return bitstatus; 182 | } 183 | 184 | /** 185 | * @} 186 | */ 187 | 188 | /** 189 | * @} 190 | */ 191 | 192 | /** 193 | * @} 194 | */ 195 | 196 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 197 | -------------------------------------------------------------------------------- /Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_dbgmcu.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f10x_dbgmcu.c 4 | * @author MCD Application Team 5 | * @version V3.6.1 6 | * @date 05-March-2012 7 | * @brief This file provides all the DBGMCU firmware functions. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | *

© COPYRIGHT 2012 STMicroelectronics

12 | * 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 14 | * You may not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at: 16 | * 17 | * http://www.st.com/software_license_agreement_liberty_v2 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | ****************************************************************************** 26 | */ 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f10x_dbgmcu.h" 30 | 31 | /** @addtogroup STM32F10x_StdPeriph_Driver 32 | * @{ 33 | */ 34 | 35 | /** @defgroup DBGMCU 36 | * @brief DBGMCU driver modules 37 | * @{ 38 | */ 39 | 40 | /** @defgroup DBGMCU_Private_TypesDefinitions 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @} 46 | */ 47 | 48 | /** @defgroup DBGMCU_Private_Defines 49 | * @{ 50 | */ 51 | 52 | #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF) 53 | /** 54 | * @} 55 | */ 56 | 57 | /** @defgroup DBGMCU_Private_Macros 58 | * @{ 59 | */ 60 | 61 | /** 62 | * @} 63 | */ 64 | 65 | /** @defgroup DBGMCU_Private_Variables 66 | * @{ 67 | */ 68 | 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @defgroup DBGMCU_Private_FunctionPrototypes 74 | * @{ 75 | */ 76 | 77 | /** 78 | * @} 79 | */ 80 | 81 | /** @defgroup DBGMCU_Private_Functions 82 | * @{ 83 | */ 84 | 85 | /** 86 | * @brief Returns the device revision identifier. 87 | * @param None 88 | * @retval Device revision identifier 89 | */ 90 | uint32_t DBGMCU_GetREVID(void) 91 | { 92 | return(DBGMCU->IDCODE >> 16); 93 | } 94 | 95 | /** 96 | * @brief Returns the device identifier. 97 | * @param None 98 | * @retval Device identifier 99 | */ 100 | uint32_t DBGMCU_GetDEVID(void) 101 | { 102 | return(DBGMCU->IDCODE & IDCODE_DEVID_MASK); 103 | } 104 | 105 | /** 106 | * @brief Configures the specified peripheral and low power mode behavior 107 | * when the MCU under Debug mode. 108 | * @param DBGMCU_Periph: specifies the peripheral and low power mode. 109 | * This parameter can be any combination of the following values: 110 | * @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode 111 | * @arg DBGMCU_STOP: Keep debugger connection during STOP mode 112 | * @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode 113 | * @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted 114 | * @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted 115 | * @arg DBGMCU_TIM1_STOP: TIM1 counter stopped when Core is halted 116 | * @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted 117 | * @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted 118 | * @arg DBGMCU_TIM4_STOP: TIM4 counter stopped when Core is halted 119 | * @arg DBGMCU_CAN1_STOP: Debug CAN2 stopped when Core is halted 120 | * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is halted 121 | * @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is halted 122 | * @arg DBGMCU_TIM5_STOP: TIM5 counter stopped when Core is halted 123 | * @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted 124 | * @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted 125 | * @arg DBGMCU_TIM8_STOP: TIM8 counter stopped when Core is halted 126 | * @arg DBGMCU_CAN2_STOP: Debug CAN2 stopped when Core is halted 127 | * @arg DBGMCU_TIM15_STOP: TIM15 counter stopped when Core is halted 128 | * @arg DBGMCU_TIM16_STOP: TIM16 counter stopped when Core is halted 129 | * @arg DBGMCU_TIM17_STOP: TIM17 counter stopped when Core is halted 130 | * @arg DBGMCU_TIM9_STOP: TIM9 counter stopped when Core is halted 131 | * @arg DBGMCU_TIM10_STOP: TIM10 counter stopped when Core is halted 132 | * @arg DBGMCU_TIM11_STOP: TIM11 counter stopped when Core is halted 133 | * @arg DBGMCU_TIM12_STOP: TIM12 counter stopped when Core is halted 134 | * @arg DBGMCU_TIM13_STOP: TIM13 counter stopped when Core is halted 135 | * @arg DBGMCU_TIM14_STOP: TIM14 counter stopped when Core is halted 136 | * @param NewState: new state of the specified peripheral in Debug mode. 137 | * This parameter can be: ENABLE or DISABLE. 138 | * @retval None 139 | */ 140 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState) 141 | { 142 | /* Check the parameters */ 143 | assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph)); 144 | assert_param(IS_FUNCTIONAL_STATE(NewState)); 145 | 146 | if (NewState != DISABLE) 147 | { 148 | DBGMCU->CR |= DBGMCU_Periph; 149 | } 150 | else 151 | { 152 | DBGMCU->CR &= ~DBGMCU_Periph; 153 | } 154 | } 155 | 156 | /** 157 | * @} 158 | */ 159 | 160 | /** 161 | * @} 162 | */ 163 | 164 | /** 165 | * @} 166 | */ 167 | 168 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 169 | -------------------------------------------------------------------------------- /src/print.c: -------------------------------------------------------------------------------- 1 | /* 2 | print.c - Functions for formatting output strings 3 | Part of Grbl 4 | 5 | Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC 6 | Copyright (c) 2009-2011 Simen Svale Skogsrud 7 | 8 | Grbl is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Grbl is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Grbl. If not, see . 20 | */ 21 | 22 | #include "grbl.h" 23 | 24 | 25 | void printString(const char *s) 26 | { 27 | while (*s) 28 | serial_write(*s++); 29 | } 30 | 31 | #ifdef AVRTARGET 32 | // Print a string stored in PGM-memory 33 | void printPgmString(const char *s) 34 | { 35 | char c; 36 | while ((c = pgm_read_byte_near(s++))) 37 | serial_write(c); 38 | } 39 | #endif 40 | 41 | // void printIntegerInBase(unsigned long n, unsigned long base) 42 | // { 43 | // unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. 44 | // unsigned long i = 0; 45 | // 46 | // if (n == 0) { 47 | // serial_write('0'); 48 | // return; 49 | // } 50 | // 51 | // while (n > 0) { 52 | // buf[i++] = n % base; 53 | // n /= base; 54 | // } 55 | // 56 | // for (; i > 0; i--) 57 | // serial_write(buf[i - 1] < 10 ? 58 | // '0' + buf[i - 1] : 59 | // 'A' + buf[i - 1] - 10); 60 | // } 61 | 62 | 63 | // Prints an uint8 variable in base 10. 64 | void print_uint8_base10(uint8_t n) 65 | { 66 | uint8_t digit_a = 0; 67 | uint8_t digit_b = 0; 68 | if (n >= 100) { // 100-255 69 | digit_a = '0' + n % 10; 70 | n /= 10; 71 | } 72 | if (n >= 10) { // 10-99 73 | digit_b = '0' + n % 10; 74 | n /= 10; 75 | } 76 | serial_write('0' + n); 77 | if (digit_b) { serial_write(digit_b); } 78 | if (digit_a) { serial_write(digit_a); } 79 | } 80 | 81 | 82 | // Prints an uint8 variable in base 2 with desired number of desired digits. 83 | void print_uint8_base2_ndigit(uint8_t n, uint8_t digits) { 84 | #if defined(AVRTARGET) || defined(STM32F103C8) 85 | unsigned char buf[digits]; 86 | #endif 87 | #ifdef WIN32 88 | unsigned char buf[20]; 89 | #endif 90 | uint8_t i = 0; 91 | 92 | for (; i < digits; i++) { 93 | buf[i] = n % 2 ; 94 | n /= 2; 95 | } 96 | 97 | for (; i > 0; i--) 98 | serial_write('0' + buf[i - 1]); 99 | } 100 | 101 | 102 | void print_uint32_base10(uint32_t n) 103 | { 104 | if (n == 0) { 105 | serial_write('0'); 106 | return; 107 | } 108 | 109 | unsigned char buf[10]; 110 | uint8_t i = 0; 111 | 112 | while (n > 0) { 113 | buf[i++] = n % 10; 114 | n /= 10; 115 | } 116 | 117 | for (; i > 0; i--) 118 | serial_write('0' + buf[i-1]); 119 | } 120 | 121 | 122 | void printInteger(long n) 123 | { 124 | if (n < 0) { 125 | serial_write('-'); 126 | print_uint32_base10(-n); 127 | } else { 128 | print_uint32_base10(n); 129 | } 130 | } 131 | 132 | 133 | // Convert float to string by immediately converting to a long integer, which contains 134 | // more digits than a float. Number of decimal places, which are tracked by a counter, 135 | // may be set by the user. The integer is then efficiently converted to a string. 136 | // NOTE: AVR '%' and '/' integer operations are very efficient. Bitshifting speed-up 137 | // techniques are actually just slightly slower. Found this out the hard way. 138 | void printFloat(float n, uint8_t decimal_places) 139 | { 140 | if (n < 0) { 141 | serial_write('-'); 142 | n = -n; 143 | } 144 | 145 | uint8_t decimals = decimal_places; 146 | while (decimals >= 2) { // Quickly convert values expected to be E0 to E-4. 147 | n *= 100; 148 | decimals -= 2; 149 | } 150 | if (decimals) { n *= 10; } 151 | n += 0.5; // Add rounding factor. Ensures carryover through entire value. 152 | 153 | // Generate digits backwards and store in string. 154 | unsigned char buf[13]; 155 | uint8_t i = 0; 156 | uint32_t a = (long)n; 157 | while(a > 0) { 158 | buf[i++] = (a % 10) + '0'; // Get digit 159 | a /= 10; 160 | } 161 | while (i < decimal_places) { 162 | buf[i++] = '0'; // Fill in zeros to decimal point for (n < 1) 163 | } 164 | if (i == decimal_places) { // Fill in leading zero, if needed. 165 | buf[i++] = '0'; 166 | } 167 | 168 | // Print the generated string. 169 | for (; i > 0; i--) { 170 | if (i == decimal_places) { serial_write('.'); } // Insert decimal point in right place. 171 | serial_write(buf[i-1]); 172 | } 173 | } 174 | 175 | 176 | // Floating value printing handlers for special variables types used in Grbl and are defined 177 | // in the config.h. 178 | // - CoordValue: Handles all position or coordinate values in inches or mm reporting. 179 | // - RateValue: Handles feed rate and current velocity in inches or mm reporting. 180 | void printFloat_CoordValue(float n) { 181 | if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) { 182 | printFloat(n*INCH_PER_MM,N_DECIMAL_COORDVALUE_INCH); 183 | } else { 184 | printFloat(n,N_DECIMAL_COORDVALUE_MM); 185 | } 186 | } 187 | 188 | void printFloat_RateValue(float n) { 189 | if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) { 190 | printFloat(n*INCH_PER_MM,N_DECIMAL_RATEVALUE_INCH); 191 | } else { 192 | printFloat(n,N_DECIMAL_RATEVALUE_MM); 193 | } 194 | } 195 | 196 | // Debug tool to print free memory in bytes at the called point. 197 | // NOTE: Keep commented unless using. Part of this function always gets compiled in. 198 | // void printFreeMemory() 199 | // { 200 | // extern int __heap_start, *__brkval; 201 | // uint16_t free; // Up to 64k values. 202 | // free = (int) &free - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); 203 | // printInteger((int32_t)free); 204 | // printString(" "); 205 | // } 206 | -------------------------------------------------------------------------------- /inc/grbl.h: -------------------------------------------------------------------------------- 1 | /* 2 | grbl.h - main Grbl include file 3 | Part of Grbl 4 | 5 | Copyright (c) 2015-2016 Sungeun K. Jeon for Gnea Research LLC 6 | 7 | Grbl is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | Grbl is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Grbl. If not, see . 19 | */ 20 | 21 | #ifndef grbl_h 22 | #define grbl_h 23 | 24 | // Grbl versioning system 25 | #define GRBL_VERSION "1.1f" 26 | #define GRBL_VERSION_BUILD "20190323" 27 | #define GRBL_SERIAL "0x00001" // Paul, added OEM info 28 | #define GRBL_SERIAL_BUILD "Date:20190130" // 29 | #define GRBL_OEM "Awesome.tech" // 30 | #define GRBL_PRODUCT "SuperGerbil" // 31 | 32 | //#if !defined(STM32F103C8) && !defined(WIN32) 33 | //#define AVRTARGET 34 | //#endif 35 | 36 | // Define standard libraries used by Grbl. 37 | #ifdef AVRTARGET 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #define PORTPINDEF uint8_t 46 | #endif 47 | #include 48 | #ifdef WIN32 49 | #include 50 | typedef signed char int8_t; 51 | typedef signed short int16_t; 52 | typedef signed int int32_t; 53 | typedef unsigned char uint8_t; 54 | typedef unsigned short uint16_t; 55 | typedef unsigned int uint32_t; 56 | typedef signed long long int64_t; 57 | typedef unsigned long long uint64_t; 58 | typedef int bool; 59 | #define false 0 60 | #define true 1 61 | #define truncf(x) (int32_t)x 62 | #define PSTR(x) x 63 | #define pgm_read_byte_near(x) *(x) 64 | #define _delay_ms(x) Sleep(x) 65 | #define M_PI 3.1415926f 66 | #define LOG(x,y) 67 | #define PORTPINDEF uint8_t 68 | #define printPgmString printString 69 | //#define NOEEPROMSUPPORT 70 | #endif 71 | #ifdef STM32F103C8 72 | #include "stm32f10x.h" 73 | #include "stm32f10x_conf.h" 74 | #include "system_stm32f10x.h" 75 | #include "stm32f10x_gpio.h" 76 | #include "stm32f10x_exti.h" 77 | #include "stm32f10x_tim.h" 78 | #include "misc.h" 79 | #include "stm32f10x_rcc.h" //place holder to add sd card libs 80 | #include "stm32f10x_rtc.h" 81 | /* 82 | #include "ff.h" 83 | #include "diskio.h" 84 | #include "ffconf.h" 85 | #include "integer.h" 86 | #include "xprintf.h" //end of the SD card libs 87 | #include "mmcb.h" 88 | #include "ST7735.h" 89 | #include "integer.h" 90 | */ 91 | 92 | #define PSTR(x) x 93 | #define pgm_read_byte_near(x) *(x) 94 | void _delay_ms(uint32_t x); 95 | void _delay_us(uint32_t x); 96 | #define false 0 97 | #define true 1 98 | //#define PORTPINDEF uint16_t 99 | #define PORTPINDEF uint32_t //Paul 100 | typedef int bool; 101 | //#define NOEEPROMSUPPORT 102 | #define printPgmString printString 103 | #endif 104 | #include 105 | #include 106 | #include 107 | 108 | // Define the Grbl system include files. NOTE: Do not alter organization. 109 | #include "config.h" 110 | #include "nuts_bolts.h" 111 | #include "settings.h" 112 | #include "system.h" 113 | #include "defaults.h" 114 | #include "cpu_map.h" 115 | #include "planner.h" 116 | #include "coolant_control.h" 117 | #include "eeprom.h" 118 | #include "gcode.h" 119 | #include "limits.h" 120 | #include "motion_control.h" 121 | #include "planner.h" 122 | #include "print.h" 123 | /* 124 | * Author Paul: added tool changer 125 | */ 126 | #include "tool.h" 127 | /* 128 | * end 129 | */ 130 | #include "probe.h" 131 | #include "protocol.h" 132 | #include "report.h" 133 | #include "serial.h" 134 | #include "spindle_control.h" 135 | #include "stepper.h" 136 | #include "jog.h" 137 | //#include "stm32_dsp.h" 138 | 139 | // --------------------------------------------------------------------------------------- 140 | // COMPILE-TIME ERROR CHECKING OF DEFINE VALUES: 141 | 142 | #ifndef HOMING_CYCLE_0 143 | #error "Required HOMING_CYCLE_0 not defined." 144 | #endif 145 | 146 | #if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE) 147 | #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled" 148 | #endif 149 | 150 | //#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P) 151 | #if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_STM32F103) 152 | #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor" 153 | #endif 154 | 155 | #if !defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && defined(SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED) 156 | #error "SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED may only be used with USE_SPINDLE_DIR_AS_ENABLE_PIN enabled" 157 | #endif 158 | 159 | #if defined(PARKING_ENABLE) 160 | #if defined(HOMING_FORCE_SET_ORIGIN) 161 | #error "HOMING_FORCE_SET_ORIGIN is not supported with PARKING_ENABLE at this time." 162 | #endif 163 | #endif 164 | 165 | #if defined(ENABLE_PARKING_OVERRIDE_CONTROL) 166 | #if !defined(PARKING_ENABLE) 167 | #error "ENABLE_PARKING_OVERRIDE_CONTROL must be enabled with PARKING_ENABLE." 168 | #endif 169 | #endif 170 | 171 | #if defined(SPINDLE_PWM_MIN_VALUE) 172 | #if !(SPINDLE_PWM_MIN_VALUE > 0) 173 | #error "SPINDLE_PWM_MIN_VALUE must be greater than zero." 174 | #endif 175 | #endif 176 | 177 | #if (REPORT_WCO_REFRESH_BUSY_COUNT < REPORT_WCO_REFRESH_IDLE_COUNT) 178 | #error "WCO busy refresh is less than idle refresh." 179 | #endif 180 | #if (REPORT_OVR_REFRESH_BUSY_COUNT < REPORT_OVR_REFRESH_IDLE_COUNT) 181 | #error "Override busy refresh is less than idle refresh." 182 | #endif 183 | #if (REPORT_WCO_REFRESH_IDLE_COUNT < 2) 184 | #error "WCO refresh must be greater than one." 185 | #endif 186 | #if (REPORT_OVR_REFRESH_IDLE_COUNT < 1) 187 | #error "Override refresh must be greater than zero." 188 | #endif 189 | // --------------------------------------------------------------------------------------- 190 | 191 | #endif 192 | -------------------------------------------------------------------------------- /stm32_flash.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | File: stm32_flash.ld 4 | Info: Generated by Atollic TrueSTUDIO(R) 9.0.0 2018-06-23 5 | 6 | Abstract: Linker script for STM32F103C8 device 7 | Set heap size, stack size, stack location, memory areas and 8 | sections according to application requirements. 9 | 10 | The MIT License (MIT) 11 | Copyright (c) 2018 STMicroelectronics 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in all 21 | copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 | SOFTWARE. 30 | 31 | ****************************************************************************** 32 | */ 33 | 34 | /* Entry Point */ 35 | ENTRY(Reset_Handler) 36 | 37 | /* Highest address of the user mode stack */ 38 | _estack = 0x20005000; /* end of 20K RAM */ 39 | 40 | /* Generate a link error if heap and stack don't fit into RAM */ 41 | _Min_Heap_Size = 0x200; /* 80 required amount of heap */ 42 | _Min_Stack_Size = 0x200; /* 200 required amount of stack */ 43 | 44 | /* Specify the memory areas */ 45 | MEMORY 46 | { 47 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K 48 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K 49 | MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K 50 | } 51 | 52 | /* Define output sections */ 53 | SECTIONS 54 | { 55 | /* The startup code goes first into FLASH */ 56 | .isr_vector : 57 | { 58 | . = ALIGN(4); 59 | KEEP(*(.isr_vector)) /* Startup code */ 60 | . = ALIGN(4); 61 | } >FLASH 62 | 63 | /* The program code and other data goes into FLASH */ 64 | .text : 65 | { 66 | . = ALIGN(4); 67 | *(.text) /* .text sections (code) */ 68 | *(.text*) /* .text* sections (code) */ 69 | *(.glue_7) /* glue arm to thumb code */ 70 | *(.glue_7t) /* glue thumb to arm code */ 71 | *(.eh_frame) 72 | 73 | KEEP (*(.init)) 74 | KEEP (*(.fini)) 75 | 76 | . = ALIGN(4); 77 | _etext = .; /* define a global symbols at end of code */ 78 | } >FLASH 79 | 80 | /* Constant data goes into FLASH */ 81 | .rodata : 82 | { 83 | . = ALIGN(4); 84 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 85 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 86 | . = ALIGN(4); 87 | } >FLASH 88 | 89 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH 90 | .ARM : { 91 | __exidx_start = .; 92 | *(.ARM.exidx*) 93 | __exidx_end = .; 94 | } >FLASH 95 | 96 | .preinit_array : 97 | { 98 | PROVIDE_HIDDEN (__preinit_array_start = .); 99 | KEEP (*(.preinit_array*)) 100 | PROVIDE_HIDDEN (__preinit_array_end = .); 101 | } >FLASH 102 | .init_array : 103 | { 104 | PROVIDE_HIDDEN (__init_array_start = .); 105 | KEEP (*(SORT(.init_array.*))) 106 | KEEP (*(.init_array*)) 107 | PROVIDE_HIDDEN (__init_array_end = .); 108 | } >FLASH 109 | .fini_array : 110 | { 111 | PROVIDE_HIDDEN (__fini_array_start = .); 112 | KEEP (*(SORT(.fini_array.*))) 113 | KEEP (*(.fini_array*)) 114 | PROVIDE_HIDDEN (__fini_array_end = .); 115 | } >FLASH 116 | 117 | /* used by the startup to initialize data */ 118 | _sidata = LOADADDR(.data); 119 | 120 | /* Initialized data sections goes into RAM, load LMA copy after code */ 121 | .data : 122 | { 123 | . = ALIGN(4); 124 | _sdata = .; /* create a global symbol at data start */ 125 | *(.data) /* .data sections */ 126 | *(.data*) /* .data* sections */ 127 | 128 | . = ALIGN(4); 129 | _edata = .; /* define a global symbol at data end */ 130 | } >RAM AT> FLASH 131 | 132 | /* Uninitialized data section */ 133 | . = ALIGN(4); 134 | .bss : 135 | { 136 | /* This is used by the startup in order to initialize the .bss secion */ 137 | _sbss = .; /* define a global symbol at bss start */ 138 | __bss_start__ = _sbss; 139 | *(.bss) 140 | *(.bss*) 141 | *(COMMON) 142 | 143 | . = ALIGN(4); 144 | _ebss = .; /* define a global symbol at bss end */ 145 | __bss_end__ = _ebss; 146 | } >RAM 147 | 148 | /* User_heap_stack section, used to check that there is enough RAM left */ 149 | ._user_heap_stack : 150 | { 151 | . = ALIGN(4); 152 | PROVIDE ( end = . ); 153 | PROVIDE ( _end = . ); 154 | . = . + _Min_Heap_Size; 155 | . = . + _Min_Stack_Size; 156 | . = ALIGN(4); 157 | } >RAM 158 | 159 | /* MEMORY_bank1 section, code must be located here explicitly */ 160 | /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */ 161 | .memory_b1_text : 162 | { 163 | *(.mb1text) /* .mb1text sections (code) */ 164 | *(.mb1text*) /* .mb1text* sections (code) */ 165 | *(.mb1rodata) /* read-only data (constants) */ 166 | *(.mb1rodata*) 167 | } >MEMORY_B1 168 | 169 | /* Remove information from the standard libraries */ 170 | /DISCARD/ : 171 | { 172 | libc.a ( * ) 173 | libm.a ( * ) 174 | libgcc.a ( * ) 175 | } 176 | 177 | .ARM.attributes 0 : { *(.ARM.attributes) } 178 | } 179 | -------------------------------------------------------------------------------- /inc/settings.h: -------------------------------------------------------------------------------- 1 | /* 2 | settings.h - eeprom configuration handling 3 | Part of Grbl 4 | 5 | Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC 6 | Copyright (c) 2009-2011 Simen Svale Skogsrud 7 | 8 | Grbl is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | Grbl is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with Grbl. If not, see . 20 | */ 21 | 22 | #ifndef settings_h 23 | #define settings_h 24 | 25 | #include "grbl.h" 26 | 27 | 28 | // Version of the EEPROM data. Will be used to migrate existing data from older versions of Grbl 29 | // when firmware is upgraded. Always stored in byte 0 of eeprom 30 | #define SETTINGS_VERSION 10 // NOTE: Check settings_reset() when moving to next version. 31 | 32 | // Define bit flag masks for the boolean settings in settings.flag. 33 | #define BITFLAG_REPORT_INCHES bit(0) 34 | #define BITFLAG_LASER_MODE bit(1) 35 | #define BITFLAG_INVERT_ST_ENABLE bit(2) 36 | #define BITFLAG_HARD_LIMIT_ENABLE bit(3) 37 | #define BITFLAG_HOMING_ENABLE bit(4) 38 | #define BITFLAG_SOFT_LIMIT_ENABLE bit(5) 39 | #define BITFLAG_INVERT_LIMIT_PINS bit(6) 40 | #define BITFLAG_INVERT_PROBE_PIN bit(7) 41 | 42 | //Define bit flag masks for the boolean settings in settings.flag. 43 | #define BITFLAG_FAULT_PIN bit(8) 44 | 45 | // Define status reporting boolean enable bit flags in settings.status_report_mask 46 | #define BITFLAG_RT_STATUS_POSITION_TYPE bit(0) 47 | #define BITFLAG_RT_STATUS_BUFFER_STATE bit(1) 48 | 49 | // Define settings restore bitflags. 50 | #define SETTINGS_RESTORE_DEFAULTS bit(0) 51 | #define SETTINGS_RESTORE_PARAMETERS bit(1) 52 | #define SETTINGS_RESTORE_STARTUP_LINES bit(2) 53 | #define SETTINGS_RESTORE_BUILD_INFO bit(3) 54 | #ifndef SETTINGS_RESTORE_ALL 55 | #define SETTINGS_RESTORE_ALL 0xFF // All bitflags 56 | #endif 57 | 58 | // Define EEPROM memory address location values for Grbl settings and parameters 59 | // NOTE: The Atmega328p has 1KB EEPROM. The upper half is reserved for parameters and 60 | // the startup script. The lower half contains the global settings and space for future 61 | // developments. 62 | #define EEPROM_ADDR_GLOBAL 1U 63 | #define EEPROM_ADDR_PARAMETERS 512U 64 | #define EEPROM_ADDR_STARTUP_BLOCK 768U 65 | #define EEPROM_ADDR_BUILD_INFO 942U 66 | #define EEPROM_ADDR_DATA 1000U 67 | 68 | // Define EEPROM address indexing for coordinate parameters 69 | #define N_COORDINATE_SYSTEM 6 // Number of supported work coordinate systems (from index 1) 70 | #define SETTING_INDEX_NCOORD N_COORDINATE_SYSTEM+1 // Total number of system stored (from index 0) 71 | // NOTE: Work coordinate indices are (0=G54, 1=G55, ... , 6=G59) 72 | #define SETTING_INDEX_G28 N_COORDINATE_SYSTEM // Home position 1 73 | #define SETTING_INDEX_G30 N_COORDINATE_SYSTEM+1 // Home position 2 74 | // #define SETTING_INDEX_G92 N_COORDINATE_SYSTEM+2 // Coordinate offset (G92.2,G92.3 not supported) 75 | 76 | // Define Grbl axis settings numbering scheme. Starts at START_VAL, every INCREMENT, over N_SETTINGS. 77 | #define AXIS_N_SETTINGS 5 // was 3 Paul 15/08/2018 78 | #define AXIS_SETTINGS_START_VAL 100 // NOTE: Reserving settings values >= 100 for axis settings. Up to 255. 79 | #define AXIS_SETTINGS_INCREMENT 10 // Must be greater than the number of axis settings 80 | 81 | // Global persistent settings (Stored from byte EEPROM_ADDR_GLOBAL onwards) 82 | typedef struct { 83 | // Axis settings 84 | float steps_per_mm[N_AXIS]; 85 | float max_rate[N_AXIS]; 86 | float acceleration[N_AXIS]; 87 | float max_travel[N_AXIS]; 88 | 89 | // Remaining Grbl settings 90 | uint8_t pulse_microseconds; 91 | uint8_t step_invert_mask; 92 | uint16_t dir_invert_mask; // Paul, adjusted 93 | uint8_t stepper_idle_lock_time; // If max value 255, steppers do not disable. 94 | uint8_t status_report_mask; // Mask to indicate desired report data. 95 | float junction_deviation; 96 | float arc_tolerance; 97 | 98 | float rpm_max; 99 | float rpm_min; 100 | uint8_t soft_start; // Contains default boolean setting for soft start spindle 101 | // uint8_t flags; // Contains default boolean settings 102 | uint16_t flags; 103 | 104 | uint8_t homing_dir_mask; 105 | float homing_feed_rate; 106 | float homing_seek_rate; 107 | uint16_t homing_debounce_delay; 108 | float homing_pulloff; 109 | // 110 | uint8_t pwm_mode; // added eeprom value for the pwm mode 111 | uint8_t m6_ff; // added eeprom value for the tool changer pulse time 112 | uint32_t tool_delay; // added eeprom value for the tool changer pulse time 113 | uint32_t m6_delay; // added eeprom value for the tool valve duration time 114 | // soft start variables 115 | uint8_t n_pieces; 116 | float rpm_max_s; 117 | float rpm_min_s; 118 | float rpm_point; 119 | float rpm_point23; 120 | float rpm_point34; 121 | float rpm_line_a1; 122 | float rpm_line_b1; 123 | float rpm_line_a2; 124 | float rpm_line_b2; 125 | float rpm_line_a3; 126 | float rpm_line_b3; 127 | float rpm_line_a4; 128 | float rpm_line_b4; 129 | } settings_t; 130 | extern settings_t settings; 131 | 132 | // Initialize the configuration subsystem (load settings from EEPROM) 133 | void settings_init(); 134 | 135 | // Helper function to clear and restore EEPROM defaults 136 | void settings_restore(uint8_t restore_flag); 137 | 138 | // A helper method to set new settings from command line 139 | uint8_t settings_store_global_setting(uint8_t parameter, float value); 140 | 141 | // Stores the protocol line variable as a startup line in EEPROM 142 | void settings_store_startup_line(uint8_t n, char *line); 143 | 144 | // Reads an EEPROM startup line to the protocol line variable 145 | uint8_t settings_read_startup_line(uint8_t n, char *line); 146 | 147 | // Stores build info user-defined string 148 | void settings_store_build_info(char *line); 149 | 150 | // Reads build info user-defined string 151 | uint8_t settings_read_build_info(char *line); 152 | 153 | // Writes selected coordinate data to EEPROM 154 | void settings_write_coord_data(uint8_t coord_select, float *coord_data); 155 | 156 | // Reads selected coordinate data from EEPROM 157 | uint8_t settings_read_coord_data(uint8_t coord_select, float *coord_data); 158 | 159 | #endif 160 | 161 | -------------------------------------------------------------------------------- /stm_usb_fs_lib/src/usb_int.c: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ******************** 2 | * File Name : usb_int.c 3 | * Author : MCD Application Team 4 | * Version : V3.2.1 5 | * Date : 07/05/2010 6 | * Description : Endpoint CTR (Low and High) interrupt's service routines 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | #ifndef STM32F10X_CL 16 | 17 | /* Includes ------------------------------------------------------------------*/ 18 | #include "usb_lib.h" 19 | 20 | /* Private typedef -----------------------------------------------------------*/ 21 | /* Private define ------------------------------------------------------------*/ 22 | /* Private macro -------------------------------------------------------------*/ 23 | /* Private variables ---------------------------------------------------------*/ 24 | __IO uint16_t SaveRState; 25 | __IO uint16_t SaveTState; 26 | 27 | /* Extern variables ----------------------------------------------------------*/ 28 | extern void (*pEpInt_IN[7])(void); /* Handles IN interrupts */ 29 | extern void (*pEpInt_OUT[7])(void); /* Handles OUT interrupts */ 30 | 31 | /* Private function prototypes -----------------------------------------------*/ 32 | /* Private functions ---------------------------------------------------------*/ 33 | 34 | /******************************************************************************* 35 | * Function Name : CTR_LP. 36 | * Description : Low priority Endpoint Correct Transfer interrupt's service 37 | * routine. 38 | * Input : None. 39 | * Output : None. 40 | * Return : None. 41 | *******************************************************************************/ 42 | void CTR_LP(void) 43 | { 44 | __IO uint16_t wEPVal = 0; 45 | /* stay in loop while pending ints */ 46 | while (((wIstr = _GetISTR()) & ISTR_CTR) != 0) 47 | { 48 | /* extract highest priority endpoint number */ 49 | EPindex = (uint8_t)(wIstr & ISTR_EP_ID); 50 | if (EPindex == 0) 51 | { 52 | /* Decode and service control endpoint interrupt */ 53 | /* calling related service routine */ 54 | /* (Setup0_Process, In0_Process, Out0_Process) */ 55 | 56 | /* save RX & TX status */ 57 | /* and set both to NAK */ 58 | 59 | 60 | SaveRState = _GetENDPOINT(ENDP0); 61 | SaveTState = SaveRState & EPTX_STAT; 62 | SaveRState &= EPRX_STAT; 63 | 64 | _SetEPRxTxStatus(ENDP0,EP_RX_NAK,EP_TX_NAK); 65 | 66 | /* DIR bit = origin of the interrupt */ 67 | 68 | if ((wIstr & ISTR_DIR) == 0) 69 | { 70 | /* DIR = 0 */ 71 | 72 | /* DIR = 0 => IN int */ 73 | /* DIR = 0 implies that (EP_CTR_TX = 1) always */ 74 | 75 | 76 | _ClearEP_CTR_TX(ENDP0); 77 | In0_Process(); 78 | 79 | /* before terminate set Tx & Rx status */ 80 | 81 | _SetEPRxTxStatus(ENDP0,SaveRState,SaveTState); 82 | return; 83 | } 84 | else 85 | { 86 | /* DIR = 1 */ 87 | 88 | /* DIR = 1 & CTR_RX => SETUP or OUT int */ 89 | /* DIR = 1 & (CTR_TX | CTR_RX) => 2 int pending */ 90 | 91 | wEPVal = _GetENDPOINT(ENDP0); 92 | 93 | if ((wEPVal &EP_SETUP) != 0) 94 | { 95 | _ClearEP_CTR_RX(ENDP0); /* SETUP bit kept frozen while CTR_RX = 1 */ 96 | Setup0_Process(); 97 | /* before terminate set Tx & Rx status */ 98 | 99 | _SetEPRxTxStatus(ENDP0,SaveRState,SaveTState); 100 | return; 101 | } 102 | 103 | else if ((wEPVal & EP_CTR_RX) != 0) 104 | { 105 | _ClearEP_CTR_RX(ENDP0); 106 | Out0_Process(); 107 | /* before terminate set Tx & Rx status */ 108 | 109 | _SetEPRxTxStatus(ENDP0,SaveRState,SaveTState); 110 | return; 111 | } 112 | } 113 | }/* if(EPindex == 0) */ 114 | else 115 | { 116 | /* Decode and service non control endpoints interrupt */ 117 | 118 | /* process related endpoint register */ 119 | wEPVal = _GetENDPOINT(EPindex); 120 | if ((wEPVal & EP_CTR_RX) != 0) 121 | { 122 | /* clear int flag */ 123 | _ClearEP_CTR_RX(EPindex); 124 | 125 | /* call OUT service function */ 126 | (*pEpInt_OUT[EPindex-1])(); 127 | 128 | } /* if((wEPVal & EP_CTR_RX) */ 129 | 130 | if ((wEPVal & EP_CTR_TX) != 0) 131 | { 132 | /* clear int flag */ 133 | _ClearEP_CTR_TX(EPindex); 134 | 135 | /* call IN service function */ 136 | (*pEpInt_IN[EPindex-1])(); 137 | } /* if((wEPVal & EP_CTR_TX) != 0) */ 138 | 139 | }/* if(EPindex == 0) else */ 140 | 141 | }/* while(...) */ 142 | } 143 | 144 | /******************************************************************************* 145 | * Function Name : CTR_HP. 146 | * Description : High Priority Endpoint Correct Transfer interrupt's service 147 | * routine. 148 | * Input : None. 149 | * Output : None. 150 | * Return : None. 151 | *******************************************************************************/ 152 | void CTR_HP(void) 153 | { 154 | uint32_t wEPVal = 0; 155 | 156 | while (((wIstr = _GetISTR()) & ISTR_CTR) != 0) 157 | { 158 | _SetISTR((uint16_t)CLR_CTR); /* clear CTR flag */ 159 | /* extract highest priority endpoint number */ 160 | EPindex = (uint8_t)(wIstr & ISTR_EP_ID); 161 | /* process related endpoint register */ 162 | wEPVal = _GetENDPOINT(EPindex); 163 | if ((wEPVal & EP_CTR_RX) != 0) 164 | { 165 | /* clear int flag */ 166 | _ClearEP_CTR_RX(EPindex); 167 | 168 | /* call OUT service function */ 169 | (*pEpInt_OUT[EPindex-1])(); 170 | 171 | } /* if((wEPVal & EP_CTR_RX) */ 172 | else if ((wEPVal & EP_CTR_TX) != 0) 173 | { 174 | /* clear int flag */ 175 | _ClearEP_CTR_TX(EPindex); 176 | 177 | /* call IN service function */ 178 | (*pEpInt_IN[EPindex-1])(); 179 | 180 | 181 | } /* if((wEPVal & EP_CTR_TX) != 0) */ 182 | 183 | }/* while(...) */ 184 | } 185 | 186 | #endif /* STM32F10X_CL */ 187 | 188 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ 189 | --------------------------------------------------------------------------------