Merge branch 'MK3_M115_Capabilities_report' into MK3_AUTO_REPORT_TEMPERATURES
This commit is contained in:
commit
a1dfbffedb
@ -381,6 +381,11 @@ const unsigned int dropsegments=5; //everything with less than this number of st
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include capabilities in M115 output
|
||||||
|
*/
|
||||||
|
#define EXTENDED_CAPABILITIES_REPORT
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//============================= Define Defines ============================
|
//============================= Define Defines ============================
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#ifndef MARLIN_H
|
#ifndef MARLIN_H
|
||||||
#define MARLIN_H
|
#define MARLIN_H
|
||||||
|
|
||||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
#include "macros.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -287,11 +287,6 @@ FORCE_INLINE unsigned long millis_nc() {
|
|||||||
void setPwmFrequency(uint8_t pin, int val);
|
void setPwmFrequency(uint8_t pin, int val);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CRITICAL_SECTION_START
|
|
||||||
#define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli();
|
|
||||||
#define CRITICAL_SECTION_END SREG = _sreg;
|
|
||||||
#endif //CRITICAL_SECTION_START
|
|
||||||
|
|
||||||
extern bool fans_check_enabled;
|
extern bool fans_check_enabled;
|
||||||
extern float homing_feedrate[];
|
extern float homing_feedrate[];
|
||||||
extern uint8_t axis_relative_modes;
|
extern uint8_t axis_relative_modes;
|
||||||
|
@ -47,7 +47,9 @@
|
|||||||
#include "Configuration.h"
|
#include "Configuration.h"
|
||||||
#include "Marlin.h"
|
#include "Marlin.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "macros.h"
|
||||||
|
|
||||||
#ifdef ENABLE_AUTO_BED_LEVELING
|
#ifdef ENABLE_AUTO_BED_LEVELING
|
||||||
#include "vector_3.h"
|
#include "vector_3.h"
|
||||||
#ifdef AUTO_BED_LEVELING_GRID
|
#ifdef AUTO_BED_LEVELING_GRID
|
||||||
@ -137,12 +139,6 @@
|
|||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
|
||||||
#include "cmdqueue.h"
|
#include "cmdqueue.h"
|
||||||
#include "io_atmega2560.h"
|
|
||||||
|
|
||||||
// Macros for bit masks
|
|
||||||
#define BIT(b) (1<<(b))
|
|
||||||
#define TEST(n,b) (((n)&BIT(b))!=0)
|
|
||||||
#define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (BIT(b))
|
|
||||||
|
|
||||||
//Macro for print fan speed
|
//Macro for print fan speed
|
||||||
#define FAN_PULSE_WIDTH_LIMIT ((fanSpeed > 100) ? 3 : 4) //time in ms
|
#define FAN_PULSE_WIDTH_LIMIT ((fanSpeed > 100) ? 3 : 4) //time in ms
|
||||||
@ -885,7 +881,7 @@ static void check_if_fw_is_on_right_printer(){
|
|||||||
|
|
||||||
#ifdef PAT9125
|
#ifdef PAT9125
|
||||||
//will return 1 only if IR can detect filament in bondtech extruder so this may fail even when we have IR sensor
|
//will return 1 only if IR can detect filament in bondtech extruder so this may fail even when we have IR sensor
|
||||||
const uint8_t ir_detected = !(PIN_GET(IR_SENSOR_PIN));
|
const uint8_t ir_detected = !READ(IR_SENSOR_PIN);
|
||||||
if (ir_detected){
|
if (ir_detected){
|
||||||
lcd_show_fullscreen_message_and_wait_P(_i("MK3 firmware detected on MK3S printer"));}////c=20 r=3
|
lcd_show_fullscreen_message_and_wait_P(_i("MK3 firmware detected on MK3S printer"));}////c=20 r=3
|
||||||
#endif //PAT9125
|
#endif //PAT9125
|
||||||
@ -3512,6 +3508,17 @@ static void gcode_G92()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef EXTENDED_CAPABILITIES_REPORT
|
||||||
|
|
||||||
|
static void cap_line(const char* name, bool ena = false) {
|
||||||
|
printf_P(PSTR("Cap:%S:%c\n"), name, (char)ena + '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
static void extended_capabilities_report()
|
||||||
|
{
|
||||||
|
//@todo
|
||||||
|
}
|
||||||
|
#endif //EXTENDED_CAPABILITIES_REPORT
|
||||||
|
|
||||||
#ifdef BACKLASH_X
|
#ifdef BACKLASH_X
|
||||||
extern uint8_t st_backlash_x;
|
extern uint8_t st_backlash_x;
|
||||||
@ -6845,6 +6852,11 @@ Sigma_Exit:
|
|||||||
SERIAL_ECHOPGM(" UUID:");
|
SERIAL_ECHOPGM(" UUID:");
|
||||||
SERIAL_ECHOLNPGM(MACHINE_UUID);
|
SERIAL_ECHOLNPGM(MACHINE_UUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef EXTENDED_CAPABILITIES_REPORT
|
||||||
|
extended_capabilities_report();
|
||||||
|
#endif //EXTENDED_CAPABILITIES_REPORT
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
//backlight.cpp
|
//backlight.cpp
|
||||||
|
|
||||||
#include "backlight.h"
|
#include "backlight.h"
|
||||||
|
#include "macros.h"
|
||||||
#include <avr/eeprom.h>
|
#include <avr/eeprom.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "eeprom.h"
|
#include "eeprom.h"
|
||||||
#include "Marlin.h"
|
|
||||||
#include "pins.h"
|
#include "pins.h"
|
||||||
#include "fastio.h"
|
#include "fastio.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
@ -111,10 +111,10 @@ void backlight_init()
|
|||||||
|
|
||||||
#else //LCD_BL_PIN
|
#else //LCD_BL_PIN
|
||||||
|
|
||||||
void force_bl_on(__attribute__((unused)) bool section_start) {}
|
void force_bl_on(bool) {}
|
||||||
void backlight_update() {}
|
void backlight_update() {}
|
||||||
void backlight_init() {}
|
void backlight_init() {}
|
||||||
void backlight_save() {}
|
void backlight_save() {}
|
||||||
void backlight_wake(__attribute__((unused)) const uint8_t flashNo) {}
|
void backlight_wake(const uint8_t) {}
|
||||||
|
|
||||||
#endif //LCD_BL_PIN
|
#endif //LCD_BL_PIN
|
@ -7,15 +7,7 @@
|
|||||||
#define _FASTIO_ARDUINO_H
|
#define _FASTIO_ARDUINO_H
|
||||||
|
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
#include "macros.h"
|
||||||
/*
|
|
||||||
utility functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MASK
|
|
||||||
/// MASKING- returns \f$2^PIN\f$
|
|
||||||
#define MASK(PIN) (1 << PIN)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
magic I/O routines
|
magic I/O routines
|
||||||
@ -23,20 +15,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/// Read a pin
|
/// Read a pin
|
||||||
#define _READ(IO) ((bool)(DIO ## IO ## _RPORT & MASK(DIO ## IO ## _PIN)))
|
#define _READ(IO) ((bool)(DIO ## IO ## _RPORT & _BV(DIO ## IO ## _PIN)))
|
||||||
/// write to a pin
|
/// write to a pin
|
||||||
// On some boards pins > 0x100 are used. These are not converted to atomic actions. An critical section is needed.
|
// On some boards pins > 0x100 are used. These are not converted to atomic actions. An critical section is needed.
|
||||||
|
|
||||||
#define _WRITE_NC(IO, v) do { if (v) {DIO ## IO ## _WPORT |= MASK(DIO ## IO ## _PIN); } else {DIO ## IO ## _WPORT &= ~MASK(DIO ## IO ## _PIN); }; } while (0)
|
#define _WRITE_NC(IO, v) do { if (v) {DIO ## IO ## _WPORT |= _BV(DIO ## IO ## _PIN); } else {DIO ## IO ## _WPORT &= ~_BV(DIO ## IO ## _PIN); }; } while (0)
|
||||||
|
|
||||||
#define _WRITE_C(IO, v) do { if (v) { \
|
#define _WRITE_C(IO, v) do { if (v) { \
|
||||||
CRITICAL_SECTION_START; \
|
CRITICAL_SECTION_START; \
|
||||||
{DIO ## IO ## _WPORT |= MASK(DIO ## IO ## _PIN); }\
|
{DIO ## IO ## _WPORT |= _BV(DIO ## IO ## _PIN); }\
|
||||||
CRITICAL_SECTION_END; \
|
CRITICAL_SECTION_END; \
|
||||||
}\
|
}\
|
||||||
else {\
|
else {\
|
||||||
CRITICAL_SECTION_START; \
|
CRITICAL_SECTION_START; \
|
||||||
{DIO ## IO ## _WPORT &= ~MASK(DIO ## IO ## _PIN); }\
|
{DIO ## IO ## _WPORT &= ~_BV(DIO ## IO ## _PIN); }\
|
||||||
CRITICAL_SECTION_END; \
|
CRITICAL_SECTION_END; \
|
||||||
}\
|
}\
|
||||||
}\
|
}\
|
||||||
@ -45,17 +37,17 @@
|
|||||||
#define _WRITE(IO, v) do { if (&(DIO ## IO ## _RPORT) >= (uint8_t *)0x100) {_WRITE_C(IO, v); } else {_WRITE_NC(IO, v); }; } while (0)
|
#define _WRITE(IO, v) do { if (&(DIO ## IO ## _RPORT) >= (uint8_t *)0x100) {_WRITE_C(IO, v); } else {_WRITE_NC(IO, v); }; } while (0)
|
||||||
|
|
||||||
/// toggle a pin
|
/// toggle a pin
|
||||||
#define _TOGGLE(IO) do {DIO ## IO ## _RPORT = MASK(DIO ## IO ## _PIN); } while (0)
|
#define _TOGGLE(IO) do {DIO ## IO ## _RPORT = _BV(DIO ## IO ## _PIN); } while (0)
|
||||||
|
|
||||||
/// set pin as input
|
/// set pin as input
|
||||||
#define _SET_INPUT(IO) do {DIO ## IO ## _DDR &= ~MASK(DIO ## IO ## _PIN); } while (0)
|
#define _SET_INPUT(IO) do {DIO ## IO ## _DDR &= ~_BV(DIO ## IO ## _PIN); } while (0)
|
||||||
/// set pin as output
|
/// set pin as output
|
||||||
#define _SET_OUTPUT(IO) do {DIO ## IO ## _DDR |= MASK(DIO ## IO ## _PIN); } while (0)
|
#define _SET_OUTPUT(IO) do {DIO ## IO ## _DDR |= _BV(DIO ## IO ## _PIN); } while (0)
|
||||||
|
|
||||||
/// check if pin is an input
|
/// check if pin is an input
|
||||||
#define _GET_INPUT(IO) ((DIO ## IO ## _DDR & MASK(DIO ## IO ## _PIN)) == 0)
|
#define _GET_INPUT(IO) ((DIO ## IO ## _DDR & _BV(DIO ## IO ## _PIN)) == 0)
|
||||||
/// check if pin is an output
|
/// check if pin is an output
|
||||||
#define _GET_OUTPUT(IO) ((DIO ## IO ## _DDR & MASK(DIO ## IO ## _PIN)) != 0)
|
#define _GET_OUTPUT(IO) ((DIO ## IO ## _DDR & _BV(DIO ## IO ## _PIN)) != 0)
|
||||||
|
|
||||||
/// check if pin is an timer
|
/// check if pin is an timer
|
||||||
#define _GET_TIMER(IO) (DIO ## IO ## _PWM)
|
#define _GET_TIMER(IO) (DIO ## IO ## _PWM)
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
#include "pat9125.h"
|
#include "pat9125.h"
|
||||||
#include "stepper.h"
|
#include "stepper.h"
|
||||||
#include "io_atmega2560.h"
|
|
||||||
#include "cmdqueue.h"
|
#include "cmdqueue.h"
|
||||||
#include "ultralcd.h"
|
#include "ultralcd.h"
|
||||||
#include "mmu.h"
|
#include "mmu.h"
|
||||||
@ -608,9 +607,8 @@ void fsensor_st_block_chunk(int cnt)
|
|||||||
if (!fsensor_enabled) return;
|
if (!fsensor_enabled) return;
|
||||||
fsensor_st_cnt += cnt;
|
fsensor_st_cnt += cnt;
|
||||||
|
|
||||||
// !!! bit toggling (PINxn <- 1) (for PinChangeInterrupt) does not work for some MCU pins
|
// !!! bit toggling (PINxn <- 1) (for PinChangeInterrupt) does not work for some MCU pins
|
||||||
if (PIN_GET(FSENSOR_INT_PIN)) {PIN_VAL(FSENSOR_INT_PIN, LOW);}
|
WRITE(FSENSOR_INT_PIN, !READ(FSENSOR_INT_PIN));
|
||||||
else {PIN_VAL(FSENSOR_INT_PIN, HIGH);}
|
|
||||||
}
|
}
|
||||||
#endif //PAT9125
|
#endif //PAT9125
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include "io_atmega2560.h"
|
|
||||||
|
|
||||||
// All this is about silencing the heat bed, as it behaves like a loudspeaker.
|
// All this is about silencing the heat bed, as it behaves like a loudspeaker.
|
||||||
// Basically, we want the PWM heating switched at 30Hz (or so) which is a well ballanced
|
// Basically, we want the PWM heating switched at 30Hz (or so) which is a well ballanced
|
||||||
|
@ -1,374 +0,0 @@
|
|||||||
//io_atmega2560.h
|
|
||||||
#ifndef _IO_ATMEGA2560
|
|
||||||
#define _IO_ATMEGA2560
|
|
||||||
|
|
||||||
|
|
||||||
#define __PIN_P0 PINE
|
|
||||||
#define __PIN_P1 PINE
|
|
||||||
#define __PIN_P2 PINE
|
|
||||||
#define __PIN_P3 PINE
|
|
||||||
#define __PIN_P4 PING
|
|
||||||
#define __PIN_P5 PINE
|
|
||||||
#define __PIN_P6 PINH
|
|
||||||
#define __PIN_P7 PINH
|
|
||||||
#define __PIN_P8 PINH
|
|
||||||
#define __PIN_P9 PINH
|
|
||||||
#define __PIN_P10 PINB
|
|
||||||
#define __PIN_P11 PINB
|
|
||||||
#define __PIN_P12 PINB
|
|
||||||
#define __PIN_P13 PINB
|
|
||||||
#define __PIN_P14 PINJ
|
|
||||||
#define __PIN_P15 PINJ
|
|
||||||
#define __PIN_P16 PINH
|
|
||||||
#define __PIN_P17 PINH
|
|
||||||
#define __PIN_P18 PIND
|
|
||||||
#define __PIN_P19 PIND
|
|
||||||
#define __PIN_P20 PIND
|
|
||||||
#define __PIN_P21 PIND
|
|
||||||
#define __PIN_P22 PINA
|
|
||||||
#define __PIN_P23 PINA
|
|
||||||
#define __PIN_P24 PINA
|
|
||||||
#define __PIN_P25 PINA
|
|
||||||
#define __PIN_P26 PINA
|
|
||||||
#define __PIN_P27 PINA
|
|
||||||
#define __PIN_P28 PINA
|
|
||||||
#define __PIN_P29 PINA
|
|
||||||
#define __PIN_P30 PINC
|
|
||||||
#define __PIN_P31 PINC
|
|
||||||
#define __PIN_P32 PINC
|
|
||||||
#define __PIN_P33 PINC
|
|
||||||
#define __PIN_P34 PINC
|
|
||||||
#define __PIN_P35 PINC
|
|
||||||
#define __PIN_P36 PINC
|
|
||||||
#define __PIN_P37 PINC
|
|
||||||
#define __PIN_P38 PIND
|
|
||||||
#define __PIN_P39 PING
|
|
||||||
#define __PIN_P40 PING
|
|
||||||
#define __PIN_P41 PING
|
|
||||||
#define __PIN_P42 PINL
|
|
||||||
#define __PIN_P43 PINL
|
|
||||||
#define __PIN_P44 PINL
|
|
||||||
#define __PIN_P45 PINL
|
|
||||||
#define __PIN_P46 PINL
|
|
||||||
#define __PIN_P47 PINL
|
|
||||||
#define __PIN_P48 PINL
|
|
||||||
#define __PIN_P49 PINL
|
|
||||||
#define __PIN_P50 PINB
|
|
||||||
#define __PIN_P51 PINB
|
|
||||||
#define __PIN_P52 PINB
|
|
||||||
#define __PIN_P53 PINB
|
|
||||||
#define __PIN_P54 PINF
|
|
||||||
#define __PIN_P55 PINF
|
|
||||||
#define __PIN_P56 PINF
|
|
||||||
#define __PIN_P57 PINF
|
|
||||||
#define __PIN_P58 PINF
|
|
||||||
#define __PIN_P59 PINF
|
|
||||||
#define __PIN_P60 PINF
|
|
||||||
#define __PIN_P61 PINF
|
|
||||||
#define __PIN_P62 PINK
|
|
||||||
#define __PIN_P63 PINK
|
|
||||||
#define __PIN_P64 PINK
|
|
||||||
#define __PIN_P65 PINK
|
|
||||||
#define __PIN_P66 PINK
|
|
||||||
#define __PIN_P67 PINK
|
|
||||||
#define __PIN_P68 PINK
|
|
||||||
#define __PIN_P69 PINK
|
|
||||||
#define __PIN_P70 PING
|
|
||||||
#define __PIN_P71 PING
|
|
||||||
#define __PIN_P72 PINJ
|
|
||||||
#define __PIN_P73 PINJ
|
|
||||||
#define __PIN_P74 PINJ
|
|
||||||
#define __PIN_P75 PINJ
|
|
||||||
#define __PIN_P76 PINJ
|
|
||||||
#define __PIN_P77 PINJ
|
|
||||||
#define __PIN_P78 PINE
|
|
||||||
#define __PIN_P79 PINE
|
|
||||||
#define __PIN_P80 PINE
|
|
||||||
#define __PIN_P81 PIND
|
|
||||||
#define __PIN_P82 PIND
|
|
||||||
#define __PIN_P83 PIND
|
|
||||||
#define __PIN_P84 PINH
|
|
||||||
#define __PIN_P85 PINH
|
|
||||||
|
|
||||||
#define __PORT_P0 PORTE
|
|
||||||
#define __PORT_P1 PORTE
|
|
||||||
#define __PORT_P2 PORTE
|
|
||||||
#define __PORT_P3 PORTE
|
|
||||||
#define __PORT_P4 PORTG
|
|
||||||
#define __PORT_P5 PORTE
|
|
||||||
#define __PORT_P6 PORTH
|
|
||||||
#define __PORT_P7 PORTH
|
|
||||||
#define __PORT_P8 PORTH
|
|
||||||
#define __PORT_P9 PORTH
|
|
||||||
#define __PORT_P10 PORTB
|
|
||||||
#define __PORT_P11 PORTB
|
|
||||||
#define __PORT_P12 PORTB
|
|
||||||
#define __PORT_P13 PORTB
|
|
||||||
#define __PORT_P14 PORTJ
|
|
||||||
#define __PORT_P15 PORTJ
|
|
||||||
#define __PORT_P16 PORTH
|
|
||||||
#define __PORT_P17 PORTH
|
|
||||||
#define __PORT_P18 PORTD
|
|
||||||
#define __PORT_P19 PORTD
|
|
||||||
#define __PORT_P20 PORTD
|
|
||||||
#define __PORT_P21 PORTD
|
|
||||||
#define __PORT_P22 PORTA
|
|
||||||
#define __PORT_P23 PORTA
|
|
||||||
#define __PORT_P24 PORTA
|
|
||||||
#define __PORT_P25 PORTA
|
|
||||||
#define __PORT_P26 PORTA
|
|
||||||
#define __PORT_P27 PORTA
|
|
||||||
#define __PORT_P28 PORTA
|
|
||||||
#define __PORT_P29 PORTA
|
|
||||||
#define __PORT_P30 PORTC
|
|
||||||
#define __PORT_P31 PORTC
|
|
||||||
#define __PORT_P32 PORTC
|
|
||||||
#define __PORT_P33 PORTC
|
|
||||||
#define __PORT_P34 PORTC
|
|
||||||
#define __PORT_P35 PORTC
|
|
||||||
#define __PORT_P36 PORTC
|
|
||||||
#define __PORT_P37 PORTC
|
|
||||||
#define __PORT_P38 PORTD
|
|
||||||
#define __PORT_P39 PORTG
|
|
||||||
#define __PORT_P40 PORTG
|
|
||||||
#define __PORT_P41 PORTG
|
|
||||||
#define __PORT_P42 PORTL
|
|
||||||
#define __PORT_P43 PORTL
|
|
||||||
#define __PORT_P44 PORTL
|
|
||||||
#define __PORT_P45 PORTL
|
|
||||||
#define __PORT_P46 PORTL
|
|
||||||
#define __PORT_P47 PORTL
|
|
||||||
#define __PORT_P48 PORTL
|
|
||||||
#define __PORT_P49 PORTL
|
|
||||||
#define __PORT_P50 PORTB
|
|
||||||
#define __PORT_P51 PORTB
|
|
||||||
#define __PORT_P52 PORTB
|
|
||||||
#define __PORT_P53 PORTB
|
|
||||||
#define __PORT_P54 PORTF
|
|
||||||
#define __PORT_P55 PORTF
|
|
||||||
#define __PORT_P56 PORTF
|
|
||||||
#define __PORT_P57 PORTF
|
|
||||||
#define __PORT_P58 PORTF
|
|
||||||
#define __PORT_P59 PORTF
|
|
||||||
#define __PORT_P60 PORTF
|
|
||||||
#define __PORT_P61 PORTF
|
|
||||||
#define __PORT_P62 PORTK
|
|
||||||
#define __PORT_P63 PORTK
|
|
||||||
#define __PORT_P64 PORTK
|
|
||||||
#define __PORT_P65 PORTK
|
|
||||||
#define __PORT_P66 PORTK
|
|
||||||
#define __PORT_P67 PORTK
|
|
||||||
#define __PORT_P68 PORTK
|
|
||||||
#define __PORT_P69 PORTK
|
|
||||||
#define __PORT_P70 PORTG
|
|
||||||
#define __PORT_P71 PORTG
|
|
||||||
#define __PORT_P72 PORTJ
|
|
||||||
#define __PORT_P73 PORTJ
|
|
||||||
#define __PORT_P74 PORTJ
|
|
||||||
#define __PORT_P75 PORTJ
|
|
||||||
#define __PORT_P76 PORTJ
|
|
||||||
#define __PORT_P77 PORTJ
|
|
||||||
#define __PORT_P78 PORTE
|
|
||||||
#define __PORT_P79 PORTE
|
|
||||||
#define __PORT_P80 PORTE
|
|
||||||
#define __PORT_P81 PORTD
|
|
||||||
#define __PORT_P82 PORTD
|
|
||||||
#define __PORT_P83 PORTD
|
|
||||||
#define __PORT_P84 PORTH
|
|
||||||
#define __PORT_P85 PORTH
|
|
||||||
|
|
||||||
#define __DDR_P0 DDRE
|
|
||||||
#define __DDR_P1 DDRE
|
|
||||||
#define __DDR_P2 DDRE
|
|
||||||
#define __DDR_P3 DDRE
|
|
||||||
#define __DDR_P4 DDRG
|
|
||||||
#define __DDR_P5 DDRE
|
|
||||||
#define __DDR_P6 DDRH
|
|
||||||
#define __DDR_P7 DDRH
|
|
||||||
#define __DDR_P8 DDRH
|
|
||||||
#define __DDR_P9 DDRH
|
|
||||||
#define __DDR_P10 DDRB
|
|
||||||
#define __DDR_P11 DDRB
|
|
||||||
#define __DDR_P12 DDRB
|
|
||||||
#define __DDR_P13 DDRB
|
|
||||||
#define __DDR_P14 DDRJ
|
|
||||||
#define __DDR_P15 DDRJ
|
|
||||||
#define __DDR_P16 DDRH
|
|
||||||
#define __DDR_P17 DDRH
|
|
||||||
#define __DDR_P18 DDRD
|
|
||||||
#define __DDR_P19 DDRD
|
|
||||||
#define __DDR_P20 DDRD
|
|
||||||
#define __DDR_P21 DDRD
|
|
||||||
#define __DDR_P22 DDRA
|
|
||||||
#define __DDR_P23 DDRA
|
|
||||||
#define __DDR_P24 DDRA
|
|
||||||
#define __DDR_P25 DDRA
|
|
||||||
#define __DDR_P26 DDRA
|
|
||||||
#define __DDR_P27 DDRA
|
|
||||||
#define __DDR_P28 DDRA
|
|
||||||
#define __DDR_P29 DDRA
|
|
||||||
#define __DDR_P30 DDRC
|
|
||||||
#define __DDR_P31 DDRC
|
|
||||||
#define __DDR_P32 DDRC
|
|
||||||
#define __DDR_P33 DDRC
|
|
||||||
#define __DDR_P34 DDRC
|
|
||||||
#define __DDR_P35 DDRC
|
|
||||||
#define __DDR_P36 DDRC
|
|
||||||
#define __DDR_P37 DDRC
|
|
||||||
#define __DDR_P38 DDRD
|
|
||||||
#define __DDR_P39 DDRG
|
|
||||||
#define __DDR_P40 DDRG
|
|
||||||
#define __DDR_P41 DDRG
|
|
||||||
#define __DDR_P42 DDRL
|
|
||||||
#define __DDR_P43 DDRL
|
|
||||||
#define __DDR_P44 DDRL
|
|
||||||
#define __DDR_P45 DDRL
|
|
||||||
#define __DDR_P46 DDRL
|
|
||||||
#define __DDR_P47 DDRL
|
|
||||||
#define __DDR_P48 DDRL
|
|
||||||
#define __DDR_P49 DDRL
|
|
||||||
#define __DDR_P50 DDRB
|
|
||||||
#define __DDR_P51 DDRB
|
|
||||||
#define __DDR_P52 DDRB
|
|
||||||
#define __DDR_P53 DDRB
|
|
||||||
#define __DDR_P54 DDRF
|
|
||||||
#define __DDR_P55 DDRF
|
|
||||||
#define __DDR_P56 DDRF
|
|
||||||
#define __DDR_P57 DDRF
|
|
||||||
#define __DDR_P58 DDRF
|
|
||||||
#define __DDR_P59 DDRF
|
|
||||||
#define __DDR_P60 DDRF
|
|
||||||
#define __DDR_P61 DDRF
|
|
||||||
#define __DDR_P62 DDRK
|
|
||||||
#define __DDR_P63 DDRK
|
|
||||||
#define __DDR_P64 DDRK
|
|
||||||
#define __DDR_P65 DDRK
|
|
||||||
#define __DDR_P66 DDRK
|
|
||||||
#define __DDR_P67 DDRK
|
|
||||||
#define __DDR_P68 DDRK
|
|
||||||
#define __DDR_P69 DDRK
|
|
||||||
#define __DDR_P70 DDRG
|
|
||||||
#define __DDR_P71 DDRG
|
|
||||||
#define __DDR_P72 DDRJ
|
|
||||||
#define __DDR_P73 DDRJ
|
|
||||||
#define __DDR_P74 DDRJ
|
|
||||||
#define __DDR_P75 DDRJ
|
|
||||||
#define __DDR_P76 DDRJ
|
|
||||||
#define __DDR_P77 DDRJ
|
|
||||||
#define __DDR_P78 DDRE
|
|
||||||
#define __DDR_P79 DDRE
|
|
||||||
#define __DDR_P80 DDRE
|
|
||||||
#define __DDR_P81 DDRD
|
|
||||||
#define __DDR_P82 DDRD
|
|
||||||
#define __DDR_P83 DDRD
|
|
||||||
#define __DDR_P84 DDRH
|
|
||||||
#define __DDR_P85 DDRH
|
|
||||||
|
|
||||||
#define __BIT_P0 0
|
|
||||||
#define __BIT_P1 1
|
|
||||||
#define __BIT_P2 4
|
|
||||||
#define __BIT_P3 5
|
|
||||||
#define __BIT_P4 5
|
|
||||||
#define __BIT_P5 3
|
|
||||||
#define __BIT_P6 3
|
|
||||||
#define __BIT_P7 4
|
|
||||||
#define __BIT_P8 5
|
|
||||||
#define __BIT_P9 6
|
|
||||||
#define __BIT_P10 4
|
|
||||||
#define __BIT_P11 5
|
|
||||||
#define __BIT_P12 6
|
|
||||||
#define __BIT_P13 7
|
|
||||||
#define __BIT_P14 1
|
|
||||||
#define __BIT_P15 0
|
|
||||||
#define __BIT_P16 0
|
|
||||||
#define __BIT_P17 1
|
|
||||||
#define __BIT_P18 3
|
|
||||||
#define __BIT_P19 2
|
|
||||||
#define __BIT_P20 1
|
|
||||||
#define __BIT_P21 0
|
|
||||||
#define __BIT_P22 0
|
|
||||||
#define __BIT_P23 1
|
|
||||||
#define __BIT_P24 2
|
|
||||||
#define __BIT_P25 3
|
|
||||||
#define __BIT_P26 4
|
|
||||||
#define __BIT_P27 5
|
|
||||||
#define __BIT_P28 6
|
|
||||||
#define __BIT_P29 7
|
|
||||||
#define __BIT_P30 7
|
|
||||||
#define __BIT_P31 6
|
|
||||||
#define __BIT_P32 5
|
|
||||||
#define __BIT_P33 4
|
|
||||||
#define __BIT_P34 3
|
|
||||||
#define __BIT_P35 2
|
|
||||||
#define __BIT_P36 1
|
|
||||||
#define __BIT_P37 0
|
|
||||||
#define __BIT_P38 7
|
|
||||||
#define __BIT_P39 2
|
|
||||||
#define __BIT_P40 1
|
|
||||||
#define __BIT_P41 0
|
|
||||||
#define __BIT_P42 7
|
|
||||||
#define __BIT_P43 6
|
|
||||||
#define __BIT_P44 5
|
|
||||||
#define __BIT_P45 4
|
|
||||||
#define __BIT_P46 3
|
|
||||||
#define __BIT_P47 2
|
|
||||||
#define __BIT_P48 1
|
|
||||||
#define __BIT_P49 0
|
|
||||||
#define __BIT_P50 3
|
|
||||||
#define __BIT_P51 2
|
|
||||||
#define __BIT_P52 1
|
|
||||||
#define __BIT_P53 0
|
|
||||||
#define __BIT_P54 0
|
|
||||||
#define __BIT_P55 1
|
|
||||||
#define __BIT_P56 2
|
|
||||||
#define __BIT_P57 3
|
|
||||||
#define __BIT_P58 4
|
|
||||||
#define __BIT_P59 5
|
|
||||||
#define __BIT_P60 6
|
|
||||||
#define __BIT_P61 7
|
|
||||||
#define __BIT_P62 0
|
|
||||||
#define __BIT_P63 1
|
|
||||||
#define __BIT_P64 2
|
|
||||||
#define __BIT_P65 3
|
|
||||||
#define __BIT_P66 4
|
|
||||||
#define __BIT_P67 5
|
|
||||||
#define __BIT_P68 6
|
|
||||||
#define __BIT_P69 7
|
|
||||||
#define __BIT_P70 4
|
|
||||||
#define __BIT_P71 3
|
|
||||||
#define __BIT_P72 2
|
|
||||||
#define __BIT_P73 3
|
|
||||||
#define __BIT_P74 7
|
|
||||||
#define __BIT_P75 4
|
|
||||||
#define __BIT_P76 5
|
|
||||||
#define __BIT_P77 6
|
|
||||||
#define __BIT_P78 2
|
|
||||||
#define __BIT_P79 6
|
|
||||||
#define __BIT_P80 7
|
|
||||||
#define __BIT_P81 4
|
|
||||||
#define __BIT_P82 5
|
|
||||||
#define __BIT_P83 6
|
|
||||||
#define __BIT_P84 2
|
|
||||||
#define __BIT_P85 7
|
|
||||||
|
|
||||||
#define __BIT(pin) __BIT_P##pin
|
|
||||||
#define __MSK(pin) (1 << __BIT(pin))
|
|
||||||
|
|
||||||
#define __PIN(pin) __PIN_P##pin
|
|
||||||
#define __PORT(pin) __PORT_P##pin
|
|
||||||
#define __DDR(pin) __DDR_P##pin
|
|
||||||
|
|
||||||
#define PIN(pin) __PIN(pin)
|
|
||||||
#define PORT(pin) __PORT(pin)
|
|
||||||
#define DDR(pin) __DDR(pin)
|
|
||||||
|
|
||||||
#define PIN_INP(pin) DDR(pin) &= ~__MSK(pin)
|
|
||||||
#define PIN_OUT(pin) DDR(pin) |= __MSK(pin)
|
|
||||||
#define PIN_CLR(pin) PORT(pin) &= ~__MSK(pin)
|
|
||||||
#define PIN_SET(pin) PORT(pin) |= __MSK(pin)
|
|
||||||
#define PIN_VAL(pin, val) if (val) PIN_SET(pin); else PIN_CLR(pin);
|
|
||||||
#define PIN_GET(pin) (PIN(pin) & __MSK(pin))
|
|
||||||
#define PIN_INQ(pin) (PORT(pin) & __MSK(pin))
|
|
||||||
|
|
||||||
|
|
||||||
#endif //_IO_ATMEGA2560
|
|
@ -17,10 +17,10 @@ uint8_t lang_selected = 0;
|
|||||||
|
|
||||||
#if (LANG_MODE == 0) //primary language only
|
#if (LANG_MODE == 0) //primary language only
|
||||||
|
|
||||||
uint8_t lang_select(__attribute__((unused)) uint8_t lang) { return 0; }
|
uint8_t lang_select(_UNUSED uint8_t lang) { return 0; }
|
||||||
uint8_t lang_get_count() { return 1; }
|
uint8_t lang_get_count() { return 1; }
|
||||||
uint16_t lang_get_code(__attribute__((unused)) uint8_t lang) { return LANG_CODE_EN; }
|
uint16_t lang_get_code(_UNUSED uint8_t lang) { return LANG_CODE_EN; }
|
||||||
const char* lang_get_name_by_code(__attribute__((unused)) uint16_t code) { return _n("English"); }
|
const char* lang_get_name_by_code(_UNUSED uint16_t code) { return _n("English"); }
|
||||||
void lang_reset(void) { }
|
void lang_reset(void) { }
|
||||||
uint8_t lang_is_selected(void) { return 1; }
|
uint8_t lang_is_selected(void) { return 1; }
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "macros.h"
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#ifdef DEBUG_SEC_LANG
|
#ifdef DEBUG_SEC_LANG
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -22,9 +23,6 @@
|
|||||||
|
|
||||||
#define MSG_FW_VERSION "Firmware"
|
#define MSG_FW_VERSION "Firmware"
|
||||||
|
|
||||||
#define STRINGIFY_(n) #n
|
|
||||||
#define STRINGIFY(n) STRINGIFY_(n)
|
|
||||||
|
|
||||||
#if (LANG_MODE == 0) //primary language only
|
#if (LANG_MODE == 0) //primary language only
|
||||||
#define PROGMEM_I2 __attribute__((section(".progmem0")))
|
#define PROGMEM_I2 __attribute__((section(".progmem0")))
|
||||||
#define PROGMEM_I1 __attribute__((section(".progmem1")))
|
#define PROGMEM_I1 __attribute__((section(".progmem1")))
|
||||||
|
90
Firmware/macros.h
Normal file
90
Firmware/macros.h
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
#ifndef MACROS_H
|
||||||
|
#define MACROS_H
|
||||||
|
|
||||||
|
#include <avr/interrupt.h> //for cli() and sei()
|
||||||
|
|
||||||
|
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||||
|
#define _UNUSED __attribute__((unused))
|
||||||
|
|
||||||
|
#ifndef CRITICAL_SECTION_START
|
||||||
|
#define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli();
|
||||||
|
#define CRITICAL_SECTION_END SREG = _sreg;
|
||||||
|
#endif //CRITICAL_SECTION_START
|
||||||
|
|
||||||
|
// Macros to make a string from a macro
|
||||||
|
#define STRINGIFY_(M) #M
|
||||||
|
#define STRINGIFY(M) STRINGIFY_(M)
|
||||||
|
|
||||||
|
// Macros for bit masks
|
||||||
|
#undef _BV
|
||||||
|
#define _BV(n) (1<<(n))
|
||||||
|
#define TEST(n,b) (!!((n)&_BV(b)))
|
||||||
|
#define SET_BIT_TO(N,B,TF) do{ if (TF) SBI(N,B); else CBI(N,B); }while(0)
|
||||||
|
|
||||||
|
#ifndef SBI
|
||||||
|
#define SBI(A,B) (A |= (1 << (B)))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CBI
|
||||||
|
#define CBI(A,B) (A &= ~(1 << (B)))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TBI(N,B) (N ^= _BV(B))
|
||||||
|
|
||||||
|
|
||||||
|
// Macros to chain up to 12 conditions
|
||||||
|
#define _DO_1(W,C,A) (_##W##_1(A))
|
||||||
|
#define _DO_2(W,C,A,B) (_##W##_1(A) C _##W##_1(B))
|
||||||
|
#define _DO_3(W,C,A,V...) (_##W##_1(A) C _DO_2(W,C,V))
|
||||||
|
#define _DO_4(W,C,A,V...) (_##W##_1(A) C _DO_3(W,C,V))
|
||||||
|
#define _DO_5(W,C,A,V...) (_##W##_1(A) C _DO_4(W,C,V))
|
||||||
|
#define _DO_6(W,C,A,V...) (_##W##_1(A) C _DO_5(W,C,V))
|
||||||
|
#define _DO_7(W,C,A,V...) (_##W##_1(A) C _DO_6(W,C,V))
|
||||||
|
#define _DO_8(W,C,A,V...) (_##W##_1(A) C _DO_7(W,C,V))
|
||||||
|
#define _DO_9(W,C,A,V...) (_##W##_1(A) C _DO_8(W,C,V))
|
||||||
|
#define _DO_10(W,C,A,V...) (_##W##_1(A) C _DO_9(W,C,V))
|
||||||
|
#define _DO_11(W,C,A,V...) (_##W##_1(A) C _DO_10(W,C,V))
|
||||||
|
#define _DO_12(W,C,A,V...) (_##W##_1(A) C _DO_11(W,C,V))
|
||||||
|
#define __DO_N(W,C,N,V...) _DO_##N(W,C,V)
|
||||||
|
#define _DO_N(W,C,N,V...) __DO_N(W,C,N,V)
|
||||||
|
#define DO(W,C,V...) _DO_N(W,C,NUM_ARGS(V),V)
|
||||||
|
|
||||||
|
// Macros to support option testing
|
||||||
|
#define _CAT(a,V...) a##V
|
||||||
|
#define CAT(a,V...) _CAT(a,V)
|
||||||
|
|
||||||
|
#define _ISENA_ ~,1
|
||||||
|
#define _ISENA_1 ~,1
|
||||||
|
#define _ISENA_0x1 ~,1
|
||||||
|
#define _ISENA_true ~,1
|
||||||
|
#define _ISENA(V...) IS_PROBE(V)
|
||||||
|
|
||||||
|
#define _ENA_1(O) _ISENA(CAT(_IS,CAT(ENA_, O)))
|
||||||
|
#define _DIS_1(O) NOT(_ENA_1(O))
|
||||||
|
#define ENABLED(V...) DO(ENA,&&,V)
|
||||||
|
#define DISABLED(V...) DO(DIS,&&,V)
|
||||||
|
|
||||||
|
#define TERN(O,A,B) _TERN(_ENA_1(O),B,A) // OPTION converted to '0' or '1'
|
||||||
|
#define TERN0(O,A) _TERN(_ENA_1(O),0,A) // OPTION converted to A or '0'
|
||||||
|
#define TERN1(O,A) _TERN(_ENA_1(O),1,A) // OPTION converted to A or '1'
|
||||||
|
#define TERN_(O,A) _TERN(_ENA_1(O),,A) // OPTION converted to A or '<nul>'
|
||||||
|
#define _TERN(E,V...) __TERN(_CAT(T_,E),V) // Prepend 'T_' to get 'T_0' or 'T_1'
|
||||||
|
#define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1'
|
||||||
|
#define ___TERN(P,V...) THIRD(P,V) // If first argument has a comma, A. Else B.
|
||||||
|
|
||||||
|
|
||||||
|
// Use NUM_ARGS(__VA_ARGS__) to get the number of variadic arguments
|
||||||
|
#define _NUM_ARGS(_,Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C,B,A,OUT,...) OUT
|
||||||
|
#define NUM_ARGS(V...) _NUM_ARGS(0,V,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
|
||||||
|
|
||||||
|
//
|
||||||
|
// Primitives supporting precompiler REPEAT
|
||||||
|
//
|
||||||
|
#define FIRST(a,...) a
|
||||||
|
#define SECOND(a,b,...) b
|
||||||
|
#define THIRD(a,b,c,...) c
|
||||||
|
|
||||||
|
#define IS_PROBE(V...) SECOND(V, 0) // Get the second item passed, or 0
|
||||||
|
#define NOT(x) IS_PROBE(_CAT(_NOT_, x)) // NOT('0') gets '1'. Anything else gets '0'.
|
||||||
|
|
||||||
|
#endif //MACROS_H
|
@ -13,8 +13,9 @@
|
|||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "printers.h"
|
#include "printers.h"
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
#include "io_atmega2560.h"
|
|
||||||
#include "AutoDeplete.h"
|
#include "AutoDeplete.h"
|
||||||
|
#include "fastio.h"
|
||||||
|
#include "pins.h"
|
||||||
//-//
|
//-//
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
@ -28,9 +29,6 @@
|
|||||||
#define MMU_P0_TIMEOUT 3000ul //timeout for P0 command: 3seconds
|
#define MMU_P0_TIMEOUT 3000ul //timeout for P0 command: 3seconds
|
||||||
#define MMU_MAX_RESEND_ATTEMPTS 2
|
#define MMU_MAX_RESEND_ATTEMPTS 2
|
||||||
|
|
||||||
#ifdef MMU_HWRESET
|
|
||||||
#define MMU_RST_PIN 76
|
|
||||||
#endif //MMU_HWRESET
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -156,8 +154,8 @@ void mmu_init(void)
|
|||||||
_delay_ms(10); //wait 10ms for sure
|
_delay_ms(10); //wait 10ms for sure
|
||||||
mmu_reset(); //reset mmu (HW or SW), do not wait for response
|
mmu_reset(); //reset mmu (HW or SW), do not wait for response
|
||||||
mmu_state = S::Init;
|
mmu_state = S::Init;
|
||||||
PIN_INP(IR_SENSOR_PIN); //input mode
|
SET_INPUT(IR_SENSOR_PIN); //input mode
|
||||||
PIN_SET(IR_SENSOR_PIN); //pullup
|
WRITE(IR_SENSOR_PIN, 1); //pullup
|
||||||
}
|
}
|
||||||
|
|
||||||
//if IR_SENSOR defined, always returns true
|
//if IR_SENSOR defined, always returns true
|
||||||
@ -170,7 +168,7 @@ bool check_for_ir_sensor()
|
|||||||
|
|
||||||
bool detected = false;
|
bool detected = false;
|
||||||
//if IR_SENSOR_PIN input is low and pat9125sensor is not present we detected idler sensor
|
//if IR_SENSOR_PIN input is low and pat9125sensor is not present we detected idler sensor
|
||||||
if ((PIN_GET(IR_SENSOR_PIN) == 0)
|
if ((READ(IR_SENSOR_PIN) == 0)
|
||||||
#ifdef PAT9125
|
#ifdef PAT9125
|
||||||
&& fsensor_not_responding
|
&& fsensor_not_responding
|
||||||
#endif //PAT9125
|
#endif //PAT9125
|
||||||
@ -363,7 +361,7 @@ void mmu_loop(void)
|
|||||||
case S::GetFinda: //response to command P0
|
case S::GetFinda: //response to command P0
|
||||||
if (mmu_idl_sens)
|
if (mmu_idl_sens)
|
||||||
{
|
{
|
||||||
if (PIN_GET(IR_SENSOR_PIN) == 0 && mmu_loading_flag)
|
if (READ(IR_SENSOR_PIN) == 0 && mmu_loading_flag)
|
||||||
{
|
{
|
||||||
#ifdef MMU_DEBUG
|
#ifdef MMU_DEBUG
|
||||||
printf_P(PSTR("MMU <= 'A'\n"));
|
printf_P(PSTR("MMU <= 'A'\n"));
|
||||||
@ -406,7 +404,7 @@ void mmu_loop(void)
|
|||||||
case S::WaitCmd: //response to mmu commands
|
case S::WaitCmd: //response to mmu commands
|
||||||
if (mmu_idl_sens)
|
if (mmu_idl_sens)
|
||||||
{
|
{
|
||||||
if (PIN_GET(IR_SENSOR_PIN) == 0 && mmu_loading_flag)
|
if (READ(IR_SENSOR_PIN) == 0 && mmu_loading_flag)
|
||||||
{
|
{
|
||||||
DEBUG_PRINTF_P(PSTR("MMU <= 'A'\n"));
|
DEBUG_PRINTF_P(PSTR("MMU <= 'A'\n"));
|
||||||
mmu_puts_P(PSTR("A\n")); //send 'abort' request
|
mmu_puts_P(PSTR("A\n")); //send 'abort' request
|
||||||
@ -596,10 +594,10 @@ bool mmu_get_response(uint8_t move)
|
|||||||
mmu_loading_flag = true;
|
mmu_loading_flag = true;
|
||||||
if (can_extrude()) mmu_load_step();
|
if (can_extrude()) mmu_load_step();
|
||||||
//don't rely on "ok" signal from mmu unit; if filament detected by idler sensor during loading stop loading movements to prevent infinite loading
|
//don't rely on "ok" signal from mmu unit; if filament detected by idler sensor during loading stop loading movements to prevent infinite loading
|
||||||
if (PIN_GET(IR_SENSOR_PIN) == 0) move = MMU_NO_MOVE;
|
if (READ(IR_SENSOR_PIN) == 0) move = MMU_NO_MOVE;
|
||||||
break;
|
break;
|
||||||
case MMU_UNLOAD_MOVE:
|
case MMU_UNLOAD_MOVE:
|
||||||
if (PIN_GET(IR_SENSOR_PIN) == 0) //filament is still detected by idler sensor, printer helps with unlading
|
if (READ(IR_SENSOR_PIN) == 0) //filament is still detected by idler sensor, printer helps with unlading
|
||||||
{
|
{
|
||||||
if (can_extrude())
|
if (can_extrude())
|
||||||
{
|
{
|
||||||
@ -617,7 +615,7 @@ bool mmu_get_response(uint8_t move)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MMU_TCODE_MOVE: //first do unload and then continue with infinite loading movements
|
case MMU_TCODE_MOVE: //first do unload and then continue with infinite loading movements
|
||||||
if (PIN_GET(IR_SENSOR_PIN) == 0) //filament detected by idler sensor, we must unload first
|
if (READ(IR_SENSOR_PIN) == 0) //filament detected by idler sensor, we must unload first
|
||||||
{
|
{
|
||||||
if (can_extrude())
|
if (can_extrude())
|
||||||
{
|
{
|
||||||
@ -1460,7 +1458,7 @@ static bool can_load()
|
|||||||
current_position[E_AXIS] -= e_increment;
|
current_position[E_AXIS] -= e_increment;
|
||||||
plan_buffer_line_curposXYZE(MMU_LOAD_FEEDRATE);
|
plan_buffer_line_curposXYZE(MMU_LOAD_FEEDRATE);
|
||||||
st_synchronize();
|
st_synchronize();
|
||||||
if(0 == PIN_GET(IR_SENSOR_PIN))
|
if(0 == READ(IR_SENSOR_PIN))
|
||||||
{
|
{
|
||||||
++filament_detected_count;
|
++filament_detected_count;
|
||||||
DEBUG_PUTCHAR('O');
|
DEBUG_PUTCHAR('O');
|
||||||
@ -1491,7 +1489,7 @@ static bool load_more()
|
|||||||
{
|
{
|
||||||
for (uint8_t i = 0; i < MMU_IDLER_SENSOR_ATTEMPTS_NR; i++)
|
for (uint8_t i = 0; i < MMU_IDLER_SENSOR_ATTEMPTS_NR; i++)
|
||||||
{
|
{
|
||||||
if (PIN_GET(IR_SENSOR_PIN) == 0) return true;
|
if (READ(IR_SENSOR_PIN) == 0) return true;
|
||||||
DEBUG_PRINTF_P(PSTR("Additional load attempt nr. %d\n"), i);
|
DEBUG_PRINTF_P(PSTR("Additional load attempt nr. %d\n"), i);
|
||||||
mmu_command(MmuCmd::C0);
|
mmu_command(MmuCmd::C0);
|
||||||
manage_response(true, true, MMU_LOAD_MOVE);
|
manage_response(true, true, MMU_LOAD_MOVE);
|
||||||
|
@ -121,6 +121,8 @@
|
|||||||
|
|
||||||
#define IR_SENSOR_PIN 62 //idler sensor @PK0 (digital pin 62/A8)
|
#define IR_SENSOR_PIN 62 //idler sensor @PK0 (digital pin 62/A8)
|
||||||
|
|
||||||
|
#define MMU_RST_PIN 76
|
||||||
|
|
||||||
// Support for an 8 bit logic analyzer, for example the Saleae.
|
// Support for an 8 bit logic analyzer, for example the Saleae.
|
||||||
// Channels 0-2 are fast, they could generate 2.667Mhz waveform with a software loop.
|
// Channels 0-2 are fast, they could generate 2.667Mhz waveform with a software loop.
|
||||||
#define LOGIC_ANALYZER_CH0 X_MIN_PIN // PB6
|
#define LOGIC_ANALYZER_CH0 X_MIN_PIN // PB6
|
||||||
|
@ -3,9 +3,10 @@
|
|||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
|
#include "stdbool.h"
|
||||||
#include "Configuration_prusa.h"
|
#include "Configuration_prusa.h"
|
||||||
#include "pins.h"
|
#include "pins.h"
|
||||||
#include "io_atmega2560.h"
|
#include "fastio.h"
|
||||||
|
|
||||||
|
|
||||||
#define SWI2C_RMSK 0x01 //read mask (bit0 = 1)
|
#define SWI2C_RMSK 0x01 //read mask (bit0 = 1)
|
||||||
@ -21,75 +22,75 @@ void __delay(void)
|
|||||||
|
|
||||||
void swi2c_init(void)
|
void swi2c_init(void)
|
||||||
{
|
{
|
||||||
PIN_OUT(SWI2C_SDA);
|
WRITE(SWI2C_SDA, 1);
|
||||||
PIN_OUT(SWI2C_SCL);
|
WRITE(SWI2C_SCL, 1);
|
||||||
PIN_SET(SWI2C_SDA);
|
SET_OUTPUT(SWI2C_SDA);
|
||||||
PIN_SET(SWI2C_SCL);
|
SET_OUTPUT(SWI2C_SCL);
|
||||||
uint8_t i; for (i = 0; i < 100; i++)
|
uint8_t i; for (i = 0; i < 100; i++)
|
||||||
__delay();
|
__delay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void swi2c_start(void)
|
void swi2c_start(void)
|
||||||
{
|
{
|
||||||
PIN_CLR(SWI2C_SDA);
|
WRITE(SWI2C_SDA, 0);
|
||||||
__delay();
|
__delay();
|
||||||
PIN_CLR(SWI2C_SCL);
|
WRITE(SWI2C_SCL, 0);
|
||||||
__delay();
|
__delay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void swi2c_stop(void)
|
void swi2c_stop(void)
|
||||||
{
|
{
|
||||||
PIN_SET(SWI2C_SCL);
|
WRITE(SWI2C_SCL, 1);
|
||||||
__delay();
|
__delay();
|
||||||
PIN_SET(SWI2C_SDA);
|
WRITE(SWI2C_SDA, 1);
|
||||||
__delay();
|
__delay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void swi2c_ack(void)
|
void swi2c_ack(void)
|
||||||
{
|
{
|
||||||
PIN_CLR(SWI2C_SDA);
|
WRITE(SWI2C_SDA, 0);
|
||||||
__delay();
|
__delay();
|
||||||
PIN_SET(SWI2C_SCL);
|
WRITE(SWI2C_SCL, 1);
|
||||||
__delay();
|
__delay();
|
||||||
PIN_CLR(SWI2C_SCL);
|
WRITE(SWI2C_SCL, 0);
|
||||||
__delay();
|
__delay();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t swi2c_wait_ack()
|
uint8_t swi2c_wait_ack()
|
||||||
{
|
{
|
||||||
PIN_INP(SWI2C_SDA);
|
SET_INPUT(SWI2C_SDA);
|
||||||
__delay();
|
__delay();
|
||||||
// PIN_SET(SWI2C_SDA);
|
// WRITE(SWI2C_SDA, 1);
|
||||||
__delay();
|
__delay();
|
||||||
PIN_SET(SWI2C_SCL);
|
WRITE(SWI2C_SCL, 1);
|
||||||
// __delay();
|
// __delay();
|
||||||
uint8_t ack = 0;
|
uint8_t ack = 0;
|
||||||
uint16_t ackto = SWI2C_TMO;
|
uint16_t ackto = SWI2C_TMO;
|
||||||
while (!(ack = (PIN_GET(SWI2C_SDA)?0:1)) && ackto--) __delay();
|
while (!(ack = (!READ(SWI2C_SDA))) && ackto--) __delay();
|
||||||
PIN_CLR(SWI2C_SCL);
|
WRITE(SWI2C_SCL, 0);
|
||||||
__delay();
|
__delay();
|
||||||
PIN_OUT(SWI2C_SDA);
|
SET_OUTPUT(SWI2C_SDA);
|
||||||
__delay();
|
__delay();
|
||||||
PIN_CLR(SWI2C_SDA);
|
WRITE(SWI2C_SDA, 0);
|
||||||
__delay();
|
__delay();
|
||||||
return ack;
|
return ack;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t swi2c_read(void)
|
uint8_t swi2c_read(void)
|
||||||
{
|
{
|
||||||
PIN_SET(SWI2C_SDA);
|
WRITE(SWI2C_SDA, 1);
|
||||||
__delay();
|
__delay();
|
||||||
PIN_INP(SWI2C_SDA);
|
SET_INPUT(SWI2C_SDA);
|
||||||
uint8_t data = 0;
|
uint8_t data = 0;
|
||||||
int8_t bit; for (bit = 7; bit >= 0; bit--)
|
int8_t bit; for (bit = 7; bit >= 0; bit--)
|
||||||
{
|
{
|
||||||
PIN_SET(SWI2C_SCL);
|
WRITE(SWI2C_SCL, 1);
|
||||||
__delay();
|
__delay();
|
||||||
data |= (PIN_GET(SWI2C_SDA)?1:0) << bit;
|
data |= (READ(SWI2C_SDA)) << bit;
|
||||||
PIN_CLR(SWI2C_SCL);
|
WRITE(SWI2C_SCL, 0);
|
||||||
__delay();
|
__delay();
|
||||||
}
|
}
|
||||||
PIN_OUT(SWI2C_SDA);
|
SET_OUTPUT(SWI2C_SDA);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,12 +98,11 @@ void swi2c_write(uint8_t data)
|
|||||||
{
|
{
|
||||||
int8_t bit; for (bit = 7; bit >= 0; bit--)
|
int8_t bit; for (bit = 7; bit >= 0; bit--)
|
||||||
{
|
{
|
||||||
if (data & (1 << bit)) PIN_SET(SWI2C_SDA);
|
WRITE(SWI2C_SDA, data & _BV(bit));
|
||||||
else PIN_CLR(SWI2C_SDA);
|
|
||||||
__delay();
|
__delay();
|
||||||
PIN_SET(SWI2C_SCL);
|
WRITE(SWI2C_SCL, 1);
|
||||||
__delay();
|
__delay();
|
||||||
PIN_CLR(SWI2C_SCL);
|
WRITE(SWI2C_SCL, 0);
|
||||||
__delay();
|
__delay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,6 @@
|
|||||||
|
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include "io_atmega2560.h"
|
|
||||||
|
|
||||||
#define BEEPER 84
|
|
||||||
|
|
||||||
void timer0_init(void)
|
void timer0_init(void)
|
||||||
{
|
{
|
||||||
|
@ -10,14 +10,8 @@
|
|||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include "pins.h"
|
#include "pins.h"
|
||||||
|
|
||||||
#ifndef CRITICAL_SECTION_START
|
|
||||||
#define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli();
|
|
||||||
#define CRITICAL_SECTION_END SREG = _sreg;
|
|
||||||
#endif //CRITICAL_SECTION_START
|
|
||||||
|
|
||||||
|
|
||||||
#include "fastio.h"
|
#include "fastio.h"
|
||||||
|
#include "macros.h"
|
||||||
|
|
||||||
void timer4_init(void)
|
void timer4_init(void)
|
||||||
{
|
{
|
||||||
@ -79,7 +73,7 @@ ISR(TIMER4_OVF_vect)
|
|||||||
WRITE(BEEPER, 0);
|
WRITE(BEEPER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tone4(__attribute__((unused)) uint8_t _pin, uint16_t frequency)
|
void tone4(_UNUSED uint8_t _pin, uint16_t frequency)
|
||||||
{
|
{
|
||||||
//this ocr and prescalarbits calculation is taken from the Arduino core and simplified for one type of timer only
|
//this ocr and prescalarbits calculation is taken from the Arduino core and simplified for one type of timer only
|
||||||
uint8_t prescalarbits = 0b001;
|
uint8_t prescalarbits = 0b001;
|
||||||
@ -105,7 +99,7 @@ void tone4(__attribute__((unused)) uint8_t _pin, uint16_t frequency)
|
|||||||
CRITICAL_SECTION_END;
|
CRITICAL_SECTION_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
void noTone4(__attribute__((unused)) uint8_t _pin)
|
void noTone4(_UNUSED uint8_t _pin)
|
||||||
{
|
{
|
||||||
CRITICAL_SECTION_START;
|
CRITICAL_SECTION_START;
|
||||||
// Revert prescaler to CLK/1024
|
// Revert prescaler to CLK/1024
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
#include "rbuf.h"
|
#include "rbuf.h"
|
||||||
|
#include "macros.h"
|
||||||
|
|
||||||
#define UART2_BAUD 115200
|
#define UART2_BAUD 115200
|
||||||
#define UART_BAUD_SELECT(baudRate,xtalCpu) (((float)(xtalCpu))/(((float)(baudRate))*8.0)-1.0+0.5)
|
#define UART_BAUD_SELECT(baudRate,xtalCpu) (((float)(xtalCpu))/(((float)(baudRate))*8.0)-1.0+0.5)
|
||||||
@ -16,7 +17,7 @@ uint8_t uart2_ibuf[14] = {0, 0};
|
|||||||
FILE _uart2io = {0};
|
FILE _uart2io = {0};
|
||||||
|
|
||||||
|
|
||||||
int uart2_putchar(char c, FILE *stream __attribute__((unused)))
|
int uart2_putchar(char c, _UNUSED FILE *stream)
|
||||||
{
|
{
|
||||||
while (!uart2_txready);
|
while (!uart2_txready);
|
||||||
UDR2 = c; // transmit byte
|
UDR2 = c; // transmit byte
|
||||||
@ -25,7 +26,7 @@ int uart2_putchar(char c, FILE *stream __attribute__((unused)))
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int uart2_getchar(FILE *stream __attribute__((unused)))
|
int uart2_getchar(_UNUSED FILE *stream)
|
||||||
{
|
{
|
||||||
if (rbuf_empty(uart2_ibuf)) return -1;
|
if (rbuf_empty(uart2_ibuf)) return -1;
|
||||||
return rbuf_get(uart2_ibuf);
|
return rbuf_get(uart2_ibuf);
|
||||||
|
@ -44,7 +44,6 @@
|
|||||||
#include "mmu.h"
|
#include "mmu.h"
|
||||||
|
|
||||||
#include "static_assert.h"
|
#include "static_assert.h"
|
||||||
#include "io_atmega2560.h"
|
|
||||||
#include "first_lay_cal.h"
|
#include "first_lay_cal.h"
|
||||||
|
|
||||||
#include "fsensor.h"
|
#include "fsensor.h"
|
||||||
@ -3999,7 +3998,7 @@ static void lcd_show_sensors_state()
|
|||||||
finda_state = mmu_finda;
|
finda_state = mmu_finda;
|
||||||
}
|
}
|
||||||
if (ir_sensor_detected) {
|
if (ir_sensor_detected) {
|
||||||
idler_state = !PIN_GET(IR_SENSOR_PIN);
|
idler_state = !READ(IR_SENSOR_PIN);
|
||||||
}
|
}
|
||||||
lcd_puts_at_P(0, 0, _i("Sensor state"));
|
lcd_puts_at_P(0, 0, _i("Sensor state"));
|
||||||
lcd_puts_at_P(1, 1, _i("PINDA:"));
|
lcd_puts_at_P(1, 1, _i("PINDA:"));
|
||||||
@ -8474,7 +8473,7 @@ static bool selftest_irsensor()
|
|||||||
mmu_load_step(false);
|
mmu_load_step(false);
|
||||||
while (blocks_queued())
|
while (blocks_queued())
|
||||||
{
|
{
|
||||||
if (PIN_GET(IR_SENSOR_PIN) == 0)
|
if (READ(IR_SENSOR_PIN) == 0)
|
||||||
{
|
{
|
||||||
lcd_selftest_error(TestError::TriggeringFsensor, "", "");
|
lcd_selftest_error(TestError::TriggeringFsensor, "", "");
|
||||||
return false;
|
return false;
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
#include "w25x20cl.h"
|
#include "w25x20cl.h"
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
#include "io_atmega2560.h"
|
|
||||||
#include "spi.h"
|
#include "spi.h"
|
||||||
|
#include "fastio.h"
|
||||||
|
|
||||||
#define _MFRID 0xEF
|
#define _MFRID 0xEF
|
||||||
#define _DEVID 0x11
|
#define _DEVID 0x11
|
||||||
@ -31,8 +31,8 @@
|
|||||||
#define _CMD_JEDEC_ID 0x9f
|
#define _CMD_JEDEC_ID 0x9f
|
||||||
#define _CMD_RD_UID 0x4b
|
#define _CMD_RD_UID 0x4b
|
||||||
|
|
||||||
#define _CS_LOW() PORT(W25X20CL_PIN_CS) &= ~__MSK(W25X20CL_PIN_CS)
|
#define _CS_LOW() WRITE(W25X20CL_PIN_CS, 0)
|
||||||
#define _CS_HIGH() PORT(W25X20CL_PIN_CS) |= __MSK(W25X20CL_PIN_CS)
|
#define _CS_HIGH() WRITE(W25X20CL_PIN_CS, 1)
|
||||||
|
|
||||||
//#define _SPI_TX swspi_tx
|
//#define _SPI_TX swspi_tx
|
||||||
//#define _SPI_RX swspi_rx
|
//#define _SPI_RX swspi_rx
|
||||||
@ -45,8 +45,8 @@ int w25x20cl_mfrid_devid(void);
|
|||||||
|
|
||||||
int8_t w25x20cl_init(void)
|
int8_t w25x20cl_init(void)
|
||||||
{
|
{
|
||||||
PIN_OUT(W25X20CL_PIN_CS);
|
|
||||||
_CS_HIGH();
|
_CS_HIGH();
|
||||||
|
SET_OUTPUT(W25X20CL_PIN_CS);
|
||||||
W25X20CL_SPI_ENTER();
|
W25X20CL_SPI_ENTER();
|
||||||
if (!w25x20cl_mfrid_devid()) return 0;
|
if (!w25x20cl_mfrid_devid()) return 0;
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user