Enforce Unix line endings (LF).

This should convert all files checked into the repository to
LF line endings, with exception of pictures and PDFs. Trying
to commit CRLF text on Unix will issue a warning when doing
"git add" or "git commit -a".

Users prefering CRLF (Windows) can set their local copy of the
repository to convert files on the fly at checkout with

  git config --local core.autocrlf = true

Note: Git acts pretty stubborn on files which don't match the
.gitattributes rules, but are already committed. This can
happen after every change to .gitattributes. Git doesn't want
to keep these files as-is in the repository and insists on
conversion as soon as they're touched somehow. The only way to
deal with this is to either edit .gitattributes again (in case
these enforced conversions don't match the intention) or to
commit the enforced changes immediately.

To put a bit more oil into the fire, Git doesn't recognize all
misalignments immediately, but trusts its cache. Accordingly
it's a good idea to clear this cache after any change to
.gitattributes:

  rm .git/index

Having this done, all further proceedings will show all
misaligments immerdiately.

For further instructions and descriptions see
http://schacon.github.io/git/gitattributes.html
http://adaptivepatchwork.com/2012/03/01/mind-the-end-of-your-line/
http://git.661346.n2.nabble.com/possible-gitattributes-eol-bug-with-new-eol-crlf-lf-support-td5516458.html
https://help.github.com/articles/dealing-with-line-endings/#refreshing-a-repository-after-changing-line-endings
This commit is contained in:
Markus Hitter 2015-02-02 01:09:16 +01:00
parent 4c34674b6e
commit 86f1fc418f
3 changed files with 340 additions and 327 deletions

13
.gitattributes vendored Normal file
View File

@ -0,0 +1,13 @@
* text
*.gcode -text
*.gz -text
*.zip -text
*.png -text
*.jpg -text
*.jpeg -text
*.pdf -text

View File

@ -1,95 +1,95 @@
/* Notice to developers: this file is intentionally included twice. */ /* Notice to developers: this file is intentionally included twice. */
/* /*
CPU clock rate CPU clock rate
*/ */
#ifndef F_CPU #ifndef F_CPU
#define F_CPU 16000000L #define F_CPU 16000000L
#endif #endif
/* /*
other fallbacks for the Arduino IDE other fallbacks for the Arduino IDE
*/ */
#define EXTRUDER #define EXTRUDER
#define GEN3 #define GEN3
#include "arduino.h" #include "arduino.h"
// controller index- bus is multidrop after all // controller index- bus is multidrop after all
#define THIS_CONTROLLER_NUM 0 #define THIS_CONTROLLER_NUM 0
//RS485 Interface pins //RS485 Interface pins
#define RX_ENABLE_PIN DIO4 #define RX_ENABLE_PIN DIO4
#define TX_ENABLE_PIN AIO2 #define TX_ENABLE_PIN AIO2
// Control pins for the A3949 chips // Control pins for the A3949 chips
#define H1D DIO7 #define H1D DIO7
#define H1E DIO5 #define H1E DIO5
#define H2D DIO8 #define H2D DIO8
#define H2E DIO6 #define H2E DIO6
// PWM versions of the enable_pins // PWM versions of the enable_pins
#define H1E_PWM OCR0B #define H1E_PWM OCR0B
#define H2E_PWM OCR0A #define H2E_PWM OCR0A
//Step/Dir Pins from motherboard to extruder //Step/Dir Pins from motherboard to extruder
//IMPORTANT: Assumes that the step pin is on PCIE0 //IMPORTANT: Assumes that the step pin is on PCIE0
#define E_STEP_PIN DIO10 #define E_STEP_PIN DIO10
#define E_DIR_PIN DIO9 #define E_DIR_PIN DIO9
//Trimpot is on AIO0, pin 23 //Trimpot is on AIO0, pin 23
#define TRIM_POT AIO0 #define TRIM_POT AIO0
#define TRIM_POT_CHANNEL 0 #define TRIM_POT_CHANNEL 0
//Read analog voltage from thermistor //Read analog voltage from thermistor
#define TEMP_PIN AIO3 #define TEMP_PIN AIO3
#define TEMP_PIN_CHANNEL 3 #define TEMP_PIN_CHANNEL 3
//Read analog voltage from thermistor //Read analog voltage from thermistor
#define TEMP_BED_PIN AIO6 #define TEMP_BED_PIN AIO6
#define TEMP_BED_PIN_CHANNEL 6 #define TEMP_BED_PIN_CHANNEL 6
#define REFERENCE REFERENCE_AVCC #define REFERENCE REFERENCE_AVCC
#define TEMP_THERMISTOR #define TEMP_THERMISTOR
#define HEATER_PIN DIO11 #define HEATER_PIN DIO11
#define BED_PIN AIO1 #define BED_PIN AIO1
#define FAN_PIN DIO12 #define FAN_PIN DIO12
// extruder settings // extruder settings
#define TEMP_HYSTERESIS 5 #define TEMP_HYSTERESIS 5
#define TEMP_RESIDENCY_TIME 60 #define TEMP_RESIDENCY_TIME 60
#ifdef DEFINE_TEMP_SENSOR #ifdef DEFINE_TEMP_SENSOR
DEFINE_TEMP_SENSOR(extruder, TT_THERMISTOR, TEMP_PIN_CHANNEL, THERMISTOR_EXTRUDER) DEFINE_TEMP_SENSOR(extruder, TT_THERMISTOR, TEMP_PIN_CHANNEL, THERMISTOR_EXTRUDER)
DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, TEMP_BED_PIN_CHANNEL, THERMISTOR_EXTRUDER) DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, TEMP_BED_PIN_CHANNEL, THERMISTOR_EXTRUDER)
// dummy temp sensor so analog_mask includes trim pot // dummy temp sensor so analog_mask includes trim pot
DEFINE_TEMP_SENSOR(noheater, TT_THERMISTOR, TRIM_POT_CHANNEL, 0) DEFINE_TEMP_SENSOR(noheater, TT_THERMISTOR, TRIM_POT_CHANNEL, 0)
#endif #endif
#ifdef DEFINE_HEATER #ifdef DEFINE_HEATER
DEFINE_HEATER(extruder, DIO11) DEFINE_HEATER(extruder, DIO11)
DEFINE_HEATER(bed, AIO1) DEFINE_HEATER(bed, AIO1)
#endif #endif
// list of PWM-able pins and corresponding timers // list of PWM-able pins and corresponding timers
// timer1 is used for step timing so don't use OC1A/OC1B (DIO9/DIO10) // timer1 is used for step timing so don't use OC1A/OC1B (DIO9/DIO10)
// OC0A DIO6 // OC0A DIO6
// OC0B DIO5 // OC0B DIO5
// OC1A DIO9 // OC1A DIO9
// OC1B DIO10 // OC1B DIO10
// OC2A DIO11 // OC2A DIO11
// OC2B DIO3 // OC2B DIO3
#define TH_COUNT 8 #define TH_COUNT 8
#define PID_SCALE 1024L #define PID_SCALE 1024L
/* /*
Motors Motors
*/ */
#define enable_motors() do { TCCR0A |= MASK(COM0A1) | MASK(COM0B1); } while (0) #define enable_motors() do { TCCR0A |= MASK(COM0A1) | MASK(COM0B1); } while (0)
#define disable_motors() do { TCCR0A &= ~MASK(COM0A1) & ~MASK(COM0B1); } while (0) #define disable_motors() do { TCCR0A &= ~MASK(COM0A1) & ~MASK(COM0B1); } while (0)

