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. */
/*
CPU clock rate
*/
#ifndef F_CPU
#define F_CPU 16000000L
#endif
/*
other fallbacks for the Arduino IDE
*/
#define EXTRUDER
#define GEN3
#include "arduino.h"
// controller index- bus is multidrop after all
#define THIS_CONTROLLER_NUM 0
//RS485 Interface pins
#define RX_ENABLE_PIN DIO4
#define TX_ENABLE_PIN AIO2
// Control pins for the A3949 chips
#define H1D DIO7
#define H1E DIO5
#define H2D DIO8
#define H2E DIO6
// PWM versions of the enable_pins
#define H1E_PWM OCR0B
#define H2E_PWM OCR0A
//Step/Dir Pins from motherboard to extruder
//IMPORTANT: Assumes that the step pin is on PCIE0
#define E_STEP_PIN DIO10
#define E_DIR_PIN DIO9
//Trimpot is on AIO0, pin 23
#define TRIM_POT AIO0
#define TRIM_POT_CHANNEL 0
//Read analog voltage from thermistor
#define TEMP_PIN AIO3
#define TEMP_PIN_CHANNEL 3
//Read analog voltage from thermistor
#define TEMP_BED_PIN AIO6
#define TEMP_BED_PIN_CHANNEL 6
#define REFERENCE REFERENCE_AVCC
#define TEMP_THERMISTOR
#define HEATER_PIN DIO11
#define BED_PIN AIO1
#define FAN_PIN DIO12
// extruder settings
/*
CPU clock rate
*/
#ifndef F_CPU
#define F_CPU 16000000L
#endif
/*
other fallbacks for the Arduino IDE
*/
#define EXTRUDER
#define GEN3
#include "arduino.h"
// controller index- bus is multidrop after all
#define THIS_CONTROLLER_NUM 0
//RS485 Interface pins
#define RX_ENABLE_PIN DIO4
#define TX_ENABLE_PIN AIO2
// Control pins for the A3949 chips
#define H1D DIO7
#define H1E DIO5
#define H2D DIO8
#define H2E DIO6
// PWM versions of the enable_pins
#define H1E_PWM OCR0B
#define H2E_PWM OCR0A
//Step/Dir Pins from motherboard to extruder
//IMPORTANT: Assumes that the step pin is on PCIE0
#define E_STEP_PIN DIO10
#define E_DIR_PIN DIO9
//Trimpot is on AIO0, pin 23
#define TRIM_POT AIO0
#define TRIM_POT_CHANNEL 0
//Read analog voltage from thermistor
#define TEMP_PIN AIO3
#define TEMP_PIN_CHANNEL 3
//Read analog voltage from thermistor
#define TEMP_BED_PIN AIO6
#define TEMP_BED_PIN_CHANNEL 6
#define REFERENCE REFERENCE_AVCC
#define TEMP_THERMISTOR
#define HEATER_PIN DIO11
#define BED_PIN AIO1
#define FAN_PIN DIO12
// extruder settings
#define TEMP_HYSTERESIS 5
#define TEMP_RESIDENCY_TIME 60
#ifdef DEFINE_TEMP_SENSOR
DEFINE_TEMP_SENSOR(extruder, TT_THERMISTOR, TEMP_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
DEFINE_TEMP_SENSOR(noheater, TT_THERMISTOR, TRIM_POT_CHANNEL, 0)
#endif
#ifdef DEFINE_HEATER
DEFINE_HEATER(extruder, DIO11)
DEFINE_HEATER(bed, AIO1)
#endif
// list of PWM-able pins and corresponding timers
// timer1 is used for step timing so don't use OC1A/OC1B (DIO9/DIO10)
// OC0A DIO6
// OC0B DIO5
// OC1A DIO9
// OC1B DIO10
// OC2A DIO11
// OC2B DIO3
#define TH_COUNT 8
#define PID_SCALE 1024L
/*
Motors
*/
#define enable_motors() do { TCCR0A |= MASK(COM0A1) | MASK(COM0B1); } while (0)
#define disable_motors() do { TCCR0A &= ~MASK(COM0A1) & ~MASK(COM0B1); } while (0)
#define TEMP_RESIDENCY_TIME 60
#ifdef DEFINE_TEMP_SENSOR
DEFINE_TEMP_SENSOR(extruder, TT_THERMISTOR, TEMP_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
DEFINE_TEMP_SENSOR(noheater, TT_THERMISTOR, TRIM_POT_CHANNEL, 0)
#endif
#ifdef DEFINE_HEATER
DEFINE_HEATER(extruder, DIO11)
DEFINE_HEATER(bed, AIO1)
#endif
// list of PWM-able pins and corresponding timers
// timer1 is used for step timing so don't use OC1A/OC1B (DIO9/DIO10)
// OC0A DIO6
// OC0B DIO5
// OC1A DIO9
// OC1B DIO10
// OC2A DIO11
// OC2B DIO3
#define TH_COUNT 8
#define PID_SCALE 1024L
/*
Motors
*/
#define enable_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 <string.h>
#include <avr/interrupt.h>
#include "intercom.h"
#include "analog.h"
#include "config_wrapper.h"
#include "watchdog.h"
#include "heater.h"
#include "temp.h"
#include "timer.h"
static uint8_t motor_pwm;
void io_init(void) {
// setup I/O pins
WRITE(DEBUG_LED, 0); SET_OUTPUT(DEBUG_LED);
WRITE(H1D,0); SET_OUTPUT(H1D);
WRITE(H1E,0); SET_OUTPUT(H1E);
WRITE(H2D,0); SET_OUTPUT(H2D);
WRITE(H2E,0); SET_OUTPUT(H2E);
SET_INPUT(TRIM_POT);
SET_INPUT(TEMP_PIN);
SET_INPUT(TEMP_BED_PIN);
SET_INPUT(E_STEP_PIN);
SET_INPUT(E_DIR_PIN);
// use pull up resistors to avoid noise
WRITE(E_STEP_PIN, 1);
WRITE(E_DIR_PIN, 1);
//Enable the RS485 transceiver
SET_OUTPUT(RX_ENABLE_PIN);
SET_OUTPUT(TX_ENABLE_PIN);
WRITE(RX_ENABLE_PIN,0);
disable_transmit();
#ifdef HEATER_PIN
WRITE(HEATER_PIN, 0); SET_OUTPUT(HEATER_PIN);
#endif
#ifdef BED_PIN
WRITE(BED_PIN, 0); SET_OUTPUT(BED_PIN);
#endif
#ifdef FAN_PIN
WRITE(FAN_PIN, 0); SET_OUTPUT(FAN_PIN);
#endif
// #if defined(HEATER_PWM) || defined(FAN_PWM) || defined(BED_PWM)
// setup PWM timer: fast PWM, no prescaler
TCCR2A = MASK(WGM21) | MASK(WGM20);
TCCR2B = MASK(CS22);
TIMSK2 = 0;
OCR2A = 0;
OCR2B = 0;
// #endif
#if defined(H1E_PWM) && defined(H2E_PWM)
TCCR0A = MASK(WGM01) | MASK(WGM00);
TCCR0B = MASK(CS20);
TIMSK0 = 0;
OCR0A = 0;
OCR0B = 0;
#endif
}
void motor_init(void) {
//Enable an interrupt to be triggered when the step pin changes
//This will be PCIE0
PCICR = MASK(PCIE0);
PCMSK0 = MASK(PCINT2);
}
ISR(PCINT0_vect) {
static uint8_t coil_pos, pwm;
//if the step pin is high, we advance the motor
if (READ(E_STEP_PIN)) {
//Turn on motors only on first tick to save power I guess
enable_motors();
//Advance the coil position
if (READ(E_DIR_PIN))
coil_pos++;
else
coil_pos--;
coil_pos &= 7;
//Grab the latest motor power to use
pwm = motor_pwm;
switch(coil_pos) {
case 0:
WRITE(H1D, 0);
WRITE(H2D, 0);
H1E_PWM = 0;
H2E_PWM = pwm;
break;
case 1:
WRITE(H1D, 1);
WRITE(H2D, 0);
H1E_PWM = pwm;
H2E_PWM = pwm;
break;
case 2:
WRITE(H1D, 1);
WRITE(H2D, 0);
H1E_PWM = pwm;
H2E_PWM = 0;
break;
case 3:
WRITE(H1D, 1);
WRITE(H2D, 1);
H1E_PWM = pwm;
H2E_PWM = pwm;
break;
case 4:
WRITE(H1D, 1);
WRITE(H2D, 1);
H1E_PWM = 0;
H2E_PWM = pwm;
break;
case 5:
WRITE(H1D, 0);
WRITE(H2D, 1);
H1E_PWM = pwm;
H2E_PWM = pwm;
break;
case 6:
WRITE(H1D, 0);
WRITE(H2D, 1);
H1E_PWM = pwm;
H2E_PWM = 0;
break;
case 7:
WRITE(H1D, 0);
WRITE(H2D, 0);
H1E_PWM = pwm;
H2E_PWM = pwm;
break;
}
}
}
void init(void) {
// set up watchdog
wd_init();
// setup analog reading
analog_init();
// set up serial
intercom_init();
// set up inputs and outputs
io_init();
// temp sensor
temp_init();
// heater
heater_init();
// set up extruder motor driver
motor_init();
// set up clock
timer_init();
// enable interrupts
sei();
// reset watchdog
wd_reset();
}
int main (void)
{
init();
enable_heater();
// main loop
for (;;)
{
wd_reset();
//Read motor PWM
motor_pwm = analog_read(TRIM_POT_CHANNEL) >> 2;
ifclock(CLOCK_FLAG_10MS) {
// check temperatures and manage heaters
temp_sensor_tick();
}
// check if we've had a new intercom packet
if (intercom_flags & FLAG_NEW_RX) {
intercom_flags &= ~FLAG_NEW_RX;
switch (rx.packet.control_word) {
// M105- read temperatures
case 105:
send_temperature(0, temp_get(0));
temp_set(0, read_temperature(0));
send_temperature(1, temp_get(1));
temp_set(1, read_temperature(1));
start_send();
break;
// M130 - set PID P factor
case 130:
pid_set_p(rx.packet.control_index, rx.packet.control_data_int32);
// M131 - set PID I factor
case 131:
pid_set_i(rx.packet.control_index, rx.packet.control_data_int32);
// M132 - set PID D factor
case 132:
pid_set_d(rx.packet.control_index, rx.packet.control_data_int32);
// M133 - set PID I limit
case 133:
pid_set_i_limit(rx.packet.control_index, rx.packet.control_data_int32);
// M134 - save PID values to eeprom
case 134:
heater_save_settings();
break;
}
}
#include <stdint.h>
#include <string.h>
#include <avr/interrupt.h>
#include "intercom.h"
#include "analog.h"
#include "config_wrapper.h"
#include "watchdog.h"
#include "heater.h"
#include "temp.h"
#include "timer.h"
static uint8_t motor_pwm;
void io_init(void) {
// setup I/O pins
WRITE(DEBUG_LED, 0); SET_OUTPUT(DEBUG_LED);
WRITE(H1D,0); SET_OUTPUT(H1D);
WRITE(H1E,0); SET_OUTPUT(H1E);
WRITE(H2D,0); SET_OUTPUT(H2D);
WRITE(H2E,0); SET_OUTPUT(H2E);
SET_INPUT(TRIM_POT);
SET_INPUT(TEMP_PIN);
SET_INPUT(TEMP_BED_PIN);
SET_INPUT(E_STEP_PIN);
SET_INPUT(E_DIR_PIN);
// use pull up resistors to avoid noise
WRITE(E_STEP_PIN, 1);
WRITE(E_DIR_PIN, 1);
//Enable the RS485 transceiver
SET_OUTPUT(RX_ENABLE_PIN);
SET_OUTPUT(TX_ENABLE_PIN);
WRITE(RX_ENABLE_PIN,0);
disable_transmit();
#ifdef HEATER_PIN
WRITE(HEATER_PIN, 0); SET_OUTPUT(HEATER_PIN);
#endif
#ifdef BED_PIN
WRITE(BED_PIN, 0); SET_OUTPUT(BED_PIN);
#endif
#ifdef FAN_PIN
WRITE(FAN_PIN, 0); SET_OUTPUT(FAN_PIN);
#endif
// #if defined(HEATER_PWM) || defined(FAN_PWM) || defined(BED_PWM)
// setup PWM timer: fast PWM, no prescaler
TCCR2A = MASK(WGM21) | MASK(WGM20);
TCCR2B = MASK(CS22);
TIMSK2 = 0;
OCR2A = 0;
OCR2B = 0;
// #endif
#if defined(H1E_PWM) && defined(H2E_PWM)
TCCR0A = MASK(WGM01) | MASK(WGM00);
TCCR0B = MASK(CS20);
TIMSK0 = 0;
OCR0A = 0;
OCR0B = 0;
#endif
}
void motor_init(void) {
//Enable an interrupt to be triggered when the step pin changes
//This will be PCIE0
PCICR = MASK(PCIE0);
PCMSK0 = MASK(PCINT2);
}
ISR(PCINT0_vect) {
static uint8_t coil_pos, pwm;
//if the step pin is high, we advance the motor
if (READ(E_STEP_PIN)) {
//Turn on motors only on first tick to save power I guess
enable_motors();
//Advance the coil position
if (READ(E_DIR_PIN))
coil_pos++;
else
coil_pos--;
coil_pos &= 7;
//Grab the latest motor power to use
pwm = motor_pwm;
switch(coil_pos) {
case 0:
WRITE(H1D, 0);
WRITE(H2D, 0);
H1E_PWM = 0;
H2E_PWM = pwm;
break;
case 1:
WRITE(H1D, 1);
WRITE(H2D, 0);
H1E_PWM = pwm;
H2E_PWM = pwm;
break;
case 2:
WRITE(H1D, 1);
WRITE(H2D, 0);
H1E_PWM = pwm;
H2E_PWM = 0;
break;
case 3:
WRITE(H1D, 1);
WRITE(H2D, 1);
H1E_PWM = pwm;
H2E_PWM = pwm;
break;
case 4:
WRITE(H1D, 1);
WRITE(H2D, 1);
H1E_PWM = 0;
H2E_PWM = pwm;
break;
case 5:
WRITE(H1D, 0);
WRITE(H2D, 1);
H1E_PWM = pwm;
H2E_PWM = pwm;
break;
case 6:
WRITE(H1D, 0);
WRITE(H2D, 1);
H1E_PWM = pwm;
H2E_PWM = 0;
break;
case 7:
WRITE(H1D, 0);
WRITE(H2D, 0);
H1E_PWM = pwm;
H2E_PWM = pwm;
break;
}
}
}
void init(void) {
// set up watchdog
wd_init();
// setup analog reading
analog_init();
// set up serial
intercom_init();
// set up inputs and outputs
io_init();
// temp sensor
temp_init();
// heater
heater_init();
// set up extruder motor driver
motor_init();
// set up clock
timer_init();
// enable interrupts
sei();
// reset watchdog
wd_reset();
}
int main (void)
{
init();
enable_heater();
// main loop
for (;;)
{
wd_reset();
//Read motor PWM
motor_pwm = analog_read(TRIM_POT_CHANNEL) >> 2;
ifclock(CLOCK_FLAG_10MS) {
// check temperatures and manage heaters
temp_sensor_tick();
}
// check if we've had a new intercom packet
if (intercom_flags & FLAG_NEW_RX) {
intercom_flags &= ~FLAG_NEW_RX;
switch (rx.packet.control_word) {
// M105- read temperatures
case 105:
send_temperature(0, temp_get(0));
temp_set(0, read_temperature(0));
send_temperature(1, temp_get(1));
temp_set(1, read_temperature(1));
start_send();
break;
// M130 - set PID P factor
case 130:
pid_set_p(rx.packet.control_index, rx.packet.control_data_int32);
// M131 - set PID I factor
case 131:
pid_set_i(rx.packet.control_index, rx.packet.control_data_int32);
// M132 - set PID D factor
case 132:
pid_set_d(rx.packet.control_index, rx.packet.control_data_int32);
// M133 - set PID I limit
case 133:
pid_set_i_limit(rx.packet.control_index, rx.packet.control_data_int32);
// M134 - save PID values to eeprom
case 134:
heater_save_settings();
break;
}
}
if (intercom_flags & FLAG_TX_FINISHED) {
WRITE(TX_ENABLE_PIN,0);
}
}
}
}
}