Skip to content

Commit

Permalink
Merge pull request #161 from Paciente8159/platformIO-config
Browse files Browse the repository at this point in the history
PlatformIO config
  • Loading branch information
Paciente8159 authored Apr 8, 2022
2 parents 881e05c + 58335b8 commit 880d199
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 114 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,10 @@ virtualeeprom
*.cfg
windows/uCNCgui/obj/Debug/net6.0-windows/uCNCgui.assets.cache
windows/uCNCgui/obj/Debug/net6.0-windows/uCNCgui.GeneratedMSBuildEditorConfig.editorconfig

#PlatformIO
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
10 changes: 10 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}
44 changes: 40 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY
//
// PIO Unified Debugger
//
// Documentation: https://docs.platformio.org/page/plus/debugging.html
// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
Expand All @@ -16,6 +20,38 @@
"load",
"monitor reset init"
]
},
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug",
"executable": "c:/Users/JCEM/Documents/GitHub/uCNC/.pio/build/mks_dlc/firmware.elf",
"projectEnvName": "mks_dlc",
"toolchainBinDir": "C:/gcc-avr8/bin",
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": {
"type": "PlatformIO",
"task": "Pre-Debug (mks_dlc)"
}
},
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug (skip Pre-Debug)",
"executable": "c:/Users/JCEM/Documents/GitHub/uCNC/.pio/build/mks_dlc/firmware.elf",
"projectEnvName": "mks_dlc",
"toolchainBinDir": "C:/gcc-avr8/bin",
"internalConsoleOptions": "openOnSessionStart"
},
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug (without uploading)",
"executable": "c:/Users/JCEM/Documents/GitHub/uCNC/.pio/build/mks_dlc/firmware.elf",
"projectEnvName": "mks_dlc",
"toolchainBinDir": "C:/gcc-avr8/bin",
"internalConsoleOptions": "openOnSessionStart",
"loadMode": "manual"
}
]
}
}
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@

### Added

