DEVICE := atmega328p
F_CPU := 16000000UL
INC := -I.
-AVRDUDE := avrdude -c usbasp -p $(DEVICE) -C $(AVR_DIR)\etc\avrdude.conf
+AVRDUDE := avrdude -c usbasp -p $(DEVICE) -C $(AVR_DIR)/etc/avrdude.conf
CSRCS = $(PROJECT).c #usart.c
OBJS = $(CSRCS:.c=.o)
+uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
+
CC := avr-gcc
LD := avr-gcc
OBJCOPY := avr-objcopy
+ifeq ($(uname_S),Windows)
RM := del >NUL
+else
+RM := rm -f
+endif
+
CFLAGS :=-Wall -Wstrict-prototypes -Wmissing-prototypes -Wcast-align -Wshadow \
-std=gnu99 -fshort-enums -pedantic-errors -Os -mcall-prologues \
-mmcu=$(DEVICE) -DF_CPU=$(F_CPU)
%.hex: %.elf
$(QUIET_OBJCOPY) -j .text -j .data -O ihex $< $@
-
+
%.elf: $(OBJS)
$(QUIET_LD) $(LDFLAGS) $^ $(LIBS) -o $@
$(QUIET_AVRDUDE) -U flash:w:$<:i
clean:
- -@$(RM) $(addprefix $(PROJECT), .elf .hex)
+ -@$(RM) $(addprefix $(PROJECT), .elf .hex) $(OBJS)
.PHONY: clean
.SECONDARY: $(addsuffix .elf, $(PROJECT)) $(OBJS)
#include "usart.c"
static void init_pwm_pin5(void);
-inline void pwm_off(void);
-inline void pwm_on(void);
-inline int pwm_is_enabled(void);
+static inline void pwm_off(void);
+static inline void pwm_on(void);
+static inline int pwm_is_enabled(void);
/* The overflow interrupt can be used to count PWM pulses if necessary */
volatile uint32_t pwm_cycles = 0;
-inline void pwm_off(void)
+static inline void pwm_off(void)
{
PORTD &= ~_BV(PB5);
TCCR0A &= ~(_BV(COM0B1) | _BV(COM0B0));
}
-inline void pwm_on(void)
+static inline void pwm_on(void)
{
cli();
pwm_cycles = 0;
TCNT0 = 0;
sei();
}
-inline int pwm_is_enabled(void)
+static inline int pwm_is_enabled(void)
{
return bit_is_set(TCCR0A, COM0B1);
}