├── usb
├── CVS
│ ├── Root
│ ├── Repository
│ ├── Entries.Extra
│ ├── Entries.Extra.Old
│ ├── Entries
│ └── Entries.Old
├── platform_config.h
├── usb_pwr.h
├── hw_config.h
├── stm32f10x_it.h
├── usb_desc.h
├── usb_prop.h
├── usb_endp.c
├── usb_istr.h
└── hw_config.c
├── util
├── CVS
│ ├── Root
│ ├── Repository
│ ├── Entries.Extra.Old
│ ├── Entries.Extra
│ ├── Entries.Old
│ └── Entries
└── stm32eeprom.h
├── inc
├── stm32f10x.h
├── system_stm32f10x.h
└── stm32f10x_conf.h
├── SPL
├── src
│ ├── stm32f10x_flash.c
│ ├── stm32f10x_i2c.c
│ ├── stm32f10x_usart.c
│ ├── stm32f10x_crc.c
│ ├── stm32f10x_iwdg.c
│ ├── stm32f10x_dbgmcu.c
│ └── stm32f10x_wwdg.c
└── inc
│ ├── stm32f10x_crc.h
│ ├── stm32f10x_wwdg.h
│ ├── stm32f10x_dbgmcu.h
│ ├── stm32f10x_iwdg.h
│ ├── stm32f10x_rtc.h
│ ├── stm32f10x_pwr.h
│ └── stm32f10x_cec.h
├── GRBL_STM32.elay
├── .gitignore
├── grbl
├── jog.h
├── examples
│ ├── grblUpload
│ │ ├── license.txt
│ │ └── grblUpload.ino
│ └── grblWrite_BuildInfo
│ │ ├── license.txt
│ │ └── grblWrite_BuildInfo.ino
├── eeprom.h
├── limits.h
├── cpu_map.h
├── coolant_control.h
├── probe.h
├── print.h
├── jog.c
├── serial.h
├── protocol.h
├── stepper.h
├── probe.c
├── spindle_control.h
├── motion_control.h
├── nuts_bolts.h
├── grbl.h
├── coolant_control.c
├── eeprom.c
├── report.h
├── print.c
├── cpu_map_stm32.h
├── nuts_bolts.c
└── settings.h
├── stm_usb_fs_lib
├── inc
│ ├── usb_int.h
│ ├── usb_mem.h
│ ├── usb_sil.h
│ ├── usb_lib.h
│ ├── usb_init.h
│ ├── usb_type.h
│ └── usb_def.h
└── src
│ ├── usb_init.c
│ ├── usb_mem.c
│ ├── usb_sil.c
│ └── usb_int.c
├── src
└── main.c
├── stm32f103c8_flash.ld
└── stm32f103c8_sram.ld
/usb/CVS/Root:
--------------------------------------------------------------------------------
1 | :local:E:/CVSRep
2 |
--------------------------------------------------------------------------------
/util/CVS/Root:
--------------------------------------------------------------------------------
1 | :local:E:/CVSRep
2 |
--------------------------------------------------------------------------------
/usb/CVS/Repository:
--------------------------------------------------------------------------------
1 | Code/grbl1.0d/stm32grbl/usb
2 |
--------------------------------------------------------------------------------
/util/CVS/Repository:
--------------------------------------------------------------------------------
1 | Code/grbl1.0d/stm32grbl/util
2 |
--------------------------------------------------------------------------------
/util/CVS/Entries.Extra.Old:
--------------------------------------------------------------------------------
1 | /stm32f10x_it.c////
2 | /stm32eeprom.h////
3 |
--------------------------------------------------------------------------------
/inc/stm32f10x.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dungjk/grbl-stm32/HEAD/inc/stm32f10x.h
--------------------------------------------------------------------------------
/util/CVS/Entries.Extra:
--------------------------------------------------------------------------------
1 | /stm32eeprom.h///1470196397/
2 | /stm32f10x_it.c///1470196397/
3 |
--------------------------------------------------------------------------------
/SPL/src/stm32f10x_flash.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dungjk/grbl-stm32/HEAD/SPL/src/stm32f10x_flash.c
--------------------------------------------------------------------------------
/SPL/src/stm32f10x_i2c.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dungjk/grbl-stm32/HEAD/SPL/src/stm32f10x_i2c.c
--------------------------------------------------------------------------------
/SPL/src/stm32f10x_usart.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dungjk/grbl-stm32/HEAD/SPL/src/stm32f10x_usart.c
--------------------------------------------------------------------------------
/util/CVS/Entries.Old:
--------------------------------------------------------------------------------
1 | /stm32f10x_it.c/0/Initial stm32f10x_it.c//
2 | /stm32eeprom.h/0/Initial stm32eeprom.h//
3 | D
4 |
--------------------------------------------------------------------------------
/util/CVS/Entries:
--------------------------------------------------------------------------------
1 | /stm32eeprom.h/1.1/Sun Jul 3 23:54:54 2016//
2 | /stm32f10x_it.c/1.1/Tue Mar 8 07:10:30 2016//
3 | D
4 |
--------------------------------------------------------------------------------
/usb/platform_config.h:
--------------------------------------------------------------------------------
1 | #ifndef __PLATFORM_CONFIG_H
2 | #define __PLATFORM_CONFIG_H
3 |
4 | #include "stm32f10x.h"
5 |
6 | #endif /* __PLATFORM_CONFIG_H */
7 |
8 |
--------------------------------------------------------------------------------
/usb/CVS/Entries.Extra:
--------------------------------------------------------------------------------
1 | /usb_pwr.h///1468199674/
2 | /usb_prop.h///1468199675/
3 | /usb_istr.h///1468199675/
4 | /usb_desc.h///1468199675/
5 | /usb_conf.h///1468199675/
6 | /stm32f10x_it.h///1468199675/
7 | /platform_config.h///1468199675/
8 | /hw_config.h///1468199675/
9 | /usb_pwr.c///1468199675/
10 | /usb_desc.c///1468199675/
11 | /hw_config.c///1468199675/
12 | /usb_istr.c///1468199675/
13 | /usb_endp.c///1471019589/
14 | /usb_prop.c///1468199675/
15 |
--------------------------------------------------------------------------------
/usb/CVS/Entries.Extra.Old:
--------------------------------------------------------------------------------
1 | /usb_pwr.h///1468199674/
2 | /usb_prop.h///1468199675/
3 | /usb_istr.h///1468199675/
4 | /usb_desc.h///1468199675/
5 | /usb_conf.h///1468199675/
6 | /stm32f10x_it.h///1468199675/
7 | /platform_config.h///1468199675/
8 | /hw_config.h///1468199675/
9 | /usb_pwr.c///1468199675/
10 | /usb_prop.c///1468199675/
11 | /usb_desc.c///1468199675/
12 | /hw_config.c///1468199675/
13 | /usb_istr.c///1468199675/
14 | /usb_endp.c///1471019589/
15 |
--------------------------------------------------------------------------------
/GRBL_STM32.elay:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/usb/CVS/Entries:
--------------------------------------------------------------------------------
1 | /usb_pwr.h/1.1/Sat Mar 19 10:14:24 2011//
2 | /usb_prop.h/1.1/Sat Mar 19 10:14:24 2011//
3 | /usb_istr.h/1.1/Sat Mar 19 10:14:24 2011//
4 | /usb_desc.h/1.1/Fri Mar 30 21:03:34 2012//
5 | /usb_conf.h/1.1/Sat Mar 19 10:14:24 2011//
6 | /stm32f10x_it.h/1.1/Sat Mar 19 10:14:24 2011//
7 | /platform_config.h/1.1/Tue Mar 1 04:44:10 2016//
8 | /hw_config.h/1.1/Wed Jun 1 01:57:17 2016//
9 | /usb_pwr.c/1.1/Sat Mar 19 10:14:26 2011//
10 | /usb_desc.c/1.1/Wed Jun 1 01:53:39 2016//
11 | /hw_config.c/1.1/Sat Nov 19 06:07:40 2016//
12 | /usb_istr.c/1.1/Wed Nov 16 07:23:56 2016//
13 | /usb_endp.c/1.3/Mon Nov 21 06:19:40 2016//
14 | /usb_prop.c/1.1/Mon Nov 21 07:52:24 2016//
15 | D
16 |
--------------------------------------------------------------------------------
/usb/CVS/Entries.Old:
--------------------------------------------------------------------------------
1 | /usb_pwr.h/1.1/Sat Mar 19 10:14:24 2011//
2 | /usb_prop.h/1.1/Sat Mar 19 10:14:24 2011//
3 | /usb_istr.h/1.1/Sat Mar 19 10:14:24 2011//
4 | /usb_desc.h/1.1/Fri Mar 30 21:03:34 2012//
5 | /usb_conf.h/1.1/Sat Mar 19 10:14:24 2011//
6 | /stm32f10x_it.h/1.1/Sat Mar 19 10:14:24 2011//
7 | /platform_config.h/1.1/Tue Mar 1 04:44:10 2016//
8 | /hw_config.h/1.1/Wed Jun 1 01:57:17 2016//
9 | /usb_pwr.c/1.1/Sat Mar 19 10:14:26 2011//
10 | /usb_prop.c/1.1/Sat Mar 31 16:25:44 2012//
11 | /usb_desc.c/1.1/Wed Jun 1 01:53:39 2016//
12 | /hw_config.c/1.1/Sat Nov 19 06:07:40 2016//
13 | /usb_istr.c/1.1/Wed Nov 16 07:23:56 2016//
14 | /usb_endp.c/1.3/Mon Nov 21 06:19:40 2016//
15 | D
16 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Prerequisites
2 | *.d
3 |
4 | # Object files
5 | *.o
6 | *.ko
7 | *.obj
8 | *.elf
9 |
10 | # Linker output
11 | *.ilk
12 | *.map
13 | *.exp
14 |
15 | # Precompiled Headers
16 | *.gch
17 | *.pch
18 |
19 | # Libraries
20 | *.lib
21 | *.a
22 | *.la
23 | *.lo
24 |
25 | # Shared objects (inc. Windows DLLs)
26 | *.dll
27 | *.so
28 | *.so.*
29 | *.dylib
30 |
31 | # Executables
32 | *.exe
33 | *.out
34 | *.app
35 | *.i*86
36 | *.x86_64
37 | *.hex
38 |
39 | # Debug files
40 | *.dSYM/
41 | *.su
42 | *.idb
43 | *.pdb
44 |
45 | # Kernel Module Compile Results
46 | *.mod*
47 | *.cmd
48 | .tmp_versions/
49 | modules.order
50 | Module.symvers
51 | Mkfile.old
52 | dkms.conf
53 |
54 | # Visual Studio Code
55 | .vscode
--------------------------------------------------------------------------------
/grbl/jog.h:
--------------------------------------------------------------------------------
1 | /*
2 | jog.h - Jogging methods
3 | Part of Grbl
4 |
5 | Copyright (c) 2016 Sungeun K. Jeon for Gnea Research LLC
6 |
7 | Grbl is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Grbl is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Grbl. If not, see .
19 | */
20 |
21 | #ifndef jog_h
22 | #define jog_h
23 |
24 | #include "gcode.h"
25 |
26 | // System motion line numbers must be zero.
27 | #define JOG_LINE_NUMBER 0
28 |
29 | // Sets up valid jog motion received from g-code parser, checks for soft-limits, and executes the jog.
30 | uint8_t jog_execute(plan_line_data_t *pl_data, parser_block_t *gc_block);
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/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.
--------------------------------------------------------------------------------
/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 | void eeprom_init();
25 | unsigned char eeprom_get_char(unsigned int addr);
26 | void eeprom_put_char(unsigned int addr, unsigned char new_value);
27 | void memcpy_to_eeprom_with_checksum(unsigned int destination, char *source, unsigned int size);
28 | int memcpy_from_eeprom_with_checksum(char *destination, unsigned int source, unsigned int size);
29 |
30 | #endif
31 |
--------------------------------------------------------------------------------
/grbl/examples/grblWrite_BuildInfo/license.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Sungeun K. Jeon for Gnea Research LLC
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.
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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-2016 Sungeun K. Jeon for Gnea Research LLC
6 | Copyright (c) 2009-2011 Simen Svale Skogsrud
7 |
8 | Grbl is free software: you can redistribute it and/or modify
9 | it under the terms of the GNU General Public License as published by
10 | the Free Software Foundation, either version 3 of the License, or
11 | (at your option) any later version.
12 |
13 | Grbl is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU General Public License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with Grbl. If not, see .
20 | */
21 |
22 | #ifndef limits_h
23 | #define limits_h
24 |
25 |
26 | // Initialize the limits module
27 | void limits_init();
28 |
29 | // Disables hard limits.
30 | void limits_disable();
31 |
32 | // Returns limit state as a bit-wise uint8 variable.
33 | uint8_t limits_get_state();
34 |
35 | // Perform one portion of the homing cycle based on the input settings.
36 | void limits_go_home(uint8_t cycle_mask);
37 |
38 | // Check for soft limit violations
39 | void limits_soft_check(float *target);
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/grbl/cpu_map.h:
--------------------------------------------------------------------------------
1 | /*
2 | cpu_map.h - CPU and pin mapping configuration file
3 | Part of Grbl
4 |
5 | Copyright (c) 2012-2016 Sungeun K. Jeon for Gnea Research LLC
6 |
7 | Grbl is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Grbl is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Grbl. If not, see .
19 | */
20 |
21 | /* The cpu_map.h files serve as a central pin mapping selection file for different
22 | processor types or alternative pin layouts. This version of Grbl officially supports
23 | only the Arduino Mega328p. */
24 |
25 | #ifndef cpu_map_h
26 | #define cpu_map_h
27 |
28 | #include "cpu_map_stm32.h"
29 |
30 | /*
31 | #ifdef CPU_MAP_CUSTOM_PROC
32 | // For a custom pin map or different processor, copy and edit one of the available cpu
33 | // map files and modify it to your needs. Make sure the defined name is also changed in
34 | // the config.h file.
35 | #endif
36 | */
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/grbl/coolant_control.h:
--------------------------------------------------------------------------------
1 | /*
2 | coolant_control.h - spindle control methods
3 | Part of Grbl
4 |
5 | Copyright (c) 2012-2016 Sungeun K. Jeon for Gnea Research LLC
6 |
7 | Grbl is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Grbl is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Grbl. If not, see .
19 | */
20 |
21 | #ifndef coolant_control_h
22 | #define coolant_control_h
23 |
24 | #define COOLANT_NO_SYNC false
25 | #define COOLANT_FORCE_SYNC true
26 |
27 | #define COOLANT_STATE_DISABLE 0 // Must be zero
28 | #define COOLANT_STATE_FLOOD bit(0)
29 | #define COOLANT_STATE_MIST bit(1)
30 |
31 |
32 | // Initializes coolant control pins.
33 | void coolant_init();
34 |
35 | // Returns current coolant output state. Overrides may alter it from programmed state.
36 | uint8_t coolant_get_state();
37 |
38 | // Immediately disables coolant pins.
39 | void coolant_stop();
40 |
41 | // Sets the coolant pins according to state specified.
42 | void coolant_set_state(uint8_t mode);
43 |
44 | // G-code parser entry-point for setting coolant states. Checks for and executes additional conditions.
45 | void coolant_sync(uint8_t mode);
46 |
47 | #endif
48 |
--------------------------------------------------------------------------------
/grbl/probe.h:
--------------------------------------------------------------------------------
1 | /*
2 | probe.h - code pertaining to probing methods
3 | Part of Grbl
4 |
5 | Copyright (c) 2014-2016 Sungeun K. Jeon for Gnea Research LLC
6 |
7 | Grbl is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Grbl is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Grbl. If not, see .
19 | */
20 |
21 | #ifndef probe_h
22 | #define probe_h
23 |
24 | // Values that define the probing state machine.
25 | #define PROBE_OFF 0 // Probing disabled or not in use. (Must be zero.)
26 | #define PROBE_ACTIVE 1 // Actively watching the input pin.
27 |
28 | // Probe pin initialization routine.
29 | void probe_init();
30 |
31 | // Called by probe_init() and the mc_probe() routines. Sets up the probe pin invert mask to
32 | // appropriately set the pin logic according to setting for normal-high/normal-low operation
33 | // and the probing cycle modes for toward-workpiece/away-from-workpiece.
34 | void probe_configure_invert_mask(uint8_t is_probe_away);
35 |
36 | // Returns probe pin state. Triggered = true. Called by gcode parser and probe state monitor.
37 | uint8_t probe_get_state();
38 |
39 | // Monitors probe pin state and records the system position when detected. Called by the
40 | // stepper ISR per ISR tick.
41 | void probe_state_monitor();
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/stm_usb_fs_lib/inc/usb_int.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
2 | * File Name : usb_int.h
3 | * Author : MCD Application Team
4 | * Version : V3.2.1
5 | * Date : 07/05/2010
6 | * Description : Endpoint CTR (Low and High) interrupt's service routines
7 | * prototypes
8 | ********************************************************************************
9 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
10 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
11 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
12 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
13 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
14 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
15 | *******************************************************************************/
16 |
17 | /* Define to prevent recursive inclusion -------------------------------------*/
18 | #ifndef __USB_INT_H
19 | #define __USB_INT_H
20 |
21 | /* Includes ------------------------------------------------------------------*/
22 | /* Exported types ------------------------------------------------------------*/
23 | /* Exported constants --------------------------------------------------------*/
24 | /* Exported macro ------------------------------------------------------------*/
25 | /* Exported functions ------------------------------------------------------- */
26 | void CTR_LP(void);
27 | void CTR_HP(void);
28 |
29 | /* External variables --------------------------------------------------------*/
30 |
31 | #endif /* __USB_INT_H */
32 |
33 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
34 |
--------------------------------------------------------------------------------
/grbl/print.h:
--------------------------------------------------------------------------------
1 | /*
2 | print.h - Functions for formatting output strings
3 | Part of Grbl
4 |
5 | Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
6 | Copyright (c) 2009-2011 Simen Svale Skogsrud
7 |
8 | Grbl is free software: you can redistribute it and/or modify
9 | it under the terms of the GNU General Public License as published by
10 | the Free Software Foundation, either version 3 of the License, or
11 | (at your option) any later version.
12 |
13 | Grbl is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU General Public License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with Grbl. If not, see .
20 | */
21 |
22 | #ifndef print_h
23 | #define print_h
24 |
25 |
26 | void printString(const char *s);
27 |
28 | void printPgmString(const char *s);
29 |
30 | void printInteger(long n);
31 |
32 | void print_uint32_base10(uint32_t n);
33 |
34 | // Prints an uint8 variable in base 10.
35 | void print_uint8_base10(uint8_t n);
36 |
37 | // Prints an uint8 variable in base 2 with desired number of desired digits.
38 | void print_uint8_base2_ndigit(uint8_t n, uint8_t digits);
39 |
40 | void printFloat(float n, uint8_t decimal_places);
41 |
42 | // Floating value printing handlers for special variables types used in Grbl.
43 | // - CoordValue: Handles all position or coordinate values in inches or mm reporting.
44 | // - RateValue: Handles feed rate and current velocity in inches or mm reporting.
45 | void printFloat_CoordValue(float n);
46 | void printFloat_RateValue(float n);
47 |
48 | // Debug tool to print free memory in bytes at the called point. Not used otherwise.
49 | void printFreeMemory();
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/stm_usb_fs_lib/inc/usb_mem.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
2 | * File Name : usb_mem.h
3 | * Author : MCD Application Team
4 | * Version : V3.2.1
5 | * Date : 07/05/2010
6 | * Description : Utility prototypes functions for memory/PMA transfers
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | /* Define to prevent recursive inclusion -------------------------------------*/
17 | #ifndef __USB_MEM_H
18 | #define __USB_MEM_H
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | /* Exported types ------------------------------------------------------------*/
22 | /* Exported constants --------------------------------------------------------*/
23 | /* Exported macro ------------------------------------------------------------*/
24 | /* Exported functions ------------------------------------------------------- */
25 | void UserToPMABufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
26 | void PMAToUserBufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
27 |
28 | /* External variables --------------------------------------------------------*/
29 |
30 | #endif /*__USB_MEM_H*/
31 |
32 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
33 |
--------------------------------------------------------------------------------
/grbl/jog.c:
--------------------------------------------------------------------------------
1 | /*
2 | jog.h - Jogging methods
3 | Part of Grbl
4 |
5 | Copyright (c) 2016 Sungeun K. Jeon for Gnea Research LLC
6 |
7 | Grbl is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Grbl is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Grbl. If not, see .
19 | */
20 |
21 | #include "grbl.h"
22 |
23 |
24 | // Sets up valid jog motion received from g-code parser, checks for soft-limits, and executes the jog.
25 | uint8_t jog_execute(plan_line_data_t *pl_data, parser_block_t *gc_block)
26 | {
27 | // Initialize planner data struct for jogging motions.
28 | // NOTE: Spindle and coolant are allowed to fully function with overrides during a jog.
29 | pl_data->feed_rate = gc_block->values.f;
30 | pl_data->condition |= PL_COND_FLAG_NO_FEED_OVERRIDE;
31 | #ifdef USE_LINE_NUMBERS
32 | pl_data->line_number = gc_block->values.n;
33 | #endif
34 |
35 | if (bit_istrue(settings.flags, BITFLAG_SOFT_LIMIT_ENABLE)) {
36 | if (system_check_travel_limits(gc_block->values.xyz)) { return(STATUS_TRAVEL_EXCEEDED); }
37 | }
38 |
39 | // Valid jog command. Plan, set state, and execute.
40 | mc_line(gc_block->values.xyz, pl_data);
41 | if (sys.state == STATE_IDLE) {
42 | if (plan_get_current_block() != NULL) { // Check if there is a block to execute.
43 | sys.state = STATE_JOG;
44 | st_prep_buffer();
45 | st_wake_up(); // NOTE: Manual start. No state machine required.
46 | }
47 | }
48 |
49 | return(STATUS_OK);
50 | }
51 |
--------------------------------------------------------------------------------
/stm_usb_fs_lib/inc/usb_sil.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
2 | * File Name : usb_sil.h
3 | * Author : MCD Application Team
4 | * Version : V3.2.1
5 | * Date : 07/05/2010
6 | * Description : Simplified Interface Layer function prototypes.
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | /* Define to prevent recursive inclusion -------------------------------------*/
17 | #ifndef __USB_SIL_H
18 | #define __USB_SIL_H
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | /* Exported types ------------------------------------------------------------*/
22 | /* Exported constants --------------------------------------------------------*/
23 | /* Exported macro ------------------------------------------------------------*/
24 | /* Exported functions ------------------------------------------------------- */
25 |
26 | uint32_t USB_SIL_Init(void);
27 | uint32_t USB_SIL_Write(uint8_t bEpAddr, uint8_t* pBufferPointer, uint32_t wBufferSize);
28 | uint32_t USB_SIL_Read(uint8_t bEpAddr, uint8_t* pBufferPointer);
29 |
30 | /* External variables --------------------------------------------------------*/
31 |
32 | #endif /* __USB_SIL_H */
33 |
34 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
35 |
--------------------------------------------------------------------------------
/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-2016 Sungeun K. Jeon for Gnea Research LLC
6 | Copyright (c) 2009-2011 Simen Svale Skogsrud
7 |
8 | Grbl is free software: you can redistribute it and/or modify
9 | it under the terms of the GNU General Public License as published by
10 | the Free Software Foundation, either version 3 of the License, or
11 | (at your option) any later version.
12 |
13 | Grbl is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU General Public License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with Grbl. If not, see .
20 | */
21 |
22 | #ifndef serial_h
23 | #define serial_h
24 |
25 | #define RX_BUFFER_SIZE 254
26 | #define TX_BUFFER_SIZE 128 // Do not try 256 it will not work for STM32.
27 |
28 | #define SERIAL_NO_DATA 0xff
29 |
30 | void serial_init();
31 |
32 | // Writes one byte to the TX serial buffer. Called by main program.
33 | void serial_write(uint8_t data);
34 |
35 | // Fetches the first byte in the serial read buffer. Called by main program.
36 | uint8_t serial_read();
37 |
38 | // Reset and empty data in read buffer. Used by e-stop and reset.
39 | void serial_reset_read_buffer();
40 |
41 | // Returns the number of bytes available in the RX serial buffer.
42 | uint8_t serial_get_rx_buffer_available();
43 |
44 | // Returns the number of bytes used in the RX serial buffer.
45 | // NOTE: Deprecated. Not used unless classic status reports are enabled in config.h.
46 | uint8_t serial_get_rx_buffer_count();
47 |
48 | // Returns the number of bytes used in the TX serial buffer.
49 | // NOTE: Not used except for debugging and ensuring no TX bottlenecks.
50 | uint8_t serial_get_tx_buffer_count();
51 |
52 | #endif
53 |
--------------------------------------------------------------------------------
/grbl/protocol.h:
--------------------------------------------------------------------------------
1 | /*
2 | protocol.h - controls Grbl execution protocol and procedures
3 | Part of Grbl
4 |
5 | Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
6 | Copyright (c) 2009-2011 Simen Svale Skogsrud
7 |
8 | Grbl is free software: you can redistribute it and/or modify
9 | it under the terms of the GNU General Public License as published by
10 | the Free Software Foundation, either version 3 of the License, or
11 | (at your option) any later version.
12 |
13 | Grbl is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU General Public License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with Grbl. If not, see .
20 | */
21 |
22 | #ifndef protocol_h
23 | #define protocol_h
24 |
25 | // Line buffer size from the serial input stream to be executed.
26 | // NOTE: Not a problem except for extreme cases, but the line buffer size can be too small
27 | // and g-code blocks can get truncated. Officially, the g-code standards support up to 256
28 | // characters. In future versions, this will be increased, when we know how much extra
29 | // memory space we can invest into here or we re-write the g-code parser not to have this
30 | // buffer.
31 | #ifndef LINE_BUFFER_SIZE
32 | #define LINE_BUFFER_SIZE 80
33 | #endif
34 |
35 | // Starts Grbl main loop. It handles all incoming characters from the serial port and executes
36 | // them as they complete. It is also responsible for finishing the initialization procedures.
37 | void protocol_main_loop();
38 |
39 | // Checks and executes a realtime command at various stop points in main program
40 | void protocol_execute_realtime();
41 | void protocol_exec_rt_system();
42 |
43 | // Executes the auto cycle feature, if enabled.
44 | void protocol_auto_cycle_start();
45 |
46 | // Block until all buffered steps are executed
47 | void protocol_buffer_synchronize();
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/util/stm32eeprom.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file EEPROM_Emulation/inc/eeprom.h
4 | * @author MCD Application Team
5 | * @version V3.1.0
6 | * @date 07/27/2009
7 | * @brief This file contains all the functions prototypes for the EEPROM
8 | * emulation firmware library.
9 | ******************************************************************************
10 | * @copy
11 | *
12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18 | *
19 | * © COPYRIGHT 2009 STMicroelectronics
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __EEPROM_H
24 | #define __EEPROM_H
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "stm32f10x_flash.h"
28 |
29 | /* Exported constants --------------------------------------------------------*/
30 | /* Define the STM32F10Xxx Flash page size depending on the used STM32 device */
31 | #if defined (STM32F10X_LD) || defined (STM32F10X_MD)
32 | #define PAGE_SIZE (uint16_t)0x400 /* Page size = 1KByte */
33 | #elif defined (STM32F10X_HD) || defined (STM32F10X_CL)
34 | #define PAGE_SIZE (uint16_t)0x800 /* Page size = 2KByte */
35 | #endif
36 |
37 | /* EEPROM start address in Flash */
38 | #define EEPROM_START_ADDRESS ((uint32_t)0x0801fc00) /* EEPROM emulation start address:
39 | after 64KByte of used Flash memory */
40 |
41 | #endif /* __EEPROM_H */
42 |
43 | /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
44 |
--------------------------------------------------------------------------------
/stm_usb_fs_lib/inc/usb_lib.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
2 | * File Name : usb_lib.h
3 | * Author : MCD Application Team
4 | * Version : V3.2.1
5 | * Date : 07/05/2010
6 | * Description : USB library include files
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | /* Define to prevent recursive inclusion -------------------------------------*/
17 | #ifndef __USB_LIB_H
18 | #define __USB_LIB_H
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "stm32f10x.h"
22 | #include "usb_type.h"
23 | #include "usb_regs.h"
24 | #include "usb_def.h"
25 | #include "usb_core.h"
26 | #include "usb_init.h"
27 | #ifndef STM32F10X_CL
28 | #include "usb_mem.h"
29 | #include "usb_int.h"
30 | #endif /* STM32F10X_CL */
31 |
32 | #include "usb_sil.h"
33 |
34 | #ifdef STM32F10X_CL
35 | #include "otgd_fs_cal.h"
36 | #include "otgd_fs_pcd.h"
37 | #include "otgd_fs_dev.h"
38 | #include "otgd_fs_int.h"
39 | #endif /* STM32F10X_CL */
40 |
41 |
42 | /* Exported types ------------------------------------------------------------*/
43 | /* Exported constants --------------------------------------------------------*/
44 | /* Exported macro ------------------------------------------------------------*/
45 | /* Exported functions ------------------------------------------------------- */
46 | /* External variables --------------------------------------------------------*/
47 |
48 | #endif /* __USB_LIB_H */
49 |
50 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
51 |
--------------------------------------------------------------------------------
/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-2016 Sungeun K. Jeon for Gnea Research LLC
6 | Copyright (c) 2009-2011 Simen Svale Skogsrud
7 |
8 | Grbl is free software: you can redistribute it and/or modify
9 | it under the terms of the GNU General Public License as published by
10 | the Free Software Foundation, either version 3 of the License, or
11 | (at your option) any later version.
12 |
13 | Grbl is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU General Public License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with Grbl. If not, see .
20 | */
21 |
22 | #ifndef stepper_h
23 | #define stepper_h
24 |
25 | #ifndef SEGMENT_BUFFER_SIZE
26 | #define SEGMENT_BUFFER_SIZE 10
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 | float st_get_realtime_rate();
58 |
59 | extern const PORTPINDEF step_pin_mask[N_AXIS];
60 | extern const PORTPINDEF direction_pin_mask[N_AXIS];
61 | extern const PORTPINDEF limit_pin_mask[N_AXIS];
62 |
63 | #endif
64 |
--------------------------------------------------------------------------------
/inc/system_stm32f10x.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file system_stm32f10x.h
4 | * @author MCD Application Team
5 | * @version V3.5.0
6 | * @date 11-March-2011
7 | * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /** @addtogroup CMSIS
23 | * @{
24 | */
25 |
26 | /** @addtogroup stm32f10x_system
27 | * @{
28 | */
29 |
30 | /**
31 | * @brief Define to prevent recursive inclusion
32 | */
33 | #ifndef __SYSTEM_STM32F10X_H
34 | #define __SYSTEM_STM32F10X_H
35 |
36 | #ifdef __cplusplus
37 | extern "C" {
38 | #endif
39 |
40 | /** @addtogroup STM32F10x_System_Includes
41 | * @{
42 | */
43 |
44 | /**
45 | * @}
46 | */
47 |
48 |
49 | /** @addtogroup STM32F10x_System_Exported_types
50 | * @{
51 | */
52 |
53 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
54 |
55 | /**
56 | * @}
57 | */
58 |
59 | /** @addtogroup STM32F10x_System_Exported_Constants
60 | * @{
61 | */
62 |
63 | /**
64 | * @}
65 | */
66 |
67 | /** @addtogroup STM32F10x_System_Exported_Macros
68 | * @{
69 | */
70 |
71 | /**
72 | * @}
73 | */
74 |
75 | /** @addtogroup STM32F10x_System_Exported_Functions
76 | * @{
77 | */
78 |
79 | extern void SystemInit(void);
80 | extern void SystemCoreClockUpdate(void);
81 | /**
82 | * @}
83 | */
84 |
85 | #ifdef __cplusplus
86 | }
87 | #endif
88 |
89 | #endif /*__SYSTEM_STM32F10X_H */
90 |
91 | /**
92 | * @}
93 | */
94 |
95 | /**
96 | * @}
97 | */
98 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
99 |
--------------------------------------------------------------------------------
/usb/usb_pwr.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ********************
2 | * File Name : usb_pwr.h
3 | * Author : MCD Application Team
4 | * Version : V3.3.0
5 | * Date : 21-March-2011
6 | * Description : Connection/disconnection & power management header
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | /* Define to prevent recursive inclusion -------------------------------------*/
17 | #ifndef __USB_PWR_H
18 | #define __USB_PWR_H
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | /* Exported types ------------------------------------------------------------*/
22 | typedef enum _RESUME_STATE
23 | {
24 | RESUME_EXTERNAL,
25 | RESUME_INTERNAL,
26 | RESUME_LATER,
27 | RESUME_WAIT,
28 | RESUME_START,
29 | RESUME_ON,
30 | RESUME_OFF,
31 | RESUME_ESOF
32 | } RESUME_STATE;
33 |
34 | typedef enum _DEVICE_STATE
35 | {
36 | UNCONNECTED,
37 | ATTACHED,
38 | POWERED,
39 | SUSPENDED,
40 | ADDRESSED,
41 | CONFIGURED
42 | } DEVICE_STATE;
43 |
44 | /* Exported constants --------------------------------------------------------*/
45 | /* Exported macro ------------------------------------------------------------*/
46 | /* Exported functions ------------------------------------------------------- */
47 | void Suspend(void);
48 | void Resume_Init(void);
49 | void Resume(RESUME_STATE eResumeSetVal);
50 | RESULT PowerOn(void);
51 | RESULT PowerOff(void);
52 |
53 | /* External variables --------------------------------------------------------*/
54 | extern __IO uint32_t bDeviceState; /* USB device status */
55 | extern __IO bool fSuspendEnabled; /* true when suspend is possible */
56 |
57 | #endif /*__USB_PWR_H*/
58 |
59 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
60 |
--------------------------------------------------------------------------------
/usb/hw_config.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ********************
2 | * File Name : hw_config.h
3 | * Author : MCD Application Team
4 | * Version : V3.3.0
5 | * Date : 21-March-2011
6 | * Description : Hardware Configuration & Setup
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | /* Define to prevent recursive inclusion -------------------------------------*/
17 | #ifndef __HW_CONFIG_H
18 | #define __HW_CONFIG_H
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "usb_type.h"
22 |
23 | /* Exported types ------------------------------------------------------------*/
24 | /* Exported constants --------------------------------------------------------*/
25 | /* Exported macro ------------------------------------------------------------*/
26 | /* Exported define -----------------------------------------------------------*/
27 | #define MASS_MEMORY_START 0x04002000
28 | #define BULK_MAX_PACKET_SIZE 0x00000040
29 | #define LED_ON 0xF0
30 | #define LED_OFF 0xFF
31 |
32 | #define USART_RX_DATA_SIZE (64)
33 | /* Exported functions ------------------------------------------------------- */
34 | void Set_System(void);
35 | void Set_USBClock(void);
36 | void Enter_LowPowerMode(void);
37 | void Leave_LowPowerMode(void);
38 | void USB_Interrupts_Config(void);
39 | void USB_Cable_Config(FunctionalState NewState);
40 | void USART_Config_Default(void);
41 | bool USART_Config(void);
42 | void OnUsbDataRx(uint8_t* data_buffer, uint8_t Nb_bytes);
43 | void Get_SerialNum(void);
44 |
45 | /* External variables --------------------------------------------------------*/
46 |
47 | #endif /*__HW_CONFIG_H*/
48 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
49 |
--------------------------------------------------------------------------------
/usb/stm32f10x_it.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ********************
2 | * File Name : stm32f10x_it.h
3 | * Author : MCD Application Team
4 | * Version : V3.3.0
5 | * Date : 21-March-2011
6 | * Description : This file contains the headers of the interrupt handlers.
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | /* Define to prevent recursive inclusion -------------------------------------*/
17 | #ifndef __STM32F10x_IT_H
18 | #define __STM32F10x_IT_H
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "stm32f10x.h"
22 |
23 | /* Exported types ------------------------------------------------------------*/
24 | /* Exported constants --------------------------------------------------------*/
25 | /* Exported macro ------------------------------------------------------------*/
26 | /* Exported functions ------------------------------------------------------- */
27 |
28 | void NMI_Handler(void);
29 | void HardFault_Handler(void);
30 | void MemManage_Handler(void);
31 | void BusFault_Handler(void);
32 | void UsageFault_Handler(void);
33 | void SVC_Handler(void);
34 | void DebugMon_Handler(void);
35 | void PendSV_Handler(void);
36 | void SysTick_Handler(void);
37 |
38 | #ifndef STM32F10X_CL
39 | void USB_LP_CAN1_RX0_IRQHandler(void);
40 | #endif /* STM32F10X_CL */
41 |
42 | #if defined (USE_STM3210B_EVAL) || defined (USE_STM3210E_EVAL)
43 | void USART1_IRQHandler(void);
44 | #endif /* USE_STM3210B_EVAL or USE_STM3210E_EVAL */
45 |
46 | #ifdef USE_STM3210C_EVAL
47 | void USART2_IRQHandler(void);
48 | #endif /* USE_STM3210C_EVAL */
49 |
50 | #ifdef STM32F10X_CL
51 | void OTG_FS_IRQHandler(void);
52 | #endif /* STM32F10X_CL */
53 |
54 | #endif /* __STM32F10x_IT_H */
55 |
56 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
57 |
--------------------------------------------------------------------------------
/SPL/inc/stm32f10x_crc.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f10x_crc.h
4 | * @author MCD Application Team
5 | * @version V3.5.0
6 | * @date 11-March-2011
7 | * @brief This file contains all the functions prototypes for the CRC firmware
8 | * library.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18 | *
19 | * © COPYRIGHT 2011 STMicroelectronics
20 | ******************************************************************************
21 | */
22 |
23 | /* Define to prevent recursive inclusion -------------------------------------*/
24 | #ifndef __STM32F10x_CRC_H
25 | #define __STM32F10x_CRC_H
26 |
27 | #ifdef __cplusplus
28 | extern "C" {
29 | #endif
30 |
31 | /* Includes ------------------------------------------------------------------*/
32 | #include "stm32f10x.h"
33 |
34 | /** @addtogroup STM32F10x_StdPeriph_Driver
35 | * @{
36 | */
37 |
38 | /** @addtogroup CRC
39 | * @{
40 | */
41 |
42 | /** @defgroup CRC_Exported_Types
43 | * @{
44 | */
45 |
46 | /**
47 | * @}
48 | */
49 |
50 | /** @defgroup CRC_Exported_Constants
51 | * @{
52 | */
53 |
54 | /**
55 | * @}
56 | */
57 |
58 | /** @defgroup CRC_Exported_Macros
59 | * @{
60 | */
61 |
62 | /**
63 | * @}
64 | */
65 |
66 | /** @defgroup CRC_Exported_Functions
67 | * @{
68 | */
69 |
70 | void CRC_ResetDR(void);
71 | uint32_t CRC_CalcCRC(uint32_t Data);
72 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength);
73 | uint32_t CRC_GetCRC(void);
74 | void CRC_SetIDRegister(uint8_t IDValue);
75 | uint8_t CRC_GetIDRegister(void);
76 |
77 | #ifdef __cplusplus
78 | }
79 | #endif
80 |
81 | #endif /* __STM32F10x_CRC_H */
82 | /**
83 | * @}
84 | */
85 |
86 | /**
87 | * @}
88 | */
89 |
90 | /**
91 | * @}
92 | */
93 |
94 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
95 |
--------------------------------------------------------------------------------
/stm_usb_fs_lib/inc/usb_init.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
2 | * File Name : usb_init.h
3 | * Author : MCD Application Team
4 | * Version : V3.2.1
5 | * Date : 07/05/2010
6 | * Description : Initialization routines & global variables
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | /* Define to prevent recursive inclusion -------------------------------------*/
17 | #ifndef __USB_INIT_H
18 | #define __USB_INIT_H
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | /* Exported types ------------------------------------------------------------*/
22 | /* Exported constants --------------------------------------------------------*/
23 | /* Exported macro ------------------------------------------------------------*/
24 | /* Exported functions ------------------------------------------------------- */
25 | void USB_Init(void);
26 |
27 | /* External variables --------------------------------------------------------*/
28 | /* The number of current endpoint, it will be used to specify an endpoint */
29 | extern uint8_t EPindex;
30 | /* The number of current device, it is an index to the Device_Table */
31 | /*extern uint8_t Device_no; */
32 | /* Points to the DEVICE_INFO structure of current device */
33 | /* The purpose of this register is to speed up the execution */
34 | extern DEVICE_INFO* pInformation;
35 | /* Points to the DEVICE_PROP structure of current device */
36 | /* The purpose of this register is to speed up the execution */
37 | extern DEVICE_PROP* pProperty;
38 | /* Temporary save the state of Rx & Tx status. */
39 | /* Whenever the Rx or Tx state is changed, its value is saved */
40 | /* in this variable first and will be set to the EPRB or EPRA */
41 | /* at the end of interrupt process */
42 | extern USER_STANDARD_REQUESTS *pUser_Standard_Requests;
43 |
44 | extern uint16_t SaveState ;
45 | extern uint16_t wInterrupt_Mask;
46 |
47 | #endif /* __USB_INIT_H */
48 |
49 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
50 |
--------------------------------------------------------------------------------
/grbl/probe.c:
--------------------------------------------------------------------------------
1 | /*
2 | probe.c - code pertaining to probing methods
3 | Part of Grbl
4 |
5 | Copyright (c) 2014-2016 Sungeun K. Jeon for Gnea Research LLC
6 |
7 | Grbl is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Grbl is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Grbl. If not, see .
19 | */
20 |
21 | #include "grbl.h"
22 |
23 |
24 | // Inverts the probe pin state depending on user settings and probing cycle mode.
25 | uint8_t probe_invert_mask;
26 |
27 |
28 | // Probe pin initialization routine.
29 | void probe_init()
30 | {
31 | GPIO_InitTypeDef GPIO_InitStructure;
32 | RCC_APB2PeriphClockCmd(RCC_PROBE_PORT, ENABLE);
33 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
34 | #ifdef DISABLE_PROBE_PIN_PULL_UP
35 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
36 | #else
37 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
38 | #endif
39 | GPIO_InitStructure.GPIO_Pin = PROBE_MASK;
40 | GPIO_Init(PROBE_PORT, &GPIO_InitStructure);
41 | probe_configure_invert_mask(false); // Initialize invert mask.
42 | }
43 |
44 |
45 | // Called by probe_init() and the mc_probe() routines. Sets up the probe pin invert mask to
46 | // appropriately set the pin logic according to setting for normal-high/normal-low operation
47 | // and the probing cycle modes for toward-workpiece/away-from-workpiece.
48 | void probe_configure_invert_mask(uint8_t is_probe_away)
49 | {
50 | probe_invert_mask = 0; // Initialize as zero.
51 | if (bit_isfalse(settings.flags,BITFLAG_INVERT_PROBE_PIN)) { probe_invert_mask ^= PROBE_MASK; }
52 | if (is_probe_away) { probe_invert_mask ^= PROBE_MASK; }
53 | }
54 |
55 |
56 | // Returns the probe pin state. Triggered = true. Called by gcode parser and probe state monitor.
57 | uint8_t probe_get_state()
58 | {
59 | return ((GPIO_ReadInputData(PROBE_PORT) & PROBE_MASK) ^ probe_invert_mask) != 0;
60 | }
61 |
62 |
63 | // Monitors probe pin state and records the system position when detected. Called by the
64 | // stepper ISR per ISR tick.
65 | // NOTE: This function must be extremely efficient as to not bog down the stepper ISR.
66 | void probe_state_monitor()
67 | {
68 | if (probe_get_state()) {
69 | sys_probe_state = PROBE_OFF;
70 | memcpy(sys_probe_position, sys_position, sizeof(sys_position));
71 | bit_true(sys_rt_exec_state, EXEC_MOTION_CANCEL);
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/grbl/spindle_control.h:
--------------------------------------------------------------------------------
1 | /*
2 | spindle_control.h - spindle control methods
3 | Part of Grbl
4 |
5 | Copyright (c) 2012-2016 Sungeun K. Jeon for Gnea Research LLC
6 | Copyright (c) 2009-2011 Simen Svale Skogsrud
7 |
8 | Grbl is free software: you can redistribute it and/or modify
9 | it under the terms of the GNU General Public License as published by
10 | the Free Software Foundation, either version 3 of the License, or
11 | (at your option) any later version.
12 |
13 | Grbl is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU General Public License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with Grbl. If not, see .
20 | */
21 |
22 | #ifndef spindle_control_h
23 | #define spindle_control_h
24 |
25 | #define SPINDLE_NO_SYNC false
26 | #define SPINDLE_FORCE_SYNC true
27 |
28 | #define SPINDLE_STATE_DISABLE 0 // Must be zero.
29 | #define SPINDLE_STATE_CW bit(0)
30 | #define SPINDLE_STATE_CCW bit(1)
31 |
32 |
33 | // Initializes spindle pins and hardware PWM, if enabled.
34 | void spindle_init();
35 |
36 | // Returns current spindle output state. Overrides may alter it from programmed states.
37 | uint8_t spindle_get_state();
38 |
39 | // Called by g-code parser when setting spindle state and requires a buffer sync.
40 | // Immediately sets spindle running state with direction and spindle rpm via PWM, if enabled.
41 | // Called by spindle_sync() after sync and parking motion/spindle stop override during restore.
42 | #ifdef VARIABLE_SPINDLE
43 | #define SPINDLE_PWM_TYPE uint16_t
44 |
45 | // Called by g-code parser when setting spindle state and requires a buffer sync.
46 | void spindle_sync(uint8_t state, float rpm);
47 |
48 | // Sets spindle running state with direction, enable, and spindle PWM.
49 | void spindle_set_state(uint8_t state, float rpm);
50 |
51 | // Sets spindle PWM quickly for stepper ISR. Also called by spindle_set_state().
52 | // NOTE: 328p PWM register is 8-bit.
53 | void spindle_set_speed(SPINDLE_PWM_TYPE pwm_value);
54 |
55 | // Computes 328p-specific PWM register value for the given RPM for quick updating.
56 | SPINDLE_PWM_TYPE spindle_compute_pwm_value(float rpm);
57 |
58 | #else
59 |
60 | // Called by g-code parser when setting spindle state and requires a buffer sync.
61 | #define spindle_sync(state, rpm) _spindle_sync(state)
62 | void _spindle_sync(uint8_t state);
63 |
64 | // Sets spindle running state with direction and enable.
65 | #define spindle_set_state(state, rpm) _spindle_set_state(state)
66 | void _spindle_set_state(uint8_t state);
67 |
68 | #endif
69 |
70 | // Stop and start spindle routines. Called by all spindle routines and stepper ISR.
71 | void spindle_stop();
72 |
73 |
74 | #endif
75 |
--------------------------------------------------------------------------------
/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-2016 Sungeun K. Jeon for Gnea Research LLC
6 | Copyright (c) 2009-2011 Simen Svale Skogsrud
7 |
8 | Grbl is free software: you can redistribute it and/or modify
9 | it under the terms of the GNU General Public License as published by
10 | the Free Software Foundation, either version 3 of the License, or
11 | (at your option) any later version.
12 |
13 | Grbl is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU General Public License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with Grbl. If not, see .
20 | */
21 |
22 | #ifndef motion_control_h
23 | #define motion_control_h
24 |
25 |
26 | // System motion commands must have a line number of zero.
27 | #define HOMING_CYCLE_LINE_NUMBER 0
28 | #define PARKING_MOTION_LINE_NUMBER 0
29 |
30 | #define HOMING_CYCLE_ALL 0 // Must be zero.
31 | #define HOMING_CYCLE_X bit(X_AXIS)
32 | #define HOMING_CYCLE_Y bit(Y_AXIS)
33 | #define HOMING_CYCLE_Z bit(Z_AXIS)
34 |
35 |
36 | // Execute linear motion in absolute millimeter coordinates. Feed rate given in millimeters/second
37 | // unless invert_feed_rate is true. Then the feed_rate means that the motion should be completed in
38 | // (1 minute)/feed_rate time.
39 | void mc_line(float *target, plan_line_data_t *pl_data);
40 |
41 | // Execute an arc in offset mode format. position == current xyz, target == target xyz,
42 | // offset == offset from current xyz, axis_XXX defines circle plane in tool space, axis_linear is
43 | // the direction of helical travel, radius == circle radius, is_clockwise_arc boolean. Used
44 | // for vector transformation direction.
45 | void mc_arc(float *target, plan_line_data_t *pl_data, float *position, float *offset, float radius,
46 | uint8_t axis_0, uint8_t axis_1, uint8_t axis_linear, uint8_t is_clockwise_arc);
47 |
48 | // Dwell for a specific number of seconds
49 | void mc_dwell(float seconds);
50 |
51 | // Perform homing cycle to locate machine zero. Requires limit switches.
52 | void mc_homing_cycle(uint8_t cycle_mask);
53 |
54 | // Perform tool length probe cycle. Requires probe switch.
55 | uint8_t mc_probe_cycle(float *target, plan_line_data_t *pl_data, uint8_t parser_flags);
56 |
57 | // Handles updating the override control state.
58 | void mc_override_ctrl_update(uint8_t override_state);
59 |
60 | // Plans and executes the single special motion case for parking. Independent of main planner buffer.
61 | void mc_parking_motion(float *parking_target, plan_line_data_t *pl_data);
62 |
63 | // Performs system reset. If in motion state, kills all motion and sets system alarm.
64 | void mc_reset();
65 |
66 | #endif
67 |
--------------------------------------------------------------------------------
/stm_usb_fs_lib/inc/usb_type.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
2 | * File Name : usb_type.h
3 | * Author : MCD Application Team
4 | * Version : V3.2.1
5 | * Date : 07/05/2010
6 | * Description : Type definitions used by the USB Library
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | /* Define to prevent recursive inclusion -------------------------------------*/
17 | #ifndef __USB_TYPE_H
18 | #define __USB_TYPE_H
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "usb_conf.h"
22 |
23 | /* Exported types ------------------------------------------------------------*/
24 | /* Exported constants --------------------------------------------------------*/
25 | #ifndef NULL
26 | #define NULL ((void *)0)
27 | #endif
28 |
29 | typedef signed long s32;
30 | typedef signed short s16;
31 | typedef signed char s8;
32 |
33 | typedef volatile signed long vs32;
34 | typedef volatile signed short vs16;
35 | typedef volatile signed char vs8;
36 |
37 | typedef unsigned long u32;
38 | typedef unsigned short u16;
39 | typedef unsigned char u8;
40 |
41 | typedef unsigned long const uc32; /* Read Only */
42 | typedef unsigned short const uc16; /* Read Only */
43 | typedef unsigned char const uc8; /* Read Only */
44 |
45 | typedef volatile unsigned long vu32;
46 | typedef volatile unsigned short vu16;
47 | typedef volatile unsigned char vu8;
48 |
49 | typedef volatile unsigned long const vuc32; /* Read Only */
50 | typedef volatile unsigned short const vuc16; /* Read Only */
51 | typedef volatile unsigned char const vuc8; /* Read Only */
52 |
53 | #define FALSE 0
54 | #define TRUE 1
55 | typedef int bool;
56 |
57 | #ifndef __STM32F10x_H
58 | typedef enum { RESET = 0, SET = !RESET } FlagStatus, ITStatus;
59 |
60 | typedef enum { DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
61 |
62 | typedef enum { ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
63 | #endif
64 | /* Exported macro ------------------------------------------------------------*/
65 | /* Exported functions ------------------------------------------------------- */
66 | /* External variables --------------------------------------------------------*/
67 |
68 | #endif /* __USB_TYPE_H */
69 |
70 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
71 |
--------------------------------------------------------------------------------
/usb/usb_desc.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ********************
2 | * File Name : usb_desc.h
3 | * Author : MCD Application Team
4 | * Version : V3.3.0
5 | * Date : 21-March-2011
6 | * Description : Descriptor Header for Virtual COM Port Device
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | /* Define to prevent recursive inclusion -------------------------------------*/
17 | #ifndef __USB_DESC_H
18 | #define __USB_DESC_H
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | /* Exported types ------------------------------------------------------------*/
22 | /* Exported constants --------------------------------------------------------*/
23 | /* Exported macro ------------------------------------------------------------*/
24 | /* Exported define -----------------------------------------------------------*/
25 | #define USB_DEVICE_DESCRIPTOR_TYPE 0x01
26 | #define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
27 | #define USB_STRING_DESCRIPTOR_TYPE 0x03
28 | #define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
29 | #define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
30 |
31 | #define VIRTUAL_COM_PORT_DATA_SIZE 64
32 | #define VIRTUAL_COM_PORT_INT_SIZE 8
33 |
34 | #define VIRTUAL_COM_PORT_SIZ_DEVICE_DESC 18
35 | #define VIRTUAL_COM_PORT_SIZ_CONFIG_DESC 67
36 | #define VIRTUAL_COM_PORT_SIZ_STRING_LANGID 4
37 | #define VIRTUAL_COM_PORT_SIZ_STRING_VENDOR 22
38 | #define VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT 28
39 | #define VIRTUAL_COM_PORT_SIZ_STRING_SERIAL 26
40 |
41 | #define STANDARD_ENDPOINT_DESC_SIZE 0x09
42 |
43 | /* Exported functions ------------------------------------------------------- */
44 | extern const uint8_t Virtual_Com_Port_DeviceDescriptor[VIRTUAL_COM_PORT_SIZ_DEVICE_DESC];
45 | extern const uint8_t Virtual_Com_Port_ConfigDescriptor[VIRTUAL_COM_PORT_SIZ_CONFIG_DESC];
46 |
47 | extern const uint8_t Virtual_Com_Port_StringLangID[VIRTUAL_COM_PORT_SIZ_STRING_LANGID];
48 | extern const uint8_t Virtual_Com_Port_StringVendor[VIRTUAL_COM_PORT_SIZ_STRING_VENDOR];
49 | extern const uint8_t Virtual_Com_Port_StringProduct[VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT];
50 | extern uint8_t Virtual_Com_Port_StringSerial[VIRTUAL_COM_PORT_SIZ_STRING_SERIAL];
51 |
52 | #endif /* __USB_DESC_H */
53 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
54 |
--------------------------------------------------------------------------------
/stm_usb_fs_lib/inc/usb_def.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
2 | * File Name : usb_def.h
3 | * Author : MCD Application Team
4 | * Version : V3.2.1
5 | * Date : 07/05/2010
6 | * Description : Definitions related to USB Core
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | /* Define to prevent recursive inclusion -------------------------------------*/
17 | #ifndef __USB_DEF_H
18 | #define __USB_DEF_H
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | /* Exported types ------------------------------------------------------------*/
22 | typedef enum _RECIPIENT_TYPE
23 | {
24 | DEVICE_RECIPIENT, /* Recipient device */
25 | INTERFACE_RECIPIENT, /* Recipient interface */
26 | ENDPOINT_RECIPIENT, /* Recipient endpoint */
27 | OTHER_RECIPIENT
28 | } RECIPIENT_TYPE;
29 |
30 |
31 | typedef enum _STANDARD_REQUESTS
32 | {
33 | GET_STATUS = 0,
34 | CLEAR_FEATURE,
35 | RESERVED1,
36 | SET_FEATURE,
37 | RESERVED2,
38 | SET_ADDRESS,
39 | GET_DESCRIPTOR,
40 | SET_DESCRIPTOR,
41 | GET_CONFIGURATION,
42 | SET_CONFIGURATION,
43 | GET_INTERFACE,
44 | SET_INTERFACE,
45 | TOTAL_sREQUEST, /* Total number of Standard request */
46 | SYNCH_FRAME = 12
47 | } STANDARD_REQUESTS;
48 |
49 | /* Definition of "USBwValue" */
50 | typedef enum _DESCRIPTOR_TYPE
51 | {
52 | DEVICE_DESCRIPTOR = 1,
53 | CONFIG_DESCRIPTOR,
54 | STRING_DESCRIPTOR,
55 | INTERFACE_DESCRIPTOR,
56 | ENDPOINT_DESCRIPTOR
57 | } DESCRIPTOR_TYPE;
58 |
59 | /* Feature selector of a SET_FEATURE or CLEAR_FEATURE */
60 | typedef enum _FEATURE_SELECTOR
61 | {
62 | ENDPOINT_STALL,
63 | DEVICE_REMOTE_WAKEUP
64 | } FEATURE_SELECTOR;
65 |
66 | /* Exported constants --------------------------------------------------------*/
67 | /* Definition of "USBbmRequestType" */
68 | #define REQUEST_TYPE 0x60 /* Mask to get request type */
69 | #define STANDARD_REQUEST 0x00 /* Standard request */
70 | #define CLASS_REQUEST 0x20 /* Class request */
71 | #define VENDOR_REQUEST 0x40 /* Vendor request */
72 |
73 | #define RECIPIENT 0x1F /* Mask to get recipient */
74 |
75 | /* Exported macro ------------------------------------------------------------*/
76 | /* Exported functions ------------------------------------------------------- */
77 |
78 | #endif /* __USB_DEF_H */
79 |
80 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
81 |
--------------------------------------------------------------------------------
/stm_usb_fs_lib/src/usb_init.c:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
2 | * File Name : usb_init.c
3 | * Author : MCD Application Team
4 | * Version : V3.2.1
5 | * Date : 07/05/2010
6 | * Description : Initialization routines & global variables
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | /* Includes ------------------------------------------------------------------*/
17 | #include "usb_lib.h"
18 |
19 | /* Private typedef -----------------------------------------------------------*/
20 | /* Private define ------------------------------------------------------------*/
21 | /* Private macro -------------------------------------------------------------*/
22 | /* Private variables ---------------------------------------------------------*/
23 | /* The number of current endpoint, it will be used to specify an endpoint */
24 | uint8_t EPindex;
25 | /* The number of current device, it is an index to the Device_Table */
26 | /* uint8_t Device_no; */
27 | /* Points to the DEVICE_INFO structure of current device */
28 | /* The purpose of this register is to speed up the execution */
29 | DEVICE_INFO *pInformation;
30 | /* Points to the DEVICE_PROP structure of current device */
31 | /* The purpose of this register is to speed up the execution */
32 | DEVICE_PROP *pProperty;
33 | /* Temporary save the state of Rx & Tx status. */
34 | /* Whenever the Rx or Tx state is changed, its value is saved */
35 | /* in this variable first and will be set to the EPRB or EPRA */
36 | /* at the end of interrupt process */
37 | uint16_t SaveState ;
38 | uint16_t wInterrupt_Mask;
39 | DEVICE_INFO Device_Info;
40 | USER_STANDARD_REQUESTS *pUser_Standard_Requests;
41 |
42 | /* Extern variables ----------------------------------------------------------*/
43 | /* Private function prototypes -----------------------------------------------*/
44 | /* Private functions ---------------------------------------------------------*/
45 |
46 | /*******************************************************************************
47 | * Function Name : USB_Init
48 | * Description : USB system initialization
49 | * Input : None.
50 | * Output : None.
51 | * Return : None.
52 | *******************************************************************************/
53 | void USB_Init(void)
54 | {
55 | pInformation = &Device_Info;
56 | pInformation->ControlState = 2;
57 | pProperty = &Device_Property;
58 | pUser_Standard_Requests = &User_Standard_Requests;
59 | /* Initialize devices one by one */
60 | pProperty->Init();
61 | }
62 |
63 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
64 |
--------------------------------------------------------------------------------
/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-2016 Sungeun K. Jeon for Gnea Research LLC
6 | Copyright (c) 2009-2011 Simen Svale Skogsrud
7 |
8 | Grbl is free software: you can redistribute it and/or modify
9 | it under the terms of the GNU General Public License as published by
10 | the Free Software Foundation, either version 3 of the License, or
11 | (at your option) any later version.
12 |
13 | Grbl is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU General Public License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with Grbl. If not, see .
20 | */
21 |
22 | #ifndef nuts_bolts_h
23 | #define nuts_bolts_h
24 | #include "stm32f10x_rcc.h"
25 | #include "float.h"
26 | #define false 0
27 | #define true 1
28 |
29 | #define SOME_LARGE_VALUE FLT_MAX
30 |
31 | // Axis array index values. Must start with 0 and be continuous.
32 | #define N_AXIS 3 // Number of axes
33 | #define X_AXIS 0 // Axis indexing value.
34 | #define Y_AXIS 1
35 | #define Z_AXIS 2
36 | // #define A_AXIS 3
37 |
38 | // CoreXY motor assignments. DO NOT ALTER.
39 | // NOTE: If the A and B motor axis bindings are changed, this effects the CoreXY equations.
40 | #ifdef COREXY
41 | #define A_MOTOR X_AXIS // Must be X_AXIS
42 | #define B_MOTOR Y_AXIS // Must be Y_AXIS
43 | #endif
44 |
45 | // Conversions
46 | #define MM_PER_INCH (25.40f)
47 | #define INCH_PER_MM (0.0393701f)
48 | #define TICKS_PER_MICROSECOND (F_CPU/1000000)
49 |
50 | #define F_CPU SystemCoreClock
51 | #define DELAY_MODE_DWELL 0
52 | #define DELAY_MODE_SYS_SUSPEND 1
53 |
54 | // Useful macros
55 | #define clear_vector(a) memset(a, 0, sizeof(a))
56 | #define clear_vector_float(a) memset(a, 0.0, sizeof(float)*N_AXIS)
57 | // #define clear_vector_long(a) memset(a, 0.0, sizeof(long)*N_AXIS)
58 | #define max(a,b) (((a) > (b)) ? (a) : (b))
59 | #define min(a,b) (((a) < (b)) ? (a) : (b))
60 | #define isequal_position_vector(a,b) !(memcmp(a, b, sizeof(float)*N_AXIS))
61 |
62 | // Bit field and masking macros
63 | #define bit(n) (1 << n)
64 | #define bit_true(x,mask) (x) |= (mask)
65 | #define bit_false(x,mask) (x) &= ~(mask)
66 | #define bit_istrue(x,mask) ((x & mask) != 0)
67 | #define bit_isfalse(x,mask) ((x & mask) == 0)
68 |
69 | // Read a floating point value from a string. Line points to the input buffer, char_counter
70 | // is the indexer pointing to the current character of the line, while float_ptr is
71 | // a pointer to the result variable. Returns true when it succeeds
72 | uint8_t read_float(char *line, uint8_t *char_counter, float *float_ptr);
73 |
74 | // Non-blocking delay function used for general operation and suspend features.
75 | void delay_sec(float seconds, uint8_t mode);
76 |
77 | // Delays variable-defined milliseconds. Compiler compatibility fix for _delay_ms().
78 | void delay_ms(uint16_t ms);
79 |
80 |
81 | // Computes hypotenuse, avoiding avr-gcc's bloated version and the extra error checking.
82 | float hypot_f(float x, float y);
83 |
84 | float convert_delta_vector_to_unit_vector(float *vector);
85 | float limit_value_by_axis_maximum(float *max_value, float *unit_vec);
86 |
87 | #endif
88 |
--------------------------------------------------------------------------------
/SPL/inc/stm32f10x_wwdg.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f10x_wwdg.h
4 | * @author MCD Application Team
5 | * @version V3.5.0
6 | * @date 11-March-2011
7 | * @brief This file contains all the functions prototypes for the WWDG firmware
8 | * library.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18 | *
19 | * © COPYRIGHT 2011 STMicroelectronics
20 | ******************************************************************************
21 | */
22 |
23 | /* Define to prevent recursive inclusion -------------------------------------*/
24 | #ifndef __STM32F10x_WWDG_H
25 | #define __STM32F10x_WWDG_H
26 |
27 | #ifdef __cplusplus
28 | extern "C" {
29 | #endif
30 |
31 | /* Includes ------------------------------------------------------------------*/
32 | #include "stm32f10x.h"
33 |
34 | /** @addtogroup STM32F10x_StdPeriph_Driver
35 | * @{
36 | */
37 |
38 | /** @addtogroup WWDG
39 | * @{
40 | */
41 |
42 | /** @defgroup WWDG_Exported_Types
43 | * @{
44 | */
45 |
46 | /**
47 | * @}
48 | */
49 |
50 | /** @defgroup WWDG_Exported_Constants
51 | * @{
52 | */
53 |
54 | /** @defgroup WWDG_Prescaler
55 | * @{
56 | */
57 |
58 | #define WWDG_Prescaler_1 ((uint32_t)0x00000000)
59 | #define WWDG_Prescaler_2 ((uint32_t)0x00000080)
60 | #define WWDG_Prescaler_4 ((uint32_t)0x00000100)
61 | #define WWDG_Prescaler_8 ((uint32_t)0x00000180)
62 | #define IS_WWDG_PRESCALER(PRESCALER) (((PRESCALER) == WWDG_Prescaler_1) || \
63 | ((PRESCALER) == WWDG_Prescaler_2) || \
64 | ((PRESCALER) == WWDG_Prescaler_4) || \
65 | ((PRESCALER) == WWDG_Prescaler_8))
66 | #define IS_WWDG_WINDOW_VALUE(VALUE) ((VALUE) <= 0x7F)
67 | #define IS_WWDG_COUNTER(COUNTER) (((COUNTER) >= 0x40) && ((COUNTER) <= 0x7F))
68 |
69 | /**
70 | * @}
71 | */
72 |
73 | /**
74 | * @}
75 | */
76 |
77 | /** @defgroup WWDG_Exported_Macros
78 | * @{
79 | */
80 | /**
81 | * @}
82 | */
83 |
84 | /** @defgroup WWDG_Exported_Functions
85 | * @{
86 | */
87 |
88 | void WWDG_DeInit(void);
89 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler);
90 | void WWDG_SetWindowValue(uint8_t WindowValue);
91 | void WWDG_EnableIT(void);
92 | void WWDG_SetCounter(uint8_t Counter);
93 | void WWDG_Enable(uint8_t Counter);
94 | FlagStatus WWDG_GetFlagStatus(void);
95 | void WWDG_ClearFlag(void);
96 |
97 | #ifdef __cplusplus
98 | }
99 | #endif
100 |
101 | #endif /* __STM32F10x_WWDG_H */
102 |
103 | /**
104 | * @}
105 | */
106 |
107 | /**
108 | * @}
109 | */
110 |
111 | /**
112 | * @}
113 | */
114 |
115 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
116 |
--------------------------------------------------------------------------------
/inc/stm32f10x_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file Project/STM32F10x_StdPeriph_Template/stm32f10x_conf.h
4 | * @author MCD Application Team
5 | * @version V3.5.0
6 | * @date 08-April-2011
7 | * @brief Library configuration file.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __STM32F10x_CONF_H
24 | #define __STM32F10x_CONF_H
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | /* Uncomment/Comment the line below to enable/disable peripheral header file inclusion */
28 | #include "stm32f10x_adc.h"
29 | #include "stm32f10x_bkp.h"
30 | #include "stm32f10x_can.h"
31 | #include "stm32f10x_cec.h"
32 | #include "stm32f10x_crc.h"
33 | #include "stm32f10x_dac.h"
34 | #include "stm32f10x_dbgmcu.h"
35 | #include "stm32f10x_dma.h"
36 | #include "stm32f10x_exti.h"
37 | #include "stm32f10x_flash.h"
38 | #include "stm32f10x_fsmc.h"
39 | #include "stm32f10x_gpio.h"
40 | #include "stm32f10x_i2c.h"
41 | #include "stm32f10x_iwdg.h"
42 | #include "stm32f10x_pwr.h"
43 | #include "stm32f10x_rcc.h"
44 | #include "stm32f10x_rtc.h"
45 | #include "stm32f10x_sdio.h"
46 | #include "stm32f10x_spi.h"
47 | #include "stm32f10x_tim.h"
48 | #include "stm32f10x_usart.h"
49 | #include "stm32f10x_wwdg.h"
50 | #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
51 |
52 | /* Exported types ------------------------------------------------------------*/
53 | /* Exported constants --------------------------------------------------------*/
54 | /* Uncomment the line below to expanse the "assert_param" macro in the
55 | Standard Peripheral Library drivers code */
56 | /* #define USE_FULL_ASSERT 1 */
57 |
58 | /* Exported macro ------------------------------------------------------------*/
59 | #ifdef USE_FULL_ASSERT
60 |
61 | /**
62 | * @brief The assert_param macro is used for function's parameters check.
63 | * @param expr: If expr is false, it calls assert_failed function which reports
64 | * the name of the source file and the source line number of the call
65 | * that failed. If expr is true, it returns no value.
66 | * @retval None
67 | */
68 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
69 | /* Exported functions ------------------------------------------------------- */
70 | void assert_failed(uint8_t* file, uint32_t line);
71 | #else
72 | #define assert_param(expr) ((void)0)
73 | #endif /* USE_FULL_ASSERT */
74 |
75 | #endif /* __STM32F10x_CONF_H */
76 |
77 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
78 |
--------------------------------------------------------------------------------
/usb/usb_prop.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ********************
2 | * File Name : usb_prop.h
3 | * Author : MCD Application Team
4 | * Version : V3.3.0
5 | * Date : 21-March-2011
6 | * Description : All processing related to Virtual COM Port Demo (Endpoint 0)
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | /* Define to prevent recursive inclusion -------------------------------------*/
17 | #ifndef __usb_prop_H
18 | #define __usb_prop_H
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | /* Exported types ------------------------------------------------------------*/
22 | typedef struct
23 | {
24 | uint32_t bitrate;
25 | uint8_t format;
26 | uint8_t paritytype;
27 | uint8_t datatype;
28 | }LINE_CODING;
29 |
30 | /* Exported constants --------------------------------------------------------*/
31 | /* Exported macro ------------------------------------------------------------*/
32 | /* Exported define -----------------------------------------------------------*/
33 |
34 | #define Virtual_Com_Port_GetConfiguration NOP_Process
35 | //#define Virtual_Com_Port_SetConfiguration NOP_Process
36 | #define Virtual_Com_Port_GetInterface NOP_Process
37 | #define Virtual_Com_Port_SetInterface NOP_Process
38 | #define Virtual_Com_Port_GetStatus NOP_Process
39 | #define Virtual_Com_Port_ClearFeature NOP_Process
40 | #define Virtual_Com_Port_SetEndPointFeature NOP_Process
41 | #define Virtual_Com_Port_SetDeviceFeature NOP_Process
42 | //#define Virtual_Com_Port_SetDeviceAddress NOP_Process
43 |
44 | #define SEND_ENCAPSULATED_COMMAND 0x00
45 | #define GET_ENCAPSULATED_RESPONSE 0x01
46 | #define SET_COMM_FEATURE 0x02
47 | #define GET_COMM_FEATURE 0x03
48 | #define CLEAR_COMM_FEATURE 0x04
49 | #define SET_LINE_CODING 0x20
50 | #define GET_LINE_CODING 0x21
51 | #define SET_CONTROL_LINE_STATE 0x22
52 | #define SEND_BREAK 0x23
53 |
54 | /* Exported functions ------------------------------------------------------- */
55 | void Virtual_Com_Port_init(void);
56 | void Virtual_Com_Port_Reset(void);
57 | void Virtual_Com_Port_SetConfiguration(void);
58 | void Virtual_Com_Port_SetDeviceAddress (void);
59 | void Virtual_Com_Port_Status_In (void);
60 | void Virtual_Com_Port_Status_Out (void);
61 | RESULT Virtual_Com_Port_Data_Setup(uint8_t);
62 | RESULT Virtual_Com_Port_NoData_Setup(uint8_t);
63 | RESULT Virtual_Com_Port_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting);
64 | uint8_t *Virtual_Com_Port_GetDeviceDescriptor(uint16_t );
65 | uint8_t *Virtual_Com_Port_GetConfigDescriptor(uint16_t);
66 | uint8_t *Virtual_Com_Port_GetStringDescriptor(uint16_t);
67 |
68 | uint8_t *Virtual_Com_Port_GetLineCoding(uint16_t Length);
69 | uint8_t *Virtual_Com_Port_SetLineCoding(uint16_t Length);
70 |
71 | #endif /* __usb_prop_H */
72 |
73 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
74 |
75 |
--------------------------------------------------------------------------------
/stm_usb_fs_lib/src/usb_mem.c:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
2 | * File Name : usb_mem.c
3 | * Author : MCD Application Team
4 | * Version : V3.2.1
5 | * Date : 07/05/2010
6 | * Description : Utility functions for memory transfers to/from PMA
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 | #ifndef STM32F10X_CL
16 |
17 | /* Includes ------------------------------------------------------------------*/
18 | #include "usb_lib.h"
19 |
20 | /* Private typedef -----------------------------------------------------------*/
21 | /* Private define ------------------------------------------------------------*/
22 | /* Private macro -------------------------------------------------------------*/
23 | /* Private variables ---------------------------------------------------------*/
24 | /* Extern variables ----------------------------------------------------------*/
25 | /* Private function prototypes -----------------------------------------------*/
26 | /* Private functions ---------------------------------------------------------*/
27 | /*******************************************************************************
28 | * Function Name : UserToPMABufferCopy
29 | * Description : Copy a buffer from user memory area to packet memory area (PMA)
30 | * Input : - pbUsrBuf: pointer to user memory area.
31 | * - wPMABufAddr: address into PMA.
32 | * - wNBytes: no. of bytes to be copied.
33 | * Output : None.
34 | * Return : None .
35 | *******************************************************************************/
36 | void UserToPMABufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes)
37 | {
38 | uint32_t n = (wNBytes + 1) >> 1; /* n = (wNBytes + 1) / 2 */
39 | uint32_t i, temp1;
40 | uint16_t *pdwVal;
41 | pdwVal = (uint16_t *)(wPMABufAddr * 2 + PMAAddr);
42 | for (i = n; i != 0; i--)
43 | {
44 | temp1 = (uint16_t) * pbUsrBuf;
45 | pbUsrBuf++;
46 | *pdwVal++ = temp1 | (uint16_t) * pbUsrBuf << 8;
47 | pdwVal++;
48 | pbUsrBuf++;
49 | }
50 | }
51 | /*******************************************************************************
52 | * Function Name : PMAToUserBufferCopy
53 | * Description : Copy a buffer from user memory area to packet memory area (PMA)
54 | * Input : - pbUsrBuf = pointer to user memory area.
55 | * - wPMABufAddr = address into PMA.
56 | * - wNBytes = no. of bytes to be copied.
57 | * Output : None.
58 | * Return : None.
59 | *******************************************************************************/
60 | void PMAToUserBufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes)
61 | {
62 | uint32_t n = (wNBytes + 1) >> 1;/* /2*/
63 | uint32_t i;
64 | uint32_t *pdwVal;
65 | pdwVal = (uint32_t *)(wPMABufAddr * 2 + PMAAddr);
66 | for (i = n; i != 0; i--)
67 | {
68 | *(uint16_t*)pbUsrBuf++ = *pdwVal++;
69 | pbUsrBuf++;
70 | }
71 | }
72 |
73 | #endif /* STM32F10X_CL */
74 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
75 |
--------------------------------------------------------------------------------
/SPL/src/stm32f10x_crc.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f10x_crc.c
4 | * @author MCD Application Team
5 | * @version V3.5.0
6 | * @date 11-March-2011
7 | * @brief This file provides all the CRC firmware functions.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Includes ------------------------------------------------------------------*/
23 | #include "stm32f10x_crc.h"
24 |
25 | /** @addtogroup STM32F10x_StdPeriph_Driver
26 | * @{
27 | */
28 |
29 | /** @defgroup CRC
30 | * @brief CRC driver modules
31 | * @{
32 | */
33 |
34 | /** @defgroup CRC_Private_TypesDefinitions
35 | * @{
36 | */
37 |
38 | /**
39 | * @}
40 | */
41 |
42 | /** @defgroup CRC_Private_Defines
43 | * @{
44 | */
45 |
46 | /**
47 | * @}
48 | */
49 |
50 | /** @defgroup CRC_Private_Macros
51 | * @{
52 | */
53 |
54 | /**
55 | * @}
56 | */
57 |
58 | /** @defgroup CRC_Private_Variables
59 | * @{
60 | */
61 |
62 | /**
63 | * @}
64 | */
65 |
66 | /** @defgroup CRC_Private_FunctionPrototypes
67 | * @{
68 | */
69 |
70 | /**
71 | * @}
72 | */
73 |
74 | /** @defgroup CRC_Private_Functions
75 | * @{
76 | */
77 |
78 | /**
79 | * @brief Resets the CRC Data register (DR).
80 | * @param None
81 | * @retval None
82 | */
83 | void CRC_ResetDR(void)
84 | {
85 | /* Reset CRC generator */
86 | CRC->CR = CRC_CR_RESET;
87 | }
88 |
89 | /**
90 | * @brief Computes the 32-bit CRC of a given data word(32-bit).
91 | * @param Data: data word(32-bit) to compute its CRC
92 | * @retval 32-bit CRC
93 | */
94 | uint32_t CRC_CalcCRC(uint32_t Data)
95 | {
96 | CRC->DR = Data;
97 |
98 | return (CRC->DR);
99 | }
100 |
101 | /**
102 | * @brief Computes the 32-bit CRC of a given buffer of data word(32-bit).
103 | * @param pBuffer: pointer to the buffer containing the data to be computed
104 | * @param BufferLength: length of the buffer to be computed
105 | * @retval 32-bit CRC
106 | */
107 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength)
108 | {
109 | uint32_t index = 0;
110 |
111 | for(index = 0; index < BufferLength; index++)
112 | {
113 | CRC->DR = pBuffer[index];
114 | }
115 | return (CRC->DR);
116 | }
117 |
118 | /**
119 | * @brief Returns the current CRC value.
120 | * @param None
121 | * @retval 32-bit CRC
122 | */
123 | uint32_t CRC_GetCRC(void)
124 | {
125 | return (CRC->DR);
126 | }
127 |
128 | /**
129 | * @brief Stores a 8-bit data in the Independent Data(ID) register.
130 | * @param IDValue: 8-bit value to be stored in the ID register
131 | * @retval None
132 | */
133 | void CRC_SetIDRegister(uint8_t IDValue)
134 | {
135 | CRC->IDR = IDValue;
136 | }
137 |
138 | /**
139 | * @brief Returns the 8-bit data stored in the Independent Data(ID) register
140 | * @param None
141 | * @retval 8-bit value of the ID register
142 | */
143 | uint8_t CRC_GetIDRegister(void)
144 | {
145 | return (CRC->IDR);
146 | }
147 |
148 | /**
149 | * @}
150 | */
151 |
152 | /**
153 | * @}
154 | */
155 |
156 | /**
157 | * @}
158 | */
159 |
160 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
161 |
--------------------------------------------------------------------------------
/usb/usb_endp.c:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ********************
2 | * File Name : usb_endp.c
3 | * Author : MCD Application Team
4 | * Version : V3.3.0
5 | * Date : 21-March-2011
6 | * Description : Endpoint routines
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | #include "usb_lib.h"
17 | #include "usb_desc.h"
18 | #include "usb_mem.h"
19 | #include "hw_config.h"
20 | #include "usb_istr.h"
21 | #include "usb_pwr.h"
22 | #include "serial.h"
23 | uint8_t USB_Rx_Buffer[VIRTUAL_COM_PORT_DATA_SIZE];
24 |
25 | extern uint8_t serial_tx_buffer[];
26 | extern uint8_t serial_tx_buffer_head;
27 | extern volatile uint8_t serial_tx_buffer_tail;
28 |
29 | void EP3_OUT_Callback(void)
30 | {
31 | uint16_t USB_Rx_Cnt;
32 |
33 | /* Get the received data buffer and update the counter */
34 | USB_Rx_Cnt = USB_SIL_Read(EP3_OUT, USB_Rx_Buffer);
35 |
36 | /* USB data will be immediately processed, this allow next USB traffic being
37 | NAKed till the end of the USART Xfer */
38 |
39 | OnUsbDataRx(USB_Rx_Buffer, USB_Rx_Cnt);
40 |
41 | /* Enable the receive of data on EP3 */
42 | SetEPRxValid(ENDP3);
43 | }
44 | void EP1_IN_Callback (void)
45 | {
46 | if (serial_tx_buffer_head != serial_tx_buffer_tail && (_GetEPTxStatus(ENDP1) == EP_TX_NAK))
47 | {
48 | uint16_t USB_Tx_length;
49 |
50 | if (serial_tx_buffer_head > serial_tx_buffer_tail)
51 | USB_Tx_length = serial_tx_buffer_head - serial_tx_buffer_tail;
52 | else
53 | {
54 | USB_Tx_length = TX_BUFFER_SIZE - serial_tx_buffer_tail + serial_tx_buffer_head;
55 | }
56 |
57 | if (USB_Tx_length != 0)
58 | {
59 | if (USB_Tx_length > 64)
60 | USB_Tx_length = 64;
61 |
62 | // UserToPMABufferCopy(&serial_tx_buffer[serial_tx_buffer_tail], ENDP1_TXADDR, USB_Tx_length);
63 | {
64 | uint8_t *pbUsrBuf = serial_tx_buffer + serial_tx_buffer_tail;
65 | uint32_t n = (USB_Tx_length + 1) >> 1; /* n = (wNBytes + 1) / 2 */
66 | uint32_t i, temp1;
67 | uint16_t *pdwVal;
68 | pdwVal = (uint16_t *)(ENDP1_TXADDR * 2 + PMAAddr);
69 | for (i = n; i != 0; i--)
70 | {
71 | temp1 = (uint16_t) * pbUsrBuf;
72 | pbUsrBuf++;
73 | if (pbUsrBuf - serial_tx_buffer == TX_BUFFER_SIZE)
74 | pbUsrBuf = serial_tx_buffer;
75 |
76 | *pdwVal++ = temp1 | (uint16_t) * pbUsrBuf << 8;
77 | pdwVal++;
78 | pbUsrBuf++;
79 | if (pbUsrBuf - serial_tx_buffer == TX_BUFFER_SIZE)
80 | pbUsrBuf = serial_tx_buffer;
81 | }
82 | }
83 |
84 | SetEPTxCount(ENDP1, USB_Tx_length);
85 | SetEPTxValid(ENDP1);
86 |
87 | serial_tx_buffer_tail += USB_Tx_length;
88 | if (serial_tx_buffer_tail >= TX_BUFFER_SIZE)
89 | serial_tx_buffer_tail -= TX_BUFFER_SIZE;
90 | }
91 | }
92 | }
93 |
94 |
95 | /* \brief Start Of Frame (SOF) callback
96 | */
97 | void SOF_Callback(void)
98 | {
99 | if(bDeviceState == CONFIGURED)
100 | {
101 | /* Check the data to be sent through IN pipe */
102 | EP1_IN_Callback();
103 | }
104 | }
105 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
106 |
107 |
--------------------------------------------------------------------------------
/src/main.c:
--------------------------------------------------------------------------------
1 | /*
2 | main.c - An embedded CNC Controller with rs274/ngc (g-code) support
3 | Part of Grbl-Advanced
4 |
5 | Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
6 | Copyright (c) 2009-2011 Simen Svale Skogsrud
7 | Copyright (c) 2017 Patrick F.
8 |
9 | Grbl-Advanced 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 | Grbl-Advanced 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 | You should have received a copy of the GNU General Public License
18 | along with Grbl-Advanced. If not, see .
19 | */
20 | #include
21 | #include
22 | #include
23 |
24 | #include "System32.h"
25 | #include "grbl_advance.h"
26 |
27 | #include "Print.h"
28 |
29 |
30 | // Declare system global variable structure
31 | System_t sys;
32 | int32_t sys_position[N_AXIS]; // Real-time machine (aka home) position vector in steps.
33 | int32_t sys_probe_position[N_AXIS]; // Last probe position in machine coordinates and steps.
34 | volatile uint8_t sys_probe_state; // Probing state value. Used to coordinate the probing cycle with stepper ISR.
35 | volatile uint8_t sys_rt_exec_state; // Global realtime executor bitflag variable for state management. See EXEC bitmasks.
36 | volatile uint8_t sys_rt_exec_alarm; // Global realtime executor bitflag variable for setting various alarms.
37 | volatile uint8_t sys_rt_exec_motion_override; // Global realtime executor bitflag variable for motion-based overrides.
38 | volatile uint8_t sys_rt_exec_accessory_override; // Global realtime executor bitflag variable for spindle/coolant overrides.
39 |
40 |
41 | int main(void) {
42 | // GPIO_InitTypeDef GPIO_InitStructure;
43 | //
44 | // /* GPIOC clock enable */
45 | // RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC , ENABLE);
46 | //
47 | // /* GPIOC Configuration: Test Pin */
48 | // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
49 | // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
50 | // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
51 | // GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
52 | // GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
53 | // GPIO_Init(GPIOC, &GPIO_InitStructure);
54 |
55 | // Init SysTick 1ms
56 | SysTick_Init();
57 |
58 | // Init formatted output
59 | Print_Init();
60 |
61 | System_Init();
62 | Stepper_Init();
63 | Settings_Init();
64 |
65 | System_ResetPosition();
66 |
67 | if(BIT_IS_TRUE(settings.flags, BITFLAG_HOMING_ENABLE)) {
68 | sys.state = STATE_ALARM;
69 | }
70 | else {
71 | sys.state = STATE_IDLE;
72 | }
73 |
74 | // Grbl-Advanced initialization loop upon power-up or a system abort. For the latter, all processes
75 | // will return to this loop to be cleanly re-initialized.
76 | while(1) {
77 | // Reset system variables.
78 | uint8_t prior_state = sys.state;
79 |
80 | System_Clear();
81 | sys.state = prior_state;
82 |
83 | Probe_Reset();
84 |
85 | sys_probe_state = 0;
86 | sys_rt_exec_state = 0;
87 | sys_rt_exec_alarm = 0;
88 | sys_rt_exec_motion_override = 0;
89 | sys_rt_exec_accessory_override = 0;
90 |
91 | // Reset Grbl-Advanced primary systems.
92 | GC_Init();
93 | Planner_Init();
94 |
95 | Coolant_Init();
96 | Limits_Init();
97 | Probe_Init();
98 | Spindle_Init();
99 | Stepper_Reset();
100 |
101 | // Sync cleared gcode and planner positions to current system position.
102 | Planner_SyncPosition();
103 | GC_SyncPosition();
104 |
105 | // Print welcome message. Indicates an initialization has occured at power-up or with a reset.
106 | Report_InitMessage();
107 |
108 | // Start Grbl-Advanced main loop. Processes program inputs and executes them.
109 | Protocol_MainLoop();
110 | }
111 |
112 | return 0;
113 | }
114 |
--------------------------------------------------------------------------------
/grbl/examples/grblWrite_BuildInfo/grblWrite_BuildInfo.ino:
--------------------------------------------------------------------------------
1 | /***********************************************************************
2 | This sketch writes a `$I` build info string directly into Arduino EEPROM
3 |
4 | To use:
5 | - Just alter the "build_info_line" string to whatever you'd like. Then
6 | compile and upload this sketch to your Arduino.
7 |
8 | - If your Arduino is blinking slowly, your string has already been
9 | written to your EEPROM and been verified by checksums! That's it!
10 |
11 | - If you Arduino LED is blinking fast, something went wrong and the
12 | checksums don't match. You can optionally connect to the Arduino via
13 | the serial monitor, and the sketch will show what its doing.
14 |
15 | NOTE: This sketch is provided as a tool template for OEMs who may need
16 | to restrict users from altering their build info, so they can place
17 | important product information here when enabling the restriction.
18 |
19 | NOTE: When uploading Grbl to the Arduino with this sketch on it, make
20 | sure you see the slow blink before you start the upload process. This
21 | ensures you aren't flashing Grbl when it's in mid-write of the EEPROM.
22 |
23 | Copyright (c) 2016 Sungeun K. Jeon for Gnea Research LLC
24 | Released under the MIT-license. See license.txt for details.
25 | ***********************************************************************/
26 |
27 | #include
28 | #include
29 |
30 | #define SERIAL_BAUD_RATE 115200
31 | #define LINE_LENGTH 80U // Grbl line length
32 | #define BYTE_LOCATION 942U // Grbl build info EEPROM address.
33 |
34 |
35 | // ----- CHANGE THIS LINE -----
36 |
37 | char build_info_line[LINE_LENGTH] = "Testing123.";
38 |
39 | // -----------------------------
40 |
41 |
42 | uint8_t status = false;
43 | int ledPin = 13; // LED connected to digital pin 13
44 |
45 | void setup() {
46 | Serial.begin(SERIAL_BAUD_RATE);
47 | delay(500);
48 |
49 | uint32_t address = BYTE_LOCATION;
50 | uint32_t size = LINE_LENGTH;
51 | char *write_pointer = (char*)build_info_line;
52 | uint8_t write_checksum = 0;
53 | for (; size>0; size--) {
54 | write_checksum = (write_checksum << 1) || (write_checksum >> 7);
55 | write_checksum += *write_pointer;
56 | EEPROM.put(address++, *(write_pointer++));
57 | }
58 | EEPROM.put(address,write_checksum);
59 |
60 | Serial.print(F("-> Writing line to EEPROM: '"));
61 | Serial.print(build_info_line);
62 | Serial.print(F("'\n\r-> Write checksum: "));
63 | Serial.println(write_checksum,DEC);
64 |
65 | size = LINE_LENGTH;
66 | address = BYTE_LOCATION;
67 | uint8_t data = 0;
68 | char read_line[LINE_LENGTH];
69 | char *read_pointer = (char*)read_line;
70 | uint8_t read_checksum = 0;
71 | uint8_t stored_checksum = 0;
72 | for(; size > 0; size--) {
73 | data = EEPROM.read(address++);
74 | read_checksum = (read_checksum << 1) || (read_checksum >> 7);
75 | read_checksum += data;
76 | *(read_pointer++) = data;
77 | }
78 | stored_checksum = EEPROM.read(address);
79 |
80 | Serial.print(F("<- Reading line from EEPROM: '"));
81 | Serial.print(read_line);
82 | Serial.print("'\n\r<- Read checksum: ");
83 | Serial.println(read_checksum,DEC);
84 |
85 | if ((read_checksum == write_checksum) && (read_checksum == stored_checksum)) {
86 | status = true;
87 | Serial.print(F("SUCCESS! All checksums match!\r\n"));
88 | } else {
89 | if (write_checksum != stored_checksum) {
90 | Serial.println(F("ERROR! Write and stored EEPROM checksums don't match!"));
91 | } else {
92 | Serial.println(F("ERROR! Read and stored checksums don't match!"));
93 | }
94 | }
95 | pinMode(ledPin, OUTPUT); // sets the digital pin as output
96 | }
97 |
98 | void loop() {
99 | // Blink to let user know EEPROM write status.
100 | // Slow blink is 'ok'. Fast blink is an 'error'.
101 | digitalWrite(ledPin, HIGH); // sets the LED on
102 | if (status) { delay(1500); } // Slow blink
103 | else { delay(100); } // Rapid blink
104 | digitalWrite(ledPin, LOW); // sets the LED off
105 | if (status) { delay(1500); }
106 | else { delay(100); }
107 | }
108 |
109 |
110 |
--------------------------------------------------------------------------------
/SPL/inc/stm32f10x_dbgmcu.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f10x_dbgmcu.h
4 | * @author MCD Application Team
5 | * @version V3.5.0
6 | * @date 11-March-2011
7 | * @brief This file contains all the functions prototypes for the DBGMCU
8 | * firmware library.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18 | *
19 | * © COPYRIGHT 2011 STMicroelectronics
20 | ******************************************************************************
21 | */
22 |
23 | /* Define to prevent recursive inclusion -------------------------------------*/
24 | #ifndef __STM32F10x_DBGMCU_H
25 | #define __STM32F10x_DBGMCU_H
26 |
27 | #ifdef __cplusplus
28 | extern "C" {
29 | #endif
30 |
31 | /* Includes ------------------------------------------------------------------*/
32 | #include "stm32f10x.h"
33 |
34 | /** @addtogroup STM32F10x_StdPeriph_Driver
35 | * @{
36 | */
37 |
38 | /** @addtogroup DBGMCU
39 | * @{
40 | */
41 |
42 | /** @defgroup DBGMCU_Exported_Types
43 | * @{
44 | */
45 |
46 | /**
47 | * @}
48 | */
49 |
50 | /** @defgroup DBGMCU_Exported_Constants
51 | * @{
52 | */
53 |
54 | #define DBGMCU_SLEEP ((uint32_t)0x00000001)
55 | #define DBGMCU_STOP ((uint32_t)0x00000002)
56 | #define DBGMCU_STANDBY ((uint32_t)0x00000004)
57 | #define DBGMCU_IWDG_STOP ((uint32_t)0x00000100)
58 | #define DBGMCU_WWDG_STOP ((uint32_t)0x00000200)
59 | #define DBGMCU_TIM1_STOP ((uint32_t)0x00000400)
60 | #define DBGMCU_TIM2_STOP ((uint32_t)0x00000800)
61 | #define DBGMCU_TIM3_STOP ((uint32_t)0x00001000)
62 | #define DBGMCU_TIM4_STOP ((uint32_t)0x00002000)
63 | #define DBGMCU_CAN1_STOP ((uint32_t)0x00004000)
64 | #define DBGMCU_I2C1_SMBUS_TIMEOUT ((uint32_t)0x00008000)
65 | #define DBGMCU_I2C2_SMBUS_TIMEOUT ((uint32_t)0x00010000)
66 | #define DBGMCU_TIM8_STOP ((uint32_t)0x00020000)
67 | #define DBGMCU_TIM5_STOP ((uint32_t)0x00040000)
68 | #define DBGMCU_TIM6_STOP ((uint32_t)0x00080000)
69 | #define DBGMCU_TIM7_STOP ((uint32_t)0x00100000)
70 | #define DBGMCU_CAN2_STOP ((uint32_t)0x00200000)
71 | #define DBGMCU_TIM15_STOP ((uint32_t)0x00400000)
72 | #define DBGMCU_TIM16_STOP ((uint32_t)0x00800000)
73 | #define DBGMCU_TIM17_STOP ((uint32_t)0x01000000)
74 | #define DBGMCU_TIM12_STOP ((uint32_t)0x02000000)
75 | #define DBGMCU_TIM13_STOP ((uint32_t)0x04000000)
76 | #define DBGMCU_TIM14_STOP ((uint32_t)0x08000000)
77 | #define DBGMCU_TIM9_STOP ((uint32_t)0x10000000)
78 | #define DBGMCU_TIM10_STOP ((uint32_t)0x20000000)
79 | #define DBGMCU_TIM11_STOP ((uint32_t)0x40000000)
80 |
81 | #define IS_DBGMCU_PERIPH(PERIPH) ((((PERIPH) & 0x800000F8) == 0x00) && ((PERIPH) != 0x00))
82 | /**
83 | * @}
84 | */
85 |
86 | /** @defgroup DBGMCU_Exported_Macros
87 | * @{
88 | */
89 |
90 | /**
91 | * @}
92 | */
93 |
94 | /** @defgroup DBGMCU_Exported_Functions
95 | * @{
96 | */
97 |
98 | uint32_t DBGMCU_GetREVID(void);
99 | uint32_t DBGMCU_GetDEVID(void);
100 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState);
101 |
102 | #ifdef __cplusplus
103 | }
104 | #endif
105 |
106 | #endif /* __STM32F10x_DBGMCU_H */
107 | /**
108 | * @}
109 | */
110 |
111 | /**
112 | * @}
113 | */
114 |
115 | /**
116 | * @}
117 | */
118 |
119 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
120 |
--------------------------------------------------------------------------------
/grbl/grbl.h:
--------------------------------------------------------------------------------
1 | /*
2 | grbl.h - main Grbl include file
3 | Part of Grbl
4 |
5 | Copyright (c) 2015-2016 Sungeun K. Jeon for Gnea Research LLC
6 |
7 | Grbl is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Grbl is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Grbl. If not, see .
19 | */
20 |
21 | #ifndef grbl_h
22 | #define grbl_h
23 |
24 | // Grbl versioning system
25 | #define GRBL_VERSION "1.1f"
26 | #define GRBL_VERSION_BUILD "20170801"
27 |
28 | // Define standard libraries used by Grbl.
29 | #include
30 | #include "stm32f10x.h"
31 | #include "stm32f10x_gpio.h"
32 | #include "stm32f10x_exti.h"
33 | #include "stm32f10x_tim.h"
34 | #include "misc.h"
35 | #define PSTR(x) x
36 | #define pgm_read_byte_near(x) *(x)
37 | void _delay_ms(uint32_t x);
38 | void _delay_us(uint32_t x);
39 | #define false 0
40 | #define true 1
41 | #define PORTPINDEF uint16_t
42 | typedef int bool;
43 | //#define NOEEPROMSUPPORT
44 | #define printPgmString printString
45 |
46 |
47 | #include
48 | #include
49 | #include
50 |
51 | // Define the Grbl system include files. NOTE: Do not alter organization.
52 | #include "config.h"
53 | #include "nuts_bolts.h"
54 | #include "settings.h"
55 | #include "system.h"
56 | #include "defaults.h"
57 | #include "cpu_map.h"
58 | #include "planner.h"
59 | #include "coolant_control.h"
60 | #include "eeprom.h"
61 | #include "gcode.h"
62 | #include "limits.h"
63 | #include "motion_control.h"
64 | #include "planner.h"
65 | #include "print.h"
66 | #include "probe.h"
67 | #include "protocol.h"
68 | #include "report.h"
69 | #include "serial.h"
70 | #include "spindle_control.h"
71 | #include "stepper.h"
72 | #include "jog.h"
73 |
74 | // ---------------------------------------------------------------------------------------
75 | // COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:
76 |
77 | #ifndef HOMING_CYCLE_0
78 | #error "Required HOMING_CYCLE_0 not defined."
79 | #endif
80 |
81 | #if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(VARIABLE_SPINDLE)
82 | #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with VARIABLE_SPINDLE enabled"
83 | #endif
84 |
85 | #if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && !defined(CPU_MAP_ATMEGA328P)
86 | #error "USE_SPINDLE_DIR_AS_ENABLE_PIN may only be used with a 328p processor"
87 | #endif
88 |
89 | #if !defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) && defined(SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED)
90 | #error "SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED may only be used with USE_SPINDLE_DIR_AS_ENABLE_PIN enabled"
91 | #endif
92 |
93 | #if defined(PARKING_ENABLE)
94 | #if defined(HOMING_FORCE_SET_ORIGIN)
95 | #error "HOMING_FORCE_SET_ORIGIN is not supported with PARKING_ENABLE at this time."
96 | #endif
97 | #endif
98 |
99 | #if defined(ENABLE_PARKING_OVERRIDE_CONTROL)
100 | #if !defined(PARKING_ENABLE)
101 | #error "ENABLE_PARKING_OVERRIDE_CONTROL must be enabled with PARKING_ENABLE."
102 | #endif
103 | #endif
104 |
105 | #if defined(SPINDLE_PWM_MIN_VALUE)
106 | #if !(SPINDLE_PWM_MIN_VALUE > 0)
107 | #error "SPINDLE_PWM_MIN_VALUE must be greater than zero."
108 | #endif
109 | #endif
110 |
111 | #if (REPORT_WCO_REFRESH_BUSY_COUNT < REPORT_WCO_REFRESH_IDLE_COUNT)
112 | #error "WCO busy refresh is less than idle refresh."
113 | #endif
114 | #if (REPORT_OVR_REFRESH_BUSY_COUNT < REPORT_OVR_REFRESH_IDLE_COUNT)
115 | #error "Override busy refresh is less than idle refresh."
116 | #endif
117 | #if (REPORT_WCO_REFRESH_IDLE_COUNT < 2)
118 | #error "WCO refresh must be greater than one."
119 | #endif
120 | #if (REPORT_OVR_REFRESH_IDLE_COUNT < 1)
121 | #error "Override refresh must be greater than zero."
122 | #endif
123 | // ---------------------------------------------------------------------------------------
124 |
125 | #endif
126 |
--------------------------------------------------------------------------------
/usb/usb_istr.h:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ********************
2 | * File Name : usb_istr.h
3 | * Author : MCD Application Team
4 | * Version : V3.3.0
5 | * Date : 21-March-2011
6 | * Description : This file includes the peripherals header files in the
7 | * user application.
8 | ********************************************************************************
9 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
10 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
11 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
12 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
13 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
14 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
15 | *******************************************************************************/
16 |
17 | /* Define to prevent recursive inclusion -------------------------------------*/
18 | #ifndef __USB_ISTR_H
19 | #define __USB_ISTR_H
20 |
21 | /* Includes ------------------------------------------------------------------*/
22 | #include "usb_conf.h"
23 |
24 | /* Exported types ------------------------------------------------------------*/
25 | /* Exported constants --------------------------------------------------------*/
26 | /* Exported macro ------------------------------------------------------------*/
27 | /* Exported functions ------------------------------------------------------- */
28 |
29 | #ifndef STM32F10X_CL
30 | void USB_Istr(void);
31 | #else /* STM32F10X_CL */
32 | u32 STM32_PCD_OTG_ISR_Handler(void);
33 | #endif /* STM32F10X_CL */
34 |
35 | /* function prototypes Automatically built defining related macros */
36 |
37 | void EP1_IN_Callback(void);
38 | void EP2_IN_Callback(void);
39 | void EP3_IN_Callback(void);
40 | void EP4_IN_Callback(void);
41 | void EP5_IN_Callback(void);
42 | void EP6_IN_Callback(void);
43 | void EP7_IN_Callback(void);
44 |
45 | void EP1_OUT_Callback(void);
46 | void EP2_OUT_Callback(void);
47 | void EP3_OUT_Callback(void);
48 | void EP4_OUT_Callback(void);
49 | void EP5_OUT_Callback(void);
50 | void EP6_OUT_Callback(void);
51 | void EP7_OUT_Callback(void);
52 |
53 | #ifndef STM32F10X_CL
54 |
55 | #ifdef CTR_CALLBACK
56 | void CTR_Callback(void);
57 | #endif
58 |
59 | #ifdef DOVR_CALLBACK
60 | void DOVR_Callback(void);
61 | #endif
62 |
63 | #ifdef ERR_CALLBACK
64 | void ERR_Callback(void);
65 | #endif
66 |
67 | #ifdef WKUP_CALLBACK
68 | void WKUP_Callback(void);
69 | #endif
70 |
71 | #ifdef SUSP_CALLBACK
72 | void SUSP_Callback(void);
73 | #endif
74 |
75 | #ifdef RESET_CALLBACK
76 | void RESET_Callback(void);
77 | #endif
78 |
79 | #ifdef SOF_CALLBACK
80 | void SOF_Callback(void);
81 | #endif
82 |
83 | #ifdef ESOF_CALLBACK
84 | void ESOF_Callback(void);
85 | #endif
86 |
87 | #else /* STM32F10X_CL */
88 |
89 | /* Interrupt subroutines user callbacks prototypes.
90 | These callbacks are called into the respective interrupt subroutine functions
91 | and can be tailored for various user application purposes.
92 | Note: Make sure that the correspondent interrupt is enabled through the
93 | definition in usb_conf.h file */
94 | void INTR_MODEMISMATCH_Callback(void);
95 | void INTR_SOFINTR_Callback(void);
96 | void INTR_RXSTSQLVL_Callback(void);
97 | void INTR_NPTXFEMPTY_Callback(void);
98 | void INTR_GINNAKEFF_Callback(void);
99 | void INTR_GOUTNAKEFF_Callback(void);
100 | void INTR_ERLYSUSPEND_Callback(void);
101 | void INTR_USBSUSPEND_Callback(void);
102 | void INTR_USBRESET_Callback(void);
103 | void INTR_ENUMDONE_Callback(void);
104 | void INTR_ISOOUTDROP_Callback(void);
105 | void INTR_EOPFRAME_Callback(void);
106 | void INTR_EPMISMATCH_Callback(void);
107 | void INTR_INEPINTR_Callback(void);
108 | void INTR_OUTEPINTR_Callback(void);
109 | void INTR_INCOMPLISOIN_Callback(void);
110 | void INTR_INCOMPLISOOUT_Callback(void);
111 | void INTR_WKUPINTR_Callback(void);
112 |
113 | /* Isochronous data update */
114 | void INTR_RXSTSQLVL_ISODU_Callback(void);
115 |
116 | #endif /* STM32F10X_CL */
117 |
118 |
119 | #endif /*__USB_ISTR_H*/
120 |
121 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
122 |
--------------------------------------------------------------------------------
/SPL/inc/stm32f10x_iwdg.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f10x_iwdg.h
4 | * @author MCD Application Team
5 | * @version V3.5.0
6 | * @date 11-March-2011
7 | * @brief This file contains all the functions prototypes for the IWDG
8 | * firmware library.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18 | *
19 | * © COPYRIGHT 2011 STMicroelectronics
20 | ******************************************************************************
21 | */
22 |
23 | /* Define to prevent recursive inclusion -------------------------------------*/
24 | #ifndef __STM32F10x_IWDG_H
25 | #define __STM32F10x_IWDG_H
26 |
27 | #ifdef __cplusplus
28 | extern "C" {
29 | #endif
30 |
31 | /* Includes ------------------------------------------------------------------*/
32 | #include "stm32f10x.h"
33 |
34 | /** @addtogroup STM32F10x_StdPeriph_Driver
35 | * @{
36 | */
37 |
38 | /** @addtogroup IWDG
39 | * @{
40 | */
41 |
42 | /** @defgroup IWDG_Exported_Types
43 | * @{
44 | */
45 |
46 | /**
47 | * @}
48 | */
49 |
50 | /** @defgroup IWDG_Exported_Constants
51 | * @{
52 | */
53 |
54 | /** @defgroup IWDG_WriteAccess
55 | * @{
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 |
70 | #define IWDG_Prescaler_4 ((uint8_t)0x00)
71 | #define IWDG_Prescaler_8 ((uint8_t)0x01)
72 | #define IWDG_Prescaler_16 ((uint8_t)0x02)
73 | #define IWDG_Prescaler_32 ((uint8_t)0x03)
74 | #define IWDG_Prescaler_64 ((uint8_t)0x04)
75 | #define IWDG_Prescaler_128 ((uint8_t)0x05)
76 | #define IWDG_Prescaler_256 ((uint8_t)0x06)
77 | #define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_Prescaler_4) || \
78 | ((PRESCALER) == IWDG_Prescaler_8) || \
79 | ((PRESCALER) == IWDG_Prescaler_16) || \
80 | ((PRESCALER) == IWDG_Prescaler_32) || \
81 | ((PRESCALER) == IWDG_Prescaler_64) || \
82 | ((PRESCALER) == IWDG_Prescaler_128)|| \
83 | ((PRESCALER) == IWDG_Prescaler_256))
84 | /**
85 | * @}
86 | */
87 |
88 | /** @defgroup IWDG_Flag
89 | * @{
90 | */
91 |
92 | #define IWDG_FLAG_PVU ((uint16_t)0x0001)
93 | #define IWDG_FLAG_RVU ((uint16_t)0x0002)
94 | #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || ((FLAG) == IWDG_FLAG_RVU))
95 | #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF)
96 | /**
97 | * @}
98 | */
99 |
100 | /**
101 | * @}
102 | */
103 |
104 | /** @defgroup IWDG_Exported_Macros
105 | * @{
106 | */
107 |
108 | /**
109 | * @}
110 | */
111 |
112 | /** @defgroup IWDG_Exported_Functions
113 | * @{
114 | */
115 |
116 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess);
117 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler);
118 | void IWDG_SetReload(uint16_t Reload);
119 | void IWDG_ReloadCounter(void);
120 | void IWDG_Enable(void);
121 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG);
122 |
123 | #ifdef __cplusplus
124 | }
125 | #endif
126 |
127 | #endif /* __STM32F10x_IWDG_H */
128 | /**
129 | * @}
130 | */
131 |
132 | /**
133 | * @}
134 | */
135 |
136 | /**
137 | * @}
138 | */
139 |
140 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
141 |
--------------------------------------------------------------------------------
/SPL/inc/stm32f10x_rtc.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f10x_rtc.h
4 | * @author MCD Application Team
5 | * @version V3.5.0
6 | * @date 11-March-2011
7 | * @brief This file contains all the functions prototypes for the RTC firmware
8 | * library.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18 | *
19 | * © COPYRIGHT 2011 STMicroelectronics
20 | ******************************************************************************
21 | */
22 |
23 | /* Define to prevent recursive inclusion -------------------------------------*/
24 | #ifndef __STM32F10x_RTC_H
25 | #define __STM32F10x_RTC_H
26 |
27 | #ifdef __cplusplus
28 | extern "C" {
29 | #endif
30 |
31 | /* Includes ------------------------------------------------------------------*/
32 | #include "stm32f10x.h"
33 |
34 | /** @addtogroup STM32F10x_StdPeriph_Driver
35 | * @{
36 | */
37 |
38 | /** @addtogroup RTC
39 | * @{
40 | */
41 |
42 | /** @defgroup RTC_Exported_Types
43 | * @{
44 | */
45 |
46 | /**
47 | * @}
48 | */
49 |
50 | /** @defgroup RTC_Exported_Constants
51 | * @{
52 | */
53 |
54 | /** @defgroup RTC_interrupts_define
55 | * @{
56 | */
57 |
58 | #define RTC_IT_OW ((uint16_t)0x0004) /*!< Overflow interrupt */
59 | #define RTC_IT_ALR ((uint16_t)0x0002) /*!< Alarm interrupt */
60 | #define RTC_IT_SEC ((uint16_t)0x0001) /*!< Second interrupt */
61 | #define IS_RTC_IT(IT) ((((IT) & (uint16_t)0xFFF8) == 0x00) && ((IT) != 0x00))
62 | #define IS_RTC_GET_IT(IT) (((IT) == RTC_IT_OW) || ((IT) == RTC_IT_ALR) || \
63 | ((IT) == RTC_IT_SEC))
64 | /**
65 | * @}
66 | */
67 |
68 | /** @defgroup RTC_interrupts_flags
69 | * @{
70 | */
71 |
72 | #define RTC_FLAG_RTOFF ((uint16_t)0x0020) /*!< RTC Operation OFF flag */
73 | #define RTC_FLAG_RSF ((uint16_t)0x0008) /*!< Registers Synchronized flag */
74 | #define RTC_FLAG_OW ((uint16_t)0x0004) /*!< Overflow flag */
75 | #define RTC_FLAG_ALR ((uint16_t)0x0002) /*!< Alarm flag */
76 | #define RTC_FLAG_SEC ((uint16_t)0x0001) /*!< Second flag */
77 | #define IS_RTC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFFF0) == 0x00) && ((FLAG) != 0x00))
78 | #define IS_RTC_GET_FLAG(FLAG) (((FLAG) == RTC_FLAG_RTOFF) || ((FLAG) == RTC_FLAG_RSF) || \
79 | ((FLAG) == RTC_FLAG_OW) || ((FLAG) == RTC_FLAG_ALR) || \
80 | ((FLAG) == RTC_FLAG_SEC))
81 | #define IS_RTC_PRESCALER(PRESCALER) ((PRESCALER) <= 0xFFFFF)
82 |
83 | /**
84 | * @}
85 | */
86 |
87 | /**
88 | * @}
89 | */
90 |
91 | /** @defgroup RTC_Exported_Macros
92 | * @{
93 | */
94 |
95 | /**
96 | * @}
97 | */
98 |
99 | /** @defgroup RTC_Exported_Functions
100 | * @{
101 | */
102 |
103 | void RTC_ITConfig(uint16_t RTC_IT, FunctionalState NewState);
104 | void RTC_EnterConfigMode(void);
105 | void RTC_ExitConfigMode(void);
106 | uint32_t RTC_GetCounter(void);
107 | void RTC_SetCounter(uint32_t CounterValue);
108 | void RTC_SetPrescaler(uint32_t PrescalerValue);
109 | void RTC_SetAlarm(uint32_t AlarmValue);
110 | uint32_t RTC_GetDivider(void);
111 | void RTC_WaitForLastTask(void);
112 | void RTC_WaitForSynchro(void);
113 | FlagStatus RTC_GetFlagStatus(uint16_t RTC_FLAG);
114 | void RTC_ClearFlag(uint16_t RTC_FLAG);
115 | ITStatus RTC_GetITStatus(uint16_t RTC_IT);
116 | void RTC_ClearITPendingBit(uint16_t RTC_IT);
117 |
118 | #ifdef __cplusplus
119 | }
120 | #endif
121 |
122 | #endif /* __STM32F10x_RTC_H */
123 | /**
124 | * @}
125 | */
126 |
127 | /**
128 | * @}
129 | */
130 |
131 | /**
132 | * @}
133 | */
134 |
135 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
136 |
--------------------------------------------------------------------------------
/grbl/coolant_control.c:
--------------------------------------------------------------------------------
1 | /*
2 | coolant_control.c - coolant control methods
3 | Part of Grbl
4 |
5 | Copyright (c) 2012-2016 Sungeun K. Jeon for Gnea Research LLC
6 |
7 | Grbl is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Grbl is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Grbl. If not, see .
19 | */
20 |
21 | #include "grbl.h"
22 |
23 |
24 | void coolant_init()
25 | {
26 | GPIO_InitTypeDef GPIO_InitStructure;
27 | RCC_APB2PeriphClockCmd(RCC_COOLANT_FLOOD_PORT, ENABLE);
28 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
29 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
30 | GPIO_InitStructure.GPIO_Pin = 1 << COOLANT_FLOOD_BIT;
31 | GPIO_Init(COOLANT_FLOOD_PORT, &GPIO_InitStructure);
32 |
33 | RCC_APB2PeriphClockCmd(RCC_COOLANT_MIST_PORT, ENABLE);
34 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
35 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
36 | GPIO_InitStructure.GPIO_Pin = 1 << COOLANT_MIST_BIT;
37 | GPIO_Init(COOLANT_MIST_PORT, &GPIO_InitStructure);
38 | coolant_stop();
39 | }
40 |
41 |
42 | // Returns current coolant output state. Overrides may alter it from programmed state.
43 | uint8_t coolant_get_state()
44 | {
45 | uint8_t cl_state = COOLANT_STATE_DISABLE;
46 | #ifdef INVERT_COOLANT_FLOOD_PIN
47 | if (bit_isfalse(
48 | GPIO_ReadOutputData(COOLANT_FLOOD_PORT)
49 | ,(1 << COOLANT_FLOOD_BIT))) {
50 | #else
51 | if (bit_istrue(
52 | GPIO_ReadOutputData(COOLANT_FLOOD_PORT)
53 | ,(1 << COOLANT_FLOOD_BIT))) {
54 | #endif
55 | cl_state |= COOLANT_STATE_FLOOD;
56 | }
57 | #ifdef ENABLE_M7
58 | #ifdef INVERT_COOLANT_MIST_PIN
59 | if (bit_isfalse(
60 | GPIO_ReadOutputData(COOLANT_MIST_PORT)
61 | ,(1 << COOLANT_MIST_BIT))) {
62 | #else
63 | if (bit_istrue(
64 | GPIO_ReadOutputData(COOLANT_MIST_PORT)
65 | ,(1 << COOLANT_MIST_BIT))) {
66 | #endif
67 | cl_state |= COOLANT_STATE_MIST;
68 | }
69 | #endif
70 | return(cl_state);
71 | }
72 |
73 |
74 | // Directly called by coolant_init(), coolant_set_state(), and mc_reset(), which can be at
75 | // an interrupt-level. No report flag set, but only called by routines that don't need it.
76 | void coolant_stop()
77 | {
78 | #ifdef INVERT_COOLANT_FLOOD_PIN
79 | GPIO_SetBits(COOLANT_FLOOD_PORT,1 << COOLANT_FLOOD_BIT);
80 | #else
81 | GPIO_ResetBits(COOLANT_FLOOD_PORT,1 << COOLANT_FLOOD_BIT);
82 | #endif
83 | #ifdef ENABLE_M7
84 | #ifdef INVERT_COOLANT_MIST_PIN
85 | GPIO_SetBits(COOLANT_MIST_PORT, 1 << COOLANT_MIST_BIT);
86 | #else
87 | GPIO_ResetBits(COOLANT_MIST_PORT, 1 << COOLANT_MIST_BIT);
88 | #endif
89 | #endif
90 | }
91 |
92 |
93 | // Main program only. Immediately sets flood coolant running state and also mist coolant,
94 | // if enabled. Also sets a flag to report an update to a coolant state.
95 | // Called by coolant toggle override, parking restore, parking retract, sleep mode, g-code
96 | // parser program end, and g-code parser coolant_sync().
97 | void coolant_set_state(uint8_t mode)
98 | {
99 | if (sys.abort) { return; } // Block during abort.
100 |
101 | if (mode == COOLANT_DISABLE) {
102 |
103 | coolant_stop();
104 |
105 | } else {
106 | if (mode & COOLANT_FLOOD_ENABLE) {
107 | #ifdef INVERT_COOLANT_FLOOD_PIN
108 | GPIO_ResetBits(COOLANT_FLOOD_PORT,1 << COOLANT_FLOOD_BIT);
109 | #else
110 | GPIO_SetBits(COOLANT_FLOOD_PORT,1 << COOLANT_FLOOD_BIT);
111 | #endif
112 | }
113 |
114 | #ifdef ENABLE_M7
115 | if (mode & COOLANT_MIST_ENABLE) {
116 | #ifdef INVERT_COOLANT_MIST_PIN
117 | GPIO_ResetBits(COOLANT_MIST_PORT, 1 << COOLANT_MIST_BIT);
118 | #else
119 | GPIO_SetBits(COOLANT_MIST_PORT, 1 << COOLANT_MIST_BIT);
120 | #endif
121 | }
122 | #endif
123 | }
124 | sys.report_ovr_counter = 0; // Set to report change immediately
125 | }
126 |
127 |
128 | // G-code parser entry-point for setting coolant state. Forces a planner buffer sync and bails
129 | // if an abort or check-mode is active.
130 | void coolant_sync(uint8_t mode)
131 | {
132 | if (sys.state == STATE_CHECK_MODE) { return; }
133 | protocol_buffer_synchronize(); // Ensure coolant turns on when specified in program.
134 | coolant_set_state(mode);
135 | }
136 |
--------------------------------------------------------------------------------
/grbl/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 "grbl.h"
25 | #include
26 | #include "stm32eeprom.h"
27 | #include "settings.h"
28 | unsigned char EE_Buffer[0x400];
29 |
30 | #ifndef NOEEPROMSUPPORT
31 | void eeprom_flush()
32 | {
33 | uint32_t nAddress = EEPROM_START_ADDRESS;
34 | uint16_t *pBuffer = (uint16_t *)EE_Buffer;
35 | uint16_t nSize = PAGE_SIZE;
36 |
37 | FLASH_Status FlashStatus = FLASH_COMPLETE;
38 |
39 | /* Erase Page0 */
40 | FlashStatus = FLASH_ErasePage(EEPROM_START_ADDRESS);
41 |
42 | /* If erase operation was failed, a Flash error code is returned */
43 | if (FlashStatus != FLASH_COMPLETE)
44 | {
45 | return;
46 | }
47 |
48 | while (nSize > 0)
49 | {
50 | if (*pBuffer != 0xffff)
51 | {
52 | FLASH_ProgramHalfWord(nAddress, *pBuffer++);
53 | }
54 | else
55 | {
56 | pBuffer++;
57 | }
58 | if (*pBuffer != 0xffff)
59 | {
60 | FLASH_ProgramHalfWord(nAddress + 2, *pBuffer++);
61 | }
62 | else
63 | {
64 | pBuffer++;
65 | }
66 | nSize -= 4;
67 | nAddress += 4;
68 | }
69 | }
70 | void eeprom_init()
71 | {
72 | uint16_t VarIdx = 0;
73 | uint8_t *pTmp = EE_Buffer;
74 |
75 | for (VarIdx = 0; VarIdx < PAGE_SIZE; VarIdx++)
76 | {
77 | *pTmp++ = (*(__IO uint8_t*)(EEPROM_START_ADDRESS + VarIdx));
78 | }
79 |
80 | if (EE_Buffer[0] != SETTINGS_VERSION)
81 | {
82 | pTmp = EE_Buffer;
83 |
84 | for (VarIdx = 0; VarIdx < PAGE_SIZE; VarIdx++)
85 | {
86 | *pTmp++ = 0xFF;
87 | }
88 | }
89 | }
90 | #endif
91 |
92 | /*! \brief Read byte from EEPROM.
93 | *
94 | * This function reads one byte from a given EEPROM address.
95 | *
96 | * \note The CPU is halted for 4 clock cycles during EEPROM read.
97 | *
98 | * \param addr EEPROM address to read from.
99 | * \return The byte read from the EEPROM address.
100 | */
101 | unsigned char eeprom_get_char( unsigned int addr )
102 | {
103 | return EE_Buffer[addr];
104 | }
105 |
106 | /*! \brief Write byte to EEPROM.
107 | *
108 | * This function writes one byte to a given EEPROM address.
109 | * The differences between the existing byte and the new value is used
110 | * to select the most efficient EEPROM programming mode.
111 | *
112 | * \note The CPU is halted for 2 clock cycles during EEPROM programming.
113 | *
114 | * \note When this function returns, the new EEPROM value is not available
115 | * until the EEPROM programming time has passed. The EEPE bit in EECR
116 | * should be polled to check whether the programming is finished.
117 | *
118 | * \note The EEPROM_GetChar() function checks the EEPE bit automatically.
119 | *
120 | * \param addr EEPROM address to write to.
121 | * \param new_value New EEPROM value.
122 | */
123 | void eeprom_put_char( unsigned int addr, unsigned char new_value )
124 | {
125 | EE_Buffer[addr] = new_value;
126 | }
127 |
128 | // Extensions added as part of Grbl
129 |
130 |
131 | void memcpy_to_eeprom_with_checksum(unsigned int destination, char *source, unsigned int size) {
132 | unsigned char checksum = 0;
133 | for(; size > 0; size--) {
134 | checksum = (checksum << 1) || (checksum >> 7);
135 | checksum += *source;
136 | eeprom_put_char(destination++, *(source++));
137 | }
138 | eeprom_put_char(destination, checksum);
139 | #ifndef NOEEPROMSUPPORT
140 | eeprom_flush();
141 | #endif
142 | }
143 |
144 | int memcpy_from_eeprom_with_checksum(char *destination, unsigned int source, unsigned int size) {
145 | unsigned char data, checksum = 0;
146 | for(; size > 0; size--) {
147 | data = eeprom_get_char(source++);
148 | checksum = (checksum << 1) || (checksum >> 7);
149 | checksum += data;
150 | *(destination++) = data;
151 | }
152 | return(checksum == eeprom_get_char(source));
153 | }
154 |
155 | // end of file
156 |
--------------------------------------------------------------------------------
/SPL/inc/stm32f10x_pwr.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f10x_pwr.h
4 | * @author MCD Application Team
5 | * @version V3.5.0
6 | * @date 11-March-2011
7 | * @brief This file contains all the functions prototypes for the PWR firmware
8 | * library.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18 | *
19 | * © COPYRIGHT 2011 STMicroelectronics
20 | ******************************************************************************
21 | */
22 |
23 | /* Define to prevent recursive inclusion -------------------------------------*/
24 | #ifndef __STM32F10x_PWR_H
25 | #define __STM32F10x_PWR_H
26 |
27 | #ifdef __cplusplus
28 | extern "C" {
29 | #endif
30 |
31 | /* Includes ------------------------------------------------------------------*/
32 | #include "stm32f10x.h"
33 |
34 | /** @addtogroup STM32F10x_StdPeriph_Driver
35 | * @{
36 | */
37 |
38 | /** @addtogroup PWR
39 | * @{
40 | */
41 |
42 | /** @defgroup PWR_Exported_Types
43 | * @{
44 | */
45 |
46 | /**
47 | * @}
48 | */
49 |
50 | /** @defgroup PWR_Exported_Constants
51 | * @{
52 | */
53 |
54 | /** @defgroup PVD_detection_level
55 | * @{
56 | */
57 |
58 | #define PWR_PVDLevel_2V2 ((uint32_t)0x00000000)
59 | #define PWR_PVDLevel_2V3 ((uint32_t)0x00000020)
60 | #define PWR_PVDLevel_2V4 ((uint32_t)0x00000040)
61 | #define PWR_PVDLevel_2V5 ((uint32_t)0x00000060)
62 | #define PWR_PVDLevel_2V6 ((uint32_t)0x00000080)
63 | #define PWR_PVDLevel_2V7 ((uint32_t)0x000000A0)
64 | #define PWR_PVDLevel_2V8 ((uint32_t)0x000000C0)
65 | #define PWR_PVDLevel_2V9 ((uint32_t)0x000000E0)
66 | #define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLevel_2V2) || ((LEVEL) == PWR_PVDLevel_2V3)|| \
67 | ((LEVEL) == PWR_PVDLevel_2V4) || ((LEVEL) == PWR_PVDLevel_2V5)|| \
68 | ((LEVEL) == PWR_PVDLevel_2V6) || ((LEVEL) == PWR_PVDLevel_2V7)|| \
69 | ((LEVEL) == PWR_PVDLevel_2V8) || ((LEVEL) == PWR_PVDLevel_2V9))
70 | /**
71 | * @}
72 | */
73 |
74 | /** @defgroup Regulator_state_is_STOP_mode
75 | * @{
76 | */
77 |
78 | #define PWR_Regulator_ON ((uint32_t)0x00000000)
79 | #define PWR_Regulator_LowPower ((uint32_t)0x00000001)
80 | #define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_Regulator_ON) || \
81 | ((REGULATOR) == PWR_Regulator_LowPower))
82 | /**
83 | * @}
84 | */
85 |
86 | /** @defgroup STOP_mode_entry
87 | * @{
88 | */
89 |
90 | #define PWR_STOPEntry_WFI ((uint8_t)0x01)
91 | #define PWR_STOPEntry_WFE ((uint8_t)0x02)
92 | #define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPEntry_WFI) || ((ENTRY) == PWR_STOPEntry_WFE))
93 |
94 | /**
95 | * @}
96 | */
97 |
98 | /** @defgroup PWR_Flag
99 | * @{
100 | */
101 |
102 | #define PWR_FLAG_WU ((uint32_t)0x00000001)
103 | #define PWR_FLAG_SB ((uint32_t)0x00000002)
104 | #define PWR_FLAG_PVDO ((uint32_t)0x00000004)
105 | #define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB) || \
106 | ((FLAG) == PWR_FLAG_PVDO))
107 |
108 | #define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_SB))
109 | /**
110 | * @}
111 | */
112 |
113 | /**
114 | * @}
115 | */
116 |
117 | /** @defgroup PWR_Exported_Macros
118 | * @{
119 | */
120 |
121 | /**
122 | * @}
123 | */
124 |
125 | /** @defgroup PWR_Exported_Functions
126 | * @{
127 | */
128 |
129 | void PWR_DeInit(void);
130 | void PWR_BackupAccessCmd(FunctionalState NewState);
131 | void PWR_PVDCmd(FunctionalState NewState);
132 | void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel);
133 | void PWR_WakeUpPinCmd(FunctionalState NewState);
134 | void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry);
135 | void PWR_EnterSTANDBYMode(void);
136 | FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG);
137 | void PWR_ClearFlag(uint32_t PWR_FLAG);
138 |
139 | #ifdef __cplusplus
140 | }
141 | #endif
142 |
143 | #endif /* __STM32F10x_PWR_H */
144 | /**
145 | * @}
146 | */
147 |
148 | /**
149 | * @}
150 | */
151 |
152 | /**
153 | * @}
154 | */
155 |
156 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
157 |
--------------------------------------------------------------------------------
/grbl/report.h:
--------------------------------------------------------------------------------
1 | /*
2 | report.h - reporting and messaging methods
3 | Part of Grbl
4 |
5 | Copyright (c) 2012-2016 Sungeun K. Jeon for Gnea Research LLC
6 |
7 | Grbl is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Grbl is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Grbl. If not, see .
19 | */
20 | #ifndef report_h
21 | #define report_h
22 |
23 | // Define Grbl status codes. Valid values (0-255)
24 | #define STATUS_OK 0
25 | #define STATUS_EXPECTED_COMMAND_LETTER 1
26 | #define STATUS_BAD_NUMBER_FORMAT 2
27 | #define STATUS_INVALID_STATEMENT 3
28 | #define STATUS_NEGATIVE_VALUE 4
29 | #define STATUS_SETTING_DISABLED 5
30 | #define STATUS_SETTING_STEP_PULSE_MIN 6
31 | #define STATUS_SETTING_READ_FAIL 7
32 | #define STATUS_IDLE_ERROR 8
33 | #define STATUS_SYSTEM_GC_LOCK 9
34 | #define STATUS_SOFT_LIMIT_ERROR 10
35 | #define STATUS_OVERFLOW 11
36 | #define STATUS_MAX_STEP_RATE_EXCEEDED 12
37 | #define STATUS_CHECK_DOOR 13
38 | #define STATUS_LINE_LENGTH_EXCEEDED 14
39 | #define STATUS_TRAVEL_EXCEEDED 15
40 | #define STATUS_INVALID_JOG_COMMAND 16
41 | #define STATUS_SETTING_DISABLED_LASER 17
42 |
43 | #define STATUS_GCODE_UNSUPPORTED_COMMAND 20
44 | #define STATUS_GCODE_MODAL_GROUP_VIOLATION 21
45 | #define STATUS_GCODE_UNDEFINED_FEED_RATE 22
46 | #define STATUS_GCODE_COMMAND_VALUE_NOT_INTEGER 23
47 | #define STATUS_GCODE_AXIS_COMMAND_CONFLICT 24
48 | #define STATUS_GCODE_WORD_REPEATED 25
49 | #define STATUS_GCODE_NO_AXIS_WORDS 26
50 | #define STATUS_GCODE_INVALID_LINE_NUMBER 27
51 | #define STATUS_GCODE_VALUE_WORD_MISSING 28
52 | #define STATUS_GCODE_UNSUPPORTED_COORD_SYS 29
53 | #define STATUS_GCODE_G53_INVALID_MOTION_MODE 30
54 | #define STATUS_GCODE_AXIS_WORDS_EXIST 31
55 | #define STATUS_GCODE_NO_AXIS_WORDS_IN_PLANE 32
56 | #define STATUS_GCODE_INVALID_TARGET 33
57 | #define STATUS_GCODE_ARC_RADIUS_ERROR 34
58 | #define STATUS_GCODE_NO_OFFSETS_IN_PLANE 35
59 | #define STATUS_GCODE_UNUSED_WORDS 36
60 | #define STATUS_GCODE_G43_DYNAMIC_AXIS_ERROR 37
61 | #define STATUS_GCODE_MAX_VALUE_EXCEEDED 38
62 |
63 | // Define Grbl alarm codes. Valid values (1-255). 0 is reserved.
64 | #define ALARM_HARD_LIMIT_ERROR EXEC_ALARM_HARD_LIMIT
65 | #define ALARM_SOFT_LIMIT_ERROR EXEC_ALARM_SOFT_LIMIT
66 | #define ALARM_ABORT_CYCLE EXEC_ALARM_ABORT_CYCLE
67 | #define ALARM_PROBE_FAIL_INITIAL EXEC_ALARM_PROBE_FAIL_INITIAL
68 | #define ALARM_PROBE_FAIL_CONTACT EXEC_ALARM_PROBE_FAIL_CONTACT
69 | #define ALARM_HOMING_FAIL_RESET EXEC_ALARM_HOMING_FAIL_RESET
70 | #define ALARM_HOMING_FAIL_DOOR EXEC_ALARM_HOMING_FAIL_DOOR
71 | #define ALARM_HOMING_FAIL_PULLOFF EXEC_ALARM_HOMING_FAIL_PULLOFF
72 | #define ALARM_HOMING_FAIL_APPROACH EXEC_ALARM_HOMING_FAIL_APPROACH
73 |
74 | // Define Grbl feedback message codes. Valid values (0-255).
75 | #define MESSAGE_CRITICAL_EVENT 1
76 | #define MESSAGE_ALARM_LOCK 2
77 | #define MESSAGE_ALARM_UNLOCK 3
78 | #define MESSAGE_ENABLED 4
79 | #define MESSAGE_DISABLED 5
80 | #define MESSAGE_SAFETY_DOOR_AJAR 6
81 | #define MESSAGE_CHECK_LIMITS 7
82 | #define MESSAGE_PROGRAM_END 8
83 | #define MESSAGE_RESTORE_DEFAULTS 9
84 | #define MESSAGE_SPINDLE_RESTORE 10
85 | #define MESSAGE_SLEEP_MODE 11
86 |
87 | // Prints system status messages.
88 | void report_status_message(uint8_t status_code);
89 |
90 | // Prints system alarm messages.
91 | void report_alarm_message(uint8_t alarm_code);
92 |
93 | // Prints miscellaneous feedback messages.
94 | void report_feedback_message(uint8_t message_code);
95 |
96 | // Prints welcome message
97 | void report_init_message();
98 |
99 | // Prints Grbl help and current global settings
100 | void report_grbl_help();
101 |
102 | // Prints Grbl global settings
103 | void report_grbl_settings();
104 |
105 | // Prints an echo of the pre-parsed line received right before execution.
106 | void report_echo_line_received(char *line);
107 |
108 | // Prints realtime status report
109 | void report_realtime_status();
110 |
111 | // Prints recorded probe position
112 | void report_probe_parameters();
113 |
114 | // Prints Grbl NGC parameters (coordinate offsets, probe)
115 | void report_ngc_parameters();
116 |
117 | // Prints current g-code parser mode state
118 | void report_gcode_modes();
119 |
120 | // Prints startup line when requested and executed.
121 | void report_startup_line(uint8_t n, char *line);
122 | void report_execute_startup_message(char *line, uint8_t status_code);
123 |
124 | // Prints build info and user info
125 | void report_build_info(char *line);
126 |
127 | #ifdef DEBUG
128 | void report_realtime_debug();
129 | #endif
130 |
131 | #endif
132 |
--------------------------------------------------------------------------------
/grbl/print.c:
--------------------------------------------------------------------------------
1 | /*
2 | print.c - Functions for formatting output strings
3 | Part of Grbl
4 |
5 | Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
6 | Copyright (c) 2009-2011 Simen Svale Skogsrud
7 |
8 | Grbl is free software: you can redistribute it and/or modify
9 | it under the terms of the GNU General Public License as published by
10 | the Free Software Foundation, either version 3 of the License, or
11 | (at your option) any later version.
12 |
13 | Grbl is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU General Public License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with Grbl. If not, see .
20 | */
21 |
22 | #include "grbl.h"
23 |
24 |
25 | void printString(const char *s)
26 | {
27 | while (*s)
28 | serial_write(*s++);
29 | }
30 |
31 | // Prints an uint8 variable in base 10.
32 | void print_uint8_base10(uint8_t n)
33 | {
34 | uint8_t digit_a = 0;
35 | uint8_t digit_b = 0;
36 | if (n >= 100) { // 100-255
37 | digit_a = '0' + n % 10;
38 | n /= 10;
39 | }
40 | if (n >= 10) { // 10-99
41 | digit_b = '0' + n % 10;
42 | n /= 10;
43 | }
44 | serial_write('0' + n);
45 | if (digit_b) { serial_write(digit_b); }
46 | if (digit_a) { serial_write(digit_a); }
47 | }
48 |
49 |
50 | // Prints an uint8 variable in base 2 with desired number of desired digits.
51 | void print_uint8_base2_ndigit(uint8_t n, uint8_t digits) {
52 | unsigned char buf[digits];
53 | uint8_t i = 0;
54 |
55 | for (; i < digits; i++) {
56 | buf[i] = n % 2 ;
57 | n /= 2;
58 | }
59 |
60 | for (; i > 0; i--)
61 | serial_write('0' + buf[i - 1]);
62 | }
63 |
64 |
65 | void print_uint32_base10(uint32_t n)
66 | {
67 | if (n == 0) {
68 | serial_write('0');
69 | return;
70 | }
71 |
72 | unsigned char buf[10];
73 | uint8_t i = 0;
74 |
75 | while (n > 0) {
76 | buf[i++] = n % 10;
77 | n /= 10;
78 | }
79 |
80 | for (; i > 0; i--)
81 | serial_write('0' + buf[i-1]);
82 | }
83 |
84 |
85 | void printInteger(long n)
86 | {
87 | if (n < 0) {
88 | serial_write('-');
89 | print_uint32_base10(-n);
90 | } else {
91 | print_uint32_base10(n);
92 | }
93 | }
94 |
95 |
96 | // Convert float to string by immediately converting to a long integer, which contains
97 | // more digits than a float. Number of decimal places, which are tracked by a counter,
98 | // may be set by the user. The integer is then efficiently converted to a string.
99 | // NOTE: AVR '%' and '/' integer operations are very efficient. Bitshifting speed-up
100 | // techniques are actually just slightly slower. Found this out the hard way.
101 | void printFloat(float n, uint8_t decimal_places)
102 | {
103 | if (n < 0) {
104 | serial_write('-');
105 | n = -n;
106 | }
107 |
108 | uint8_t decimals = decimal_places;
109 | while (decimals >= 2) { // Quickly convert values expected to be E0 to E-4.
110 | n *= 100;
111 | decimals -= 2;
112 | }
113 | if (decimals) { n *= 10; }
114 | n += 0.5; // Add rounding factor. Ensures carryover through entire value.
115 |
116 | // Generate digits backwards and store in string.
117 | unsigned char buf[13];
118 | uint8_t i = 0;
119 | uint32_t a = (long)n;
120 | while(a > 0) {
121 | buf[i++] = (a % 10) + '0'; // Get digit
122 | a /= 10;
123 | }
124 | while (i < decimal_places) {
125 | buf[i++] = '0'; // Fill in zeros to decimal point for (n < 1)
126 | }
127 | if (i == decimal_places) { // Fill in leading zero, if needed.
128 | buf[i++] = '0';
129 | }
130 |
131 | // Print the generated string.
132 | for (; i > 0; i--) {
133 | if (i == decimal_places) { serial_write('.'); } // Insert decimal point in right place.
134 | serial_write(buf[i-1]);
135 | }
136 | }
137 |
138 |
139 | // Floating value printing handlers for special variables types used in Grbl and are defined
140 | // in the config.h.
141 | // - CoordValue: Handles all position or coordinate values in inches or mm reporting.
142 | // - RateValue: Handles feed rate and current velocity in inches or mm reporting.
143 | void printFloat_CoordValue(float n) {
144 | if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) {
145 | printFloat(n*INCH_PER_MM,N_DECIMAL_COORDVALUE_INCH);
146 | } else {
147 | printFloat(n,N_DECIMAL_COORDVALUE_MM);
148 | }
149 | }
150 |
151 | void printFloat_RateValue(float n) {
152 | if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) {
153 | printFloat(n*INCH_PER_MM,N_DECIMAL_RATEVALUE_INCH);
154 | } else {
155 | printFloat(n,N_DECIMAL_RATEVALUE_MM);
156 | }
157 | }
158 |
159 | // Debug tool to print free memory in bytes at the called point.
160 | // NOTE: Keep commented unless using. Part of this function always gets compiled in.
161 | // void printFreeMemory()
162 | // {
163 | // extern int __heap_start, *__brkval;
164 | // uint16_t free; // Up to 64k values.
165 | // free = (int) &free - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
166 | // printInteger((int32_t)free);
167 | // printString(" ");
168 | // }
169 |
--------------------------------------------------------------------------------
/grbl/cpu_map_stm32.h:
--------------------------------------------------------------------------------
1 | #ifndef __cpu_map_stm32_h__
2 | #define __cpu_map_stm32_h__
3 |
4 | // Define step pulse output pins. NOTE: All step bit pins must be on the same port.
5 | #define STEP_PORT GPIOA
6 | #define RCC_STEP_PORT RCC_APB2Periph_GPIOA
7 | #define X_STEP_BIT 0
8 | #define Y_STEP_BIT 1
9 | #define Z_STEP_BIT 2
10 | #define STEP_MASK ((1 << X_STEP_BIT) | (1 << Y_STEP_BIT) | (1 << Z_STEP_BIT)) // All step bits
11 |
12 | // Define step direction output pins. NOTE: All direction pins must be on the same port.
13 | #define DIRECTION_PORT GPIOA
14 | #define RCC_DIRECTION_PORT RCC_APB2Periph_GPIOA
15 | #define X_DIRECTION_BIT 3
16 | #define Y_DIRECTION_BIT 4
17 | #define Z_DIRECTION_BIT 5
18 | #define DIRECTION_MASK ((1 << X_DIRECTION_BIT) | (1 << Y_DIRECTION_BIT) | (1 << Z_DIRECTION_BIT)) // All direction bits
19 |
20 | // Define stepper driver enable/disable output pin.
21 | #define STEPPERS_DISABLE_PORT GPIOA
22 | #define RCC_STEPPERS_DISABLE_PORT RCC_APB2Periph_GPIOA
23 | #define STEPPERS_DISABLE_BIT 6
24 | #define STEPPERS_DISABLE_MASK (1 << STEPPERS_DISABLE_BIT)
25 | #define SetStepperDisableBit() GPIO_SetBits(STEPPERS_DISABLE_PORT, STEPPERS_DISABLE_MASK)
26 | #define ResetStepperDisableBit() GPIO_ResetBits(STEPPERS_DISABLE_PORT, STEPPERS_DISABLE_MASK)
27 |
28 | // Define homing/hard limit switch input pins and limit interrupt vectors.
29 | // NOTE: All limit bit pins must be on the same port
30 | #define LIMIT_PIN GPIOB
31 | #define LIMIT_PORT GPIOB
32 | #define RCC_LIMIT_PORT RCC_APB2Periph_GPIOB
33 | #define GPIO_LIMIT_PORT GPIO_PortSourceGPIOB
34 | #define X_LIMIT_BIT 10
35 | #define Y_LIMIT_BIT 11
36 | #define Z_LIMIT_BIT 12
37 |
38 | #define LIMIT_MASK ((1 << X_LIMIT_BIT) | (1 << Y_LIMIT_BIT) | (1 << Z_LIMIT_BIT)) // All limit bits
39 |
40 | // Define spindle enable and spindle direction output pins.
41 | #define SPINDLE_ENABLE_PORT GPIOB
42 | #define RCC_SPINDLE_ENABLE_PORT RCC_APB2Periph_GPIOB
43 | #define SPINDLE_ENABLE_BIT 13 //
44 | #ifndef USE_SPINDLE_DIR_AS_ENABLE_PIN
45 | #define SPINDLE_DIRECTION_DDR GPIOB
46 | #define SPINDLE_DIRECTION_PORT GPIOB
47 | #define SPINDLE_DIRECTION_BIT 14 //
48 | #endif
49 | #define SetSpindleEnablebit() GPIO_WriteBit(SPINDLE_ENABLE_PORT, 1 << SPINDLE_ENABLE_BIT, Bit_SET)
50 | #define ResetSpindleEnablebit() GPIO_WriteBit(SPINDLE_ENABLE_PORT, 1 << SPINDLE_ENABLE_BIT, Bit_RESET)
51 | #define SetSpindleDirectionBit() GPIO_WriteBit(SPINDLE_DIRECTION_PORT, 1 << SPINDLE_DIRECTION_BIT, Bit_SET)
52 | #define ResetSpindleDirectionBit() GPIO_WriteBit(SPINDLE_DIRECTION_PORT, 1 << SPINDLE_DIRECTION_BIT, Bit_RESET)
53 |
54 | // Define flood and mist coolant enable output pins.
55 | // a later date if flash and memory space allows.
56 | #define COOLANT_FLOOD_PORT GPIOB
57 | #define RCC_COOLANT_FLOOD_PORT RCC_APB2Periph_GPIOB
58 | #define COOLANT_FLOOD_BIT 3
59 | #define COOLANT_MIST_PORT GPIOB
60 | #define RCC_COOLANT_MIST_PORT RCC_APB2Periph_GPIOB
61 | #define COOLANT_MIST_BIT 4
62 |
63 | // Define user-control controls (cycle start, reset, feed hold) input pins.
64 | // NOTE: All CONTROLs pins must be on the same port and not on a port with other input pins (limits).
65 | #define CONTROL_PIN_PORT GPIOB
66 | #define CONTROL_PORT GPIOB
67 | #define RCC_CONTROL_PORT RCC_APB2Periph_GPIOB
68 | #define GPIO_CONTROL_PORT GPIO_PortSourceGPIOB
69 | #define CONTROL_RESET_BIT 5
70 | #define CONTROL_FEED_HOLD_BIT 6
71 | #define CONTROL_CYCLE_START_BIT 7
72 | #define CONTROL_SAFETY_DOOR_BIT 8
73 | #define CONTROL_MASK ((1 << CONTROL_RESET_BIT) | (1 << CONTROL_FEED_HOLD_BIT) | (1 << CONTROL_CYCLE_START_BIT) | (1 << CONTROL_SAFETY_DOOR_BIT))
74 |
75 | // Define probe switch input pin.
76 | #define PROBE_PORT GPIOA
77 | #define RCC_PROBE_PORT RCC_APB2Periph_GPIOA
78 | #define PROBE_BIT 15
79 | #define PROBE_MASK (1 << PROBE_BIT)
80 |
81 | // Start of PWM & Stepper Enabled Spindle
82 | #ifdef VARIABLE_SPINDLE
83 |
84 | // NOTE: On the 328p, these must be the same as the SPINDLE_ENABLE settings.
85 | #define SPINDLE_PWM_FREQUENCY 10000 // KHz
86 | #define SPINDLE_PWM_DDR GPIOA
87 | #define SPINDLE_PWM_PORT GPIOA
88 | #define RCC_SPINDLE_PWM_PORT RCC_APB2Periph_GPIOA
89 | #define SPINDLE_PWM_BIT 8
90 | #endif // End of VARIABLE_SPINDLE
91 | #define SPINDLE_PWM_MAX_VALUE (1000000 / SPINDLE_PWM_FREQUENCY)
92 | #ifndef SPINDLE_PWM_MIN_VALUE
93 | #define SPINDLE_PWM_MIN_VALUE 1 // Must be greater than zero.
94 | #endif
95 | #define SPINDLE_PWM_OFF_VALUE 0
96 | #define SPINDLE_PWM_RANGE (SPINDLE_PWM_MAX_VALUE - SPINDLE_PWM_MIN_VALUE)
97 |
98 | // Port A Port B
99 | // 0 X_STEP_BIT
100 | // 1 Y_STEP_BIT
101 | // 2 Z_STEP_BIT
102 | // 3 X_DIRECTION_BIT COOLANT_FLOOD_BIT
103 | // 4 Y_DIRECTION_BIT COOLANT_MIST_BIT
104 | // 5 Z_DIRECTION_BIT CONTROL_RESET_BIT
105 | // 6 STEPPERS_DISABLE_BIT CONTROL_FEED_HOLD_BIT
106 | // 7 CONTROL_CYCLE_START_BIT
107 | // 8 SPINDLE_PWM_BIT CONTROL_SAFETY_DOOR_BIT
108 | // 9
109 | // 10 X_LIMIT_BIT
110 | // 11 Y_LIMIT_BIT
111 | // 12 Z_LIMIT_BIT
112 | // 13 14 SWD SPINDLE_ENABLE_BIT
113 | // 14 SPINDLE_DIRECTION_BIT
114 | // 15 PROBE_BIT
115 |
116 | #endif
--------------------------------------------------------------------------------
/usb/hw_config.c:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2011 STMicroelectronics ********************
2 | * File Name : hw_config.c
3 | * Author : MCD Application Team
4 | * Version : V3.3.0
5 | * Date : 21-March-2011
6 | * Description : Hardware Configuration & Setup
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 |
16 | #include "stm32f10x_it.h"
17 |
18 | #include "usb_lib.h"
19 | #include "usb_prop.h"
20 | #include "usb_desc.h"
21 | #include "hw_config.h"
22 | #include "platform_config.h"
23 | #include "usb_pwr.h"
24 | #include "stm32f10x_rcc.h"
25 | #include "misc.h"
26 |
27 | ErrorStatus HSEStartUpStatus;
28 |
29 | static void IntToUnicode(uint32_t value, uint8_t *pbuf, uint8_t len);
30 |
31 | /*******************************************************************************
32 | * Description : Configures Main system clocks & power
33 | *******************************************************************************/
34 | void Set_System(void)
35 | {
36 | }
37 |
38 | /*******************************************************************************
39 | * Description : Configures USB Clock input (48MHz)
40 | *******************************************************************************/
41 | void Set_USBClock(void)
42 | {
43 | /* Select USBCLK source */
44 | RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5);
45 |
46 | /* Enable the USB clock */
47 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);
48 | }
49 |
50 | /*******************************************************************************
51 | * Description : Power-off system clocks and power while entering suspend mode
52 | *******************************************************************************/
53 | void Enter_LowPowerMode(void)
54 | {
55 | /* Set the device state to suspend */
56 | bDeviceState = SUSPENDED;
57 | }
58 |
59 | /*******************************************************************************
60 | * Description : Restores system clocks and power while exiting suspend mode
61 | *******************************************************************************/
62 | void Leave_LowPowerMode(void)
63 | {
64 | DEVICE_INFO *pInfo = &Device_Info;
65 |
66 | /* Set the device state to the correct state */
67 | if (pInfo->Current_Configuration != 0)
68 | {
69 | /* Device configured */
70 | bDeviceState = CONFIGURED;
71 | }
72 | else
73 | {
74 | bDeviceState = ATTACHED;
75 | }
76 | }
77 |
78 | /*******************************************************************************
79 | * Description : Configures the USB interrupts
80 | *******************************************************************************/
81 | void USB_Interrupts_Config(void)
82 | {
83 | NVIC_InitTypeDef NVIC_InitStructure;
84 |
85 | NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
86 |
87 | NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn;
88 | NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
89 | NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
90 | NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
91 | NVIC_Init(&NVIC_InitStructure);
92 | }
93 |
94 | /*******************************************************************************
95 | * Description : Software Connection/Disconnection of USB Cable
96 | *******************************************************************************/
97 | void USB_Cable_Config(FunctionalState NewState)
98 | {
99 | }
100 |
101 | /*******************************************************************************
102 | * Description : Create the serial number string descriptor.
103 | *******************************************************************************/
104 | void Get_SerialNum(void)
105 | {
106 | uint32_t Device_Serial0, Device_Serial1, Device_Serial2;
107 |
108 | Device_Serial0 = *(__IO uint32_t*) (0x1FFFF7E8);
109 | Device_Serial1 = *(__IO uint32_t*) (0x1FFFF7EC);
110 | Device_Serial2 = *(__IO uint32_t*) (0x1FFFF7F0);
111 |
112 | Device_Serial0 += Device_Serial2;
113 |
114 | if (Device_Serial0 != 0)
115 | {
116 | IntToUnicode(Device_Serial0, &Virtual_Com_Port_StringSerial[2], 8);
117 | IntToUnicode(Device_Serial1, &Virtual_Com_Port_StringSerial[18], 4);
118 | }
119 | }
120 |
121 | /*******************************************************************************
122 | * Description : Convert Hex 32Bits value into char.
123 | *******************************************************************************/
124 | static void IntToUnicode(uint32_t value, uint8_t *pbuf, uint8_t len)
125 | {
126 | uint8_t idx = 0;
127 |
128 | for (idx = 0; idx < len; idx++)
129 | {
130 | if (((value >> 28)) < 0xA)
131 | {
132 | pbuf[2 * idx] = (value >> 28) + '0';
133 | }
134 | else
135 | {
136 | pbuf[2 * idx] = (value >> 28) + 'A' - 10;
137 | }
138 |
139 | value = value << 4;
140 |
141 | pbuf[2 * idx + 1] = 0;
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/stm_usb_fs_lib/src/usb_sil.c:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
2 | * File Name : usb_sil.c
3 | * Author : MCD Application Team
4 | * Version : V3.2.1
5 | * Date : 07/05/2010
6 | * Description : Simplified Interface Layer for Global Initialization and
7 | * Endpoint Rea/Write operations.
8 | ********************************************************************************
9 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
10 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
11 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
12 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
13 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
14 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
15 | *******************************************************************************/
16 |
17 | /* Includes ------------------------------------------------------------------*/
18 | #include "usb_lib.h"
19 |
20 | /* Private typedef -----------------------------------------------------------*/
21 | /* Private define ------------------------------------------------------------*/
22 | /* Private macro -------------------------------------------------------------*/
23 | /* Private variables ---------------------------------------------------------*/
24 | /* Extern variables ----------------------------------------------------------*/
25 | /* Private function prototypes -----------------------------------------------*/
26 | /* Private functions ---------------------------------------------------------*/
27 |
28 | /*******************************************************************************
29 | * Function Name : USB_SIL_Init
30 | * Description : Initialize the USB Device IP and the Endpoint 0.
31 | * Input : None.
32 | * Output : None.
33 | * Return : Status.
34 | *******************************************************************************/
35 | uint32_t USB_SIL_Init(void)
36 | {
37 | #ifndef STM32F10X_CL
38 |
39 | /* USB interrupts initialization */
40 | /* clear pending interrupts */
41 | _SetISTR(0);
42 | wInterrupt_Mask = IMR_MSK;
43 | /* set interrupts mask */
44 | _SetCNTR(wInterrupt_Mask);
45 |
46 | #else
47 |
48 | /* Perform OTG Device initialization procedure (including EP0 init) */
49 | OTG_DEV_Init();
50 |
51 | #endif /* STM32F10X_CL */
52 |
53 | return 0;
54 | }
55 |
56 | /*******************************************************************************
57 | * Function Name : USB_SIL_Write
58 | * Description : Write a buffer of data to a selected endpoint.
59 | * Input : - bEpAddr: The address of the non control endpoint.
60 | * - pBufferPointer: The pointer to the buffer of data to be written
61 | * to the endpoint.
62 | * - wBufferSize: Number of data to be written (in bytes).
63 | * Output : None.
64 | * Return : Status.
65 | *******************************************************************************/
66 | uint32_t USB_SIL_Write(uint8_t bEpAddr, uint8_t* pBufferPointer, uint32_t wBufferSize)
67 | {
68 | #ifndef STM32F10X_CL
69 |
70 | /* Use the memory interface function to write to the selected endpoint */
71 | UserToPMABufferCopy(pBufferPointer, GetEPTxAddr(bEpAddr & 0x7F), wBufferSize);
72 |
73 | /* Update the data length in the control register */
74 | SetEPTxCount((bEpAddr & 0x7F), wBufferSize);
75 |
76 | #else
77 |
78 | /* Use the PCD interface layer function to write to the selected endpoint */
79 | PCD_EP_Write (bEpAddr, pBufferPointer, wBufferSize);
80 |
81 | #endif /* STM32F10X_CL */
82 |
83 | return 0;
84 | }
85 |
86 | /*******************************************************************************
87 | * Function Name : USB_SIL_Read
88 | * Description : Write a buffer of data to a selected endpoint.
89 | * Input : - bEpAddr: The address of the non control endpoint.
90 | * - pBufferPointer: The pointer to which will be saved the
91 | * received data buffer.
92 | * Output : None.
93 | * Return : Number of received data (in Bytes).
94 | *******************************************************************************/
95 | uint32_t USB_SIL_Read(uint8_t bEpAddr, uint8_t* pBufferPointer)
96 | {
97 | uint32_t DataLength = 0;
98 |
99 | #ifndef STM32F10X_CL
100 |
101 | /* Get the number of received data on the selected Endpoint */
102 | DataLength = GetEPRxCount(bEpAddr & 0x7F);
103 |
104 | /* Use the memory interface function to write to the selected endpoint */
105 | PMAToUserBufferCopy(pBufferPointer, GetEPRxAddr(bEpAddr & 0x7F), DataLength);
106 |
107 | #else
108 |
109 | USB_OTG_EP *ep;
110 |
111 | /* Get the structure pointer of the selected Endpoint */
112 | ep = PCD_GetOutEP(bEpAddr);
113 |
114 | /* Get the number of received data */
115 | DataLength = ep->xfer_len;
116 |
117 | /* Use the PCD interface layer function to read the selected endpoint */
118 | PCD_EP_Read (bEpAddr, pBufferPointer, DataLength);
119 |
120 | #endif /* STM32F10X_CL */
121 |
122 | /* Return the number of received data */
123 | return DataLength;
124 | }
125 |
126 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
127 |
--------------------------------------------------------------------------------
/grbl/nuts_bolts.c:
--------------------------------------------------------------------------------
1 | /*
2 | nuts_bolts.c - Shared functions
3 | Part of Grbl
4 |
5 | Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
6 | Copyright (c) 2009-2011 Simen Svale Skogsrud
7 |
8 | Grbl is free software: you can redistribute it and/or modify
9 | it under the terms of the GNU General Public License as published by
10 | the Free Software Foundation, either version 3 of the License, or
11 | (at your option) any later version.
12 |
13 | Grbl is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU General Public License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with Grbl. If not, see .
20 | */
21 |
22 | #include "grbl.h"
23 |
24 |
25 | #define MAX_INT_DIGITS 8 // Maximum number of digits in int32 (and float)
26 |
27 |
28 | // Extracts a floating point value from a string. The following code is based loosely on
29 | // the avr-libc strtod() function by Michael Stumpf and Dmitry Xmelkov and many freely
30 | // available conversion method examples, but has been highly optimized for Grbl. For known
31 | // CNC applications, the typical decimal value is expected to be in the range of E0 to E-4.
32 | // Scientific notation is officially not supported by g-code, and the 'E' character may
33 | // be a g-code word on some CNC systems. So, 'E' notation will not be recognized.
34 | // NOTE: Thanks to Radu-Eosif Mihailescu for identifying the issues with using strtod().
35 | uint8_t read_float(char *line, uint8_t *char_counter, float *float_ptr)
36 | {
37 | char *ptr = line + *char_counter;
38 | unsigned char c;
39 |
40 | // Grab first character and increment pointer. No spaces assumed in line.
41 | c = *ptr++;
42 |
43 | // Capture initial positive/minus character
44 | bool isnegative = false;
45 | if (c == '-') {
46 | isnegative = true;
47 | c = *ptr++;
48 | } else if (c == '+') {
49 | c = *ptr++;
50 | }
51 |
52 | // Extract number into fast integer. Track decimal in terms of exponent value.
53 | uint32_t intval = 0;
54 | int8_t exp = 0;
55 | uint8_t ndigit = 0;
56 | bool isdecimal = false;
57 | while(1) {
58 | c -= '0';
59 | if (c <= 9) {
60 | ndigit++;
61 | if (ndigit <= MAX_INT_DIGITS) {
62 | if (isdecimal) { exp--; }
63 | intval = (((intval << 2) + intval) << 1) + c; // intval*10 + c
64 | } else {
65 | if (!(isdecimal)) { exp++; } // Drop overflow digits
66 | }
67 | } else if (c == (('.'-'0') & 0xff) && !(isdecimal)) {
68 | isdecimal = true;
69 | } else {
70 | break;
71 | }
72 | c = *ptr++;
73 | }
74 |
75 | // Return if no digits have been read.
76 | if (!ndigit) { return(false); };
77 |
78 | // Convert integer into floating point.
79 | float fval;
80 | fval = (float)intval;
81 |
82 | // Apply decimal. Should perform no more than two floating point multiplications for the
83 | // expected range of E0 to E-4.
84 | if (fval != 0) {
85 | while (exp <= -2) {
86 | fval *= 0.01f;
87 | exp += 2;
88 | }
89 | if (exp < 0) {
90 | fval *= 0.1f;
91 | } else if (exp > 0) {
92 | do {
93 | fval *= 10.0f;
94 | } while (--exp > 0);
95 | }
96 | }
97 |
98 | // Assign floating point value with correct sign.
99 | if (isnegative) {
100 | *float_ptr = -fval;
101 | } else {
102 | *float_ptr = fval;
103 | }
104 |
105 | *char_counter = ptr - line - 1; // Set char_counter to next statement
106 |
107 | return(true);
108 | }
109 |
110 |
111 | // Non-blocking delay function used for general operation and suspend features.
112 | void delay_sec(float seconds, uint8_t mode)
113 | {
114 | uint16_t i = (uint16_t)ceilf(1000 / DWELL_TIME_STEP*seconds);
115 | while (i-- > 0) {
116 | if (sys.abort) { return; }
117 | if (mode == DELAY_MODE_DWELL) {
118 | protocol_execute_realtime();
119 | } else { // DELAY_MODE_SYS_SUSPEND
120 | // Execute rt_system() only to avoid nesting suspend loops.
121 | protocol_exec_rt_system();
122 | if (sys.suspend & SUSPEND_RESTART_RETRACT) { return; } // Bail, if safety door reopens.
123 | }
124 | _delay_ms(DWELL_TIME_STEP); // Delay DWELL_TIME_STEP increment
125 | }
126 | }
127 |
128 |
129 | // Delays variable defined milliseconds. Compiler compatibility fix for _delay_ms(),
130 | // which only accepts constants in future compiler releases.
131 | void delay_ms(uint16_t ms)
132 | {
133 | while ( ms-- ) { _delay_ms(1); }
134 | }
135 |
136 |
137 | // Simple hypotenuse computation function.
138 | float hypot_f(float x, float y) { return(sqrtf(x*x + y*y)); }
139 |
140 |
141 | float convert_delta_vector_to_unit_vector(float *vector)
142 | {
143 | uint8_t idx;
144 | float magnitude = 0.0f;
145 | for (idx=0; idx© COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Includes ------------------------------------------------------------------*/
23 | #include "stm32f10x_iwdg.h"
24 |
25 | /** @addtogroup STM32F10x_StdPeriph_Driver
26 | * @{
27 | */
28 |
29 | /** @defgroup IWDG
30 | * @brief IWDG driver modules
31 | * @{
32 | */
33 |
34 | /** @defgroup IWDG_Private_TypesDefinitions
35 | * @{
36 | */
37 |
38 | /**
39 | * @}
40 | */
41 |
42 | /** @defgroup IWDG_Private_Defines
43 | * @{
44 | */
45 |
46 | /* ---------------------- IWDG registers bit mask ----------------------------*/
47 |
48 | /* KR register bit mask */
49 | #define KR_KEY_Reload ((uint16_t)0xAAAA)
50 | #define KR_KEY_Enable ((uint16_t)0xCCCC)
51 |
52 | /**
53 | * @}
54 | */
55 |
56 | /** @defgroup IWDG_Private_Macros
57 | * @{
58 | */
59 |
60 | /**
61 | * @}
62 | */
63 |
64 | /** @defgroup IWDG_Private_Variables
65 | * @{
66 | */
67 |
68 | /**
69 | * @}
70 | */
71 |
72 | /** @defgroup IWDG_Private_FunctionPrototypes
73 | * @{
74 | */
75 |
76 | /**
77 | * @}
78 | */
79 |
80 | /** @defgroup IWDG_Private_Functions
81 | * @{
82 | */
83 |
84 | /**
85 | * @brief Enables or disables write access to IWDG_PR and IWDG_RLR registers.
86 | * @param IWDG_WriteAccess: new state of write access to IWDG_PR and IWDG_RLR registers.
87 | * This parameter can be one of the following values:
88 | * @arg IWDG_WriteAccess_Enable: Enable write access to IWDG_PR and IWDG_RLR registers
89 | * @arg IWDG_WriteAccess_Disable: Disable write access to IWDG_PR and IWDG_RLR registers
90 | * @retval None
91 | */
92 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess)
93 | {
94 | /* Check the parameters */
95 | assert_param(IS_IWDG_WRITE_ACCESS(IWDG_WriteAccess));
96 | IWDG->KR = IWDG_WriteAccess;
97 | }
98 |
99 | /**
100 | * @brief Sets IWDG Prescaler value.
101 | * @param IWDG_Prescaler: specifies the IWDG Prescaler value.
102 | * This parameter can be one of the following values:
103 | * @arg IWDG_Prescaler_4: IWDG prescaler set to 4
104 | * @arg IWDG_Prescaler_8: IWDG prescaler set to 8
105 | * @arg IWDG_Prescaler_16: IWDG prescaler set to 16
106 | * @arg IWDG_Prescaler_32: IWDG prescaler set to 32
107 | * @arg IWDG_Prescaler_64: IWDG prescaler set to 64
108 | * @arg IWDG_Prescaler_128: IWDG prescaler set to 128
109 | * @arg IWDG_Prescaler_256: IWDG prescaler set to 256
110 | * @retval None
111 | */
112 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler)
113 | {
114 | /* Check the parameters */
115 | assert_param(IS_IWDG_PRESCALER(IWDG_Prescaler));
116 | IWDG->PR = IWDG_Prescaler;
117 | }
118 |
119 | /**
120 | * @brief Sets IWDG Reload value.
121 | * @param Reload: specifies the IWDG Reload value.
122 | * This parameter must be a number between 0 and 0x0FFF.
123 | * @retval None
124 | */
125 | void IWDG_SetReload(uint16_t Reload)
126 | {
127 | /* Check the parameters */
128 | assert_param(IS_IWDG_RELOAD(Reload));
129 | IWDG->RLR = Reload;
130 | }
131 |
132 | /**
133 | * @brief Reloads IWDG counter with value defined in the reload register
134 | * (write access to IWDG_PR and IWDG_RLR registers disabled).
135 | * @param None
136 | * @retval None
137 | */
138 | void IWDG_ReloadCounter(void)
139 | {
140 | IWDG->KR = KR_KEY_Reload;
141 | }
142 |
143 | /**
144 | * @brief Enables IWDG (write access to IWDG_PR and IWDG_RLR registers disabled).
145 | * @param None
146 | * @retval None
147 | */
148 | void IWDG_Enable(void)
149 | {
150 | IWDG->KR = KR_KEY_Enable;
151 | }
152 |
153 | /**
154 | * @brief Checks whether the specified IWDG flag is set or not.
155 | * @param IWDG_FLAG: specifies the flag to check.
156 | * This parameter can be one of the following values:
157 | * @arg IWDG_FLAG_PVU: Prescaler Value Update on going
158 | * @arg IWDG_FLAG_RVU: Reload Value Update on going
159 | * @retval The new state of IWDG_FLAG (SET or RESET).
160 | */
161 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG)
162 | {
163 | FlagStatus bitstatus = RESET;
164 | /* Check the parameters */
165 | assert_param(IS_IWDG_FLAG(IWDG_FLAG));
166 | if ((IWDG->SR & IWDG_FLAG) != (uint32_t)RESET)
167 | {
168 | bitstatus = SET;
169 | }
170 | else
171 | {
172 | bitstatus = RESET;
173 | }
174 | /* Return the flag status */
175 | return bitstatus;
176 | }
177 |
178 | /**
179 | * @}
180 | */
181 |
182 | /**
183 | * @}
184 | */
185 |
186 | /**
187 | * @}
188 | */
189 |
190 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
191 |
--------------------------------------------------------------------------------
/grbl/settings.h:
--------------------------------------------------------------------------------
1 | /*
2 | settings.h - eeprom configuration handling
3 | Part of Grbl
4 |
5 | Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
6 | Copyright (c) 2009-2011 Simen Svale Skogsrud
7 |
8 | Grbl is free software: you can redistribute it and/or modify
9 | it under the terms of the GNU General Public License as published by
10 | the Free Software Foundation, either version 3 of the License, or
11 | (at your option) any later version.
12 |
13 | Grbl is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU General Public License for more details.
17 |
18 | You should have received a copy of the GNU General Public License
19 | along with Grbl. If not, see .
20 | */
21 |
22 | #ifndef settings_h
23 | #define settings_h
24 |
25 | #include "grbl.h"
26 |
27 |
28 | // Version of the EEPROM data. Will be used to migrate existing data from older versions of Grbl
29 | // when firmware is upgraded. Always stored in byte 0 of eeprom
30 | #define SETTINGS_VERSION 10 // NOTE: Check settings_reset() when moving to next version.
31 |
32 | // Define bit flag masks for the boolean settings in settings.flag.
33 | #define BITFLAG_REPORT_INCHES bit(0)
34 | #define BITFLAG_LASER_MODE bit(1)
35 | #define BITFLAG_INVERT_ST_ENABLE bit(2)
36 | #define BITFLAG_HARD_LIMIT_ENABLE bit(3)
37 | #define BITFLAG_HOMING_ENABLE bit(4)
38 | #define BITFLAG_SOFT_LIMIT_ENABLE bit(5)
39 | #define BITFLAG_INVERT_LIMIT_PINS bit(6)
40 | #define BITFLAG_INVERT_PROBE_PIN bit(7)
41 |
42 | // Define status reporting boolean enable bit flags in settings.status_report_mask
43 | #define BITFLAG_RT_STATUS_POSITION_TYPE bit(0)
44 | #define BITFLAG_RT_STATUS_BUFFER_STATE bit(1)
45 |
46 | // Define settings restore bitflags.
47 | #define SETTINGS_RESTORE_DEFAULTS bit(0)
48 | #define SETTINGS_RESTORE_PARAMETERS bit(1)
49 | #define SETTINGS_RESTORE_STARTUP_LINES bit(2)
50 | #define SETTINGS_RESTORE_BUILD_INFO bit(3)
51 | #ifndef SETTINGS_RESTORE_ALL
52 | #define SETTINGS_RESTORE_ALL 0xFF // All bitflags
53 | #endif
54 |
55 | // Define EEPROM memory address location values for Grbl settings and parameters
56 | // NOTE: The Atmega328p has 1KB EEPROM. The upper half is reserved for parameters and
57 | // the startup script. The lower half contains the global settings and space for future
58 | // developments.
59 | #define EEPROM_ADDR_GLOBAL 1U
60 | #define EEPROM_ADDR_PARAMETERS 512U
61 | #define EEPROM_ADDR_STARTUP_BLOCK 768U
62 | #define EEPROM_ADDR_BUILD_INFO 942U
63 |
64 | // Define EEPROM address indexing for coordinate parameters
65 | #define N_COORDINATE_SYSTEM 6 // Number of supported work coordinate systems (from index 1)
66 | #define SETTING_INDEX_NCOORD N_COORDINATE_SYSTEM+1 // Total number of system stored (from index 0)
67 | // NOTE: Work coordinate indices are (0=G54, 1=G55, ... , 6=G59)
68 | #define SETTING_INDEX_G28 N_COORDINATE_SYSTEM // Home position 1
69 | #define SETTING_INDEX_G30 N_COORDINATE_SYSTEM+1 // Home position 2
70 | // #define SETTING_INDEX_G92 N_COORDINATE_SYSTEM+2 // Coordinate offset (G92.2,G92.3 not supported)
71 |
72 | // Define Grbl axis settings numbering scheme. Starts at START_VAL, every INCREMENT, over N_SETTINGS.
73 | #define AXIS_N_SETTINGS 4
74 | #define AXIS_SETTINGS_START_VAL 100 // NOTE: Reserving settings values >= 100 for axis settings. Up to 255.
75 | #define AXIS_SETTINGS_INCREMENT 10 // Must be greater than the number of axis settings
76 |
77 | // Global persistent settings (Stored from byte EEPROM_ADDR_GLOBAL onwards)
78 | typedef struct {
79 | // Axis settings
80 | float steps_per_mm[N_AXIS];
81 | float max_rate[N_AXIS];
82 | float acceleration[N_AXIS];
83 | float max_travel[N_AXIS];
84 |
85 | // Remaining Grbl settings
86 | uint8_t pulse_microseconds;
87 | uint8_t step_invert_mask;
88 | uint8_t dir_invert_mask;
89 | uint8_t stepper_idle_lock_time; // If max value 255, steppers do not disable.
90 | uint8_t status_report_mask; // Mask to indicate desired report data.
91 | float junction_deviation;
92 | float arc_tolerance;
93 |
94 | float rpm_max;
95 | float rpm_min;
96 |
97 | uint8_t flags; // Contains default boolean settings
98 |
99 | uint8_t homing_dir_mask;
100 | float homing_feed_rate;
101 | float homing_seek_rate;
102 | uint16_t homing_debounce_delay;
103 | float homing_pulloff;
104 | } settings_t;
105 | extern settings_t settings;
106 |
107 | // Initialize the configuration subsystem (load settings from EEPROM)
108 | void settings_init();
109 |
110 | // Helper function to clear and restore EEPROM defaults
111 | void settings_restore(uint8_t restore_flag);
112 |
113 | // A helper method to set new settings from command line
114 | uint8_t settings_store_global_setting(uint8_t parameter, float value);
115 |
116 | // Stores the protocol line variable as a startup line in EEPROM
117 | void settings_store_startup_line(uint8_t n, char *line);
118 |
119 | // Reads an EEPROM startup line to the protocol line variable
120 | uint8_t settings_read_startup_line(uint8_t n, char *line);
121 |
122 | // Stores build info user-defined string
123 | void settings_store_build_info(char *line);
124 |
125 | // Reads build info user-defined string
126 | uint8_t settings_read_build_info(char *line);
127 |
128 | // Writes selected coordinate data to EEPROM
129 | void settings_write_coord_data(uint8_t coord_select, float *coord_data);
130 |
131 | // Reads selected coordinate data from EEPROM
132 | uint8_t settings_read_coord_data(uint8_t coord_select, float *coord_data);
133 |
134 | #endif
135 |
--------------------------------------------------------------------------------
/SPL/src/stm32f10x_dbgmcu.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f10x_dbgmcu.c
4 | * @author MCD Application Team
5 | * @version V3.5.0
6 | * @date 11-March-2011
7 | * @brief This file provides all the DBGMCU firmware functions.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Includes ------------------------------------------------------------------*/
23 | #include "stm32f10x_dbgmcu.h"
24 |
25 | /** @addtogroup STM32F10x_StdPeriph_Driver
26 | * @{
27 | */
28 |
29 | /** @defgroup DBGMCU
30 | * @brief DBGMCU driver modules
31 | * @{
32 | */
33 |
34 | /** @defgroup DBGMCU_Private_TypesDefinitions
35 | * @{
36 | */
37 |
38 | /**
39 | * @}
40 | */
41 |
42 | /** @defgroup DBGMCU_Private_Defines
43 | * @{
44 | */
45 |
46 | #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF)
47 | /**
48 | * @}
49 | */
50 |
51 | /** @defgroup DBGMCU_Private_Macros
52 | * @{
53 | */
54 |
55 | /**
56 | * @}
57 | */
58 |
59 | /** @defgroup DBGMCU_Private_Variables
60 | * @{
61 | */
62 |
63 | /**
64 | * @}
65 | */
66 |
67 | /** @defgroup DBGMCU_Private_FunctionPrototypes
68 | * @{
69 | */
70 |
71 | /**
72 | * @}
73 | */
74 |
75 | /** @defgroup DBGMCU_Private_Functions
76 | * @{
77 | */
78 |
79 | /**
80 | * @brief Returns the device revision identifier.
81 | * @param None
82 | * @retval Device revision identifier
83 | */
84 | uint32_t DBGMCU_GetREVID(void)
85 | {
86 | return(DBGMCU->IDCODE >> 16);
87 | }
88 |
89 | /**
90 | * @brief Returns the device identifier.
91 | * @param None
92 | * @retval Device identifier
93 | */
94 | uint32_t DBGMCU_GetDEVID(void)
95 | {
96 | return(DBGMCU->IDCODE & IDCODE_DEVID_MASK);
97 | }
98 |
99 | /**
100 | * @brief Configures the specified peripheral and low power mode behavior
101 | * when the MCU under Debug mode.
102 | * @param DBGMCU_Periph: specifies the peripheral and low power mode.
103 | * This parameter can be any combination of the following values:
104 | * @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode
105 | * @arg DBGMCU_STOP: Keep debugger connection during STOP mode
106 | * @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode
107 | * @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted
108 | * @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted
109 | * @arg DBGMCU_TIM1_STOP: TIM1 counter stopped when Core is halted
110 | * @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted
111 | * @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted
112 | * @arg DBGMCU_TIM4_STOP: TIM4 counter stopped when Core is halted
113 | * @arg DBGMCU_CAN1_STOP: Debug CAN2 stopped when Core is halted
114 | * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is halted
115 | * @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is halted
116 | * @arg DBGMCU_TIM5_STOP: TIM5 counter stopped when Core is halted
117 | * @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted
118 | * @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted
119 | * @arg DBGMCU_TIM8_STOP: TIM8 counter stopped when Core is halted
120 | * @arg DBGMCU_CAN2_STOP: Debug CAN2 stopped when Core is halted
121 | * @arg DBGMCU_TIM15_STOP: TIM15 counter stopped when Core is halted
122 | * @arg DBGMCU_TIM16_STOP: TIM16 counter stopped when Core is halted
123 | * @arg DBGMCU_TIM17_STOP: TIM17 counter stopped when Core is halted
124 | * @arg DBGMCU_TIM9_STOP: TIM9 counter stopped when Core is halted
125 | * @arg DBGMCU_TIM10_STOP: TIM10 counter stopped when Core is halted
126 | * @arg DBGMCU_TIM11_STOP: TIM11 counter stopped when Core is halted
127 | * @arg DBGMCU_TIM12_STOP: TIM12 counter stopped when Core is halted
128 | * @arg DBGMCU_TIM13_STOP: TIM13 counter stopped when Core is halted
129 | * @arg DBGMCU_TIM14_STOP: TIM14 counter stopped when Core is halted
130 | * @param NewState: new state of the specified peripheral in Debug mode.
131 | * This parameter can be: ENABLE or DISABLE.
132 | * @retval None
133 | */
134 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState)
135 | {
136 | /* Check the parameters */
137 | assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph));
138 | assert_param(IS_FUNCTIONAL_STATE(NewState));
139 |
140 | if (NewState != DISABLE)
141 | {
142 | DBGMCU->CR |= DBGMCU_Periph;
143 | }
144 | else
145 | {
146 | DBGMCU->CR &= ~DBGMCU_Periph;
147 | }
148 | }
149 |
150 | /**
151 | * @}
152 | */
153 |
154 | /**
155 | * @}
156 | */
157 |
158 | /**
159 | * @}
160 | */
161 |
162 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
163 |
--------------------------------------------------------------------------------
/stm32f103c8_flash.ld:
--------------------------------------------------------------------------------
1 | /* ---------------------------------------------------------------------------- */
2 | /* Em::Blocks embedded development Support */
3 | /* ---------------------------------------------------------------------------- */
4 | /* Copyright (c) 2014, EmBlocks */
5 | /* */
6 | /* All rights reserved. */
7 | /* */
8 | /* Redistribution and use in source and binary forms, with or without */
9 | /* modification, are permitted provided that the following condition is met: */
10 | /* */
11 | /* - Redistributions of source code must retain the above copyright notice, */
12 | /* this list of conditions and the disclaimer below. */
13 | /* */
14 | /* EmBlocks's name may not be used to endorse or promote products derived from */
15 | /* this software without specific prior written permission. */
16 | /* */
17 | /* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY EBLOCKS "AS IS" AND ANY EXPRESS OR */
18 | /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
19 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */
20 | /* DISCLAIMED. IN NO EVENT SHALL EMBLOCKS BE LIABLE FOR ANY DIRECT, INDIRECT, */
21 | /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
22 | /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
23 | /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
24 | /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
25 | /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
26 | /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
27 | /* ---------------------------------------------------------------------------- */
28 |
29 | /*------------------------------------------------------------------------------
30 | * Linker script for running in internal FLASH on the STM32F103C8
31 | *----------------------------------------------------------------------------*/
32 |
33 | OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
34 | OUTPUT_ARCH(arm)
35 | SEARCH_DIR(.)
36 |
37 | /* Memory Spaces Definitions */
38 | MEMORY
39 | {
40 | ROM (rx) : ORIGIN = 0x08000000, LENGTH = 64K
41 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
42 | }
43 |
44 | /* Linker script to place sections and symbol values. Should be used together
45 | * with other linker script that defines memory regions FLASH and RAM.
46 | * It references following symbols, which must be defined in code:
47 | * Reset_Handler : Entry of reset handler
48 | *
49 | * It defines following symbols, which code can use without definition:
50 | * __exidx_start
51 | * __exidx_end
52 | * __etext
53 | * __data_start__
54 | * __preinit_array_start
55 | * __preinit_array_end
56 | * __init_array_start
57 | * __init_array_end
58 | * __fini_array_start
59 | * __fini_array_end
60 | * __data_end__
61 | * __bss_start__
62 | * __bss_end__
63 | * __end__
64 | * end
65 | * __HeapLimit
66 | * __StackLimit
67 | * __StackTop
68 | * __stack
69 | */
70 |
71 |
72 | SECTIONS
73 | {
74 | .text :
75 | {
76 | KEEP(*(.isr_vector))
77 | *(.text*)
78 |
79 | KEEP(*(.init))
80 | KEEP(*(.fini))
81 |
82 | /* .ctors */
83 | *crtbegin.o(.ctors)
84 | *crtbegin?.o(.ctors)
85 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
86 | *(SORT(.ctors.*))
87 | *(.ctors)
88 |
89 | /* .dtors */
90 | *crtbegin.o(.dtors)
91 | *crtbegin?.o(.dtors)
92 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
93 | *(SORT(.dtors.*))
94 | *(.dtors)
95 |
96 | *(.rodata*)
97 |
98 | KEEP(*(.eh_frame*))
99 | } > ROM
100 |
101 | .ARM.extab :
102 | {
103 | *(.ARM.extab* .gnu.linkonce.armextab.*)
104 | } > ROM
105 |
106 | __exidx_start = .;
107 | .ARM.exidx :
108 | {
109 | *(.ARM.exidx* .gnu.linkonce.armexidx.*)
110 | } > ROM
111 | __exidx_end = .;
112 |
113 | __etext = .;
114 |
115 | .data : AT (__etext)
116 | {
117 | __data_start__ = .;
118 | *(vtable)
119 | *(.data*)
120 |
121 | . = ALIGN(4);
122 | /* preinit data */
123 | PROVIDE_HIDDEN (__preinit_array_start = .);
124 | KEEP(*(.preinit_array))
125 | PROVIDE_HIDDEN (__preinit_array_end = .);
126 |
127 | . = ALIGN(4);
128 | /* init data */
129 | PROVIDE_HIDDEN (__init_array_start = .);
130 | KEEP(*(SORT(.init_array.*)))
131 | KEEP(*(.init_array))
132 | PROVIDE_HIDDEN (__init_array_end = .);
133 |
134 |
135 | . = ALIGN(4);
136 | /* finit data */
137 | PROVIDE_HIDDEN (__fini_array_start = .);
138 | KEEP(*(SORT(.fini_array.*)))
139 | KEEP(*(.fini_array))
140 | PROVIDE_HIDDEN (__fini_array_end = .);
141 |
142 | . = ALIGN(4);
143 | /* All data end */
144 | __data_end__ = .;
145 |
146 | } > RAM
147 |
148 | .bss (NOLOAD):
149 | {
150 | __bss_start__ = .;
151 | *(.bss*)
152 | *(COMMON)
153 | __bss_end__ = .;
154 | } > RAM
155 |
156 | .heap (NOLOAD):
157 | {
158 | __end__ = .;
159 | end = __end__;
160 | *(.heap*)
161 | __HeapLimit = .;
162 | } > RAM
163 |
164 | /* .stack_dummy section doesn't contains any symbols. It is only
165 | * used for linker to calculate size of stack sections, and assign
166 | * values to stack symbols later */
167 | .stack_dummy (NOLOAD):
168 | {
169 | *(.stack)
170 | } > RAM
171 |
172 | /* Set stack top to end of RAM, and stack limit move down by
173 | * size of stack_dummy section */
174 | __StackTop = ORIGIN(RAM) + LENGTH(RAM);
175 | __StackLimit = __StackTop - SIZEOF(.stack_dummy);
176 | PROVIDE(__stack = __StackTop);
177 |
178 | /* Check if data + heap + stack exceeds RAM limit */
179 | ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
180 | }
181 |
--------------------------------------------------------------------------------
/stm32f103c8_sram.ld:
--------------------------------------------------------------------------------
1 | /* ---------------------------------------------------------------------------- */
2 | /* Em::Blocks embedded development Support */
3 | /* ---------------------------------------------------------------------------- */
4 | /* Copyright (c) 2014, EmBlocks */
5 | /* */
6 | /* All rights reserved. */
7 | /* */
8 | /* Redistribution and use in source and binary forms, with or without */
9 | /* modification, are permitted provided that the following condition is met: */
10 | /* */
11 | /* - Redistributions of source code must retain the above copyright notice, */
12 | /* this list of conditions and the disclaimer below. */
13 | /* */
14 | /* EmBlocks's name may not be used to endorse or promote products derived from */
15 | /* this software without specific prior written permission. */
16 | /* */
17 | /* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY EBLOCKS "AS IS" AND ANY EXPRESS OR */
18 | /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
19 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */
20 | /* DISCLAIMED. IN NO EVENT SHALL EMBLOCKS BE LIABLE FOR ANY DIRECT, INDIRECT, */
21 | /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
22 | /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
23 | /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
24 | /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
25 | /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
26 | /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
27 | /* ---------------------------------------------------------------------------- */
28 |
29 | /*------------------------------------------------------------------------------
30 | * Linker script for running in internal SRAM on the STM32F103C8
31 | *----------------------------------------------------------------------------*/
32 |
33 | OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
34 | OUTPUT_ARCH(arm)
35 | SEARCH_DIR(.)
36 |
37 | /* Memory Spaces Definitions */
38 | MEMORY
39 | {
40 | ROM (rx) : ORIGIN = 0x08000000, LENGTH = 64K
41 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
42 | }
43 |
44 | /* Linker script to place sections and symbol values. Should be used together
45 | * with other linker script that defines memory regions FLASH and RAM.
46 | * It references following symbols, which must be defined in code:
47 | * Reset_Handler : Entry of reset handler
48 | *
49 | * It defines following symbols, which code can use without definition:
50 | * __exidx_start
51 | * __exidx_end
52 | * __etext
53 | * __data_start__
54 | * __preinit_array_start
55 | * __preinit_array_end
56 | * __init_array_start
57 | * __init_array_end
58 | * __fini_array_start
59 | * __fini_array_end
60 | * __data_end__
61 | * __bss_start__
62 | * __bss_end__
63 | * __end__
64 | * end
65 | * __HeapLimit
66 | * __StackLimit
67 | * __StackTop
68 | * __stack
69 | */
70 |
71 |
72 | SECTIONS
73 | {
74 | .text :
75 | {
76 | KEEP(*(.isr_vector))
77 | *(.text*)
78 |
79 | KEEP(*(.init))
80 | KEEP(*(.fini))
81 |
82 | /* .ctors */
83 | *crtbegin.o(.ctors)
84 | *crtbegin?.o(.ctors)
85 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
86 | *(SORT(.ctors.*))
87 | *(.ctors)
88 |
89 | /* .dtors */
90 | *crtbegin.o(.dtors)
91 | *crtbegin?.o(.dtors)
92 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
93 | *(SORT(.dtors.*))
94 | *(.dtors)
95 |
96 | *(.rodata*)
97 |
98 | KEEP(*(.eh_frame*))
99 | } > RAM
100 |
101 | .ARM.extab :
102 | {
103 | *(.ARM.extab* .gnu.linkonce.armextab.*)
104 | } > RAM
105 |
106 | __exidx_start = .;
107 | .ARM.exidx :
108 | {
109 | *(.ARM.exidx* .gnu.linkonce.armexidx.*)
110 | } > RAM
111 | __exidx_end = .;
112 |
113 | __etext = .;
114 |
115 | .data : AT (__etext)
116 | {
117 | __data_start__ = .;
118 | *(vtable)
119 | *(.data*)
120 |
121 | . = ALIGN(4);
122 | /* preinit data */
123 | PROVIDE_HIDDEN (__preinit_array_start = .);
124 | KEEP(*(.preinit_array))
125 | PROVIDE_HIDDEN (__preinit_array_end = .);
126 |
127 | . = ALIGN(4);
128 | /* init data */
129 | PROVIDE_HIDDEN (__init_array_start = .);
130 | KEEP(*(SORT(.init_array.*)))
131 | KEEP(*(.init_array))
132 | PROVIDE_HIDDEN (__init_array_end = .);
133 |
134 |
135 | . = ALIGN(4);
136 | /* finit data */
137 | PROVIDE_HIDDEN (__fini_array_start = .);
138 | KEEP(*(SORT(.fini_array.*)))
139 | KEEP(*(.fini_array))
140 | PROVIDE_HIDDEN (__fini_array_end = .);
141 |
142 | . = ALIGN(4);
143 | /* All data end */
144 | __data_end__ = .;
145 |
146 | } > RAM
147 |
148 | .bss (NOLOAD):
149 | {
150 | __bss_start__ = .;
151 | *(.bss*)
152 | *(COMMON)
153 | __bss_end__ = .;
154 | } > RAM
155 |
156 | .heap (NOLOAD):
157 | {
158 | __end__ = .;
159 | end = __end__;
160 | *(.heap*)
161 | __HeapLimit = .;
162 | } > RAM
163 |
164 | /* .stack_dummy section doesn't contains any symbols. It is only
165 | * used for linker to calculate size of stack sections, and assign
166 | * values to stack symbols later */
167 | .stack_dummy (NOLOAD):
168 | {
169 | . = ALIGN(8);
170 | *(.stack)
171 | } > RAM
172 |
173 | /* Set stack top to end of RAM, and stack limit move down by
174 | * size of stack_dummy section */
175 | __StackTop = ORIGIN(RAM) + LENGTH(RAM);
176 | __StackLimit = __StackTop - SIZEOF(.stack_dummy);
177 | PROVIDE(__stack = __StackTop);
178 |
179 | /* Check if data + heap + stack exceeds RAM limit */
180 | ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
181 | }
182 |
--------------------------------------------------------------------------------
/SPL/src/stm32f10x_wwdg.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f10x_wwdg.c
4 | * @author MCD Application Team
5 | * @version V3.5.0
6 | * @date 11-March-2011
7 | * @brief This file provides all the WWDG firmware functions.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 | *
18 | * © COPYRIGHT 2011 STMicroelectronics
19 | ******************************************************************************
20 | */
21 |
22 | /* Includes ------------------------------------------------------------------*/
23 | #include "stm32f10x_wwdg.h"
24 | #include "stm32f10x_rcc.h"
25 |
26 | /** @addtogroup STM32F10x_StdPeriph_Driver
27 | * @{
28 | */
29 |
30 | /** @defgroup WWDG
31 | * @brief WWDG driver modules
32 | * @{
33 | */
34 |
35 | /** @defgroup WWDG_Private_TypesDefinitions
36 | * @{
37 | */
38 |
39 | /**
40 | * @}
41 | */
42 |
43 | /** @defgroup WWDG_Private_Defines
44 | * @{
45 | */
46 |
47 | /* ----------- WWDG registers bit address in the alias region ----------- */
48 | #define WWDG_OFFSET (WWDG_BASE - PERIPH_BASE)
49 |
50 | /* Alias word address of EWI bit */
51 | #define CFR_OFFSET (WWDG_OFFSET + 0x04)
52 | #define EWI_BitNumber 0x09
53 | #define CFR_EWI_BB (PERIPH_BB_BASE + (CFR_OFFSET * 32) + (EWI_BitNumber * 4))
54 |
55 | /* --------------------- WWDG registers bit mask ------------------------ */
56 |
57 | /* CR register bit mask */
58 | #define CR_WDGA_Set ((uint32_t)0x00000080)
59 |
60 | /* CFR register bit mask */
61 | #define CFR_WDGTB_Mask ((uint32_t)0xFFFFFE7F)
62 | #define CFR_W_Mask ((uint32_t)0xFFFFFF80)
63 | #define BIT_Mask ((uint8_t)0x7F)
64 |
65 | /**
66 | * @}
67 | */
68 |
69 | /** @defgroup WWDG_Private_Macros
70 | * @{
71 | */
72 |
73 | /**
74 | * @}
75 | */
76 |
77 | /** @defgroup WWDG_Private_Variables
78 | * @{
79 | */
80 |
81 | /**
82 | * @}
83 | */
84 |
85 | /** @defgroup WWDG_Private_FunctionPrototypes
86 | * @{
87 | */
88 |
89 | /**
90 | * @}
91 | */
92 |
93 | /** @defgroup WWDG_Private_Functions
94 | * @{
95 | */
96 |
97 | /**
98 | * @brief Deinitializes the WWDG peripheral registers to their default reset values.
99 | * @param None
100 | * @retval None
101 | */
102 | void WWDG_DeInit(void)
103 | {
104 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_WWDG, ENABLE);
105 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_WWDG, DISABLE);
106 | }
107 |
108 | /**
109 | * @brief Sets the WWDG Prescaler.
110 | * @param WWDG_Prescaler: specifies the WWDG Prescaler.
111 | * This parameter can be one of the following values:
112 | * @arg WWDG_Prescaler_1: WWDG counter clock = (PCLK1/4096)/1
113 | * @arg WWDG_Prescaler_2: WWDG counter clock = (PCLK1/4096)/2
114 | * @arg WWDG_Prescaler_4: WWDG counter clock = (PCLK1/4096)/4
115 | * @arg WWDG_Prescaler_8: WWDG counter clock = (PCLK1/4096)/8
116 | * @retval None
117 | */
118 | void WWDG_SetPrescaler(uint32_t WWDG_Prescaler)
119 | {
120 | uint32_t tmpreg = 0;
121 | /* Check the parameters */
122 | assert_param(IS_WWDG_PRESCALER(WWDG_Prescaler));
123 | /* Clear WDGTB[1:0] bits */
124 | tmpreg = WWDG->CFR & CFR_WDGTB_Mask;
125 | /* Set WDGTB[1:0] bits according to WWDG_Prescaler value */
126 | tmpreg |= WWDG_Prescaler;
127 | /* Store the new value */
128 | WWDG->CFR = tmpreg;
129 | }
130 |
131 | /**
132 | * @brief Sets the WWDG window value.
133 | * @param WindowValue: specifies the window value to be compared to the downcounter.
134 | * This parameter value must be lower than 0x80.
135 | * @retval None
136 | */
137 | void WWDG_SetWindowValue(uint8_t WindowValue)
138 | {
139 | __IO uint32_t tmpreg = 0;
140 |
141 | /* Check the parameters */
142 | assert_param(IS_WWDG_WINDOW_VALUE(WindowValue));
143 | /* Clear W[6:0] bits */
144 |
145 | tmpreg = WWDG->CFR & CFR_W_Mask;
146 |
147 | /* Set W[6:0] bits according to WindowValue value */
148 | tmpreg |= WindowValue & (uint32_t) BIT_Mask;
149 |
150 | /* Store the new value */
151 | WWDG->CFR = tmpreg;
152 | }
153 |
154 | /**
155 | * @brief Enables the WWDG Early Wakeup interrupt(EWI).
156 | * @param None
157 | * @retval None
158 | */
159 | void WWDG_EnableIT(void)
160 | {
161 | *(__IO uint32_t *) CFR_EWI_BB = (uint32_t)ENABLE;
162 | }
163 |
164 | /**
165 | * @brief Sets the WWDG counter value.
166 | * @param Counter: specifies the watchdog counter value.
167 | * This parameter must be a number between 0x40 and 0x7F.
168 | * @retval None
169 | */
170 | void WWDG_SetCounter(uint8_t Counter)
171 | {
172 | /* Check the parameters */
173 | assert_param(IS_WWDG_COUNTER(Counter));
174 | /* Write to T[6:0] bits to configure the counter value, no need to do
175 | a read-modify-write; writing a 0 to WDGA bit does nothing */
176 | WWDG->CR = Counter & BIT_Mask;
177 | }
178 |
179 | /**
180 | * @brief Enables WWDG and load the counter value.
181 | * @param Counter: specifies the watchdog counter value.
182 | * This parameter must be a number between 0x40 and 0x7F.
183 | * @retval None
184 | */
185 | void WWDG_Enable(uint8_t Counter)
186 | {
187 | /* Check the parameters */
188 | assert_param(IS_WWDG_COUNTER(Counter));
189 | WWDG->CR = CR_WDGA_Set | Counter;
190 | }
191 |
192 | /**
193 | * @brief Checks whether the Early Wakeup interrupt flag is set or not.
194 | * @param None
195 | * @retval The new state of the Early Wakeup interrupt flag (SET or RESET)
196 | */
197 | FlagStatus WWDG_GetFlagStatus(void)
198 | {
199 | return (FlagStatus)(WWDG->SR);
200 | }
201 |
202 | /**
203 | * @brief Clears Early Wakeup interrupt flag.
204 | * @param None
205 | * @retval None
206 | */
207 | void WWDG_ClearFlag(void)
208 | {
209 | WWDG->SR = (uint32_t)RESET;
210 | }
211 |
212 | /**
213 | * @}
214 | */
215 |
216 | /**
217 | * @}
218 | */
219 |
220 | /**
221 | * @}
222 | */
223 |
224 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
225 |
--------------------------------------------------------------------------------
/stm_usb_fs_lib/src/usb_int.c:
--------------------------------------------------------------------------------
1 | /******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
2 | * File Name : usb_int.c
3 | * Author : MCD Application Team
4 | * Version : V3.2.1
5 | * Date : 07/05/2010
6 | * Description : Endpoint CTR (Low and High) interrupt's service routines
7 | ********************************************************************************
8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 | *******************************************************************************/
15 | #ifndef STM32F10X_CL
16 |
17 | /* Includes ------------------------------------------------------------------*/
18 | #include "usb_lib.h"
19 |
20 | /* Private typedef -----------------------------------------------------------*/
21 | /* Private define ------------------------------------------------------------*/
22 | /* Private macro -------------------------------------------------------------*/
23 | /* Private variables ---------------------------------------------------------*/
24 | __IO uint16_t SaveRState;
25 | __IO uint16_t SaveTState;
26 |
27 | /* Extern variables ----------------------------------------------------------*/
28 | extern void (*pEpInt_IN[7])(void); /* Handles IN interrupts */
29 | extern void (*pEpInt_OUT[7])(void); /* Handles OUT interrupts */
30 |
31 | /* Private function prototypes -----------------------------------------------*/
32 | /* Private functions ---------------------------------------------------------*/
33 |
34 | /*******************************************************************************
35 | * Function Name : CTR_LP.
36 | * Description : Low priority Endpoint Correct Transfer interrupt's service
37 | * routine.
38 | * Input : None.
39 | * Output : None.
40 | * Return : None.
41 | *******************************************************************************/
42 | void CTR_LP(void)
43 | {
44 | __IO uint16_t wEPVal = 0;
45 | /* stay in loop while pending ints */
46 | while (((wIstr = _GetISTR()) & ISTR_CTR) != 0)
47 | {
48 | /* extract highest priority endpoint number */
49 | EPindex = (uint8_t)(wIstr & ISTR_EP_ID);
50 | if (EPindex == 0)
51 | {
52 | /* Decode and service control endpoint interrupt */
53 | /* calling related service routine */
54 | /* (Setup0_Process, In0_Process, Out0_Process) */
55 |
56 | /* save RX & TX status */
57 | /* and set both to NAK */
58 |
59 |
60 | SaveRState = _GetENDPOINT(ENDP0);
61 | SaveTState = SaveRState & EPTX_STAT;
62 | SaveRState &= EPRX_STAT;
63 |
64 | _SetEPRxTxStatus(ENDP0,EP_RX_NAK,EP_TX_NAK);
65 |
66 | /* DIR bit = origin of the interrupt */
67 |
68 | if ((wIstr & ISTR_DIR) == 0)
69 | {
70 | /* DIR = 0 */
71 |
72 | /* DIR = 0 => IN int */
73 | /* DIR = 0 implies that (EP_CTR_TX = 1) always */
74 |
75 |
76 | _ClearEP_CTR_TX(ENDP0);
77 | In0_Process();
78 |
79 | /* before terminate set Tx & Rx status */
80 |
81 | _SetEPRxTxStatus(ENDP0,SaveRState,SaveTState);
82 | return;
83 | }
84 | else
85 | {
86 | /* DIR = 1 */
87 |
88 | /* DIR = 1 & CTR_RX => SETUP or OUT int */
89 | /* DIR = 1 & (CTR_TX | CTR_RX) => 2 int pending */
90 |
91 | wEPVal = _GetENDPOINT(ENDP0);
92 |
93 | if ((wEPVal &EP_SETUP) != 0)
94 | {
95 | _ClearEP_CTR_RX(ENDP0); /* SETUP bit kept frozen while CTR_RX = 1 */
96 | Setup0_Process();
97 | /* before terminate set Tx & Rx status */
98 |
99 | _SetEPRxTxStatus(ENDP0,SaveRState,SaveTState);
100 | return;
101 | }
102 |
103 | else if ((wEPVal & EP_CTR_RX) != 0)
104 | {
105 | _ClearEP_CTR_RX(ENDP0);
106 | Out0_Process();
107 | /* before terminate set Tx & Rx status */
108 |
109 | _SetEPRxTxStatus(ENDP0,SaveRState,SaveTState);
110 | return;
111 | }
112 | }
113 | }/* if(EPindex == 0) */
114 | else
115 | {
116 | /* Decode and service non control endpoints interrupt */
117 |
118 | /* process related endpoint register */
119 | wEPVal = _GetENDPOINT(EPindex);
120 | if ((wEPVal & EP_CTR_RX) != 0)
121 | {
122 | /* clear int flag */
123 | _ClearEP_CTR_RX(EPindex);
124 |
125 | /* call OUT service function */
126 | (*pEpInt_OUT[EPindex-1])();
127 |
128 | } /* if((wEPVal & EP_CTR_RX) */
129 |
130 | if ((wEPVal & EP_CTR_TX) != 0)
131 | {
132 | /* clear int flag */
133 | _ClearEP_CTR_TX(EPindex);
134 |
135 | /* call IN service function */
136 | (*pEpInt_IN[EPindex-1])();
137 | } /* if((wEPVal & EP_CTR_TX) != 0) */
138 |
139 | }/* if(EPindex == 0) else */
140 |
141 | }/* while(...) */
142 | }
143 |
144 | /*******************************************************************************
145 | * Function Name : CTR_HP.
146 | * Description : High Priority Endpoint Correct Transfer interrupt's service
147 | * routine.
148 | * Input : None.
149 | * Output : None.
150 | * Return : None.
151 | *******************************************************************************/
152 | void CTR_HP(void)
153 | {
154 | uint32_t wEPVal = 0;
155 |
156 | while (((wIstr = _GetISTR()) & ISTR_CTR) != 0)
157 | {
158 | _SetISTR((uint16_t)CLR_CTR); /* clear CTR flag */
159 | /* extract highest priority endpoint number */
160 | EPindex = (uint8_t)(wIstr & ISTR_EP_ID);
161 | /* process related endpoint register */
162 | wEPVal = _GetENDPOINT(EPindex);
163 | if ((wEPVal & EP_CTR_RX) != 0)
164 | {
165 | /* clear int flag */
166 | _ClearEP_CTR_RX(EPindex);
167 |
168 | /* call OUT service function */
169 | (*pEpInt_OUT[EPindex-1])();
170 |
171 | } /* if((wEPVal & EP_CTR_RX) */
172 | else if ((wEPVal & EP_CTR_TX) != 0)
173 | {
174 | /* clear int flag */
175 | _ClearEP_CTR_TX(EPindex);
176 |
177 | /* call IN service function */
178 | (*pEpInt_IN[EPindex-1])();
179 |
180 |
181 | } /* if((wEPVal & EP_CTR_TX) != 0) */
182 |
183 | }/* while(...) */
184 | }
185 |
186 | #endif /* STM32F10X_CL */
187 |
188 | /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
189 |
--------------------------------------------------------------------------------
/SPL/inc/stm32f10x_cec.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f10x_cec.h
4 | * @author MCD Application Team
5 | * @version V3.5.0
6 | * @date 11-March-2011
7 | * @brief This file contains all the functions prototypes for the CEC firmware
8 | * library.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18 | *
19 | * © COPYRIGHT 2011 STMicroelectronics
20 | ******************************************************************************
21 | */
22 |
23 | /* Define to prevent recursive inclusion -------------------------------------*/
24 | #ifndef __STM32F10x_CEC_H
25 | #define __STM32F10x_CEC_H
26 |
27 | #ifdef __cplusplus
28 | extern "C" {
29 | #endif
30 |
31 | /* Includes ------------------------------------------------------------------*/
32 | #include "stm32f10x.h"
33 |
34 | /** @addtogroup STM32F10x_StdPeriph_Driver
35 | * @{
36 | */
37 |
38 | /** @addtogroup CEC
39 | * @{
40 | */
41 |
42 |
43 | /** @defgroup CEC_Exported_Types
44 | * @{
45 | */
46 |
47 | /**
48 | * @brief CEC Init structure definition
49 | */
50 | typedef struct
51 | {
52 | uint16_t CEC_BitTimingMode; /*!< Configures the CEC Bit Timing Error Mode.
53 | This parameter can be a value of @ref CEC_BitTiming_Mode */
54 | uint16_t CEC_BitPeriodMode; /*!< Configures the CEC Bit Period Error Mode.
55 | This parameter can be a value of @ref CEC_BitPeriod_Mode */
56 | }CEC_InitTypeDef;
57 |
58 | /**
59 | * @}
60 | */
61 |
62 | /** @defgroup CEC_Exported_Constants
63 | * @{
64 | */
65 |
66 | /** @defgroup CEC_BitTiming_Mode
67 | * @{
68 | */
69 | #define CEC_BitTimingStdMode ((uint16_t)0x00) /*!< Bit timing error Standard Mode */
70 | #define CEC_BitTimingErrFreeMode CEC_CFGR_BTEM /*!< Bit timing error Free Mode */
71 |
72 | #define IS_CEC_BIT_TIMING_ERROR_MODE(MODE) (((MODE) == CEC_BitTimingStdMode) || \
73 | ((MODE) == CEC_BitTimingErrFreeMode))
74 | /**
75 | * @}
76 | */
77 |
78 | /** @defgroup CEC_BitPeriod_Mode
79 | * @{
80 | */
81 | #define CEC_BitPeriodStdMode ((uint16_t)0x00) /*!< Bit period error Standard Mode */
82 | #define CEC_BitPeriodFlexibleMode CEC_CFGR_BPEM /*!< Bit period error Flexible Mode */
83 |
84 | #define IS_CEC_BIT_PERIOD_ERROR_MODE(MODE) (((MODE) == CEC_BitPeriodStdMode) || \
85 | ((MODE) == CEC_BitPeriodFlexibleMode))
86 | /**
87 | * @}
88 | */
89 |
90 |
91 | /** @defgroup CEC_interrupts_definition
92 | * @{
93 | */
94 | #define CEC_IT_TERR CEC_CSR_TERR
95 | #define CEC_IT_TBTRF CEC_CSR_TBTRF
96 | #define CEC_IT_RERR CEC_CSR_RERR
97 | #define CEC_IT_RBTF CEC_CSR_RBTF
98 | #define IS_CEC_GET_IT(IT) (((IT) == CEC_IT_TERR) || ((IT) == CEC_IT_TBTRF) || \
99 | ((IT) == CEC_IT_RERR) || ((IT) == CEC_IT_RBTF))
100 | /**
101 | * @}
102 | */
103 |
104 |
105 | /** @defgroup CEC_Own_Address
106 | * @{
107 | */
108 | #define IS_CEC_ADDRESS(ADDRESS) ((ADDRESS) < 0x10)
109 | /**
110 | * @}
111 | */
112 |
113 | /** @defgroup CEC_Prescaler
114 | * @{
115 | */
116 | #define IS_CEC_PRESCALER(PRESCALER) ((PRESCALER) <= 0x3FFF)
117 |
118 | /**
119 | * @}
120 | */
121 |
122 | /** @defgroup CEC_flags_definition
123 | * @{
124 | */
125 |
126 | /**
127 | * @brief ESR register flags
128 | */
129 | #define CEC_FLAG_BTE ((uint32_t)0x10010000)
130 | #define CEC_FLAG_BPE ((uint32_t)0x10020000)
131 | #define CEC_FLAG_RBTFE ((uint32_t)0x10040000)
132 | #define CEC_FLAG_SBE ((uint32_t)0x10080000)
133 | #define CEC_FLAG_ACKE ((uint32_t)0x10100000)
134 | #define CEC_FLAG_LINE ((uint32_t)0x10200000)
135 | #define CEC_FLAG_TBTFE ((uint32_t)0x10400000)
136 |
137 | /**
138 | * @brief CSR register flags
139 | */
140 | #define CEC_FLAG_TEOM ((uint32_t)0x00000002)
141 | #define CEC_FLAG_TERR ((uint32_t)0x00000004)
142 | #define CEC_FLAG_TBTRF ((uint32_t)0x00000008)
143 | #define CEC_FLAG_RSOM ((uint32_t)0x00000010)
144 | #define CEC_FLAG_REOM ((uint32_t)0x00000020)
145 | #define CEC_FLAG_RERR ((uint32_t)0x00000040)
146 | #define CEC_FLAG_RBTF ((uint32_t)0x00000080)
147 |
148 | #define IS_CEC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFF03) == 0x00) && ((FLAG) != 0x00))
149 |
150 | #define IS_CEC_GET_FLAG(FLAG) (((FLAG) == CEC_FLAG_BTE) || ((FLAG) == CEC_FLAG_BPE) || \
151 | ((FLAG) == CEC_FLAG_RBTFE) || ((FLAG)== CEC_FLAG_SBE) || \
152 | ((FLAG) == CEC_FLAG_ACKE) || ((FLAG) == CEC_FLAG_LINE) || \
153 | ((FLAG) == CEC_FLAG_TBTFE) || ((FLAG) == CEC_FLAG_TEOM) || \
154 | ((FLAG) == CEC_FLAG_TERR) || ((FLAG) == CEC_FLAG_TBTRF) || \
155 | ((FLAG) == CEC_FLAG_RSOM) || ((FLAG) == CEC_FLAG_REOM) || \
156 | ((FLAG) == CEC_FLAG_RERR) || ((FLAG) == CEC_FLAG_RBTF))
157 |
158 | /**
159 | * @}
160 | */
161 |
162 | /**
163 | * @}
164 | */
165 |
166 | /** @defgroup CEC_Exported_Macros
167 | * @{
168 | */
169 |
170 | /**
171 | * @}
172 | */
173 |
174 | /** @defgroup CEC_Exported_Functions
175 | * @{
176 | */
177 | void CEC_DeInit(void);
178 | void CEC_Init(CEC_InitTypeDef* CEC_InitStruct);
179 | void CEC_Cmd(FunctionalState NewState);
180 | void CEC_ITConfig(FunctionalState NewState);
181 | void CEC_OwnAddressConfig(uint8_t CEC_OwnAddress);
182 | void CEC_SetPrescaler(uint16_t CEC_Prescaler);
183 | void CEC_SendDataByte(uint8_t Data);
184 | uint8_t CEC_ReceiveDataByte(void);
185 | void CEC_StartOfMessage(void);
186 | void CEC_EndOfMessageCmd(FunctionalState NewState);
187 | FlagStatus CEC_GetFlagStatus(uint32_t CEC_FLAG);
188 | void CEC_ClearFlag(uint32_t CEC_FLAG);
189 | ITStatus CEC_GetITStatus(uint8_t CEC_IT);
190 | void CEC_ClearITPendingBit(uint16_t CEC_IT);
191 |
192 | #ifdef __cplusplus
193 | }
194 | #endif
195 |
196 | #endif /* __STM32F10x_CEC_H */
197 |
198 | /**
199 | * @}
200 | */
201 |
202 | /**
203 | * @}
204 | */
205 |
206 | /**
207 | * @}
208 | */
209 |
210 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
211 |
--------------------------------------------------------------------------------