├── .cproject
├── .custom.cfg
├── .gitattributes
├── .project
├── .settings
└── language.settings.xml
├── CMSIS
├── core
│ ├── arm_common_tables.h
│ ├── arm_const_structs.h
│ ├── arm_math.h
│ ├── core_cm0.h
│ ├── core_cm0plus.h
│ ├── core_cm3.h
│ ├── core_cm4.h
│ ├── core_cm7.h
│ ├── core_cmFunc.h
│ ├── core_cmInstr.h
│ ├── core_cmSimd.h
│ ├── core_sc000.h
│ └── core_sc300.h
└── device
│ ├── stm32f4xx.h
│ └── system_stm32f4xx.h
├── Debug
├── .gitignore
├── grbl_stm32.bin
├── grbl_stm32.elf
└── output.map
├── LinkerScript.ld
├── README.md
├── StdPeriph_Driver
├── Release_Notes.html
├── inc
│ ├── misc.h
│ ├── stm32f4xx_adc.h
│ ├── stm32f4xx_can.h
│ ├── stm32f4xx_cec.h
│ ├── stm32f4xx_conf.h
│ ├── stm32f4xx_crc.h
│ ├── stm32f4xx_cryp.h
│ ├── stm32f4xx_dac.h
│ ├── stm32f4xx_dbgmcu.h
│ ├── stm32f4xx_dcmi.h
│ ├── stm32f4xx_dma.h
│ ├── stm32f4xx_dma2d.h
│ ├── stm32f4xx_exti.h
│ ├── stm32f4xx_flash.h
│ ├── stm32f4xx_flash_ramfunc.h
│ ├── stm32f4xx_gpio.h
│ ├── stm32f4xx_hash.h
│ ├── stm32f4xx_i2c.h
│ ├── stm32f4xx_iwdg.h
│ ├── stm32f4xx_ltdc.h
│ ├── stm32f4xx_pwr.h
│ ├── stm32f4xx_qspi.h
│ ├── stm32f4xx_rcc.h
│ ├── stm32f4xx_rng.h
│ ├── stm32f4xx_rtc.h
│ ├── stm32f4xx_sai.h
│ ├── stm32f4xx_sdio.h
│ ├── stm32f4xx_spdifrx.h
│ ├── stm32f4xx_spi.h
│ ├── stm32f4xx_syscfg.h
│ ├── stm32f4xx_tim.h
│ ├── stm32f4xx_usart.h
│ └── stm32f4xx_wwdg.h
└── src
│ ├── misc.c
│ ├── stm32f4xx_adc.c
│ ├── stm32f4xx_can.c
│ ├── stm32f4xx_crc.c
│ ├── stm32f4xx_cryp.c
│ ├── stm32f4xx_cryp_aes.c
│ ├── stm32f4xx_cryp_des.c
│ ├── stm32f4xx_cryp_tdes.c
│ ├── stm32f4xx_dac.c
│ ├── stm32f4xx_dbgmcu.c
│ ├── stm32f4xx_dcmi.c
│ ├── stm32f4xx_dma.c
│ ├── stm32f4xx_dma2d.c
│ ├── stm32f4xx_exti.c
│ ├── stm32f4xx_flash.c
│ ├── stm32f4xx_flash_ramfunc.c
│ ├── stm32f4xx_gpio.c
│ ├── stm32f4xx_hash.c
│ ├── stm32f4xx_hash_md5.c
│ ├── stm32f4xx_hash_sha1.c
│ ├── stm32f4xx_i2c.c
│ ├── stm32f4xx_iwdg.c
│ ├── stm32f4xx_ltdc.c
│ ├── stm32f4xx_pwr.c
│ ├── stm32f4xx_rcc.c
│ ├── stm32f4xx_rng.c
│ ├── stm32f4xx_rtc.c
│ ├── stm32f4xx_sai.c
│ ├── stm32f4xx_sdio.c
│ ├── stm32f4xx_spi.c
│ ├── stm32f4xx_syscfg.c
│ ├── stm32f4xx_tim.c
│ ├── stm32f4xx_usart.c
│ └── stm32f4xx_wwdg.c
├── inc
└── stm32f4xx_it.h
├── src
├── avr
│ ├── eeprom.c
│ ├── interrupt.h
│ ├── io.c
│ ├── io.h
│ └── pgmspace.h
├── grbl
│ ├── config.h
│ ├── coolant_control.c
│ ├── coolant_control.h
│ ├── cpu_map.h
│ ├── cpu_map
│ │ ├── cpu_map_atmega2560.h
│ │ ├── cpu_map_atmega328p.h
│ │ └── cpu_map_stm32f411_nucleos.h
│ ├── defaults.h
│ ├── defaults
│ │ ├── defaults_generic.h
│ │ ├── defaults_llc.h
│ │ ├── defaults_oxcnc.h
│ │ ├── defaults_shapeoko.h
│ │ ├── defaults_shapeoko2.h
│ │ ├── defaults_shapeoko3.h
│ │ ├── defaults_sherline.h
│ │ ├── defaults_simulator.h
│ │ ├── defaults_x_carve_1000mm.h
│ │ ├── defaults_x_carve_500mm.h
│ │ └── defaults_zen_toolworks_7x7.h
│ ├── eeprom.c
│ ├── eeprom.h
│ ├── examples
│ │ └── grblUpload
│ │ │ ├── grblUpload.ino
│ │ │ └── license.txt
│ ├── gcode.c
│ ├── gcode.h
│ ├── grbl.h
│ ├── limits.c
│ ├── limits.h
│ ├── main.c
│ ├── motion_control.c
│ ├── motion_control.h
│ ├── nuts_bolts.c
│ ├── nuts_bolts.h
│ ├── planner.c
│ ├── planner.h
│ ├── print.c
│ ├── print.h
│ ├── probe.c
│ ├── probe.h
│ ├── protocol.c
│ ├── protocol.h
│ ├── report.c
│ ├── report.h
│ ├── serial.c
│ ├── serial.h
│ ├── settings.c
│ ├── settings.h
│ ├── spindle_control.c
│ ├── spindle_control.h
│ ├── stepper.c
│ ├── stepper.h
│ ├── system.c
│ └── system.h
├── syscalls.c
├── system_stm32f4xx.c
└── util
│ ├── delay.c
│ ├── delay.h
│ └── floatunsisf.c
└── startup
└── startup_stm32f411xe.s
/.custom.cfg:
--------------------------------------------------------------------------------
1 | # This is an .custom board with a single STM32F411RETx chip.
2 | # Generated by System Workbench for STM32
3 |
4 | source [find interface/stlink-v2-1.cfg]
5 |
6 | set WORKAREASIZE 0x20000
7 | transport select "hla_swd"
8 |
9 |
10 | source [find target/stm32f4x_stlink.cfg]
11 |
12 | # use hardware reset, connect under reset
13 | reset_config srst_only srst_nogate
14 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | grbl_stm32
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
25 | fr.ac6.mcu.ide.core.MCUProjectNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/.settings/language.settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/CMSIS/core/arm_common_tables.h:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------
2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved.
3 | *
4 | * $Date: 31. July 2014
5 | * $Revision: V1.4.4
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 | * Redistribution and use in source and binary forms, with or without
15 | * modification, are permitted provided that the following conditions
16 | * are met:
17 | * - Redistributions of source code must retain the above copyright
18 | * notice, this list of conditions and the following disclaimer.
19 | * - Redistributions in binary form must reproduce the above copyright
20 | * notice, this list of conditions and the following disclaimer in
21 | * the documentation and/or other materials provided with the
22 | * distribution.
23 | * - Neither the name of ARM LIMITED nor the names of its contributors
24 | * may be used to endorse or promote products derived from this
25 | * software without specific prior written permission.
26 | *
27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 | * POSSIBILITY OF SUCH DAMAGE.
39 | * -------------------------------------------------------------------- */
40 |
41 | #ifndef _ARM_COMMON_TABLES_H
42 | #define _ARM_COMMON_TABLES_H
43 |
44 | #include "arm_math.h"
45 |
46 | extern const uint16_t armBitRevTable[1024];
47 | extern const q15_t armRecipTableQ15[64];
48 | extern const q31_t armRecipTableQ31[64];
49 | //extern const q31_t realCoefAQ31[1024];
50 | //extern const q31_t realCoefBQ31[1024];
51 | extern const float32_t twiddleCoef_16[32];
52 | extern const float32_t twiddleCoef_32[64];
53 | extern const float32_t twiddleCoef_64[128];
54 | extern const float32_t twiddleCoef_128[256];
55 | extern const float32_t twiddleCoef_256[512];
56 | extern const float32_t twiddleCoef_512[1024];
57 | extern const float32_t twiddleCoef_1024[2048];
58 | extern const float32_t twiddleCoef_2048[4096];
59 | extern const float32_t twiddleCoef_4096[8192];
60 | #define twiddleCoef twiddleCoef_4096
61 | extern const q31_t twiddleCoef_16_q31[24];
62 | extern const q31_t twiddleCoef_32_q31[48];
63 | extern const q31_t twiddleCoef_64_q31[96];
64 | extern const q31_t twiddleCoef_128_q31[192];
65 | extern const q31_t twiddleCoef_256_q31[384];
66 | extern const q31_t twiddleCoef_512_q31[768];
67 | extern const q31_t twiddleCoef_1024_q31[1536];
68 | extern const q31_t twiddleCoef_2048_q31[3072];
69 | extern const q31_t twiddleCoef_4096_q31[6144];
70 | extern const q15_t twiddleCoef_16_q15[24];
71 | extern const q15_t twiddleCoef_32_q15[48];
72 | extern const q15_t twiddleCoef_64_q15[96];
73 | extern const q15_t twiddleCoef_128_q15[192];
74 | extern const q15_t twiddleCoef_256_q15[384];
75 | extern const q15_t twiddleCoef_512_q15[768];
76 | extern const q15_t twiddleCoef_1024_q15[1536];
77 | extern const q15_t twiddleCoef_2048_q15[3072];
78 | extern const q15_t twiddleCoef_4096_q15[6144];
79 | extern const float32_t twiddleCoef_rfft_32[32];
80 | extern const float32_t twiddleCoef_rfft_64[64];
81 | extern const float32_t twiddleCoef_rfft_128[128];
82 | extern const float32_t twiddleCoef_rfft_256[256];
83 | extern const float32_t twiddleCoef_rfft_512[512];
84 | extern const float32_t twiddleCoef_rfft_1024[1024];
85 | extern const float32_t twiddleCoef_rfft_2048[2048];
86 | extern const float32_t twiddleCoef_rfft_4096[4096];
87 |
88 |
89 | /* floating-point bit reversal tables */
90 | #define ARMBITREVINDEXTABLE__16_TABLE_LENGTH ((uint16_t)20 )
91 | #define ARMBITREVINDEXTABLE__32_TABLE_LENGTH ((uint16_t)48 )
92 | #define ARMBITREVINDEXTABLE__64_TABLE_LENGTH ((uint16_t)56 )
93 | #define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208 )
94 | #define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440 )
95 | #define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448 )
96 | #define ARMBITREVINDEXTABLE1024_TABLE_LENGTH ((uint16_t)1800)
97 | #define ARMBITREVINDEXTABLE2048_TABLE_LENGTH ((uint16_t)3808)
98 | #define ARMBITREVINDEXTABLE4096_TABLE_LENGTH ((uint16_t)4032)
99 |
100 | extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE__16_TABLE_LENGTH];
101 | extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE__32_TABLE_LENGTH];
102 | extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE__64_TABLE_LENGTH];
103 | extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH];
104 | extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH];
105 | extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH];
106 | extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE1024_TABLE_LENGTH];
107 | extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE2048_TABLE_LENGTH];
108 | extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE4096_TABLE_LENGTH];
109 |
110 | /* fixed-point bit reversal tables */
111 | #define ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH ((uint16_t)12 )
112 | #define ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH ((uint16_t)24 )
113 | #define ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH ((uint16_t)56 )
114 | #define ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH ((uint16_t)112 )
115 | #define ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH ((uint16_t)240 )
116 | #define ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH ((uint16_t)480 )
117 | #define ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH ((uint16_t)992 )
118 | #define ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH ((uint16_t)1984)
119 | #define ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH ((uint16_t)4032)
120 |
121 | extern const uint16_t armBitRevIndexTable_fixed_16[ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH];
122 | extern const uint16_t armBitRevIndexTable_fixed_32[ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH];
123 | extern const uint16_t armBitRevIndexTable_fixed_64[ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH];
124 | extern const uint16_t armBitRevIndexTable_fixed_128[ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH];
125 | extern const uint16_t armBitRevIndexTable_fixed_256[ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH];
126 | extern const uint16_t armBitRevIndexTable_fixed_512[ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH];
127 | extern const uint16_t armBitRevIndexTable_fixed_1024[ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH];
128 | extern const uint16_t armBitRevIndexTable_fixed_2048[ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH];
129 | extern const uint16_t armBitRevIndexTable_fixed_4096[ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH];
130 |
131 | /* Tables for Fast Math Sine and Cosine */
132 | extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1];
133 | extern const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1];
134 | extern const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1];
135 |
136 | #endif /* ARM_COMMON_TABLES_H */
137 |
--------------------------------------------------------------------------------
/CMSIS/core/arm_const_structs.h:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------
2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved.
3 | *
4 | * $Date: 31. July 2014
5 | * $Revision: V1.4.4
6 | *
7 | * Project: CMSIS DSP Library
8 | * Title: arm_const_structs.h
9 | *
10 | * Description: This file has constant structs that are initialized for
11 | * user convenience. For example, some can be given as
12 | * arguments to the arm_cfft_f32() function.
13 | *
14 | * Target Processor: Cortex-M4/Cortex-M3
15 | *
16 | * Redistribution and use in source and binary forms, with or without
17 | * modification, are permitted provided that the following conditions
18 | * are met:
19 | * - Redistributions of source code must retain the above copyright
20 | * notice, this list of conditions and the following disclaimer.
21 | * - Redistributions in binary form must reproduce the above copyright
22 | * notice, this list of conditions and the following disclaimer in
23 | * the documentation and/or other materials provided with the
24 | * distribution.
25 | * - Neither the name of ARM LIMITED nor the names of its contributors
26 | * may be used to endorse or promote products derived from this
27 | * software without specific prior written permission.
28 | *
29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
32 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
33 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
34 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
35 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
37 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40 | * POSSIBILITY OF SUCH DAMAGE.
41 | * -------------------------------------------------------------------- */
42 |
43 | #ifndef _ARM_CONST_STRUCTS_H
44 | #define _ARM_CONST_STRUCTS_H
45 |
46 | #include "arm_math.h"
47 | #include "arm_common_tables.h"
48 |
49 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16;
50 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32;
51 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64;
52 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128;
53 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256;
54 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512;
55 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024;
56 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048;
57 | extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096;
58 |
59 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16;
60 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32;
61 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64;
62 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128;
63 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256;
64 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512;
65 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024;
66 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048;
67 | extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096;
68 |
69 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16;
70 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32;
71 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64;
72 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128;
73 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256;
74 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512;
75 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024;
76 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048;
77 | extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096;
78 |
79 | #endif
80 |
--------------------------------------------------------------------------------
/CMSIS/device/stm32f4xx.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IRNAS/grbl_stm32/5739935add750fc07cdeccda526196cb2e193ba8/CMSIS/device/stm32f4xx.h
--------------------------------------------------------------------------------
/CMSIS/device/system_stm32f4xx.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file system_stm32f4xx.h
4 | * @author MCD Application Team
5 | * @version V1.5.0
6 | * @date 06-March-2015
7 | * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | *
© COPYRIGHT 2015 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 stm32f4xx_system
33 | * @{
34 | */
35 |
36 | /**
37 | * @brief Define to prevent recursive inclusion
38 | */
39 | #ifndef __SYSTEM_STM32F4XX_H
40 | #define __SYSTEM_STM32F4XX_H
41 |
42 | #ifdef __cplusplus
43 | extern "C" {
44 | #endif
45 |
46 | /** @addtogroup STM32F4xx_System_Includes
47 | * @{
48 | */
49 |
50 | /**
51 | * @}
52 | */
53 |
54 |
55 | /** @addtogroup STM32F4xx_System_Exported_types
56 | * @{
57 | */
58 |
59 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
60 |
61 |
62 | /**
63 | * @}
64 | */
65 |
66 | /** @addtogroup STM32F4xx_System_Exported_Constants
67 | * @{
68 | */
69 |
70 | /**
71 | * @}
72 | */
73 |
74 | /** @addtogroup STM32F4xx_System_Exported_Macros
75 | * @{
76 | */
77 |
78 | /**
79 | * @}
80 | */
81 |
82 | /** @addtogroup STM32F4xx_System_Exported_Functions
83 | * @{
84 | */
85 |
86 | extern void SystemInit(void);
87 | extern void SystemCoreClockUpdate(void);
88 | /**
89 | * @}
90 | */
91 |
92 | #ifdef __cplusplus
93 | }
94 | #endif
95 |
96 | #endif /*__SYSTEM_STM32F4XX_H */
97 |
98 | /**
99 | * @}
100 | */
101 |
102 | /**
103 | * @}
104 | */
105 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
106 |
--------------------------------------------------------------------------------
/Debug/.gitignore:
--------------------------------------------------------------------------------
1 | /StdPeriph_Driver/
2 | /makefile
3 | /objects.list
4 | /objects.mk
5 | /sources.mk
6 | /src/
7 | /startup/
8 |
--------------------------------------------------------------------------------
/Debug/grbl_stm32.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IRNAS/grbl_stm32/5739935add750fc07cdeccda526196cb2e193ba8/Debug/grbl_stm32.bin
--------------------------------------------------------------------------------
/Debug/grbl_stm32.elf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IRNAS/grbl_stm32/5739935add750fc07cdeccda526196cb2e193ba8/Debug/grbl_stm32.elf
--------------------------------------------------------------------------------
/LinkerScript.ld:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IRNAS/grbl_stm32/5739935add750fc07cdeccda526196cb2e193ba8/LinkerScript.ld
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GRBL for STM32 - NUCLEO
2 |
3 | This repo represents the version of GRBL for [STM32F411RET6][MCU_LINK] MCU. This MCU is located on the [STM NUCLEO][BOARD_LINK] board, picture 1.1. This project can be used with standard GRBL shield like [Arduino CNC Shield][ARDUINO_SHIELD_LINK] or three STM shields [
4 | X-NUCLEO-IHM01A1][STM_SHIELD_LINK], for stepper motors. With minor modifications [COREXY][COREXY_LINK] configuration is also supported.
5 |
6 | ![alt tag][NUCLEO_PICTURE]
7 |
8 | ### Why NUCLEO board?
9 |
10 | Reasons for choosing open Nucleo environment are:
11 | - it is cheaper then Arduino UNO
12 | - better ARM MCU, a possibility for new features
13 | - open SDK and IDE
14 |
15 | ### Documentation
16 | All documentation on this project, how to compile code, and what to change for different hardware setups, can be found on project [Wiki][WIKI_LINK]
17 |
18 | ### Different versions
19 | This project can be used with differente hardware setings. Here are presented several versions with compiled **.elf** files just to download to the Nucleo board.
20 |
21 | ##### 1. NUCLEO STM + 3x ST Stepper drivers
22 | Hardware:
23 | - [NUCLEO-F411RE][BOARD_LINK]
24 | - 3x [X-NUCLEO-IHM01A1][STM_SHIELD_LINK]
25 |
26 | Binary: download here
27 |
28 | ##### 2. NUCLEO STM + GRBL shield
29 | Hardware:
30 | - [NUCLEO-F411RE][BOARD_LINK]
31 | - [Arduino CNC Shield][ARDUINO_SHIELD_LINK]
32 |
33 | Binary: download here
34 |
35 | ##### 3. NUCLEO STM + GRBL shield (COREXY)
36 | Hardware:
37 | - [NUCLEO-F411RE][BOARD_LINK]
38 | - [Arduino CNC Shield][ARDUINO_SHIELD_LINK]
39 | - [PreciseXY][PRECISEXY_LINK]
40 |
41 | Binary: download here
42 |
43 | ### Version
44 | 1.0.0
45 |
46 |
47 |
48 | [//]: # (These are reference links used in the body)
49 |
50 | [BOARD_LINK]:
51 | [MCU_LINK]:
52 | [NUCLEO_PICTURE]:
53 | [ARDUINO_SHIELD_LINK]:
54 | [STM_SHIELD_LINK]:
55 | [COREXY_LINK]:
56 | [PRECISEXY_LINK]:
57 | [WIKI_LINK]:
58 |
59 |
--------------------------------------------------------------------------------
/StdPeriph_Driver/Release_Notes.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IRNAS/grbl_stm32/5739935add750fc07cdeccda526196cb2e193ba8/StdPeriph_Driver/Release_Notes.html
--------------------------------------------------------------------------------
/StdPeriph_Driver/inc/misc.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file misc.h
4 | * @author MCD Application Team
5 | * @version V1.5.1
6 | * @date 22-May-2015
7 | * @brief This file contains all the functions prototypes for the miscellaneous
8 | * firmware library functions (add-on to CMSIS functions).
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * © COPYRIGHT 2015 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 __MISC_H
31 | #define __MISC_H
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /* Includes ------------------------------------------------------------------*/
38 | #include "stm32f4xx.h"
39 |
40 | /** @addtogroup STM32F4xx_StdPeriph_Driver
41 | * @{
42 | */
43 |
44 | /** @addtogroup MISC
45 | * @{
46 | */
47 |
48 | /* Exported types ------------------------------------------------------------*/
49 |
50 | /**
51 | * @brief NVIC Init Structure definition
52 | */
53 |
54 | typedef struct
55 | {
56 | uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled.
57 | This parameter can be an enumerator of @ref IRQn_Type
58 | enumeration (For the complete STM32 Devices IRQ Channels
59 | list, please refer to stm32f4xx.h file) */
60 |
61 | uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel
62 | specified in NVIC_IRQChannel. This parameter can be a value
63 | between 0 and 15 as described in the table @ref MISC_NVIC_Priority_Table
64 | A lower priority value indicates a higher priority */
65 |
66 | uint8_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel specified
67 | in NVIC_IRQChannel. This parameter can be a value
68 | between 0 and 15 as described in the table @ref MISC_NVIC_Priority_Table
69 | A lower priority value indicates a higher priority */
70 |
71 | FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel
72 | will be enabled or disabled.
73 | This parameter can be set either to ENABLE or DISABLE */
74 | } NVIC_InitTypeDef;
75 |
76 | /* Exported constants --------------------------------------------------------*/
77 |
78 | /** @defgroup MISC_Exported_Constants
79 | * @{
80 | */
81 |
82 | /** @defgroup MISC_Vector_Table_Base
83 | * @{
84 | */
85 |
86 | #define NVIC_VectTab_RAM ((uint32_t)0x20000000)
87 | #define NVIC_VectTab_FLASH ((uint32_t)0x08000000)
88 | #define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \
89 | ((VECTTAB) == NVIC_VectTab_FLASH))
90 | /**
91 | * @}
92 | */
93 |
94 | /** @defgroup MISC_System_Low_Power
95 | * @{
96 | */
97 |
98 | #define NVIC_LP_SEVONPEND ((uint8_t)0x10)
99 | #define NVIC_LP_SLEEPDEEP ((uint8_t)0x04)
100 | #define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02)
101 | #define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \
102 | ((LP) == NVIC_LP_SLEEPDEEP) || \
103 | ((LP) == NVIC_LP_SLEEPONEXIT))
104 | /**
105 | * @}
106 | */
107 |
108 | /** @defgroup MISC_Preemption_Priority_Group
109 | * @{
110 | */
111 |
112 | #define NVIC_PriorityGroup_0 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority
113 | 4 bits for subpriority */
114 | #define NVIC_PriorityGroup_1 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority
115 | 3 bits for subpriority */
116 | #define NVIC_PriorityGroup_2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority
117 | 2 bits for subpriority */
118 | #define NVIC_PriorityGroup_3 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority
119 | 1 bits for subpriority */
120 | #define NVIC_PriorityGroup_4 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority
121 | 0 bits for subpriority */
122 |
123 | #define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \
124 | ((GROUP) == NVIC_PriorityGroup_1) || \
125 | ((GROUP) == NVIC_PriorityGroup_2) || \
126 | ((GROUP) == NVIC_PriorityGroup_3) || \
127 | ((GROUP) == NVIC_PriorityGroup_4))
128 |
129 | #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
130 |
131 | #define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10)
132 |
133 | #define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x000FFFFF)
134 |
135 | /**
136 | * @}
137 | */
138 |
139 | /** @defgroup MISC_SysTick_clock_source
140 | * @{
141 | */
142 |
143 | #define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB)
144 | #define SysTick_CLKSource_HCLK ((uint32_t)0x00000004)
145 | #define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \
146 | ((SOURCE) == SysTick_CLKSource_HCLK_Div8))
147 | /**
148 | * @}
149 | */
150 |
151 | /**
152 | * @}
153 | */
154 |
155 | /* Exported macro ------------------------------------------------------------*/
156 | /* Exported functions --------------------------------------------------------*/
157 |
158 | void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup);
159 | void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct);
160 | void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset);
161 | void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState);
162 | void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource);
163 |
164 | #ifdef __cplusplus
165 | }
166 | #endif
167 |
168 | #endif /* __MISC_H */
169 |
170 | /**
171 | * @}
172 | */
173 |
174 | /**
175 | * @}
176 | */
177 |
178 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
179 |
--------------------------------------------------------------------------------
/StdPeriph_Driver/inc/stm32f4xx_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_conf.h
4 | * @author MCD Application Team
5 | * @version V1.5.0
6 | * @date 06-March-2015
7 | * @brief Library configuration file.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2015 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 | /* Define to prevent recursive inclusion -------------------------------------*/
29 | #ifndef __STM32F4xx_CONF_H
30 | #define __STM32F4xx_CONF_H
31 |
32 | /* Includes ------------------------------------------------------------------*/
33 | /* Uncomment the line below to enable peripheral header file inclusion */
34 | #include "stm32f4xx_adc.h"
35 | #include "stm32f4xx_crc.h"
36 | #include "stm32f4xx_dbgmcu.h"
37 | #include "stm32f4xx_dma.h"
38 | #include "stm32f4xx_exti.h"
39 | #include "stm32f4xx_flash.h"
40 | #include "stm32f4xx_gpio.h"
41 | #include "stm32f4xx_i2c.h"
42 | #include "stm32f4xx_iwdg.h"
43 | #include "stm32f4xx_pwr.h"
44 | #include "stm32f4xx_rcc.h"
45 | #include "stm32f4xx_rtc.h"
46 | #include "stm32f4xx_sdio.h"
47 | #include "stm32f4xx_spi.h"
48 | #include "stm32f4xx_syscfg.h"
49 | #include "stm32f4xx_tim.h"
50 | #include "stm32f4xx_usart.h"
51 | #include "stm32f4xx_wwdg.h"
52 | #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
53 |
54 | #if defined (STM32F429_439xx) || defined(STM32F446xx)
55 | #include "stm32f4xx_cryp.h"
56 | #include "stm32f4xx_hash.h"
57 | #include "stm32f4xx_rng.h"
58 | #include "stm32f4xx_can.h"
59 | #include "stm32f4xx_dac.h"
60 | #include "stm32f4xx_dcmi.h"
61 | #include "stm32f4xx_dma2d.h"
62 | #include "stm32f4xx_fmc.h"
63 | #include "stm32f4xx_ltdc.h"
64 | #include "stm32f4xx_sai.h"
65 | #endif /* STM32F429_439xx || STM32F446xx */
66 |
67 | #if defined (STM32F427_437xx)
68 | #include "stm32f4xx_cryp.h"
69 | #include "stm32f4xx_hash.h"
70 | #include "stm32f4xx_rng.h"
71 | #include "stm32f4xx_can.h"
72 | #include "stm32f4xx_dac.h"
73 | #include "stm32f4xx_dcmi.h"
74 | #include "stm32f4xx_dma2d.h"
75 | #include "stm32f4xx_fmc.h"
76 | #include "stm32f4xx_sai.h"
77 | #endif /* STM32F427_437xx */
78 |
79 | #if defined (STM32F40_41xxx)
80 | #include "stm32f4xx_cryp.h"
81 | #include "stm32f4xx_hash.h"
82 | #include "stm32f4xx_rng.h"
83 | #include "stm32f4xx_can.h"
84 | #include "stm32f4xx_dac.h"
85 | #include "stm32f4xx_dcmi.h"
86 | #include "stm32f4xx_fsmc.h"
87 | #endif /* STM32F40_41xxx */
88 |
89 | #if defined (STM32F411xE)
90 | #include "stm32f4xx_flash_ramfunc.h"
91 | #endif /* STM32F411xE */
92 |
93 | #if defined (STM32F446xx)
94 | #include "stm32f4xx_qspi.h"
95 | #include "stm32f4xx_fmpi2c.h"
96 | #include "stm32f4xx_spdifrx.h"
97 | #include "stm32f4xx_cec.h"
98 | #endif /* STM32F446xx */
99 |
100 |
101 | /* Exported types ------------------------------------------------------------*/
102 | /* Exported constants --------------------------------------------------------*/
103 |
104 | /* If an external clock source is used, then the value of the following define
105 | should be set to the value of the external clock source, else, if no external
106 | clock is used, keep this define commented */
107 | /*#define I2S_EXTERNAL_CLOCK_VAL 12288000 */ /* Value of the external clock in Hz */
108 |
109 |
110 | /* Uncomment the line below to expanse the "assert_param" macro in the
111 | Standard Peripheral Library drivers code */
112 | /* #define USE_FULL_ASSERT 1 */
113 |
114 | /* Exported macro ------------------------------------------------------------*/
115 | #ifdef USE_FULL_ASSERT
116 |
117 | /**
118 | * @brief The assert_param macro is used for function's parameters check.
119 | * @param expr: If expr is false, it calls assert_failed function
120 | * which reports the name of the source file and the source
121 | * line number of the call that failed.
122 | * If expr is true, it returns no value.
123 | * @retval None
124 | */
125 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
126 | /* Exported functions ------------------------------------------------------- */
127 | void assert_failed(uint8_t* file, uint32_t line);
128 | #else
129 | #define assert_param(expr) ((void)0)
130 | #endif /* USE_FULL_ASSERT */
131 |
132 | #endif /* __STM32F4xx_CONF_H */
133 |
134 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
135 |
--------------------------------------------------------------------------------
/StdPeriph_Driver/inc/stm32f4xx_crc.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f4xx_crc.h
4 | * @author MCD Application Team
5 | * @version V1.5.1
6 | * @date 22-May-2015
7 | * @brief This file contains all the functions prototypes for the CRC firmware
8 | * library.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * © COPYRIGHT 2015 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 __STM32F4xx_CRC_H
31 | #define __STM32F4xx_CRC_H
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /* Includes ------------------------------------------------------------------*/
38 | #include "stm32f4xx.h"
39 |
40 | /** @addtogroup STM32F4xx_StdPeriph_Driver
41 | * @{
42 | */
43 |
44 | /** @addtogroup CRC
45 | * @{
46 | */
47 |
48 | /* Exported types ------------------------------------------------------------*/
49 | /* Exported constants --------------------------------------------------------*/
50 |
51 | /** @defgroup CRC_Exported_Constants
52 | * @{
53 | */
54 |
55 | /**
56 | * @}
57 | */
58 |
59 | /* Exported macro ------------------------------------------------------------*/
60 | /* Exported functions --------------------------------------------------------*/
61 |
62 | void CRC_ResetDR(void);
63 | uint32_t CRC_CalcCRC(uint32_t Data);
64 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength);
65 | uint32_t CRC_GetCRC(void);
66 | void CRC_SetIDRegister(uint8_t IDValue);
67 | uint8_t CRC_GetIDRegister(void);
68 |
69 | #ifdef __cplusplus
70 | }
71 | #endif
72 |
73 | #endif /* __STM32F4xx_CRC_H */
74 |
75 | /**
76 | * @}
77 | */
78 |
79 | /**
80 | * @}
81 | */
82 |
83 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
84 |
--------------------------------------------------------------------------------
/StdPeriph_Driver/inc/stm32f4xx_dbgmcu.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f4xx_dbgmcu.h
4 | * @author MCD Application Team
5 | * @version V1.5.1
6 | * @date 22-May-2015
7 | * @brief This file contains all the functions prototypes for the DBGMCU firmware library.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2015 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 | /* Define to prevent recursive inclusion -------------------------------------*/
29 | #ifndef __STM32F4xx_DBGMCU_H
30 | #define __STM32F4xx_DBGMCU_H
31 |
32 | #ifdef __cplusplus
33 | extern "C" {
34 | #endif
35 |
36 | /* Includes ------------------------------------------------------------------*/
37 | #include "stm32f4xx.h"
38 |
39 | /** @addtogroup STM32F4xx_StdPeriph_Driver
40 | * @{
41 | */
42 |
43 | /** @addtogroup DBGMCU
44 | * @{
45 | */
46 |
47 | /* Exported types ------------------------------------------------------------*/
48 | /* Exported constants --------------------------------------------------------*/
49 |
50 | /** @defgroup DBGMCU_Exported_Constants
51 | * @{
52 | */
53 | #define DBGMCU_SLEEP ((uint32_t)0x00000001)
54 | #define DBGMCU_STOP ((uint32_t)0x00000002)
55 | #define DBGMCU_STANDBY ((uint32_t)0x00000004)
56 | #define IS_DBGMCU_PERIPH(PERIPH) ((((PERIPH) & 0xFFFFFFF8) == 0x00) && ((PERIPH) != 0x00))
57 |
58 | #define DBGMCU_TIM2_STOP ((uint32_t)0x00000001)
59 | #define DBGMCU_TIM3_STOP ((uint32_t)0x00000002)
60 | #define DBGMCU_TIM4_STOP ((uint32_t)0x00000004)
61 | #define DBGMCU_TIM5_STOP ((uint32_t)0x00000008)
62 | #define DBGMCU_TIM6_STOP ((uint32_t)0x00000010)
63 | #define DBGMCU_TIM7_STOP ((uint32_t)0x00000020)
64 | #define DBGMCU_TIM12_STOP ((uint32_t)0x00000040)
65 | #define DBGMCU_TIM13_STOP ((uint32_t)0x00000080)
66 | #define DBGMCU_TIM14_STOP ((uint32_t)0x00000100)
67 | #define DBGMCU_RTC_STOP ((uint32_t)0x00000400)
68 | #define DBGMCU_WWDG_STOP ((uint32_t)0x00000800)
69 | #define DBGMCU_IWDG_STOP ((uint32_t)0x00001000)
70 | #define DBGMCU_I2C1_SMBUS_TIMEOUT ((uint32_t)0x00200000)
71 | #define DBGMCU_I2C2_SMBUS_TIMEOUT ((uint32_t)0x00400000)
72 | #define DBGMCU_I2C3_SMBUS_TIMEOUT ((uint32_t)0x00800000)
73 | #define DBGMCU_CAN1_STOP ((uint32_t)0x02000000)
74 | #define DBGMCU_CAN2_STOP ((uint32_t)0x04000000)
75 | #define IS_DBGMCU_APB1PERIPH(PERIPH) ((((PERIPH) & 0xF91FE200) == 0x00) && ((PERIPH) != 0x00))
76 |
77 | #define DBGMCU_TIM1_STOP ((uint32_t)0x00000001)
78 | #define DBGMCU_TIM8_STOP ((uint32_t)0x00000002)
79 | #define DBGMCU_TIM9_STOP ((uint32_t)0x00010000)
80 | #define DBGMCU_TIM10_STOP ((uint32_t)0x00020000)
81 | #define DBGMCU_TIM11_STOP ((uint32_t)0x00040000)
82 | #define IS_DBGMCU_APB2PERIPH(PERIPH) ((((PERIPH) & 0xFFF8FFFC) == 0x00) && ((PERIPH) != 0x00))
83 | /**
84 | * @}
85 | */
86 |
87 | /* Exported macro ------------------------------------------------------------*/
88 | /* Exported functions --------------------------------------------------------*/
89 | uint32_t DBGMCU_GetREVID(void);
90 | uint32_t DBGMCU_GetDEVID(void);
91 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState);
92 | void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState);
93 | void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState);
94 |
95 | #ifdef __cplusplus
96 | }
97 | #endif
98 |
99 | #endif /* __STM32F4xx_DBGMCU_H */
100 |
101 | /**
102 | * @}
103 | */
104 |
105 | /**
106 | * @}
107 | */
108 |
109 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
110 |
--------------------------------------------------------------------------------
/StdPeriph_Driver/inc/stm32f4xx_flash_ramfunc.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f4xx_flash_ramfunc.h
4 | * @author MCD Application Team
5 | * @version V1.5.1
6 | * @date 22-May-2015
7 | * @brief Header file of FLASH RAMFUNC driver.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2015 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 |
29 | /* Define to prevent recursive inclusion -------------------------------------*/
30 | #ifndef __STM32F4xx_FLASH_RAMFUNC_H
31 | #define __STM32F4xx_FLASH_RAMFUNC_H
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /* Includes ------------------------------------------------------------------*/
38 | #include "stm32f4xx.h"
39 |
40 | /** @addtogroup STM32F4xx_StdPeriph_Driver
41 | * @{
42 | */
43 |
44 | /** @addtogroup FLASH RAMFUNC
45 | * @{
46 | */
47 |
48 | /* Exported types ------------------------------------------------------------*/
49 | /* Private define ------------------------------------------------------------*/
50 | /**
51 | * @brief __RAM_FUNC definition
52 | */
53 | #if defined ( __CC_ARM )
54 | /* ARM Compiler
55 | ------------
56 | RAM functions are defined using the toolchain options.
57 | Functions that are executed in RAM should reside in a separate source module.
58 | Using the 'Options for File' dialog you can simply change the 'Code / Const'
59 | area of a module to a memory space in physical RAM.
60 | Available memory areas are declared in the 'Target' tab of the 'Options for Target'
61 | dialog.
62 | */
63 | #define __RAM_FUNC void
64 |
65 | #elif defined ( __ICCARM__ )
66 | /* ICCARM Compiler
67 | ---------------
68 | RAM functions are defined using a specific toolchain keyword "__ramfunc".
69 | */
70 | #define __RAM_FUNC __ramfunc void
71 |
72 | #elif defined ( __GNUC__ )
73 | /* GNU Compiler
74 | ------------
75 | RAM functions are defined using a specific toolchain attribute
76 | "__attribute__((section(".RamFunc")))".
77 | */
78 | #define __RAM_FUNC void __attribute__((section(".RamFunc")))
79 |
80 | #endif
81 | /* Exported constants --------------------------------------------------------*/
82 | /* Exported macro ------------------------------------------------------------*/
83 | /* Exported functions --------------------------------------------------------*/
84 | __RAM_FUNC FLASH_FlashInterfaceCmd(FunctionalState NewState);
85 | __RAM_FUNC FLASH_FlashSleepModeCmd(FunctionalState NewState);
86 |
87 |
88 | #ifdef __cplusplus
89 | }
90 | #endif
91 |
92 | #endif /* __STM32F4xx_FLASH_RAMFUNC_H */
93 |
94 | /**
95 | * @}
96 | */
97 |
98 | /**
99 | * @}
100 | */
101 |
102 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
103 |
104 |
--------------------------------------------------------------------------------
/StdPeriph_Driver/inc/stm32f4xx_iwdg.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f4xx_iwdg.h
4 | * @author MCD Application Team
5 | * @version V1.5.1
6 | * @date 22-May-2015
7 | * @brief This file contains all the functions prototypes for the IWDG
8 | * firmware library.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * © COPYRIGHT 2015 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 __STM32F4xx_IWDG_H
31 | #define __STM32F4xx_IWDG_H
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /* Includes ------------------------------------------------------------------*/
38 | #include "stm32f4xx.h"
39 |
40 | /** @addtogroup STM32F4xx_StdPeriph_Driver
41 | * @{
42 | */
43 |
44 | /** @addtogroup IWDG
45 | * @{
46 | */
47 |
48 | /* Exported types ------------------------------------------------------------*/
49 | /* Exported constants --------------------------------------------------------*/
50 |
51 | /** @defgroup IWDG_Exported_Constants
52 | * @{
53 | */
54 |
55 | /** @defgroup IWDG_WriteAccess
56 | * @{
57 | */
58 | #define IWDG_WriteAccess_Enable ((uint16_t)0x5555)
59 | #define IWDG_WriteAccess_Disable ((uint16_t)0x0000)
60 | #define IS_IWDG_WRITE_ACCESS(ACCESS) (((ACCESS) == IWDG_WriteAccess_Enable) || \
61 | ((ACCESS) == IWDG_WriteAccess_Disable))
62 | /**
63 | * @}
64 | */
65 |
66 | /** @defgroup IWDG_prescaler
67 | * @{
68 | */
69 | #define IWDG_Prescaler_4 ((uint8_t)0x00)
70 | #define IWDG_Prescaler_8 ((uint8_t)0x01)
71 | #define IWDG_Prescaler_16 ((uint8_t)0x02)
72 | #define IWDG_Prescaler_32 ((uint8_t)0x03)
73 | #define IWDG_Prescaler_64 ((uint8_t)0x04)
74 | #define IWDG_Prescaler_128 ((uint8_t)0x05)
75 | #define IWDG_Prescaler_256 ((uint8_t)0x06)
76 | #define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_Prescaler_4) || \
77 | ((PRESCALER) == IWDG_Prescaler_8) || \
78 | ((PRESCALER) == IWDG_Prescaler_16) || \
79 | ((PRESCALER) == IWDG_Prescaler_32) || \
80 | ((PRESCALER) == IWDG_Prescaler_64) || \
81 | ((PRESCALER) == IWDG_Prescaler_128)|| \
82 | ((PRESCALER) == IWDG_Prescaler_256))
83 | /**
84 | * @}
85 | */
86 |
87 | /** @defgroup IWDG_Flag
88 | * @{
89 | */
90 | #define IWDG_FLAG_PVU ((uint16_t)0x0001)
91 | #define IWDG_FLAG_RVU ((uint16_t)0x0002)
92 | #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || ((FLAG) == IWDG_FLAG_RVU))
93 | #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF)
94 | /**
95 | * @}
96 | */
97 |
98 | /**
99 | * @}
100 | */
101 |
102 | /* Exported macro ------------------------------------------------------------*/
103 | /* Exported functions --------------------------------------------------------*/
104 |
105 | /* Prescaler and Counter configuration functions ******************************/
106 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess);
107 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler);
108 | void IWDG_SetReload(uint16_t Reload);
109 | void IWDG_ReloadCounter(void);
110 |
111 | /* IWDG activation function ***************************************************/
112 | void IWDG_Enable(void);
113 |
114 | /* Flag management function ***************************************************/
115 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG);
116 |
117 | #ifdef __cplusplus
118 | }
119 | #endif
120 |
121 | #endif /* __STM32F4xx_IWDG_H */
122 |
123 | /**
124 | * @}
125 | */
126 |
127 | /**
128 | * @}
129 | */
130 |
131 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
132 |
--------------------------------------------------------------------------------
/StdPeriph_Driver/inc/stm32f4xx_rng.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f4xx_rng.h
4 | * @author MCD Application Team
5 | * @version V1.5.1
6 | * @date 22-May-2015
7 | * @brief This file contains all the functions prototypes for the Random
8 | * Number Generator(RNG) firmware library.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * © COPYRIGHT 2015 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 __STM32F4xx_RNG_H
31 | #define __STM32F4xx_RNG_H
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /* Includes ------------------------------------------------------------------*/
38 | #include "stm32f4xx.h"
39 |
40 | /** @addtogroup STM32F4xx_StdPeriph_Driver
41 | * @{
42 | */
43 |
44 | /** @addtogroup RNG
45 | * @{
46 | */
47 |
48 | /* Exported types ------------------------------------------------------------*/
49 | /* Exported constants --------------------------------------------------------*/
50 |
51 | /** @defgroup RNG_Exported_Constants
52 | * @{
53 | */
54 |
55 | /** @defgroup RNG_flags_definition
56 | * @{
57 | */
58 | #define RNG_FLAG_DRDY ((uint8_t)0x0001) /*!< Data ready */
59 | #define RNG_FLAG_CECS ((uint8_t)0x0002) /*!< Clock error current status */
60 | #define RNG_FLAG_SECS ((uint8_t)0x0004) /*!< Seed error current status */
61 |
62 | #define IS_RNG_GET_FLAG(RNG_FLAG) (((RNG_FLAG) == RNG_FLAG_DRDY) || \
63 | ((RNG_FLAG) == RNG_FLAG_CECS) || \
64 | ((RNG_FLAG) == RNG_FLAG_SECS))
65 | #define IS_RNG_CLEAR_FLAG(RNG_FLAG) (((RNG_FLAG) == RNG_FLAG_CECS) || \
66 | ((RNG_FLAG) == RNG_FLAG_SECS))
67 | /**
68 | * @}
69 | */
70 |
71 | /** @defgroup RNG_interrupts_definition
72 | * @{
73 | */
74 | #define RNG_IT_CEI ((uint8_t)0x20) /*!< Clock error interrupt */
75 | #define RNG_IT_SEI ((uint8_t)0x40) /*!< Seed error interrupt */
76 |
77 | #define IS_RNG_IT(IT) ((((IT) & (uint8_t)0x9F) == 0x00) && ((IT) != 0x00))
78 | #define IS_RNG_GET_IT(RNG_IT) (((RNG_IT) == RNG_IT_CEI) || ((RNG_IT) == RNG_IT_SEI))
79 | /**
80 | * @}
81 | */
82 |
83 | /**
84 | * @}
85 | */
86 |
87 | /* Exported macro ------------------------------------------------------------*/
88 | /* Exported functions --------------------------------------------------------*/
89 |
90 | /* Function used to set the RNG configuration to the default reset state *****/
91 | void RNG_DeInit(void);
92 |
93 | /* Configuration function *****************************************************/
94 | void RNG_Cmd(FunctionalState NewState);
95 |
96 | /* Get 32 bit Random number function ******************************************/
97 | uint32_t RNG_GetRandomNumber(void);
98 |
99 | /* Interrupts and flags management functions **********************************/
100 | void RNG_ITConfig(FunctionalState NewState);
101 | FlagStatus RNG_GetFlagStatus(uint8_t RNG_FLAG);
102 | void RNG_ClearFlag(uint8_t RNG_FLAG);
103 | ITStatus RNG_GetITStatus(uint8_t RNG_IT);
104 | void RNG_ClearITPendingBit(uint8_t RNG_IT);
105 |
106 | #ifdef __cplusplus
107 | }
108 | #endif
109 |
110 | #endif /*__STM32F4xx_RNG_H */
111 |
112 | /**
113 | * @}
114 | */
115 |
116 | /**
117 | * @}
118 | */
119 |
120 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
121 |
--------------------------------------------------------------------------------
/StdPeriph_Driver/inc/stm32f4xx_wwdg.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f4xx_wwdg.h
4 | * @author MCD Application Team
5 | * @version V1.5.1
6 | * @date 22-May-2015
7 | * @brief This file contains all the functions prototypes for the WWDG firmware
8 | * library.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * © COPYRIGHT 2015 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 __STM32F4xx_WWDG_H
31 | #define __STM32F4xx_WWDG_H
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | /* Includes ------------------------------------------------------------------*/
38 | #include "stm32f4xx.h"
39 |
40 | /** @addtogroup STM32F4xx_StdPeriph_Driver
41 | * @{
42 | */
43 |
44 | /** @addtogroup WWDG
45 | * @{
46 | */
47 |
48 | /* Exported types ------------------------------------------------------------*/
49 | /* Exported constants --------------------------------------------------------*/
50 |
51 | /** @defgroup WWDG_Exported_Constants
52 | * @{
53 | */
54 |
55 | /** @defgroup WWDG_Prescaler
56 | * @{
57 | */
58 |
59 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000)
60 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080)
61 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100)
62 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180)
63 | #define IS_WWDG_PRESCALER(PRESCALER) (((PRESCALER) == WWDG_Prescaler_1) || \
64 | ((PRESCALER) == WWDG_Prescaler_2) || \
65 | ((PRESCALER) == WWDG_Prescaler_4) || \
66 | ((PRESCALER) == WWDG_Prescaler_8))
67 | #define IS_WWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0x7F)
68 | #define IS_WWDG_COUNTER(COUNTER) (((COUNTER) >= 0x40) && ((COUNTER) <= 0x7F))
69 |
70 | /**
71 | * @}
72 | */
73 |
74 | /**
75 | * @}
76 | */
77 |
78 | /* Exported macro ------------------------------------------------------------*/
79 | /* Exported functions --------------------------------------------------------*/
80 |
81 | /* Function used to set the WWDG configuration to the default reset state ****/
82 | void WWDG_DeInit(void);
83 |
84 | /* Prescaler, Refresh window and Counter configuration functions **************/
85 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler);
86 | void WWDG_SetWindowValue(uint8_t WindowValue);
87 | void WWDG_EnableIT(void);
88 | void WWDG_SetCounter(uint8_t Counter);
89 |
90 | /* WWDG activation function ***************************************************/
91 | void WWDG_Enable(uint8_t Counter);
92 |
93 | /* Interrupts and flags management functions **********************************/
94 | FlagStatus WWDG_GetFlagStatus(void);
95 | void WWDG_ClearFlag(void);
96 |
97 | #ifdef __cplusplus
98 | }
99 | #endif
100 |
101 | #endif /* __STM32F4xx_WWDG_H */
102 |
103 | /**
104 | * @}
105 | */
106 |
107 | /**
108 | * @}
109 | */
110 |
111 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
112 |
--------------------------------------------------------------------------------
/StdPeriph_Driver/src/stm32f4xx_crc.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f4xx_crc.c
4 | * @author MCD Application Team
5 | * @version V1.5.1
6 | * @date 22-May-2015
7 | * @brief This file provides all the CRC firmware functions.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2015 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 "stm32f4xx_crc.h"
30 |
31 | /** @addtogroup STM32F4xx_StdPeriph_Driver
32 | * @{
33 | */
34 |
35 | /** @defgroup CRC
36 | * @brief CRC driver modules
37 | * @{
38 | */
39 |
40 | /* Private typedef -----------------------------------------------------------*/
41 | /* Private define ------------------------------------------------------------*/
42 | /* Private macro -------------------------------------------------------------*/
43 | /* Private variables ---------------------------------------------------------*/
44 | /* Private function prototypes -----------------------------------------------*/
45 | /* Private functions ---------------------------------------------------------*/
46 |
47 | /** @defgroup CRC_Private_Functions
48 | * @{
49 | */
50 |
51 | /**
52 | * @brief Resets the CRC Data register (DR).
53 | * @param None
54 | * @retval None
55 | */
56 | void CRC_ResetDR(void)
57 | {
58 | /* Reset CRC generator */
59 | CRC->CR = CRC_CR_RESET;
60 | }
61 |
62 | /**
63 | * @brief Computes the 32-bit CRC of a given data word(32-bit).
64 | * @param Data: data word(32-bit) to compute its CRC
65 | * @retval 32-bit CRC
66 | */
67 | uint32_t CRC_CalcCRC(uint32_t Data)
68 | {
69 | CRC->DR = Data;
70 |
71 | return (CRC->DR);
72 | }
73 |
74 | /**
75 | * @brief Computes the 32-bit CRC of a given buffer of data word(32-bit).
76 | * @param pBuffer: pointer to the buffer containing the data to be computed
77 | * @param BufferLength: length of the buffer to be computed
78 | * @retval 32-bit CRC
79 | */
80 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength)
81 | {
82 | uint32_t index = 0;
83 |
84 | for(index = 0; index < BufferLength; index++)
85 | {
86 | CRC->DR = pBuffer[index];
87 | }
88 | return (CRC->DR);
89 | }
90 |
91 | /**
92 | * @brief Returns the current CRC value.
93 | * @param None
94 | * @retval 32-bit CRC
95 | */
96 | uint32_t CRC_GetCRC(void)
97 | {
98 | return (CRC->DR);
99 | }
100 |
101 | /**
102 | * @brief Stores a 8-bit data in the Independent Data(ID) register.
103 | * @param IDValue: 8-bit value to be stored in the ID register
104 | * @retval None
105 | */
106 | void CRC_SetIDRegister(uint8_t IDValue)
107 | {
108 | CRC->IDR = IDValue;
109 | }
110 |
111 | /**
112 | * @brief Returns the 8-bit data stored in the Independent Data(ID) register
113 | * @param None
114 | * @retval 8-bit value of the ID register
115 | */
116 | uint8_t CRC_GetIDRegister(void)
117 | {
118 | return (CRC->IDR);
119 | }
120 |
121 | /**
122 | * @}
123 | */
124 |
125 | /**
126 | * @}
127 | */
128 |
129 | /**
130 | * @}
131 | */
132 |
133 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
134 |
--------------------------------------------------------------------------------
/StdPeriph_Driver/src/stm32f4xx_dbgmcu.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f4xx_dbgmcu.c
4 | * @author MCD Application Team
5 | * @version V1.5.1
6 | * @date 22-May-2015
7 | * @brief This file provides all the DBGMCU firmware functions.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2015 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 "stm32f4xx_dbgmcu.h"
30 |
31 | /** @addtogroup STM32F4xx_StdPeriph_Driver
32 | * @{
33 | */
34 |
35 | /** @defgroup DBGMCU
36 | * @brief DBGMCU driver modules
37 | * @{
38 | */
39 |
40 | /* Private typedef -----------------------------------------------------------*/
41 | /* Private define ------------------------------------------------------------*/
42 | #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF)
43 |
44 | /* Private macro -------------------------------------------------------------*/
45 | /* Private variables ---------------------------------------------------------*/
46 | /* Private function prototypes -----------------------------------------------*/
47 | /* Private functions ---------------------------------------------------------*/
48 |
49 | /** @defgroup DBGMCU_Private_Functions
50 | * @{
51 | */
52 |
53 | /**
54 | * @brief Returns the device revision identifier.
55 | * @param None
56 | * @retval Device revision identifier
57 | */
58 | uint32_t DBGMCU_GetREVID(void)
59 | {
60 | return(DBGMCU->IDCODE >> 16);
61 | }
62 |
63 | /**
64 | * @brief Returns the device identifier.
65 | * @param None
66 | * @retval Device identifier
67 | */
68 | uint32_t DBGMCU_GetDEVID(void)
69 | {
70 | return(DBGMCU->IDCODE & IDCODE_DEVID_MASK);
71 | }
72 |
73 | /**
74 | * @brief Configures low power mode behavior when the MCU is in Debug mode.
75 | * @param DBGMCU_Periph: specifies the low power mode.
76 | * This parameter can be any combination of the following values:
77 | * @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode
78 | * @arg DBGMCU_STOP: Keep debugger connection during STOP mode
79 | * @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode
80 | * @param NewState: new state of the specified low power mode in Debug mode.
81 | * This parameter can be: ENABLE or DISABLE.
82 | * @retval None
83 | */
84 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState)
85 | {
86 | /* Check the parameters */
87 | assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph));
88 | assert_param(IS_FUNCTIONAL_STATE(NewState));
89 | if (NewState != DISABLE)
90 | {
91 | DBGMCU->CR |= DBGMCU_Periph;
92 | }
93 | else
94 | {
95 | DBGMCU->CR &= ~DBGMCU_Periph;
96 | }
97 | }
98 |
99 | /**
100 | * @brief Configures APB1 peripheral behavior when the MCU is in Debug mode.
101 | * @param DBGMCU_Periph: specifies the APB1 peripheral.
102 | * This parameter can be any combination of the following values:
103 | * @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted
104 | * @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted
105 | * @arg DBGMCU_TIM4_STOP: TIM4 counter stopped when Core is halted
106 | * @arg DBGMCU_TIM5_STOP: TIM5 counter stopped when Core is halted
107 | * @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted
108 | * @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted
109 | * @arg DBGMCU_TIM12_STOP: TIM12 counter stopped when Core is halted
110 | * @arg DBGMCU_TIM13_STOP: TIM13 counter stopped when Core is halted
111 | * @arg DBGMCU_TIM14_STOP: TIM14 counter stopped when Core is halted
112 | * @arg DBGMCU_RTC_STOP: RTC Calendar and Wakeup counter stopped when Core is halted.
113 | * @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted
114 | * @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted
115 | * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is halted
116 | * @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is halted
117 | * @arg DBGMCU_I2C3_SMBUS_TIMEOUT: I2C3 SMBUS timeout mode stopped when Core is halted
118 | * @arg DBGMCU_CAN2_STOP: Debug CAN1 stopped when Core is halted
119 | * @arg DBGMCU_CAN1_STOP: Debug CAN2 stopped when Core is halted
120 | * This parameter can be: ENABLE or DISABLE.
121 | * @retval None
122 | */
123 | void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState)
124 | {
125 | /* Check the parameters */
126 | assert_param(IS_DBGMCU_APB1PERIPH(DBGMCU_Periph));
127 | assert_param(IS_FUNCTIONAL_STATE(NewState));
128 |
129 | if (NewState != DISABLE)
130 | {
131 | DBGMCU->APB1FZ |= DBGMCU_Periph;
132 | }
133 | else
134 | {
135 | DBGMCU->APB1FZ &= ~DBGMCU_Periph;
136 | }
137 | }
138 |
139 | /**
140 | * @brief Configures APB2 peripheral behavior when the MCU is in Debug mode.
141 | * @param DBGMCU_Periph: specifies the APB2 peripheral.
142 | * This parameter can be any combination of the following values:
143 | * @arg DBGMCU_TIM1_STOP: TIM1 counter stopped when Core is halted
144 | * @arg DBGMCU_TIM8_STOP: TIM8 counter stopped when Core is halted
145 | * @arg DBGMCU_TIM9_STOP: TIM9 counter stopped when Core is halted
146 | * @arg DBGMCU_TIM10_STOP: TIM10 counter stopped when Core is halted
147 | * @arg DBGMCU_TIM11_STOP: TIM11 counter stopped when Core is halted
148 | * @param NewState: new state of the specified peripheral in Debug mode.
149 | * This parameter can be: ENABLE or DISABLE.
150 | * @retval None
151 | */
152 | void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState)
153 | {
154 | /* Check the parameters */
155 | assert_param(IS_DBGMCU_APB2PERIPH(DBGMCU_Periph));
156 | assert_param(IS_FUNCTIONAL_STATE(NewState));
157 |
158 | if (NewState != DISABLE)
159 | {
160 | DBGMCU->APB2FZ |= DBGMCU_Periph;
161 | }
162 | else
163 | {
164 | DBGMCU->APB2FZ &= ~DBGMCU_Periph;
165 | }
166 | }
167 |
168 | /**
169 | * @}
170 | */
171 |
172 | /**
173 | * @}
174 | */
175 |
176 | /**
177 | * @}
178 | */
179 |
180 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
181 |
--------------------------------------------------------------------------------
/StdPeriph_Driver/src/stm32f4xx_flash_ramfunc.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f4xx_flash_ramfunc.c
4 | * @author MCD Application Team
5 | * @version V1.5.1
6 | * @date 22-May-2015
7 | * @brief FLASH RAMFUNC module driver.
8 | * This file provides a FLASH firmware functions which should be
9 | * executed from internal SRAM
10 | * + Stop/Start the flash interface while System Run
11 | * + Enable/Disable the flash sleep while System Run
12 | *
13 | @verbatim
14 | ==============================================================================
15 | ##### APIs executed from Internal RAM #####
16 | ==============================================================================
17 | [..]
18 | *** ARM Compiler ***
19 | --------------------
20 | [..] RAM functions are defined using the toolchain options.
21 | Functions that are be executed in RAM should reside in a separate
22 | source module. Using the 'Options for File' dialog you can simply change
23 | the 'Code / Const' area of a module to a memory space in physical RAM.
24 | Available memory areas are declared in the 'Target' tab of the
25 | Options for Target' dialog.
26 |
27 | *** ICCARM Compiler ***
28 | -----------------------
29 | [..] RAM functions are defined using a specific toolchain keyword "__ramfunc".
30 |
31 | *** GNU Compiler ***
32 | --------------------
33 | [..] RAM functions are defined using a specific toolchain attribute
34 | "__attribute__((section(".RamFunc")))".
35 |
36 | @endverbatim
37 | ******************************************************************************
38 | * @attention
39 | *
40 | * © COPYRIGHT 2015 STMicroelectronics
41 | *
42 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
43 | * You may not use this file except in compliance with the License.
44 | * You may obtain a copy of the License at:
45 | *
46 | * http://www.st.com/software_license_agreement_liberty_v2
47 | *
48 | * Unless required by applicable law or agreed to in writing, software
49 | * distributed under the License is distributed on an "AS IS" BASIS,
50 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
51 | * See the License for the specific language governing permissions and
52 | * limitations under the License.
53 | *
54 | ******************************************************************************
55 | */
56 |
57 | /* Includes ------------------------------------------------------------------*/
58 | #include "stm32f4xx_flash_ramfunc.h"
59 |
60 | /** @addtogroup STM32F4xx_StdPeriph_Driver
61 | * @{
62 | */
63 |
64 | /** @defgroup FLASH RAMFUNC
65 | * @brief FLASH RAMFUNC driver modules
66 | * @{
67 | */
68 |
69 | /* Private typedef -----------------------------------------------------------*/
70 | /* Private define ------------------------------------------------------------*/
71 | /* Private macro -------------------------------------------------------------*/
72 | /* Private variables ---------------------------------------------------------*/
73 | /* Private function prototypes -----------------------------------------------*/
74 | /* Private functions ---------------------------------------------------------*/
75 |
76 | /** @defgroup FLASH_RAMFUNC_Private_Functions
77 | * @{
78 | */
79 |
80 | /** @defgroup FLASH_RAMFUNC_Group1 Peripheral features functions executed from internal RAM
81 | * @brief Peripheral Extended features functions
82 | *
83 | @verbatim
84 |
85 | ===============================================================================
86 | ##### ramfunc functions #####
87 | ===============================================================================
88 | [..]
89 | This subsection provides a set of functions that should be executed from RAM
90 | transfers.
91 |
92 | @endverbatim
93 | * @{
94 | */
95 |
96 | /**
97 | * @brief Start/Stop the flash interface while System Run
98 | * @note This mode is only available for STM32F411xx devices.
99 | * @note This mode could n't be set while executing with the flash itself.
100 | * It should be done with specific routine executed from RAM.
101 | * @param NewState: new state of the Smart Card mode.
102 | * This parameter can be: ENABLE or DISABLE.
103 | * @retval None
104 | */
105 | __RAM_FUNC FLASH_FlashInterfaceCmd(FunctionalState NewState)
106 | {
107 | if (NewState != DISABLE)
108 | {
109 | /* Start the flash interface while System Run */
110 | CLEAR_BIT(PWR->CR, PWR_CR_FISSR);
111 | }
112 | else
113 | {
114 | /* Stop the flash interface while System Run */
115 | SET_BIT(PWR->CR, PWR_CR_FISSR);
116 | }
117 | }
118 |
119 | /**
120 | * @brief Enable/Disable the flash sleep while System Run
121 | * @note This mode is only available for STM32F411xx devices.
122 | * @note This mode could n't be set while executing with the flash itself.
123 | * It should be done with specific routine executed from RAM.
124 | * @param NewState: new state of the Smart Card mode.
125 | * This parameter can be: ENABLE or DISABLE.
126 | * @retval None
127 | */
128 | __RAM_FUNC FLASH_FlashSleepModeCmd(FunctionalState NewState)
129 | {
130 | if (NewState != DISABLE)
131 | {
132 | /* Enable the flash sleep while System Run */
133 | SET_BIT(PWR->CR, PWR_CR_FMSSR);
134 | }
135 | else
136 | {
137 | /* Disable the flash sleep while System Run */
138 | CLEAR_BIT(PWR->CR, PWR_CR_FMSSR);
139 | }
140 | }
141 |
142 | /**
143 | * @}
144 | */
145 |
146 | /**
147 | * @}
148 | */
149 |
150 | /**
151 | * @}
152 | */
153 |
154 | /**
155 | * @}
156 | */
157 |
158 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
159 |
--------------------------------------------------------------------------------
/inc/stm32f4xx_it.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_it.h
4 | * @author MCD Application Team
5 | * @version V1.5.0
6 | * @date 06-March-2015
7 | * @brief This file contains the headers of the interrupt handlers.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT 2015 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 | /* Define to prevent recursive inclusion -------------------------------------*/
29 | #ifndef __STM32F4xx_IT_H
30 | #define __STM32F4xx_IT_H
31 |
32 | #ifdef __cplusplus
33 | extern "C" {
34 | #endif
35 |
36 | /* Includes ------------------------------------------------------------------*/
37 | #include "stm32f4xx.h"
38 |
39 | /* Exported types ------------------------------------------------------------*/
40 | /* Exported constants --------------------------------------------------------*/
41 | /* Exported macro ------------------------------------------------------------*/
42 | /* Exported functions ------------------------------------------------------- */
43 |
44 | void NMI_Handler(void);
45 | void HardFault_Handler(void);
46 | void MemManage_Handler(void);
47 | void BusFault_Handler(void);
48 | void UsageFault_Handler(void);
49 | void SVC_Handler(void);
50 | void DebugMon_Handler(void);
51 | void PendSV_Handler(void);
52 | void SysTick_Handler(void);
53 |
54 | #ifdef __cplusplus
55 | }
56 | #endif
57 |
58 | #endif /* __STM32F4xx_IT_H */
59 |
60 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
61 |
--------------------------------------------------------------------------------
/src/avr/eeprom.c:
--------------------------------------------------------------------------------
1 | // This file has been prepared for Doxygen automatic documentation generation.
2 | /*! \file ********************************************************************
3 | *
4 | * Atmel Corporation
5 | *
6 | * \li File: eeprom.c
7 | * \li Compiler: IAR EWAAVR 3.10c
8 | * \li Support mail: avr@atmel.com
9 | *
10 | * \li Supported devices: All devices with split EEPROM erase/write
11 | * capabilities can be used.
12 | * The example is written for ATmega48.
13 | *
14 | * \li AppNote: AVR103 - Using the EEPROM Programming Modes.
15 | *
16 | * \li Description: Example on how to use the split EEPROM erase/write
17 | * capabilities in e.g. ATmega48. All EEPROM
18 | * programming modes are tested, i.e. Erase+Write,
19 | * Erase-only and Write-only.
20 | *
21 | * $Revision: 1.6 $
22 | * $Date: Friday, February 11, 2005 07:16:44 UTC $
23 | ****************************************************************************/
24 | #include
25 | #include
26 | #include "stm32f4xx.h"
27 | #include
28 |
29 | char eeprom[4096];
30 |
31 |
32 | /*! \brief Read byte from EEPROM.
33 | *
34 | * This function reads one byte from a given EEPROM address.
35 | *
36 | * \note The CPU is halted for 4 clock cycles during EEPROM read.
37 | *
38 | * \param addr EEPROM address to read from.
39 | * \return The byte read from the EEPROM address.
40 | */
41 |
42 |
43 | unsigned char eeprom_get_char( unsigned int addr )
44 | {
45 | // do {} while( EECR & (1< 0; size--) {
166 | checksum = (checksum << 1) || (checksum >> 7);
167 | checksum += *source;
168 | eeprom_put_char(destination++, *(source++));
169 | }
170 | eeprom_put_char(destination, checksum);
171 |
172 | eraseflash();
173 |
174 | progflash();
175 |
176 | }
177 |
178 | int memcpy_from_eeprom_with_checksum(char *destination, unsigned int source, unsigned int size) {
179 | unsigned char data, checksum = 0;
180 | for(; size > 0; size--) {
181 | data = eeprom_get_char(source++);
182 | checksum = (checksum << 1) || (checksum >> 7);
183 | checksum += data;
184 | *(destination++) = data;
185 | }
186 | return(checksum == eeprom_get_char(source));
187 | }
188 |
189 | // end of file
190 |
--------------------------------------------------------------------------------
/src/avr/interrupt.h:
--------------------------------------------------------------------------------
1 | /*
2 | interrupt.h - replacement for the avr include of the same name to provide
3 | dummy register variables and macros
4 |
5 | Part of Grbl Simulator
6 |
7 | Copyright (c) 2012-2014 Jens Geisler, Adam Shelly
8 |
9 | Grbl is free software: you can redistribute it and/or modify
10 | it under the terms of the GNU General Public License as published by
11 | the Free Software Foundation, either version 3 of the License, or
12 | (at your option) any later version.
13 |
14 | Grbl is distributed in the hope that it will be useful,
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | GNU General Public License for more details.
18 |
19 | You should have received a copy of the GNU General Public License
20 | along with Grbl. If not, see .
21 | */
22 |
23 | #define sei() __enable_irq()
24 | #define cli() __disable_irq()
25 |
--------------------------------------------------------------------------------
/src/avr/io.c:
--------------------------------------------------------------------------------
1 | /*
2 | io.h - replacement for the avr include of the same name to provide
3 | dummy register variables and macros
4 |
5 | Part of Grbl Simulator
6 |
7 | Copyright (c) 2104 Adam Shelly
8 |
9 | Grbl is free software: you can redistribute it and/or modify
10 | it under the terms of the GNU General Public License as published by
11 | the Free Software Foundation, either version 3 of the License, or
12 | (at your option) any later version.
13 |
14 | Grbl is distributed in the hope that it will be useful,
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | GNU General Public License for more details.
18 |
19 | You should have received a copy of the GNU General Public License
20 | along with Grbl. If not, see .
21 | */
22 |
23 | #include "io.h"
24 |
25 | // dummy register variables
26 | volatile io_sim_t io={{0}};
27 |
--------------------------------------------------------------------------------
/src/avr/io.h:
--------------------------------------------------------------------------------
1 | /*
2 | io.h - replacement for the avr include of the same name to provide
3 | dummy register variables and macros
4 |
5 | Part of Grbl Simulator
6 |
7 | Copyright (c) 2012-2104 Jens Geisler, Adam Shelly
8 |
9 | Grbl is free software: you can redistribute it and/or modify
10 | it under the terms of the GNU General Public License as published by
11 | the Free Software Foundation, either version 3 of the License, or
12 | (at your option) any later version.
13 |
14 | Grbl is distributed in the hope that it will be useful,
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | GNU General Public License for more details.
18 |
19 | You should have received a copy of the GNU General Public License
20 | along with Grbl. If not, see .
21 | */
22 |
23 |
24 | #ifndef io_h
25 | #define io_h
26 |
27 | #include
28 |
29 | union hilo16 {
30 | uint16_t w;
31 | struct {
32 | uint8_t l; //TODO: check that these are right order on x86. Doesn't matter for current usage, but might someday
33 | uint8_t h;
34 | };
35 | };
36 |
37 | enum {
38 | SIM_A, SIM_B, SIM_C, SIM_D, SIM_E,
39 | SIM_F, SIM_G, SIM_H, SIM_J, SIM_K, SIM_L,
40 | SIM_PORT_COUNT
41 | };
42 |
43 | #define SIM_N_TIMERS 3 //328p has 3, Mega has 6
44 |
45 |
46 | // dummy register variables
47 | typedef struct io_sim {
48 | uint8_t ddr[SIM_PORT_COUNT];
49 | uint8_t port[SIM_PORT_COUNT];
50 | uint8_t pin[SIM_PORT_COUNT];
51 | uint8_t timsk[SIM_N_TIMERS];
52 | uint16_t ocra[SIM_N_TIMERS];
53 | uint16_t ocrb[SIM_N_TIMERS];
54 | uint16_t ocrc[SIM_N_TIMERS];
55 | uint16_t tcnt[SIM_N_TIMERS]; //tcint0 is really only 8bit
56 | uint8_t tccra[SIM_N_TIMERS];
57 | uint8_t tccrb[SIM_N_TIMERS];
58 | uint8_t tifr[SIM_N_TIMERS];
59 | uint8_t pcicr;
60 | uint8_t pcmsk[3];
61 | uint8_t ucsr0[3];
62 | uint8_t udr[3];
63 | uint8_t gpior[3];
64 | uint8_t mcusr;
65 | uint8_t wdtcsr;
66 | union hilo16 ubrr0;
67 |
68 | uint16_t prescaler; //continuously running
69 | uint8_t sreg;
70 |
71 | } io_sim_t;
72 | extern volatile io_sim_t io;
73 |
74 |
75 |
76 |
77 | // dummy macros for interrupt related registers
78 | #define PORTA io.port[SIM_A]
79 | #define PORTB io.port[SIM_B]
80 | #define PORTC io.port[SIM_C]
81 | #define PORTD io.port[SIM_D]
82 | #define PORTE io.port[SIM_E]
83 | #define PORTF io.port[SIM_F]
84 | #define PORTG io.port[SIM_G]
85 | #define PORTH io.port[SIM_H]
86 | #define PORTJ io.port[SIM_J]
87 | #define PORTK io.port[SIM_K]
88 | #define PORTL io.port[SIM_L]
89 |
90 | #define DDRA io.ddr[SIM_A]
91 | #define DDRB io.ddr[SIM_B]
92 | #define DDRC io.ddr[SIM_C]
93 | #define DDRD io.ddr[SIM_D]
94 | #define DDRE io.ddr[SIM_E]
95 | #define DDRF io.ddr[SIM_F]
96 | #define DDRG io.ddr[SIM_G]
97 | #define DDRH io.ddr[SIM_H]
98 | #define DDRJ io.ddr[SIM_J]
99 | #define DDRK io.ddr[SIM_K]
100 | #define DDRL io.ddr[SIM_L]
101 |
102 | #define PINA io.pin[SIM_A]
103 | #define PINB io.pin[SIM_B]
104 | #define PINC io.pin[SIM_C]
105 | #define PIND io.pin[SIM_D]
106 | #define PINE io.pin[SIM_E]
107 | #define PINF io.pin[SIM_F]
108 | #define PING io.pin[SIM_G]
109 | #define PINH io.pin[SIM_H]
110 | #define PINJ io.pin[SIM_J]
111 | #define PINK io.pin[SIM_K]
112 | #define PINL io.pin[SIM_L]
113 |
114 |
115 | #define TIMSK0 io.timsk[0]
116 | #define TIMSK1 io.timsk[1]
117 | #define TIMSK2 io.timsk[2]
118 | #define TIMSK3 io.timsk[3]
119 | #define TIMSK4 io.timsk[4]
120 | #define TIMSK5 io.timsk[5]
121 |
122 |
123 | #define SIM_TOV 0
124 | #define SIM_OCA 1
125 | #define SIM_OCB 2
126 | #define SIM_OCC 3
127 | #define SIM_ICI 5
128 | #define SIM_ROLL 7 //stealing reserved TIFR bit
129 |
130 | #define OCIE0A SIM_OCA
131 | #define OCIE0B SIM_OCB
132 | #define TOIE0 SIM_TOV
133 |
134 | #define ICIE1 SIM_ICI
135 | #define OCIE1C SIM_OCC
136 | #define OCIE1B SIM_OCB
137 | #define OCIE1A SIM_OCA
138 | #define TOIE1 SIM_ICI
139 |
140 | #define ICIE2 SIM_ICI
141 | #define OCIE2C SIM_OCC
142 | #define OCIE2B SIM_OCB
143 | #define OCIE2A SIM_OCA
144 | #define TOIE2 SIM_TOV
145 |
146 | #define OCR0A io.ocra[0]
147 | #define OCR1A io.ocra[1]
148 | #define OCR2A io.ocra[2]
149 | //There are more..
150 |
151 |
152 | #define TCNT0 io.tcnt[0]
153 | #define TCNT1 io.tcnt[1]
154 | #define TCNT2 io.tcnt[2]
155 |
156 | #define TCCR0A io.tccra[0]
157 | #define TCCR0B io.tccrb[0]
158 | #define TCCR1A io.tccra[1]
159 | #define TCCR1B io.tccrb[1]
160 | #define TCCR2A io.tccra[2]
161 | #define TCCR2B io.tccrb[2]
162 |
163 | #define CS00 0
164 | #define CS01 1
165 | #define CS12 2
166 | #define CS11 1
167 | #define CS10 0
168 | #define CS21 1
169 |
170 | #define WGM13 4
171 | #define WGM12 3
172 | #define WGM11 1
173 | #define WGM10 0
174 | #define WGM21 1
175 |
176 | #define WGM20 0
177 |
178 | #define COM2A1 7
179 | #define COM2A0 6
180 |
181 | #define COM1A1 7
182 | #define COM1A0 6
183 | #define COM1B1 5
184 | #define COM1B0 4
185 | #define COM1C1 3
186 | #define COM1C0 2
187 |
188 |
189 | #define PCICR io.pcicr
190 | #define PCIE0 0
191 | #define PCIE1 1
192 | #define PCIE2 2
193 |
194 | //serial channel
195 | #define UCSR0A io.ucsr0[SIM_A]
196 | #define UCSR0B io.ucsr0[SIM_B]
197 | #define UDR0 io.udr[0]
198 | #define UDRIE0 0
199 | #define RXCIE0 1
200 | #define RXEN0 2
201 | #define TXEN0 3
202 | #define U2X0 4
203 | #define UBRR0H io.ubrr0.h
204 | #define UBRR0L io.ubrr0.l
205 |
206 | #define PCMSK0 io.pcmsk[0]
207 | #define PCMSK1 io.pcmsk[1]
208 | #define PCMSK2 io.pcmsk[2]
209 |
210 | //GPIO
211 | #define GPIOR0 io.gpior[0]
212 | #define GPIOR1 io.gpior[1]
213 | #define GPIOR2 io.gpior[2]
214 |
215 | //MCU Status
216 | #define MCUSR io.mcusr
217 |
218 | #define PORF 0
219 | #define EXTRF 1
220 | #define BORF 2
221 | #define WDRF 3
222 | #define JTRF 4
223 |
224 | //Interrupt Status
225 | #define SREG io.sreg
226 |
227 |
228 |
229 | #endif
230 |
--------------------------------------------------------------------------------
/src/avr/pgmspace.h:
--------------------------------------------------------------------------------
1 | /*
2 | pgmspace.h - replacement for the avr include of the same name to provide
3 | dummy functions andd macros
4 |
5 | Part of Grbl Simulator
6 |
7 | Copyright (c) 2012 Jens Geisler
8 |
9 | Grbl is free software: you can redistribute it and/or modify
10 | it under the terms of the GNU General Public License as published by
11 | the Free Software Foundation, either version 3 of the License, or
12 | (at your option) any later version.
13 |
14 | Grbl is distributed in the hope that it will be useful,
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | GNU General Public License for more details.
18 |
19 | You should have received a copy of the GNU General Public License
20 | along with Grbl. If not, see .
21 | */
22 |
23 | #ifndef pgmspace_h
24 | #define pgmspace_h
25 |
26 | #define PSTR(s) s
27 |
28 | #define pgm_read_byte_near(s) *s
29 |
30 | #endif
31 |
--------------------------------------------------------------------------------
/src/grbl/coolant_control.c:
--------------------------------------------------------------------------------
1 | /*
2 | coolant_control.c - coolant control methods
3 | Part of Grbl
4 |
5 | Copyright (c) 2012-2015 Sungeun K. Jeon
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 | void coolant_init()
25 | {
26 | // COOLANT_FLOOD_DDR |= (1 << COOLANT_FLOOD_BIT);
27 | // #ifdef ENABLE_M7
28 | // COOLANT_MIST_DDR |= (1 << COOLANT_MIST_BIT);
29 | // #endif
30 |
31 | #ifdef FLOOD_COOLANT
32 | set_as_output(FLOOD_COOLANT);
33 | #endif
34 |
35 | #ifdef ENABLE_M7
36 | set_as_output(MIST_COOLANT);
37 | #endif
38 |
39 | coolant_stop();
40 | }
41 |
42 |
43 | void coolant_stop()
44 | {
45 | // COOLANT_FLOOD_PORT &= ~(1 << COOLANT_FLOOD_BIT);
46 | // #ifdef ENABLE_M7
47 | // COOLANT_MIST_PORT &= ~(1 << COOLANT_MIST_BIT);
48 | // #endif
49 | #ifdef FLOOD_COOLANT
50 | GPIO_ResetBits(FLOOD_COOLANT);
51 | #endif
52 | #ifdef ENABLE_M7
53 | GPIO_ResetBits(MIST_COOLANT);
54 | #endif
55 | }
56 |
57 |
58 | void coolant_set_state(uint8_t mode)
59 | {
60 | if (sys.abort) { return; } // Block during abort.
61 |
62 | // if (mode == COOLANT_FLOOD_ENABLE) {
63 | // COOLANT_FLOOD_PORT |= (1 << COOLANT_FLOOD_BIT);
64 | //
65 | // #ifdef ENABLE_M7
66 | // } else if (mode == COOLANT_MIST_ENABLE) {
67 | // COOLANT_MIST_PORT |= (1 << COOLANT_MIST_BIT);
68 | // #endif
69 | if (mode == COOLANT_FLOOD_ENABLE) {
70 | #ifdef FLOOD_COOLANT
71 | GPIO_SetBits(FLOOD_COOLANT);
72 | #endif
73 | #ifdef ENABLE_M7
74 | } else if (mode == COOLANT_MIST_ENABLE) {
75 | GPIO_SetBits(MIST_COOLANT);
76 | #endif
77 | ;
78 | } else {
79 | coolant_stop();
80 | }
81 | }
82 |
83 |
84 | void coolant_run(uint8_t mode)
85 | {
86 | if (sys.state == STATE_CHECK_MODE) { return; }
87 | protocol_buffer_synchronize(); // Ensure coolant turns on when specified in program.
88 | coolant_set_state(mode);
89 | }
90 |
--------------------------------------------------------------------------------
/src/grbl/coolant_control.h:
--------------------------------------------------------------------------------
1 | /*
2 | coolant_control.h - spindle control methods
3 | Part of Grbl
4 |
5 | Copyright (c) 2012-2015 Sungeun K. Jeon
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 |
25 | void coolant_init();
26 | void coolant_stop();
27 | void coolant_set_state(uint8_t mode);
28 | void coolant_run(uint8_t mode);
29 |
30 | #endif
--------------------------------------------------------------------------------
/src/grbl/cpu_map.h:
--------------------------------------------------------------------------------
1 | /*
2 | cpu_map.h - CPU and pin mapping configuration file
3 | Part of Grbl
4 |
5 | Copyright (c) 2012-2015 Sungeun K. Jeon
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 | /* The cpu_map.h files serve as a central pin mapping selection file for different processor
22 | types, i.e. AVR 328p or AVR Mega 2560. Each processor has its own pin mapping file.
23 | (i.e. cpu_map_atmega328p.h) Grbl officially supports the Arduino Uno, but the
24 | other supplied pin mappings are supplied by users, so your results may vary. */
25 |
26 | // NOTE: With new processors, only add the define name and filename to use.
27 |
28 | #ifndef cpu_map_h
29 | #define cpu_map_h
30 |
31 |
32 | #ifdef CPU_MAP_ATMEGA328P // (Arduino Uno) Officially supported by Grbl.
33 | #include "cpu_map/cpu_map_atmega328p.h"
34 | #endif
35 |
36 | #ifdef CPU_MAP_ATMEGA2560 // (Arduino Mega 2560) Working @EliteEng
37 | #include "cpu_map/cpu_map_atmega2560.h"
38 | #endif
39 |
40 | #ifdef CPU_MAP_STM32F411_NUCLEOS // (Arduino Mega 2560) Working @EliteEng
41 | #include "cpu_map/cpu_map_stm32f411_nucleos.h"
42 | #endif
43 |
44 | /*
45 | #ifdef CPU_MAP_CUSTOM_PROC
46 | // For a custom pin map or different processor, copy and edit one of the available cpu
47 | // map files and modify it to your needs. Make sure the defined name is also changed in
48 | // the config.h file.
49 | #endif
50 | */
51 |
52 | #endif
53 |
--------------------------------------------------------------------------------
/src/grbl/cpu_map/cpu_map_atmega2560.h:
--------------------------------------------------------------------------------
1 | /*
2 | cpu_map_atmega2560.h - CPU and pin mapping configuration file
3 | Part of Grbl
4 |
5 | Copyright (c) 2012-2015 Sungeun K. Jeon
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 | /* This cpu_map file serves as a central pin mapping settings file for AVR Mega 2560 */
22 |
23 |
24 | #ifdef GRBL_PLATFORM
25 | #error "cpu_map already defined: GRBL_PLATFORM=" GRBL_PLATFORM
26 | #endif
27 |
28 |
29 | #define GRBL_PLATFORM "Atmega2560"
30 |
31 | // Serial port pins
32 | #define SERIAL_RX USART0_RX_vect
33 | #define SERIAL_UDRE USART0_UDRE_vect
34 |
35 | // Increase Buffers to make use of extra SRAM
36 | //#define RX_BUFFER_SIZE 256
37 | //#define TX_BUFFER_SIZE 128
38 | //#define BLOCK_BUFFER_SIZE 36
39 | //#define LINE_BUFFER_SIZE 100
40 | //#define SEGMENT_BUFFER_SIZE 10
41 |
42 | // Define step pulse output pins. NOTE: All step bit pins must be on the same port.
43 | #define STEP_DDR DDRA
44 | #define STEP_PORT PORTA
45 | #define STEP_PIN PINA
46 | #define X_STEP_BIT 2 // MEGA2560 Digital Pin 24
47 | #define Y_STEP_BIT 3 // MEGA2560 Digital Pin 25
48 | #define Z_STEP_BIT 4 // MEGA2560 Digital Pin 26
49 | #define STEP_MASK ((1<.
19 | */
20 |
21 | /* Grbl officially supports the Arduino Uno, but the other supplied pin mappings are
22 | supplied by users, so your results may vary. This cpu_map file serves as a central
23 | pin mapping settings file for AVR 328p used on the Arduino Uno. */
24 |
25 | #ifdef GRBL_PLATFORM
26 | #error "cpu_map already defined: GRBL_PLATFORM=" GRBL_PLATFORM
27 | #endif
28 |
29 |
30 | #define GRBL_PLATFORM "Atmega328p"
31 |
32 | // Define serial port pins and interrupt vectors.
33 | #define SERIAL_RX USART_RX_vect
34 | #define SERIAL_UDRE USART_UDRE_vect
35 |
36 | // Define step pulse output pins. NOTE: All step bit pins must be on the same port.
37 | #define STEP_DDR DDRD
38 | #define STEP_PORT PORTD
39 | #define X_STEP_BIT 2 // Uno Digital Pin 2
40 | #define Y_STEP_BIT 3 // Uno Digital Pin 3
41 | #define Z_STEP_BIT 4 // Uno Digital Pin 4
42 | #define STEP_MASK ((1<.
19 | */
20 |
21 | /* The defaults.h file serves as a central default settings selector for different machine
22 | types, from DIY CNC mills to CNC conversions of off-the-shelf machines. The settings
23 | files listed here are supplied by users, so your results may vary. However, this should
24 | give you a good starting point as you get to know your machine and tweak the settings for
25 | your nefarious needs.
26 | Ensure one and only one of these DEFAULTS_XXX values is defined in config.h */
27 |
28 | #ifndef defaults_h
29 |
30 | // Only define the DEFAULT_XXX with where to find the corresponding default_XXX.h file.
31 | // Don't #define defaults_h here, let the selected file do it. Prevents including more than one.
32 |
33 | #ifdef DEFAULTS_GENERIC
34 | // Grbl generic default settings. Should work across different machines.
35 | #include "defaults/defaults_generic.h"
36 | #endif
37 |
38 | #ifdef DEFAULTS_SHERLINE_5400
39 | // Description: Sherline 5400 mill with three NEMA 23 Keling KL23H256-21-8B 185 oz-in stepper motors,
40 | // driven by three Pololu A4988 stepper drivers with a 30V, 6A power supply at 1.5A per winding.
41 | #include "defaults/defaults_sherline.h"
42 | #endif
43 |
44 | #ifdef DEFAULTS_SHAPEOKO
45 | // Description: Shapeoko CNC mill with three NEMA 17 stepper motors, driven by Synthetos
46 | // grblShield with a 24V, 4.2A power supply.
47 | #include "defaults/defaults_shapeoko.h"
48 | #endif
49 |
50 | #ifdef DEFAULTS_SHAPEOKO_2
51 | // Description: Shapeoko CNC mill with three NEMA 17 stepper motors, driven by Synthetos
52 | // grblShield at 28V.
53 | #include "defaults/defaults_shapeoko2.h"
54 | #endif
55 |
56 | #ifdef DEFAULTS_SHAPEOKO_3
57 | // Description: Shapeoko CNC mill with three NEMA 23 stepper motors, driven by CarbideMotion
58 | #include "defaults/defaults_shapeoko3.h"
59 | #endif
60 |
61 | #ifdef DEFAULTS_X_CARVE_500MM
62 | // Description: X-Carve 3D Carver CNC mill with three 200 step/rev motors driven by Synthetos
63 | // grblShield at 24V.
64 | #include "defaults/defaults_x_carve_500mm.h"
65 | #endif
66 |
67 | #ifdef DEFAULTS_X_CARVE_1000MM
68 | // Description: X-Carve 3D Carver CNC mill with three 200 step/rev motors driven by Synthetos
69 | // grblShield at 24V.
70 | #include "defaults/defaults_x_carve_1000mm.h"
71 | #endif
72 |
73 | #ifdef DEFAULTS_ZEN_TOOLWORKS_7x7
74 | // Description: Zen Toolworks 7x7 mill with three Shinano SST43D2121 65oz-in NEMA 17 stepper motors.
75 | // Leadscrew is different from some ZTW kits, where most are 1.25mm/rev rather than 8.0mm/rev here.
76 | // Driven by 30V, 6A power supply and TI DRV8811 stepper motor drivers.
77 | #include "defaults/defaults_zen_toolworks_7x7.h"
78 | #endif
79 |
80 | #ifdef DEFAULTS_OXCNC
81 | // Grbl settings for OpenBuilds OX CNC Machine
82 | // http://www.openbuilds.com/builds/openbuilds-ox-cnc-machine.341/
83 | #include "defaults/defaults_oxcnc.h"
84 | #endif
85 |
86 | #ifdef DEFAULTS_SIMULATOR
87 | // Settings only for Grbl Simulator (www.github.com/grbl/grbl-sim)
88 | #include "defaults/defaults_simulator.h"
89 | #endif
90 |
91 | #ifdef DEFAULTS_LLC
92 | // Grbl generic default settings. Should work across different machines.
93 | #include "defaults/defaults_llc.h"
94 | #endif
95 |
96 | #endif
97 |
--------------------------------------------------------------------------------
/src/grbl/defaults/defaults_generic.h:
--------------------------------------------------------------------------------
1 | /*
2 | defaults_generic.h - defaults settings configuration file
3 | Part of Grbl
4 |
5 | Copyright (c) 2012-2015 Sungeun K. Jeon
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 | /* The defaults.h file serves as a central default settings file for different machine
22 | types, from DIY CNC mills to CNC conversions of off-the-shelf machines. The settings
23 | here are supplied by users, so your results may vary. However, this should give you
24 | a good starting point as you get to know your machine and tweak the settings for your
25 | nefarious needs. */
26 |
27 | #ifndef defaults_h
28 | #define defaults_h
29 |
30 | // Grbl generic default settings. Should work across different machines.
31 | #define DEFAULT_X_STEPS_PER_MM 250.0
32 | #define DEFAULT_Y_STEPS_PER_MM 250.0
33 | #define DEFAULT_Z_STEPS_PER_MM 250.0
34 | #define DEFAULT_X_MAX_RATE 500.0 // mm/min
35 | #define DEFAULT_Y_MAX_RATE 500.0 // mm/min
36 | #define DEFAULT_Z_MAX_RATE 500.0 // mm/min
37 | #define DEFAULT_X_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
38 | #define DEFAULT_Y_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
39 | #define DEFAULT_Z_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
40 | #define DEFAULT_X_MAX_TRAVEL 200.0 // mm
41 | #define DEFAULT_Y_MAX_TRAVEL 200.0 // mm
42 | #define DEFAULT_Z_MAX_TRAVEL 200.0 // mm
43 | #define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm
44 | #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
45 | #define DEFAULT_STEP_PULSE_MICROSECONDS 10
46 | #define DEFAULT_STEPPING_INVERT_MASK 0
47 | #define DEFAULT_DIRECTION_INVERT_MASK 0
48 | #define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-254, 255 keeps steppers enabled)
49 | #define DEFAULT_STATUS_REPORT_MASK ((BITFLAG_RT_STATUS_MACHINE_POSITION)|(BITFLAG_RT_STATUS_WORK_POSITION))
50 | #define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
51 | #define DEFAULT_ARC_TOLERANCE 0.002 // mm
52 | #define DEFAULT_REPORT_INCHES 0 // false
53 | #define DEFAULT_INVERT_ST_ENABLE 0 // false
54 | #define DEFAULT_INVERT_LIMIT_PINS 0 // false
55 | #define DEFAULT_SOFT_LIMIT_ENABLE 0 // false
56 | #define DEFAULT_HARD_LIMIT_ENABLE 0 // false
57 | #define DEFAULT_HOMING_ENABLE 0 // false
58 | #define DEFAULT_HOMING_DIR_MASK 0 // move positive dir
59 | #define DEFAULT_HOMING_FEED_RATE 25.0 // mm/min
60 | #define DEFAULT_HOMING_SEEK_RATE 500.0 // mm/min
61 | #define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
62 | #define DEFAULT_HOMING_PULLOFF 1.0 // mm
63 |
64 | #endif
65 |
--------------------------------------------------------------------------------
/src/grbl/defaults/defaults_llc.h:
--------------------------------------------------------------------------------
1 | /*
2 | defaults_generic.h - defaults settings configuration file
3 | Part of Grbl
4 |
5 | Copyright (c) 2012-2015 Sungeun K. Jeon
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 | /* The defaults.h file serves as a central default settings file for different machine
22 | types, from DIY CNC mills to CNC conversions of off-the-shelf machines. The settings
23 | here are supplied by users, so your results may vary. However, this should give you
24 | a good starting point as you get to know your machine and tweak the settings for your
25 | nefarious needs. */
26 |
27 | #ifndef defaults_h
28 | #define defaults_h
29 |
30 | // Grbl generic default settings. Should work across different machines.
31 | #define DEFAULT_X_STEPS_PER_MM 200.0*8
32 | #define DEFAULT_Y_STEPS_PER_MM 200.0*8
33 | #define DEFAULT_Z_STEPS_PER_MM 200.0*8
34 | #define DEFAULT_X_MAX_RATE 500.0 // mm/min
35 | #define DEFAULT_Y_MAX_RATE 300.0 // mm/min
36 | #define DEFAULT_Z_MAX_RATE 200.0 // mm/min
37 | #define DEFAULT_X_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
38 | #define DEFAULT_Y_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
39 | #define DEFAULT_Z_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
40 | #define DEFAULT_X_MAX_TRAVEL 200.0 // mm
41 | #define DEFAULT_Y_MAX_TRAVEL 200.0 // mm
42 | #define DEFAULT_Z_MAX_TRAVEL 200.0 // mm
43 | #define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm
44 | #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
45 | #define DEFAULT_STEP_PULSE_MICROSECONDS 10
46 | #define DEFAULT_STEPPING_INVERT_MASK 0
47 | #define DEFAULT_DIRECTION_INVERT_MASK 0
48 | #define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-254, 255 keeps steppers enabled)
49 | #define DEFAULT_STATUS_REPORT_MASK ((BITFLAG_RT_STATUS_MACHINE_POSITION)|(BITFLAG_RT_STATUS_WORK_POSITION)|BITFLAG_RT_STATUS_LIMIT_PINS)
50 | #define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
51 | #define DEFAULT_ARC_TOLERANCE 0.002 // mm
52 | #define DEFAULT_REPORT_INCHES 0 // false
53 | #define DEFAULT_INVERT_ST_ENABLE 0 // false
54 | #define DEFAULT_INVERT_LIMIT_PINS 0 // false
55 | #define DEFAULT_SOFT_LIMIT_ENABLE 0 // false
56 | #define DEFAULT_HARD_LIMIT_ENABLE 1 // false
57 | #define DEFAULT_HOMING_ENABLE 1 // false
58 | #define DEFAULT_HOMING_DIR_MASK 0 // move positive dir
59 | #define DEFAULT_HOMING_FEED_RATE 500.0 // mm/min
60 | #define DEFAULT_HOMING_SEEK_RATE 300.0 // mm/min
61 | #define DEFAULT_HOMING_DEBOUNCE_DELAY 50 // msec (0-65k)
62 | #define DEFAULT_HOMING_PULLOFF 2.0 // mm
63 |
64 | #endif
65 |
--------------------------------------------------------------------------------
/src/grbl/defaults/defaults_oxcnc.h:
--------------------------------------------------------------------------------
1 | /*
2 | defaults_oxcnc.h - defaults settings configuration file
3 | Part of Grbl
4 |
5 | Copyright (c) 2012-2015 Sungeun K. Jeon
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 | /* The defaults.h file serves as a central default settings file for different machine
22 | types, from DIY CNC mills to CNC conversions of off-the-shelf machines. The settings
23 | here are supplied by users, so your results may vary. However, this should give you
24 | a good starting point as you get to know your machine and tweak the settings for your
25 | nefarious needs. */
26 |
27 | #ifndef defaults_h
28 | #define defaults_h
29 |
30 | // Grbl settings for OpenBuilds OX CNC Machine
31 | // http://www.openbuilds.com/builds/openbuilds-ox-cnc-machine.341/
32 | #define DEFAULT_X_STEPS_PER_MM 26.670
33 | #define DEFAULT_Y_STEPS_PER_MM 26.670
34 | #define DEFAULT_Z_STEPS_PER_MM 50
35 | #define DEFAULT_X_MAX_RATE 500.0 // mm/min
36 | #define DEFAULT_Y_MAX_RATE 500.0 // mm/min
37 | #define DEFAULT_Z_MAX_RATE 500.0 // mm/min
38 | #define DEFAULT_X_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
39 | #define DEFAULT_Y_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
40 | #define DEFAULT_Z_ACCELERATION (10.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
41 | #define DEFAULT_X_MAX_TRAVEL 500.0 // mm
42 | #define DEFAULT_Y_MAX_TRAVEL 750.0 // mm
43 | #define DEFAULT_Z_MAX_TRAVEL 80.0 // mm
44 | #define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm
45 | #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
46 | #define DEFAULT_STEP_PULSE_MICROSECONDS 10
47 | #define DEFAULT_STEPPING_INVERT_MASK 0
48 | #define DEFAULT_DIRECTION_INVERT_MASK 0
49 | #define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-254, 255 keeps steppers enabled)
50 | #define DEFAULT_STATUS_REPORT_MASK ((BITFLAG_RT_STATUS_MACHINE_POSITION)|(BITFLAG_RT_STATUS_WORK_POSITION))
51 | #define DEFAULT_JUNCTION_DEVIATION 0.02 // mm
52 | #define DEFAULT_ARC_TOLERANCE 0.002 // mm
53 | #define DEFAULT_REPORT_INCHES 0 // false
54 | #define DEFAULT_INVERT_ST_ENABLE 0 // false
55 | #define DEFAULT_INVERT_LIMIT_PINS 0 // false
56 | #define DEFAULT_SOFT_LIMIT_ENABLE 0 // false
57 | #define DEFAULT_HARD_LIMIT_ENABLE 0 // false
58 | #define DEFAULT_HOMING_ENABLE 0 // false
59 | #define DEFAULT_HOMING_DIR_MASK 0 // move positive dir
60 | #define DEFAULT_HOMING_FEED_RATE 25.0 // mm/min
61 | #define DEFAULT_HOMING_SEEK_RATE 500.0 // mm/min
62 | #define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
63 | #define DEFAULT_HOMING_PULLOFF 1.0 // mm
64 |
65 | #endif
66 |
--------------------------------------------------------------------------------
/src/grbl/defaults/defaults_shapeoko.h:
--------------------------------------------------------------------------------
1 | /*
2 | defaults_shapeoko.h - defaults settings configuration file
3 | Part of Grbl
4 |
5 | Copyright (c) 2012-2015 Sungeun K. Jeon
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 | /* The defaults.h file serves as a central default settings file for different machine
22 | types, from DIY CNC mills to CNC conversions of off-the-shelf machines. The settings
23 | here are supplied by users, so your results may vary. However, this should give you
24 | a good starting point as you get to know your machine and tweak the settings for your
25 | nefarious needs. */
26 |
27 | #ifndef defaults_h
28 | #define defaults_h
29 |
30 |
31 | // Description: Shapeoko CNC mill with three NEMA 17 stepper motors, driven by Synthetos
32 | // grblShield with a 24V, 4.2A power supply.
33 | #define MICROSTEPS_XY 8
34 | #define STEP_REVS_XY 400
35 | #define MM_PER_REV_XY (0.08*18*MM_PER_INCH) // 0.08 in belt pitch, 18 pulley teeth
36 | #define MICROSTEPS_Z 2
37 | #define STEP_REVS_Z 400
38 | #define MM_PER_REV_Z 1.250 // 1.25 mm/rev leadscrew
39 | #define DEFAULT_X_STEPS_PER_MM (MICROSTEPS_XY*STEP_REVS_XY/MM_PER_REV_XY)
40 | #define DEFAULT_Y_STEPS_PER_MM (MICROSTEPS_XY*STEP_REVS_XY/MM_PER_REV_XY)
41 | #define DEFAULT_Z_STEPS_PER_MM (MICROSTEPS_Z*STEP_REVS_Z/MM_PER_REV_Z)
42 | #define DEFAULT_X_MAX_RATE 1000.0 // mm/min
43 | #define DEFAULT_Y_MAX_RATE 1000.0 // mm/min
44 | #define DEFAULT_Z_MAX_RATE 1000.0 // mm/min
45 | #define DEFAULT_X_ACCELERATION (15.0*60*60) // 15*60*60 mm/min^2 = 15 mm/sec^2
46 | #define DEFAULT_Y_ACCELERATION (15.0*60*60) // 15*60*60 mm/min^2 = 15 mm/sec^2
47 | #define DEFAULT_Z_ACCELERATION (15.0*60*60) // 15*60*60 mm/min^2 = 15 mm/sec^2
48 | #define DEFAULT_X_MAX_TRAVEL 200.0 // mm
49 | #define DEFAULT_Y_MAX_TRAVEL 200.0 // mm
50 | #define DEFAULT_Z_MAX_TRAVEL 200.0 // mm
51 | #define DEFAULT_SPINDLE_RPM_MAX 10000.0 // rpm
52 | #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
53 | #define DEFAULT_STEP_PULSE_MICROSECONDS 10
54 | #define DEFAULT_STEPPING_INVERT_MASK 0
55 | #define DEFAULT_DIRECTION_INVERT_MASK ((1<.
19 | */
20 |
21 | /* The defaults.h file serves as a central default settings file for different machine
22 | types, from DIY CNC mills to CNC conversions of off-the-shelf machines. The settings
23 | here are supplied by users, so your results may vary. However, this should give you
24 | a good starting point as you get to know your machine and tweak the settings for your
25 | nefarious needs. */
26 |
27 | #ifndef defaults_h
28 | #define defaults_h
29 |
30 | // Description: Shapeoko CNC mill with three NEMA 17 stepper motors, driven by Synthetos
31 | // grblShield at 28V.
32 | #define MICROSTEPS_XY 8
33 | #define STEP_REVS_XY 200
34 | #define MM_PER_REV_XY (2.0*20) // 2mm belt pitch, 20 pulley teeth
35 | #define MICROSTEPS_Z 2
36 | #define STEP_REVS_Z 200
37 | #define MM_PER_REV_Z 1.250 // 1.25 mm/rev leadscrew
38 | #define DEFAULT_X_STEPS_PER_MM (MICROSTEPS_XY*STEP_REVS_XY/MM_PER_REV_XY)
39 | #define DEFAULT_Y_STEPS_PER_MM (MICROSTEPS_XY*STEP_REVS_XY/MM_PER_REV_XY)
40 | #define DEFAULT_Z_STEPS_PER_MM (MICROSTEPS_Z*STEP_REVS_Z/MM_PER_REV_Z)
41 | #define DEFAULT_X_MAX_RATE 5000.0 // mm/min
42 | #define DEFAULT_Y_MAX_RATE 5000.0 // mm/min
43 | #define DEFAULT_Z_MAX_RATE 500.0 // mm/min
44 | #define DEFAULT_X_ACCELERATION (250.0*60*60) // 25*60*60 mm/min^2 = 25 mm/sec^2
45 | #define DEFAULT_Y_ACCELERATION (250.0*60*60) // 25*60*60 mm/min^2 = 25 mm/sec^2
46 | #define DEFAULT_Z_ACCELERATION (50.0*60*60) // 25*60*60 mm/min^2 = 25 mm/sec^2
47 | #define DEFAULT_X_MAX_TRAVEL 290.0 // mm
48 | #define DEFAULT_Y_MAX_TRAVEL 290.0 // mm
49 | #define DEFAULT_Z_MAX_TRAVEL 100.0 // mm
50 | #define DEFAULT_SPINDLE_RPM_MAX 10000.0 // rpm
51 | #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
52 | #define DEFAULT_STEP_PULSE_MICROSECONDS 10
53 | #define DEFAULT_STEPPING_INVERT_MASK 0
54 | #define DEFAULT_DIRECTION_INVERT_MASK ((1<.
19 | */
20 |
21 | /* The defaults.h file serves as a central default settings file for different machine
22 | types, from DIY CNC mills to CNC conversions of off-the-shelf machines. The settings
23 | here are supplied by users, so your results may vary. However, this should give you
24 | a good starting point as you get to know your machine and tweak the settings for your
25 | nefarious needs. */
26 |
27 | #ifndef defaults_h
28 | #define defaults_h
29 |
30 | // Description: Shapeoko CNC mill with three NEMA 23 stepper motors, driven by CarbideMotion
31 | #define MICROSTEPS_XY 8
32 | #define STEP_REVS_XY 200
33 | #define MM_PER_REV_XY (2.0*20) // 2mm belt pitch, 20 pulley teeth
34 | #define MICROSTEPS_Z 8
35 | #define STEP_REVS_Z 200
36 | #define MM_PER_REV_Z (2.0*20) // 2mm belt pitch, 20 pulley teeth
37 | #define DEFAULT_X_STEPS_PER_MM (MICROSTEPS_XY*STEP_REVS_XY/MM_PER_REV_XY)
38 | #define DEFAULT_Y_STEPS_PER_MM (MICROSTEPS_XY*STEP_REVS_XY/MM_PER_REV_XY)
39 | #define DEFAULT_Z_STEPS_PER_MM (MICROSTEPS_Z*STEP_REVS_Z/MM_PER_REV_Z)
40 | #define DEFAULT_X_MAX_RATE 5000.0 // mm/min
41 | #define DEFAULT_Y_MAX_RATE 5000.0 // mm/min
42 | #define DEFAULT_Z_MAX_RATE 5000.0 // mm/min
43 | #define DEFAULT_X_ACCELERATION (400.0*60*60) // 400*60*60 mm/min^2 = 400 mm/sec^2
44 | #define DEFAULT_Y_ACCELERATION (400.0*60*60) // 400*60*60 mm/min^2 = 400 mm/sec^2
45 | #define DEFAULT_Z_ACCELERATION (400.0*60*60) // 400*60*60 mm/min^2 = 400 mm/sec^2
46 | #define DEFAULT_X_MAX_TRAVEL 425.0 // mm
47 | #define DEFAULT_Y_MAX_TRAVEL 465.0 // mm
48 | #define DEFAULT_Z_MAX_TRAVEL 80.0 // mm
49 | #define DEFAULT_SPINDLE_RPM_MAX 10000.0 // rpm
50 | #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
51 | #define DEFAULT_STEP_PULSE_MICROSECONDS 10
52 | #define DEFAULT_STEPPING_INVERT_MASK 0
53 | #define DEFAULT_DIRECTION_INVERT_MASK ((1<.
19 | */
20 |
21 | /* The defaults.h file serves as a central default settings file for different machine
22 | types, from DIY CNC mills to CNC conversions of off-the-shelf machines. The settings
23 | here are supplied by users, so your results may vary. However, this should give you
24 | a good starting point as you get to know your machine and tweak the settings for your
25 | nefarious needs. */
26 |
27 | #ifndef defaults_h
28 | #define defaults_h
29 |
30 | // Description: Sherline 5400 mill with three NEMA 23 Keling KL23H256-21-8B 185 oz-in stepper motors,
31 | // driven by three Pololu A4988 stepper drivers with a 30V, 6A power supply at 1.5A per winding.
32 | #define MICROSTEPS 2
33 | #define STEPS_PER_REV 200.0
34 | #define MM_PER_REV (0.050*MM_PER_INCH) // 0.050 inch/rev leadscrew
35 | #define DEFAULT_X_STEPS_PER_MM (STEPS_PER_REV*MICROSTEPS/MM_PER_REV)
36 | #define DEFAULT_Y_STEPS_PER_MM (STEPS_PER_REV*MICROSTEPS/MM_PER_REV)
37 | #define DEFAULT_Z_STEPS_PER_MM (STEPS_PER_REV*MICROSTEPS/MM_PER_REV)
38 | #define DEFAULT_X_MAX_RATE 635.0 // mm/min (25 ipm)
39 | #define DEFAULT_Y_MAX_RATE 635.0 // mm/min
40 | #define DEFAULT_Z_MAX_RATE 635.0 // mm/min
41 | #define DEFAULT_X_ACCELERATION (50.0*60*60) // 50*60*60 mm/min^2 = 50 mm/sec^2
42 | #define DEFAULT_Y_ACCELERATION (50.0*60*60) // 50*60*60 mm/min^2 = 50 mm/sec^2
43 | #define DEFAULT_Z_ACCELERATION (50.0*60*60) // 50*60*60 mm/min^2 = 50 mm/sec^2
44 | #define DEFAULT_X_MAX_TRAVEL 225.0 // mm
45 | #define DEFAULT_Y_MAX_TRAVEL 125.0 // mm
46 | #define DEFAULT_Z_MAX_TRAVEL 170.0 // mm
47 | #define DEFAULT_SPINDLE_RPM_MAX 2800.0 // rpm
48 | #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
49 | #define DEFAULT_STEP_PULSE_MICROSECONDS 10
50 | #define DEFAULT_STEPPING_INVERT_MASK 0
51 | #define DEFAULT_DIRECTION_INVERT_MASK ((1<.
19 | */
20 |
21 | /* The defaults.h file serves as a central default settings file for different machine
22 | types, from DIY CNC mills to CNC conversions of off-the-shelf machines. The settings
23 | here are supplied by users, so your results may vary. However, this should give you
24 | a good starting point as you get to know your machine and tweak the settings for your
25 | nefarious needs. */
26 |
27 | #ifndef defaults_h
28 | #define defaults_h
29 |
30 | // Settings only for Grbl Simulator (www.github.com/grbl/grbl-sim)
31 | // Grbl generic default settings. Should work across different machines.
32 | #define DEFAULT_X_STEPS_PER_MM 1000.0
33 | #define DEFAULT_Y_STEPS_PER_MM 1000.0
34 | #define DEFAULT_Z_STEPS_PER_MM 1000.0
35 | #define DEFAULT_X_MAX_RATE 1000.0 // mm/min
36 | #define DEFAULT_Y_MAX_RATE 1000.0 // mm/min
37 | #define DEFAULT_Z_MAX_RATE 1000.0 // mm/min
38 | #define DEFAULT_X_ACCELERATION (100.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
39 | #define DEFAULT_Y_ACCELERATION (100.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
40 | #define DEFAULT_Z_ACCELERATION (100.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
41 | #define DEFAULT_X_MAX_TRAVEL 1000.0 // mm
42 | #define DEFAULT_Y_MAX_TRAVEL 1000.0 // mm
43 | #define DEFAULT_Z_MAX_TRAVEL 1000.0 // mm
44 | #define DEFAULT_SPINDLE_RPM_MAX 1000.0 // rpm
45 | #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
46 | #define DEFAULT_STEP_PULSE_MICROSECONDS 10
47 | #define DEFAULT_STEPPING_INVERT_MASK 0
48 | #define DEFAULT_DIRECTION_INVERT_MASK 0
49 | #define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-254, 255 keeps steppers enabled)
50 | #define DEFAULT_STATUS_REPORT_MASK ((BITFLAG_RT_STATUS_MACHINE_POSITION)|(BITFLAG_RT_STATUS_WORK_POSITION))
51 | #define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
52 | #define DEFAULT_ARC_TOLERANCE 0.002 // mm
53 | #define DEFAULT_REPORT_INCHES 0 // false
54 | #define DEFAULT_INVERT_ST_ENABLE 0 // false
55 | #define DEFAULT_INVERT_LIMIT_PINS 0 // false
56 | #define DEFAULT_SOFT_LIMIT_ENABLE 0 // false
57 | #define DEFAULT_HARD_LIMIT_ENABLE 0 // false
58 | #define DEFAULT_HOMING_ENABLE 0 // false
59 | #define DEFAULT_HOMING_DIR_MASK 0 // move positive dir
60 | #define DEFAULT_HOMING_FEED_RATE 25.0 // mm/min
61 | #define DEFAULT_HOMING_SEEK_RATE 500.0 // mm/min
62 | #define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
63 | #define DEFAULT_HOMING_PULLOFF 1.0 // mm
64 |
65 | #endif
66 |
--------------------------------------------------------------------------------
/src/grbl/defaults/defaults_x_carve_1000mm.h:
--------------------------------------------------------------------------------
1 | /*
2 | defaults_x_carve_1000mm.h - defaults settings configuration file
3 | Part of Grbl
4 |
5 | Copyright (c) 2012-2015 Sungeun K. Jeon
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 | /* The defaults.h file serves as a central default settings file for different machine
22 | types, from DIY CNC mills to CNC conversions of off-the-shelf machines. The settings
23 | here are supplied by users, so your results may vary. However, this should give you
24 | a good starting point as you get to know your machine and tweak the settings for your
25 | nefarious needs. */
26 |
27 | #ifndef defaults_h
28 | #define defaults_h
29 |
30 | // Description: X-Carve 3D Carver CNC mill with three 200 step/rev motors driven by Synthetos
31 | // grblShield at 24V.
32 | #define MICROSTEPS_XY 8
33 | #define STEP_REVS_XY 200
34 | #define MM_PER_REV_XY (2.0*20) // 2mm belt pitch, 20 pulley teeth
35 | #define MICROSTEPS_Z 2
36 | #define STEP_REVS_Z 200
37 | #define MM_PER_REV_Z 2.117 // ACME 3/8-12 Leadscrew
38 | #define DEFAULT_X_STEPS_PER_MM (MICROSTEPS_XY*STEP_REVS_XY/MM_PER_REV_XY)
39 | #define DEFAULT_Y_STEPS_PER_MM (MICROSTEPS_XY*STEP_REVS_XY/MM_PER_REV_XY)
40 | #define DEFAULT_Z_STEPS_PER_MM (MICROSTEPS_Z*STEP_REVS_Z/MM_PER_REV_Z)
41 | #define DEFAULT_X_MAX_RATE 8000.0 // mm/min
42 | #define DEFAULT_Y_MAX_RATE 8000.0 // mm/min
43 | #define DEFAULT_Z_MAX_RATE 500.0 // mm/min
44 | #define DEFAULT_X_ACCELERATION (500.0*60*60) // 25*60*60 mm/min^2 = 25 mm/sec^2
45 | #define DEFAULT_Y_ACCELERATION (500.0*60*60) // 25*60*60 mm/min^2 = 25 mm/sec^2
46 | #define DEFAULT_Z_ACCELERATION (50.0*60*60) // 25*60*60 mm/min^2 = 25 mm/sec^2
47 | #define DEFAULT_X_MAX_TRAVEL 740.0 // mm
48 | #define DEFAULT_Y_MAX_TRAVEL 790.0 // mm
49 | #define DEFAULT_Z_MAX_TRAVEL 100.0 // mm
50 | #define DEFAULT_SPINDLE_RPM_MAX 10000.0 // rpm
51 | #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
52 | #define DEFAULT_STEP_PULSE_MICROSECONDS 10
53 | #define DEFAULT_STEPPING_INVERT_MASK 0
54 | #define DEFAULT_DIRECTION_INVERT_MASK ((1<.
19 | */
20 |
21 | /* The defaults.h file serves as a central default settings file for different machine
22 | types, from DIY CNC mills to CNC conversions of off-the-shelf machines. The settings
23 | here are supplied by users, so your results may vary. However, this should give you
24 | a good starting point as you get to know your machine and tweak the settings for your
25 | nefarious needs. */
26 |
27 | #ifndef defaults_h
28 | #define defaults_h
29 |
30 | // Description: X-Carve 3D Carver CNC mill with three 200 step/rev motors driven by Synthetos
31 | // grblShield at 24V.
32 | #define MICROSTEPS_XY 8
33 | #define STEP_REVS_XY 200
34 | #define MM_PER_REV_XY (2.0*20) // 2mm belt pitch, 20 pulley teeth
35 | #define MICROSTEPS_Z 2
36 | #define STEP_REVS_Z 200
37 | #define MM_PER_REV_Z 2.117 // ACME 3/8-12 Leadscrew
38 | #define DEFAULT_X_STEPS_PER_MM (MICROSTEPS_XY*STEP_REVS_XY/MM_PER_REV_XY)
39 | #define DEFAULT_Y_STEPS_PER_MM (MICROSTEPS_XY*STEP_REVS_XY/MM_PER_REV_XY)
40 | #define DEFAULT_Z_STEPS_PER_MM (MICROSTEPS_Z*STEP_REVS_Z/MM_PER_REV_Z)
41 | #define DEFAULT_X_MAX_RATE 8000.0 // mm/min
42 | #define DEFAULT_Y_MAX_RATE 8000.0 // mm/min
43 | #define DEFAULT_Z_MAX_RATE 500.0 // mm/min
44 | #define DEFAULT_X_ACCELERATION (500.0*60*60) // 25*60*60 mm/min^2 = 25 mm/sec^2
45 | #define DEFAULT_Y_ACCELERATION (500.0*60*60) // 25*60*60 mm/min^2 = 25 mm/sec^2
46 | #define DEFAULT_Z_ACCELERATION (50.0*60*60) // 25*60*60 mm/min^2 = 25 mm/sec^2
47 | #define DEFAULT_X_MAX_TRAVEL 290.0 // mm
48 | #define DEFAULT_Y_MAX_TRAVEL 290.0 // mm
49 | #define DEFAULT_Z_MAX_TRAVEL 100.0 // mm
50 | #define DEFAULT_SPINDLE_RPM_MAX 10000.0 // rpm
51 | #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
52 | #define DEFAULT_STEP_PULSE_MICROSECONDS 10
53 | #define DEFAULT_STEPPING_INVERT_MASK 0
54 | #define DEFAULT_DIRECTION_INVERT_MASK ((1<.
19 | */
20 |
21 | /* The defaults.h file serves as a central default settings file for different machine
22 | types, from DIY CNC mills to CNC conversions of off-the-shelf machines. The settings
23 | here are supplied by users, so your results may vary. However, this should give you
24 | a good starting point as you get to know your machine and tweak the settings for your
25 | nefarious needs. */
26 |
27 | #ifndef defaults_h
28 | #define defaults_h
29 |
30 | // Description: Zen Toolworks 7x7 mill with three Shinano SST43D2121 65oz-in NEMA 17 stepper motors.
31 | // Leadscrew is different from some ZTW kits, where most are 1.25mm/rev rather than 8.0mm/rev here.
32 | // Driven by 30V, 6A power supply and TI DRV8811 stepper motor drivers.
33 | #define MICROSTEPS 8
34 | #define STEPS_PER_REV 200.0
35 | #define MM_PER_REV 8.0 // 8 mm/rev leadscrew
36 | #define DEFAULT_X_STEPS_PER_MM (STEPS_PER_REV*MICROSTEPS/MM_PER_REV)
37 | #define DEFAULT_Y_STEPS_PER_MM (STEPS_PER_REV*MICROSTEPS/MM_PER_REV)
38 | #define DEFAULT_Z_STEPS_PER_MM (STEPS_PER_REV*MICROSTEPS/MM_PER_REV)
39 | #define DEFAULT_X_MAX_RATE 6000.0 // mm/min
40 | #define DEFAULT_Y_MAX_RATE 6000.0 // mm/min
41 | #define DEFAULT_Z_MAX_RATE 6000.0 // mm/min
42 | #define DEFAULT_X_ACCELERATION (600.0*60*60) // 600*60*60 mm/min^2 = 600 mm/sec^2
43 | #define DEFAULT_Y_ACCELERATION (600.0*60*60) // 600*60*60 mm/min^2 = 600 mm/sec^2
44 | #define DEFAULT_Z_ACCELERATION (600.0*60*60) // 600*60*60 mm/min^2 = 600 mm/sec^2
45 | #define DEFAULT_X_MAX_TRAVEL 190.0 // mm
46 | #define DEFAULT_Y_MAX_TRAVEL 180.0 // mm
47 | #define DEFAULT_Z_MAX_TRAVEL 150.0 // mm
48 | #define DEFAULT_SPINDLE_RPM_MAX 10000.0 // rpm
49 | #define DEFAULT_SPINDLE_RPM_MIN 0.0 // rpm
50 | #define DEFAULT_STEP_PULSE_MICROSECONDS 10
51 | #define DEFAULT_STEPPING_INVERT_MASK 0
52 | #define DEFAULT_DIRECTION_INVERT_MASK ((1<
25 | #include
26 |
27 | char eeprom[1024];
28 |
29 |
30 | /*! \brief Read byte from EEPROM.
31 | *
32 | * This function reads one byte from a given EEPROM address.
33 | *
34 | * \note The CPU is halted for 4 clock cycles during EEPROM read.
35 | *
36 | * \param addr EEPROM address to read from.
37 | * \return The byte read from the EEPROM address.
38 | */
39 | unsigned char eeprom_get_char( unsigned int addr )
40 | {
41 | // do {} while( EECR & (1< 0; size--) {
130 | checksum = (checksum << 1) || (checksum >> 7);
131 | checksum += *source;
132 | eeprom_put_char(destination++, *(source++));
133 | }
134 | eeprom_put_char(destination, checksum);
135 | }
136 |
137 | int memcpy_from_eeprom_with_checksum(char *destination, unsigned int source, unsigned int size) {
138 | unsigned char data, checksum = 0;
139 | for(; size > 0; size--) {
140 | data = eeprom_get_char(source++);
141 | checksum = (checksum << 1) || (checksum >> 7);
142 | checksum += data;
143 | *(destination++) = data;
144 | }
145 | return(checksum == eeprom_get_char(source));
146 | }
147 |
148 | // end of file
149 |
--------------------------------------------------------------------------------
/src/grbl/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 |
24 | unsigned char eeprom_get_char(unsigned int addr);
25 | void eeprom_put_char(unsigned int addr, unsigned char new_value);
26 | void memcpy_to_eeprom_with_checksum(unsigned int destination, char *source, unsigned int size);
27 | int memcpy_from_eeprom_with_checksum(char *destination, unsigned int source, unsigned int size);
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/src/grbl/examples/grblUpload/grblUpload.ino:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | This sketch compiles and uploads Grbl to your 328p-based Arduino!
3 |
4 | To use:
5 | - First make sure you have imported Grbl source code into your Arduino
6 | IDE. There are details on our Github website on how to do this.
7 |
8 | - Select your Arduino Board and Serial Port in the Tools drop-down menu.
9 | NOTE: Grbl only officially supports 328p-based Arduinos, like the Uno.
10 | Using other boards will likely not work!
11 |
12 | - Then just click 'Upload'. That's it!
13 |
14 | For advanced users:
15 | If you'd like to see what else Grbl can do, there are some additional
16 | options for customization and features you can enable or disable.
17 | Navigate your file system to where the Arduino IDE has stored the Grbl
18 | source code files, open the 'config.h' file in your favorite text
19 | editor. Inside are dozens of feature descriptions and #defines. Simply
20 | comment or uncomment the #defines or alter their assigned values, save
21 | your changes, and then click 'Upload' here.
22 |
23 | Copyright (c) 2015 Sungeun K. Jeon
24 | Released under the MIT-license. See license.txt for details.
25 | ***********************************************************************/
26 |
27 | #include
28 |
29 | // Do not alter this file!
30 |
--------------------------------------------------------------------------------
/src/grbl/examples/grblUpload/license.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Sungeun K. Jeon
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/src/grbl/grbl.h:
--------------------------------------------------------------------------------
1 | /*
2 | grbl.h - main Grbl include file
3 | Part of Grbl
4 |
5 | Copyright (c) 2015 Sungeun K. Jeon
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.0c-STM32"
26 | #define GRBL_VERSION_BUILD __DATE__
27 |
28 | #include "stm32f4xx.h"
29 | #define F_CPU 25000000 /* really is 100MHz timer runs at F_CPU/prescale */
30 |
31 | // Define standard libraries used by Grbl.
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 | #include
42 |
43 | // Define the Grbl system include files. NOTE: Do not alter organization.
44 | #include "config.h"
45 | #include "nuts_bolts.h"
46 | #include "settings.h"
47 | #include "system.h"
48 | #include "defaults.h"
49 | #include "cpu_map.h"
50 | #include "coolant_control.h"
51 | #include "eeprom.h"
52 | #include "gcode.h"
53 | #include "limits.h"
54 | #include "motion_control.h"
55 | #include "planner.h"
56 | #include "print.h"
57 | #include "probe.h"
58 | #include "protocol.h"
59 | #include "report.h"
60 | #include "serial.h"
61 | #include "spindle_control.h"
62 | #include "stepper.h"
63 |
64 | #endif
65 |
--------------------------------------------------------------------------------
/src/grbl/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-2015 Sungeun K. Jeon
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 | void limitpin_check();
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/src/grbl/main.c:
--------------------------------------------------------------------------------
1 | /*
2 | main.c - An embedded CNC Controller with rs274/ngc (g-code) support
3 | Part of Grbl
4 |
5 | Copyright (c) 2011-2015 Sungeun K. Jeon
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 | // Declare system global variable structure
26 | system_t sys;
27 |
28 |
29 | int main(void)
30 | {
31 |
32 |
33 |
34 | // Initialize system upon power-up.
35 | serial_init(); // Setup serial baud rate and interrupts
36 | settings_init(); // Load Grbl settings from EEPROM
37 | stepper_init(); // Configure stepper pins and interrupt timers
38 | system_init(); // Configure pinout pins and pin-change interrupt
39 |
40 | memset(&sys, 0, sizeof(sys)); // Clear all system variables
41 | sys.abort = true; // Set abort to complete initialization
42 | sei(); // Enable interrupts
43 |
44 | // Check for power-up and set system alarm if homing is enabled to force homing cycle
45 | // by setting Grbl's alarm state. Alarm locks out all g-code commands, including the
46 | // startup scripts, but allows access to settings and internal commands. Only a homing
47 | // cycle '$H' or kill alarm locks '$X' will disable the alarm.
48 | // NOTE: The startup script will run after successful completion of the homing cycle, but
49 | // not after disabling the alarm locks. Prevents motion startup blocks from crashing into
50 | // things uncontrollably. Very bad.
51 | #ifdef HOMING_INIT_LOCK
52 | if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; }
53 | #endif
54 |
55 | // Force Grbl into an ALARM state upon a power-cycle or hard reset.
56 | #ifdef FORCE_INITIALIZATION_ALARM
57 | sys.state = STATE_ALARM;
58 | #endif
59 |
60 | // Grbl initialization loop upon power-up or a system abort. For the latter, all processes
61 | // will return to this loop to be cleanly re-initialized.
62 | for(;;) {
63 |
64 | // TODO: Separate configure task that require interrupts to be disabled, especially upon
65 | // a system abort and ensuring any active interrupts are cleanly reset.
66 |
67 | // Reset Grbl primary systems.
68 | serial_reset_read_buffer(); // Clear serial read buffer
69 | gc_init(); // Set g-code parser to default state
70 | spindle_init();
71 | coolant_init();
72 | limits_init();
73 | probe_init();
74 | plan_reset(); // Clear block buffer and planner variables
75 | st_reset(); // Clear stepper subsystem variables.
76 |
77 | // Sync cleared gcode and planner positions to current system position.
78 | plan_sync_position();
79 | gc_sync_position();
80 |
81 | // Reset system variables.
82 | sys.abort = false;
83 | sys_rt_exec_state = 0;
84 | sys_rt_exec_alarm = 0;
85 | sys.suspend = false;
86 |
87 | // Start Grbl main loop. Processes program inputs and executes them.
88 | protocol_main_loop();
89 |
90 | }
91 | return 0; /* Never reached */
92 | }
93 |
--------------------------------------------------------------------------------
/src/grbl/motion_control.h:
--------------------------------------------------------------------------------
1 | /*
2 | motion_control.h - high level interface for issuing motion commands
3 | Part of Grbl
4 |
5 | Copyright (c) 2011-2015 Sungeun K. Jeon
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 | #define HOMING_CYCLE_LINE_NUMBER -1
27 | #define PARKING_MOTION_LINE_NUMBER -2
28 |
29 | // Execute linear motion in absolute millimeter coordinates. Feed rate given in millimeters/second
30 | // unless invert_feed_rate is true. Then the feed_rate means that the motion should be completed in
31 | // (1 minute)/feed_rate time.
32 | #ifdef USE_LINE_NUMBERS
33 | void mc_line(float *target, float feed_rate, uint8_t invert_feed_rate, int32_t line_number);
34 | #else
35 | void mc_line(float *target, float feed_rate, uint8_t invert_feed_rate);
36 | #endif
37 |
38 | // Execute an arc in offset mode format. position == current xyz, target == target xyz,
39 | // offset == offset from current xyz, axis_XXX defines circle plane in tool space, axis_linear is
40 | // the direction of helical travel, radius == circle radius, is_clockwise_arc boolean. Used
41 | // for vector transformation direction.
42 | #ifdef USE_LINE_NUMBERS
43 | void mc_arc(float *position, float *target, float *offset, float radius, float feed_rate,
44 | uint8_t invert_feed_rate, uint8_t axis_0, uint8_t axis_1, uint8_t axis_linear, uint8_t is_clockwise_arc, int32_t line_number);
45 | #else
46 | void mc_arc(float *position, float *target, float *offset, float radius, float feed_rate,
47 | uint8_t invert_feed_rate, uint8_t axis_0, uint8_t axis_1, uint8_t axis_linear, uint8_t is_clockwise_arc);
48 | #endif
49 |
50 | // Dwell for a specific number of seconds
51 | void mc_dwell(float seconds);
52 |
53 | // Perform homing cycle to locate machine zero. Requires limit switches.
54 | void mc_homing_cycle();
55 |
56 | // Perform tool length probe cycle. Requires probe switch.
57 | #ifdef USE_LINE_NUMBERS
58 | void mc_probe_cycle(float *target, float feed_rate, uint8_t invert_feed_rate, uint8_t is_probe_away,
59 | uint8_t is_no_error, int32_t line_number);
60 | #else
61 | void mc_probe_cycle(float *target, float feed_rate, uint8_t invert_feed_rate, uint8_t is_probe_away,
62 | uint8_t is_no_error);
63 | #endif
64 |
65 | // Plans and executes the single special motion case for parking. Independent of main planner buffer.
66 | void mc_parking_motion(float *parking_target, float feed_rate);
67 |
68 | // Performs system reset. If in motion state, kills all motion and sets system alarm.
69 | void mc_reset();
70 |
71 | #endif
72 |
--------------------------------------------------------------------------------
/src/grbl/nuts_bolts.c:
--------------------------------------------------------------------------------
1 | /*
2 | nuts_bolts.c - Shared functions
3 | Part of Grbl
4 |
5 | Copyright (c) 2011-2015 Sungeun K. Jeon
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.01;
87 | exp += 2;
88 | }
89 | if (exp < 0) {
90 | fval *= 0.1;
91 | } else if (exp > 0) {
92 | do {
93 | fval *= 10.0;
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 = ceil(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_SAFETY_DOOR
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 | #if 0
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 | // Delays variable defined microseconds. Compiler compatibility fix for _delay_us(),
138 | // which only accepts constants in future compiler releases. Written to perform more
139 | // efficiently with larger delays, as the counter adds parasitic time in each iteration.
140 | void delay_us(uint32_t us)
141 | {
142 | while (us) {
143 | if (us < 10) {
144 | _delay_us(1);
145 | us--;
146 | } else if (us < 100) {
147 | _delay_us(10);
148 | us -= 10;
149 | } else if (us < 1000) {
150 | _delay_us(100);
151 | us -= 100;
152 | } else {
153 | _delay_ms(1);
154 | us -= 1000;
155 | }
156 | }
157 | }
158 | #endif
159 |
160 | // Simple hypotenuse computation function.
161 | float hypot_f(float x, float y) { return(sqrt(x*x + y*y)); }
162 |
163 |
164 | void set_as_output(GPIO_TypeDef* port, uint32_t pin)
165 | {
166 | GPIO_InitTypeDef GPIO_InitStructure;
167 |
168 | GPIO_InitStructure.GPIO_Pin = pin;
169 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
170 | GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
171 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
172 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
173 | GPIO_Init(port, &GPIO_InitStructure);
174 | }
175 |
176 | void set_as_input(GPIO_TypeDef* port, uint32_t pin)
177 | {
178 | GPIO_InitTypeDef GPIO_InitStructure;
179 |
180 | GPIO_InitStructure.GPIO_Pin = pin;
181 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
182 | GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
183 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
184 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
185 | GPIO_Init(port, &GPIO_InitStructure);
186 | }
187 |
188 |
--------------------------------------------------------------------------------
/src/grbl/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-2015 Sungeun K. Jeon
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 |
25 | #define false 0
26 | #define true 1
27 |
28 | // Axis array index values. Must start with 0 and be continuous.
29 | #define N_AXIS 3 // Number of axes
30 | #define X_AXIS 0 // Axis indexing value.
31 | #define Y_AXIS 1
32 | #define Z_AXIS 2
33 | // #define A_AXIS 3
34 |
35 | // CoreXY motor assignments. DO NOT ALTER.
36 | // NOTE: If the A and B motor axis bindings are changed, this effects the CoreXY equations.
37 | #ifdef COREXY
38 | #define A_MOTOR X_AXIS // Must be X_AXIS
39 | #define B_MOTOR Y_AXIS // Must be Y_AXIS
40 | #endif
41 |
42 | // Conversions
43 | #define MM_PER_INCH (25.40)
44 | #define INCH_PER_MM (0.0393701)
45 | #define TICKS_PER_MICROSECOND (F_CPU/1000000)
46 |
47 | #define DELAY_MODE_DWELL 0
48 | #define DELAY_MODE_SAFETY_DOOR 1
49 |
50 | // Useful macros
51 | #define clear_vector(a) memset(a, 0, sizeof(a))
52 | #define clear_vector_float(a) memset(a, 0.0, sizeof(float)*N_AXIS)
53 | // #define clear_vector_long(a) memset(a, 0.0, sizeof(long)*N_AXIS)
54 | #define max(a,b) (((a) > (b)) ? (a) : (b))
55 | #define min(a,b) (((a) < (b)) ? (a) : (b))
56 |
57 | // Bit field and masking macros
58 | #define bit(n) (1 << n)
59 | #define bit_true(x,mask) (x) |= (mask)
60 | #define bit_false(x,mask) (x) &= ~(mask)
61 | #define bit_istrue(x,mask) ((x & mask) != 0)
62 | #define bit_isfalse(x,mask) ((x & mask) == 0)
63 |
64 | #define RAM_BASE 0x20000000
65 | #define RAM_BB_BASE 0x22000000
66 | #define Var_ClrBit_BB(Var, BitNumber) (*(vu32 *) (RAM_BB_BASE | (((u32)&Var - RAM_BASE) << 5) | ((BitNumber) << 2)) = 0)
67 | #define Var_SetBit_BB(Var, BitNumber) (*(vu32 *) (RAM_BB_BASE | (((u32)&Var - RAM_BASE) << 5) | ((BitNumber) << 2)) = 1)
68 | #define Var_GetBit_BB(Var, BitNumber) (*(vu32 *) (RAM_BB_BASE | (((u32)&Var - RAM_BASE) << 5) | ((BitNumber) << 2)))
69 |
70 |
71 | // Read a floating point value from a string. Line points to the input buffer, char_counter
72 | // is the indexer pointing to the current character of the line, while float_ptr is
73 | // a pointer to the result variable. Returns true when it succeeds
74 | uint8_t read_float(char *line, uint8_t *char_counter, float *float_ptr);
75 |
76 | // Non-blocking delay function used for general operation and suspend features.
77 | void delay_sec(float seconds, uint8_t mode);
78 |
79 | // Delays variable-defined milliseconds. Compiler compatibility fix for _delay_ms().
80 | void delay_ms(uint16_t ms);
81 |
82 | // Delays variable-defined microseconds. Compiler compatibility fix for _delay_us().
83 | void delay_us(uint32_t us);
84 |
85 | // Computes hypotenuse, avoiding avr-gcc's bloated version and the extra error checking.
86 | float hypot_f(float x, float y);
87 |
88 | #define delay_ms(t) _delay_ms(t)
89 | #define delay_us(t) _delay_us(t)
90 |
91 |
92 | void set_as_output(GPIO_TypeDef* port, uint32_t pin);
93 |
94 | void set_as_input(GPIO_TypeDef* port, uint32_t pin);
95 |
96 |
97 | #endif
98 |
--------------------------------------------------------------------------------
/src/grbl/planner.h:
--------------------------------------------------------------------------------
1 | /*
2 | planner.h - buffers movement commands and manages the acceleration profile plan
3 | Part of Grbl
4 |
5 | Copyright (c) 2011-2015 Sungeun K. Jeon
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 planner_h
23 | #define planner_h
24 |
25 |
26 | // The number of linear motions that can be in the plan at any give time
27 | #ifndef BLOCK_BUFFER_SIZE
28 | #ifdef USE_LINE_NUMBERS
29 | #define BLOCK_BUFFER_SIZE 16
30 | #else
31 | #define BLOCK_BUFFER_SIZE 18
32 | #endif
33 | #endif
34 |
35 | #define PLAN_OK true
36 | #define PLAN_EMPTY_BLOCK false
37 |
38 | // This struct stores a linear movement of a g-code block motion with its critical "nominal" values
39 | // are as specified in the source g-code.
40 | typedef struct {
41 | // Fields used by the bresenham algorithm for tracing the line
42 | // NOTE: Used by stepper algorithm to execute the block correctly. Do not alter these values.
43 | uint8_t direction_bits; // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
44 | uint32_t steps[N_AXIS]; // Step count along each axis
45 | uint32_t step_event_count; // The maximum step axis count and number of steps required to complete this block.
46 |
47 | // Fields used by the motion planner to manage acceleration. Some of these values may be updated
48 | // by the stepper module during execution of special motion cases for replanning purposes.
49 | float entry_speed_sqr; // The current planned entry speed at block junction in (mm/min)^2
50 | float max_entry_speed_sqr; // Maximum allowable entry speed based on the minimum of junction limit and
51 | // neighboring nominal speeds with overrides in (mm/min)^2
52 | float max_junction_speed_sqr; // Junction entry speed limit based on direction vectors in (mm/min)^2
53 | float nominal_speed_sqr; // Axis-limit adjusted nominal speed for this block in (mm/min)^2
54 | float acceleration; // Axis-limit adjusted line acceleration in (mm/min^2)
55 | float millimeters; // The remaining distance for this block to be executed in (mm)
56 | // uint8_t max_override; // Maximum override value based on axis speed limits
57 |
58 | #ifdef USE_LINE_NUMBERS
59 | int32_t line_number;
60 | #endif
61 | } plan_block_t;
62 |
63 |
64 | // Initialize and reset the motion plan subsystem
65 | void plan_reset();
66 |
67 | // Add a new linear movement to the buffer. target[N_AXIS] is the signed, absolute target position
68 | // in millimeters. Feed rate specifies the speed of the motion. If feed rate is inverted, the feed
69 | // rate is taken to mean "frequency" and would complete the operation in 1/feed_rate minutes.
70 | #ifdef USE_LINE_NUMBERS
71 | uint8_t plan_buffer_line(float *target, float feed_rate, uint8_t invert_feed_rate, uint8_t is_parking_motion, int32_t line_number);
72 | #else
73 | uint8_t plan_buffer_line(float *target, float feed_rate, uint8_t invert_feed_rate, uint8_t is_parking_motion);
74 | #endif
75 |
76 | // Called when the current block is no longer needed. Discards the block and makes the memory
77 | // availible for new blocks.
78 | void plan_discard_current_block();
79 |
80 | // Gets the planner block for the parking special motion case. Parking uses the always available buffer head.
81 | plan_block_t *plan_get_parking_block();
82 |
83 | // Gets the current block. Returns NULL if buffer empty
84 | plan_block_t *plan_get_current_block();
85 |
86 | // Called periodically by step segment buffer. Mostly used internally by planner.
87 | uint8_t plan_next_block_index(uint8_t block_index);
88 |
89 | // Called by step segment buffer when computing executing block velocity profile.
90 | float plan_get_exec_block_exit_speed();
91 |
92 | // Reset the planner position vector (in steps)
93 | void plan_sync_position();
94 |
95 | // Reinitialize plan with a partially completed block
96 | void plan_cycle_reinitialize();
97 |
98 | // Returns the number of active blocks are in the planner buffer.
99 | uint8_t plan_get_block_buffer_count();
100 |
101 | // Returns the status of the block ring buffer. True, if buffer is full.
102 | uint8_t plan_check_full_buffer();
103 |
104 | #endif
105 |
--------------------------------------------------------------------------------
/src/grbl/print.c:
--------------------------------------------------------------------------------
1 | /*
2 | print.c - Functions for formatting output strings
3 | Part of Grbl
4 |
5 | Copyright (c) 2011-2015 Sungeun K. Jeon
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 |
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 |
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 with base and number of desired digits.
64 | void print_unsigned_int8(uint8_t n, uint8_t base, uint8_t digits)
65 | {
66 | unsigned char buf[digits];
67 | uint8_t i = 0;
68 |
69 | for (; i < digits; i++) {
70 | buf[i] = n % base ;
71 | n /= base;
72 | }
73 |
74 | for (; i > 0; i--)
75 | serial_write('0' + buf[i - 1]);
76 | }
77 |
78 |
79 | // Prints an uint8 variable in base 2.
80 | void print_uint8_base2(uint8_t n) {
81 | print_unsigned_int8(n,2,8);
82 | }
83 |
84 |
85 | // Prints an uint8 variable in base 10.
86 | void print_uint8_base10(uint8_t n)
87 | {
88 | uint8_t digits;
89 | if (n < 10) { digits = 1; }
90 | else if (n < 100) { digits = 2; }
91 | else { digits = 3; }
92 | print_unsigned_int8(n,10,digits);
93 | }
94 |
95 |
96 | void print_uint32_base10(uint32_t n)
97 | {
98 | if (n == 0) {
99 | serial_write('0');
100 | return;
101 | }
102 |
103 | unsigned char buf[10];
104 | uint8_t i = 0;
105 |
106 | while (n > 0) {
107 | buf[i++] = n % 10;
108 | n /= 10;
109 | }
110 |
111 | for (; i > 0; i--)
112 | serial_write('0' + buf[i-1]);
113 | }
114 |
115 |
116 | void printInteger(long n)
117 | {
118 | if (n < 0) {
119 | serial_write('-');
120 | print_uint32_base10(-n);
121 | } else {
122 | print_uint32_base10(n);
123 | }
124 | }
125 |
126 |
127 | // Convert float to string by immediately converting to a long integer, which contains
128 | // more digits than a float. Number of decimal places, which are tracked by a counter,
129 | // may be set by the user. The integer is then efficiently converted to a string.
130 | // NOTE: AVR '%' and '/' integer operations are very efficient. Bitshifting speed-up
131 | // techniques are actually just slightly slower. Found this out the hard way.
132 | void printFloat(float n, uint8_t decimal_places)
133 | {
134 | if (n < 0) {
135 | serial_write('-');
136 | n = -n;
137 | }
138 |
139 | uint8_t decimals = decimal_places;
140 | while (decimals >= 2) { // Quickly convert values expected to be E0 to E-4.
141 | n *= 100;
142 | decimals -= 2;
143 | }
144 | if (decimals) { n *= 10; }
145 | n += 0.5; // Add rounding factor. Ensures carryover through entire value.
146 |
147 | // Generate digits backwards and store in string.
148 | unsigned char buf[10];
149 | uint8_t i = 0;
150 | uint32_t a = (long)n;
151 | buf[decimal_places] = '.'; // Place decimal point, even if decimal places are zero.
152 | while(a > 0) {
153 | if (i == decimal_places) { i++; } // Skip decimal point location
154 | buf[i++] = (a % 10) + '0'; // Get digit
155 | a /= 10;
156 | }
157 | while (i < decimal_places) {
158 | buf[i++] = '0'; // Fill in zeros to decimal point for (n < 1)
159 | }
160 | if (i == decimal_places) { // Fill in leading zero, if needed.
161 | i++;
162 | buf[i++] = '0';
163 | }
164 |
165 | // Print the generated string.
166 | for (; i > 0; i--)
167 | serial_write(buf[i-1]);
168 | }
169 |
170 |
171 | // Floating value printing handlers for special variables types used in Grbl and are defined
172 | // in the config.h.
173 | // - CoordValue: Handles all position or coordinate values in inches or mm reporting.
174 | // - RateValue: Handles feed rate and current velocity in inches or mm reporting.
175 | // - SettingValue: Handles all floating point settings values (always in mm.)
176 | void printFloat_CoordValue(float n) {
177 | if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) {
178 | printFloat(n*INCH_PER_MM,N_DECIMAL_COORDVALUE_INCH);
179 | } else {
180 | printFloat(n,N_DECIMAL_COORDVALUE_MM);
181 | }
182 | }
183 |
184 | void printFloat_RateValue(float n) {
185 | if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) {
186 | printFloat(n*INCH_PER_MM,N_DECIMAL_RATEVALUE_INCH);
187 | } else {
188 | printFloat(n,N_DECIMAL_RATEVALUE_MM);
189 | }
190 | }
191 |
192 | void printFloat_SettingValue(float n) { printFloat(n,N_DECIMAL_SETTINGVALUE); }
193 |
194 | void printFloat_RPMValue(float n) { printFloat(n,N_DECIMAL_RPMVALUE); }
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 |
--------------------------------------------------------------------------------
/src/grbl/print.h:
--------------------------------------------------------------------------------
1 | /*
2 | print.h - Functions for formatting output strings
3 | Part of Grbl
4 |
5 | Copyright (c) 2011-2015 Sungeun K. Jeon
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 uint8 variable with base and number of desired digits.
35 | void print_unsigned_int8(uint8_t n, uint8_t base, uint8_t digits);
36 |
37 | // Prints an uint8 variable in base 2.
38 | void print_uint8_base2(uint8_t n);
39 |
40 | // Prints an uint8 variable in base 10.
41 | void print_uint8_base10(uint8_t n);
42 |
43 | void printFloat(float n, uint8_t decimal_places);
44 |
45 | // Floating value printing handlers for special variables types used in Grbl.
46 | // - CoordValue: Handles all position or coordinate values in inches or mm reporting.
47 | // - RateValue: Handles feed rate and current velocity in inches or mm reporting.
48 | // - SettingValue: Handles all floating point settings values (always in mm.)
49 | // - RPMValue: Handles spindle RPM values in settings and reports.
50 | void printFloat_CoordValue(float n);
51 | void printFloat_RateValue(float n);
52 | void printFloat_SettingValue(float n);
53 | void printFloat_RPMValue(float n);
54 |
55 | // Debug tool to print free memory in bytes at the called point. Not used otherwise.
56 | void printFreeMemory();
57 |
58 | #endif
--------------------------------------------------------------------------------
/src/grbl/probe.c:
--------------------------------------------------------------------------------
1 | /*
2 | probe.c - code pertaining to probing methods
3 | Part of Grbl
4 |
5 | Copyright (c) 2014-2015 Sungeun K. Jeon
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 | // PROBE_DDR &= ~(PROBE_MASK); // Configure as input pins
32 | // #ifdef DISABLE_PROBE_PIN_PULL_UP
33 | // PROBE_PORT &= ~(PROBE_MASK); // Normal low operation. Requires external pull-down.
34 | // #else
35 | // PROBE_PORT |= PROBE_MASK; // Enable internal pull-up resistors. Normal high operation.
36 | // #endif
37 |
38 | set_as_input(PROBE);
39 | probe_configure_invert_mask(false); // Initialize invert mask. Re-updated during use.
40 | }
41 |
42 |
43 | // Called by probe_init() and the mc_probe() routines. Sets up the probe pin invert mask to
44 | // appropriately set the pin logic according to setting for normal-high/normal-low operation
45 | // and the probing cycle modes for toward-workpiece/away-from-workpiece.
46 | void probe_configure_invert_mask(uint8_t is_probe_away)
47 | {
48 | probe_invert_mask = 0; // Initialize as zero.
49 | if (bit_isfalse(settings.flags,BITFLAG_INVERT_PROBE_PIN)) { probe_invert_mask ^= PROBE_MASK; }
50 | if (is_probe_away) { probe_invert_mask ^= PROBE_MASK; }
51 | }
52 |
53 |
54 | // Returns the probe pin state. Triggered = true. Called by gcode parser and probe state monitor.
55 | //uint8_t probe_get_state() { return((PROBE_PIN & PROBE_MASK) ^ probe_invert_mask); }
56 |
57 | uint8_t probe_get_state(void)
58 | {
59 | uint8_t pin = GPIO_ReadInputDataBit(PROBE);
60 |
61 | if(probe_invert_mask) pin = !pin;
62 |
63 | return pin;
64 | }
65 |
66 | // Monitors probe pin state and records the system position when detected. Called by the
67 | // stepper ISR per ISR tick.
68 | // NOTE: This function must be extremely efficient as to not bog down the stepper ISR.
69 | void probe_state_monitor()
70 | {
71 | if (sys_probe_state == PROBE_ACTIVE) {
72 | if (probe_get_state()) {
73 | sys_probe_state = PROBE_OFF;
74 | memcpy(sys.probe_position, sys.position, sizeof(sys.position));
75 | bit_true(sys_rt_exec_state, EXEC_MOTION_CANCEL);
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/grbl/probe.h:
--------------------------------------------------------------------------------
1 | /*
2 | probe.h - code pertaining to probing methods
3 | Part of Grbl
4 |
5 | Copyright (c) 2014-2015 Sungeun K. Jeon
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 |
--------------------------------------------------------------------------------
/src/grbl/protocol.h:
--------------------------------------------------------------------------------
1 | /*
2 | protocol.h - controls Grbl execution protocol and procedures
3 | Part of Grbl
4 |
5 | Copyright (c) 2011-2015 Sungeun K. Jeon
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 | // Notify the stepper subsystem to start executing the g-code program in buffer.
44 | // void protocol_cycle_start();
45 |
46 | // Reinitializes the buffer after a feed hold for a resume.
47 | // void protocol_cycle_reinitialize();
48 |
49 | // Initiates a feed hold of the running program
50 | // void protocol_feed_hold();
51 |
52 | // Executes the auto cycle feature, if enabled.
53 | void protocol_auto_cycle_start();
54 |
55 | // Block until all buffered steps are executed
56 | void protocol_buffer_synchronize();
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/src/grbl/report.h:
--------------------------------------------------------------------------------
1 | /*
2 | report.h - reporting and messaging methods
3 | Part of Grbl
4 |
5 | Copyright (c) 2012-2015 Sungeun K. Jeon
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.
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_ALARM_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 |
39 | #define STATUS_GCODE_UNSUPPORTED_COMMAND 20
40 | #define STATUS_GCODE_MODAL_GROUP_VIOLATION 21
41 | #define STATUS_GCODE_UNDEFINED_FEED_RATE 22
42 | #define STATUS_GCODE_COMMAND_VALUE_NOT_INTEGER 23
43 | #define STATUS_GCODE_AXIS_COMMAND_CONFLICT 24
44 | #define STATUS_GCODE_WORD_REPEATED 25
45 | #define STATUS_GCODE_NO_AXIS_WORDS 26
46 | #define STATUS_GCODE_INVALID_LINE_NUMBER 27
47 | #define STATUS_GCODE_VALUE_WORD_MISSING 28
48 | #define STATUS_GCODE_UNSUPPORTED_COORD_SYS 29
49 | #define STATUS_GCODE_G53_INVALID_MOTION_MODE 30
50 | #define STATUS_GCODE_AXIS_WORDS_EXIST 31
51 | #define STATUS_GCODE_NO_AXIS_WORDS_IN_PLANE 32
52 | #define STATUS_GCODE_INVALID_TARGET 33
53 | #define STATUS_GCODE_ARC_RADIUS_ERROR 34
54 | #define STATUS_GCODE_NO_OFFSETS_IN_PLANE 35
55 | #define STATUS_GCODE_UNUSED_WORDS 36
56 | #define STATUS_GCODE_G43_DYNAMIC_AXIS_ERROR 37
57 |
58 | // Define Grbl alarm codes.
59 | #define ALARM_HARD_LIMIT_ERROR 1
60 | #define ALARM_SOFT_LIMIT_ERROR 2
61 | #define ALARM_ABORT_CYCLE 3
62 | #define ALARM_PROBE_FAIL 4
63 | #define ALARM_HOMING_FAIL 5
64 | #define ALARM_STEPPER_FAIL 6
65 |
66 | // Define Grbl feedback message codes.
67 | #define MESSAGE_CRITICAL_EVENT 1
68 | #define MESSAGE_ALARM_LOCK 2
69 | #define MESSAGE_ALARM_UNLOCK 3
70 | #define MESSAGE_ENABLED 4
71 | #define MESSAGE_DISABLED 5
72 | #define MESSAGE_SAFETY_DOOR_AJAR 6
73 | #define MESSAGE_PROGRAM_END 7
74 | #define MESSAGE_RESTORE_DEFAULTS 8
75 |
76 | // Prints system status messages.
77 | void report_status_message(uint8_t status_code);
78 |
79 | // Prints system alarm messages.
80 | void report_alarm_message(int8_t alarm_code);
81 |
82 | // Prints miscellaneous feedback messages.
83 | void report_feedback_message(uint8_t message_code);
84 |
85 | // Prints welcome message
86 | void report_init_message();
87 |
88 | // Prints Grbl help and current global settings
89 | void report_grbl_help();
90 |
91 | // Prints Grbl global settings
92 | void report_grbl_settings();
93 |
94 | // Prints an echo of the pre-parsed line received right before execution.
95 | void report_echo_line_received(char *line);
96 |
97 | // Prints realtime status report
98 | void report_realtime_status();
99 |
100 | // Prints recorded probe position
101 | void report_probe_parameters();
102 |
103 | // Prints Grbl NGC parameters (coordinate offsets, probe)
104 | void report_ngc_parameters();
105 |
106 | // Prints current g-code parser mode state
107 | void report_gcode_modes();
108 |
109 | // Prints startup line
110 | void report_startup_line(uint8_t n, char *line);
111 |
112 | // Prints build info and user info
113 | void report_build_info(char *line);
114 |
115 | #endif
116 |
--------------------------------------------------------------------------------
/src/grbl/serial.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IRNAS/grbl_stm32/5739935add750fc07cdeccda526196cb2e193ba8/src/grbl/serial.c
--------------------------------------------------------------------------------
/src/grbl/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-2015 Sungeun K. Jeon
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 |
26 | #ifndef RX_BUFFER_SIZE
27 | #define RX_BUFFER_SIZE 128
28 | #endif
29 | #ifndef TX_BUFFER_SIZE
30 | #define TX_BUFFER_SIZE 64
31 | #endif
32 |
33 | #define SERIAL_NO_DATA 0xff
34 |
35 | #ifdef ENABLE_XONXOFF
36 | #define RX_BUFFER_FULL 96 // XOFF high watermark
37 | #define RX_BUFFER_LOW 64 // XON low watermark
38 | #define SEND_XOFF 1
39 | #define SEND_XON 2
40 | #define XOFF_SENT 3
41 | #define XON_SENT 4
42 | #define XOFF_CHAR 0x13
43 | #define XON_CHAR 0x11
44 | #endif
45 |
46 | void serial_init();
47 |
48 | // Writes one byte to the TX serial buffer. Called by main program.
49 | void serial_write(uint8_t data);
50 |
51 | // Fetches the first byte in the serial read buffer. Called by main program.
52 | uint8_t serial_read();
53 |
54 | // Reset and empty data in read buffer. Used by e-stop and reset.
55 | void serial_reset_read_buffer();
56 |
57 | // Returns the number of bytes used in the RX serial buffer.
58 | uint8_t serial_get_rx_buffer_count();
59 |
60 | // Returns the number of bytes used in the TX serial buffer.
61 | // NOTE: Not used except for debugging and ensuring no TX bottlenecks.
62 | uint8_t serial_get_tx_buffer_count();
63 |
64 | #endif
65 |
--------------------------------------------------------------------------------
/src/grbl/settings.h:
--------------------------------------------------------------------------------
1 | /*
2 | settings.h - eeprom configuration handling
3 | Part of Grbl
4 |
5 | Copyright (c) 2011-2015 Sungeun K. Jeon
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_AUTO_START bit(1) // Obsolete. Don't alter to keep back compatibility.
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 status reporting boolean enable bit flags in settings.status_report_mask
43 | #define BITFLAG_RT_STATUS_MACHINE_POSITION bit(0)
44 | #define BITFLAG_RT_STATUS_WORK_POSITION bit(1)
45 | #define BITFLAG_RT_STATUS_PLANNER_BUFFER bit(2)
46 | #define BITFLAG_RT_STATUS_SERIAL_RX bit(3)
47 | #define BITFLAG_RT_STATUS_LIMIT_PINS bit(4)
48 | #define BITFLAG_RT_STATUS_PROBE_PIN bit(5)
49 | #define BITFLAG_RT_STATUS_CONTROL_PINS bit(6)
50 |
51 | // Define settings restore bitflags.
52 | #define SETTINGS_RESTORE_ALL 0xFF // All bitflags
53 | #define SETTINGS_RESTORE_DEFAULTS bit(0)
54 | #define SETTINGS_RESTORE_PARAMETERS bit(1)
55 | #define SETTINGS_RESTORE_STARTUP_LINES bit(2)
56 | #define SETTINGS_RESTORE_BUILD_INFO bit(3)
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 |
67 | // Define EEPROM address indexing for coordinate parameters
68 | #define N_COORDINATE_SYSTEM 6 // Number of supported work coordinate systems (from index 1)
69 | #define SETTING_INDEX_NCOORD N_COORDINATE_SYSTEM+1 // Total number of system stored (from index 0)
70 | // NOTE: Work coordinate indices are (0=G54, 1=G55, ... , 6=G59)
71 | #define SETTING_INDEX_G28 N_COORDINATE_SYSTEM // Home position 1
72 | #define SETTING_INDEX_G30 N_COORDINATE_SYSTEM+1 // Home position 2
73 | // #define SETTING_INDEX_G92 N_COORDINATE_SYSTEM+2 // Coordinate offset (G92.2,G92.3 not supported)
74 |
75 | // Define Grbl axis settings numbering scheme. Starts at START_VAL, every INCREMENT, over N_SETTINGS.
76 | #define AXIS_N_SETTINGS 4
77 | #define AXIS_SETTINGS_START_VAL 100 // NOTE: Reserving settings values >= 100 for axis settings. Up to 255.
78 | #define AXIS_SETTINGS_INCREMENT 10 // Must be greater than the number of axis settings
79 |
80 | // Global persistent settings (Stored from byte EEPROM_ADDR_GLOBAL onwards)
81 | typedef struct {
82 | // Axis settings
83 | float steps_per_mm[N_AXIS];
84 | float max_rate[N_AXIS];
85 | float acceleration[N_AXIS];
86 | float max_travel[N_AXIS];
87 |
88 | // Remaining Grbl settings
89 | uint8_t pulse_microseconds;
90 | uint8_t step_invert_mask;
91 | uint8_t dir_invert_mask;
92 | uint8_t stepper_idle_lock_time; // If max value 255, steppers do not disable.
93 | uint8_t status_report_mask; // Mask to indicate desired report data.
94 | float junction_deviation;
95 | float arc_tolerance;
96 |
97 | float rpm_max;
98 | float rpm_min;
99 |
100 | uint8_t flags; // Contains default boolean settings
101 |
102 | uint8_t homing_dir_mask;
103 | float homing_feed_rate;
104 | float homing_seek_rate;
105 | uint16_t homing_debounce_delay;
106 | float homing_pulloff;
107 | } settings_t;
108 | extern settings_t settings;
109 |
110 | // Initialize the configuration subsystem (load settings from EEPROM)
111 | void settings_init();
112 |
113 | // Helper function to clear and restore EEPROM defaults
114 | void settings_restore(uint8_t restore_flag);
115 |
116 | // A helper method to set new settings from command line
117 | uint8_t settings_store_global_setting(uint8_t parameter, float value);
118 |
119 | // Stores the protocol line variable as a startup line in EEPROM
120 | void settings_store_startup_line(uint8_t n, char *line);
121 |
122 | // Reads an EEPROM startup line to the protocol line variable
123 | uint8_t settings_read_startup_line(uint8_t n, char *line);
124 |
125 | // Stores build info user-defined string
126 | void settings_store_build_info(char *line);
127 |
128 | // Reads build info user-defined string
129 | uint8_t settings_read_build_info(char *line);
130 |
131 | // Writes selected coordinate data to EEPROM
132 | void settings_write_coord_data(uint8_t coord_select, float *coord_data);
133 |
134 | // Reads selected coordinate data from EEPROM
135 | uint8_t settings_read_coord_data(uint8_t coord_select, float *coord_data);
136 |
137 | // Returns the step pin mask according to Grbl's internal axis numbering
138 | uint8_t get_step_pin_mask(uint8_t i);
139 |
140 | // Returns the direction pin mask according to Grbl's internal axis numbering
141 | uint8_t get_direction_pin_mask(uint8_t i);
142 |
143 | // Returns the limit pin mask according to Grbl's internal axis numbering
144 | uint8_t get_limit_pin_mask(uint8_t i);
145 |
146 |
147 | #endif
148 |
--------------------------------------------------------------------------------
/src/grbl/spindle_control.h:
--------------------------------------------------------------------------------
1 | /*
2 | spindle_control.h - spindle control methods
3 | Part of Grbl
4 |
5 | Copyright (c) 2012-2015 Sungeun K. Jeon
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 |
26 | // Initializes spindle pins and hardware PWM, if enabled.
27 | void spindle_init();
28 |
29 | // Sets spindle direction and spindle rpm via PWM, if enabled.
30 | void spindle_run(uint8_t direction, float rpm);
31 |
32 | void spindle_set_state(uint8_t state, float rpm);
33 |
34 | // Kills spindle.
35 | void spindle_stop();
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/src/grbl/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-2015 Sungeun K. Jeon
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 | #define SEGMENT_BUFFER_SIZE 6
27 | #endif
28 |
29 | // Initialize and setup the stepper motor subsystem
30 | void stepper_init();
31 |
32 | // Enable steppers, but cycle does not start unless called by motion control or realtime command.
33 | void st_wake_up();
34 |
35 | // Immediately disables steppers
36 | void st_go_idle();
37 |
38 | // Generate the step and direction port invert masks.
39 | void st_generate_step_dir_invert_masks();
40 |
41 | // Reset the stepper subsystem variables
42 | void st_reset();
43 |
44 | // Changes the run state of the step segment buffer to execute the special parking motion.
45 | void st_parking_setup_buffer();
46 |
47 | // Restores the step segment buffer to the normal run state after a parking motion.
48 | void st_parking_restore_buffer();
49 |
50 | // Reloads step segment buffer. Called continuously by realtime execution system.
51 | void st_prep_buffer();
52 |
53 | // Called by planner_recalculate() when the executing block is updated by the new plan.
54 | void st_update_plan_block_parameters();
55 |
56 | // Called by realtime status reporting if realtime rate reporting is enabled in config.h.
57 | #ifdef REPORT_REALTIME_RATE
58 | float st_get_realtime_rate();
59 | #endif
60 |
61 | #endif
62 |
--------------------------------------------------------------------------------
/src/syscalls.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IRNAS/grbl_stm32/5739935add750fc07cdeccda526196cb2e193ba8/src/syscalls.c
--------------------------------------------------------------------------------
/src/system_stm32f4xx.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IRNAS/grbl_stm32/5739935add750fc07cdeccda526196cb2e193ba8/src/system_stm32f4xx.c
--------------------------------------------------------------------------------
/src/util/delay.c:
--------------------------------------------------------------------------------
1 | /*
2 | delay.c - replacement for the avr library of the same name to provide
3 | dummy functions
4 |
5 | Part of Grbl Simulator
6 |
7 | Copyright (c) 2012 Jens Geisler
8 | Copyright (c) 2015 Adam Shelly
9 |
10 | Grbl is free software: you can redistribute it and/or modify
11 | it under the terms of the GNU General Public License as published by
12 | the Free Software Foundation, either version 3 of the License, or
13 | (at your option) any later version.
14 |
15 | Grbl is distributed in the hope that it will be useful,
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | GNU General Public License for more details.
19 |
20 | You should have received a copy of the GNU General Public License
21 | along with Grbl. If not, see .
22 | */
23 |
24 | // for 100 MHz STM32F4
25 | #define COUNTS_PER_MICROSECOND 33
26 | void _delay_us(int d)
27 | {
28 | unsigned int count = d * COUNTS_PER_MICROSECOND - 2;
29 | __asm volatile(" mov r0, %[count] \n\t"
30 | "1: subs r0, #1 \n\t"
31 | " bhi 1b \n\t"
32 | :
33 | : [count] "r" (count)
34 | : "r0");
35 | }
36 |
37 | void _delay_ms(int d)
38 | {
39 | while (d--) _delay_us(999);
40 | }
41 |
--------------------------------------------------------------------------------
/src/util/delay.h:
--------------------------------------------------------------------------------
1 | /*
2 | delay.h - replacement for the avr include of the same name to provide
3 | dummy functions
4 |
5 | Part of Grbl Simulator
6 |
7 | Copyright (c) 2012 Jens Geisler
8 |
9 | Grbl is free software: you can redistribute it and/or modify
10 | it under the terms of the GNU General Public License as published by
11 | the Free Software Foundation, either version 3 of the License, or
12 | (at your option) any later version.
13 |
14 | Grbl is distributed in the hope that it will be useful,
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | GNU General Public License for more details.
18 |
19 | You should have received a copy of the GNU General Public License
20 | along with Grbl. If not, see .
21 | */
22 |
23 | #ifndef delay_h
24 | #define delay_h
25 |
26 | void _delay_ms(int i);
27 | void _delay_us(int i);
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/src/util/floatunsisf.c:
--------------------------------------------------------------------------------
1 | float __floatunsisf (unsigned long v) {
2 | return v;
3 | }
--------------------------------------------------------------------------------