kopia lustrzana https://github.com/gnea/grbl
feat: new firmware
rodzic
3d5989ef60
commit
ee9ff9faed
|
@ -29,6 +29,13 @@
|
||||||
#define config_h
|
#define config_h
|
||||||
#include "grbl.h" // For Arduino IDE compatibility.
|
#include "grbl.h" // For Arduino IDE compatibility.
|
||||||
|
|
||||||
|
enum MachineType {
|
||||||
|
RCMINI,
|
||||||
|
BAMBOO
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MACHINE_TYPE MachineType::BAMBOO
|
||||||
|
|
||||||
|
|
||||||
// Define CPU pin map and default settings.
|
// Define CPU pin map and default settings.
|
||||||
// NOTE: OEMs can avoid the need to maintain/update the defaults.h and cpu_map.h files and use only
|
// NOTE: OEMs can avoid the need to maintain/update the defaults.h and cpu_map.h files and use only
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#define grbl_h
|
#define grbl_h
|
||||||
|
|
||||||
// Grbl versioning system
|
// Grbl versioning system
|
||||||
#define GRBL_VERSION "1.1h"
|
#define GRBL_VERSION "1.2h"
|
||||||
#define GRBL_VERSION_BUILD "20190830"
|
#define GRBL_VERSION_BUILD "20190830"
|
||||||
|
|
||||||
// Define standard libraries used by Grbl.
|
// Define standard libraries used by Grbl.
|
||||||
|
@ -60,6 +60,8 @@
|
||||||
#include "spindle_control.h"
|
#include "spindle_control.h"
|
||||||
#include "stepper.h"
|
#include "stepper.h"
|
||||||
#include "jog.h"
|
#include "jog.h"
|
||||||
|
#include "vcm.h"
|
||||||
|
#include "spi.h"
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------
|
||||||
// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:
|
// COMPILE-TIME ERROR CHECKING OF DEFINE VALUES:
|
||||||
|
|
|
@ -95,6 +95,20 @@ uint8_t limits_get_state()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t pinch_roller_get_state()
|
||||||
|
{
|
||||||
|
if (MACHINE_TYPE === MachineType::BAMBOO)
|
||||||
|
{
|
||||||
|
// Check PC3 state
|
||||||
|
if (PINC & (1 << PINC3))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// This is the Limit Pin Change Interrupt, which handles the hard limit feature. A bouncing
|
// This is the Limit Pin Change Interrupt, which handles the hard limit feature. A bouncing
|
||||||
// limit switch can cause a lot of problems, like false readings and multiple interrupt calls.
|
// limit switch can cause a lot of problems, like false readings and multiple interrupt calls.
|
||||||
// If a switch is triggered at all, something bad has happened and treat it as such, regardless
|
// If a switch is triggered at all, something bad has happened and treat it as such, regardless
|
||||||
|
|
|
@ -32,6 +32,8 @@ void limits_disable();
|
||||||
// Returns limit state as a bit-wise uint8 variable.
|
// Returns limit state as a bit-wise uint8 variable.
|
||||||
uint8_t limits_get_state();
|
uint8_t limits_get_state();
|
||||||
|
|
||||||
|
uint8_t pinch_roller_get_state();
|
||||||
|
|
||||||
// Perform one portion of the homing cycle based on the input settings.
|
// Perform one portion of the homing cycle based on the input settings.
|
||||||
void limits_go_home(uint8_t cycle_mask);
|
void limits_go_home(uint8_t cycle_mask);
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,8 @@ int main(void)
|
||||||
coolant_init();
|
coolant_init();
|
||||||
limits_init();
|
limits_init();
|
||||||
probe_init();
|
probe_init();
|
||||||
|
vcm_init();
|
||||||
|
motor_spi_init();
|
||||||
plan_reset(); // Clear block buffer and planner variables
|
plan_reset(); // Clear block buffer and planner variables
|
||||||
st_reset(); // Clear stepper subsystem variables.
|
st_reset(); // Clear stepper subsystem variables.
|
||||||
|
|
||||||
|
|
|
@ -369,7 +369,7 @@ void report_execute_startup_message(char *line, uint8_t status_code)
|
||||||
// Prints build info line
|
// Prints build info line
|
||||||
void report_build_info(char *line)
|
void report_build_info(char *line)
|
||||||
{
|
{
|
||||||
printPgmString(PSTR("[VER:" GRBL_VERSION "." GRBL_VERSION_BUILD ":"));
|
printPgmString(PSTR("[VER:" GRBL_VERSION "." GRBL_VERSION_BUILD ":" MACHINE_TYPE ":" ));
|
||||||
printString(line);
|
printString(line);
|
||||||
report_util_feedback_line_feed();
|
report_util_feedback_line_feed();
|
||||||
printPgmString(PSTR("[OPT:")); // Generate compile-time build option list
|
printPgmString(PSTR("[OPT:")); // Generate compile-time build option list
|
||||||
|
@ -568,7 +568,8 @@ void report_realtime_status()
|
||||||
uint8_t lim_pin_state = limits_get_state();
|
uint8_t lim_pin_state = limits_get_state();
|
||||||
uint8_t ctrl_pin_state = system_control_get_state();
|
uint8_t ctrl_pin_state = system_control_get_state();
|
||||||
uint8_t prb_pin_state = probe_get_state();
|
uint8_t prb_pin_state = probe_get_state();
|
||||||
if (lim_pin_state | ctrl_pin_state | prb_pin_state) {
|
uint8_t pinch_roller_state = pinch_roller_get_state();
|
||||||
|
if ((lim_pin_state | ctrl_pin_state | prb_pin_state) || pinch_roller_state) {
|
||||||
printPgmString(PSTR("|Pn:"));
|
printPgmString(PSTR("|Pn:"));
|
||||||
if (prb_pin_state) { serial_write('P'); }
|
if (prb_pin_state) { serial_write('P'); }
|
||||||
if (lim_pin_state) {
|
if (lim_pin_state) {
|
||||||
|
@ -586,6 +587,7 @@ void report_realtime_status()
|
||||||
if (bit_istrue(lim_pin_state,bit(X_AXIS))) { serial_write('X'); }
|
if (bit_istrue(lim_pin_state,bit(X_AXIS))) { serial_write('X'); }
|
||||||
if (bit_istrue(lim_pin_state,bit(Y_AXIS))) { serial_write('Y'); }
|
if (bit_istrue(lim_pin_state,bit(Y_AXIS))) { serial_write('Y'); }
|
||||||
if (bit_istrue(lim_pin_state,bit(Z_AXIS))) { serial_write('Z'); }
|
if (bit_istrue(lim_pin_state,bit(Z_AXIS))) { serial_write('Z'); }
|
||||||
|
if (pinch_roller_state) { serial_write('R'); }
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (ctrl_pin_state) {
|
if (ctrl_pin_state) {
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
#include "grbl.h"
|
||||||
|
|
||||||
|
#define CS1_PORT PORTC // Chip Select for Driver 1
|
||||||
|
#define CS1_PIN PC0
|
||||||
|
|
||||||
|
#define CS2_PORT PORTC // Chip Select for Driver 2
|
||||||
|
#define CS2_PIN PC1
|
||||||
|
|
||||||
|
#define SPI_DDR DDRB
|
||||||
|
#define SPI_PORT PORTB
|
||||||
|
#define MOSI PB3
|
||||||
|
#define MISO PB4
|
||||||
|
#define SCK PB5
|
||||||
|
|
||||||
|
void spi_init() {
|
||||||
|
SPI_DDR |= (1 << MOSI) | (1 << SCK); // Set MOSI and SCK as output
|
||||||
|
SPI_DDR &= ~(1 << MISO); // Set MISO as input
|
||||||
|
SPCR = (1 << SPE) | (1 << MSTR) | (1 << SPR0); // Enable SPI, Master, Fclk/16
|
||||||
|
}
|
||||||
|
|
||||||
|
void spi_write(uint8_t cs_port, uint8_t cs_pin, uint8_t address, uint8_t data) {
|
||||||
|
// Pull CS low to select device
|
||||||
|
cs_port &= ~(1 << cs_pin);
|
||||||
|
_delay_us(1); // Short delay for setup
|
||||||
|
|
||||||
|
// Send address
|
||||||
|
SPDR = address;
|
||||||
|
while (!(SPSR & (1 << SPIF))); // Wait for transmission to complete
|
||||||
|
|
||||||
|
// Send data
|
||||||
|
SPDR = data;
|
||||||
|
while (!(SPSR & (1 << SPIF))); // Wait for transmission to complete
|
||||||
|
|
||||||
|
// Pull CS high to deselect device
|
||||||
|
cs_port |= (1 << cs_pin);
|
||||||
|
_delay_us(1); // Short delay for setup
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CTRL1 Control Register (address = 0x04) [Default = 0Fh]
|
||||||
|
* BIT = 2-0
|
||||||
|
* SETTING = DECAY MODE
|
||||||
|
* 111b = Smart tune Ripple Control
|
||||||
|
*/
|
||||||
|
void motor_spi_init() {
|
||||||
|
// Configure Chip Select pins as outputs
|
||||||
|
DDRC |= (1 << CS1_PIN) | (1 << CS2_PIN);
|
||||||
|
CS1_PORT |= (1 << CS1_PIN); // Set CS high (deselect)
|
||||||
|
CS2_PORT |= (1 << CS2_PIN); // Set CS high (deselect)
|
||||||
|
|
||||||
|
// Send configuration to Driver 1
|
||||||
|
spi_write(CS1_PORT, CS1_PIN, 0x04, 0x07);
|
||||||
|
|
||||||
|
// Send configuration to Driver 2
|
||||||
|
spi_write(CS2_PORT, CS2_PIN, 0x04, 0x07);
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
void motor_spi_init();
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include "grbl.h"
|
||||||
|
|
||||||
|
void vcm_init()
|
||||||
|
{
|
||||||
|
if (MACHINE_TYPE === MachineType::BAMBOO)
|
||||||
|
{
|
||||||
|
DDRD |= (1 << DDD7);
|
||||||
|
// Set pin 7 to HIGH
|
||||||
|
PORTD |= (1 << PORTD7);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
void vcm_init();
|
Ładowanie…
Reference in New Issue