From 6e9eb7593bf4f1ad2cd08b6480c79fa39ab09016 Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Sun, 11 Mar 2018 22:05:21 -0700 Subject: [PATCH] Added site favicon, Fixed problems with offsets and imperial units, Added step-test --- .gitignore | 3 + CHANGELOG.md | 3 + src/avr/Makefile | 129 ++-------------------------- src/avr/Makefile.common | 115 +++++++++++++++++++++++++ src/avr/src/config.h | 12 +-- src/avr/src/drv8711.c | 2 +- src/avr/src/hardware.c | 3 +- src/avr/src/hardware.h | 2 +- src/avr/src/line.c | 3 + src/avr/src/main.c | 2 +- src/avr/src/motor.c | 4 + src/avr/src/pins.h | 28 +++--- src/avr/step-test/Makefile | 20 +++++ src/avr/step-test/step-test.c | 157 ++++++++++++++++++++++++++++++++++ src/avr/test/firmware-test.c | 2 +- src/py/bbctrl/Mach.py | 2 +- src/resources/favicon.ico | Bin 0 -> 32038 bytes 17 files changed, 344 insertions(+), 143 deletions(-) create mode 100644 src/avr/Makefile.common create mode 100644 src/avr/step-test/Makefile create mode 100644 src/avr/step-test/step-test.c create mode 100644 src/resources/favicon.ico diff --git a/.gitignore b/.gitignore index 36cd877..9e00f1b 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ __pycache__ *.deb *.zip /rpi-share + +*.elf +*.hex diff --git a/CHANGELOG.md b/CHANGELOG.md index f5518f2..8314278 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ Buildbotics CNC Controller Firmware Change Log - Fixed stopping problems. #127 - Fixed ``Negative s-curve time`` error. - Improved jogging with soft limits. + - Added site favicon. + - Fixed problems with offsets and imperial units. + - Fixed ``All zero s-curve times`` caused by extreemly short, non-zero moves. ## v0.3.18 - Don't enable any tool by default. diff --git a/src/avr/Makefile b/src/avr/Makefile index d1489da..2c00a07 100644 --- a/src/avr/Makefile +++ b/src/avr/Makefile @@ -3,96 +3,26 @@ PROJECT = bbctrl-avr-firmware MCU = atxmega192a3u CLOCK = 32000000 -TARGET = $(PROJECT).elf - -# Compile flags -CC = avr-g++ - -COMMON = -mmcu=$(MCU) -flto -fwhole-program - -CFLAGS += $(COMMON) -CFLAGS += -Wall -Werror -CFLAGS += -Wno-error=strict-aliasing # for _invsqrt -CFLAGS += -std=gnu++98 -DF_CPU=$(CLOCK)UL -O3 -CFLAGS += -funsigned-bitfields -fpack-struct -fshort-enums -funsigned-char -CFLAGS += -MD -MP -MT $@ -MF build/dep/$(@F).d -CFLAGS += -D__STDC_LIMIT_MACROS -CFLAGS += -Isrc - -# Linker flags -LDFLAGS += $(COMMON) -Wl,-u,vfprintf -lprintf_flt -lm -LIBS += -lm - -# EEPROM flags -EEFLAGS += -j .eeprom -EEFLAGS += --set-section-flags=.eeprom="alloc,load" -EEFLAGS += --change-section-lma .eeprom=0 --no-change-warnings - -# Programming flags -ifndef (PROGRAMMER) -PROGRAMMER = avrispmkII -#PROGRAMMER = jtag3pdi -endif -PDEV = usb -AVRDUDE_OPTS = -c $(PROGRAMMER) -p $(MCU) -P $(PDEV) - -FUSE0=0xff -FUSE1=0x00 -FUSE2=0xbe -FUSE4=0xff -FUSE5=0xeb - # SRC SRC = $(wildcard src/*.c) $(wildcard src/*.cpp) OBJ = $(patsubst src/%.cpp,build/%.o,$(patsubst src/%.c,build/%.o,$(SRC))) JSON = vars command messages JSON := $(patsubst %,build/%.json,$(JSON)) -# Build -all: $(PROJECT).hex $(JSON) size - -# JSON -build/%.json: src/%.json.in src/%.def - cpp -Isrc $< | sed "/^#.*$$/d;s/'\(.\)'/\"\1\"/g" > $@ - -# Compile -build/%.o: src/%.c - @mkdir -p $(shell dirname $@) - $(CC) $(INCLUDES) $(CFLAGS) -c -o $@ $< +include Makefile.common -build/%.o: src/%.cpp - @mkdir -p $(shell dirname $@) - $(CC) $(INCLUDES) $(CFLAGS) -c -o $@ $< +CFLAGS += -Isrc -build/%.o: src/%.S - @mkdir -p $(shell dirname $@) - $(CC) $(INCLUDES) $(CFLAGS) -c -o $@ $< +# Build +all: $(PROJECT).hex $(JSON) size -# Link -$(TARGET): $(OBJ) +$(PROJECT).elf: $(OBJ) $(CC) $(LDFLAGS) $(OBJ) $(LIBS) -o $@ -%.hex: %.elf - avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature $< $@ - -%.eep: %.elf - avr-objcopy $(EEFLAGS) -O ihex $< $@ -%.lss: %.elf - avr-objdump -h -S $< > $@ - -size: $(TARGET) - @for X in A B C; do\ - echo '****************************************************************' ;\ - avr-size -$$X --mcu=$(MCU) $(TARGET) ;\ - done - -data-usage: $(TARGET) - avr-nm -S --size-sort -t decimal $(TARGET) | grep ' [BbDd] ' - - -prog-usage: $(TARGET) - avr-nm -S --size-sort -t decimal $(TARGET) | grep -v ' [BbDd] ' +# JSON +build/%.json: src/%.json.in src/%.def + cpp -Isrc $< | sed "/^#.*$$/d;s/'\(.\)'/\"\1\"/g" > $@ # Program init: @@ -102,48 +32,7 @@ init: $(MAKE) program-boot $(MAKE) program -reset: - avrdude $(AVRDUDE_OPTS) - -erase: - avrdude $(AVRDUDE_OPTS) -e - -program: $(PROJECT).hex - avrdude $(AVRDUDE_OPTS) -U flash:w:$(PROJECT).hex:i - -verify: $(PROJECT).hex - avrdude $(AVRDUDE_OPTS) -U flash:v:$(PROJECT).hex:i - program-boot: $(MAKE) -C ../boot program -fuses: - avrdude $(AVRDUDE_OPTS) -U fuse0:w:$(FUSE0):m -U fuse1:w:$(FUSE1):m \ - -U fuse2:w:$(FUSE2):m -U fuse4:w:$(FUSE4):m -U fuse5:w:$(FUSE5):m - -read_fuses: - avrdude $(AVRDUDE_OPTS) -q -q -U fuse0:r:-:h -U fuse1:r:-:h -U fuse2:r:-:h \ - -U fuse4:r:-:h -U fuse5:r:-:h - -signature: - avrdude $(AVRDUDE_OPTS) -q -q -U signature:r:-:h - -prodsig: - avrdude $(AVRDUDE_OPTS) -q -q -U prodsig:r:-:h - -usersig: - avrdude $(AVRDUDE_OPTS) -q -q -U usersig:r:-:h - -# Clean -tidy: - rm -f $(shell find -name \*~ -o -name \#\*) - -clean: tidy - rm -rf $(PROJECT).elf $(PROJECT).hex $(PROJECT).eep $(PROJECT).lss \ - $(PROJECT).map build - -.PHONY: tidy clean size all reset erase program fuses read_fuses prodsig -.PHONY: signature usersig data-usage prog-usage - -# Dependencies --include $(shell mkdir -p build/dep) $(wildcard build/dep/*) +.PHONY: all init program-boot diff --git a/src/avr/Makefile.common b/src/avr/Makefile.common new file mode 100644 index 0000000..5810090 --- /dev/null +++ b/src/avr/Makefile.common @@ -0,0 +1,115 @@ +# Compile flags +CC = avr-g++ + +COMMON = -mmcu=$(MCU) -flto -fwhole-program + +CFLAGS += $(COMMON) +CFLAGS += -Wall -Werror +CFLAGS += -Wno-error=strict-aliasing # for _invsqrt +CFLAGS += -std=gnu++98 -DF_CPU=$(CLOCK)UL -O3 +CFLAGS += -funsigned-bitfields -fpack-struct -fshort-enums -funsigned-char +CFLAGS += -MD -MP -MT $@ -MF build/dep/$(@F).d +CFLAGS += -D__STDC_LIMIT_MACROS + +# Linker flags +LDFLAGS += $(COMMON) -Wl,-u,vfprintf -lprintf_flt -lm +LIBS += -lm + +# EEPROM flags +EEFLAGS += -j .eeprom +EEFLAGS += --set-section-flags=.eeprom="alloc,load" +EEFLAGS += --change-section-lma .eeprom=0 --no-change-warnings + +# Programming flags +ifndef (PROGRAMMER) +PROGRAMMER = avrispmkII +#PROGRAMMER = jtag3pdi +endif +PDEV = usb +AVRDUDE_OPTS = -c $(PROGRAMMER) -p $(MCU) -P $(PDEV) + +FUSE0=0xff +FUSE1=0x00 +FUSE2=0xbe +FUSE4=0xff +FUSE5=0xeb + +# Compile +build/%.o: src/%.c + @mkdir -p $(shell dirname $@) + $(CC) $(CFLAGS) -c -o $@ $< + +build/%.o: src/%.cpp + @mkdir -p $(shell dirname $@) + $(CC) $(CFLAGS) -c -o $@ $< + +build/%.o: src/%.S + @mkdir -p $(shell dirname $@) + $(CC) $(CFLAGS) -c -o $@ $< + +# Link +%.hex: %.elf + avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature $< $@ + +%.eep: %.elf + avr-objcopy $(EEFLAGS) -O ihex $< $@ + +%.lss: %.elf + avr-objdump -h -S $< > $@ + +size: $(PROJECT).elf + @for X in A B C; do\ + echo '****************************************************************' ;\ + avr-size -$$X --mcu=$(MCU) $(PROJECT).elf ;\ + done + +data-usage: $(PROJECT).elf + avr-nm -S --size-sort -t decimal $(PROJECT).elf | grep ' [BbDd] ' + + +prog-usage: $(PROJECT).elf + avr-nm -S --size-sort -t decimal $(PROJECT).elf | grep -v ' [BbDd] ' + +# Program +reset: + avrdude $(AVRDUDE_OPTS) + +erase: + avrdude $(AVRDUDE_OPTS) -e + +program: $(PROJECT).hex + avrdude $(AVRDUDE_OPTS) -U flash:w:$(PROJECT).hex:i + +verify: $(PROJECT).hex + avrdude $(AVRDUDE_OPTS) -U flash:v:$(PROJECT).hex:i + +fuses: + avrdude $(AVRDUDE_OPTS) -U fuse0:w:$(FUSE0):m -U fuse1:w:$(FUSE1):m \ + -U fuse2:w:$(FUSE2):m -U fuse4:w:$(FUSE4):m -U fuse5:w:$(FUSE5):m + +read_fuses: + avrdude $(AVRDUDE_OPTS) -q -q -U fuse0:r:-:h -U fuse1:r:-:h -U fuse2:r:-:h \ + -U fuse4:r:-:h -U fuse5:r:-:h + +signature: + avrdude $(AVRDUDE_OPTS) -q -q -U signature:r:-:h + +prodsig: + avrdude $(AVRDUDE_OPTS) -q -q -U prodsig:r:-:h + +usersig: + avrdude $(AVRDUDE_OPTS) -q -q -U usersig:r:-:h + +# Clean +tidy: + rm -f $(shell find -name \*~ -o -name \#\*) + +clean: tidy + rm -rf $(PROJECT).elf $(PROJECT).hex $(PROJECT).eep $(PROJECT).lss \ + $(PROJECT).map build + +.PHONY: tidy clean size reset erase program fuses read_fuses prodsig +.PHONY: signature usersig data-usage prog-usage + +# Dependencies +-include $(shell mkdir -p build/dep) $(wildcard build/dep/*) diff --git a/src/avr/src/config.h b/src/avr/src/config.h index fbee04d..c1c0eba 100644 --- a/src/avr/src/config.h +++ b/src/avr/src/config.h @@ -36,7 +36,7 @@ // Pins enum { - STALL_X_PIN = PORT_A << 3, + STALL_X_PIN = PIN_ID(PORT_A, 0), STALL_Y_PIN, STALL_Z_PIN, STALL_A_PIN, @@ -45,7 +45,7 @@ enum { ANALOG_1_PIN, ANALOG_2_PIN, - MIN_X_PIN = PORT_B << 3, + MIN_X_PIN = PIN_ID(PORT_B, 0), MAX_X_PIN, MIN_A_PIN, MAX_A_PIN, @@ -54,7 +54,7 @@ enum { MIN_Z_PIN, MAX_Z_PIN, - SDA_PIN = PORT_C << 3, + SDA_PIN = PIN_ID(PORT_C, 0), SCL_PIN, SERIAL_RX_PIN, SERIAL_TX_PIN, @@ -63,7 +63,7 @@ enum { SPI_MISO_PIN, SPI_MOSI_PIN, - STEP_X_PIN = PORT_D << 3, + STEP_X_PIN = PIN_ID(PORT_D, 0), SPI_CS_X_PIN, SPI_CS_A_PIN, SPI_CS_Z_PIN, @@ -72,7 +72,7 @@ enum { RS485_RO_PIN, RS485_DI_PIN, - STEP_Y_PIN = PORT_E << 3, + STEP_Y_PIN = PIN_ID(PORT_E, 0), SPI_CS_Y_PIN, DIR_X_PIN, DIR_Y_PIN, @@ -81,7 +81,7 @@ enum { DIR_Z_PIN, DIR_A_PIN, - STEP_Z_PIN = PORT_F << 3, + STEP_Z_PIN = PIN_ID(PORT_F, 0), RS485_RW_PIN, FAULT_PIN, ESTOP_PIN, diff --git a/src/avr/src/drv8711.c b/src/avr/src/drv8711.c index 37583d7..e05ac51 100644 --- a/src/avr/src/drv8711.c +++ b/src/avr/src/drv8711.c @@ -359,7 +359,7 @@ void drv8711_init() { PR.PRPC &= ~PR_SPI_bm; // Disable power reduction SPIC.CTRL = SPI_ENABLE_bm | SPI_MASTER_bm | SPI_MODE_0_gc | SPI_PRESCALER_DIV16_gc; // enable, big endian, master, mode, clock div - PORT(SPI_CLK_PIN)->REMAP = PORT_SPI_bm; // Swap SCK and MOSI + PIN_PORT(SPI_CLK_PIN)->REMAP = PORT_SPI_bm; // Swap SCK and MOSI SPIC.INTCTRL = SPI_INTLVL_LO_gc; // interupt level _init_spi_commands(); diff --git a/src/avr/src/hardware.c b/src/avr/src/hardware.c index ee81ff7..5528d9b 100644 --- a/src/avr/src/hardware.c +++ b/src/avr/src/hardware.c @@ -28,7 +28,6 @@ #include "hardware.h" #include "rtc.h" #include "usart.h" -#include "huanyang.h" #include "config.h" #include "pgmspace.h" @@ -112,7 +111,7 @@ static void _read_hw_id() { /// Lowest level hardware init -void hardware_init() { +void hw_init() { _init_clock(); // set system clock rtc_init(); // real time counter _read_hw_id(); diff --git a/src/avr/src/hardware.h b/src/avr/src/hardware.h index fdda57e..e2be012 100644 --- a/src/avr/src/hardware.h +++ b/src/avr/src/hardware.h @@ -32,7 +32,7 @@ #include -void hardware_init(); +void hw_init(); void hw_request_hard_reset(); void hw_reset_handler(); diff --git a/src/avr/src/line.c b/src/avr/src/line.c index 5516e16..2260f1d 100644 --- a/src/avr/src/line.c +++ b/src/avr/src/line.c @@ -215,6 +215,9 @@ static stat_t _line_exec() { // Adjust segment time if near a stopping point float seg_time = SEGMENT_TIME; if (l.stop_section && section_time - l.current_time < SEGMENT_TIME) { + // TODO Instead of adjusting seg_time either absorb the next partial segment + // or expand it to a full segment so that we only have SEGMENT_TIME length + // segments. seg_time += section_time - l.current_time; l.offset_time += section_time - l.current_time; l.current_time = section_time; diff --git a/src/avr/src/main.c b/src/avr/src/main.c index 377952c..5877224 100644 --- a/src/avr/src/main.c +++ b/src/avr/src/main.c @@ -56,7 +56,7 @@ int main() { // Init cli(); // disable interrupts - hardware_init(); // hardware setup - must be first + hw_init(); // hardware setup - must be first outputs_init(); // output pins analog_init(); // analog input pins usart_init(); // serial port diff --git a/src/avr/src/motor.c b/src/avr/src/motor.c index 8841d9f..b82a583 100644 --- a/src/avr/src/motor.c +++ b/src/avr/src/motor.c @@ -242,6 +242,9 @@ void motor_end_move(int motor) { // Stop clock m->timer->CTRLA = 0; + // TODO Wait for pending DMA transfers + //while (m->dma->CTRLB & (DMA_CH_CHBUSY_bm | DMA_CH_CHPEND_bm)) continue; + // Get actual step count from DMA channel const int24_t half_steps = 0xffff - m->dma->TRFCNT; @@ -327,6 +330,7 @@ void motor_prep_move(int motor, float time, float target) { // Find the fastest clock rate that will fit the required number of steps. // Note, clock toggles step line so we need two clocks per step. + // TODO Always use DIV2 clock uint24_t seg_clocks = time * F_CPU * 60; uint24_t ticks_per_step = seg_clocks / half_steps + 1; // Round up if (ticks_per_step < 0xffff) m->timer_clock = TC_CLKSEL_DIV1_gc; diff --git a/src/avr/src/pins.h b/src/avr/src/pins.h index 49ae19e..56fc78d 100644 --- a/src/avr/src/pins.h +++ b/src/avr/src/pins.h @@ -29,24 +29,32 @@ enum {PORT_A = 1, PORT_B, PORT_C, PORT_D, PORT_E, PORT_F}; -#define PORT(PIN) pin_ports[(PIN >> 3) - 1] -#define BM(PIN) (1 << (PIN & 7)) +#define PIN_INDEX(PIN) (PIN & 7) +#define PORT_INDEX(PIN) ((PIN >> 3) - 1) + +#define PIN_PORT(PIN) pin_ports[PORT_INDEX(PIN)] +#define PIN_BM(PIN) (1 << PIN_INDEX(PIN)) + +#define PIN_ID(PORT, PIN) (PORT << 3 | (PIN & 7)) #ifdef __AVR__ #include extern PORT_t *pin_ports[]; -#define DIRSET_PIN(PIN) PORT(PIN)->DIRSET = BM(PIN) -#define DIRCLR_PIN(PIN) PORT(PIN)->DIRCLR = BM(PIN) -#define OUTCLR_PIN(PIN) PORT(PIN)->OUTCLR = BM(PIN) -#define OUTSET_PIN(PIN) PORT(PIN)->OUTSET = BM(PIN) -#define OUTTGL_PIN(PIN) PORT(PIN)->OUTTGL = BM(PIN) -#define OUT_PIN(PIN) (!!(PORT(PIN)->OUT & BM(PIN))) -#define IN_PIN(PIN) (!!(PORT(PIN)->IN & BM(PIN))) -#define PINCTRL_PIN(PIN) ((&PORT(PIN)->PIN0CTRL)[PIN & 7]) +#define DIRSET_PIN(PIN) PIN_PORT(PIN)->DIRSET = PIN_BM(PIN) +#define DIRCLR_PIN(PIN) PIN_PORT(PIN)->DIRCLR = PIN_BM(PIN) +#define OUTCLR_PIN(PIN) PIN_PORT(PIN)->OUTCLR = PIN_BM(PIN) +#define OUTSET_PIN(PIN) PIN_PORT(PIN)->OUTSET = PIN_BM(PIN) +#define OUTTGL_PIN(PIN) PIN_PORT(PIN)->OUTTGL = PIN_BM(PIN) +#define OUT_PIN(PIN) (!!(PIN_PORT(PIN)->OUT & PIN_BM(PIN))) +#define IN_PIN(PIN) (!!(PIN_PORT(PIN)->IN & PIN_BM(PIN))) +#define PINCTRL_PIN(PIN) ((&PIN_PORT(PIN)->PIN0CTRL)[PIN_INDEX(PIN)]) #define SET_PIN(PIN, X) \ do {if (X) OUTSET_PIN(PIN); else OUTCLR_PIN(PIN);} while (0); +#define PIN_EVSYS_CHMUX(PIN) \ + (EVSYS_CHMUX_PORTA_PIN0_gc + (8 * PORT_INDEX(PIN)) + PIN_INDEX(PIN)) + #endif // __AVR__ diff --git a/src/avr/step-test/Makefile b/src/avr/step-test/Makefile new file mode 100644 index 0000000..52f894a --- /dev/null +++ b/src/avr/step-test/Makefile @@ -0,0 +1,20 @@ +# Makefile for Bulidbotics step-test +PROJECT = step-test +MCU = atxmega192a3u +CLOCK = 32000000 + +# SRC +SRC = usart.c lcd.c pins.c hardware.c +SRC := $(wildcard *.c) $(patsubst %,../src/%,$(SRC)) + +include ../Makefile.common + +CFLAGS += -I../src -I. + +# Build +all: $(PROJECT).hex size + +$(PROJECT).elf: $(SRC) + $(CC) $(SRC) $(CFLAGS) $(LDFLAGS) $(LIBS) -o $@ + +.PHONY: all diff --git a/src/avr/step-test/step-test.c b/src/avr/step-test/step-test.c new file mode 100644 index 0000000..c16dfe1 --- /dev/null +++ b/src/avr/step-test/step-test.c @@ -0,0 +1,157 @@ +/******************************************************************************\ + + This file is part of the Buildbotics firmware. + + Copyright (c) 2015 - 2018, Buildbotics LLC + All rights reserved. + + This file ("the software") is free software: you can redistribute it + and/or modify it under the terms of the GNU General Public License, + version 2 as published by the Free Software Foundation. You should + have received a copy of the GNU General Public License, version 2 + along with the software. If not, see . + + The software is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the software. If not, see + . + + For information regarding this software email: + "Joseph Coffland" + +\******************************************************************************/ + +#include "config.h" +#include "hardware.h" +#include "usart.h" +#include "lcd.h" + +#include + +#include +#include + + +void rtc_init() {} + + +static struct { + uint8_t step_pin; + uint8_t dir_pin; + TC0_t *timer; + volatile int16_t high; + +} channel[4] = { + {STEP_X_PIN, DIR_X_PIN, &TCC0, 0}, + {STEP_Y_PIN, DIR_Y_PIN, &TCD0, 0}, + {STEP_Z_PIN, DIR_Z_PIN, &TCE0, 0}, + {STEP_A_PIN, DIR_A_PIN, &TCF0, 0}, +}; + + +#define EVSYS_CHMUX(CH) (&EVSYS_CH0MUX)[CH] +#define EVSYS_CHCTRL(CH) (&EVSYS_CH0CTRL)[CH] + + +void channel_overflow(int i) { + if (IN_PIN(channel[i].dir_pin)) channel[i].high--; + else channel[i].high++; +} + + +ISR(TCC0_OVF_vect) {channel_overflow(0);} +ISR(TCD0_OVF_vect) {channel_overflow(1);} +ISR(TCE0_OVF_vect) {channel_overflow(2);} +ISR(TCF0_OVF_vect) {channel_overflow(3);} + + +void channel_update_dir(int i) { + if (IN_PIN(channel[i].dir_pin)) channel[i].timer->CTRLFSET = TC0_DIR_bm; + else channel[i].timer->CTRLFCLR = TC0_DIR_bm; +} + + +ISR(PORTE_INT0_vect) { + for (int i = 0; i < 4; i++) channel_update_dir(i); +} + + +int32_t channel_read(int i) { + while (true) { + int32_t x = (int32_t)channel[i].high << 16 | channel[i].timer->CNT; + int32_t y = (int32_t)channel[i].high << 16 | channel[i].timer->CNT; + if (x == y) return x; + } +} + + +void channel_init(int i) { + uint8_t step_pin = channel[i].step_pin; + uint8_t dir_pin = channel[i].dir_pin; + + // Configure I/O + DIRCLR_PIN(step_pin); + DIRCLR_PIN(dir_pin); + PINCTRL_PIN(step_pin) = PORT_SRLEN_bm | PORT_ISC_RISING_gc; + PINCTRL_PIN(dir_pin) = PORT_SRLEN_bm | PORT_ISC_BOTHEDGES_gc; + + // Dir change interrupt + PIN_PORT(dir_pin)->INTCTRL |= PORT_INT0LVL_MED_gc; + PIN_PORT(dir_pin)->INT0MASK |= PIN_BM(dir_pin); + + // Events + EVSYS_CHMUX(i) = PIN_EVSYS_CHMUX(step_pin); + EVSYS_CHCTRL(i) = EVSYS_DIGFILT_8SAMPLES_gc; + + // Clock + channel[i].timer->CTRLA = TC_CLKSEL_EVCH0_gc + i; + channel[i].timer->INTCTRLA = TC_OVFINTLVL_HI_gc; + + // Set initial clock direction + channel_update_dir(i); +} + + +ISR(TCC1_OVF_vect) { + printf("%ld,%ld,%ld,%ld\n", + channel_read(0), channel_read(1), channel_read(2), channel_read(3)); +} + + +static void _splash(uint8_t addr) { + lcd_init(addr); + lcd_goto(addr, 5, 1); + lcd_pgmstr(addr, PSTR("Step Test")); +} + + +static void init() { + cli(); + + hw_init(); + usart_init(); + for (int i = 0; i < 4; i++) channel_init(i); + + // Configure clock + TCC1.INTCTRLA = TC_OVFINTLVL_LO_gc; + TCC1.PER = F_CPU / 256 * 0.01; // 10ms + TCC1.CTRLA = TC_CLKSEL_DIV256_gc; + + sei(); +} + + +int main() { + init(); + + _splash(0x27); + _splash(0x3f); + + while (true) continue; + + return 0; +} diff --git a/src/avr/test/firmware-test.c b/src/avr/test/firmware-test.c index ae51a31..5e5b3a0 100644 --- a/src/avr/test/firmware-test.c +++ b/src/avr/test/firmware-test.c @@ -36,7 +36,7 @@ #include -int main(int argc, char *argv[]) { +int main() { axis_map_motors(); exec_init(); // motion exec vars_init(); // configuration variables diff --git a/src/py/bbctrl/Mach.py b/src/py/bbctrl/Mach.py index 443ad74..b162dba 100644 --- a/src/py/bbctrl/Mach.py +++ b/src/py/bbctrl/Mach.py @@ -115,7 +115,7 @@ class Mach(Comm): # Continue after seek hold if (self.ctrl.state.get('pr', '') == 'Switch found' and self.planner.is_synchronizing()): - self.unpause() + self._unpause() # Continue after stop hold if self.ctrl.state.get('pr', '') == 'User stop': diff --git a/src/resources/favicon.ico b/src/resources/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..f71dc1e62fa41fdad5e6ab5cb9ccda9f6d8e0215 GIT binary patch literal 32038 zcmeHQ4R}=5nH~#W+rk!VS^KO@g=*z#cdgRy(p_poGLuAvbz7guU8E{#*NQHv#VSAk zm8^;gB!hrLMO3IFBqRYF!mmmA)qv!00tu<)57s0kA<4|-XOc{E_WjPi=gyrwbLS_S znM{#+o-f}y=bm%E_dVyk=bn4-IX4EwHHMLf_;>^KM8l6v2E&~OgJJSyDZb+tgW)Np zO`Isl#~KXRKW;FLg{J(Ek2DzamKqE{LK#$HNQO{)xPM8R_HCv=o^LUxmd*^sR#Jw| zkd$e=Cw^5?Lj1}ipGAysoHZENlzrD|wroKCCn4zw|C7%`5k3h1MW&7C8L*)@eE*0$ z{gN^}I*qG~FZs?b9ZmdG^(zv$Hmoph{9>hX&6y3xb!W!}QZ^EKg5ghi&<1N! zhJimrUoP>75&4;rgm-GGotg2CGymeRT%?W%%Afik@&nE#vqR!fT-H~NHm)t#g)6v| zR`LJ2Zh;6NQ1SmCf2P49&x3zz=^uTSL;jZ`&y#@vOYoUj(Eoq$t4t)11cw#pZ4~M zZ4jv)T>4=xROAVSe+%*rK>m@+Lu;#vx;QYVL$v(YYJnn8Ap9>PpF>+Vn&ZHm=7s+% zEoS67$@967fA6dFC1rJ7fJ8Naa3H^&45^3MA$<^S|M$wr=(v!6p3j}X6Jwx55p&sq z(OgF3qASfkT#sj>x5vF&pl-H^hruJ8bMfS@Z3oY|JAdigAzcds4W~z(u*M*`?;SS& zW=nb-j}J<+I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