[merge] ultrasonic into main
This commit is contained in:
@@ -29,7 +29,9 @@ Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "opdracht 2.4", "opdracht 2.
|
||||
EndProject
|
||||
Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "opdracht 3.3", "opdracht 3.3\opdracht 3.3.cproj", "{985D5C75-F61E-49F1-A532-66A1E6141552}"
|
||||
EndProject
|
||||
Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "opdracht 4.1", "opdracht 4.1\opdracht 4.1.cproj", "{2432E6BF-DA1E-4668-99BB-59FEA1F5B8A2}"
|
||||
Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "opdracht 4.b1", "opdracht 4.b1\opdracht 4.b1.cproj", "{314FE495-A311-499D-B63E-4B5E7B7F2054}"
|
||||
EndProject
|
||||
Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "ultrasonicSensor", "ultrasonicSensor\ultrasonicSensor.cproj", "{26DA64DE-DD48-4718-94B5-81F9EC5D4B33}"
|
||||
EndProject
|
||||
Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "opdracht C", "opdracht C\opdracht C.cproj", "{2DF6F5F3-181F-430E-B49A-3D9794F91482}"
|
||||
EndProject
|
||||
@@ -91,6 +93,7 @@ Global
|
||||
{985D5C75-F61E-49F1-A532-66A1E6141552}.Debug|AVR.Build.0 = Debug|AVR
|
||||
{985D5C75-F61E-49F1-A532-66A1E6141552}.Release|AVR.ActiveCfg = Release|AVR
|
||||
{985D5C75-F61E-49F1-A532-66A1E6141552}.Release|AVR.Build.0 = Release|AVR
|
||||
<<<<<<< HEAD
|
||||
{2432E6BF-DA1E-4668-99BB-59FEA1F5B8A2}.Debug|AVR.ActiveCfg = Debug|AVR
|
||||
{2432E6BF-DA1E-4668-99BB-59FEA1F5B8A2}.Debug|AVR.Build.0 = Debug|AVR
|
||||
{2432E6BF-DA1E-4668-99BB-59FEA1F5B8A2}.Release|AVR.ActiveCfg = Release|AVR
|
||||
@@ -99,6 +102,16 @@ Global
|
||||
{2DF6F5F3-181F-430E-B49A-3D9794F91482}.Debug|AVR.Build.0 = Debug|AVR
|
||||
{2DF6F5F3-181F-430E-B49A-3D9794F91482}.Release|AVR.ActiveCfg = Release|AVR
|
||||
{2DF6F5F3-181F-430E-B49A-3D9794F91482}.Release|AVR.Build.0 = Release|AVR
|
||||
=======
|
||||
{314FE495-A311-499D-B63E-4B5E7B7F2054}.Debug|AVR.ActiveCfg = Debug|AVR
|
||||
{314FE495-A311-499D-B63E-4B5E7B7F2054}.Debug|AVR.Build.0 = Debug|AVR
|
||||
{314FE495-A311-499D-B63E-4B5E7B7F2054}.Release|AVR.ActiveCfg = Release|AVR
|
||||
{314FE495-A311-499D-B63E-4B5E7B7F2054}.Release|AVR.Build.0 = Release|AVR
|
||||
{26DA64DE-DD48-4718-94B5-81F9EC5D4B33}.Debug|AVR.ActiveCfg = Debug|AVR
|
||||
{26DA64DE-DD48-4718-94B5-81F9EC5D4B33}.Debug|AVR.Build.0 = Debug|AVR
|
||||
{26DA64DE-DD48-4718-94B5-81F9EC5D4B33}.Release|AVR.ActiveCfg = Release|AVR
|
||||
{26DA64DE-DD48-4718-94B5-81F9EC5D4B33}.Release|AVR.Build.0 = Release|AVR
|
||||
>>>>>>> ultrasonic-sensor
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -1,207 +0,0 @@
|
||||
|
||||
Opdracht 2.2.elf: file format elf32-avr
|
||||
|
||||
Sections:
|
||||
Idx Name Size VMA LMA File off Algn
|
||||
0 .data 00000000 00800100 00800100 0000016c 2**0
|
||||
ALLOC, LOAD, DATA
|
||||
1 .text 000000a4 00000000 00000000 00000054 2**1
|
||||
CONTENTS, ALLOC, LOAD, READONLY, CODE
|
||||
2 .comment 0000002f 00000000 00000000 0000016c 2**0
|
||||
CONTENTS, READONLY
|
||||
3 .debug_aranges 00000038 00000000 00000000 0000019b 2**0
|
||||
CONTENTS, READONLY, DEBUGGING
|
||||
4 .debug_info 00000b3a 00000000 00000000 000001d3 2**0
|
||||
CONTENTS, READONLY, DEBUGGING
|
||||
5 .debug_abbrev 00000819 00000000 00000000 00000d0d 2**0
|
||||
CONTENTS, READONLY, DEBUGGING
|
||||
6 .debug_line 000002da 00000000 00000000 00001526 2**0
|
||||
CONTENTS, READONLY, DEBUGGING
|
||||
7 .debug_frame 00000074 00000000 00000000 00001800 2**2
|
||||
CONTENTS, READONLY, DEBUGGING
|
||||
8 .debug_str 0000027d 00000000 00000000 00001874 2**0
|
||||
CONTENTS, READONLY, DEBUGGING
|
||||
9 .debug_loc 000000e2 00000000 00000000 00001af1 2**0
|
||||
CONTENTS, READONLY, DEBUGGING
|
||||
10 .debug_ranges 00000028 00000000 00000000 00001bd3 2**0
|
||||
CONTENTS, READONLY, DEBUGGING
|
||||
11 .text 00000004 00000114 00000114 00000168 2**1
|
||||
CONTENTS, ALLOC, LOAD, READONLY, CODE
|
||||
12 .note.gnu.avr.deviceinfo 0000003c 00000000 00000000 00001bfc 2**2
|
||||
CONTENTS, READONLY, DEBUGGING
|
||||
13 .text.__vector_2 00000028 000000a4 000000a4 000000f8 2**1
|
||||
CONTENTS, ALLOC, LOAD, READONLY, CODE
|
||||
14 .text.__vector_3 00000028 000000cc 000000cc 00000120 2**1
|
||||
CONTENTS, ALLOC, LOAD, READONLY, CODE
|
||||
15 .text.main 00000020 000000f4 000000f4 00000148 2**1
|
||||
CONTENTS, ALLOC, LOAD, READONLY, CODE
|
||||
|
||||
Disassembly of section .text:
|
||||
|
||||
00000000 <__vectors>:
|
||||
0: 0c 94 46 00 jmp 0x8c ; 0x8c <__ctors_end>
|
||||
4: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
8: 0c 94 52 00 jmp 0xa4 ; 0xa4 <_etext>
|
||||
c: 0c 94 66 00 jmp 0xcc ; 0xcc <__vector_3>
|
||||
10: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
14: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
18: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
1c: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
20: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
24: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
28: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
2c: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
30: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
34: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
38: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
3c: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
40: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
44: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
48: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
4c: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
50: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
54: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
58: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
5c: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
60: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
64: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
68: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
6c: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
70: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
74: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
78: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
7c: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
80: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
84: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
88: 0c 94 8a 00 jmp 0x114 ; 0x114 <__bad_interrupt>
|
||||
|
||||
0000008c <__ctors_end>:
|
||||
8c: 11 24 eor r1, r1
|
||||
8e: 1f be out 0x3f, r1 ; 63
|
||||
90: cf ef ldi r28, 0xFF ; 255
|
||||
92: d0 e1 ldi r29, 0x10 ; 16
|
||||
94: de bf out 0x3e, r29 ; 62
|
||||
96: cd bf out 0x3d, r28 ; 61
|
||||
98: 0e 94 7a 00 call 0xf4 ; 0xf4 <main>
|
||||
9c: 0c 94 50 00 jmp 0xa0 ; 0xa0 <_exit>
|
||||
|
||||
000000a0 <_exit>:
|
||||
a0: f8 94 cli
|
||||
|
||||
000000a2 <__stop_program>:
|
||||
a2: ff cf rjmp .-2 ; 0xa2 <__stop_program>
|
||||
|
||||
Disassembly of section .text:
|
||||
|
||||
00000114 <__bad_interrupt>:
|
||||
114: 0c 94 00 00 jmp 0 ; 0x0 <__TEXT_REGION_ORIGIN__>
|
||||
|
||||
Disassembly of section .text.__vector_2:
|
||||
|
||||
000000a4 <__vector_2>:
|
||||
}
|
||||
/************************************************************************/
|
||||
/* interrupt 1
|
||||
walk the light 1 down */
|
||||
/************************************************************************/
|
||||
ISR( INT1_vect ) {
|
||||
a4: 1f 92 push r1
|
||||
a6: 0f 92 push r0
|
||||
a8: 0f b6 in r0, 0x3f ; 63
|
||||
aa: 0f 92 push r0
|
||||
ac: 11 24 eor r1, r1
|
||||
ae: 8f 93 push r24
|
||||
if (PORTC == 0b10000000)
|
||||
b0: 85 b3 in r24, 0x15 ; 21
|
||||
b2: 80 38 cpi r24, 0x80 ; 128
|
||||
b4: 11 f4 brne .+4 ; 0xba <__vector_2+0x16>
|
||||
{
|
||||
PORTC == 0b00000001;
|
||||
b6: 85 b3 in r24, 0x15 ; 21
|
||||
b8: 03 c0 rjmp .+6 ; 0xc0 <__vector_2+0x1c>
|
||||
} else {
|
||||
PORTC = PORTC << 1;
|
||||
ba: 85 b3 in r24, 0x15 ; 21
|
||||
bc: 88 0f add r24, r24
|
||||
be: 85 bb out 0x15, r24 ; 21
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
c0: 8f 91 pop r24
|
||||
c2: 0f 90 pop r0
|
||||
c4: 0f be out 0x3f, r0 ; 63
|
||||
c6: 0f 90 pop r0
|
||||
c8: 1f 90 pop r1
|
||||
ca: 18 95 reti
|
||||
|
||||
Disassembly of section .text.__vector_3:
|
||||
|
||||
000000cc <__vector_3>:
|
||||
|
||||
/************************************************************************/
|
||||
/* interrupt 2
|
||||
walk the light 1 up */
|
||||
/************************************************************************/
|
||||
ISR( INT2_vect ) {
|
||||
cc: 1f 92 push r1
|
||||
ce: 0f 92 push r0
|
||||
d0: 0f b6 in r0, 0x3f ; 63
|
||||
d2: 0f 92 push r0
|
||||
d4: 11 24 eor r1, r1
|
||||
d6: 8f 93 push r24
|
||||
if (PORTC == 0b00000001)
|
||||
d8: 85 b3 in r24, 0x15 ; 21
|
||||
da: 81 30 cpi r24, 0x01 ; 1
|
||||
dc: 11 f4 brne .+4 ; 0xe2 <__vector_3+0x16>
|
||||
{
|
||||
PORTC = 0b10000000;
|
||||
de: 80 e8 ldi r24, 0x80 ; 128
|
||||
e0: 85 bb out 0x15, r24 ; 21
|
||||
}
|
||||
PORTC = PORTC >> 1;
|
||||
e2: 85 b3 in r24, 0x15 ; 21
|
||||
e4: 86 95 lsr r24
|
||||
e6: 85 bb out 0x15, r24 ; 21
|
||||
}
|
||||
e8: 8f 91 pop r24
|
||||
ea: 0f 90 pop r0
|
||||
ec: 0f be out 0x3f, r0 ; 63
|
||||
ee: 0f 90 pop r0
|
||||
f0: 1f 90 pop r1
|
||||
f2: 18 95 reti
|
||||
|
||||
Disassembly of section .text.main:
|
||||
|
||||
000000f4 <main>:
|
||||
int main(void)
|
||||
{
|
||||
/* Replace with your application code */
|
||||
|
||||
// Init I/O
|
||||
DDRD = 0xF0; // PORTD (7:4) is output, (3:0) is input
|
||||
f4: 80 ef ldi r24, 0xF0 ; 240
|
||||
f6: 81 bb out 0x11, r24 ; 17
|
||||
DDRC = 0xFF;
|
||||
f8: 8f ef ldi r24, 0xFF ; 255
|
||||
fa: 84 bb out 0x14, r24 ; 20
|
||||
|
||||
// Init Interrupt hardware
|
||||
EICRA |= 0x2C; // INT2 falling edge, INT1 rising edge
|
||||
fc: ea e6 ldi r30, 0x6A ; 106
|
||||
fe: f0 e0 ldi r31, 0x00 ; 0
|
||||
100: 80 81 ld r24, Z
|
||||
102: 8c 62 ori r24, 0x2C ; 44
|
||||
104: 80 83 st Z, r24
|
||||
EIMSK |= 0x06; // Enable INT2 & INT1
|
||||
106: 89 b7 in r24, 0x39 ; 57
|
||||
108: 86 60 ori r24, 0x06 ; 6
|
||||
10a: 89 bf out 0x39, r24 ; 57
|
||||
|
||||
PORTC = 0x01; // init the first bit
|
||||
10c: 81 e0 ldi r24, 0x01 ; 1
|
||||
10e: 85 bb out 0x15, r24 ; 21
|
||||
|
||||
sei(); // enable input mechanism
|
||||
110: 78 94 sei
|
||||
112: ff cf rjmp .-2 ; 0x112 <main+0x1e>
|
||||
@@ -65,36 +65,4 @@ int main(void)
|
||||
}
|
||||
|
||||
|
||||
void init_4bits_mode(void) {
|
||||
// PORTC output mode and all low (also E and RS pin)
|
||||
DDRC = 0xFF;
|
||||
PORTC = 0x00;
|
||||
|
||||
PORTC = 0x20; // (0x28 for 2 lines)
|
||||
lcd_strobe_lcd_e();
|
||||
}
|
||||
|
||||
void init_4bits_mode(void) {
|
||||
|
||||
// PORTC output mode and all low (also E and RS pin)
|
||||
DDRC = 0xFF;
|
||||
PORTC = 0x00;
|
||||
|
||||
PORTC = 0x20; // function for 4-bit 1 row
|
||||
lcd_strobe_lcd_e();
|
||||
|
||||
PORTC = 0x20; // function high nibble 4-bit 2 row
|
||||
lcd_strobe_lcd_e();
|
||||
PORTC = 0x80; // function low nibble 4-bit 2 row
|
||||
lcd_strobe_lcd_e();
|
||||
|
||||
PORTC = 0x00; // function high nibble turn on visible blinking-block cursor
|
||||
lcd_strobe_lcd_e();
|
||||
PORTC = 0xF0; // function low nibble turn on visible blinking-block cursor
|
||||
lcd_strobe_lcd_e();
|
||||
|
||||
PORTC = 0x00; // Entry mode set high nibble
|
||||
lcd_strobe_lcd_e();
|
||||
PORTC = 0x60; // Entry mode set low nibble
|
||||
lcd_strobe_lcd_e();
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectVersion>7.0</ProjectVersion>
|
||||
<ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
|
||||
<ProjectGuid>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>
|
||||
<ProjectGuid>{314fe495-a311-499d-b63e-4b5e7b7f2054}</ProjectGuid>
|
||||
<avrdevice>ATmega128</avrdevice>
|
||||
<avrdeviceseries>none</avrdeviceseries>
|
||||
<OutputType>Executable</OutputType>
|
||||
@@ -15,6 +15,19 @@
|
||||
<AssemblyName>opdracht 4.b1</AssemblyName>
|
||||
<Name>opdracht 4.b1</Name>
|
||||
<RootNamespace>opdracht 4.b1</RootNamespace>
|
||||
<ToolchainFlavour>Native</ToolchainFlavour>
|
||||
<KeepTimersRunning>true</KeepTimersRunning>
|
||||
<OverrideVtor>false</OverrideVtor>
|
||||
<CacheFlash>true</CacheFlash>
|
||||
<ProgFlashFromRam>true</ProgFlashFromRam>
|
||||
<RamSnippetAddress />
|
||||
<UncachedRange />
|
||||
<preserveEEPROM>true</preserveEEPROM>
|
||||
<OverrideVtorValue />
|
||||
<BootSegment>2</BootSegment>
|
||||
<ResetRule>0</ResetRule>
|
||||
<eraseonlaunchrule>0</eraseonlaunchrule>
|
||||
<EraseKey />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<ToolchainSettings>
|
||||
@@ -24,5 +37,10 @@
|
||||
<ToolchainSettings>
|
||||
</ToolchainSettings>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="main.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
|
||||
</Project>
|
||||
151
Microcontrollers/ultrasonicSensor/Debug/Makefile
Normal file
151
Microcontrollers/ultrasonicSensor/Debug/Makefile
Normal file
@@ -0,0 +1,151 @@
|
||||
################################################################################
|
||||
# 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 += \
|
||||
../lcd_control.c \
|
||||
../main.c \
|
||||
../ultrasonic_sensor.c
|
||||
|
||||
|
||||
PREPROCESSING_SRCS +=
|
||||
|
||||
|
||||
ASM_SRCS +=
|
||||
|
||||
|
||||
OBJS += \
|
||||
lcd_control.o \
|
||||
main.o \
|
||||
ultrasonic_sensor.o
|
||||
|
||||
OBJS_AS_ARGS += \
|
||||
lcd_control.o \
|
||||
main.o \
|
||||
ultrasonic_sensor.o
|
||||
|
||||
C_DEPS += \
|
||||
lcd_control.d \
|
||||
main.d \
|
||||
ultrasonic_sensor.d
|
||||
|
||||
C_DEPS_AS_ARGS += \
|
||||
lcd_control.d \
|
||||
main.d \
|
||||
ultrasonic_sensor.d
|
||||
|
||||
OUTPUT_FILE_PATH +=ultrasonicSensor.elf
|
||||
|
||||
OUTPUT_FILE_PATH_AS_ARGS +=ultrasonicSensor.elf
|
||||
|
||||
ADDITIONAL_DEPENDENCIES:=
|
||||
|
||||
OUTPUT_FILE_DEP:= ./makedep.mk
|
||||
|
||||
LIB_DEP+=
|
||||
|
||||
LINKER_SCRIPT_DEP+=
|
||||
|
||||
|
||||
# AVR32/GNU C Compiler
|
||||
./lcd_control.o: .././lcd_control.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.6.364\include" -Og -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -mrelax -g2 -Wall -mmcu=atmega128 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\gcc\dev\atmega128" -c -std=gnu99 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
|
||||
@echo Finished building: $<
|
||||
|
||||
|
||||
./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.6.364\include" -Og -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -mrelax -g2 -Wall -mmcu=atmega128 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\gcc\dev\atmega128" -c -std=gnu99 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
|
||||
@echo Finished building: $<
|
||||
|
||||
|
||||
./ultrasonic_sensor.o: .././ultrasonic_sensor.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.6.364\include" -Og -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -mrelax -g2 -Wall -mmcu=atmega128 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\gcc\dev\atmega128" -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) $(LIB_DEP) $(LINKER_SCRIPT_DEP)
|
||||
@echo Building target: $@
|
||||
@echo Invoking: AVR/GNU Linker : 5.4.0
|
||||
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -o$(OUTPUT_FILE_PATH_AS_ARGS) $(OBJS_AS_ARGS) $(USER_OBJS) $(LIBS) -Wl,-Map="ultrasonicSensor.map" -Wl,--start-group -Wl,-lm -Wl,--end-group -Wl,--gc-sections -mrelax -mmcu=atmega128 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\gcc\dev\atmega128"
|
||||
@echo Finished building target: $@
|
||||
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "ultrasonicSensor.elf" "ultrasonicSensor.hex"
|
||||
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -j .eeprom --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex "ultrasonicSensor.elf" "ultrasonicSensor.eep" || exit 0
|
||||
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objdump.exe" -h -S "ultrasonicSensor.elf" > "ultrasonicSensor.lss"
|
||||
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O srec -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "ultrasonicSensor.elf" "ultrasonicSensor.srec"
|
||||
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-size.exe" "ultrasonicSensor.elf"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Other Targets
|
||||
clean:
|
||||
-$(RM) $(OBJS_AS_ARGS) $(EXECUTABLES)
|
||||
-$(RM) $(C_DEPS_AS_ARGS)
|
||||
rm -rf "ultrasonicSensor.elf" "ultrasonicSensor.a" "ultrasonicSensor.hex" "ultrasonicSensor.lss" "ultrasonicSensor.eep" "ultrasonicSensor.map" "ultrasonicSensor.srec" "ultrasonicSensor.usersignatures"
|
||||
|
||||
10
Microcontrollers/ultrasonicSensor/Debug/makedep.mk
Normal file
10
Microcontrollers/ultrasonicSensor/Debug/makedep.mk
Normal file
@@ -0,0 +1,10 @@
|
||||
################################################################################
|
||||
# Automatically-generated file. Do not edit or delete the file
|
||||
################################################################################
|
||||
|
||||
lcd_control.c
|
||||
|
||||
main.c
|
||||
|
||||
ultrasonic_sensor.c
|
||||
|
||||
1434
Microcontrollers/ultrasonicSensor/Debug/ultrasonicSensor.lss
Normal file
1434
Microcontrollers/ultrasonicSensor/Debug/ultrasonicSensor.lss
Normal file
File diff suppressed because it is too large
Load Diff
154
Microcontrollers/ultrasonicSensor/Debug/ultrasonicSensor.srec
Normal file
154
Microcontrollers/ultrasonicSensor/Debug/ultrasonicSensor.srec
Normal file
@@ -0,0 +1,154 @@
|
||||
S0180000756C747261736F6E696353656E736F722E737265634E
|
||||
S113000045C0000038C100005EC000005CC00000B4
|
||||
S11300105AC0000058C0000056C0000054C0000080
|
||||
S113002052C0000050C000004EC000004CC0000090
|
||||
S11300304AC0000048C0000046C0000044C00000A0
|
||||
S113004042C0000040C000003EC000003CC00000B0
|
||||
S11300503AC0000038C0000036C0000034C00000C0
|
||||
S113006032C0000030C000002EC000002CC00000D0
|
||||
S11300702AC0000028C0000026C0000024C00000E0
|
||||
S113008022C0000020C000001EC0000011241FBEBA
|
||||
S1130090CFEFD0E1DEBFCDBF11E0A0E0B1E0E8E6F4
|
||||
S11300A0F9E000E00BBF02C007900D92A430B10745
|
||||
S11300B0D9F721E0A4E0B1E001C01D92A630B20757
|
||||
S11300C0E1F700D14FC49CCF9BB321E030E002C0E4
|
||||
S11300D0220F331F8A95E2F7292B2BBB08959BB37C
|
||||
S11300E021E030E002C0220F331F8A95E2F7209509
|
||||
S11300F029232BBB089586E090E0E6DF83EC99E0AA
|
||||
S11301000197F1F700C0000086E090E0E8DF83EC9F
|
||||
S113011099E00197F1F700C000000895CF93C82F2C
|
||||
S113012085BB84E090E0D0DFE6DFC295C07FC5BB2D
|
||||
S113013084E090E0C9DFDFDFCF910895CF93C82F2B
|
||||
S113014085BB84E090E0CBDFD6DFC295C07FC5BB22
|
||||
S113015084E090E0C4DFCFDFCF91089581E0EEDF4B
|
||||
S113016087E893E10197F1F700C0000080E8E6CF4B
|
||||
S11301700895CF938FEF84BB85BB8ABB15BA1BBA96
|
||||
S1130180C0E2C5BBB8DFC5BBB6DF80E885BBB3DF63
|
||||
S113019015BAB1DF80EF85BBAEDF15BAACDF80E600
|
||||
S11301A085BBA9DF82E0CADFA6DFCF910895CF9394
|
||||
S11301B0DF93EC0102C0B2DF219688818111FBCF6D
|
||||
S11301C0DF91CF910895AF92BF92CF92DF92EF92D9
|
||||
S11301D0FF920F931F93CF93DF93CDB7DEB7D82E43
|
||||
S11301E0C92EADB6BEB69F938F930F2EF1E0EF2EBE
|
||||
S11301F0F1E0FF2EF02DFF92EF921F921F921F92BB
|
||||
S11302001F92C7D001962DB73EB7285F3F4F0FB658
|
||||
S1130210F8943EBF0FBE2DBF281B390B0FB6F894C0
|
||||
S11302203EBF0FBE2DBF0DB71EB70F5F1F4FCF923E
|
||||
S1130230DF92FF92EF929F938F931F930F93A9D016
|
||||
S1130240802F912FB4DF8DB79EB708960FB6F89420
|
||||
S11302509EBF0FBE8DBF0FB6F894BEBE0FBEADBE1F
|
||||
S1130260DF91CF911F910F91FF90EF90DF90CF908E
|
||||
S1130270BF90AF9008951F920F920FB60F92112462
|
||||
S11302800BB60F922F933F934F935F936F937F938C
|
||||
S11302908F939F93AF93BF93EF93FF935CD0FF91A2
|
||||
S11302A0EF91BF91AF919F918F917F916F915F91EA
|
||||
S11302B04F913F912F910F900BBE0F900FBE0F9057
|
||||
S11302C01F9018952CD055DF87EA91E60197F1F736
|
||||
S11302D000C0000043DF32D041DF56D074DF84E633
|
||||
S11302E090E00ED0F8CF20E030E006C043E04A951D
|
||||
S11302F0F1F700002F5F3F4F28173907B8F308952F
|
||||
S113030020E030E008C0E3ECF9E03197F1F700C0F9
|
||||
S113031000002F5F3F4F28173907A8F308958FEF88
|
||||
S11303208093640011BA83E080936A0089B7816086
|
||||
S113033089BF1FBC8CE08EBD78940895CF93DF9362
|
||||
S1130340C5E6D0E018828AE090E0CDDF81E08883C2
|
||||
S1130350DF91CF91089580910001813041F482E0D2
|
||||
S113036080936A001DBC1CBC10920001089583E0B8
|
||||
S113037080936A008CB59DB5909305018093040128
|
||||
S113038081E080930001089580910401909105011A
|
||||
S113039008950F931F93CF93DF93CDB7DEB72E97B6
|
||||
S11303A00FB6F894DEBF0FBECDBF0D891E898F89AD
|
||||
S11303B0988D26E02C831A83098397FF02C080E07E
|
||||
S11303C090E801979E838D83AE01455E5F4F698DF2
|
||||
S11303D07A8DCE01019619D04D815E8157FD0AC0F8
|
||||
S11303E02F813885421753070CF49A01F801E20F64
|
||||
S11303F0F31F10822E960FB6F894DEBF0FBECDBF4A
|
||||
S1130400DF91CF911F910F9108952F923F924F92B8
|
||||
S11304105F926F927F928F929F92AF92BF92CF9290
|
||||
S1130420DF92EF92FF920F931F93CF93DF93CDB799
|
||||
S1130430DEB72B970FB6F894DEBF0FBECDBF6C01AD
|
||||
S11304407B018A01FC0117821682838181FFBFC16F
|
||||
S1130450CE0101963C01F6019381F70193FD85914C
|
||||
S113046093FF81917F01882309F4ADC1853239F46A
|
||||
S113047093FD859193FF81917F01853221F4B6012B
|
||||
S113048090E0D6D1E8CF912C212C312CFFE1F3154B
|
||||
S1130490D8F08B3279F038F4803279F08332A1F4D9
|
||||
S11304A0232D20611DC08D3261F0803369F4232D2A
|
||||
S11304B0216016C0832D8260382EE32DE4603E2E29
|
||||
S11304C02AC0F32DF8601DC037FC2DC020ED280F85
|
||||
S11304D02A3040F08E32B9F436FC75C1232D2064E5
|
||||
S11304E0322E19C036FE06C08AE0989E200D1124D3
|
||||
S11304F0922E11C0EAE02E9E200D1124222EF32DFF
|
||||
S1130500F0623F2E08C08C3621F4832D8068382E8B
|
||||
S113051002C0883641F4F70193FD859193FF8191E0
|
||||
S11305207F018111B3CF982F9F7D9554933028F488
|
||||
S11305300C5F1F4F9FE399830DC0833631F08337DF
|
||||
S113054071F0833509F055C020C0F801808189839A
|
||||
S11305500E5F1F4F88248394912C530112C02801ED
|
||||
S1130560F2E04F0E511CF801A080B18036FE03C0AA
|
||||
S1130570692D70E002C06FEF7FEFC5014ED14C01D1
|
||||
S11305808201F32DFF773F2E15C0280122E0420E91
|
||||
S1130590511CF801A080B18036FE03C0692D70E0C3
|
||||
S11305A002C06FEF7FEFC5012DD14C01F32DF06830
|
||||
S11305B03F2E820133FC19C0822D90E088169906E3
|
||||
S11305C0A0F4B60180E290E033D12A94F5CFF5018E
|
||||
S11305D037FC859137FE81915F01B60190E028D107
|
||||
S11305E021102A9421E0821A91088114910479F748
|
||||
S11305F0E1C0843611F0893639F5F80137FE07C0B9
|
||||
S113060060817181828193810C5F1F4F08C060817A
|
||||
S11306107181072E000C880B990B0E5F1F4FF32D71
|
||||
S1130620FF763F2E97FF09C0909580957095619550
|
||||
S11306307F4F8F4F9F4FF0683F2E2AE030E0A30199
|
||||
S113064033D1882E861844C0853731F4232D2F7E6C
|
||||
S1130650B22E2AE030E025C0932D997FB92E8F3633
|
||||
S1130660C1F018F4883579F0AEC0803719F08837B6
|
||||
S113067021F0A9C0E92FE061BE2EB4FE0DC0FB2D10
|
||||
S1130680F460BF2E09C034FE0AC0292F2660B22EA2
|
||||
S113069006C028E030E005C020E130E002C020E1DF
|
||||
S11306A032E0F801B7FE07C06081718182819381D5
|
||||
S11306B00C5F1F4F06C06081718180E090E00E5F87
|
||||
S11306C01F4FA301F1D0882E8618FB2DFF773F2EF4
|
||||
S11306D036FE0DC0232D2E7FA22E891458F434FE2D
|
||||
S11306E00BC032FC09C0832D8E7EA82E05C0B82C09
|
||||
S11306F0A32C03C0B82C01C0B92CA4FE0FC0FE016A
|
||||
S1130700E80DF11D8081803321F49A2D997EA92E64
|
||||
S113071009C0A2FE06C0B394B39404C08A2D86789F
|
||||
S113072009F0B394A3FC10C0A0FE06C0B21480F478
|
||||
S1130730280C922C9B180DC0B21458F4B60180E218
|
||||
S113074090E076D0B394F8CFB21418F42B1802C00A
|
||||
S1130750982C212CA4FE0FC0B60180E390E068D051
|
||||
S1130760A2FE16C0A1FC03C088E790E002C088E5A1
|
||||
S113077090E0B6010CC08A2D867851F0A1FE02C02B
|
||||
S11307808BE201C080E2A7FC8DE2B60190E050D07C
|
||||
S1130790891430F4B60180E390E04AD09A94F8CFFB
|
||||
S11307A08A94F301E80DF11D8081B60190E040D0F8
|
||||
S11307B08110F6CF222009F44ECEB60180E290E0FB
|
||||
S11307C037D02A94F7CFF6018681978102C08FEF44
|
||||
S11307D09FEF2B960FB6F894DEBF0FBECDBFDF910F
|
||||
S11307E0CF911F910F91FF90EF90DF90CF90BF902A
|
||||
S11307F0AF909F908F907F906F905F904F903F90BD
|
||||
S11308002F900895FC010590615070400110D8F7B5
|
||||
S1130810809590958E0F9F1F0895FC016150704044
|
||||
S113082001900110D8F7809590958E0F9F1F089521
|
||||
S11308300F931F93CF93DF93FB01238121FD03C00B
|
||||
S11308408FEF9FEF2CC022FF16C046815781248171
|
||||
S113085035814217530744F4A081B1819D012F5F74
|
||||
S11308603F4F318320838C93268137812F5F3F4F05
|
||||
S11308703783268314C08B01EC01FB010084F185CE
|
||||
S1130880E02D0995892BE1F6D80116968D919C915E
|
||||
S11308901797019617969C938E931697CE01DF9126
|
||||
S11308A0CF911F910F910895FA01AA27283051F191
|
||||
S11308B0203181F1E8946F936E7F6E5F7F4F8F4F8D
|
||||
S11308C09F4FAF4FB1E03ED0B4E03CD0670F781FEC
|
||||
S11308D0891F9A1FA11D680F791F8A1F911DA11DD1
|
||||
S11308E06A0F711D811D911DA11D20D009F468940A
|
||||
S11308F03F912AE0269F11243019305D3193DEF6B2
|
||||
S1130900CF010895462F4770405D4193B3E00FD067
|
||||
S1130910C9F7F6CF462F4F70405D4A3318F0495D52
|
||||
S113092031FD4052419302D0A9F7EACFB4E0A69535
|
||||
S11309309795879577956795BA95C9F70097610557
|
||||
S1130940710508959B01AC010A2E069457954795AD
|
||||
S113095037952795BA95C9F7620F731F841F951FA2
|
||||
S10B0960A01D0895F894FFCFD7
|
||||
S107096801256400FD
|
||||
S9030000FC
|
||||
132
Microcontrollers/ultrasonicSensor/lcd_control.c
Normal file
132
Microcontrollers/ultrasonicSensor/lcd_control.c
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* lcd_controlc.c
|
||||
*
|
||||
* Created: 24-2-2021 11:55:12
|
||||
* Author: Sem
|
||||
*/
|
||||
#define F_CPU 10e6
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "lcd_control.h"
|
||||
|
||||
void _delay_ms(double __ms);
|
||||
|
||||
void lcd_clear() {
|
||||
lcd_write_command (0x01); //Leeg display
|
||||
_delay_ms(2);
|
||||
lcd_write_command (0x80); //Cursor terug naar start
|
||||
}
|
||||
|
||||
void lcd_strobe_lcd_e(void) {
|
||||
|
||||
sbi_porta(LCD_E); // E high
|
||||
_delay_ms(1);
|
||||
cbi_porta(LCD_E); // E low
|
||||
_delay_ms(1);
|
||||
|
||||
}
|
||||
|
||||
void sbi_portc(int index){
|
||||
PORTC |= (1<<index);
|
||||
}
|
||||
|
||||
|
||||
void cbi_portc(int index){
|
||||
PORTC &= ~(1<<index);
|
||||
}
|
||||
|
||||
void sbi_porta(int index){
|
||||
PORTA |= (1<<index);
|
||||
}
|
||||
|
||||
|
||||
void cbi_porta(int index){
|
||||
PORTA &= ~(1<<index);
|
||||
}
|
||||
|
||||
void init_4bits_mode(void) {
|
||||
|
||||
// PORTC output mode and all low (also E and RS pin)
|
||||
|
||||
// Init I/O
|
||||
DDRC = 0xFF; // PORTD(7) output, PORTD(6:0) input
|
||||
PORTC = 0xFF;
|
||||
|
||||
DDRA = 0xFF;
|
||||
PORTC = 0x00;
|
||||
PORTA = 0x00;
|
||||
|
||||
PORTC = 0x20; // function for 4-bit 1 row
|
||||
lcd_strobe_lcd_e();
|
||||
|
||||
PORTC = 0x20; // function high nibble 4-bit 2 row
|
||||
lcd_strobe_lcd_e();
|
||||
PORTC = 0x80; // function low nibble 4-bit 2 row
|
||||
lcd_strobe_lcd_e();
|
||||
|
||||
PORTC = 0x00; // function high nibble turn on visible blinking-block cursor
|
||||
lcd_strobe_lcd_e();
|
||||
PORTC = 0xF0; // function low nibble turn on visible blinking-block cursor
|
||||
lcd_strobe_lcd_e();
|
||||
|
||||
PORTC = 0x00; // Entry mode set high nibble
|
||||
lcd_strobe_lcd_e();
|
||||
PORTC = 0x60; // Entry mode set low nibble
|
||||
lcd_strobe_lcd_e();
|
||||
|
||||
// return home
|
||||
lcd_write_command(0x02);
|
||||
lcd_strobe_lcd_e();
|
||||
}
|
||||
|
||||
void lcd_write_character(unsigned char byte){
|
||||
|
||||
|
||||
//upper nibble
|
||||
PORTC = byte;
|
||||
sbi_porta(LCD_RS);
|
||||
lcd_strobe_lcd_e();
|
||||
|
||||
//lower nibble
|
||||
PORTC = (byte<<4);
|
||||
sbi_porta(LCD_RS);
|
||||
lcd_strobe_lcd_e();
|
||||
|
||||
}
|
||||
|
||||
void lcd_write_command(unsigned char byte){
|
||||
|
||||
//upper nibble
|
||||
PORTC = byte;
|
||||
cbi_porta(LCD_RS);
|
||||
lcd_strobe_lcd_e();
|
||||
|
||||
//lower nibble
|
||||
PORTC = (byte<<4);
|
||||
cbi_porta(LCD_RS);
|
||||
lcd_strobe_lcd_e();
|
||||
|
||||
}
|
||||
|
||||
void lcd_write_string(const char *str) {
|
||||
|
||||
for(;*str; str++){
|
||||
lcd_write_character(*str);
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_move_right(void){
|
||||
|
||||
lcd_write_command(0x1E);
|
||||
}
|
||||
|
||||
void lcd_write_int(int number)
|
||||
{
|
||||
int length = snprintf(NULL, 0, "%d", number);
|
||||
char str[length + 1];
|
||||
snprintf(str, length + 1, "%d", number);
|
||||
lcd_write_string(str);
|
||||
}
|
||||
30
Microcontrollers/ultrasonicSensor/lcd_control.h
Normal file
30
Microcontrollers/ultrasonicSensor/lcd_control.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* lcd_control.h
|
||||
*
|
||||
* Created: 24-2-2021 11:56:16
|
||||
* Author: Sem
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LCD_CONTROL_H_
|
||||
#define LCD_CONTROL_H_
|
||||
|
||||
#define LCD_E 6
|
||||
#define LCD_RS 4
|
||||
|
||||
void _delay_ms(double __ms);
|
||||
void lcd_strobe_lcd_e(void);
|
||||
void sbi_portc(int index);
|
||||
void cbi_portc(int index);
|
||||
void sbi_porta(int index);
|
||||
void cbi_porta(int index);
|
||||
void init_4bits_mode(void);
|
||||
void lcd_write_string(const char *str);
|
||||
void lcd_write_character(unsigned char byte);
|
||||
void lcd_write_command(unsigned char byte);
|
||||
void lcd_clear();
|
||||
void lcd_write_int(int number);
|
||||
|
||||
|
||||
|
||||
#endif /* LCD_CONTROL_H_ */
|
||||
58
Microcontrollers/ultrasonicSensor/main.c
Normal file
58
Microcontrollers/ultrasonicSensor/main.c
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* ultrasonicSensor.c
|
||||
*
|
||||
* Created: 17-3-2021 09:47:12
|
||||
* Author : Sem
|
||||
|
||||
interrupt op rising edge in echo,
|
||||
dan timer1 aanzetten -> timer1 want 16 bits en willen nauwkeurig afstand kunnen meten, en afstand kan van 2 cm tot 4 m, dus willen zeker zijn dat het past
|
||||
en interrupt zetten op falling edge in echo
|
||||
als falling edge interrupt geeft ->
|
||||
waarde uit timer1 uitlezen
|
||||
en formule gebruiken high level time * velocity (340M/S) / 2
|
||||
timer1 uitzetten
|
||||
interrupt weer op rising edge van echo zetten
|
||||
|
||||
|
||||
|
||||
*/
|
||||
#define F_CPU 10e6
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#include "lcd_control.h"
|
||||
#include "ultrasonic_sensor.h"
|
||||
|
||||
ISR(INT0_vect)
|
||||
{
|
||||
ultrasonic_handle_interrupt();
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
ultrasonic_init();
|
||||
init_4bits_mode();
|
||||
|
||||
_delay_ms(10);
|
||||
|
||||
lcd_clear();
|
||||
|
||||
|
||||
while (1)
|
||||
{
|
||||
ultrasonic_send_pulse();
|
||||
|
||||
lcd_clear();
|
||||
lcd_write_int(ultrasonic_get_timer_dist());
|
||||
|
||||
|
||||
wait_ms(100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Store xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="AtmelPackComponentManagement">
|
||||
<ProjectComponents>
|
||||
<ProjectComponent z:Id="i1" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
|
||||
<CApiVersion></CApiVersion>
|
||||
<CBundle></CBundle>
|
||||
<CClass>Device</CClass>
|
||||
<CGroup>Startup</CGroup>
|
||||
<CSub></CSub>
|
||||
<CVariant></CVariant>
|
||||
<CVendor>Atmel</CVendor>
|
||||
<CVersion>1.6.0</CVersion>
|
||||
<DefaultRepoPath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs</DefaultRepoPath>
|
||||
<DependentComponents xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
|
||||
<Description></Description>
|
||||
<Files xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
|
||||
<d4p1:anyType i:type="FileInfo">
|
||||
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\include\</AbsolutePath>
|
||||
<Attribute></Attribute>
|
||||
<Category>include</Category>
|
||||
<Condition>C</Condition>
|
||||
<FileContentHash i:nil="true" />
|
||||
<FileVersion></FileVersion>
|
||||
<Name>include/</Name>
|
||||
<SelectString></SelectString>
|
||||
<SourcePath></SourcePath>
|
||||
</d4p1:anyType>
|
||||
<d4p1:anyType i:type="FileInfo">
|
||||
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\include\avr\iom128.h</AbsolutePath>
|
||||
<Attribute></Attribute>
|
||||
<Category>header</Category>
|
||||
<Condition>C</Condition>
|
||||
<FileContentHash>JdJ7J9I/SJh965SEyyyVYw==</FileContentHash>
|
||||
<FileVersion></FileVersion>
|
||||
<Name>include/avr/iom128.h</Name>
|
||||
<SelectString></SelectString>
|
||||
<SourcePath></SourcePath>
|
||||
</d4p1:anyType>
|
||||
<d4p1:anyType i:type="FileInfo">
|
||||
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\templates\main.c</AbsolutePath>
|
||||
<Attribute>template</Attribute>
|
||||
<Category>source</Category>
|
||||
<Condition>C Exe</Condition>
|
||||
<FileContentHash>zBFq/2TxUzr5xF+6ABRBCw==</FileContentHash>
|
||||
<FileVersion></FileVersion>
|
||||
<Name>templates/main.c</Name>
|
||||
<SelectString>Main file (.c)</SelectString>
|
||||
<SourcePath></SourcePath>
|
||||
</d4p1:anyType>
|
||||
<d4p1:anyType i:type="FileInfo">
|
||||
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\templates\main.cpp</AbsolutePath>
|
||||
<Attribute>template</Attribute>
|
||||
<Category>source</Category>
|
||||
<Condition>C Exe</Condition>
|
||||
<FileContentHash>mkKaE95TOoATsuBGv6jmxg==</FileContentHash>
|
||||
<FileVersion></FileVersion>
|
||||
<Name>templates/main.cpp</Name>
|
||||
<SelectString>Main file (.cpp)</SelectString>
|
||||
<SourcePath></SourcePath>
|
||||
</d4p1:anyType>
|
||||
<d4p1:anyType i:type="FileInfo">
|
||||
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\gcc\dev\atmega128</AbsolutePath>
|
||||
<Attribute></Attribute>
|
||||
<Category>libraryPrefix</Category>
|
||||
<Condition>GCC</Condition>
|
||||
<FileContentHash i:nil="true" />
|
||||
<FileVersion></FileVersion>
|
||||
<Name>gcc/dev/atmega128</Name>
|
||||
<SelectString></SelectString>
|
||||
<SourcePath></SourcePath>
|
||||
</d4p1:anyType>
|
||||
</Files>
|
||||
<PackName>ATmega_DFP</PackName>
|
||||
<PackPath>C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.6.364/Atmel.ATmega_DFP.pdsc</PackPath>
|
||||
<PackVersion>1.6.364</PackVersion>
|
||||
<PresentInProject>true</PresentInProject>
|
||||
<ReferenceConditionId>ATmega128</ReferenceConditionId>
|
||||
<RteComponents xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
|
||||
<d4p1:string></d4p1:string>
|
||||
</RteComponents>
|
||||
<Status>Resolved</Status>
|
||||
<VersionMode>Fixed</VersionMode>
|
||||
<IsComponentInAtProject>true</IsComponentInAtProject>
|
||||
</ProjectComponent>
|
||||
</ProjectComponents>
|
||||
</Store>
|
||||
130
Microcontrollers/ultrasonicSensor/ultrasonicSensor.cproj
Normal file
130
Microcontrollers/ultrasonicSensor/ultrasonicSensor.cproj
Normal file
@@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="14.0">
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectVersion>7.0</ProjectVersion>
|
||||
<ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
|
||||
<ProjectGuid>{26da64de-dd48-4718-94b5-81f9ec5d4b33}</ProjectGuid>
|
||||
<avrdevice>ATmega128</avrdevice>
|
||||
<avrdeviceseries>none</avrdeviceseries>
|
||||
<OutputType>Executable</OutputType>
|
||||
<Language>C</Language>
|
||||
<OutputFileName>$(MSBuildProjectName)</OutputFileName>
|
||||
<OutputFileExtension>.elf</OutputFileExtension>
|
||||
<OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
|
||||
<AssemblyName>ultrasonicSensor</AssemblyName>
|
||||
<Name>ultrasonicSensor</Name>
|
||||
<RootNamespace>ultrasonicSensor</RootNamespace>
|
||||
<ToolchainFlavour>Native</ToolchainFlavour>
|
||||
<KeepTimersRunning>true</KeepTimersRunning>
|
||||
<OverrideVtor>false</OverrideVtor>
|
||||
<CacheFlash>true</CacheFlash>
|
||||
<ProgFlashFromRam>true</ProgFlashFromRam>
|
||||
<RamSnippetAddress />
|
||||
<UncachedRange />
|
||||
<preserveEEPROM>true</preserveEEPROM>
|
||||
<OverrideVtorValue />
|
||||
<BootSegment>2</BootSegment>
|
||||
<ResetRule>0</ResetRule>
|
||||
<eraseonlaunchrule>0</eraseonlaunchrule>
|
||||
<EraseKey />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<ToolchainSettings>
|
||||
<AvrGcc>
|
||||
<avrgcc.common.Device>-mmcu=atmega128 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\gcc\dev\atmega128"</avrgcc.common.Device>
|
||||
<avrgcc.common.optimization.RelaxBranches>True</avrgcc.common.optimization.RelaxBranches>
|
||||
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
|
||||
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
|
||||
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
|
||||
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
|
||||
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
|
||||
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
|
||||
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
|
||||
<avrgcc.compiler.symbols.DefSymbols>
|
||||
<ListValues>
|
||||
<Value>NDEBUG</Value>
|
||||
</ListValues>
|
||||
</avrgcc.compiler.symbols.DefSymbols>
|
||||
<avrgcc.compiler.directories.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\include\</Value>
|
||||
</ListValues>
|
||||
</avrgcc.compiler.directories.IncludePaths>
|
||||
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
|
||||
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
|
||||
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
|
||||
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
|
||||
<avrgcc.linker.libraries.Libraries>
|
||||
<ListValues>
|
||||
<Value>libm</Value>
|
||||
</ListValues>
|
||||
</avrgcc.linker.libraries.Libraries>
|
||||
<avrgcc.assembler.general.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\include\</Value>
|
||||
</ListValues>
|
||||
</avrgcc.assembler.general.IncludePaths>
|
||||
</AvrGcc>
|
||||
</ToolchainSettings>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<ToolchainSettings>
|
||||
<AvrGcc>
|
||||
<avrgcc.common.Device>-mmcu=atmega128 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\gcc\dev\atmega128"</avrgcc.common.Device>
|
||||
<avrgcc.common.optimization.RelaxBranches>True</avrgcc.common.optimization.RelaxBranches>
|
||||
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
|
||||
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
|
||||
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
|
||||
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
|
||||
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
|
||||
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
|
||||
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
|
||||
<avrgcc.compiler.symbols.DefSymbols>
|
||||
<ListValues>
|
||||
<Value>DEBUG</Value>
|
||||
</ListValues>
|
||||
</avrgcc.compiler.symbols.DefSymbols>
|
||||
<avrgcc.compiler.directories.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\include\</Value>
|
||||
</ListValues>
|
||||
</avrgcc.compiler.directories.IncludePaths>
|
||||
<avrgcc.compiler.optimization.level>Optimize debugging experience (-Og)</avrgcc.compiler.optimization.level>
|
||||
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
|
||||
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
|
||||
<avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
|
||||
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
|
||||
<avrgcc.linker.libraries.Libraries>
|
||||
<ListValues>
|
||||
<Value>libm</Value>
|
||||
</ListValues>
|
||||
</avrgcc.linker.libraries.Libraries>
|
||||
<avrgcc.assembler.general.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\include\</Value>
|
||||
</ListValues>
|
||||
</avrgcc.assembler.general.IncludePaths>
|
||||
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
|
||||
</AvrGcc>
|
||||
</ToolchainSettings>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="lcd_control.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="lcd_control.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="main.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ultrasonic_sensor.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ultrasonic_sensor.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
|
||||
</Project>
|
||||
91
Microcontrollers/ultrasonicSensor/ultrasonic_sensor.c
Normal file
91
Microcontrollers/ultrasonicSensor/ultrasonic_sensor.c
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* ultrasonic_sensor.c
|
||||
*
|
||||
* Created: 24-3-2021 13:04:52
|
||||
* Author: Sem
|
||||
*/
|
||||
|
||||
#define F_CPU 10e6
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#include "lcd_control.h"
|
||||
|
||||
static uint16_t timer_dist = 0;
|
||||
|
||||
enum interrupt_status {INTERRUPT_FALLING, INTERRUPT_RISING};
|
||||
|
||||
static enum interrupt_status int_stat = INTERRUPT_RISING;
|
||||
|
||||
void wait_us(unsigned int us)
|
||||
{
|
||||
for(int i = 0; i < us; i++)
|
||||
{
|
||||
_delay_us(1);
|
||||
}
|
||||
}
|
||||
|
||||
void wait_ms(unsigned int ms)
|
||||
{
|
||||
|
||||
for(int i = 0; i < ms; i++)
|
||||
{
|
||||
_delay_ms(1);
|
||||
}
|
||||
}
|
||||
void ultrasonic_init()
|
||||
{
|
||||
DDRG = 0xFF; // port g all output. pin 0 is trig, the rest is for debug
|
||||
DDRD = 0x00; // port D pin 0 on input. 0 is echo and also interrupt
|
||||
|
||||
EICRA = 0x03; // interrupt PORTD on pin 0, rising edge
|
||||
|
||||
EIMSK |= 0x01; // enable interrupt on pin 0 (INT0)
|
||||
|
||||
TCCR1A = 0b00000000; // initialize timer1, prescaler=256
|
||||
TCCR1B = 0b00001100; // CTC compare A, RUN
|
||||
|
||||
sei(); // turn on interrupt system
|
||||
}
|
||||
|
||||
void ultrasonic_send_pulse()
|
||||
{
|
||||
PORTG = 0x00; // 10 us low pulse
|
||||
wait_us(10);
|
||||
PORTG = 0x01;
|
||||
}
|
||||
|
||||
void ultrasonic_handle_interrupt()
|
||||
{
|
||||
// if the interrupt was generated on a rising edge (start sending echo)
|
||||
if (int_stat == INTERRUPT_RISING)
|
||||
{
|
||||
// set interrupt pin 0 on PORTD to falling edge
|
||||
EICRA = 0x02;
|
||||
|
||||
// reset the time in timer1
|
||||
TCNT1 = 0x00;
|
||||
|
||||
// set interrupt status
|
||||
int_stat = INTERRUPT_FALLING;
|
||||
} else
|
||||
// else if it was generated on a falling edge (end sending echo)
|
||||
{
|
||||
// set interrupt pin 0 on PORTD to rising edge
|
||||
EICRA = 0x03;
|
||||
|
||||
// read timer1 into time_dist
|
||||
timer_dist = TCNT1;
|
||||
|
||||
// set interrupt status
|
||||
int_stat = INTERRUPT_RISING;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t ultrasonic_get_timer_dist()
|
||||
{
|
||||
return timer_dist;
|
||||
}
|
||||
|
||||
12
Microcontrollers/ultrasonicSensor/ultrasonic_sensor.h
Normal file
12
Microcontrollers/ultrasonicSensor/ultrasonic_sensor.h
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* ultrasonic_sensor.h
|
||||
*
|
||||
* Created: 24-3-2021 13:14:50
|
||||
* Author: Sem
|
||||
*/
|
||||
|
||||
|
||||
void ultrasonic_init();
|
||||
void ultrasonic_send_pulse();
|
||||
uint16_t ultrasonic_get_timer_dist();
|
||||
void ultrasonic_handle_interrupt();
|
||||
Reference in New Issue
Block a user