From d8c11c3841ffb8be42213a851b523bc0081303fb Mon Sep 17 00:00:00 2001 From: ajasts Date: Mon, 3 Mar 2025 10:39:42 +0200 Subject: [PATCH 1/2] Fixed debugging issue, now breakpoints work --- lab1/Makefile | 3 +-- lab2/Makefile | 7 +++---- lab3/Makefile | 9 ++++----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lab1/Makefile b/lab1/Makefile index 67420fe..12a7431 100644 --- a/lab1/Makefile +++ b/lab1/Makefile @@ -20,7 +20,6 @@ CFLAGS = -I.. -I../inc \ -mfpu=fpv4-sp-d16 \ -ffunction-sections \ -fdata-sections \ - -g \ -gstrict-dwarf \ -Wall \ -I$(ARMGCC_ROOT)/arm-none-eabi/include/newlib-nano \ @@ -43,7 +42,7 @@ LFLAGS = -Wl,-T,../config.lds \ all: $(NAME).out main.o: main.c - @$(CC) $(CFLAGS) $< -c -o $@ + @$(CC) $(CFLAGS) -g $< -c -o $@ system.o: ../system.c @$(CC) $(CFLAGS) $< -c -o $@ diff --git a/lab2/Makefile b/lab2/Makefile index bdbe9ae..06c5834 100644 --- a/lab2/Makefile +++ b/lab2/Makefile @@ -20,7 +20,6 @@ CFLAGS = -I.. -I../inc -I../common \ -mfpu=fpv4-sp-d16 \ -ffunction-sections \ -fdata-sections \ - -g \ -gstrict-dwarf \ -Wall \ -I$(ARMGCC_ROOT)/arm-none-eabi/include/newlib-nano \ @@ -43,13 +42,13 @@ LFLAGS = -Wl,-T,../config.lds \ all: $(NAME).out main.o: main.c - @$(CC) $(CFLAGS) $< -c -o $@ + @$(CC) $(CFLAGS) -g $< -c -o $@ bump.o: ../common/bump.c - @$(CC) $(CFLAGS) $< -c -o $@ + @$(CC) $(CFLAGS) -g $< -c -o $@ delay.o: ../common/delay.c - @$(CC) $(CFLAGS) $< -c -o $@ + @$(CC) $(CFLAGS) -g $< -c -o $@ clock.o: ../common/clock.c @$(CC) $(CFLAGS) $< -c -o $@ diff --git a/lab3/Makefile b/lab3/Makefile index baf7de6..8cd1e5a 100644 --- a/lab3/Makefile +++ b/lab3/Makefile @@ -20,7 +20,6 @@ CFLAGS = -I.. -I../inc -I../common \ -mfpu=fpv4-sp-d16 \ -ffunction-sections \ -fdata-sections \ - -g \ -gstrict-dwarf \ -Wall \ -I$(ARMGCC_ROOT)/arm-none-eabi/include/newlib-nano \ @@ -43,19 +42,19 @@ LFLAGS = -Wl,-T,../config.lds \ all: $(NAME).out main.o: main.c - @$(CC) $(CFLAGS) $< -c -o $@ + @$(CC) $(CFLAGS) -g $< -c -o $@ bump.o: ../common/bump.c - @$(CC) $(CFLAGS) $< -c -o $@ + @$(CC) $(CFLAGS) -g $< -c -o $@ delay.o: ../common/delay.c - @$(CC) $(CFLAGS) $< -c -o $@ + @$(CC) $(CFLAGS) -g $< -c -o $@ clock.o: ../common/clock.c @$(CC) $(CFLAGS) $< -c -o $@ reflectance.o: ../common/reflectance.c - @$(CC) $(CFLAGS) $< -c -o $@ + @$(CC) $(CFLAGS) -g $< -c -o $@ cpu.o: ../common/cpu.c @$(CC) $(CFLAGS) $< -c -o $@ From 57c882325edcec6e1ab3bdadd59a6e4b55510fa5 Mon Sep 17 00:00:00 2001 From: Hladu357 Date: Tue, 25 Feb 2025 17:27:42 +0200 Subject: [PATCH 2/2] lab1 --- lab1/main.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/lab1/main.c b/lab1/main.c index 3376c07..e462159 100644 --- a/lab1/main.c +++ b/lab1/main.c @@ -173,9 +173,66 @@ int main3(void) { } // Your solution here +void initRedLED(void) { + P1->SEL0 &= ~0x01; + P1->SEL1 &= ~0x01; // 1) configure P1.0 as GPIO + P1->DIR |= 0x01; // 2) make P1.0 output +} + +void initColorLED(void) { + P2->SEL0 &= ~0x07; + P2->SEL1 &= ~0x07; // 1) configure P2.2-P2.0 as GPIO + P2->DIR |= 0x07; // 2) make P2.2-P2.0 out + P2->DS |= 0x07; // 3) activate increased drive strength + P2->OUT &= ~0x07; // 4) all LEDs off +} + +void initInput(void) { + P1->SEL0 &= ~(SW1 | SW2); + P1->SEL1 &= ~(SW1 | SW2); // 1) configure P1.4 P1.1 P1.0 as GPIO + P1->DIR &= ~(SW1 | SW2); // 2) SW1 and SW2 input + P1->REN |= (SW1 | SW2); // 4) enable pull resistors on P1.4 and P1.1 +} + +// read P1.4, P1.1 inputs +uint8_t inP1(void) { + return P1->IN & (SW1 | SW2); +} + +// write one output bit to P1 +void outP1(uint8_t data) { + P1->OUT = (P1->OUT & ~0x01) | data; +} + +// write three outputs bits to P2 +void outP2(uint8_t data) { + P2->OUT = (P2->OUT & ~0x07) | data; +} + int main(void) { - + initRedLED(); + initColorLED(); + initInput(); + + outP2(0); while (true) { - + uint8_t switches = inP1() ^ (SW1 | SW2); + switch (switches) { + case SW1: + outP1(RED); + outP2(BLUE); + break; + case SW2: + outP1(RED); + outP2(GREEN); + break; + case SW1 | SW2: + outP1(0); + outP2(RED); + break; + default: + outP1(0); + outP2(BLUE | GREEN); + } } } \ No newline at end of file