Minimal Changes
This commit is contained in:
23
sketches/led-driver/Makefile
Normal file
23
sketches/led-driver/Makefile
Normal file
@ -0,0 +1,23 @@
|
||||
CFLAGS = -O3 -Wall --std=c11
|
||||
CHIP = 328p
|
||||
SOURCE_FILES = $(wildcard *.c)
|
||||
OBJ_FILES = $(SOURCE_FILES:%.c=%.o)
|
||||
BIN = led-driver.bin
|
||||
HEX = led-driver.hex
|
||||
|
||||
default: $(HEX)
|
||||
|
||||
%.o: %.c
|
||||
avr-gcc $(CFLAGS) -mmcu=atmega$(CHIP) -o $@ $<
|
||||
|
||||
$(BIN): $(OBJ_FILES)
|
||||
avr-gcc $(CFLAGS) -o $@ $^
|
||||
|
||||
$(HEX): $(BIN)
|
||||
avr-objcopy -O ihex -j .text -j .data $^ $@
|
||||
|
||||
flash: $(HEX)
|
||||
avrdude -p m$(CHIP) -c arduino -B 115200 -P /dev/ttyACM0 -v -v -e flash:w:$(HEX):a
|
||||
|
||||
clean:
|
||||
$(RM) $(OBJ_FILES) $(BIN) $(HEX)
|
81
sketches/led-driver/a.hex
Normal file
81
sketches/led-driver/a.hex
Normal file
@ -0,0 +1,81 @@
|
||||
:100000000C9434000C943E000C943E000C943E0082
|
||||
:100010000C943E000C943E000C943E000C943E0068
|
||||
:100020000C943E000C943E000C943E000C943E0058
|
||||
:100030000C943E000C943E000C943E000C943E0048
|
||||
:100040000C943E000C943E000C943E000C943E0038
|
||||
:100050000C943E000C943E000C943E000C943E0028
|
||||
:100060000C943E000C943E0011241FBECFEFD8E04C
|
||||
:10007000DEBFCDBF0E9440000C9477020C940000BC
|
||||
:1000800081E087B988B9000000000000000000008E
|
||||
:10009000000018B800000000000000000000000090
|
||||
:1000A0000000000000000000000000000000000050
|
||||
:1000B000000088B9000000000000000000000000FF
|
||||
:1000C00018B8000000000000000000000000000060
|
||||
:1000D0000000000000000000000000000000000020
|
||||
:1000E00088B900000000000000000000000018B8FF
|
||||
:1000F0000000000000000000000000000000000000
|
||||
:10010000000000000000000000000000000088B9AE
|
||||
:1001100000000000000000000000000018B800000F
|
||||
:1001200000000000000000000000000000000000CF
|
||||
:1001300000000000000000000000000088B900007E
|
||||
:100140000000000000000000000018B800000000DF
|
||||
:10015000000000000000000000000000000000009F
|
||||
:100160000000000000000000000088B9000000004E
|
||||
:10017000000000000000000018B8000000000000AF
|
||||
:10018000000000000000000000000000000000006F
|
||||
:10019000000000000000000088B90000000000001E
|
||||
:1001A00000000000000018B800000000000000007F
|
||||
:1001B000000000000000000000000000000000003F
|
||||
:1001C00000000000000088B90000000000000000EE
|
||||
:1001D0000000000018B8000000000000000000004F
|
||||
:1001E000000000000000000000000000000000000F
|
||||
:1001F0000000000088B900000000000000000000BE
|
||||
:10020000000018B80000000000000000000000001E
|
||||
:1002100000000000000000000000000000000000DE
|
||||
:10022000000088B90000000000000000000000008D
|
||||
:1002300018B80000000000000000000000000000EE
|
||||
:1002400000000000000000000000000000000000AE
|
||||
:1002500088B900000000000000000000000018B88D
|
||||
:10026000000000000000000000000000000000008E
|
||||
:10027000000000000000000000000000000088B93D
|
||||
:1002800000000000000000000000000018B800009E
|
||||
:10029000000000000000000000000000000000005E
|
||||
:1002A00000000000000000000000000088B900000D
|
||||
:1002B0000000000000000000000018B8000000006E
|
||||
:1002C000000000000000000000000000000000002E
|
||||
:1002D0000000000000000000000088B900000000DD
|
||||
:1002E000000000000000000018B80000000000003E
|
||||
:1002F00000000000000000000000000000000000FE
|
||||
:10030000000000000000000088B9000000000000AC
|
||||
:1003100000000000000018B800000000000000000D
|
||||
:1003200000000000000000000000000000000000CD
|
||||
:1003300000000000000088B900000000000000007C
|
||||
:100340000000000018B800000000000000000000DD
|
||||
:10035000000000000000000000000000000000009D
|
||||
:100360000000000088B9000000000000000000004C
|
||||
:10037000000000000000000000000000000000007D
|
||||
:10038000000018B80000000000000000000000009D
|
||||
:100390000000000088B9000000000000000000001C
|
||||
:1003A000000000000000000000000000000000004D
|
||||
:1003B000000018B80000000000000000000000006D
|
||||
:1003C0000000000088B900000000000000000000EC
|
||||
:1003D000000000000000000000000000000000001D
|
||||
:1003E000000018B80000000000000000000000003D
|
||||
:1003F0000000000088B900000000000000000000BC
|
||||
:1004000000000000000000000000000000000000EC
|
||||
:10041000000018B80000000000000000000000000C
|
||||
:100420000000000088B9000000000000000000008B
|
||||
:1004300000000000000000000000000000000000BC
|
||||
:10044000000018B8000000000000000000000000DC
|
||||
:100450000000000088B9000000000000000000005B
|
||||
:10046000000000000000000000000000000000008C
|
||||
:10047000000018B8000000000000000000000000AC
|
||||
:100480000000000088B9000000000000000000002B
|
||||
:10049000000000000000000000000000000000005C
|
||||
:1004A000000018B80000000000000000000000007C
|
||||
:1004B0000000000088B900000000000000000000FB
|
||||
:1004C000000000000000000000000000000000002C
|
||||
:1004D000000018B80000000000000000000000004C
|
||||
:1004E0000000000090E19A95F1F700C0CBCDF894A0
|
||||
:0204F000FFCF3C
|
||||
:00000001FF
|
BIN
sketches/led-driver/a.out
Executable file
BIN
sketches/led-driver/a.out
Executable file
Binary file not shown.
BIN
sketches/led-driver/led-driver.bin
Executable file
BIN
sketches/led-driver/led-driver.bin
Executable file
Binary file not shown.
54
sketches/led-driver/led-driver.c
Normal file
54
sketches/led-driver/led-driver.c
Normal file
@ -0,0 +1,54 @@
|
||||
#define F_CPU 1000000UL
|
||||
#include <stdint.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
/*
|
||||
// f=20MHz -> T=0,05 µs
|
||||
uint8_t T0H = 6; // == 0.3 µs ~ 0.4 µs (+- 150ns) == [0.25, 0.55] µs
|
||||
uint8_t T1H = 14; // == 0.7 µs ~ 0.8 µs (+- 150ns) == [0.65, 0.95] µs
|
||||
uint8_t T0L = 15; // == 0.75 µs ~ 0.85µs (+- 150ns) == [0.70, 1.00] µs
|
||||
uint8_t T1L = 8; // == 0.35 µs ~ 0.45µs (+- 150ns) == [0.30, 0.60] µs
|
||||
uint8_t RES = 51; // > 50 µs
|
||||
*/
|
||||
|
||||
#define wait6 __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t")
|
||||
#define wait8 __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t")
|
||||
#define wait14 __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t")
|
||||
#define wait15 __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t")
|
||||
|
||||
inline void writeZero() {
|
||||
PORTB = 1;
|
||||
wait6;
|
||||
PORTB = 0;
|
||||
wait15;
|
||||
}
|
||||
|
||||
inline void writeOne() {
|
||||
PORTB = 1;
|
||||
wait14;
|
||||
PORTB = 0;
|
||||
wait8;
|
||||
}
|
||||
|
||||
int main2() {
|
||||
DDRB = 1; // PORT C0 output
|
||||
|
||||
do{
|
||||
writeZero();writeZero();writeZero();writeZero();writeZero();writeZero();writeZero();writeZero();
|
||||
writeZero();writeZero();writeZero();writeZero();writeZero();writeZero();writeZero();writeZero();
|
||||
writeOne();writeOne();writeOne();writeOne();writeOne();writeOne();writeOne();writeOne();
|
||||
_delay_ms(1);
|
||||
}while(1);
|
||||
}
|
||||
|
||||
int main( void )
|
||||
{
|
||||
DDRC |= (1 << PC0);
|
||||
|
||||
while(1) {
|
||||
PORTC ^= (1 << PC0);
|
||||
_delay_ms(1000);
|
||||
}
|
||||
return 0;
|
||||
}
|
83
sketches/led-driver/led-driver.hex
Normal file
83
sketches/led-driver/led-driver.hex
Normal file
@ -0,0 +1,83 @@
|
||||
:100000000C9434000C943E000C943E000C943E0082
|
||||
:100010000C943E000C943E000C943E000C943E0068
|
||||
:100020000C943E000C943E000C943E000C943E0058
|
||||
:100030000C943E000C943E000C943E000C943E0048
|
||||
:100040000C943E000C943E000C943E000C943E0038
|
||||
:100050000C943E000C943E000C943E000C943E0028
|
||||
:100060000C943E000C943E0011241FBECFEFD8E04C
|
||||
:10007000DEBFCDBF0E9479020C9488020C94000070
|
||||
:1000800081E084B985B90000000000000000000094
|
||||
:10009000000015B800000000000000000000000093
|
||||
:1000A0000000000000000000000000000000000050
|
||||
:1000B000000085B900000000000000000000000002
|
||||
:1000C00015B8000000000000000000000000000063
|
||||
:1000D0000000000000000000000000000000000020
|
||||
:1000E00085B900000000000000000000000015B805
|
||||
:1000F0000000000000000000000000000000000000
|
||||
:10010000000000000000000000000000000085B9B1
|
||||
:1001100000000000000000000000000015B8000012
|
||||
:1001200000000000000000000000000000000000CF
|
||||
:1001300000000000000000000000000085B9000081
|
||||
:100140000000000000000000000015B800000000E2
|
||||
:10015000000000000000000000000000000000009F
|
||||
:100160000000000000000000000085B90000000051
|
||||
:10017000000000000000000015B8000000000000B2
|
||||
:10018000000000000000000000000000000000006F
|
||||
:10019000000000000000000085B900000000000021
|
||||
:1001A00000000000000015B8000000000000000082
|
||||
:1001B000000000000000000000000000000000003F
|
||||
:1001C00000000000000085B90000000000000000F1
|
||||
:1001D0000000000015B80000000000000000000052
|
||||
:1001E000000000000000000000000000000000000F
|
||||
:1001F0000000000085B900000000000000000000C1
|
||||
:10020000000015B800000000000000000000000021
|
||||
:1002100000000000000000000000000000000000DE
|
||||
:10022000000085B900000000000000000000000090
|
||||
:1002300015B80000000000000000000000000000F1
|
||||
:1002400000000000000000000000000000000000AE
|
||||
:1002500085B900000000000000000000000015B893
|
||||
:10026000000000000000000000000000000000008E
|
||||
:10027000000000000000000000000000000085B940
|
||||
:1002800000000000000000000000000015B80000A1
|
||||
:10029000000000000000000000000000000000005E
|
||||
:1002A00000000000000000000000000085B9000010
|
||||
:1002B0000000000000000000000015B80000000071
|
||||
:1002C000000000000000000000000000000000002E
|
||||
:1002D0000000000000000000000085B900000000E0
|
||||
:1002E000000000000000000015B800000000000041
|
||||
:1002F00000000000000000000000000000000000FE
|
||||
:10030000000000000000000085B9000000000000AF
|
||||
:1003100000000000000015B8000000000000000010
|
||||
:1003200000000000000000000000000000000000CD
|
||||
:1003300000000000000085B900000000000000007F
|
||||
:100340000000000015B800000000000000000000E0
|
||||
:10035000000000000000000000000000000000009D
|
||||
:100360000000000085B9000000000000000000004F
|
||||
:10037000000000000000000000000000000000007D
|
||||
:10038000000015B8000000000000000000000000A0
|
||||
:100390000000000085B9000000000000000000001F
|
||||
:1003A000000000000000000000000000000000004D
|
||||
:1003B000000015B800000000000000000000000070
|
||||
:1003C0000000000085B900000000000000000000EF
|
||||
:1003D000000000000000000000000000000000001D
|
||||
:1003E000000015B800000000000000000000000040
|
||||
:1003F0000000000085B900000000000000000000BF
|
||||
:1004000000000000000000000000000000000000EC
|
||||
:10041000000015B80000000000000000000000000F
|
||||
:100420000000000085B9000000000000000000008E
|
||||
:1004300000000000000000000000000000000000BC
|
||||
:10044000000015B8000000000000000000000000DF
|
||||
:100450000000000085B9000000000000000000005E
|
||||
:10046000000000000000000000000000000000008C
|
||||
:10047000000015B8000000000000000000000000AF
|
||||
:100480000000000085B9000000000000000000002E
|
||||
:10049000000000000000000000000000000000005C
|
||||
:1004A000000015B80000000000000000000000007F
|
||||
:1004B0000000000085B900000000000000000000FE
|
||||
:1004C000000000000000000000000000000000002C
|
||||
:1004D000000015B80000000000000000000000004F
|
||||
:1004E00000000000E9EFF0E03197F1F700C00000F4
|
||||
:1004F000C9CD389A91E088B1892788B92FE33DE0CA
|
||||
:1005000083E0215030408040E1F700C00000F3CF8D
|
||||
:04051000F894FFCF8D
|
||||
:00000001FF
|
BIN
sketches/led-driver/led-driver.o
Executable file
BIN
sketches/led-driver/led-driver.o
Executable file
Binary file not shown.
Reference in New Issue
Block a user