Skip to content

Commit

Permalink
Add AVR code
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony556 committed Jul 1, 2020
1 parent 7b43f7a commit 0e8c0a9
Show file tree
Hide file tree
Showing 16 changed files with 1,932 additions and 2 deletions.
21 changes: 21 additions & 0 deletions AVR/source/firmware/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 @progmem, @wchill

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
68 changes: 68 additions & 0 deletions AVR/source/firmware/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#
# LUFA Library
# Copyright (C) Dean Camera, 2014.
#
# dean [at] fourwalledcubicle [dot] com
# www.lufa-lib.org
#
# --------------------------------------
# LUFA Project Makefile.
# --------------------------------------

# Run "make help" for target help.

# Set the MCU accordingly to your device (e.g. at90usb1286 for a Teensy 2.0++, or atmega16u2 for an Arduino UNO R3)
MCU = atmega32u4
ARCH = AVR8
F_CPU = 16000000
F_USB = $(F_CPU)
OPTIMIZATION = s
INCLUDE_DIR = include
TARGET = Joystick
SRC_DIR = src
SRC = $(SRC_DIR)/Joystick.c $(LUFA_SRC_USB)
LUFA_PATH = lufa/LUFA
CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -Iinclude/
LD_FLAGS =

EMULATOR_TARGET = emulator
EMULATOR_CC = gcc
EMULATOR_CC_FLAGS = -Iinclude/ -DMOCK_AVR
EMULATOR_OBJ_DIR = emulator_obj
EMULATOR_SRC_FILES := $(wildcard $(SRC_DIR)/*.c)
EMULATOR_OBJ_FILES := $(patsubst $(SRC_DIR)/%.c,$(EMULATOR_OBJ_DIR)/%.o,$(EMULATOR_SRC_FILES))

# Default target
all: $(EMULATOR_TARGET)
# Include LUFA build script makefiles
include $(LUFA_PATH)/Build/lufa_core.mk
include $(LUFA_PATH)/Build/lufa_sources.mk
include $(LUFA_PATH)/Build/lufa_build.mk
include $(LUFA_PATH)/Build/lufa_cppcheck.mk
include $(LUFA_PATH)/Build/lufa_doxygen.mk
include $(LUFA_PATH)/Build/lufa_dfu.mk
include $(LUFA_PATH)/Build/lufa_hid.mk
include $(LUFA_PATH)/Build/lufa_avrdude.mk
include $(LUFA_PATH)/Build/lufa_atprogram.mk

# Target for LED/buzzer to alert when print is done
with-alert: all
with-alert: CC_FLAGS += -DALERT_WHEN_DONE

flash: all
sudo dfu-programmer $(MCU) erase
sudo dfu-programmer $(MCU) flash $(TARGET).hex
sudo dfu-programmer $(MCU) reset

$(EMULATOR_TARGET): $(EMULATOR_OBJ_FILES)
$(EMULATOR_CC) -o $@ $^

$(EMULATOR_OBJ_DIR)/%.o: $(SRC_DIR)/%.c
mkdir -p $(EMULATOR_OBJ_DIR)
$(EMULATOR_CC) $(EMULATOR_CC_FLAGS) -c -o $@ $<

clean-emu:
rm -rf $(EMULATOR_OBJ_DIR) $(EMULATOR_TARGET)

run-emu:
socat -d -d PTY,link=/tmp/faketty0,raw,echo=0 EXEC:./$(EMULATOR_TARGET)
8 changes: 8 additions & 0 deletions AVR/source/firmware/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[LUFA Version Used: 170418](http://www.fourwalledcubicle.com/LUFA.php)

Directory structure:

- source/firmware/lufa/LUFA/
- Build
- CodeTemplates
- ...
5 changes: 5 additions & 0 deletions AVR/source/firmware/include/.directory
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Dolphin]
Timestamp=2020,6,25,3,3,21
Version=4
ViewMode=1
VisibleRoles=Details_text,Details_modificationtime,Details_size,CustomizedDetails
Loading

0 comments on commit 0e8c0a9

Please sign in to comment.