Plain C AVR library for ST7735 displays
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.1 KiB

3 years ago
5 years ago
5 years ago
5 years ago
  1. AVRMCU ?= atmega8
  2. F_CPU ?= 16000000
  3. ISPPORT ?= /dev/kaboard
  4. VERSION = 0.2
  5. HEADERS = include/spi.h include/st7735.h include/st7735initcmds.h
  6. HEADERS += images/logo_bw.h images/logo.h include/st7735_gfx.h
  7. HEADERS += include/st7735_font.h fonts/tom_thumb.h fonts/free_sans.h
  8. SRC = main.c spi.c st7735.c st7735_gfx.c st7735_font.c
  9. TARGET = st7735_test
  10. OBJDIR = bin
  11. LIB_TARGET = libst7735
  12. LIB_SRC = spi.c st7735.c st7735_gfx.c st7735_font.c
  13. CC = avr-gcc
  14. AR = ar
  15. OBJCOPY = avr-objcopy
  16. OBJDUMP = avr-objdump
  17. SIZE = avr-size
  18. SRC_TMP = $(subst ../,,$(SRC))
  19. OBJ = $(SRC_TMP:%.c=$(OBJDIR)/$(AVRMCU)/%.o)
  20. LIB_SRC_TMP = $(subst ../,,$(LIB_SRC))
  21. LIB_OBJ = $(LIB_SRC_TMP:%.c=$(OBJDIR)/$(AVRMCU)/%.o)
  22. CFLAGS = -I include -I images -I fonts -Os -Wall -Wstrict-prototypes --std=c99
  23. CFLAGS += -ffunction-sections -fdata-sections
  24. CFLAGS += -fshort-enums -fpack-struct -funsigned-char -funsigned-bitfields
  25. CFLAGS += -mmcu=$(AVRMCU) -DF_CPU=$(F_CPU)UL -DVERSION=$(VERSION)
  26. LDFLAGS = -mmcu=$(AVRMCU) -Wl,--gc-sections
  27. ARFLAGS = -rc
  28. all: start $(OBJDIR)/$(AVRMCU)/$(TARGET).hex $(OBJDIR)/$(AVRMCU)/$(LIB_TARGET).a size
  29. @echo ":: Done !"
  30. start:
  31. @echo "ST7735 for AVR $(VERSION)"
  32. @echo "=========================="
  33. @echo ":: Building for $(AVRMCU)"
  34. @echo ":: MCU operating frequency is $(F_CPU)Hz"
  35. images/logo.h : images/logo.png utils/img_convert.py
  36. python3 utils/img_convert.py $< $@
  37. images/logo_bw.h : images/logo_bw.png utils/img_convert_mono.py
  38. python3 utils/img_convert_mono.py $< $@
  39. $(OBJDIR)/$(AVRMCU)/%.o : %.c $(HEADERS) Makefile
  40. @mkdir -p $$(dirname $@)
  41. $(CC) $(CFLAGS) -c $< -o $@
  42. $(OBJDIR)/$(AVRMCU)/$(TARGET).elf : $(OBJ)
  43. $(CC) $(LDFLAGS) $+ -o $@
  44. $(OBJDIR)/$(AVRMCU)/$(LIB_TARGET).a : $(LIB_OBJ)
  45. $(AR) $(ARFLAGS) $@ $+
  46. $(OBJDIR)/$(AVRMCU)/$(TARGET).hex : $(OBJDIR)/$(AVRMCU)/$(TARGET).elf
  47. $(OBJCOPY) -O ihex $< $@
  48. size : $(OBJDIR)/$(AVRMCU)/$(TARGET).elf
  49. @echo
  50. @$(SIZE) --mcu=$(AVRMCU) -C $(OBJDIR)/$(AVRMCU)/$(TARGET).elf
  51. @echo
  52. clean :
  53. @rm -rf $(OBJDIR)
  54. @rm images/*.h
  55. flash : all
  56. avrdude -c arduino \
  57. -p $(AVRMCU) -P $(ISPPORT) \
  58. -U flash:w:$(OBJDIR)/$(AVRMCU)/$(TARGET).hex
  59. test : flash
  60. screen $(ISPPORT) 38400