- added platformIO.ini file the µCNC project (#161)

### Changed

- improved subsegment planner computations by skipping junction speed calculations after initial calculation for first subsegment (#160)
- improved subsegment planner computations by skipping junction speed calculations after initial calculation for first subsegment (#160)
- optimized the MKS DLC boardmap file to reuse UNO boardmap

### Fixed

Expand Down
13 changes: 13 additions & 0 deletions avr_compiler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Import("env")

#
# Dump build environment (for debug)
# print(env.Dump())
#

env.Append(
LINKFLAGS=[
"-flto",
"-fuse-linker-plugin"
]
)
60 changes: 60 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[platformio]
include_dir=uCNC
src_dir=uCNC

[env:uno]
platform = atmelavr
board = uno
framework = arduino
build_flags = -D BOARD=BOARD_UNO -ffunction-sections -fdata-sections -mcall-prologues -mrelax -flto -fno-fat-lto-objects -fno-tree-scev-cprop -Wl,--gc-sections -Wl,--relax
extra_scripts = avr_compiler.py

[env:mks_dlc]
platform = atmelavr
board = uno
board_build.f_cpu = 20000000UL
framework = arduino
build_flags = -D BOARD=BOARD_MKS_DLC -ffunction-sections -fdata-sections -mcall-prologues -mrelax -flto -fno-fat-lto-objects -fno-tree-scev-cprop -Wl,--gc-sections -Wl,--relax
extra_scripts = avr_compiler.py

[env:ramps14]
platform = atmelavr
board = megaatmega2560
framework = arduino
build_flags = -D BOARD=BOARD_RAMPS14 -ffunction-sections -fdata-sections -mcall-prologues -mrelax -flto -fno-fat-lto-objects -fno-tree-scev-cprop -Wl,--gc-sections -Wl,--relax
extra_scripts = avr_compiler.py

[env:rambo]
platform = atmelavr
board = megaatmega2560
framework = arduino
build_flags = -D BOARD=BOARD_RAMBO14 -ffunction-sections -fdata-sections -mcall-prologues -mrelax -flto -fno-fat-lto-objects -fno-tree-scev-cprop -Wl,--gc-sections -Wl,--relax
extra_scripts = avr_compiler.py

[env:zeroUSB]
platform = atmelsam
board = zeroUSB
framework = arduino
build_flags = -D BOARD=BOARD_MZERO -D INTERFACE=1 -fdata-sections -ffunction-sections -nostdlib -fno-exceptions -Wl,--gc-sections

[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = arduino
build_flags = -D BOARD=BOARD_BLUEPILL -D INTERFACE=1 -D HAL_TIM_MODULE_DISABLED -D HAL_EXTI_MODULE_DISABLED -fdata-sections -ffunction-sections -Wl,--gc-sections

[env:blackpill_f401cc]
platform = ststm32
board = blackpill_f401cc
framework = arduino
build_flags = -D BOARD=BOARD_BLACKPILL -D INTERFACE=1 -D HAL_TIM_MODULE_DISABLED -D HAL_EXTI_MODULE_DISABLED -fdata-sections -ffunction-sections -Wl,--gc-sections
11 changes: 8 additions & 3 deletions uCNC/cnc_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,15 @@ extern "C"
* Disable/enable all control, limits or/and probing input pins. This
* helps to reduce code size if features are not needed
* */

// #define DISABLE_ALL_CONTROLS
#ifndef DISABLE_ALL_CONTROLS
// #define DISABLE_ALL_CONTROLS
#endif
#ifndef DISABLE_ALL_LIMITS
// #define DISABLE_ALL_LIMITS
// #define DISABLE_PROBE
#endif
#ifndef DISABLE_PROBE
// #define DISABLE_PROBE
#endif

/**
* Modifies the startup message to emulate Grbl (required by some programs so
Expand Down
107 changes: 3 additions & 104 deletions uCNC/src/hal/boards/avr/boardmap_mks_dlc.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,111 +24,10 @@ extern "C"
{
#endif

#define PCINT0_PORT B
#define PCINT1_PORT C
#define PCINT2_PORT D
#include "boardmap_uno.h"

// SAME AS GRBL for test purposes
// Setup step pins
#define STEP2_BIT 4 // assigns STEP2 pin
#define STEP2_PORT D // assigns STEP2 port
#define STEP1_BIT 3 // assigns STEP1 pin
#define STEP1_PORT D // assigns STEP1 port
#define STEP0_BIT 2 // assigns STEP0 pin
#define STEP0_PORT D // assigns STEP0 port
//#define STEP6_BIT 4 //assigns STEP6 pin (will mirror DUAL_AXIS0)
//#define STEP6_PORT C //assigns STEP6 port (will mirror DUAL_AXIS0)

// Setup dir pins
#define DIR2_BIT 7 // assigns DIR2 pin
#define DIR2_PORT D // assigns DIR2 port
#define DIR1_BIT 6 // assigns DIR1 pin
#define DIR1_PORT D // assigns DIR1 port
#define DIR0_BIT 5 // assigns DIR0 pin
#define DIR0_PORT D // assigns DIR0 port

// Setup limit pins
#define LIMIT_Z_BIT 4 // assigns LIMIT_Z pin
#define LIMIT_Z_PORT B // assigns LIMIT_Z port
#define LIMIT_Z_ISR 0 // assigns LIMIT_Z ISR
/*#define LIMIT_Y2_BIT 4 //Z and second Y limit share the pin
#define LIMIT_Y2_PORT B //Z and second Y limit share the pin
#define LIMIT_Y2_ISR 0 //Z and second Y limit share the pin*/

#define LIMIT_Y_BIT 2 // assigns LIMIT_Y pin
#define LIMIT_Y_PORT B // assigns LIMIT_Y port
#define LIMIT_Y_ISR 0 // assigns LIMIT_Y ISR

#define LIMIT_X_BIT 1 // assigns LIMIT_X pin
#define LIMIT_X_PORT B // assigns LIMIT_X port
#define LIMIT_X_ISR 0 // assigns LIMIT_X ISR

// Active limits switch weak pull-ups
#define LIMIT_X_PULLUP
#define LIMIT_Y_PULLUP
#define LIMIT_Z_PULLUP

// Setup probe pin
// #define PROBE_BIT 5
// #define PROBE_PORT C
// #define PROBE_ISR 1

// Setup control input pins
// #define ESTOP_BIT 0
// #define FHOLD_BIT 1
// #define CS_RES_BIT 2
// #define ESTOP_PORT C
// #define FHOLD_PORT C
// #define CS_RES_PORT C
// #define ESTOP_ISR 1
// #define FHOLD_ISR 1
// #define CS_RES_ISR 1

// Active controls switch weak pull-ups
// #define ESTOP_PULLUP
// #define FHOLD_PULLUP

// Setup com pins
#define RX_BIT 0
#define TX_BIT 1
#define RX_PORT D
#define TX_PORT D
// only uncomment this if other port other then 0 is used
//#define COM_NUMBER 0

// Setup PWM
#define PWM0_BIT 3 // assigns PWM0 pin
#define PWM0_PORT B // assigns PWM0 pin
#define PWM0_CHANNEL A
#define PWM0_TIMER 2

// Setup generic IO Pins
// Functionalities are set in cnc_hal_config.h file

// spindle dir
#define DOUT0_BIT 5
#define DOUT0_PORT B

// coolant
// #define DOUT1_BIT 3
// #define DOUT1_PORT C

// spindle speed sensor
// #define ANALOG0_BIT 4
// #define ANALOG0_PORT C
// #define ANALOG0_CHANNEL 4

// Stepper enable pin. For Grbl on Uno board a single pin is used
#define STEP0_EN_BIT 0
#define STEP0_EN_PORT B

// Setup the Step Timer used has the heartbeat for µCNC
// Timer 1 is used by default
//#define ITP_TIMER 1

// Setup the RTC Timer used by µCNC to provide an (mostly) accurate time base for all time dependent functions
// Timer 0 is set by default
//#define RTC_TIMER 0
// disables control pins
#define DISABLE_ALL_CONTROLS

#ifdef __cplusplus
}
Expand Down
1 change: 1 addition & 0 deletions uCNC/src/hal/boards/boarddefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ extern "C"

#if (BOARD == BOARD_MKS_DLC)
#define MCU MCU_AVR
#define PLANNER_BUFFER_SIZE 14
#include "avr/boardmap_mks_dlc.h"
#endif

Expand Down
2 changes: 2 additions & 0 deletions uCNC/src/hal/mcus/samd21/mcumap_samd21.h
Original file line number Diff line number Diff line change
Expand Up @@ -2739,6 +2739,8 @@ extern "C"
#define mcu_tx_ready() (COM->USART.INTFLAG.bit.DRE)
#elif (INTERFACE == INTERFACE_USB)
#define CFG_TUSB_MCU OPT_MCU_SAMD21
extern uint32_t tud_cdc_n_write_available(uint8_t itf);
extern uint32_t tud_cdc_n_available(uint8_t itf);
#define mcu_rx_ready() tud_cdc_n_available(0)
#define mcu_tx_ready() tud_cdc_n_write_available(0)
#endif
Expand Down
4 changes: 3 additions & 1 deletion uCNC/src/hal/mcus/stm32f1x/mcumap_stm32f1x.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extern "C"
/*
MCU specific definitions and replacements
*/
#include "stm32f1xx.h"
#include <stm32f1xx.h>
#include <stdbool.h>

// defines the frequency of the mcu
Expand Down Expand Up @@ -4231,6 +4231,8 @@ extern "C"
#define mcu_rx_ready() (COM_USART->SR & USART_SR_RXNE)
#define mcu_tx_ready() (COM_USART->SR & USART_SR_TXE)
#elif (INTERFACE == INTERFACE_USB)
extern uint32_t tud_cdc_n_write_available(uint8_t itf);
extern uint32_t tud_cdc_n_available(uint8_t itf);
#define mcu_rx_ready() tud_cdc_n_available(0)
#define mcu_tx_ready() tud_cdc_n_write_available(0)
#endif
Expand Down
4 changes: 3 additions & 1 deletion uCNC/src/hal/mcus/stm32f4x/mcumap_stm32f4x.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extern "C"
MCU specific definitions and replacements
*/

#include "stm32f4xx.h"
#include <stm32f4xx.h>
#include <stdbool.h>

// defines the frequency of the mcu
Expand Down Expand Up @@ -3062,6 +3062,8 @@ extern "C"
#define mcu_rx_ready() (COM_USART->SR & USART_SR_RXNE)
#define mcu_tx_ready() (COM_USART->SR & USART_SR_TXE)
#elif (INTERFACE == INTERFACE_USB)
extern uint32_t tud_cdc_n_write_available(uint8_t itf);
extern uint32_t tud_cdc_n_available(uint8_t itf);
#define mcu_rx_ready() tud_cdc_n_available(0)
#define mcu_tx_ready() tud_cdc_n_write_available(0)
#endif
Expand Down

0 comments on commit 880d199

Please sign in to comment.