From: Pat Thoyts Date: Fri, 3 May 2019 20:17:36 +0000 (+0100) Subject: Support gcc inline and unix builds X-Git-Url: http://privyetmir.co.uk/gitweb?a=commitdiff_plain;h=1660be637293eef51824a33288ca7eb64f1b0fbb;p=avr%2Ftimer-serial.git Support gcc inline and unix builds --- diff --git a/Makefile b/Makefile index 75fbc86..34cdbe8 100644 --- a/Makefile +++ b/Makefile @@ -4,15 +4,22 @@ PROJECT := timer-serial 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) @@ -30,7 +37,7 @@ all: $(PROJECT).hex %.hex: %.elf $(QUIET_OBJCOPY) -j .text -j .data -O ihex $< $@ - + %.elf: $(OBJS) $(QUIET_LD) $(LDFLAGS) $^ $(LIBS) -o $@ @@ -41,7 +48,7 @@ flash: $(PROJECT).hex $(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) diff --git a/timer-serial.c b/timer-serial.c index c164450..e23700a 100644 --- a/timer-serial.c +++ b/timer-serial.c @@ -13,19 +13,19 @@ #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; @@ -33,7 +33,7 @@ inline void pwm_on(void) TCNT0 = 0; sei(); } -inline int pwm_is_enabled(void) +static inline int pwm_is_enabled(void) { return bit_is_set(TCCR0A, COM0B1); }