P3 initial

This commit is contained in:
S170H
2023-11-22 18:25:14 +01:00
parent ec783fd3b6
commit be0247a93b
40 changed files with 2406 additions and 303 deletions

View File

@@ -0,0 +1,122 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
SHELL := cmd.exe
RM := rm -rf
USER_OBJS :=
LIBS :=
PROJ :=
O_SRCS :=
C_SRCS :=
S_SRCS :=
S_UPPER_SRCS :=
OBJ_SRCS :=
ASM_SRCS :=
PREPROCESSING_SRCS :=
OBJS :=
OBJS_AS_ARGS :=
C_DEPS :=
C_DEPS_AS_ARGS :=
EXECUTABLES :=
OUTPUT_FILE_PATH :=
OUTPUT_FILE_PATH_AS_ARGS :=
AVR_APP_PATH :=$$$AVR_APP_PATH$$$
QUOTE := "
ADDITIONAL_DEPENDENCIES:=
OUTPUT_FILE_DEP:=
LIB_DEP:=
LINKER_SCRIPT_DEP:=
# Every subdirectory with source files must be described here
SUBDIRS :=
# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../main.c
PREPROCESSING_SRCS +=
ASM_SRCS +=
OBJS += \
main.o
OBJS_AS_ARGS += \
main.o
C_DEPS += \
main.d
C_DEPS_AS_ARGS += \
main.d
OUTPUT_FILE_PATH +=libP2\ Interrups.a
OUTPUT_FILE_PATH_AS_ARGS +="libP2 Interrups.a"
ADDITIONAL_DEPENDENCIES:=
OUTPUT_FILE_DEP:= ./makedep.mk
LIB_DEP+=
LINKER_SCRIPT_DEP+=
# AVR32/GNU C Compiler
./main.o: .././main.c
@echo Building file: $<
@echo Invoking: AVR/GNU C Compiler : 5.4.0
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -x c -funsigned-char -funsigned-bitfields -DDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\include" -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=atmega328p -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\gcc\dev\atmega328p" -c -std=gnu99 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
@echo Finished building: $<
# AVR32/GNU Preprocessing Assembler
# AVR32/GNU Assembler
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif
# Add inputs and outputs from these tool invocations to the build variables
# All Target
all: $(OUTPUT_FILE_PATH) $(ADDITIONAL_DEPENDENCIES)
$(OUTPUT_FILE_PATH): $(OBJS) $(USER_OBJS) $(OUTPUT_FILE_DEP)
@echo Building target: $@
@echo Invoking: AVR/GNU Archiver : 5.4.0
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-ar.exe$(QUOTE) -r -o$(OUTPUT_FILE_PATH_AS_ARGS) $(OBJS_AS_ARGS) $(USER_OBJS) $(LIBS)
@echo Finished building target: $@
# Other Targets
clean:
-$(RM) $(OBJS_AS_ARGS) $(EXECUTABLES)
-$(RM) $(C_DEPS_AS_ARGS)
rm -rf "libP2 Interrups.elf" "libP2 Interrups.a" "libP2 Interrups.hex" "libP2 Interrups.lss" "libP2 Interrups.eep" "libP2 Interrups.map" "libP2 Interrups.srec" "libP2 Interrups.usersignatures"

Binary file not shown.

View File

@@ -0,0 +1,49 @@
main.d main.o: .././main.c \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\inttypes.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdint.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\stdint.h \
C:\Program\ Files\ (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\include/avr/iom328p.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\portpins.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\common.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\version.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\fuse.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\interrupt.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay_basic.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\math.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdbool.h
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\inttypes.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdint.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\stdint.h:
C:\Program\ Files\ (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\include/avr/iom328p.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\portpins.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\common.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\version.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\fuse.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\interrupt.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay_basic.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\math.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdbool.h:

Binary file not shown.

View File

@@ -0,0 +1,6 @@
################################################################################
# Automatically-generated file. Do not edit or delete the file
################################################################################
main.c

View File

@@ -12,55 +12,57 @@
#include <util/delay.h>
#include <stdbool.h> // boolean type and values
#define LED00 PINB0
#define LED09 PINB1
#define SWITCH01 PIND2
#define SWITCH02 PIND3
#define LED0 PINB0
#define LED9 PINB1
#define SW1 PIND2
#define SW2 PIND3
volatile int on = LED00;
volatile int activeLED = LED0;
volatile bool blink = true;
void setupPorts() {
DDRB = 0xff; // Data direction register B (B0 & B1) as output
DDRB = 0xff;
PORTB = 0x00;
DDRD = 0x00; // Data direction register D (D0 & D1) as input
PORTD |= (1 << SWITCH01) | (1 << SWITCH02); // setting bit for switch
//cli(); // clear global interrupt flag: interrupts will be immediately disabled
EICRA |= (1 << ISC11) | (1 << ISC01); // the falling edge of INT1 or INT0 generates an interrupt request.
EIMSK = (1 << INT0) | (1 << INT1); // enable external interrupt request
sei(); // set global interrupt enable
DDRD = 0x00;
PORTD |= (1 << SW1) | (1 << SW2); // Activate pull-up resistors
// Falling edge of INT0 and INT1 generates an interrupt request
EICRA |= (1 << ISC11) | (1 << ISC01);
EIMSK |= (1 << INT0) | (1 << INT1); // Enable external interrupt request
sei(); // Set global interrupt enable
}
// SW1 is pressed
ISR(INT0_vect) {
if (on == LED00) { // if D0 is already on, switching from blink to steady light or vice versa
if (activeLED == LED0) { // if D0 is already on, switching from blink to steady light or vice versa
blink = !blink;
} else { // else D9 is on, turn off D9 and turn on D0
PORTB = (1 << LED00);
}
on = LED00;
else { // else D9 is on, turn off D9 and turn on D0
PORTB = (1 << LED0);
}
activeLED = LED0;
}
// SW2 is pressed
ISR(INT1_vect) {
if (on == LED09) {
if (activeLED == LED9) {
blink = !blink;
} else {
PORTB = (1 << LED09);
}
on = LED09;
else {
PORTB = (1 << LED9);
}
activeLED = LED9;
}
int main(void)
{
/* Replace with your application code */
int main(void) {
setupPorts();
while(1){
while (1) {
if (blink) {
PORTB ^= (1 << on);
} else {
PORTB = (1 << on);
PORTB ^= (1 << activeLED); // Toggle active LED
}
_delay_ms(200);
_delay_ms(50);
}
}