diff --git a/sketches/input/Makefile b/sketches/input/Makefile new file mode 100644 index 0000000..28318bd --- /dev/null +++ b/sketches/input/Makefile @@ -0,0 +1,31 @@ +CFLAGS = -Os -Wall --std=c11 -g +CHIP = atmega328p +SOURCE_FILES = $(wildcard *.c) +OBJ_FILES = $(SOURCE_FILES:%.c=%.o) +BIN = input.bin +HEX = input.hex +ASM = input.asm + +default: $(HEX) + +%.o: %.c + avr-gcc $(CFLAGS) -mmcu=$(CHIP) -o $@ $< + +$(BIN): $(OBJ_FILES) + avr-gcc $(CFLAGS) -o $@ $^ + +$(ASM): $(BIN) + avr-objdump -d -g -l -S $^ > $@ + +$(HEX): $(BIN) + avr-objcopy -O ihex -j .text -j .data $^ $@ + +asm: $(ASM) + +flash: $(HEX) + avrdude -p $(CHIP) -c arduino -B 115200 -P /dev/ttyACM0 -v -v -e -Uflash:w:$(HEX):a + +clean: + $(RM) $(OBJ_FILES) $(BIN) $(HEX) $(ASM) + + diff --git a/sketches/input/input.bin b/sketches/input/input.bin new file mode 100755 index 0000000..d2965bb Binary files /dev/null and b/sketches/input/input.bin differ diff --git a/sketches/input/input.c b/sketches/input/input.c new file mode 100644 index 0000000..c367563 --- /dev/null +++ b/sketches/input/input.c @@ -0,0 +1,50 @@ +#include +#include +#include +#define F_CPU 20000000UL +#include +#include +//~ #define BAUD 9600 +//~ #include +#include + +uint8_t volatile status = 0; + +ISR(INT1_vect){ + status = 1; + //~ PCORT0 = 1; +} + +int main(){ + + //~ PORTD |= (1 << PORTD2); // turn On the Pull-up + // PD2 is now an input with pull-up enabled + + + EICRA |= 0x0F; // External Interrupt Control Register + // INT0 on rising edge + EIMSK |= 0x03; // External Interrupt Mask Register + // Enable INT0 for interrupt + + SREG |= 0x80; // Status Register + // Enable global interrupts + + //~ PCICR |= 0x04; // Pin Change Interrupt Control Register + //~ // Enabled PCINT[23;16] -> Pin 13,12,11,6,5,4,3,2 + //~ PCIFR |= 0x04; // Pin Change Interrupt Flag Register + + //~ PCMSK2 = 0xff; // Pin Change Mask Register 2 + //~ // Enabled PCINT[23;16] (Single Pins) + DDRC = 0xff; + + + + while(1){ + if(status){ + PORTC ^= 0x01; + status = 0; + } + PORTC ^= 0x02; + } + return 0; +} diff --git a/sketches/input/input.hex b/sketches/input/input.hex new file mode 100644 index 0000000..aabeaf9 --- /dev/null +++ b/sketches/input/input.hex @@ -0,0 +1,16 @@ +:100000000C9434000C9446000C9448000C94460068 +:100010000C9446000C9446000C9446000C94460048 +:100020000C9446000C9446000C9446000C94460038 +:100030000C9446000C9446000C9446000C94460028 +:100040000C9446000C9446000C9446000C94460018 +:100050000C9446000C9446000C9446000C94460008 +:100060000C9446000C94460011241FBECFEFD8E03C +:10007000DEBFCDBF21E0A0E0B1E001C01D92A13004 +:10008000B207E1F70E9457000C9473000C94000033 +:100090001F920F920FB60F9211248F9381E08093DD +:1000A00000018F910F900FBE0F901F9018958091B7 +:1000B00069008F60809369008DB383608DBB8FB7BB +:1000C00080688FBF8FEF87B921E092E080910001B7 +:1000D000882329F088B1822788B91092000188B15D +:0A00E000892788B9F3CFF894FFCF09 +:00000001FF diff --git a/sketches/input/input.o b/sketches/input/input.o new file mode 100755 index 0000000..4939671 Binary files /dev/null and b/sketches/input/input.o differ diff --git a/sketches/led-driver/led-driver.c b/sketches/led-driver/led-driver.c index 852e1c3..a8aecb4 100644 --- a/sketches/led-driver/led-driver.c +++ b/sketches/led-driver/led-driver.c @@ -58,14 +58,9 @@ void writeZero(); void writeOne(); void writeRGB(uint8_t red, uint8_t green, uint8_t blue); void writeNothing(uint8_t c); +void mydelay(uint16_t ms); -void mydelay(uint16_t ms) { - while(ms--) { - _delay_loop_2(5000); // 1ms - } -} - -int mainz() +int mainParty() { DDRC = 1; uint8_t d = 14; @@ -91,7 +86,7 @@ int mainz() return 0; } -int main() { +int main(){ DDRC = 1; // PORT C0 output // uart_init(); @@ -220,3 +215,9 @@ void writeNothing(uint8_t c){ } _delay_ms(500); } + +void mydelay(uint16_t ms) { + while(ms--) { + _delay_loop_2(5000); // 1ms + } +}