|
|
@ -882,8 +882,8 @@ void tp_init() |
|
|
|
{ |
|
|
|
#if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1)) |
|
|
|
//disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector
|
|
|
|
MCUCR=(1<<JTD); |
|
|
|
MCUCR=(1<<JTD); |
|
|
|
MCUCR=BIT(JTD); |
|
|
|
MCUCR=BIT(JTD); |
|
|
|
#endif |
|
|
|
|
|
|
|
// Finish init of mult extruder arrays
|
|
|
@ -941,13 +941,13 @@ void tp_init() |
|
|
|
#endif //HEATER_0_USES_MAX6675
|
|
|
|
|
|
|
|
#ifdef DIDR2 |
|
|
|
#define ANALOG_SELECT(pin) do{ if (pin < 8) DIDR0 |= 1 << pin; else DIDR2 |= 1 << (pin - 8); }while(0) |
|
|
|
#define ANALOG_SELECT(pin) do{ if (pin < 8) DIDR0 |= BIT(pin); else DIDR2 |= BIT(pin - 8); }while(0) |
|
|
|
#else |
|
|
|
#define ANALOG_SELECT(pin) do{ DIDR0 |= 1 << pin; }while(0) |
|
|
|
#define ANALOG_SELECT(pin) do{ DIDR0 |= BIT(pin); }while(0) |
|
|
|
#endif |
|
|
|
|
|
|
|
// Set analog inputs
|
|
|
|
ADCSRA = 1<<ADEN | 1<<ADSC | 1<<ADIF | 0x07; |
|
|
|
ADCSRA = BIT(ADEN) | BIT(ADSC) | BIT(ADIF) | 0x07; |
|
|
|
DIDR0 = 0; |
|
|
|
#ifdef DIDR2 |
|
|
|
DIDR2 = 0; |
|
|
@ -974,7 +974,7 @@ void tp_init() |
|
|
|
// Use timer0 for temperature measurement
|
|
|
|
// Interleave temperature interrupt with millies interrupt
|
|
|
|
OCR0B = 128; |
|
|
|
TIMSK0 |= (1<<OCIE0B); |
|
|
|
TIMSK0 |= BIT(OCIE0B); |
|
|
|
|
|
|
|
// Wait for temperature measurement to settle
|
|
|
|
delay(250); |
|
|
@ -1178,12 +1178,12 @@ void disable_heater() { |
|
|
|
max6675_temp = 0; |
|
|
|
|
|
|
|
#ifdef PRR |
|
|
|
PRR &= ~(1<<PRSPI); |
|
|
|
PRR &= ~BIT(PRSPI); |
|
|
|
#elif defined(PRR0) |
|
|
|
PRR0 &= ~(1<<PRSPI); |
|
|
|
PRR0 &= ~BIT(PRSPI); |
|
|
|
#endif |
|
|
|
|
|
|
|
SPCR = (1<<MSTR) | (1<<SPE) | (1<<SPR0); |
|
|
|
SPCR = BIT(MSTR) | BIT(SPE) | BIT(SPR0); |
|
|
|
|
|
|
|
// enable TT_MAX6675
|
|
|
|
WRITE(MAX6675_SS, 0); |
|
|
@ -1194,13 +1194,13 @@ void disable_heater() { |
|
|
|
|
|
|
|
// read MSB
|
|
|
|
SPDR = 0; |
|
|
|
for (;(SPSR & (1<<SPIF)) == 0;); |
|
|
|
for (;(SPSR & BIT(SPIF)) == 0;); |
|
|
|
max6675_temp = SPDR; |
|
|
|
max6675_temp <<= 8; |
|
|
|
|
|
|
|
// read LSB
|
|
|
|
SPDR = 0; |
|
|
|
for (;(SPSR & (1<<SPIF)) == 0;); |
|
|
|
for (;(SPSR & BIT(SPIF)) == 0;); |
|
|
|
max6675_temp |= SPDR; |
|
|
|
|
|
|
|
// disable TT_MAX6675
|
|
|
@ -1250,7 +1250,7 @@ ISR(TIMER0_COMPB_vect) { |
|
|
|
static unsigned long raw_temp_3_value = 0; |
|
|
|
static unsigned long raw_temp_bed_value = 0; |
|
|
|
static TempState temp_state = StartupDelay; |
|
|
|
static unsigned char pwm_count = (1 << SOFT_PWM_SCALE); |
|
|
|
static unsigned char pwm_count = BIT(SOFT_PWM_SCALE); |
|
|
|
|
|
|
|
// Static members for each heater
|
|
|
|
#ifdef SLOW_PWM_HEATERS |
|
|
@ -1335,7 +1335,7 @@ ISR(TIMER0_COMPB_vect) { |
|
|
|
if (soft_pwm_fan < pwm_count) WRITE_FAN(0); |
|
|
|
#endif |
|
|
|
|
|
|
|
pwm_count += (1 << SOFT_PWM_SCALE); |
|
|
|
pwm_count += BIT(SOFT_PWM_SCALE); |
|
|
|
pwm_count &= 0x7f; |
|
|
|
|
|
|
|
#else // SLOW_PWM_HEATERS
|
|
|
@ -1416,7 +1416,7 @@ ISR(TIMER0_COMPB_vect) { |
|
|
|
if (soft_pwm_fan < pwm_count) WRITE_FAN(0); |
|
|
|
#endif //FAN_SOFT_PWM
|
|
|
|
|
|
|
|
pwm_count += (1 << SOFT_PWM_SCALE); |
|
|
|
pwm_count += BIT(SOFT_PWM_SCALE); |
|
|
|
pwm_count &= 0x7f; |
|
|
|
|
|
|
|
// increment slow_pwm_count only every 64 pwm_count circa 65.5ms
|
|
|
@ -1442,9 +1442,9 @@ ISR(TIMER0_COMPB_vect) { |
|
|
|
|
|
|
|
#endif // SLOW_PWM_HEATERS
|
|
|
|
|
|
|
|
#define SET_ADMUX_ADCSRA(pin) ADMUX = (1 << REFS0) | (pin & 0x07); ADCSRA |= 1<<ADSC |
|
|
|
#define SET_ADMUX_ADCSRA(pin) ADMUX = BIT(REFS0) | (pin & 0x07); ADCSRA |= BIT(ADSC) |
|
|
|
#ifdef MUX5 |
|
|
|
#define START_ADC(pin) if (pin > 7) ADCSRB = 1 << MUX5; else ADCSRB = 0; SET_ADMUX_ADCSRA(pin) |
|
|
|
#define START_ADC(pin) if (pin > 7) ADCSRB = BIT(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(pin) |
|
|
|
#else |
|
|
|
#define START_ADC(pin) ADCSRB = 0; SET_ADMUX_ADCSRA(pin) |
|
|
|
#endif |
|
|
|