aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvg <vgm+dev@devys.org>2022-07-01 22:44:55 +0200
committervg <vgm+dev@devys.org>2022-07-01 22:44:55 +0200
commitecc4e90c3b33179d8eeefdbbb3c083893d3a1c5c (patch)
tree73312b7c7a9f9eb3b3480cfc9c7c1ffe26419d27
parent1bd2ef3624cebfa6dd08613b00b3a2491c9dbdae (diff)
downloadavr-ecc4e90c3b33179d8eeefdbbb3c083893d3a1c5c.tar.gz
avr-ecc4e90c3b33179d8eeefdbbb3c083893d3a1c5c.tar.bz2
avr-ecc4e90c3b33179d8eeefdbbb3c083893d3a1c5c.zip
new program to wakeup ampli with timer
-rw-r--r--avr-attiny25-ampli-wakeup-delay/Makefile41
-rw-r--r--avr-attiny25-ampli-wakeup-delay/main.c23
2 files changed, 64 insertions, 0 deletions
diff --git a/avr-attiny25-ampli-wakeup-delay/Makefile b/avr-attiny25-ampli-wakeup-delay/Makefile
new file mode 100644
index 0000000..14bc95e
--- /dev/null
+++ b/avr-attiny25-ampli-wakeup-delay/Makefile
@@ -0,0 +1,41 @@
+# settings for arduino uno
+DEVICE = attiny25
+CLOCK = 1000000
+
+# buspirate programmer
+PORT=/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A400XJSH-if00-port0
+AVRDUDE=avrdude -p $(DEVICE) -c buspirate -P $(PORT)
+
+DEFS = -DF_CPU=$(CLOCK)UL
+LIBS = -Wl,--relax,--gc-sections,--print-gc-sections,--entry=main
+LIBS = -Wl,--entry=main,--gc-sections,--rela
+CFLAGS = -Wall -Werror -pedantic
+#-std=c99 // default should be gnu99 nowaday, no need to specify c99
+CFLAGS += -Os -funsigned-bitfields -fpack-struct -fshort-enums
+CFLAGS += -mmcu=$(DEVICE) $(DEFS)
+#LDFLAGS = $(LIBS)
+
+all: main.hex size
+
+main.hex: main.c
+ avr-gcc -o main.elf $? $(CFLAGS) $(LDFLAGS)
+ avr-objcopy -j .text -j .data -O ihex main.elf main.hex
+
+f: flash
+flash: all
+ $(AVRDUDE) -U flash:w:main.hex:i
+
+dumpfuses:
+ $(AVRDUDE) -U lfuse:r:lfuse.txt:h
+ $(AVRDUDE) -U hfuse:r:hfuse.txt:h
+ $(AVRDUDE) -U efuse:r:efuse.txt:h
+
+clean:
+ rm -f *.o *.elf *.hex
+
+size:
+ avr-size --mcu=$(DEVICE) -t -A main.elf
+ avr-size --mcu=$(DEVICE) -C main.elf
+ avr-nm --size-sort main.elf
+
+
diff --git a/avr-attiny25-ampli-wakeup-delay/main.c b/avr-attiny25-ampli-wakeup-delay/main.c
new file mode 100644
index 0000000..6fb530e
--- /dev/null
+++ b/avr-attiny25-ampli-wakeup-delay/main.c
@@ -0,0 +1,23 @@
+#include <avr/io.h>
+#include <util/delay.h>
+
+int main(void)
+{
+ /* PB4 output */
+ DDRB |= _BV(4);
+ PORTB &= ~_BV(4);
+
+ //for (;;)
+ //{
+ // _delay_ms(1000);
+ // PORTB ^= _BV(4);
+ //}
+
+ // wait for 45s and enable the amplifier
+ for (uint8_t i = 0; i < 32; ++i) {
+ _delay_ms(1000);
+ }
+ PORTB |= _BV(4);
+
+ return 0;
+}