View File

@ -1,238 +1,238 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <avr/interrupt.h> #include <avr/interrupt.h>
#include "intercom.h" #include "intercom.h"
#include "analog.h" #include "analog.h"
#include "config_wrapper.h" #include "config_wrapper.h"
#include "watchdog.h" #include "watchdog.h"
#include "heater.h" #include "heater.h"
#include "temp.h" #include "temp.h"
#include "timer.h" #include "timer.h"
static uint8_t motor_pwm; static uint8_t motor_pwm;
void io_init(void) { void io_init(void) {
// setup I/O pins // setup I/O pins
WRITE(DEBUG_LED, 0); SET_OUTPUT(DEBUG_LED); WRITE(DEBUG_LED, 0); SET_OUTPUT(DEBUG_LED);
WRITE(H1D,0); SET_OUTPUT(H1D); WRITE(H1D,0); SET_OUTPUT(H1D);
WRITE(H1E,0); SET_OUTPUT(H1E); WRITE(H1E,0); SET_OUTPUT(H1E);
WRITE(H2D,0); SET_OUTPUT(H2D); WRITE(H2D,0); SET_OUTPUT(H2D);
WRITE(H2E,0); SET_OUTPUT(H2E); WRITE(H2E,0); SET_OUTPUT(H2E);
SET_INPUT(TRIM_POT); SET_INPUT(TRIM_POT);
SET_INPUT(TEMP_PIN); SET_INPUT(TEMP_PIN);
SET_INPUT(TEMP_BED_PIN); SET_INPUT(TEMP_BED_PIN);
SET_INPUT(E_STEP_PIN); SET_INPUT(E_STEP_PIN);
SET_INPUT(E_DIR_PIN); SET_INPUT(E_DIR_PIN);
// use pull up resistors to avoid noise // use pull up resistors to avoid noise
WRITE(E_STEP_PIN, 1); WRITE(E_STEP_PIN, 1);
WRITE(E_DIR_PIN, 1); WRITE(E_DIR_PIN, 1);
//Enable the RS485 transceiver //Enable the RS485 transceiver
SET_OUTPUT(RX_ENABLE_PIN); SET_OUTPUT(RX_ENABLE_PIN);
SET_OUTPUT(TX_ENABLE_PIN); SET_OUTPUT(TX_ENABLE_PIN);
WRITE(RX_ENABLE_PIN,0); WRITE(RX_ENABLE_PIN,0);
disable_transmit(); disable_transmit();
#ifdef HEATER_PIN #ifdef HEATER_PIN
WRITE(HEATER_PIN, 0); SET_OUTPUT(HEATER_PIN); WRITE(HEATER_PIN, 0); SET_OUTPUT(HEATER_PIN);
#endif #endif
#ifdef BED_PIN #ifdef BED_PIN
WRITE(BED_PIN, 0); SET_OUTPUT(BED_PIN); WRITE(BED_PIN, 0); SET_OUTPUT(BED_PIN);
#endif #endif
#ifdef FAN_PIN #ifdef FAN_PIN
WRITE(FAN_PIN, 0); SET_OUTPUT(FAN_PIN); WRITE(FAN_PIN, 0); SET_OUTPUT(FAN_PIN);
#endif #endif
// #if defined(HEATER_PWM) || defined(FAN_PWM) || defined(BED_PWM) // #if defined(HEATER_PWM) || defined(FAN_PWM) || defined(BED_PWM)
// setup PWM timer: fast PWM, no prescaler // setup PWM timer: fast PWM, no prescaler
TCCR2A = MASK(WGM21) | MASK(WGM20); TCCR2A = MASK(WGM21) | MASK(WGM20);
TCCR2B = MASK(CS22); TCCR2B = MASK(CS22);
TIMSK2 = 0; TIMSK2 = 0;
OCR2A = 0; OCR2A = 0;
OCR2B = 0; OCR2B = 0;
// #endif // #endif
#if defined(H1E_PWM) && defined(H2E_PWM) #if defined(H1E_PWM) && defined(H2E_PWM)
TCCR0A = MASK(WGM01) | MASK(WGM00); TCCR0A = MASK(WGM01) | MASK(WGM00);
TCCR0B = MASK(CS20); TCCR0B = MASK(CS20);
TIMSK0 = 0; TIMSK0 = 0;
OCR0A = 0; OCR0A = 0;
OCR0B = 0; OCR0B = 0;
#endif #endif
} }
void motor_init(void) { void motor_init(void) {
//Enable an interrupt to be triggered when the step pin changes //Enable an interrupt to be triggered when the step pin changes
//This will be PCIE0 //This will be PCIE0
PCICR = MASK(PCIE0); PCICR = MASK(PCIE0);
PCMSK0 = MASK(PCINT2); PCMSK0 = MASK(PCINT2);
} }
ISR(PCINT0_vect) { ISR(PCINT0_vect) {
static uint8_t coil_pos, pwm; static uint8_t coil_pos, pwm;
//if the step pin is high, we advance the motor //if the step pin is high, we advance the motor
if (READ(E_STEP_PIN)) { if (READ(E_STEP_PIN)) {
//Turn on motors only on first tick to save power I guess //Turn on motors only on first tick to save power I guess
enable_motors(); enable_motors();
//Advance the coil position //Advance the coil position
if (READ(E_DIR_PIN)) if (READ(E_DIR_PIN))
coil_pos++; coil_pos++;
else else
coil_pos--; coil_pos--;
coil_pos &= 7; coil_pos &= 7;
//Grab the latest motor power to use //Grab the latest motor power to use
pwm = motor_pwm; pwm = motor_pwm;
switch(coil_pos) { switch(coil_pos) {
case 0: case 0:
WRITE(H1D, 0); WRITE(H1D, 0);
WRITE(H2D, 0); WRITE(H2D, 0);
H1E_PWM = 0; H1E_PWM = 0;
H2E_PWM = pwm; H2E_PWM = pwm;
break; break;
case 1: case 1:
WRITE(H1D, 1); WRITE(H1D, 1);
WRITE(H2D, 0); WRITE(H2D, 0);
H1E_PWM = pwm; H1E_PWM = pwm;
H2E_PWM = pwm; H2E_PWM = pwm;
break; break;
case 2: case 2:
WRITE(H1D, 1); WRITE(H1D, 1);
WRITE(H2D, 0); WRITE(H2D, 0);
H1E_PWM = pwm; H1E_PWM = pwm;
H2E_PWM = 0; H2E_PWM = 0;
break; break;
case 3: case 3:
WRITE(H1D, 1); WRITE(H1D, 1);
WRITE(H2D, 1); WRITE(H2D, 1);
H1E_PWM = pwm; H1E_PWM = pwm;
H2E_PWM = pwm; H2E_PWM = pwm;
break; break;
case 4: case 4:
WRITE(H1D, 1); WRITE(H1D, 1);
WRITE(H2D, 1); WRITE(H2D, 1);
H1E_PWM = 0; H1E_PWM = 0;
H2E_PWM = pwm; H2E_PWM = pwm;
break; break;
case 5: case 5:
WRITE(H1D, 0); WRITE(H1D, 0);
WRITE(H2D, 1); WRITE(H2D, 1);
H1E_PWM = pwm; H1E_PWM = pwm;
H2E_PWM = pwm; H2E_PWM = pwm;
break; break;
case 6: case 6:
WRITE(H1D, 0); WRITE(H1D, 0);
WRITE(H2D, 1); WRITE(H2D, 1);
H1E_PWM = pwm; H1E_PWM = pwm;
H2E_PWM = 0; H2E_PWM = 0;
break; break;
case 7: case 7:
WRITE(H1D, 0); WRITE(H1D, 0);
WRITE(H2D, 0); WRITE(H2D, 0);
H1E_PWM = pwm; H1E_PWM = pwm;
H2E_PWM = pwm; H2E_PWM = pwm;
break; break;
} }
} }
} }
void init(void) { void init(void) {
// set up watchdog // set up watchdog
wd_init(); wd_init();
// setup analog reading // setup analog reading
analog_init(); analog_init();
// set up serial // set up serial
intercom_init(); intercom_init();
// set up inputs and outputs // set up inputs and outputs
io_init(); io_init();
// temp sensor // temp sensor
temp_init(); temp_init();
// heater // heater
heater_init(); heater_init();
// set up extruder motor driver // set up extruder motor driver
motor_init(); motor_init();
// set up clock // set up clock
timer_init(); timer_init();
// enable interrupts // enable interrupts
sei(); sei();
// reset watchdog // reset watchdog
wd_reset(); wd_reset();
} }
int main (void) int main (void)
{ {
init(); init();
enable_heater(); enable_heater();
// main loop // main loop
for (;;) for (;;)
{ {
wd_reset(); wd_reset();
//Read motor PWM //Read motor PWM
motor_pwm = analog_read(TRIM_POT_CHANNEL) >> 2; motor_pwm = analog_read(TRIM_POT_CHANNEL) >> 2;
ifclock(CLOCK_FLAG_10MS) { ifclock(CLOCK_FLAG_10MS) {
// check temperatures and manage heaters // check temperatures and manage heaters
temp_sensor_tick(); temp_sensor_tick();
} }
// check if we've had a new intercom packet // check if we've had a new intercom packet
if (intercom_flags & FLAG_NEW_RX) { if (intercom_flags & FLAG_NEW_RX) {
intercom_flags &= ~FLAG_NEW_RX; intercom_flags &= ~FLAG_NEW_RX;
switch (rx.packet.control_word) { switch (rx.packet.control_word) {
// M105- read temperatures // M105- read temperatures
case 105: case 105:
send_temperature(0, temp_get(0)); send_temperature(0, temp_get(0));
temp_set(0, read_temperature(0)); temp_set(0, read_temperature(0));
send_temperature(1, temp_get(1)); send_temperature(1, temp_get(1));
temp_set(1, read_temperature(1)); temp_set(1, read_temperature(1));
start_send(); start_send();
break; break;
// M130 - set PID P factor // M130 - set PID P factor
case 130: case 130:
pid_set_p(rx.packet.control_index, rx.packet.control_data_int32); pid_set_p(rx.packet.control_index, rx.packet.control_data_int32);
// M131 - set PID I factor // M131 - set PID I factor
case 131: case 131:
pid_set_i(rx.packet.control_index, rx.packet.control_data_int32); pid_set_i(rx.packet.control_index, rx.packet.control_data_int32);
// M132 - set PID D factor // M132 - set PID D factor
case 132: case 132:
pid_set_d(rx.packet.control_index, rx.packet.control_data_int32); pid_set_d(rx.packet.control_index, rx.packet.control_data_int32);
// M133 - set PID I limit // M133 - set PID I limit
case 133: case 133:
pid_set_i_limit(rx.packet.control_index, rx.packet.control_data_int32); pid_set_i_limit(rx.packet.control_index, rx.packet.control_data_int32);
// M134 - save PID values to eeprom // M134 - save PID values to eeprom
case 134: case 134:
heater_save_settings(); heater_save_settings();
break; break;
} }
} }
if (intercom_flags & FLAG_TX_FINISHED) { if (intercom_flags & FLAG_TX_FINISHED) {
WRITE(TX_ENABLE_PIN,0); WRITE(TX_ENABLE_PIN,0);
} }
} }
} }