Skip to content

Commit

Permalink
Add SPI pin customization support
Browse files Browse the repository at this point in the history
  • Loading branch information
luc-github committed Aug 29, 2019
1 parent b3cd36b commit 55165a7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Grbl_Esp32/cpu_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@
*/

//Set your pine definition
//let -1 to use default board pin
#define GRBL_SPI_SS -1
#define GRBL_SPI_MOSI -1
#define GRBL_SPI_MIS0 -1
#define GRBL_SPI_SCK -1
//Set you frequency
#define GRBL_SPI_FREQ 4000000

#ifdef CPU_MAP_ESP32
// This is the CPU Map for the ESP32 CNC Controller R2
Expand Down
2 changes: 1 addition & 1 deletion Grbl_Esp32/grbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

// Grbl versioning system
#define GRBL_VERSION "1.1f"
#define GRBL_VERSION_BUILD "20190708"
#define GRBL_VERSION_BUILD "20190829"

//#include <sdkconfig.h>
#include <Arduino.h>
Expand Down
2 changes: 1 addition & 1 deletion Grbl_Esp32/grbl_sd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ uint8_t get_sd_state(bool refresh)
sd_state = SDCARD_NOT_PRESENT;
//using default value for speed ? should be parameter
//refresh content if card was removed
if (SD.begin()) {
if (SD.begin((GRBL_SPI_SS == -1)?SS:GRBL_SPI_SS, SPI, GRBL_SPI_FREQ)) {
if ( SD.cardSize() > 0 )sd_state = SDCARD_IDLE;
}
return sd_state;
Expand Down
4 changes: 4 additions & 0 deletions Grbl_Esp32/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ void system_ini() // Renamed from system_init() due to conflict with esp32 files
#endif

#endif
//customize pin definition if needed
#if (GRBL_SPI_SS != -1) || (GRBL_SPI_MIS0 != -1) || (GRBL_SPI_MOSI != -1) || (GRBL_SPI_SCK != -1)
SPI.begin(GRBL_SPI_SCK, GRBL_SPI_MIS0, GRBL_SPI_MOSI, GRBL_SPI_SS);
#endif
}

void IRAM_ATTR isr_control_inputs()
Expand Down

0 comments on commit 55165a7

Please sign in to comment.