############################################################################
# Below here nothing should be changed...
+RESET_TTY_DIR=../reset_tty/
+RESET_TTY=$(RESET_TTY_DIR)reset_tty
ARDUINO = $(INSTALL_DIR)/hardware/cores/arduino
AVR_TOOLS_PATH = /usr/bin
SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
sym: applet/$(TARGET).sym
# Program the device.
-upload: applet/$(TARGET).hex
+upload: applet/$(TARGET).hex $(RESET_TTY)
+ $(RESET_TTY) $(PORT)
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
+$(RESET_TTY):
+ make -C $(RESET_TTY_DIR)
# Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex
--- /dev/null
+
+TARGET=reset_tty
+
+all: reset_tty
+
+.PHONY: clean
+
+clean:
+ rm -f $(TARGET)
--- /dev/null
+#include <stdlib.h>
+#include <termios.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <time.h>
+#include <stdio.h>
+#include <sys/select.h>
+
+#define STATE_OFF 0
+#define STATE_ON 1
+
+void setDTRState (int fd, int state) {
+ int flags;
+
+ ioctl(fd, TIOCMGET, &flags);
+ flags = (state == STATE_ON ? flags | TIOCM_DTR : flags & ~TIOCM_DTR);
+ ioctl(fd, TIOCMSET, &flags);
+}
+
+int
+main(int argc, char* argv[])
+{
+ char* device = argc < 2 ? "/dev/ttyUSB0" : argv[1];
+ int fd = open(device, O_RDWR);
+ if (fd == 0) {
+ fprintf(stderr, "Could not open %s\n", device);
+ return EXIT_FAILURE;
+ }
+
+ setDTRState(fd, STATE_ON);
+ struct timeval sleeptime = {0, 100000}; // 100ms
+ select(0, NULL, NULL, NULL, &sleeptime);
+ setDTRState(fd, STATE_OFF);
+ sleeptime.tv_sec = 0;
+ sleeptime.tv_usec = 100000;
+ select(0, NULL, NULL, NULL, &sleeptime);
+ setDTRState(fd, STATE_ON);
+ close(fd);
+
+ return EXIT_SUCCESS;
+}
+
############################################################################
# Below here nothing should be changed...
+RESET_TTY_DIR=../reset_tty/
+RESET_TTY=$(RESET_TTY_DIR)reset_tty
ARDUINO = $(INSTALL_DIR)/hardware/cores/arduino
AVR_TOOLS_PATH = /usr/bin
SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
sym: applet/$(TARGET).sym
# Program the device.
-upload: applet/$(TARGET).hex reset_tty
- ./reset_tty
+upload: applet/$(TARGET).hex $(RESET_TTY)
+ $(RESET_TTY) $(PORT)
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
>> $(MAKEFILE); \
$(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
-reset_tty: reset_tty.c
- $(CC) -L /usr/lib/ -L /lib -I /usr/include/ -o reset_tty reset_tty.c
+$(RESET_TTY):
+ make -C $(RESET_TTY_DIR)
.PHONY: all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter
+++ /dev/null
-#include <stdlib.h>
-#include <termios.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <time.h>
-#include <stdio.h>
-#include <sys/select.h>
-
-#define STATE_OFF 0
-#define STATE_ON 1
-
-void setDTRState (int fd, int state) {
- int flags;
-
- ioctl(fd, TIOCMGET, &flags);
- flags = (state == STATE_ON ? flags | TIOCM_DTR : flags & ~TIOCM_DTR);
- ioctl(fd, TIOCMSET, &flags);
-}
-
-int
-main(int argc, char* argv[])
-{
- char* device = argc < 2 ? "/dev/ttyUSB0" : argv[1];
- int fd = open(device, O_RDWR);
- if (fd == 0) {
- fprintf(stderr, "Could not open %s\n", device);
- return EXIT_FAILURE;
- }
-
- setDTRState(fd, STATE_ON);
- struct timeval sleeptime = {0, 100000}; // 100ms
- select(0, NULL, NULL, NULL, &sleeptime);
- setDTRState(fd, STATE_OFF);
- sleeptime.tv_sec = 0;
- sleeptime.tv_usec = 100000;
- select(0, NULL, NULL, NULL, &sleeptime);
- setDTRState(fd, STATE_ON);
- close(fd);
-
- return EXIT_SUCCESS;
-}
-