Compare commits
21 Commits
master
...
final-proj
Author | SHA1 | Date | |
---|---|---|---|
![]() |
744115b446 | ||
![]() |
827e52ab5c | ||
dcd24b56c5 | |||
c53844a053 | |||
aea4c6e976 | |||
55025a9ada | |||
![]() |
c38a4eac71 | ||
![]() |
7d2af468b3 | ||
49b8aee14b | |||
57cf2de7c7 | |||
9e28ff2f9a | |||
51dd44c00c | |||
a1de5eafb6 | |||
a628489b2a | |||
c4d7d1cc50 | |||
45e0794fe3 | |||
958073b19b | |||
fa8cc80206 | |||
0e5306387e | |||
a81fa0cb82 | |||
93137fdf09 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@ cmake-build-debug/*
|
|||||||
.idea/*
|
.idea/*
|
||||||
*/build/**
|
*/build/**
|
||||||
*/_build/**
|
*/_build/**
|
||||||
|
*.o
|
||||||
|
4
final_project/.gitignore
vendored
Normal file
4
final_project/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
*.map
|
||||||
|
*.o
|
||||||
|
*.out
|
||||||
|
*-bak
|
24
final_project/312_final.code-workspace
Normal file
24
final_project/312_final.code-workspace
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": "sd_reader"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "lcd_disp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "testing"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"files.associations": {
|
||||||
|
"io.h": "c",
|
||||||
|
"interrupt.h": "c",
|
||||||
|
"periph.h": "c",
|
||||||
|
"comms.h": "c",
|
||||||
|
"string.h": "c",
|
||||||
|
"main.h": "c",
|
||||||
|
"sleep.h": "c"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
0
final_project/comms/comms.c
Normal file
0
final_project/comms/comms.c
Normal file
85
final_project/comms/comms.h
Normal file
85
final_project/comms/comms.h
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
#ifndef COMMS_H_
|
||||||
|
#define COMMS_H_
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Our format goes like this:
|
||||||
|
*
|
||||||
|
* 1 byte command, with data after
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
COMMS_CMD_CLR = 0U, //! Clears LCD and all file names
|
||||||
|
COMMS_CMD_NUM, //! sends the total number of songs to choose from
|
||||||
|
COMMS_CMD_QUERY_NAME, //! Queries for the name of a given song ID
|
||||||
|
COMMS_CMD_REPLY_NAME, //! Responds with the name of the given song ID
|
||||||
|
COMMS_CMD_SELECT_FILE, //! selects a file from the given list to play, data is 1 byte for id
|
||||||
|
COMMS_CMD_PLAY, //! Starts playing file
|
||||||
|
COMMS_CMD_PAUSE //! pauses playing file
|
||||||
|
} comms_cmd_t;
|
||||||
|
|
||||||
|
/** @brief Inline function to send commands and values.
|
||||||
|
*/
|
||||||
|
inline void comms_send(comms_cmd_t cmd) {
|
||||||
|
|
||||||
|
#if defined(__AVR_ATtiny2313__)
|
||||||
|
while (! (UCSRA & (1 << UDRE)));
|
||||||
|
UDR = cmd;
|
||||||
|
#elif defined(__AVR_ATmega328P__)
|
||||||
|
while (! (UCSR0A & (1 << UDRE0)));
|
||||||
|
UDR0 = cmd;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Selects a file from the list on the DAC side.
|
||||||
|
*
|
||||||
|
* If another song is playing, this will stop
|
||||||
|
* that song from playing and select the new one.
|
||||||
|
*/
|
||||||
|
inline void comms_select_file(uint8_t id) {
|
||||||
|
comms_send(COMMS_CMD_SELECT_FILE);
|
||||||
|
comms_send((comms_cmd_t) id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Queries for the name of the given song ID.
|
||||||
|
*/
|
||||||
|
inline void comms_query_name(uint8_t id) {
|
||||||
|
comms_send(COMMS_CMD_QUERY_NAME);
|
||||||
|
comms_send(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Repliers with the name of the requsted song ID
|
||||||
|
*/
|
||||||
|
inline void comms_reply_name(char* name) {
|
||||||
|
uint8_t len = strlen(name);
|
||||||
|
comms_send(COMMS_CMD_REPLY_NAME);
|
||||||
|
comms_send(len);
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < len; i++) {
|
||||||
|
comms_send((uint8_t) name[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Clears the LCD list of files.
|
||||||
|
*/
|
||||||
|
inline void comms_clear() {
|
||||||
|
comms_send(COMMS_CMD_CLR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Starts playing song.
|
||||||
|
*/
|
||||||
|
inline void comms_play() {
|
||||||
|
comms_send(COMMS_CMD_PLAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Pauses playing song.
|
||||||
|
*/
|
||||||
|
inline void comms_pause() {
|
||||||
|
comms_send(COMMS_CMD_PLAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
16
final_project/hw/DAC.sch
Normal file
16
final_project/hw/DAC.sch
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
EESchema Schematic File Version 4
|
||||||
|
EELAYER 30 0
|
||||||
|
EELAYER END
|
||||||
|
$Descr A4 11693 8268
|
||||||
|
encoding utf-8
|
||||||
|
Sheet 2 3
|
||||||
|
Title ""
|
||||||
|
Date ""
|
||||||
|
Rev ""
|
||||||
|
Comp ""
|
||||||
|
Comment1 ""
|
||||||
|
Comment2 ""
|
||||||
|
Comment3 ""
|
||||||
|
Comment4 ""
|
||||||
|
$EndDescr
|
||||||
|
$EndSCHEMATC
|
172
final_project/hw/amp.sch
Normal file
172
final_project/hw/amp.sch
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
EESchema Schematic File Version 4
|
||||||
|
EELAYER 30 0
|
||||||
|
EELAYER END
|
||||||
|
$Descr A4 11693 8268
|
||||||
|
encoding utf-8
|
||||||
|
Sheet 3 3
|
||||||
|
Title ""
|
||||||
|
Date ""
|
||||||
|
Rev ""
|
||||||
|
Comp ""
|
||||||
|
Comment1 ""
|
||||||
|
Comment2 ""
|
||||||
|
Comment3 ""
|
||||||
|
Comment4 ""
|
||||||
|
$EndDescr
|
||||||
|
Text HLabel 2350 1500 0 50 Input ~ 0
|
||||||
|
DAC_out
|
||||||
|
$Comp
|
||||||
|
L Amplifier_Operational:TL072 U?
|
||||||
|
U 1 1 5DDEF8DF
|
||||||
|
P 4500 2400
|
||||||
|
F 0 "U?" H 4500 2767 50 0000 C CNN
|
||||||
|
F 1 "TL072" H 4500 2676 50 0000 C CNN
|
||||||
|
F 2 "" H 4500 2400 50 0001 C CNN
|
||||||
|
F 3 "http://www.ti.com/lit/ds/symlink/tl071.pdf" H 4500 2400 50 0001 C CNN
|
||||||
|
1 4500 2400
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L Amplifier_Operational:TL072 U?
|
||||||
|
U 2 1 5DDF08AD
|
||||||
|
P 6350 2650
|
||||||
|
F 0 "U?" H 6350 3017 50 0000 C CNN
|
||||||
|
F 1 "TL072" H 6350 2926 50 0000 C CNN
|
||||||
|
F 2 "" H 6350 2650 50 0001 C CNN
|
||||||
|
F 3 "http://www.ti.com/lit/ds/symlink/tl071.pdf" H 6350 2650 50 0001 C CNN
|
||||||
|
2 6350 2650
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
2350 1500 3050 1500
|
||||||
|
Wire Wire Line
|
||||||
|
3050 1500 3050 2300
|
||||||
|
Wire Wire Line
|
||||||
|
4150 2500 4200 2500
|
||||||
|
Text Label 5600 2400 0 50 ~ 0
|
||||||
|
DIVIDER_OUT
|
||||||
|
$Comp
|
||||||
|
L Device:R_POT RV?
|
||||||
|
U 1 1 5DDFB96D
|
||||||
|
P 5100 2550
|
||||||
|
F 0 "RV?" H 5031 2596 50 0000 R CNN
|
||||||
|
F 1 "R_POT" H 5031 2505 50 0000 R CNN
|
||||||
|
F 2 "" H 5100 2550 50 0001 C CNN
|
||||||
|
F 3 "~" H 5100 2550 50 0001 C CNN
|
||||||
|
1 5100 2550
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
4800 2400 5100 2400
|
||||||
|
Wire Wire Line
|
||||||
|
5100 2700 5100 2900
|
||||||
|
Wire Wire Line
|
||||||
|
5100 2900 5050 2900
|
||||||
|
$Comp
|
||||||
|
L power:GND #PWR?
|
||||||
|
U 1 1 5DDFD958
|
||||||
|
P 5050 2900
|
||||||
|
F 0 "#PWR?" H 5050 2650 50 0001 C CNN
|
||||||
|
F 1 "GND" H 5055 2727 50 0000 C CNN
|
||||||
|
F 2 "" H 5050 2900 50 0001 C CNN
|
||||||
|
F 3 "" H 5050 2900 50 0001 C CNN
|
||||||
|
1 5050 2900
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
5250 2550 6050 2550
|
||||||
|
Wire Wire Line
|
||||||
|
4150 2500 4150 2650
|
||||||
|
Wire Wire Line
|
||||||
|
4150 2650 4800 2650
|
||||||
|
Wire Wire Line
|
||||||
|
4800 2650 4800 2400
|
||||||
|
Connection ~ 4800 2400
|
||||||
|
Wire Wire Line
|
||||||
|
6050 2750 6050 2950
|
||||||
|
Wire Wire Line
|
||||||
|
6050 2950 6650 2950
|
||||||
|
Wire Wire Line
|
||||||
|
6650 2950 6650 2650
|
||||||
|
Wire Wire Line
|
||||||
|
6650 2650 6850 2650
|
||||||
|
Connection ~ 6650 2650
|
||||||
|
$Comp
|
||||||
|
L Device:R R?
|
||||||
|
U 1 1 5DE007D1
|
||||||
|
P 6850 2800
|
||||||
|
F 0 "R?" H 6920 2846 50 0000 L CNN
|
||||||
|
F 1 "R" H 6920 2755 50 0000 L CNN
|
||||||
|
F 2 "" V 6780 2800 50 0001 C CNN
|
||||||
|
F 3 "~" H 6850 2800 50 0001 C CNN
|
||||||
|
1 6850 2800
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L Device:R R?
|
||||||
|
U 1 1 5DE00F57
|
||||||
|
P 6850 3100
|
||||||
|
F 0 "R?" H 6920 3146 50 0000 L CNN
|
||||||
|
F 1 "R" H 6920 3055 50 0000 L CNN
|
||||||
|
F 2 "" V 6780 3100 50 0001 C CNN
|
||||||
|
F 3 "~" H 6850 3100 50 0001 C CNN
|
||||||
|
1 6850 3100
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
6850 2950 7250 2950
|
||||||
|
Connection ~ 6850 2950
|
||||||
|
Wire Wire Line
|
||||||
|
6850 3250 6850 3350
|
||||||
|
$Comp
|
||||||
|
L power:GND #PWR?
|
||||||
|
U 1 1 5DE01A1C
|
||||||
|
P 6850 3350
|
||||||
|
F 0 "#PWR?" H 6850 3100 50 0001 C CNN
|
||||||
|
F 1 "GND" H 6855 3177 50 0000 C CNN
|
||||||
|
F 2 "" H 6850 3350 50 0001 C CNN
|
||||||
|
F 3 "" H 6850 3350 50 0001 C CNN
|
||||||
|
1 6850 3350
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L Device:C C?
|
||||||
|
U 1 1 5DDF1BEF
|
||||||
|
P 3200 2300
|
||||||
|
F 0 "C?" V 2948 2300 50 0000 C CNN
|
||||||
|
F 1 "C" V 3039 2300 50 0000 C CNN
|
||||||
|
F 2 "" H 3238 2150 50 0001 C CNN
|
||||||
|
F 3 "~" H 3200 2300 50 0001 C CNN
|
||||||
|
1 3200 2300
|
||||||
|
0 1 1 0
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L Device:R 200k
|
||||||
|
U 1 1 5DDF226F
|
||||||
|
P 3700 2450
|
||||||
|
F 0 "200k" H 3770 2496 50 0000 L CNN
|
||||||
|
F 1 "R" H 3770 2405 50 0000 L CNN
|
||||||
|
F 2 "" V 3630 2450 50 0001 C CNN
|
||||||
|
F 3 "~" H 3700 2450 50 0001 C CNN
|
||||||
|
1 3700 2450
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
3350 2300 3700 2300
|
||||||
|
Wire Wire Line
|
||||||
|
3700 2300 4200 2300
|
||||||
|
Connection ~ 3700 2300
|
||||||
|
Wire Wire Line
|
||||||
|
3700 2600 3700 2750
|
||||||
|
$Comp
|
||||||
|
L power:GND #PWR?
|
||||||
|
U 1 1 5DDF33D2
|
||||||
|
P 3700 2750
|
||||||
|
F 0 "#PWR?" H 3700 2500 50 0001 C CNN
|
||||||
|
F 1 "GND" H 3705 2577 50 0000 C CNN
|
||||||
|
F 2 "" H 3700 2750 50 0001 C CNN
|
||||||
|
F 3 "" H 3700 2750 50 0001 C CNN
|
||||||
|
1 3700 2750
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$EndSCHEMATC
|
32
final_project/hw/final.lib
Normal file
32
final_project/hw/final.lib
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
EESchema-LIBRARY Version 2.4
|
||||||
|
#encoding utf-8
|
||||||
|
#
|
||||||
|
# LCD
|
||||||
|
#
|
||||||
|
DEF LCD U 0 40 Y Y 1 F N
|
||||||
|
F0 "U" 250 -1300 50 H V C CNN
|
||||||
|
F1 "LCD" 250 200 50 H V C CNN
|
||||||
|
F2 "" 0 0 50 H I C CNN
|
||||||
|
F3 "" 0 0 50 H I C CNN
|
||||||
|
DRAW
|
||||||
|
S -150 250 350 -1350 0 1 0 f
|
||||||
|
X GND 1 -250 200 100 R 50 50 1 1 W
|
||||||
|
X D3 10 -250 -700 100 R 50 50 1 1 B
|
||||||
|
X D4 11 -250 -800 100 R 50 50 1 1 B
|
||||||
|
X D5 12 -250 -900 100 R 50 50 1 1 B
|
||||||
|
X D6 13 -250 -1000 100 R 50 50 1 1 B
|
||||||
|
X D7 14 -250 -1100 100 R 50 50 1 1 B
|
||||||
|
X NC 15 -250 -1200 100 R 50 50 1 1 N
|
||||||
|
X NC 16 -250 -1300 100 R 50 50 1 1 N
|
||||||
|
X VDD 2 -250 100 100 R 50 50 1 1 W
|
||||||
|
X Vo 3 -250 0 100 R 50 50 1 1 I
|
||||||
|
X RS 4 -250 -100 100 R 50 50 1 1 I
|
||||||
|
X RW 5 -250 -200 100 R 50 50 1 1 I
|
||||||
|
X EN 6 -250 -300 100 R 50 50 1 1 I
|
||||||
|
X D0 7 -250 -400 100 R 50 50 1 1 B
|
||||||
|
X D1 8 -250 -500 100 R 50 50 1 1 B
|
||||||
|
X D2 9 -250 -600 100 R 50 50 1 1 B
|
||||||
|
ENDDRAW
|
||||||
|
ENDDEF
|
||||||
|
#
|
||||||
|
#End Library
|
342
final_project/hw/final_project-cache.lib
Normal file
342
final_project/hw/final_project-cache.lib
Normal file
@ -0,0 +1,342 @@
|
|||||||
|
EESchema-LIBRARY Version 2.4
|
||||||
|
#encoding utf-8
|
||||||
|
#
|
||||||
|
# Amplifier_Operational_TL072
|
||||||
|
#
|
||||||
|
DEF Amplifier_Operational_TL072 U 0 5 Y Y 3 L N
|
||||||
|
F0 "U" 0 200 50 H V L CNN
|
||||||
|
F1 "Amplifier_Operational_TL072" 0 -200 50 H V L CNN
|
||||||
|
F2 "" 0 0 50 H I C CNN
|
||||||
|
F3 "" 0 0 50 H I C CNN
|
||||||
|
ALIAS LM358 AD8620 LMC6062 LMC6082 TL062 TL072 TL082 NE5532 SA5532 RC4558 RC4560 RC4580 LMV358 TS912 TSV912IDT TSV912IST TLC272 TLC277 MCP602 OPA1678 OPA2134 OPA2340 OPA2376xxD OPA2376xxDGK MC33078 MC33178 LM4562 OP249 OP275 ADA4075-2 MCP6002-xP MCP6002-xSN MCP6002-xMS LM7332 OPA2333xxD OPA2333xxDGK LMC6482 LT1492 LTC6081xMS8 LM6172 MCP6L92 NJM2043 NJM2114 NJM4556A NJM4558 NJM4559 NJM4560 NJM4580 NJM5532 ADA4807-2ARM OPA2691 LT6234 OPA2356xxD OPA2356xxDGK OPA1612AxD MC33172 OPA1602 TLV2372 LT6237 OPA2277
|
||||||
|
$FPLIST
|
||||||
|
SOIC*3.9x4.9mm*P1.27mm*
|
||||||
|
DIP*W7.62mm*
|
||||||
|
TO*99*
|
||||||
|
OnSemi*Micro8*
|
||||||
|
TSSOP*3x3mm*P0.65mm*
|
||||||
|
TSSOP*4.4x3mm*P0.65mm*
|
||||||
|
MSOP*3x3mm*P0.65mm*
|
||||||
|
SSOP*3.9x4.9mm*P0.635mm*
|
||||||
|
LFCSP*2x2mm*P0.5mm*
|
||||||
|
*SIP*
|
||||||
|
SOIC*5.3x6.2mm*P1.27mm*
|
||||||
|
$ENDFPLIST
|
||||||
|
DRAW
|
||||||
|
P 4 1 1 10 -200 200 200 0 -200 -200 -200 200 f
|
||||||
|
P 4 2 1 10 -200 200 200 0 -200 -200 -200 200 f
|
||||||
|
X ~ 1 300 0 100 L 50 50 1 1 O
|
||||||
|
X - 2 -300 -100 100 R 50 50 1 1 I
|
||||||
|
X + 3 -300 100 100 R 50 50 1 1 I
|
||||||
|
X + 5 -300 100 100 R 50 50 2 1 I
|
||||||
|
X - 6 -300 -100 100 R 50 50 2 1 I
|
||||||
|
X ~ 7 300 0 100 L 50 50 2 1 O
|
||||||
|
X V- 4 -100 -300 150 U 50 50 3 1 W
|
||||||
|
X V+ 8 -100 300 150 D 50 50 3 1 W
|
||||||
|
ENDDRAW
|
||||||
|
ENDDEF
|
||||||
|
#
|
||||||
|
# Connector_SD_Card
|
||||||
|
#
|
||||||
|
DEF Connector_SD_Card J 0 40 Y Y 1 F N
|
||||||
|
F0 "J" -650 550 50 H V C CNN
|
||||||
|
F1 "Connector_SD_Card" 600 -550 50 H V C CNN
|
||||||
|
F2 "" 0 0 50 H I C CNN
|
||||||
|
F3 "" 0 0 50 H I C CNN
|
||||||
|
$FPLIST
|
||||||
|
SD*
|
||||||
|
$ENDFPLIST
|
||||||
|
DRAW
|
||||||
|
S -350 -375 -250 -425 0 1 0 F
|
||||||
|
S -350 -275 -250 -325 0 1 0 F
|
||||||
|
S -350 -175 -250 -225 0 1 0 F
|
||||||
|
S -350 -75 -250 -125 0 1 0 F
|
||||||
|
S -350 25 -250 -25 0 1 0 F
|
||||||
|
S -350 125 -250 75 0 1 0 F
|
||||||
|
S -350 225 -250 175 0 1 0 F
|
||||||
|
S -350 325 -250 275 0 1 0 F
|
||||||
|
S -300 425 -200 375 0 1 0 F
|
||||||
|
P 6 0 1 0 -400 350 -300 450 800 450 800 -450 -400 -450 -400 350 f
|
||||||
|
P 6 0 1 0 650 450 650 500 -800 500 -800 -500 650 -500 650 -450 N
|
||||||
|
X CD/DAT3 1 -900 300 100 R 50 50 1 1 I
|
||||||
|
X CARD_DETECT 10 900 200 100 L 50 50 1 1 I
|
||||||
|
X WRITE_PROTECT 11 900 100 100 L 50 50 1 1 I
|
||||||
|
X SHELL1 12 900 -100 100 L 50 50 1 1 I
|
||||||
|
X SHELL2 13 900 -200 100 L 50 50 1 1 I
|
||||||
|
X CMD 2 -900 200 100 R 50 50 1 1 I
|
||||||
|
X VSS 3 -900 100 100 R 50 50 1 1 W
|
||||||
|
X VDD 4 -900 0 100 R 50 50 1 1 W
|
||||||
|
X CLK 5 -900 -100 100 R 50 50 1 1 I
|
||||||
|
X VSS 6 -900 -200 100 R 50 50 1 1 W
|
||||||
|
X DAT0 7 -900 -300 100 R 50 50 1 1 I
|
||||||
|
X DAT1 8 -900 -400 100 R 50 50 1 1 I
|
||||||
|
X DAT2 9 -900 400 100 R 50 50 1 1 I
|
||||||
|
ENDDRAW
|
||||||
|
ENDDEF
|
||||||
|
#
|
||||||
|
# Device_C
|
||||||
|
#
|
||||||
|
DEF Device_C C 0 10 N Y 1 F N
|
||||||
|
F0 "C" 25 100 50 H V L CNN
|
||||||
|
F1 "Device_C" 25 -100 50 H V L CNN
|
||||||
|
F2 "" 38 -150 50 H I C CNN
|
||||||
|
F3 "" 0 0 50 H I C CNN
|
||||||
|
$FPLIST
|
||||||
|
C_*
|
||||||
|
$ENDFPLIST
|
||||||
|
DRAW
|
||||||
|
P 2 0 1 20 -80 -30 80 -30 N
|
||||||
|
P 2 0 1 20 -80 30 80 30 N
|
||||||
|
X ~ 1 0 150 110 D 50 50 1 1 P
|
||||||
|
X ~ 2 0 -150 110 U 50 50 1 1 P
|
||||||
|
ENDDRAW
|
||||||
|
ENDDEF
|
||||||
|
#
|
||||||
|
# Device_Crystal
|
||||||
|
#
|
||||||
|
DEF Device_Crystal Y 0 40 N N 1 F N
|
||||||
|
F0 "Y" 0 150 50 H V C CNN
|
||||||
|
F1 "Device_Crystal" 0 -150 50 H V C CNN
|
||||||
|
F2 "" 0 0 50 H I C CNN
|
||||||
|
F3 "" 0 0 50 H I C CNN
|
||||||
|
$FPLIST
|
||||||
|
Crystal*
|
||||||
|
$ENDFPLIST
|
||||||
|
DRAW
|
||||||
|
S -45 100 45 -100 0 1 12 N
|
||||||
|
P 2 0 1 0 -100 0 -75 0 N
|
||||||
|
P 2 0 1 20 -75 -50 -75 50 N
|
||||||
|
P 2 0 1 20 75 -50 75 50 N
|
||||||
|
P 2 0 1 0 100 0 75 0 N
|
||||||
|
X 1 1 -150 0 50 R 50 50 1 1 P
|
||||||
|
X 2 2 150 0 50 L 50 50 1 1 P
|
||||||
|
ENDDRAW
|
||||||
|
ENDDEF
|
||||||
|
#
|
||||||
|
# Device_R
|
||||||
|
#
|
||||||
|
DEF Device_R R 0 0 N Y 1 F N
|
||||||
|
F0 "R" 80 0 50 V V C CNN
|
||||||
|
F1 "Device_R" 0 0 50 V V C CNN
|
||||||
|
F2 "" -70 0 50 V I C CNN
|
||||||
|
F3 "" 0 0 50 H I C CNN
|
||||||
|
$FPLIST
|
||||||
|
R_*
|
||||||
|
$ENDFPLIST
|
||||||
|
DRAW
|
||||||
|
S -40 -100 40 100 0 1 10 N
|
||||||
|
X ~ 1 0 150 50 D 50 50 1 1 P
|
||||||
|
X ~ 2 0 -150 50 U 50 50 1 1 P
|
||||||
|
ENDDRAW
|
||||||
|
ENDDEF
|
||||||
|
#
|
||||||
|
# Device_R_POT
|
||||||
|
#
|
||||||
|
DEF Device_R_POT RV 0 40 Y N 1 F N
|
||||||
|
F0 "RV" -175 0 50 V V C CNN
|
||||||
|
F1 "Device_R_POT" -100 0 50 V V C CNN
|
||||||
|
F2 "" 0 0 50 H I C CNN
|
||||||
|
F3 "" 0 0 50 H I C CNN
|
||||||
|
$FPLIST
|
||||||
|
Potentiometer*
|
||||||
|
$ENDFPLIST
|
||||||
|
DRAW
|
||||||
|
S 40 100 -40 -100 0 1 10 N
|
||||||
|
P 2 0 1 0 100 0 60 0 N
|
||||||
|
P 4 0 1 0 45 0 90 20 90 -20 45 0 F
|
||||||
|
X 1 1 0 150 50 D 50 50 1 1 P
|
||||||
|
X 2 2 150 0 50 L 50 50 1 1 P
|
||||||
|
X 3 3 0 -150 50 U 50 50 1 1 P
|
||||||
|
ENDDRAW
|
||||||
|
ENDDEF
|
||||||
|
#
|
||||||
|
# Regulator_Linear_AP2112K-3.3
|
||||||
|
#
|
||||||
|
DEF Regulator_Linear_AP2112K-3.3 U 0 10 Y Y 1 F N
|
||||||
|
F0 "U" -200 225 50 H V L CNN
|
||||||
|
F1 "Regulator_Linear_AP2112K-3.3" 0 225 50 H V L CNN
|
||||||
|
F2 "Package_TO_SOT_SMD:SOT-23-5" 0 325 50 H I C CNN
|
||||||
|
F3 "" 0 100 50 H I C CNN
|
||||||
|
ALIAS AP2204K-1.8 AP2204K-2.5 AP2204K-2.8 AP2204K-3.0 AP2204K-3.3 AP2204K-5.0 AP2127K-1.0 AP2127K-1.2 AP2127K-1.5 AP2127K-1.8 AP2127K-2.5 AP2127K-2.8 AP2127K-3.0 AP2127K-3.3 AP2127K-4.2 AP2127K-4.75 AP2112K-1.2 AP2112K-1.8 AP2112K-2.5 AP2112K-2.6 AP2112K-3.3
|
||||||
|
$FPLIST
|
||||||
|
SOT?23?5*
|
||||||
|
$ENDFPLIST
|
||||||
|
DRAW
|
||||||
|
S -200 175 200 -200 0 1 10 f
|
||||||
|
X VIN 1 -300 100 100 R 50 50 1 1 W
|
||||||
|
X GND 2 0 -300 100 U 50 50 1 1 W
|
||||||
|
X EN 3 -300 0 100 R 50 50 1 1 I
|
||||||
|
X NC 4 300 0 100 L 50 50 1 1 N N
|
||||||
|
X VOUT 5 300 100 100 L 50 50 1 1 w
|
||||||
|
ENDDRAW
|
||||||
|
ENDDEF
|
||||||
|
#
|
||||||
|
# Switch_SW_Push
|
||||||
|
#
|
||||||
|
DEF Switch_SW_Push SW 0 40 N N 1 F N
|
||||||
|
F0 "SW" 50 100 50 H V L CNN
|
||||||
|
F1 "Switch_SW_Push" 0 -60 50 H V C CNN
|
||||||
|
F2 "" 0 200 50 H I C CNN
|
||||||
|
F3 "" 0 200 50 H I C CNN
|
||||||
|
DRAW
|
||||||
|
C -80 0 20 0 1 0 N
|
||||||
|
C 80 0 20 0 1 0 N
|
||||||
|
P 2 0 1 0 0 50 0 120 N
|
||||||
|
P 2 0 1 0 100 50 -100 50 N
|
||||||
|
X 1 1 -200 0 100 R 50 50 0 1 P
|
||||||
|
X 2 2 200 0 100 L 50 50 0 1 P
|
||||||
|
ENDDRAW
|
||||||
|
ENDDEF
|
||||||
|
#
|
||||||
|
# final_LCD
|
||||||
|
#
|
||||||
|
DEF final_LCD U 0 40 Y Y 1 F N
|
||||||
|
F0 "U" 250 -1300 50 H V C CNN
|
||||||
|
F1 "final_LCD" 250 200 50 H V C CNN
|
||||||
|
F2 "" 0 0 50 H I C CNN
|
||||||
|
F3 "" 0 0 50 H I C CNN
|
||||||
|
DRAW
|
||||||
|
S -150 250 350 -1350 0 1 0 f
|
||||||
|
X GND 1 -250 200 100 R 50 50 1 1 W
|
||||||
|
X D3 10 -250 -700 100 R 50 50 1 1 B
|
||||||
|
X D4 11 -250 -800 100 R 50 50 1 1 B
|
||||||
|
X D5 12 -250 -900 100 R 50 50 1 1 B
|
||||||
|
X D6 13 -250 -1000 100 R 50 50 1 1 B
|
||||||
|
X D7 14 -250 -1100 100 R 50 50 1 1 B
|
||||||
|
X NC 15 -250 -1200 100 R 50 50 1 1 N
|
||||||
|
X NC 16 -250 -1300 100 R 50 50 1 1 N
|
||||||
|
X VDD 2 -250 100 100 R 50 50 1 1 W
|
||||||
|
X Vo 3 -250 0 100 R 50 50 1 1 I
|
||||||
|
X RS 4 -250 -100 100 R 50 50 1 1 I
|
||||||
|
X RW 5 -250 -200 100 R 50 50 1 1 I
|
||||||
|
X EN 6 -250 -300 100 R 50 50 1 1 I
|
||||||
|
X D0 7 -250 -400 100 R 50 50 1 1 B
|
||||||
|
X D1 8 -250 -500 100 R 50 50 1 1 B
|
||||||
|
X D2 9 -250 -600 100 R 50 50 1 1 B
|
||||||
|
ENDDRAW
|
||||||
|
ENDDEF
|
||||||
|
#
|
||||||
|
# final_project-rescue_ATmega328-PU-MCU_Microchip_ATmega
|
||||||
|
#
|
||||||
|
DEF final_project-rescue_ATmega328-PU-MCU_Microchip_ATmega U 0 20 Y Y 1 F N
|
||||||
|
F0 "U" -500 1450 50 H V L BNN
|
||||||
|
F1 "final_project-rescue_ATmega328-PU-MCU_Microchip_ATmega" 100 -1450 50 H V L TNN
|
||||||
|
F2 "Package_DIP:DIP-28_W7.62mm" 0 0 50 H I C CIN
|
||||||
|
F3 "" 0 0 50 H I C CNN
|
||||||
|
$FPLIST
|
||||||
|
DIP*W7.62mm*
|
||||||
|
$ENDFPLIST
|
||||||
|
DRAW
|
||||||
|
S -500 -1400 500 1400 0 1 10 f
|
||||||
|
X ~RESET~/PC6 1 600 -300 100 L 50 50 1 1 T
|
||||||
|
X XTAL2/PB7 10 600 500 100 L 50 50 1 1 T
|
||||||
|
X PD5 11 600 -1000 100 L 50 50 1 1 T
|
||||||
|
X PD6 12 600 -1100 100 L 50 50 1 1 T
|
||||||
|
X PD7 13 600 -1200 100 L 50 50 1 1 T
|
||||||
|
X PB0 14 600 1200 100 L 50 50 1 1 T
|
||||||
|
X PB1 15 600 1100 100 L 50 50 1 1 T
|
||||||
|
X PB2 16 600 1000 100 L 50 50 1 1 T
|
||||||
|
X PB3 17 600 900 100 L 50 50 1 1 T
|
||||||
|
X PB4 18 600 800 100 L 50 50 1 1 T
|
||||||
|
X PB5 19 600 700 100 L 50 50 1 1 T
|
||||||
|
X PD0 2 600 -500 100 L 50 50 1 1 T
|
||||||
|
X AVCC 20 100 1500 100 D 50 50 1 1 W
|
||||||
|
X AREF 21 -600 1200 100 R 50 50 1 1 P
|
||||||
|
X GND 22 0 -1500 100 U 50 50 1 1 P N
|
||||||
|
X PC0 23 600 300 100 L 50 50 1 1 T
|
||||||
|
X PC1 24 600 200 100 L 50 50 1 1 T
|
||||||
|
X PC2 25 600 100 100 L 50 50 1 1 T
|
||||||
|
X PC3 26 600 0 100 L 50 50 1 1 T
|
||||||
|
X PC4 27 600 -100 100 L 50 50 1 1 T
|
||||||
|
X PC5 28 600 -200 100 L 50 50 1 1 T
|
||||||
|
X PD1 3 600 -600 100 L 50 50 1 1 T
|
||||||
|
X PD2 4 600 -700 100 L 50 50 1 1 T
|
||||||
|
X PD3 5 600 -800 100 L 50 50 1 1 T
|
||||||
|
X PD4 6 600 -900 100 L 50 50 1 1 T
|
||||||
|
X VCC 7 0 1500 100 D 50 50 1 1 W
|
||||||
|
X GND 8 0 -1500 100 U 50 50 1 1 W
|
||||||
|
X XTAL1/PB6 9 600 600 100 L 50 50 1 1 T
|
||||||
|
ENDDRAW
|
||||||
|
ENDDEF
|
||||||
|
#
|
||||||
|
# final_project-rescue_ATtiny2313-20MU-MCU_Microchip_ATtiny
|
||||||
|
#
|
||||||
|
DEF final_project-rescue_ATtiny2313-20MU-MCU_Microchip_ATtiny U 0 20 Y Y 1 F N
|
||||||
|
F0 "U" -500 1050 50 H V L BNN
|
||||||
|
F1 "final_project-rescue_ATtiny2313-20MU-MCU_Microchip_ATtiny" 100 -1050 50 H V L TNN
|
||||||
|
F2 "Package_DFN_QFN:MLF-20-1EP_4x4mm_P0.5mm_EP2.6x2.6mm" 0 0 50 H I C CIN
|
||||||
|
F3 "" 0 0 50 H I C CNN
|
||||||
|
$FPLIST
|
||||||
|
MLF*1EP*4x4mm*P0.5mm*
|
||||||
|
$ENDFPLIST
|
||||||
|
DRAW
|
||||||
|
S -500 -1000 500 1000 0 1 10 f
|
||||||
|
X PD1 1 600 -200 100 L 50 50 1 1 T
|
||||||
|
X PB0 10 600 800 100 L 50 50 1 1 T
|
||||||
|
X PB1 11 600 700 100 L 50 50 1 1 T
|
||||||
|
X PB2 12 600 600 100 L 50 50 1 1 T
|
||||||
|
X PB3 13 600 500 100 L 50 50 1 1 T
|
||||||
|
X PB4 14 600 400 100 L 50 50 1 1 T
|
||||||
|
X PB5 15 600 300 100 L 50 50 1 1 T
|
||||||
|
X PB6 16 600 200 100 L 50 50 1 1 T
|
||||||
|
X PB7 17 600 100 100 L 50 50 1 1 T
|
||||||
|
X VCC 18 0 1100 100 D 50 50 1 1 W
|
||||||
|
X PA2/~RESET 19 -600 800 100 R 50 50 1 1 T
|
||||||
|
X PA1/XTAL2 2 -600 400 100 R 50 50 1 1 T
|
||||||
|
X PD0 20 600 -100 100 L 50 50 1 1 T
|
||||||
|
X GND 21 0 -1100 100 U 50 50 1 1 P N
|
||||||
|
X PA0/XTAL1 3 -600 600 100 R 50 50 1 1 T
|
||||||
|
X PD2 4 600 -300 100 L 50 50 1 1 T
|
||||||
|
X PD3 5 600 -400 100 L 50 50 1 1 T
|
||||||
|
X PD4 6 600 -500 100 L 50 50 1 1 T
|
||||||
|
X PD5 7 600 -600 100 L 50 50 1 1 T
|
||||||
|
X GND 8 0 -1100 100 U 50 50 1 1 W
|
||||||
|
X PD6 9 600 -700 100 L 50 50 1 1 T
|
||||||
|
ENDDRAW
|
||||||
|
ENDDEF
|
||||||
|
#
|
||||||
|
# power_+3V3
|
||||||
|
#
|
||||||
|
DEF power_+3V3 #PWR 0 0 Y Y 1 F P
|
||||||
|
F0 "#PWR" 0 -150 50 H I C CNN
|
||||||
|
F1 "power_+3V3" 0 140 50 H V C CNN
|
||||||
|
F2 "" 0 0 50 H I C CNN
|
||||||
|
F3 "" 0 0 50 H I C CNN
|
||||||
|
ALIAS +3.3V
|
||||||
|
DRAW
|
||||||
|
P 2 0 1 0 -30 50 0 100 N
|
||||||
|
P 2 0 1 0 0 0 0 100 N
|
||||||
|
P 2 0 1 0 0 100 30 50 N
|
||||||
|
X +3V3 1 0 0 0 U 50 50 1 1 W N
|
||||||
|
ENDDRAW
|
||||||
|
ENDDEF
|
||||||
|
#
|
||||||
|
# power_+5V
|
||||||
|
#
|
||||||
|
DEF power_+5V #PWR 0 0 Y Y 1 F P
|
||||||
|
F0 "#PWR" 0 -150 50 H I C CNN
|
||||||
|
F1 "power_+5V" 0 140 50 H V C CNN
|
||||||
|
F2 "" 0 0 50 H I C CNN
|
||||||
|
F3 "" 0 0 50 H I C CNN
|
||||||
|
DRAW
|
||||||
|
P 2 0 1 0 -30 50 0 100 N
|
||||||
|
P 2 0 1 0 0 0 0 100 N
|
||||||
|
P 2 0 1 0 0 100 30 50 N
|
||||||
|
X +5V 1 0 0 0 U 50 50 1 1 W N
|
||||||
|
ENDDRAW
|
||||||
|
ENDDEF
|
||||||
|
#
|
||||||
|
# power_GND
|
||||||
|
#
|
||||||
|
DEF power_GND #PWR 0 0 Y Y 1 F P
|
||||||
|
F0 "#PWR" 0 -250 50 H I C CNN
|
||||||
|
F1 "power_GND" 0 -150 50 H V C CNN
|
||||||
|
F2 "" 0 0 50 H I C CNN
|
||||||
|
F3 "" 0 0 50 H I C CNN
|
||||||
|
DRAW
|
||||||
|
P 6 0 1 0 0 0 0 -50 50 -50 0 -100 -50 -50 0 -50 N
|
||||||
|
X GND 1 0 0 0 D 50 50 1 1 W N
|
||||||
|
ENDDRAW
|
||||||
|
ENDDEF
|
||||||
|
#
|
||||||
|
#End Library
|
3
final_project/hw/final_project-rescue.dcm
Normal file
3
final_project/hw/final_project-rescue.dcm
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
EESchema-DOCLIB Version 2.0
|
||||||
|
#
|
||||||
|
#End Doc Library
|
83
final_project/hw/final_project-rescue.lib
Normal file
83
final_project/hw/final_project-rescue.lib
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
EESchema-LIBRARY Version 2.4
|
||||||
|
#encoding utf-8
|
||||||
|
#
|
||||||
|
# ATmega328-PU-MCU_Microchip_ATmega
|
||||||
|
#
|
||||||
|
DEF ATmega328-PU-MCU_Microchip_ATmega U 0 20 Y Y 1 F N
|
||||||
|
F0 "U" -500 1450 50 H V L BNN
|
||||||
|
F1 "ATmega328-PU-MCU_Microchip_ATmega" 100 -1450 50 H V L TNN
|
||||||
|
F2 "Package_DIP:DIP-28_W7.62mm" 0 0 50 H I C CIN
|
||||||
|
F3 "" 0 0 50 H I C CNN
|
||||||
|
$FPLIST
|
||||||
|
DIP*W7.62mm*
|
||||||
|
$ENDFPLIST
|
||||||
|
DRAW
|
||||||
|
S -500 -1400 500 1400 0 1 10 f
|
||||||
|
X ~RESET~/PC6 1 600 -300 100 L 50 50 1 1 T
|
||||||
|
X XTAL2/PB7 10 600 500 100 L 50 50 1 1 T
|
||||||
|
X PD5 11 600 -1000 100 L 50 50 1 1 T
|
||||||
|
X PD6 12 600 -1100 100 L 50 50 1 1 T
|
||||||
|
X PD7 13 600 -1200 100 L 50 50 1 1 T
|
||||||
|
X PB0 14 600 1200 100 L 50 50 1 1 T
|
||||||
|
X PB1 15 600 1100 100 L 50 50 1 1 T
|
||||||
|
X PB2 16 600 1000 100 L 50 50 1 1 T
|
||||||
|
X PB3 17 600 900 100 L 50 50 1 1 T
|
||||||
|
X PB4 18 600 800 100 L 50 50 1 1 T
|
||||||
|
X PB5 19 600 700 100 L 50 50 1 1 T
|
||||||
|
X PD0 2 600 -500 100 L 50 50 1 1 T
|
||||||
|
X AVCC 20 100 1500 100 D 50 50 1 1 W
|
||||||
|
X AREF 21 -600 1200 100 R 50 50 1 1 P
|
||||||
|
X GND 22 0 -1500 100 U 50 50 1 1 P N
|
||||||
|
X PC0 23 600 300 100 L 50 50 1 1 T
|
||||||
|
X PC1 24 600 200 100 L 50 50 1 1 T
|
||||||
|
X PC2 25 600 100 100 L 50 50 1 1 T
|
||||||
|
X PC3 26 600 0 100 L 50 50 1 1 T
|
||||||
|
X PC4 27 600 -100 100 L 50 50 1 1 T
|
||||||
|
X PC5 28 600 -200 100 L 50 50 1 1 T
|
||||||
|
X PD1 3 600 -600 100 L 50 50 1 1 T
|
||||||
|
X PD2 4 600 -700 100 L 50 50 1 1 T
|
||||||
|
X PD3 5 600 -800 100 L 50 50 1 1 T
|
||||||
|
X PD4 6 600 -900 100 L 50 50 1 1 T
|
||||||
|
X VCC 7 0 1500 100 D 50 50 1 1 W
|
||||||
|
X GND 8 0 -1500 100 U 50 50 1 1 W
|
||||||
|
X XTAL1/PB6 9 600 600 100 L 50 50 1 1 T
|
||||||
|
ENDDRAW
|
||||||
|
ENDDEF
|
||||||
|
#
|
||||||
|
# ATtiny2313-20MU-MCU_Microchip_ATtiny
|
||||||
|
#
|
||||||
|
DEF ATtiny2313-20MU-MCU_Microchip_ATtiny U 0 20 Y Y 1 F N
|
||||||
|
F0 "U" -500 1050 50 H V L BNN
|
||||||
|
F1 "ATtiny2313-20MU-MCU_Microchip_ATtiny" 100 -1050 50 H V L TNN
|
||||||
|
F2 "Package_DFN_QFN:MLF-20-1EP_4x4mm_P0.5mm_EP2.6x2.6mm" 0 0 50 H I C CIN
|
||||||
|
F3 "" 0 0 50 H I C CNN
|
||||||
|
$FPLIST
|
||||||
|
MLF*1EP*4x4mm*P0.5mm*
|
||||||
|
$ENDFPLIST
|
||||||
|
DRAW
|
||||||
|
S -500 -1000 500 1000 0 1 10 f
|
||||||
|
X PD1 1 600 -200 100 L 50 50 1 1 T
|
||||||
|
X PB0 10 600 800 100 L 50 50 1 1 T
|
||||||
|
X PB1 11 600 700 100 L 50 50 1 1 T
|
||||||
|
X PB2 12 600 600 100 L 50 50 1 1 T
|
||||||
|
X PB3 13 600 500 100 L 50 50 1 1 T
|
||||||
|
X PB4 14 600 400 100 L 50 50 1 1 T
|
||||||
|
X PB5 15 600 300 100 L 50 50 1 1 T
|
||||||
|
X PB6 16 600 200 100 L 50 50 1 1 T
|
||||||
|
X PB7 17 600 100 100 L 50 50 1 1 T
|
||||||
|
X VCC 18 0 1100 100 D 50 50 1 1 W
|
||||||
|
X PA2/~RESET 19 -600 800 100 R 50 50 1 1 T
|
||||||
|
X PA1/XTAL2 2 -600 400 100 R 50 50 1 1 T
|
||||||
|
X PD0 20 600 -100 100 L 50 50 1 1 T
|
||||||
|
X GND 21 0 -1100 100 U 50 50 1 1 P N
|
||||||
|
X PA0/XTAL1 3 -600 600 100 R 50 50 1 1 T
|
||||||
|
X PD2 4 600 -300 100 L 50 50 1 1 T
|
||||||
|
X PD3 5 600 -400 100 L 50 50 1 1 T
|
||||||
|
X PD4 6 600 -500 100 L 50 50 1 1 T
|
||||||
|
X PD5 7 600 -600 100 L 50 50 1 1 T
|
||||||
|
X GND 8 0 -1100 100 U 50 50 1 1 W
|
||||||
|
X PD6 9 600 -700 100 L 50 50 1 1 T
|
||||||
|
ENDDRAW
|
||||||
|
ENDDEF
|
||||||
|
#
|
||||||
|
#End Library
|
1
final_project/hw/final_project.kicad_pcb
Normal file
1
final_project/hw/final_project.kicad_pcb
Normal file
@ -0,0 +1 @@
|
|||||||
|
(kicad_pcb (version 4) (host kicad "dummy file") )
|
33
final_project/hw/final_project.pro
Normal file
33
final_project/hw/final_project.pro
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
update=22/05/2015 07:44:53
|
||||||
|
version=1
|
||||||
|
last_client=kicad
|
||||||
|
[general]
|
||||||
|
version=1
|
||||||
|
RootSch=
|
||||||
|
BoardNm=
|
||||||
|
[pcbnew]
|
||||||
|
version=1
|
||||||
|
LastNetListRead=
|
||||||
|
UseCmpFile=1
|
||||||
|
PadDrill=0.600000000000
|
||||||
|
PadDrillOvalY=0.600000000000
|
||||||
|
PadSizeH=1.500000000000
|
||||||
|
PadSizeV=1.500000000000
|
||||||
|
PcbTextSizeV=1.500000000000
|
||||||
|
PcbTextSizeH=1.500000000000
|
||||||
|
PcbTextThickness=0.300000000000
|
||||||
|
ModuleTextSizeV=1.000000000000
|
||||||
|
ModuleTextSizeH=1.000000000000
|
||||||
|
ModuleTextSizeThickness=0.150000000000
|
||||||
|
SolderMaskClearance=0.000000000000
|
||||||
|
SolderMaskMinWidth=0.000000000000
|
||||||
|
DrawSegmentWidth=0.200000000000
|
||||||
|
BoardOutlineThickness=0.100000000000
|
||||||
|
ModuleOutlineThickness=0.150000000000
|
||||||
|
[cvpcb]
|
||||||
|
version=1
|
||||||
|
NetIExt=net
|
||||||
|
[eeschema]
|
||||||
|
version=1
|
||||||
|
LibDir=
|
||||||
|
[eeschema/libraries]
|
788
final_project/hw/final_project.sch
Normal file
788
final_project/hw/final_project.sch
Normal file
@ -0,0 +1,788 @@
|
|||||||
|
EESchema Schematic File Version 4
|
||||||
|
EELAYER 30 0
|
||||||
|
EELAYER END
|
||||||
|
$Descr A4 11693 8268
|
||||||
|
encoding utf-8
|
||||||
|
Sheet 1 3
|
||||||
|
Title ""
|
||||||
|
Date ""
|
||||||
|
Rev ""
|
||||||
|
Comp ""
|
||||||
|
Comment1 ""
|
||||||
|
Comment2 ""
|
||||||
|
Comment3 ""
|
||||||
|
Comment4 ""
|
||||||
|
$EndDescr
|
||||||
|
$Comp
|
||||||
|
L final_project-rescue:ATmega328-PU-MCU_Microchip_ATmega U?
|
||||||
|
U 1 1 5DDD9932
|
||||||
|
P 3450 2950
|
||||||
|
F 0 "U?" H 2806 2996 50 0000 R CNN
|
||||||
|
F 1 "ATmega328-PU" H 2806 2905 50 0000 R CNN
|
||||||
|
F 2 "Package_DIP:DIP-28_W7.62mm" H 3450 2950 50 0001 C CIN
|
||||||
|
F 3 "http://ww1.microchip.com/downloads/en/DeviceDoc/ATmega328_P%20AVR%20MCU%20with%20picoPower%20Technology%20Data%20Sheet%2040001984A.pdf" H 3450 2950 50 0001 C CNN
|
||||||
|
1 3450 2950
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
4050 2250 4250 2250
|
||||||
|
Wire Wire Line
|
||||||
|
4050 2150 4250 2150
|
||||||
|
Wire Wire Line
|
||||||
|
4050 2050 4250 2050
|
||||||
|
Wire Wire Line
|
||||||
|
4050 1950 4250 1950
|
||||||
|
Text Label 4250 2250 0 50 ~ 0
|
||||||
|
SCK
|
||||||
|
Text Label 4250 2150 0 50 ~ 0
|
||||||
|
MOSI
|
||||||
|
Text Label 4250 2050 0 50 ~ 0
|
||||||
|
MISO
|
||||||
|
Text Label 4250 1950 0 50 ~ 0
|
||||||
|
CS
|
||||||
|
Wire Wire Line
|
||||||
|
4050 3450 4250 3450
|
||||||
|
Wire Wire Line
|
||||||
|
4050 3550 4250 3550
|
||||||
|
Text Label 4250 3450 0 50 ~ 0
|
||||||
|
RXD
|
||||||
|
Text Label 4250 3550 0 50 ~ 0
|
||||||
|
TXD
|
||||||
|
$Comp
|
||||||
|
L Device:Crystal Y?
|
||||||
|
U 1 1 5DDDDF12
|
||||||
|
P 4650 2450
|
||||||
|
F 0 "Y?" V 4604 2581 50 0000 L CNN
|
||||||
|
F 1 "16MHz" V 4695 2581 50 0000 L CNN
|
||||||
|
F 2 "" H 4650 2450 50 0001 C CNN
|
||||||
|
F 3 "~" H 4650 2450 50 0001 C CNN
|
||||||
|
1 4650 2450
|
||||||
|
0 1 1 0
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
4650 2350 4650 2300
|
||||||
|
Wire Wire Line
|
||||||
|
4050 2450 4300 2450
|
||||||
|
Wire Wire Line
|
||||||
|
4650 2300 5250 2300
|
||||||
|
Connection ~ 4650 2300
|
||||||
|
Wire Wire Line
|
||||||
|
4650 2600 5150 2600
|
||||||
|
$Comp
|
||||||
|
L Device:C C?
|
||||||
|
U 1 1 5DDDEABA
|
||||||
|
P 5150 2750
|
||||||
|
F 0 "C?" H 5265 2796 50 0000 L CNN
|
||||||
|
F 1 "18p" H 5265 2705 50 0000 L CNN
|
||||||
|
F 2 "" H 5188 2600 50 0001 C CNN
|
||||||
|
F 3 "~" H 5150 2750 50 0001 C CNN
|
||||||
|
1 5150 2750
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L Device:C C?
|
||||||
|
U 1 1 5DDDEEAD
|
||||||
|
P 5250 2450
|
||||||
|
F 0 "C?" H 5365 2496 50 0000 L CNN
|
||||||
|
F 1 "18p" H 5365 2405 50 0000 L CNN
|
||||||
|
F 2 "" H 5288 2300 50 0001 C CNN
|
||||||
|
F 3 "~" H 5250 2450 50 0001 C CNN
|
||||||
|
1 5250 2450
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
5250 2600 5250 2900
|
||||||
|
Wire Wire Line
|
||||||
|
5250 2900 5150 2900
|
||||||
|
Wire Wire Line
|
||||||
|
5150 2900 5150 3000
|
||||||
|
Connection ~ 5150 2900
|
||||||
|
$Comp
|
||||||
|
L power:GND #PWR?
|
||||||
|
U 1 1 5DDDF660
|
||||||
|
P 5150 3000
|
||||||
|
F 0 "#PWR?" H 5150 2750 50 0001 C CNN
|
||||||
|
F 1 "GND" H 5155 2827 50 0000 C CNN
|
||||||
|
F 2 "" H 5150 3000 50 0001 C CNN
|
||||||
|
F 3 "" H 5150 3000 50 0001 C CNN
|
||||||
|
1 5150 3000
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
4050 1750 4500 1750
|
||||||
|
Wire Wire Line
|
||||||
|
4050 1850 4500 1850
|
||||||
|
Wire Wire Line
|
||||||
|
4050 2650 4150 2650
|
||||||
|
Wire Wire Line
|
||||||
|
4050 2950 4150 2950
|
||||||
|
Wire Wire Line
|
||||||
|
4050 3050 4150 3050
|
||||||
|
Wire Wire Line
|
||||||
|
4050 3150 4150 3150
|
||||||
|
Wire Wire Line
|
||||||
|
4050 3650 4600 3650
|
||||||
|
Wire Wire Line
|
||||||
|
4050 3750 4600 3750
|
||||||
|
Wire Wire Line
|
||||||
|
4050 3850 4600 3850
|
||||||
|
Wire Wire Line
|
||||||
|
4050 3950 4600 3950
|
||||||
|
Wire Wire Line
|
||||||
|
4050 4050 4600 4050
|
||||||
|
Wire Wire Line
|
||||||
|
4050 4150 4600 4150
|
||||||
|
Text Label 4600 3650 0 50 ~ 0
|
||||||
|
DAC6
|
||||||
|
Text Label 4600 3750 0 50 ~ 0
|
||||||
|
DAC7
|
||||||
|
Text Label 4600 3850 0 50 ~ 0
|
||||||
|
DAC8
|
||||||
|
Text Label 4600 3950 0 50 ~ 0
|
||||||
|
DAC9
|
||||||
|
Text Label 4600 4050 0 50 ~ 0
|
||||||
|
DAC10
|
||||||
|
Text Label 4600 4150 0 50 ~ 0
|
||||||
|
DAC11
|
||||||
|
Text Label 4500 1750 0 50 ~ 0
|
||||||
|
DAC12
|
||||||
|
Text Label 4500 1850 0 50 ~ 0
|
||||||
|
DAC13
|
||||||
|
Wire Wire Line
|
||||||
|
3450 1450 3450 1300
|
||||||
|
Wire Wire Line
|
||||||
|
3450 4450 3450 4600
|
||||||
|
$Comp
|
||||||
|
L power:+5V #PWR?
|
||||||
|
U 1 1 5DDEFED6
|
||||||
|
P 3450 1300
|
||||||
|
F 0 "#PWR?" H 3450 1150 50 0001 C CNN
|
||||||
|
F 1 "+5V" H 3465 1473 50 0000 C CNN
|
||||||
|
F 2 "" H 3450 1300 50 0001 C CNN
|
||||||
|
F 3 "" H 3450 1300 50 0001 C CNN
|
||||||
|
1 3450 1300
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L power:GND #PWR?
|
||||||
|
U 1 1 5DDF0E43
|
||||||
|
P 3450 4600
|
||||||
|
F 0 "#PWR?" H 3450 4350 50 0001 C CNN
|
||||||
|
F 1 "GND" H 3455 4427 50 0000 C CNN
|
||||||
|
F 2 "" H 3450 4600 50 0001 C CNN
|
||||||
|
F 3 "" H 3450 4600 50 0001 C CNN
|
||||||
|
1 3450 4600
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L power:GND #PWR?
|
||||||
|
U 1 1 5DDF122E
|
||||||
|
P 6650 3800
|
||||||
|
F 0 "#PWR?" H 6650 3550 50 0001 C CNN
|
||||||
|
F 1 "GND" H 6655 3627 50 0000 C CNN
|
||||||
|
F 2 "" H 6650 3800 50 0001 C CNN
|
||||||
|
F 3 "" H 6650 3800 50 0001 C CNN
|
||||||
|
1 6650 3800
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
NoConn ~ 4050 3250
|
||||||
|
NoConn ~ 2850 1750
|
||||||
|
NoConn ~ 3550 1450
|
||||||
|
$Sheet
|
||||||
|
S 1800 5200 1550 1500
|
||||||
|
U 5DDEEC27
|
||||||
|
F0 "DAC" 50
|
||||||
|
F1 "DAC.sch" 50
|
||||||
|
F2 "DAC_OUT" I R 3350 5300 50
|
||||||
|
F3 "DAC0" I L 1800 5300 50
|
||||||
|
F4 "DAC1" I L 1800 5400 50
|
||||||
|
F5 "DAC2" I L 1800 5500 50
|
||||||
|
F6 "DAC3" I L 1800 5600 50
|
||||||
|
F7 "DAC4" I L 1800 5700 50
|
||||||
|
F8 "DAC5" I L 1800 5800 50
|
||||||
|
F9 "DAC6" I L 1800 5900 50
|
||||||
|
F10 "DAC7" I L 1800 6000 50
|
||||||
|
F11 "DAC8" I L 1800 6100 50
|
||||||
|
F12 "DAC9" I L 1800 6200 50
|
||||||
|
F13 "DAC10" I L 1800 6300 50
|
||||||
|
F14 "DAC11" I L 1800 6400 50
|
||||||
|
F15 "DAC12" I L 1800 6500 50
|
||||||
|
F16 "DAC13" I L 1800 6600 50
|
||||||
|
$EndSheet
|
||||||
|
$Sheet
|
||||||
|
S 5450 5300 1450 900
|
||||||
|
U 5DDEF065
|
||||||
|
F0 "amp" 50
|
||||||
|
F1 "amp.sch" 50
|
||||||
|
F2 "DAC_out" I L 5450 5400 50
|
||||||
|
$EndSheet
|
||||||
|
$Comp
|
||||||
|
L final:LCD U?
|
||||||
|
U 1 1 5DE2158A
|
||||||
|
P 9600 1500
|
||||||
|
F 0 "U?" H 9850 200 50 0000 L CNN
|
||||||
|
F 1 "LCD" H 9800 1700 50 0000 L CNN
|
||||||
|
F 2 "" H 9600 1500 50 0001 C CNN
|
||||||
|
F 3 "" H 9600 1500 50 0001 C CNN
|
||||||
|
1 9600 1500
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Text Label 9350 2300 2 50 ~ 0
|
||||||
|
LCD_D4
|
||||||
|
Text Label 9350 2400 2 50 ~ 0
|
||||||
|
LCD_D5
|
||||||
|
Text Label 9350 2500 2 50 ~ 0
|
||||||
|
LCD_D6
|
||||||
|
Text Label 9350 2600 2 50 ~ 0
|
||||||
|
LCD_D7
|
||||||
|
Text Label 9350 1600 2 50 ~ 0
|
||||||
|
LCD_RS
|
||||||
|
Text Label 9350 1700 2 50 ~ 0
|
||||||
|
LCD_RW
|
||||||
|
$Comp
|
||||||
|
L power:GND #PWR?
|
||||||
|
U 1 1 5DE24EEB
|
||||||
|
P 8750 1500
|
||||||
|
F 0 "#PWR?" H 8750 1250 50 0001 C CNN
|
||||||
|
F 1 "GND" H 8755 1327 50 0000 C CNN
|
||||||
|
F 2 "" H 8750 1500 50 0001 C CNN
|
||||||
|
F 3 "" H 8750 1500 50 0001 C CNN
|
||||||
|
1 8750 1500
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
9350 1400 9200 1400
|
||||||
|
Wire Wire Line
|
||||||
|
9200 1400 9200 1000
|
||||||
|
$Comp
|
||||||
|
L power:+5V #PWR?
|
||||||
|
U 1 1 5DE25CF2
|
||||||
|
P 9200 1000
|
||||||
|
F 0 "#PWR?" H 9200 850 50 0001 C CNN
|
||||||
|
F 1 "+5V" H 9215 1173 50 0000 C CNN
|
||||||
|
F 2 "" H 9200 1000 50 0001 C CNN
|
||||||
|
F 3 "" H 9200 1000 50 0001 C CNN
|
||||||
|
1 9200 1000
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Text Label 9350 1500 2 50 ~ 0
|
||||||
|
LCD_CONTRAST
|
||||||
|
Text Label 9350 1800 2 50 ~ 0
|
||||||
|
LCD_EN
|
||||||
|
NoConn ~ 9350 1900
|
||||||
|
NoConn ~ 9350 2000
|
||||||
|
NoConn ~ 9350 2100
|
||||||
|
NoConn ~ 9350 2200
|
||||||
|
$Comp
|
||||||
|
L power:GND #PWR?
|
||||||
|
U 1 1 5DE2FCEC
|
||||||
|
P 10350 1700
|
||||||
|
F 0 "#PWR?" H 10350 1450 50 0001 C CNN
|
||||||
|
F 1 "GND" H 10355 1527 50 0000 C CNN
|
||||||
|
F 2 "" H 10350 1700 50 0001 C CNN
|
||||||
|
F 3 "" H 10350 1700 50 0001 C CNN
|
||||||
|
1 10350 1700
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L power:+5V #PWR?
|
||||||
|
U 1 1 5DE2FA18
|
||||||
|
P 10350 1000
|
||||||
|
F 0 "#PWR?" H 10350 850 50 0001 C CNN
|
||||||
|
F 1 "+5V" H 10365 1173 50 0000 C CNN
|
||||||
|
F 2 "" H 10350 1000 50 0001 C CNN
|
||||||
|
F 3 "" H 10350 1000 50 0001 C CNN
|
||||||
|
1 10350 1000
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Text Label 10550 1350 0 50 ~ 0
|
||||||
|
LCD_CONTRAST
|
||||||
|
Wire Wire Line
|
||||||
|
10350 1350 10350 1400
|
||||||
|
Connection ~ 10350 1350
|
||||||
|
Wire Wire Line
|
||||||
|
10350 1350 10550 1350
|
||||||
|
Wire Wire Line
|
||||||
|
10350 1300 10350 1350
|
||||||
|
$Comp
|
||||||
|
L Device:R R?
|
||||||
|
U 1 1 5DE2D84F
|
||||||
|
P 10350 1550
|
||||||
|
F 0 "R?" H 10420 1596 50 0000 L CNN
|
||||||
|
F 1 "R" H 10420 1505 50 0000 L CNN
|
||||||
|
F 2 "" V 10280 1550 50 0001 C CNN
|
||||||
|
F 3 "~" H 10350 1550 50 0001 C CNN
|
||||||
|
1 10350 1550
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L Device:R R?
|
||||||
|
U 1 1 5DE2D413
|
||||||
|
P 10350 1150
|
||||||
|
F 0 "R?" H 10420 1196 50 0000 L CNN
|
||||||
|
F 1 "R" H 10420 1105 50 0000 L CNN
|
||||||
|
F 2 "" V 10280 1150 50 0001 C CNN
|
||||||
|
F 3 "~" H 10350 1150 50 0001 C CNN
|
||||||
|
1 10350 1150
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
8750 1300 8750 1500
|
||||||
|
Wire Wire Line
|
||||||
|
9350 1300 8750 1300
|
||||||
|
Wire Notes Line
|
||||||
|
8650 750 11150 750
|
||||||
|
Wire Notes Line
|
||||||
|
11150 750 11150 2900
|
||||||
|
Wire Notes Line
|
||||||
|
11150 2900 8650 2900
|
||||||
|
Wire Notes Line
|
||||||
|
8650 2900 8650 750
|
||||||
|
Text Notes 11000 2900 0 50 ~ 0
|
||||||
|
LCD\n
|
||||||
|
$Comp
|
||||||
|
L Connector:SD_Card J?
|
||||||
|
U 1 1 5DE47B4E
|
||||||
|
P 9850 4650
|
||||||
|
F 0 "J?" H 9850 5315 50 0000 C CNN
|
||||||
|
F 1 "SD_Card" H 9850 5224 50 0000 C CNN
|
||||||
|
F 2 "" H 9850 4650 50 0001 C CNN
|
||||||
|
F 3 "http://portal.fciconnect.com/Comergent//fci/drawing/10067847.pdf" H 9850 4650 50 0001 C CNN
|
||||||
|
1 9850 4650
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
NoConn ~ 10750 4450
|
||||||
|
NoConn ~ 10750 4550
|
||||||
|
NoConn ~ 10750 4750
|
||||||
|
NoConn ~ 10750 4850
|
||||||
|
NoConn ~ 8900 5050
|
||||||
|
NoConn ~ 8950 4250
|
||||||
|
Wire Wire Line
|
||||||
|
8950 4550 8800 4550
|
||||||
|
Wire Wire Line
|
||||||
|
8800 4550 8800 4850
|
||||||
|
$Comp
|
||||||
|
L power:GND #PWR?
|
||||||
|
U 1 1 5DE4FECC
|
||||||
|
P 8800 5300
|
||||||
|
F 0 "#PWR?" H 8800 5050 50 0001 C CNN
|
||||||
|
F 1 "GND" H 8805 5127 50 0000 C CNN
|
||||||
|
F 2 "" H 8800 5300 50 0001 C CNN
|
||||||
|
F 3 "" H 8800 5300 50 0001 C CNN
|
||||||
|
1 8800 5300
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
8950 4850 8800 4850
|
||||||
|
Connection ~ 8800 4850
|
||||||
|
Wire Wire Line
|
||||||
|
8800 4850 8800 5300
|
||||||
|
Wire Wire Line
|
||||||
|
8950 4650 8750 4650
|
||||||
|
Wire Wire Line
|
||||||
|
8750 4650 8750 4000
|
||||||
|
Wire Wire Line
|
||||||
|
8950 4950 8650 4950
|
||||||
|
Text Label 8650 4950 2 50 ~ 0
|
||||||
|
MISO
|
||||||
|
Wire Wire Line
|
||||||
|
8950 4750 8650 4750
|
||||||
|
Text Label 8650 4750 2 50 ~ 0
|
||||||
|
CLK
|
||||||
|
Wire Wire Line
|
||||||
|
8950 4450 8650 4450
|
||||||
|
Text Label 8650 4450 2 50 ~ 0
|
||||||
|
CMD
|
||||||
|
Wire Wire Line
|
||||||
|
8950 4350 8650 4350
|
||||||
|
Text Label 8650 4350 2 50 ~ 0
|
||||||
|
CD
|
||||||
|
$Comp
|
||||||
|
L power:+3V3 #PWR?
|
||||||
|
U 1 1 5DE57C4F
|
||||||
|
P 8750 4000
|
||||||
|
F 0 "#PWR?" H 8750 3850 50 0001 C CNN
|
||||||
|
F 1 "+3V3" H 8765 4173 50 0000 C CNN
|
||||||
|
F 2 "" H 8750 4000 50 0001 C CNN
|
||||||
|
F 3 "" H 8750 4000 50 0001 C CNN
|
||||||
|
1 8750 4000
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L Device:R R?
|
||||||
|
U 1 1 5DE5821B
|
||||||
|
P 7400 5500
|
||||||
|
F 0 "R?" H 7470 5546 50 0000 L CNN
|
||||||
|
F 1 "R" H 7470 5455 50 0000 L CNN
|
||||||
|
F 2 "" V 7330 5500 50 0001 C CNN
|
||||||
|
F 3 "~" H 7400 5500 50 0001 C CNN
|
||||||
|
1 7400 5500
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L Device:R R?
|
||||||
|
U 1 1 5DE589C1
|
||||||
|
P 7400 5800
|
||||||
|
F 0 "R?" H 7470 5846 50 0000 L CNN
|
||||||
|
F 1 "R" H 7470 5755 50 0000 L CNN
|
||||||
|
F 2 "" V 7330 5800 50 0001 C CNN
|
||||||
|
F 3 "~" H 7400 5800 50 0001 C CNN
|
||||||
|
1 7400 5800
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L Device:R R?
|
||||||
|
U 1 1 5DE58C5B
|
||||||
|
P 7900 5500
|
||||||
|
F 0 "R?" H 7970 5546 50 0000 L CNN
|
||||||
|
F 1 "R" H 7970 5455 50 0000 L CNN
|
||||||
|
F 2 "" V 7830 5500 50 0001 C CNN
|
||||||
|
F 3 "~" H 7900 5500 50 0001 C CNN
|
||||||
|
1 7900 5500
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L Device:R R?
|
||||||
|
U 1 1 5DE58FA3
|
||||||
|
P 7900 5800
|
||||||
|
F 0 "R?" H 7970 5846 50 0000 L CNN
|
||||||
|
F 1 "R" H 7970 5755 50 0000 L CNN
|
||||||
|
F 2 "" V 7830 5800 50 0001 C CNN
|
||||||
|
F 3 "~" H 7900 5800 50 0001 C CNN
|
||||||
|
1 7900 5800
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L Device:R R?
|
||||||
|
U 1 1 5DE5926A
|
||||||
|
P 8300 5500
|
||||||
|
F 0 "R?" H 8370 5546 50 0000 L CNN
|
||||||
|
F 1 "R" H 8370 5455 50 0000 L CNN
|
||||||
|
F 2 "" V 8230 5500 50 0001 C CNN
|
||||||
|
F 3 "~" H 8300 5500 50 0001 C CNN
|
||||||
|
1 8300 5500
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L Device:R R?
|
||||||
|
U 1 1 5DE59509
|
||||||
|
P 8300 5800
|
||||||
|
F 0 "R?" H 8370 5846 50 0000 L CNN
|
||||||
|
F 1 "R" H 8370 5755 50 0000 L CNN
|
||||||
|
F 2 "" V 8230 5800 50 0001 C CNN
|
||||||
|
F 3 "~" H 8300 5800 50 0001 C CNN
|
||||||
|
1 8300 5800
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
7400 5350 7400 5250
|
||||||
|
Wire Wire Line
|
||||||
|
7400 5250 7300 5250
|
||||||
|
Text Label 7300 5250 2 50 ~ 0
|
||||||
|
MOSI
|
||||||
|
Wire Wire Line
|
||||||
|
7900 5350 7900 5250
|
||||||
|
Wire Wire Line
|
||||||
|
7900 5250 7750 5250
|
||||||
|
Text Label 7750 5250 2 50 ~ 0
|
||||||
|
SCK
|
||||||
|
Wire Wire Line
|
||||||
|
8300 5350 8300 5250
|
||||||
|
Wire Wire Line
|
||||||
|
8300 5250 8200 5250
|
||||||
|
Text Label 8200 5250 2 50 ~ 0
|
||||||
|
CS
|
||||||
|
Wire Wire Line
|
||||||
|
7400 5650 7500 5650
|
||||||
|
Connection ~ 7400 5650
|
||||||
|
Wire Wire Line
|
||||||
|
7900 5650 8000 5650
|
||||||
|
Connection ~ 7900 5650
|
||||||
|
Wire Wire Line
|
||||||
|
8300 5650 8400 5650
|
||||||
|
Connection ~ 8300 5650
|
||||||
|
$Comp
|
||||||
|
L power:GND #PWR?
|
||||||
|
U 1 1 5DE60F8B
|
||||||
|
P 8300 5950
|
||||||
|
F 0 "#PWR?" H 8300 5700 50 0001 C CNN
|
||||||
|
F 1 "GND" H 8305 5777 50 0000 C CNN
|
||||||
|
F 2 "" H 8300 5950 50 0001 C CNN
|
||||||
|
F 3 "" H 8300 5950 50 0001 C CNN
|
||||||
|
1 8300 5950
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L power:GND #PWR?
|
||||||
|
U 1 1 5DE6121F
|
||||||
|
P 7900 5950
|
||||||
|
F 0 "#PWR?" H 7900 5700 50 0001 C CNN
|
||||||
|
F 1 "GND" H 7905 5777 50 0000 C CNN
|
||||||
|
F 2 "" H 7900 5950 50 0001 C CNN
|
||||||
|
F 3 "" H 7900 5950 50 0001 C CNN
|
||||||
|
1 7900 5950
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L power:GND #PWR?
|
||||||
|
U 1 1 5DE61424
|
||||||
|
P 7400 5950
|
||||||
|
F 0 "#PWR?" H 7400 5700 50 0001 C CNN
|
||||||
|
F 1 "GND" H 7405 5777 50 0000 C CNN
|
||||||
|
F 2 "" H 7400 5950 50 0001 C CNN
|
||||||
|
F 3 "" H 7400 5950 50 0001 C CNN
|
||||||
|
1 7400 5950
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Text Label 8000 5650 0 50 ~ 0
|
||||||
|
CLK
|
||||||
|
Text Label 7500 5650 0 50 ~ 0
|
||||||
|
CMD
|
||||||
|
Text Label 8400 5650 0 50 ~ 0
|
||||||
|
CD
|
||||||
|
Text Notes 7650 6350 0 50 ~ 0
|
||||||
|
Level Shifting\n
|
||||||
|
Wire Wire Line
|
||||||
|
5150 5300 5150 5400
|
||||||
|
Wire Wire Line
|
||||||
|
5150 5400 5450 5400
|
||||||
|
Wire Wire Line
|
||||||
|
3350 5300 5150 5300
|
||||||
|
Wire Wire Line
|
||||||
|
4050 2750 4150 2750
|
||||||
|
Connection ~ 4650 2600
|
||||||
|
Wire Wire Line
|
||||||
|
4050 2350 4650 2350
|
||||||
|
Text Label 4150 3150 0 50 ~ 0
|
||||||
|
DAC5
|
||||||
|
Text Label 4150 3050 0 50 ~ 0
|
||||||
|
DAC4
|
||||||
|
Text Label 4150 2950 0 50 ~ 0
|
||||||
|
DAC3
|
||||||
|
Text Label 4200 2850 0 50 ~ 0
|
||||||
|
DAC2
|
||||||
|
Text Label 4150 2750 0 50 ~ 0
|
||||||
|
DAC1
|
||||||
|
Text Label 4150 2650 0 50 ~ 0
|
||||||
|
DAC0
|
||||||
|
Wire Wire Line
|
||||||
|
4050 2850 4200 2850
|
||||||
|
Wire Wire Line
|
||||||
|
4300 2600 4650 2600
|
||||||
|
Wire Wire Line
|
||||||
|
4300 2450 4300 2600
|
||||||
|
Text Label 1800 5800 2 50 ~ 0
|
||||||
|
DAC5
|
||||||
|
Text Label 1800 5700 2 50 ~ 0
|
||||||
|
DAC4
|
||||||
|
Text Label 1800 5600 2 50 ~ 0
|
||||||
|
DAC3
|
||||||
|
Text Label 1800 5500 2 50 ~ 0
|
||||||
|
DAC2
|
||||||
|
Text Label 1800 5400 2 50 ~ 0
|
||||||
|
DAC1
|
||||||
|
Text Label 1800 5300 2 50 ~ 0
|
||||||
|
DAC0
|
||||||
|
Text Label 1800 5900 2 50 ~ 0
|
||||||
|
DAC6
|
||||||
|
Text Label 1800 6000 2 50 ~ 0
|
||||||
|
DAC7
|
||||||
|
Text Label 1800 6100 2 50 ~ 0
|
||||||
|
DAC8
|
||||||
|
Text Label 1800 6200 2 50 ~ 0
|
||||||
|
DAC9
|
||||||
|
Text Label 1800 6300 2 50 ~ 0
|
||||||
|
DAC10
|
||||||
|
Text Label 1800 6400 2 50 ~ 0
|
||||||
|
DAC11
|
||||||
|
Text Label 1800 6500 2 50 ~ 0
|
||||||
|
DAC12
|
||||||
|
Text Label 1800 6600 2 50 ~ 0
|
||||||
|
DAC13
|
||||||
|
$Comp
|
||||||
|
L Switch:SW_Push SW?
|
||||||
|
U 1 1 5DE938F9
|
||||||
|
P 950 1400
|
||||||
|
F 0 "SW?" V 904 1548 50 0000 L CNN
|
||||||
|
F 1 "SW_Push" V 995 1548 50 0000 L CNN
|
||||||
|
F 2 "" H 950 1600 50 0001 C CNN
|
||||||
|
F 3 "~" H 950 1600 50 0001 C CNN
|
||||||
|
1 950 1400
|
||||||
|
0 1 1 0
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L Switch:SW_Push SW?
|
||||||
|
U 1 1 5DE95103
|
||||||
|
P 950 2150
|
||||||
|
F 0 "SW?" V 904 2298 50 0000 L CNN
|
||||||
|
F 1 "SW_Push" V 995 2298 50 0000 L CNN
|
||||||
|
F 2 "" H 950 2350 50 0001 C CNN
|
||||||
|
F 3 "~" H 950 2350 50 0001 C CNN
|
||||||
|
1 950 2150
|
||||||
|
0 1 1 0
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L Switch:SW_Push SW?
|
||||||
|
U 1 1 5DE95459
|
||||||
|
P 950 2850
|
||||||
|
F 0 "SW?" V 904 2998 50 0000 L CNN
|
||||||
|
F 1 "SW_Push" V 995 2998 50 0000 L CNN
|
||||||
|
F 2 "" H 950 3050 50 0001 C CNN
|
||||||
|
F 3 "~" H 950 3050 50 0001 C CNN
|
||||||
|
1 950 2850
|
||||||
|
0 1 1 0
|
||||||
|
$EndComp
|
||||||
|
Text Label 950 1200 2 50 ~ 0
|
||||||
|
BUT0
|
||||||
|
Text Label 950 1950 2 50 ~ 0
|
||||||
|
BUT1
|
||||||
|
Text Label 950 2650 2 50 ~ 0
|
||||||
|
BUT2
|
||||||
|
$Comp
|
||||||
|
L power:GND #PWR?
|
||||||
|
U 1 1 5DE97876
|
||||||
|
P 950 1600
|
||||||
|
F 0 "#PWR?" H 950 1350 50 0001 C CNN
|
||||||
|
F 1 "GND" H 955 1427 50 0000 C CNN
|
||||||
|
F 2 "" H 950 1600 50 0001 C CNN
|
||||||
|
F 3 "" H 950 1600 50 0001 C CNN
|
||||||
|
1 950 1600
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L power:GND #PWR?
|
||||||
|
U 1 1 5DE97EED
|
||||||
|
P 950 2350
|
||||||
|
F 0 "#PWR?" H 950 2100 50 0001 C CNN
|
||||||
|
F 1 "GND" H 955 2177 50 0000 C CNN
|
||||||
|
F 2 "" H 950 2350 50 0001 C CNN
|
||||||
|
F 3 "" H 950 2350 50 0001 C CNN
|
||||||
|
1 950 2350
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L power:GND #PWR?
|
||||||
|
U 1 1 5DE98112
|
||||||
|
P 950 3050
|
||||||
|
F 0 "#PWR?" H 950 2800 50 0001 C CNN
|
||||||
|
F 1 "GND" H 955 2877 50 0000 C CNN
|
||||||
|
F 2 "" H 950 3050 50 0001 C CNN
|
||||||
|
F 3 "" H 950 3050 50 0001 C CNN
|
||||||
|
1 950 3050
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L Regulator_Linear:AP2112K-3.3 U?
|
||||||
|
U 1 1 5DE99466
|
||||||
|
P 7600 4300
|
||||||
|
F 0 "U?" H 7600 4642 50 0000 C CNN
|
||||||
|
F 1 "AP2112K-3.3" H 7600 4551 50 0000 C CNN
|
||||||
|
F 2 "Package_TO_SOT_SMD:SOT-23-5" H 7600 4625 50 0001 C CNN
|
||||||
|
F 3 "https://www.diodes.com/assets/Datasheets/AP2112.pdf" H 7600 4400 50 0001 C CNN
|
||||||
|
1 7600 4300
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
7300 4200 7200 4200
|
||||||
|
Wire Wire Line
|
||||||
|
7200 4200 7200 4100
|
||||||
|
$Comp
|
||||||
|
L power:+5V #PWR?
|
||||||
|
U 1 1 5DEA3406
|
||||||
|
P 7200 4100
|
||||||
|
F 0 "#PWR?" H 7200 3950 50 0001 C CNN
|
||||||
|
F 1 "+5V" H 7215 4273 50 0000 C CNN
|
||||||
|
F 2 "" H 7200 4100 50 0001 C CNN
|
||||||
|
F 3 "" H 7200 4100 50 0001 C CNN
|
||||||
|
1 7200 4100
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
7300 4300 7200 4300
|
||||||
|
Wire Wire Line
|
||||||
|
7200 4300 7200 4200
|
||||||
|
Connection ~ 7200 4200
|
||||||
|
$Comp
|
||||||
|
L power:GND #PWR?
|
||||||
|
U 1 1 5DEA545A
|
||||||
|
P 7600 4600
|
||||||
|
F 0 "#PWR?" H 7600 4350 50 0001 C CNN
|
||||||
|
F 1 "GND" H 7605 4427 50 0000 C CNN
|
||||||
|
F 2 "" H 7600 4600 50 0001 C CNN
|
||||||
|
F 3 "" H 7600 4600 50 0001 C CNN
|
||||||
|
1 7600 4600
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
7900 4200 8050 4200
|
||||||
|
Wire Wire Line
|
||||||
|
8050 4200 8050 4100
|
||||||
|
$Comp
|
||||||
|
L power:+3V3 #PWR?
|
||||||
|
U 1 1 5DEA72CB
|
||||||
|
P 8050 4100
|
||||||
|
F 0 "#PWR?" H 8050 3950 50 0001 C CNN
|
||||||
|
F 1 "+3V3" H 8065 4273 50 0000 C CNN
|
||||||
|
F 2 "" H 8050 4100 50 0001 C CNN
|
||||||
|
F 3 "" H 8050 4100 50 0001 C CNN
|
||||||
|
1 8050 4100
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
NoConn ~ 6050 1950
|
||||||
|
NoConn ~ 6050 2150
|
||||||
|
NoConn ~ 6050 1750
|
||||||
|
Text Label 7250 1750 0 50 ~ 0
|
||||||
|
LCD_RW
|
||||||
|
Text Label 7250 3250 0 50 ~ 0
|
||||||
|
LCD_RS
|
||||||
|
Text Label 7250 2350 0 50 ~ 0
|
||||||
|
LCD_D6
|
||||||
|
Text Label 7250 2450 0 50 ~ 0
|
||||||
|
LCD_D7
|
||||||
|
Text Label 7250 2250 0 50 ~ 0
|
||||||
|
LCD_D5
|
||||||
|
Text Label 7250 2150 0 50 ~ 0
|
||||||
|
LCD_D4
|
||||||
|
$Comp
|
||||||
|
L power:+5V #PWR?
|
||||||
|
U 1 1 5DDF0261
|
||||||
|
P 6650 1150
|
||||||
|
F 0 "#PWR?" H 6650 1000 50 0001 C CNN
|
||||||
|
F 1 "+5V" H 6665 1323 50 0000 C CNN
|
||||||
|
F 2 "" H 6650 1150 50 0001 C CNN
|
||||||
|
F 3 "" H 6650 1150 50 0001 C CNN
|
||||||
|
1 6650 1150
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
6650 3650 6650 3800
|
||||||
|
Wire Wire Line
|
||||||
|
6650 1450 6650 1150
|
||||||
|
Text Label 7450 2750 0 50 ~ 0
|
||||||
|
RXD
|
||||||
|
Text Label 7450 2650 0 50 ~ 0
|
||||||
|
TXD
|
||||||
|
Wire Wire Line
|
||||||
|
7250 2750 7450 2750
|
||||||
|
Wire Wire Line
|
||||||
|
7250 2650 7450 2650
|
||||||
|
$Comp
|
||||||
|
L final_project-rescue:ATtiny2313-20MU-MCU_Microchip_ATtiny U?
|
||||||
|
U 1 1 5DDDA525
|
||||||
|
P 6650 2550
|
||||||
|
F 0 "U?" H 6650 3831 50 0000 C CNN
|
||||||
|
F 1 "ATtiny2313-20MU" H 6650 3740 50 0000 C CNN
|
||||||
|
F 2 "Package_DFN_QFN:MLF-20-1EP_4x4mm_P0.5mm_EP2.6x2.6mm" H 6650 2550 50 0001 C CIN
|
||||||
|
F 3 "http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-2543-AVR-ATtiny2313_Datasheet.pdf" H 6650 2550 50 0001 C CNN
|
||||||
|
1 6650 2550
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Text Label 7250 1950 0 50 ~ 0
|
||||||
|
BUT_RED
|
||||||
|
Text Label 6050 2150 2 50 ~ 0
|
||||||
|
BUT_RIGHT
|
||||||
|
Text Label 6050 1950 2 50 ~ 0
|
||||||
|
BUT_LEFT
|
||||||
|
Text Label 7250 1850 0 50 ~ 0
|
||||||
|
E
|
||||||
|
$EndSCHEMATC
|
4
final_project/hw/sym-lib-table
Normal file
4
final_project/hw/sym-lib-table
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
(sym_lib_table
|
||||||
|
(lib (name final)(type Legacy)(uri ${KIPRJMOD}/final.lib)(options "")(descr ""))
|
||||||
|
(lib (name final_project-rescue)(type Legacy)(uri ${KIPRJMOD}/final_project-rescue.lib)(options "")(descr ""))
|
||||||
|
)
|
19
final_project/lcd_disp/.vscode/c_cpp_properties.json
vendored
Normal file
19
final_project/lcd_disp/.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Linux",
|
||||||
|
"intelliSenseMode": "gcc-x64",
|
||||||
|
"compilerPath": "/usr/lib/ccache/avr-gcc",
|
||||||
|
"cStandard": "c99",
|
||||||
|
"cppStandard": "c++17",
|
||||||
|
"compilerArgs": [
|
||||||
|
"-Wall", "-pedantic", "-mmcu=attiy2313a"
|
||||||
|
],
|
||||||
|
"defines": [
|
||||||
|
"F_CPU=16000000",
|
||||||
|
"__"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
3
final_project/lcd_disp/.vscode/settings.json
vendored
Normal file
3
final_project/lcd_disp/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"C_Cpp.intelliSenseEngine": "Tag Parser"
|
||||||
|
}
|
19
final_project/lcd_disp/.vscode/tasks.json
vendored
Normal file
19
final_project/lcd_disp/.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||||
|
// for the documentation about the tasks.json format
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "make",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "make",
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
52
final_project/lcd_disp/Makefile
Normal file
52
final_project/lcd_disp/Makefile
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
|
||||||
|
NAME := sd-reader
|
||||||
|
HEX := $(NAME).hex
|
||||||
|
OUT := $(NAME).out
|
||||||
|
MAP := $(NAME).map
|
||||||
|
SOURCES := $(wildcard *.c)
|
||||||
|
HEADERS := $(wildcard *.h)
|
||||||
|
OBJECTS := $(patsubst %.c,%.o,$(SOURCES))
|
||||||
|
|
||||||
|
MCU := attiny2313a
|
||||||
|
MCU_AVRDUDE := t2313
|
||||||
|
MCU_FREQ := 8000000UL
|
||||||
|
|
||||||
|
CC := avr-gcc
|
||||||
|
OBJCOPY := avr-objcopy
|
||||||
|
SIZE := avr-size -A
|
||||||
|
DOXYGEN := doxygen
|
||||||
|
|
||||||
|
CFLAGS := -Werror -Wall -pedantic -mmcu=$(MCU) -std=c99 -g -Os -DF_CPU=$(MCU_FREQ)
|
||||||
|
|
||||||
|
all: $(HEX)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(HEX) $(OUT) $(MAP) $(OBJECTS)
|
||||||
|
rm -rf doc/html
|
||||||
|
|
||||||
|
flash: $(HEX)
|
||||||
|
avrdude -y -c avr910 -p $(MCU_AVRDUDE) -U flash:w:$(HEX)
|
||||||
|
|
||||||
|
$(HEX): $(OUT)
|
||||||
|
$(OBJCOPY) -R .eeprom -O ihex $< $@
|
||||||
|
|
||||||
|
$(OUT): $(OBJECTS)
|
||||||
|
$(CC) $(CFLAGS) -o $@ -Wl,-Map,$(MAP) $^
|
||||||
|
@echo
|
||||||
|
@$(SIZE) $@
|
||||||
|
@echo
|
||||||
|
|
||||||
|
%.o: %.c $(HEADERS)
|
||||||
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
%.pp: %.c
|
||||||
|
$(CC) $(CFLAGS) -E -o $@ $<
|
||||||
|
|
||||||
|
%.ppo: %.c
|
||||||
|
$(CC) $(CFLAGS) -E $<
|
||||||
|
|
||||||
|
doc: $(HEADERS) $(SOURCES) Doxyfile
|
||||||
|
$(DOXYGEN) Doxyfile
|
||||||
|
|
||||||
|
.PHONY: all clean flash doc
|
||||||
|
|
86
final_project/lcd_disp/comms.h
Symbolic link
86
final_project/lcd_disp/comms.h
Symbolic link
@ -0,0 +1,86 @@
|
|||||||
|
#ifndef COMMS_H_
|
||||||
|
#define COMMS_H_
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Our format goes like this:
|
||||||
|
*
|
||||||
|
* 1 byte command, with data after
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
COMMS_CMD_CLR = 0U, //! Clears LCD and all file names
|
||||||
|
COMMS_CMD_NUM, //! sends the total number of songs to choose from
|
||||||
|
COMMS_CMD_QUERY_NUM,
|
||||||
|
COMMS_CMD_QUERY_NAME, //! Queries for the name of a given song ID
|
||||||
|
COMMS_CMD_REPLY_NAME, //! Responds with the name of the given song ID
|
||||||
|
COMMS_CMD_SELECT_FILE, //! selects a file from the given list to play, data is 1 byte for id
|
||||||
|
COMMS_CMD_PLAY, //! Starts playing file
|
||||||
|
COMMS_CMD_PAUSE //! pauses playing file
|
||||||
|
} comms_cmd_t;
|
||||||
|
|
||||||
|
/** @brief Inline function to send commands and values.
|
||||||
|
*/
|
||||||
|
inline void comms_send(comms_cmd_t cmd) {
|
||||||
|
#if defined(ATTINY2313)
|
||||||
|
while (!(UCSRA & (1 << UDRE)));
|
||||||
|
UDR = cmd;
|
||||||
|
#elif defined(ATMEGA328)
|
||||||
|
while (!(UCSR0A & (1 << UDRE0)));
|
||||||
|
UDR0 = cmd;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Selects a file from the list on the DAC side.
|
||||||
|
*
|
||||||
|
* If another song is playing, this will stop
|
||||||
|
* that song from playing and select the new one.
|
||||||
|
*/
|
||||||
|
inline void comms_select_file(uint8_t id) {
|
||||||
|
comms_send(COMMS_CMD_SELECT_FILE);
|
||||||
|
comms_send((comms_cmd_t) id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Queries for the name of the given song ID.
|
||||||
|
*/
|
||||||
|
inline void comms_query_name(uint8_t id) {
|
||||||
|
comms_send(COMMS_CMD_QUERY_NAME);
|
||||||
|
_delay_ms(1);
|
||||||
|
comms_send(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Repliers with the name of the requsted song ID
|
||||||
|
*/
|
||||||
|
inline void comms_reply_name(char* name) {
|
||||||
|
uint8_t len = strlen(name);
|
||||||
|
comms_send(COMMS_CMD_REPLY_NAME);
|
||||||
|
comms_send(len);
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < len; i++) {
|
||||||
|
comms_send((uint8_t) name[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Clears the LCD list of files.
|
||||||
|
*/
|
||||||
|
inline void comms_clear() {
|
||||||
|
comms_send(COMMS_CMD_CLR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Starts playing song.
|
||||||
|
*/
|
||||||
|
inline void comms_play() {
|
||||||
|
comms_send(COMMS_CMD_PLAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Pauses playing song.
|
||||||
|
*/
|
||||||
|
inline void comms_pause() {
|
||||||
|
comms_send(COMMS_CMD_PLAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
52
final_project/lcd_disp/fifo.c
Normal file
52
final_project/lcd_disp/fifo.c
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#include "fifo.h"
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
FIFO_TYPE buffer[FIFO_LEN];
|
||||||
|
uint16_t rd_ptr;
|
||||||
|
uint16_t wr_ptr;
|
||||||
|
uint16_t entries;
|
||||||
|
} fifo;
|
||||||
|
|
||||||
|
void fifo_init() {
|
||||||
|
fifo.rd_ptr = 0;
|
||||||
|
fifo.wr_ptr = 0;
|
||||||
|
fifo.entries = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
fifo_err_t fifo_pop(FIFO_TYPE* dest) {
|
||||||
|
// FIFO is empty, nothing to return!
|
||||||
|
if (fifo.entries == 0) {
|
||||||
|
return FIFO_EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Entries in FIFO, pop
|
||||||
|
*dest = fifo.buffer[fifo.rd_ptr];
|
||||||
|
fifo.rd_ptr++;
|
||||||
|
fifo.entries--;
|
||||||
|
|
||||||
|
// Ensure pointers don't overflow!
|
||||||
|
if (fifo.rd_ptr == FIFO_LEN) {
|
||||||
|
fifo.rd_ptr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FIFO_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fifo_err_t fifo_push(FIFO_TYPE src) {
|
||||||
|
// FIFO is full, don't store anything
|
||||||
|
if (fifo.entries == FIFO_LEN) {
|
||||||
|
return FIFO_FULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIFO has space, write
|
||||||
|
fifo.buffer[fifo.wr_ptr] = src;
|
||||||
|
fifo.wr_ptr++;
|
||||||
|
fifo.entries++;
|
||||||
|
|
||||||
|
// Ensure pointers don't overflow!
|
||||||
|
if (fifo.wr_ptr == FIFO_LEN) {
|
||||||
|
fifo.wr_ptr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FIFO_SUCCESS;
|
||||||
|
}
|
36
final_project/lcd_disp/fifo.h
Normal file
36
final_project/lcd_disp/fifo.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#ifndef FIFO_H_
|
||||||
|
#define FIFO_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
FIFO_SUCCESS,
|
||||||
|
FIFO_FULL,
|
||||||
|
FIFO_EMPTY
|
||||||
|
} fifo_err_t;
|
||||||
|
|
||||||
|
#define FIFO_LEN 20
|
||||||
|
#define FIFO_TYPE uint8_t
|
||||||
|
|
||||||
|
/** @brief Initialises FIFO
|
||||||
|
*
|
||||||
|
* This MUST be called before any other fifo_* functions are called.
|
||||||
|
* Unless memory is initialised to 0. Then it's fine I guess.
|
||||||
|
*/
|
||||||
|
void fifo_init();
|
||||||
|
|
||||||
|
/** @brief Pops most recent addition off of FIFO buffer.
|
||||||
|
*
|
||||||
|
* @retval FIFO_SUCCESS Successfully read data from FIFO
|
||||||
|
* @retval FIFO_EMPTY Buffer was empty, no data read
|
||||||
|
*/
|
||||||
|
fifo_err_t fifo_pop(FIFO_TYPE* dest);
|
||||||
|
|
||||||
|
/** @brief Pushes entry onto FIFO buffer.
|
||||||
|
*
|
||||||
|
* @retval FIFO_SUCCESS successfully wrote data to FIFO buffer
|
||||||
|
* @retval FIFO_FULL buffer, was full, no data written
|
||||||
|
*/
|
||||||
|
fifo_err_t fifo_push(FIFO_TYPE src);
|
||||||
|
|
||||||
|
#endif
|
@ -128,7 +128,7 @@
|
|||||||
#if LCD_IO_MODE
|
#if LCD_IO_MODE
|
||||||
|
|
||||||
#ifndef LCD_PORT
|
#ifndef LCD_PORT
|
||||||
#define LCD_PORT PORTC /**< port for the LCD lines */
|
#define LCD_PORT PORTB /**< port for the LCD lines */
|
||||||
#endif
|
#endif
|
||||||
#ifndef LCD_DATA0_PORT
|
#ifndef LCD_DATA0_PORT
|
||||||
#define LCD_DATA0_PORT LCD_PORT /**< port for 4bit data bit 0 */
|
#define LCD_DATA0_PORT LCD_PORT /**< port for 4bit data bit 0 */
|
||||||
@ -143,34 +143,34 @@
|
|||||||
#define LCD_DATA3_PORT LCD_PORT /**< port for 4bit data bit 3 */
|
#define LCD_DATA3_PORT LCD_PORT /**< port for 4bit data bit 3 */
|
||||||
#endif
|
#endif
|
||||||
#ifndef LCD_DATA0_PIN
|
#ifndef LCD_DATA0_PIN
|
||||||
#define LCD_DATA0_PIN 5 /**< pin for 4bit data bit 0 */
|
#define LCD_DATA0_PIN 4 /**< pin for 4bit data bit 0 */
|
||||||
#endif
|
#endif
|
||||||
#ifndef LCD_DATA1_PIN
|
#ifndef LCD_DATA1_PIN
|
||||||
#define LCD_DATA1_PIN 4 /**< pin for 4bit data bit 1 */
|
#define LCD_DATA1_PIN 5 /**< pin for 4bit data bit 1 */
|
||||||
#endif
|
#endif
|
||||||
#ifndef LCD_DATA2_PIN
|
#ifndef LCD_DATA2_PIN
|
||||||
#define LCD_DATA2_PIN 3 /**< pin for 4bit data bit 2 */
|
#define LCD_DATA2_PIN 6 /**< pin for 4bit data bit 2 */
|
||||||
#endif
|
#endif
|
||||||
#ifndef LCD_DATA3_PIN
|
#ifndef LCD_DATA3_PIN
|
||||||
#define LCD_DATA3_PIN 2 /**< pin for 4bit data bit 3 */
|
#define LCD_DATA3_PIN 7 /**< pin for 4bit data bit 3 */
|
||||||
#endif
|
#endif
|
||||||
#ifndef LCD_RS_PORT
|
#ifndef LCD_RS_PORT
|
||||||
#define LCD_RS_PORT PORTD /**< port for RS line */
|
#define LCD_RS_PORT PORTD /**< port for RS line */
|
||||||
#endif
|
#endif
|
||||||
#ifndef LCD_RS_PIN
|
#ifndef LCD_RS_PIN
|
||||||
#define LCD_RS_PIN 0 /**< pin for RS line */
|
#define LCD_RS_PIN 6 /**< pin for RS line */
|
||||||
#endif
|
#endif
|
||||||
#ifndef LCD_RW_PORT
|
#ifndef LCD_RW_PORT
|
||||||
#define LCD_RW_PORT PORTD /**< port for RW line */
|
#define LCD_RW_PORT PORTB /**< port for RW line */
|
||||||
#endif
|
#endif
|
||||||
#ifndef LCD_RW_PIN
|
#ifndef LCD_RW_PIN
|
||||||
#define LCD_RW_PIN 1 /**< pin for RW line */
|
#define LCD_RW_PIN 0 /**< pin for RW line */
|
||||||
#endif
|
#endif
|
||||||
#ifndef LCD_E_PORT
|
#ifndef LCD_E_PORT
|
||||||
#define LCD_E_PORT PORTD /**< port for Enable line */
|
#define LCD_E_PORT PORTB /**< port for Enable line */
|
||||||
#endif
|
#endif
|
||||||
#ifndef LCD_E_PIN
|
#ifndef LCD_E_PIN
|
||||||
#define LCD_E_PIN 2 /**< pin for Enable line */
|
#define LCD_E_PIN 1 /**< pin for Enable line */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(__AVR_AT90S4414__) || defined(__AVR_AT90S8515__) || defined(__AVR_ATmega64__) || \
|
#elif defined(__AVR_AT90S4414__) || defined(__AVR_AT90S8515__) || defined(__AVR_ATmega64__) || \
|
195
final_project/lcd_disp/main.c
Normal file
195
final_project/lcd_disp/main.c
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* ---- Global Flags ---- */
|
||||||
|
int8_t display_song = -1; //! ID of the song currently being displayed, -1 if song list is not initialised
|
||||||
|
int8_t last_displayed_song = -1;
|
||||||
|
int8_t selected_song = -1; //! ID of the selected song. -1 if no song is selected.
|
||||||
|
bool update_display = false; //! flag on whether or not to update display
|
||||||
|
|
||||||
|
|
||||||
|
struct {
|
||||||
|
char name[SONG_NAME_LEN + 1]; //! array of all song names, names are allocated on heap
|
||||||
|
uint8_t num_songs; //! Number of songs loaded into display memory
|
||||||
|
bool playing; //! Whether the currently selected song is playing
|
||||||
|
} songs;
|
||||||
|
|
||||||
|
void say_no_songs() {
|
||||||
|
lcd_clrscr();
|
||||||
|
lcd_puts("No songs!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** @brief Handles right button press
|
||||||
|
*/
|
||||||
|
void handle_left_press() {
|
||||||
|
if (songs.num_songs == 0) {
|
||||||
|
say_no_songs();
|
||||||
|
comms_send(COMMS_CMD_QUERY_NUM);
|
||||||
|
} else if (display_song == -1) {
|
||||||
|
if (songs.num_songs > 0) {
|
||||||
|
display_song = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Choose lower ID song. Wrap around.
|
||||||
|
display_song--;
|
||||||
|
if (display_song == 0) {
|
||||||
|
display_song = songs.num_songs - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Handles left button press
|
||||||
|
*/
|
||||||
|
void handle_right_press() {
|
||||||
|
if (songs.num_songs == 0) {
|
||||||
|
say_no_songs();
|
||||||
|
comms_send(COMMS_CMD_QUERY_NUM);
|
||||||
|
} else if (display_song == -1) {
|
||||||
|
if (songs.num_songs > 0) {
|
||||||
|
display_song = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Choose higher ID song. Wrap around.
|
||||||
|
display_song++;
|
||||||
|
if (display_song == songs.num_songs) {
|
||||||
|
display_song = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Handles playpause button press.
|
||||||
|
*
|
||||||
|
* Based on selected song and displayed song, will select new song
|
||||||
|
* or play/pause song.
|
||||||
|
*/
|
||||||
|
void handle_playpause_press() {
|
||||||
|
// If there are no songs displayed, error
|
||||||
|
if (display_song == -1) {
|
||||||
|
say_no_songs();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no song selected, select the correct one.
|
||||||
|
if (selected_song == -1) {
|
||||||
|
comms_select_file(display_song);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Song selected, send play/pause
|
||||||
|
if (songs.playing) {
|
||||||
|
comms_pause();
|
||||||
|
songs.playing = false;
|
||||||
|
} else {
|
||||||
|
comms_play();
|
||||||
|
songs.playing = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
DDRA |= (1 << 3); // debug
|
||||||
|
// Scratch variables
|
||||||
|
uint8_t incoming_cmd = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
fifo_init();
|
||||||
|
gpio_init();
|
||||||
|
timer_init();
|
||||||
|
usart_init();
|
||||||
|
|
||||||
|
lcd_init(LCD_DISP_ON);
|
||||||
|
lcd_gotoxy(0,0);
|
||||||
|
|
||||||
|
lcd_puts("...");
|
||||||
|
|
||||||
|
sei();
|
||||||
|
|
||||||
|
// Main loop
|
||||||
|
while (1) {
|
||||||
|
// Handle incoming messages
|
||||||
|
if (fifo_pop(&incoming_cmd) == FIFO_SUCCESS) {
|
||||||
|
switch (incoming_cmd) {
|
||||||
|
// Clear songs, so there are none to display
|
||||||
|
case (COMMS_CMD_CLR):
|
||||||
|
songs.num_songs = 0;
|
||||||
|
display_song = -1;
|
||||||
|
selected_song = -1;
|
||||||
|
break;
|
||||||
|
// change number of songs
|
||||||
|
case (COMMS_CMD_NUM):
|
||||||
|
while(fifo_pop((FIFO_TYPE*) &songs.num_songs) != FIFO_SUCCESS);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
lcd_clrscr();
|
||||||
|
lcd_puts("Incorrect command!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle "left" button press
|
||||||
|
if (!(BUTTONS_LEFT_PIN & (1 << BUTTONS_LEFT))) {
|
||||||
|
handle_left_press();
|
||||||
|
_delay_ms(100); // Delay to debounce
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle "right" button press
|
||||||
|
if (!(BUTTONS_RIGHT_PIN & (1 << BUTTONS_RIGHT))) {
|
||||||
|
handle_right_press();
|
||||||
|
_delay_ms(100); // Delay to debounce
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle play/pause button press
|
||||||
|
if (!(BUTTONS_PLAYPAUSE_PIN & (1 << BUTTONS_PLAYPAUSE))) {
|
||||||
|
handle_playpause_press();
|
||||||
|
_delay_ms(100); // Delay to debounce
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update display periodically
|
||||||
|
if (update_display) {
|
||||||
|
|
||||||
|
// check if song has changed
|
||||||
|
if (last_displayed_song != display_song) {
|
||||||
|
lcd_clrscr();
|
||||||
|
comms_query_name(display_song);
|
||||||
|
|
||||||
|
char tmp_chr;
|
||||||
|
|
||||||
|
// Wait for command to come in
|
||||||
|
while (fifo_pop((FIFO_TYPE*) &tmp_chr) != FIFO_SUCCESS);
|
||||||
|
|
||||||
|
// TODO add error handling here
|
||||||
|
|
||||||
|
// Wait for length info to come in
|
||||||
|
while (fifo_pop((FIFO_TYPE*) &tmp_chr) != FIFO_SUCCESS);
|
||||||
|
uint8_t len = tmp_chr;
|
||||||
|
|
||||||
|
// Read in string
|
||||||
|
for (uint8_t i = 0; i < len; i++) {
|
||||||
|
// Hold until fifo returns successfully
|
||||||
|
while(fifo_pop((FIFO_TYPE*) &songs.name[i]) != FIFO_SUCCESS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lcd_clrscr();
|
||||||
|
|
||||||
|
if (display_song != -1) {
|
||||||
|
lcd_puts(songs.name);
|
||||||
|
lcd_gotoxy(0, 1);
|
||||||
|
lcd_putc('1' + display_song);
|
||||||
|
lcd_gotoxy(13,1);
|
||||||
|
lcd_putc('1' + display_song);
|
||||||
|
lcd_putc('/');
|
||||||
|
lcd_putc('0' + songs.num_songs);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
lcd_puts("");
|
||||||
|
}
|
||||||
|
|
||||||
|
update_display = false;
|
||||||
|
last_displayed_song = display_song;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
27
final_project/lcd_disp/main.h
Normal file
27
final_project/lcd_disp/main.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef MAIN_H_
|
||||||
|
#define MAIN_H_
|
||||||
|
|
||||||
|
#define F_CPU 8000000
|
||||||
|
#define ATTINY2313
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <util/delay.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include "lcd.h"
|
||||||
|
#include "fifo.h"
|
||||||
|
#include "comms.h"
|
||||||
|
#include "periph.h"
|
||||||
|
|
||||||
|
#define SONG_NAME_LEN 16
|
||||||
|
|
||||||
|
/* ---- Globally available flags ---- */
|
||||||
|
extern bool update_display;
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
71
final_project/lcd_disp/periph.c
Normal file
71
final_project/lcd_disp/periph.c
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
#include "periph.h"
|
||||||
|
|
||||||
|
|
||||||
|
/** @brief Handles incoming Serial commands from the main player.
|
||||||
|
*/
|
||||||
|
ISR(USART_RX_vect) {
|
||||||
|
cli();
|
||||||
|
// Push incoming data to FIFO
|
||||||
|
fifo_push(UDR);
|
||||||
|
|
||||||
|
// Flag is cleared by reading data from UDR
|
||||||
|
sei();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Display update timer
|
||||||
|
*/
|
||||||
|
ISR(TIMER0_COMPA_vect) {
|
||||||
|
cli();
|
||||||
|
update_display = true;
|
||||||
|
|
||||||
|
// Flag is cleared by calling the vector
|
||||||
|
sei();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void gpio_init() {
|
||||||
|
// Initialise button pins as inputs
|
||||||
|
BUTTONS_LEFT_DDR &= ~(1 << BUTTONS_LEFT);
|
||||||
|
BUTTONS_RIGHT_DDR &= ~(1 << BUTTONS_RIGHT);
|
||||||
|
BUTTONS_PLAYPAUSE_DDR &= ~(1 << BUTTONS_PLAYPAUSE);
|
||||||
|
|
||||||
|
// Turn on button pullups
|
||||||
|
BUTTONS_LEFT_PORT |= (1 << BUTTONS_LEFT);
|
||||||
|
BUTTONS_RIGHT_PORT |= (1 << BUTTONS_RIGHT);
|
||||||
|
BUTTONS_PLAYPAUSE_PORT |= (1 << BUTTONS_PLAYPAUSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void timer_init() {
|
||||||
|
/**
|
||||||
|
* Need to verify the math here.
|
||||||
|
* But with a prescaler of 1024, f_cpu at 8MHz, an OCRA of 195 gives
|
||||||
|
* 20Hz refresh rate.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// COM0x can be set to defaults
|
||||||
|
// To set to CTC, WGM = 0b010
|
||||||
|
TCCR0A = (1 << WGM01);
|
||||||
|
|
||||||
|
// Set to ~20Hz
|
||||||
|
OCR0A = 195;
|
||||||
|
|
||||||
|
// CS = 0b101 -> 1024 prescaler
|
||||||
|
// Everything else should be 0.
|
||||||
|
// TCCR0B = 0b00000101; <- can't use this because binary stuff is a GCC extension
|
||||||
|
TCCR0B = 5;
|
||||||
|
|
||||||
|
// Enable interrupt
|
||||||
|
TIMSK = (1 << OCIE0A);
|
||||||
|
}
|
||||||
|
|
||||||
|
void usart_init() {
|
||||||
|
// initialize USART
|
||||||
|
UBRRL = UBRR_VALUE & 255;
|
||||||
|
UBRRH = UBRR_VALUE >> 8;
|
||||||
|
UCSRB = (1 << TXEN) | (1 << RXEN); // fire-up USART
|
||||||
|
UCSRC = (1 << UCSZ1) | (1 << UCSZ0); // fire-up USART
|
||||||
|
|
||||||
|
|
||||||
|
// Enable RX complete interrupt
|
||||||
|
UCSRB |= (1 << RXCIE);
|
||||||
|
}
|
53
final_project/lcd_disp/periph.h
Normal file
53
final_project/lcd_disp/periph.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
* @mainpage
|
||||||
|
* Peripherals
|
||||||
|
*
|
||||||
|
* @brief Peripheral initialization functions and interrupt handling routines.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Contains the ISRs to handle the USART RX interrupt and the display timer interrupt.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef PERIPH_H_
|
||||||
|
#define PERIPH_H_
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define USART_BAUDRATE 9600 //! USART baudrate, change this to set it.
|
||||||
|
#define UBRR_VALUE (((F_CPU/(USART_BAUDRATE*16UL)))-1)
|
||||||
|
|
||||||
|
#define BUTTONS_DDR DDRD
|
||||||
|
#define BUTTONS_LEFT_DDR DDRA
|
||||||
|
#define BUTTONS_RIGHT_DDR DDRA
|
||||||
|
#define BUTTONS_PLAYPAUSE_DDR DDRB
|
||||||
|
#define BUTTONS_LEFT_PORT PORTA
|
||||||
|
#define BUTTONS_RIGHT_PORT PORTA
|
||||||
|
#define BUTTONS_PLAYPAUSE_PORT PORTB
|
||||||
|
#define BUTTONS_LEFT_PIN PINA
|
||||||
|
#define BUTTONS_RIGHT_PIN PINA
|
||||||
|
#define BUTTONS_PLAYPAUSE_PIN PINB
|
||||||
|
#define BUTTONS_LEFT 0
|
||||||
|
#define BUTTONS_RIGHT 1
|
||||||
|
#define BUTTONS_PLAYPAUSE 2
|
||||||
|
|
||||||
|
|
||||||
|
/** @brief Sets up various GPIO functions
|
||||||
|
*
|
||||||
|
* First enables buttons as inputs.
|
||||||
|
*/
|
||||||
|
void gpio_init();
|
||||||
|
|
||||||
|
/** @brief Initialises timer for updating display
|
||||||
|
*
|
||||||
|
* Sets up timer0 in
|
||||||
|
*/
|
||||||
|
void timer_init();
|
||||||
|
|
||||||
|
/** @brief Sets up USART for TX and RX with a baud rate of USART_BAUDRATE
|
||||||
|
*/
|
||||||
|
void usart_init();
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -1,16 +0,0 @@
|
|||||||
#include <avr/io.h>
|
|
||||||
|
|
||||||
// Set up GPIO here
|
|
||||||
void pin_setup() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
pin_setup()
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
18
final_project/sd_reader/.vscode/c_cpp_properties.json
vendored
Normal file
18
final_project/sd_reader/.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Linux",
|
||||||
|
"intelliSenseMode": "gcc-x64",
|
||||||
|
"compilerPath": "/usr/lib/ccache/avr-gcc",
|
||||||
|
"cStandard": "c99",
|
||||||
|
"cppStandard": "c++17",
|
||||||
|
"compilerArgs": [
|
||||||
|
"-Wall", "-pedantic", "-mmcu=atmega328"
|
||||||
|
],
|
||||||
|
"defines": [
|
||||||
|
"F_CPU=16000000"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
19
final_project/sd_reader/.vscode/tasks.json
vendored
Normal file
19
final_project/sd_reader/.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||||
|
// for the documentation about the tasks.json format
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "make",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "make",
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
124
final_project/sd_reader/ChangeLog
Normal file
124
final_project/sd_reader/ChangeLog
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
|
||||||
|
2012-06-12 sd-reader
|
||||||
|
* fix capacity readout from csd register depending on format version
|
||||||
|
* fix gcc strict-aliasing warnings (also somewhat enlarges code size)
|
||||||
|
|
||||||
|
2011-04-23 sd-reader
|
||||||
|
* fix FAT access for cluster numbers beyond 2^15 (for FAT16) and 2^30 (for FAT32) (thanks to Darwin Engwer for testing)
|
||||||
|
* correctly return disk-full condition from fat_write_file() on certain conditions
|
||||||
|
* use byteorder memory access functions for fat_fs_get_free()
|
||||||
|
* be more specific on the return value of fat_write_file()
|
||||||
|
|
||||||
|
2011-02-05 sd-reader
|
||||||
|
* implement renaming a file or directory
|
||||||
|
* rewrite byteorder handling to fix unaligned memory accesses on 32-bit and probably 16-bit architectures
|
||||||
|
* make fat_create_file() not return failure if the file already exists
|
||||||
|
* make the "cat" output respect the count of bytes actually read
|
||||||
|
* document how to use fat_seek_file() for retrieving the file position
|
||||||
|
|
||||||
|
2010-10-10 sd-reader
|
||||||
|
* Fix equal file names when reading two successive 8.3 directory entries.
|
||||||
|
* Fix calculation of cluster positions beyond 4GB (32 bit integer overflow).
|
||||||
|
* Fix endless looping of directory listing (occured with valid entry at end of last cluster).
|
||||||
|
|
||||||
|
2010-01-10 sd-reader
|
||||||
|
* Make LFN support configurable.
|
||||||
|
* Ignore LFN directory entries without 8.3 name.
|
||||||
|
* Ignore LFN directory entries which do not match the 8.3 name's checksum.
|
||||||
|
* Implement delayed directory entry updates (disabled by default) (thanks to Adam Mayer).
|
||||||
|
* Speedup search for free cluster.
|
||||||
|
* Fix memory leak when using the "init" command (thanks to Tibor Vilhan).
|
||||||
|
* Fix ATmega328P-specific pin mappings.
|
||||||
|
* Add some of the picoPower MCU variants.
|
||||||
|
|
||||||
|
2009-03-30 sd-reader
|
||||||
|
* Make 8.3 basename and/or extension lowercase when told by Windows NT and later.
|
||||||
|
* Add ATmega328 pin configuration.
|
||||||
|
* Fix MMC/SD/SDHC distinction.
|
||||||
|
* Fix raw block read/write buffering (thanks to Kurt Sterckx).
|
||||||
|
* Fix fat size calculation for FAT16 when configured with FAT32.
|
||||||
|
* Fix compilation for read-only configurations.
|
||||||
|
* Fix card lock detection.
|
||||||
|
* Make it easier to link with a C++ application (thanks to Jérôme Despatis).
|
||||||
|
|
||||||
|
2008-11-21 sd-reader
|
||||||
|
* Support for SDHC cards (disabled by default).
|
||||||
|
* Support for FAT32 (disabled by default).
|
||||||
|
|
||||||
|
2008-06-08 sd-reader
|
||||||
|
* New "init" command to allow reinitialization of memory card.
|
||||||
|
* Fix searching through multi-cluster directories.
|
||||||
|
* Fix reading directory entries spanning a cluster border (backport from mega-eth).
|
||||||
|
* Do not abort the whole lfn entry when the file name is too long, just drop single characters (backport from mega-eth).
|
||||||
|
* Change fat16_get_dir_entry_of_path() to ignore a slash at the end (backport from mega-eth).
|
||||||
|
* Make listing a directory's content much faster (backport from mega-eth).
|
||||||
|
* Shrink code size by centralizing cluster offset calculation (backport from mega-eth).
|
||||||
|
* Some other small fixes and optimizations.
|
||||||
|
|
||||||
|
2007-12-13 sd-reader
|
||||||
|
* Dual-license the major implementation modules under GPL and LGPL.
|
||||||
|
|
||||||
|
2007-06-03 sd-reader
|
||||||
|
* Fix reading beyond cached block (by Benjamin Meier).
|
||||||
|
* Implement support for reading and writing file modification dates/times.
|
||||||
|
(Thanks to Torsten Seeboth for testing.)
|
||||||
|
|
||||||
|
2007-03-01 sd-reader
|
||||||
|
* Avoid LFN directory entries for the "." and ".." directory references.
|
||||||
|
This prevented Windows from deleting directories.
|
||||||
|
* Handle special case where the 8.3 filename begins with 0xe5.
|
||||||
|
* Fix return value of fat16_delete_file() when deleting empty files.
|
||||||
|
* Fix fat16_clear_cluster() which was zeroing only 16 of every 32 bytes.
|
||||||
|
|
||||||
|
2007-01-20 sd-reader
|
||||||
|
* Fix directory creation.
|
||||||
|
- Correctly create "." and ".." directory entries (8.3 <-> lfn versions).
|
||||||
|
- Correctly clear cluster containing the directory entries for new directory.
|
||||||
|
|
||||||
|
2006-11-01 sd-reader
|
||||||
|
* Implement creation and deletion of directories.
|
||||||
|
* Clear the directory entries of new directory clusters.
|
||||||
|
* Prevent linkage against printf().
|
||||||
|
* Make the use of malloc()/free() optional.
|
||||||
|
|
||||||
|
2006-09-01 sd-reader
|
||||||
|
* Fix shortening files.
|
||||||
|
* Fix free disk space calculation.
|
||||||
|
|
||||||
|
2006-08-24 sd-reader
|
||||||
|
* Improve sleep handling.
|
||||||
|
* Display extended card information on boot and
|
||||||
|
when executing the "disk" shell command.
|
||||||
|
* Correctly determine FAT type by cluster count.
|
||||||
|
* Fix cluster allocation beyond card capacity.
|
||||||
|
|
||||||
|
2006-08-16 sd-reader
|
||||||
|
* Provide FAT16 capacity and usage information.
|
||||||
|
* Implement the backspace key in the mini shell.
|
||||||
|
* Enter idle mode when waiting for uart activity.
|
||||||
|
* Make the Card Select pin MCU dependent as well.
|
||||||
|
* Add mini shell commands to documentation.
|
||||||
|
|
||||||
|
2006-08-08 sd-reader
|
||||||
|
* Thanks go to Torsten Seeboth for his ongoing efforts
|
||||||
|
to test changes, fix regressions and give suggestions.
|
||||||
|
Many of the changes below were initiated by him.
|
||||||
|
* Much more reliable card initialization.
|
||||||
|
* Highly improved performance
|
||||||
|
- optional write buffering
|
||||||
|
- better cluster handling
|
||||||
|
- remove unneeded SPI access when reading from buffered block
|
||||||
|
- use highest spi frequency after card initialization
|
||||||
|
* Add superfloppy support.
|
||||||
|
* Better checks when opening a FAT16 filesystem.
|
||||||
|
* Provide SPI pin mappings for commonly used ATmegas.
|
||||||
|
* Fix resizing files, hangs could occur.
|
||||||
|
* Fix overflow when creating files with names longer than 31 characters.
|
||||||
|
* Fix numerous other small things.
|
||||||
|
|
||||||
|
2006-03-19 sd-reader
|
||||||
|
* Fix speed regressions.
|
||||||
|
|
||||||
|
2006-03-16 sd-reader
|
||||||
|
* Initial release.
|
||||||
|
|
1525
final_project/sd_reader/Doxyfile
Normal file
1525
final_project/sd_reader/Doxyfile
Normal file
File diff suppressed because it is too large
Load Diff
124
final_project/sd_reader/FAQ
Normal file
124
final_project/sd_reader/FAQ
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
Frequently Asked Questions for sd-reader
|
||||||
|
========================================
|
||||||
|
|
||||||
|
General
|
||||||
|
-------
|
||||||
|
|
||||||
|
Q: Which cards are supported?
|
||||||
|
A: All MMC/SD/SDHC/miniSD/microSD/microSDHC should work, although not all variants have been tested.
|
||||||
|
Some very old (low capacity) cards might be broken as well. Cards with a capacity of 16 MB or
|
||||||
|
less are usually formatted with FAT12, so these are supported in raw mode only, if at all.
|
||||||
|
|
||||||
|
Q: What data rates can I expect?
|
||||||
|
A: See the benchmark page on the homepage.
|
||||||
|
http://www.roland-riegel.de/sd-reader/benchmarks/
|
||||||
|
|
||||||
|
Q: Are there boards available for purchase?
|
||||||
|
A: No.
|
||||||
|
|
||||||
|
Hardware
|
||||||
|
--------
|
||||||
|
|
||||||
|
Q: Where can I find the schematic?
|
||||||
|
A: Get it on the homepage.
|
||||||
|
http://www.roland-riegel.de/sd-reader/sd-reader_circuit_latest.zip
|
||||||
|
|
||||||
|
Q: What if my card socket has no Card-Detect and/or Card-Lock switches?
|
||||||
|
A: Change sd_raw_config.h such that it looks like
|
||||||
|
|
||||||
|
#define configure_pin_available() /* nothing */
|
||||||
|
#define configure_pin_locked() /* nothing */
|
||||||
|
|
||||||
|
#define get_pin_available() 0
|
||||||
|
#define get_pin_locked() 1
|
||||||
|
|
||||||
|
Q: All attempts to write to the card fail, although reading works. What's the problem?
|
||||||
|
A: Enable write support within sd_raw_config.h. And probably, your card socket has no Card-lock
|
||||||
|
detection (see question above).
|
||||||
|
|
||||||
|
Q: The card initialization fails. What can I do?
|
||||||
|
A: Usually this is some kind of hardware problem.
|
||||||
|
* Check the physical connections.
|
||||||
|
* Keep the signal lines to the card as short as possible.
|
||||||
|
* Do not use diodes to derive the card's supply voltage. Use a 3.3V voltage regulator instead.
|
||||||
|
* Have a stable, buffered power supply and use capacitors for correct voltage regulator
|
||||||
|
operation (see the schematics linked above).
|
||||||
|
* Use extra capacitors of 50uF and 100nF as close to the card as possible.
|
||||||
|
* When using an integrated level shifter or no level shifting at all (see the next question),
|
||||||
|
try adding a pullup of 50k from the data-out line of the card to 3.3V.
|
||||||
|
* Make sure the limiting frequency of the level shifter is not exceeded. Have a look into its
|
||||||
|
datasheet!
|
||||||
|
* Check the signals with a scope.
|
||||||
|
|
||||||
|
Q: What alternatives to resistor level shifting exist?
|
||||||
|
A: If you want to use additional devices with SPI or the resistor solution appears too ugly, there
|
||||||
|
are two possibilities. Either operate the whole circuit with a single 3.3V supply and no level
|
||||||
|
shifting at all or use a level shifting IC which interfaces the memory card to the AVR.
|
||||||
|
Depending on your requirements, adequate devices could include MAX3378E, MAX3392E, MAX3395E,
|
||||||
|
74LVC245 and 74HCT4050 (optionally together with 74HCT125). Please check the datasheets for the
|
||||||
|
required DC/AC characteristics!
|
||||||
|
|
||||||
|
Software
|
||||||
|
--------
|
||||||
|
|
||||||
|
Q: What's the software license?
|
||||||
|
A: GPLv2 or (for most parts) LGPLv2.1. Before using a file, read its license terms included at the
|
||||||
|
beginning of the file.
|
||||||
|
|
||||||
|
Q: What's the programming language used?
|
||||||
|
A: It's C, in compliance with the ISO C99 standard.
|
||||||
|
|
||||||
|
Q: What are these .patch-files provided?
|
||||||
|
A: Those record the source code differences between the old and new release. If you edited your
|
||||||
|
private sd-reader version, it might be easier to apply the patch files using the "patch" utility
|
||||||
|
common on Unix-like systems, rather than manually inserting the changes by hand. For Windows
|
||||||
|
users, the GnuWin32 project provides a port of "patch".
|
||||||
|
|
||||||
|
Q: Where can I learn more about the library interface and how to use it?
|
||||||
|
A: Look into the HTML documentation provided online or within each source distribution. Also take
|
||||||
|
the provided main.c as an example application and as a starting point.
|
||||||
|
|
||||||
|
Q: How do I adapt it to an ATmegaXYZ and my circuit in particular?
|
||||||
|
A: Add your MCU-specific pin configuration to sd_raw_config.h. Some commonly used ones are already
|
||||||
|
included.
|
||||||
|
|
||||||
|
Q: How do I adapt it to a different MCU clock?
|
||||||
|
A: Change the MCU_FREQ variable within the Makefile.
|
||||||
|
|
||||||
|
Q: How do I adapt it to some different MCU architecture?
|
||||||
|
A: Change sd_raw_init(), sd_raw_send_byte(), sd_raw_rec_byte() within sd_raw.c and the pin
|
||||||
|
definitions within sd_raw_config.h appropriately.
|
||||||
|
|
||||||
|
Q: Can the library be used with Arduino?
|
||||||
|
A: Yes. I do not have any experience with Arduino myself, but people report that it works with some
|
||||||
|
minor modifications to the library code needed due to some different compiler settings. Please
|
||||||
|
search the web for details.
|
||||||
|
|
||||||
|
Q: Can I use software SPI?
|
||||||
|
A: Yes, but the code is not prepared for it.
|
||||||
|
|
||||||
|
Q: My application crashes somewhere in the lib. Is there some bug hidden?
|
||||||
|
A: There might be a bug. Much more likely, however, is that you experience memory problems,
|
||||||
|
especially heap/stack collisions. The crashes can appear everywhere, but typically this is not
|
||||||
|
the place where the real problem is. Try to minimize the size of structures and other memory
|
||||||
|
blocks your application uses. Sum up the amount of memory your application allocates with global
|
||||||
|
and local variables and the memory you allocate dynamically with malloc(). The avr-nm utility
|
||||||
|
also helps a lot here. When called with the "--print-size --size-sort" parameters, it lists all
|
||||||
|
symbols and their code/memory size within the given file. See the avr-libc FAQ and the nm manual
|
||||||
|
for further information.
|
||||||
|
http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_ramoverlap
|
||||||
|
http://sourceware.org/binutils/docs/binutils/nm.html
|
||||||
|
|
||||||
|
Q: Opening the FAT filesystem fails. What can I do?
|
||||||
|
A: Make sure there is a FAT16 or FAT32 filesystem on the card. This usually isn't possible for old
|
||||||
|
cards with 16 MB or less. For larger ones, format the cards using the OS utilities, like the
|
||||||
|
Windows Explorer, the Unix/Linux mkdosfs command or special SD card format tools.
|
||||||
|
http://panasonic.jp/support/global/cs/sd/download/sd_formatter.html
|
||||||
|
http://www.sdcard.org/consumers/formatter/
|
||||||
|
|
||||||
|
Q: Writing to the card returns no failure, but when checking the file's content the data is not
|
||||||
|
there. What happens?
|
||||||
|
A: For performance reasons, writing to the card is always buffered. Before pulling the card out of
|
||||||
|
its socket (or issuing a reset of the MCU), make sure sd_raw_sync() gets called such that all
|
||||||
|
buffered data is written out to permanent card storage.
|
||||||
|
|
52
final_project/sd_reader/Makefile
Normal file
52
final_project/sd_reader/Makefile
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
|
||||||
|
NAME := sd-reader
|
||||||
|
HEX := $(NAME).hex
|
||||||
|
OUT := $(NAME).out
|
||||||
|
MAP := $(NAME).map
|
||||||
|
SOURCES := $(wildcard *.c)
|
||||||
|
HEADERS := $(wildcard *.h)
|
||||||
|
OBJECTS := $(patsubst %.c,%.o,$(SOURCES))
|
||||||
|
|
||||||
|
MCU := atmega328p
|
||||||
|
MCU_AVRDUDE := m328
|
||||||
|
MCU_FREQ := 16000000UL
|
||||||
|
|
||||||
|
CC := avr-gcc
|
||||||
|
OBJCOPY := avr-objcopy
|
||||||
|
SIZE := avr-size -A
|
||||||
|
DOXYGEN := doxygen
|
||||||
|
|
||||||
|
CFLAGS := -Werror -Wall -pedantic -mmcu=$(MCU) -std=c99 -g -O3 -DF_CPU=$(MCU_FREQ)
|
||||||
|
|
||||||
|
all: $(HEX)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(HEX) $(OUT) $(MAP) $(OBJECTS)
|
||||||
|
rm -rf doc/html
|
||||||
|
|
||||||
|
flash: $(HEX)
|
||||||
|
avrdude -y -c avr910 -p $(MCU_AVRDUDE) -U flash:w:$(HEX)
|
||||||
|
|
||||||
|
$(HEX): $(OUT)
|
||||||
|
$(OBJCOPY) -R .eeprom -O ihex $< $@
|
||||||
|
|
||||||
|
$(OUT): $(OBJECTS)
|
||||||
|
$(CC) $(CFLAGS) -o $@ -Wl,-Map,$(MAP) $^
|
||||||
|
@echo
|
||||||
|
@$(SIZE) $@
|
||||||
|
@echo
|
||||||
|
|
||||||
|
%.o: %.c $(HEADERS)
|
||||||
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
%.pp: %.c
|
||||||
|
$(CC) $(CFLAGS) -E -o $@ $<
|
||||||
|
|
||||||
|
%.ppo: %.c
|
||||||
|
$(CC) $(CFLAGS) -E $<
|
||||||
|
|
||||||
|
doc: $(HEADERS) $(SOURCES) Doxyfile
|
||||||
|
$(DOXYGEN) Doxyfile
|
||||||
|
|
||||||
|
.PHONY: all clean flash doc
|
||||||
|
|
110
final_project/sd_reader/byteordering.c
Normal file
110
final_project/sd_reader/byteordering.c
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2012 by Roland Riegel <feedback@roland-riegel.de>
|
||||||
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of either the GNU General Public License version 2
|
||||||
|
* or the GNU Lesser General Public License version 2.1, both as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "byteordering.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup byteordering
|
||||||
|
*
|
||||||
|
* Architecture-dependent handling of byte-ordering.
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* Byte-order handling implementation (license: GPLv2 or LGPLv2.1)
|
||||||
|
*
|
||||||
|
* \author Roland Riegel
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if DOXYGEN || SWAP_NEEDED
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \internal
|
||||||
|
* Swaps the bytes of a 16-bit integer.
|
||||||
|
*
|
||||||
|
* \param[in] i A 16-bit integer which to swap.
|
||||||
|
* \returns The swapped 16-bit integer.
|
||||||
|
*/
|
||||||
|
uint16_t swap16(uint16_t i)
|
||||||
|
{
|
||||||
|
return SWAP16(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \internal
|
||||||
|
* Swaps the bytes of a 32-bit integer.
|
||||||
|
*
|
||||||
|
* \param[in] i A 32-bit integer which to swap.
|
||||||
|
* \returns The swapped 32-bit integer.
|
||||||
|
*/
|
||||||
|
uint32_t swap32(uint32_t i)
|
||||||
|
{
|
||||||
|
return SWAP32(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a 16-bit integer from memory in little-endian byte order.
|
||||||
|
*
|
||||||
|
* \param[in] p Pointer from where to read the integer.
|
||||||
|
* \returns The 16-bit integer read from memory.
|
||||||
|
*/
|
||||||
|
uint16_t read16(const uint8_t* p)
|
||||||
|
{
|
||||||
|
return (((uint16_t) p[1]) << 8) |
|
||||||
|
(((uint16_t) p[0]) << 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a 32-bit integer from memory in little-endian byte order.
|
||||||
|
*
|
||||||
|
* \param[in] p Pointer from where to read the integer.
|
||||||
|
* \returns The 32-bit integer read from memory.
|
||||||
|
*/
|
||||||
|
uint32_t read32(const uint8_t* p)
|
||||||
|
{
|
||||||
|
return (((uint32_t) p[3]) << 24) |
|
||||||
|
(((uint32_t) p[2]) << 16) |
|
||||||
|
(((uint32_t) p[1]) << 8) |
|
||||||
|
(((uint32_t) p[0]) << 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes a 16-bit integer into memory in little-endian byte order.
|
||||||
|
*
|
||||||
|
* \param[in] p Pointer where to write the integer to.
|
||||||
|
* \param[in] i The 16-bit integer to write.
|
||||||
|
*/
|
||||||
|
void write16(uint8_t* p, uint16_t i)
|
||||||
|
{
|
||||||
|
p[1] = (uint8_t) ((i & 0xff00) >> 8);
|
||||||
|
p[0] = (uint8_t) ((i & 0x00ff) >> 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes a 32-bit integer into memory in little-endian byte order.
|
||||||
|
*
|
||||||
|
* \param[in] p Pointer where to write the integer to.
|
||||||
|
* \param[in] i The 32-bit integer to write.
|
||||||
|
*/
|
||||||
|
void write32(uint8_t* p, uint32_t i)
|
||||||
|
{
|
||||||
|
p[3] = (uint8_t) ((i & 0xff000000) >> 24);
|
||||||
|
p[2] = (uint8_t) ((i & 0x00ff0000) >> 16);
|
||||||
|
p[1] = (uint8_t) ((i & 0x0000ff00) >> 8);
|
||||||
|
p[0] = (uint8_t) ((i & 0x000000ff) >> 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
188
final_project/sd_reader/byteordering.h
Normal file
188
final_project/sd_reader/byteordering.h
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2012 by Roland Riegel <feedback@roland-riegel.de>
|
||||||
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of either the GNU General Public License version 2
|
||||||
|
* or the GNU Lesser General Public License version 2.1, both as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BYTEORDERING_H
|
||||||
|
#define BYTEORDERING_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup byteordering
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* Byte-order handling header (license: GPLv2 or LGPLv2.1)
|
||||||
|
*
|
||||||
|
* \author Roland Riegel
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define SWAP16(val) ((((uint16_t) (val)) << 8) | \
|
||||||
|
(((uint16_t) (val)) >> 8) \
|
||||||
|
)
|
||||||
|
#define SWAP32(val) (((((uint32_t) (val)) & 0x000000ff) << 24) | \
|
||||||
|
((((uint32_t) (val)) & 0x0000ff00) << 8) | \
|
||||||
|
((((uint32_t) (val)) & 0x00ff0000) >> 8) | \
|
||||||
|
((((uint32_t) (val)) & 0xff000000) >> 24) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#if LITTLE_ENDIAN || __AVR__
|
||||||
|
#define SWAP_NEEDED 0
|
||||||
|
#elif BIG_ENDIAN
|
||||||
|
#define SWAP_NEEDED 1
|
||||||
|
#else
|
||||||
|
#error "Endianess undefined! Please define LITTLE_ENDIAN=1 or BIG_ENDIAN=1."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \def HTOL16(val)
|
||||||
|
*
|
||||||
|
* Converts a 16-bit integer from host byte order to little-endian byte order.
|
||||||
|
*
|
||||||
|
* Use this macro for compile time constants only. For variable values
|
||||||
|
* use the function htol16() instead. This saves code size.
|
||||||
|
*
|
||||||
|
* \param[in] val A 16-bit integer in host byte order.
|
||||||
|
* \returns The given 16-bit integer converted to little-endian byte order.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* \def HTOL32(val)
|
||||||
|
*
|
||||||
|
* Converts a 32-bit integer from host byte order to little-endian byte order.
|
||||||
|
*
|
||||||
|
* Use this macro for compile time constants only. For variable values
|
||||||
|
* use the function htol32() instead. This saves code size.
|
||||||
|
*
|
||||||
|
* \param[in] val A 32-bit integer in host byte order.
|
||||||
|
* \returns The given 32-bit integer converted to little-endian byte order.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* \def LTOH16(val)
|
||||||
|
*
|
||||||
|
* Converts a 16-bit integer from little-endian byte order to host byte order.
|
||||||
|
*
|
||||||
|
* Use this macro for compile time constants only. For variable values
|
||||||
|
* use the function ltoh16() instead. This saves code size.
|
||||||
|
*
|
||||||
|
* \param[in] val A 16-bit integer in little-endian byte order.
|
||||||
|
* \returns The given 16-bit integer converted to host byte order.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* \def LTOH32(val)
|
||||||
|
*
|
||||||
|
* Converts a 32-bit integer from little-endian byte order to host byte order.
|
||||||
|
*
|
||||||
|
* Use this macro for compile time constants only. For variable values
|
||||||
|
* use the function ltoh32() instead. This saves code size.
|
||||||
|
*
|
||||||
|
* \param[in] val A 32-bit integer in little-endian byte order.
|
||||||
|
* \returns The given 32-bit integer converted to host byte order.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if SWAP_NEEDED
|
||||||
|
#define HTOL16(val) SWAP16(val)
|
||||||
|
#define HTOL32(val) SWAP32(val)
|
||||||
|
#define LTOH16(val) SWAP16(val)
|
||||||
|
#define LTOH32(val) SWAP32(val)
|
||||||
|
#else
|
||||||
|
#define HTOL16(val) (val)
|
||||||
|
#define HTOL32(val) (val)
|
||||||
|
#define LTOH16(val) (val)
|
||||||
|
#define LTOH32(val) (val)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if DOXYGEN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a 16-bit integer from host byte order to little-endian byte order.
|
||||||
|
*
|
||||||
|
* Use this function on variable values instead of the
|
||||||
|
* macro HTOL16(). This saves code size.
|
||||||
|
*
|
||||||
|
* \param[in] h A 16-bit integer in host byte order.
|
||||||
|
* \returns The given 16-bit integer converted to little-endian byte order.
|
||||||
|
*/
|
||||||
|
uint16_t htol16(uint16_t h);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a 32-bit integer from host byte order to little-endian byte order.
|
||||||
|
*
|
||||||
|
* Use this function on variable values instead of the
|
||||||
|
* macro HTOL32(). This saves code size.
|
||||||
|
*
|
||||||
|
* \param[in] h A 32-bit integer in host byte order.
|
||||||
|
* \returns The given 32-bit integer converted to little-endian byte order.
|
||||||
|
*/
|
||||||
|
uint32_t htol32(uint32_t h);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a 16-bit integer from little-endian byte order to host byte order.
|
||||||
|
*
|
||||||
|
* Use this function on variable values instead of the
|
||||||
|
* macro LTOH16(). This saves code size.
|
||||||
|
*
|
||||||
|
* \param[in] l A 16-bit integer in little-endian byte order.
|
||||||
|
* \returns The given 16-bit integer converted to host byte order.
|
||||||
|
*/
|
||||||
|
uint16_t ltoh16(uint16_t l);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a 32-bit integer from little-endian byte order to host byte order.
|
||||||
|
*
|
||||||
|
* Use this function on variable values instead of the
|
||||||
|
* macro LTOH32(). This saves code size.
|
||||||
|
*
|
||||||
|
* \param[in] l A 32-bit integer in little-endian byte order.
|
||||||
|
* \returns The given 32-bit integer converted to host byte order.
|
||||||
|
*/
|
||||||
|
uint32_t ltoh32(uint32_t l);
|
||||||
|
|
||||||
|
#elif SWAP_NEEDED
|
||||||
|
|
||||||
|
#define htol16(h) swap16(h)
|
||||||
|
#define htol32(h) swap32(h)
|
||||||
|
#define ltoh16(l) swap16(l)
|
||||||
|
#define ltoh32(l) swap32(l)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define htol16(h) (h)
|
||||||
|
#define htol32(h) (h)
|
||||||
|
#define ltoh16(l) (l)
|
||||||
|
#define ltoh32(l) (l)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint16_t read16(const uint8_t* p);
|
||||||
|
uint32_t read32(const uint8_t* p);
|
||||||
|
void write16(uint8_t* p, uint16_t i);
|
||||||
|
void write32(uint8_t* p, uint32_t i);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if SWAP_NEEDED
|
||||||
|
uint16_t swap16(uint16_t i);
|
||||||
|
uint32_t swap32(uint32_t i);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
81
final_project/sd_reader/comms.h
Symbolic link
81
final_project/sd_reader/comms.h
Symbolic link
@ -0,0 +1,81 @@
|
|||||||
|
#ifndef COMMS_H_
|
||||||
|
#define COMMS_H_
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Our format goes like this:
|
||||||
|
*
|
||||||
|
* 1 byte command, with data after
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
COMMS_CMD_CLR = 0U, //! Clears LCD and all file names
|
||||||
|
COMMS_CMD_NUM, //! sends the total number of songs to choose from
|
||||||
|
COMMS_CMD_QUERY_NUM,
|
||||||
|
COMMS_CMD_QUERY_NAME, //! Queries for the name of a given song ID
|
||||||
|
COMMS_CMD_REPLY_NAME, //! Responds with the name of the given song ID
|
||||||
|
COMMS_CMD_SELECT_FILE, //! selects a file from the given list to play, data is 1 byte for id
|
||||||
|
COMMS_CMD_PLAY, //! Starts playing file
|
||||||
|
COMMS_CMD_PAUSE //! pauses playing file
|
||||||
|
} comms_cmd_t;
|
||||||
|
|
||||||
|
/** @brief Inline function to send commands and values.
|
||||||
|
*/
|
||||||
|
inline void comms_send(comms_cmd_t cmd) {
|
||||||
|
|
||||||
|
while (! (UCSR0A & (1 << UDRE0)));
|
||||||
|
UDR0 = cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Selects a file from the list on the DAC side.
|
||||||
|
*
|
||||||
|
* If another song is playing, this will stop
|
||||||
|
* that song from playing and select the new one.
|
||||||
|
*/
|
||||||
|
inline void comms_select_file(uint8_t id) {
|
||||||
|
comms_send(COMMS_CMD_SELECT_FILE);
|
||||||
|
comms_send((comms_cmd_t) id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Queries for the name of the given song ID.
|
||||||
|
*/
|
||||||
|
inline void comms_query_name(uint8_t id) {
|
||||||
|
comms_send(COMMS_CMD_QUERY_NAME);
|
||||||
|
comms_send(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Repliers with the name of the requsted song ID
|
||||||
|
*/
|
||||||
|
inline void comms_reply_name(char* name) {
|
||||||
|
uint8_t len = strlen(name);
|
||||||
|
comms_send(COMMS_CMD_REPLY_NAME);
|
||||||
|
comms_send(len);
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < len; i++) {
|
||||||
|
comms_send((uint8_t) name[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Clears the LCD list of files.
|
||||||
|
*/
|
||||||
|
inline void comms_clear() {
|
||||||
|
comms_send(COMMS_CMD_CLR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Starts playing song.
|
||||||
|
*/
|
||||||
|
inline void comms_play() {
|
||||||
|
comms_send(COMMS_CMD_PLAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Pauses playing song.
|
||||||
|
*/
|
||||||
|
inline void comms_pause() {
|
||||||
|
comms_send(COMMS_CMD_PLAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
BIN
final_project/sd_reader/doc/pic01.jpg
Normal file
BIN
final_project/sd_reader/doc/pic01.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
BIN
final_project/sd_reader/doc/pic02.jpg
Normal file
BIN
final_project/sd_reader/doc/pic02.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
2551
final_project/sd_reader/fat.c
Normal file
2551
final_project/sd_reader/fat.c
Normal file
File diff suppressed because it is too large
Load Diff
131
final_project/sd_reader/fat.h
Normal file
131
final_project/sd_reader/fat.h
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2012 by Roland Riegel <feedback@roland-riegel.de>
|
||||||
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of either the GNU General Public License version 2
|
||||||
|
* or the GNU Lesser General Public License version 2.1, both as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FAT_H
|
||||||
|
#define FAT_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "fat_config.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup fat
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* FAT header (license: GPLv2 or LGPLv2.1)
|
||||||
|
*
|
||||||
|
* \author Roland Riegel
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup fat_file
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** The file is read-only. */
|
||||||
|
#define FAT_ATTRIB_READONLY (1 << 0)
|
||||||
|
/** The file is hidden. */
|
||||||
|
#define FAT_ATTRIB_HIDDEN (1 << 1)
|
||||||
|
/** The file is a system file. */
|
||||||
|
#define FAT_ATTRIB_SYSTEM (1 << 2)
|
||||||
|
/** The file is empty and has the volume label as its name. */
|
||||||
|
#define FAT_ATTRIB_VOLUME (1 << 3)
|
||||||
|
/** The file is a directory. */
|
||||||
|
#define FAT_ATTRIB_DIR (1 << 4)
|
||||||
|
/** The file has to be archived. */
|
||||||
|
#define FAT_ATTRIB_ARCHIVE (1 << 5)
|
||||||
|
|
||||||
|
/** The given offset is relative to the beginning of the file. */
|
||||||
|
#define FAT_SEEK_SET 0
|
||||||
|
/** The given offset is relative to the current read/write position. */
|
||||||
|
#define FAT_SEEK_CUR 1
|
||||||
|
/** The given offset is relative to the end of the file. */
|
||||||
|
#define FAT_SEEK_END 2
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct partition_struct;
|
||||||
|
struct fat_fs_struct;
|
||||||
|
struct fat_file_struct;
|
||||||
|
struct fat_dir_struct;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup fat_file
|
||||||
|
* Describes a directory entry.
|
||||||
|
*/
|
||||||
|
struct fat_dir_entry_struct
|
||||||
|
{
|
||||||
|
/** The file's name, truncated to 31 characters. */
|
||||||
|
char long_name[32];
|
||||||
|
/** The file's attributes. Mask of the FAT_ATTRIB_* constants. */
|
||||||
|
uint8_t attributes;
|
||||||
|
#if FAT_DATETIME_SUPPORT
|
||||||
|
/** Compressed representation of modification time. */
|
||||||
|
uint16_t modification_time;
|
||||||
|
/** Compressed representation of modification date. */
|
||||||
|
uint16_t modification_date;
|
||||||
|
#endif
|
||||||
|
/** The cluster in which the file's first byte resides. */
|
||||||
|
cluster_t cluster;
|
||||||
|
/** The file's size. */
|
||||||
|
uint32_t file_size;
|
||||||
|
/** The total disk offset of this directory entry. */
|
||||||
|
offset_t entry_offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct fat_fs_struct* fat_open(struct partition_struct* partition);
|
||||||
|
void fat_close(struct fat_fs_struct* fs);
|
||||||
|
|
||||||
|
struct fat_file_struct* fat_open_file(struct fat_fs_struct* fs, const struct fat_dir_entry_struct* dir_entry);
|
||||||
|
void fat_close_file(struct fat_file_struct* fd);
|
||||||
|
intptr_t fat_read_file(struct fat_file_struct* fd, uint8_t* buffer, uintptr_t buffer_len);
|
||||||
|
intptr_t fat_write_file(struct fat_file_struct* fd, const uint8_t* buffer, uintptr_t buffer_len);
|
||||||
|
uint8_t fat_seek_file(struct fat_file_struct* fd, int32_t* offset, uint8_t whence);
|
||||||
|
uint8_t fat_resize_file(struct fat_file_struct* fd, uint32_t size);
|
||||||
|
|
||||||
|
struct fat_dir_struct* fat_open_dir(struct fat_fs_struct* fs, const struct fat_dir_entry_struct* dir_entry);
|
||||||
|
void fat_close_dir(struct fat_dir_struct* dd);
|
||||||
|
uint8_t fat_read_dir(struct fat_dir_struct* dd, struct fat_dir_entry_struct* dir_entry);
|
||||||
|
uint8_t fat_reset_dir(struct fat_dir_struct* dd);
|
||||||
|
|
||||||
|
uint8_t fat_create_file(struct fat_dir_struct* parent, const char* file, struct fat_dir_entry_struct* dir_entry);
|
||||||
|
uint8_t fat_delete_file(struct fat_fs_struct* fs, struct fat_dir_entry_struct* dir_entry);
|
||||||
|
uint8_t fat_move_file(struct fat_fs_struct* fs, struct fat_dir_entry_struct* dir_entry, struct fat_dir_struct* parent_new, const char* file_new);
|
||||||
|
uint8_t fat_create_dir(struct fat_dir_struct* parent, const char* dir, struct fat_dir_entry_struct* dir_entry);
|
||||||
|
#define fat_delete_dir fat_delete_file
|
||||||
|
#define fat_move_dir fat_move_file
|
||||||
|
|
||||||
|
void fat_get_file_modification_date(const struct fat_dir_entry_struct* dir_entry, uint16_t* year, uint8_t* month, uint8_t* day);
|
||||||
|
void fat_get_file_modification_time(const struct fat_dir_entry_struct* dir_entry, uint8_t* hour, uint8_t* min, uint8_t* sec);
|
||||||
|
|
||||||
|
uint8_t fat_get_dir_entry_of_path(struct fat_fs_struct* fs, const char* path, struct fat_dir_entry_struct* dir_entry);
|
||||||
|
|
||||||
|
offset_t fat_get_fs_size(const struct fat_fs_struct* fs);
|
||||||
|
offset_t fat_get_fs_free(const struct fat_fs_struct* fs);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
128
final_project/sd_reader/fat_config.h
Normal file
128
final_project/sd_reader/fat_config.h
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2012 by Roland Riegel <feedback@roland-riegel.de>
|
||||||
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of either the GNU General Public License version 2
|
||||||
|
* or the GNU Lesser General Public License version 2.1, both as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FAT_CONFIG_H
|
||||||
|
#define FAT_CONFIG_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "sd_raw_config.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup fat
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* FAT configuration (license: GPLv2 or LGPLv2.1)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup fat_config
|
||||||
|
* Controls FAT write support.
|
||||||
|
*
|
||||||
|
* Set to 1 to enable FAT write support, set to 0 to disable it.
|
||||||
|
*/
|
||||||
|
#define FAT_WRITE_SUPPORT SD_RAW_WRITE_SUPPORT
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup fat_config
|
||||||
|
* Controls FAT long filename (LFN) support.
|
||||||
|
*
|
||||||
|
* Set to 1 to enable LFN support, set to 0 to disable it.
|
||||||
|
*/
|
||||||
|
#define FAT_LFN_SUPPORT 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup fat_config
|
||||||
|
* Controls FAT date and time support.
|
||||||
|
*
|
||||||
|
* Set to 1 to enable FAT date and time stamping support.
|
||||||
|
*/
|
||||||
|
#define FAT_DATETIME_SUPPORT 0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup fat_config
|
||||||
|
* Controls FAT32 support.
|
||||||
|
*
|
||||||
|
* Set to 1 to enable FAT32 support.
|
||||||
|
*/
|
||||||
|
#define FAT_FAT32_SUPPORT SD_RAW_SDHC
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup fat_config
|
||||||
|
* Controls updates of directory entries.
|
||||||
|
*
|
||||||
|
* Set to 1 to delay directory entry updates until the file is closed.
|
||||||
|
* This can boost performance significantly, but may cause data loss
|
||||||
|
* if the file is not properly closed.
|
||||||
|
*/
|
||||||
|
#define FAT_DELAY_DIRENTRY_UPDATE 0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup fat_config
|
||||||
|
* Determines the function used for retrieving current date and time.
|
||||||
|
*
|
||||||
|
* Define this to the function call which shall be used to retrieve
|
||||||
|
* current date and time.
|
||||||
|
*
|
||||||
|
* \note Used only when FAT_DATETIME_SUPPORT is 1.
|
||||||
|
*
|
||||||
|
* \param[out] year Pointer to a \c uint16_t which receives the current year.
|
||||||
|
* \param[out] month Pointer to a \c uint8_t which receives the current month.
|
||||||
|
* \param[out] day Pointer to a \c uint8_t which receives the current day.
|
||||||
|
* \param[out] hour Pointer to a \c uint8_t which receives the current hour.
|
||||||
|
* \param[out] min Pointer to a \c uint8_t which receives the current minute.
|
||||||
|
* \param[out] sec Pointer to a \c uint8_t which receives the current sec.
|
||||||
|
*/
|
||||||
|
#define fat_get_datetime(year, month, day, hour, min, sec) \
|
||||||
|
get_datetime(year, month, day, hour, min, sec)
|
||||||
|
/* forward declaration for the above */
|
||||||
|
void get_datetime(uint16_t* year, uint8_t* month, uint8_t* day, uint8_t* hour, uint8_t* min, uint8_t* sec);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup fat_config
|
||||||
|
* Maximum number of filesystem handles.
|
||||||
|
*/
|
||||||
|
#define FAT_FS_COUNT 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup fat_config
|
||||||
|
* Maximum number of file handles.
|
||||||
|
*/
|
||||||
|
#define FAT_FILE_COUNT 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup fat_config
|
||||||
|
* Maximum number of directory handles.
|
||||||
|
*/
|
||||||
|
#define FAT_DIR_COUNT 2
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if FAT_FAT32_SUPPORT
|
||||||
|
typedef uint32_t cluster_t;
|
||||||
|
#else
|
||||||
|
typedef uint16_t cluster_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
52
final_project/sd_reader/fifo.c
Normal file
52
final_project/sd_reader/fifo.c
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#include "fifo.h"
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
FIFO_TYPE buffer[FIFO_LEN];
|
||||||
|
uint16_t rd_ptr;
|
||||||
|
uint16_t wr_ptr;
|
||||||
|
uint16_t entries;
|
||||||
|
} fifo;
|
||||||
|
|
||||||
|
void fifo_init() {
|
||||||
|
fifo.rd_ptr = 0;
|
||||||
|
fifo.wr_ptr = 0;
|
||||||
|
fifo.entries = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
fifo_err_t fifo_pop(FIFO_TYPE* dest) {
|
||||||
|
// FIFO is empty, nothing to return!
|
||||||
|
if (fifo.entries == 0) {
|
||||||
|
return FIFO_EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Entries in FIFO, pop
|
||||||
|
*dest = fifo.buffer[fifo.rd_ptr];
|
||||||
|
fifo.rd_ptr++;
|
||||||
|
fifo.entries--;
|
||||||
|
|
||||||
|
// Ensure pointers don't overflow!
|
||||||
|
if (fifo.rd_ptr == FIFO_LEN) {
|
||||||
|
fifo.rd_ptr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FIFO_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fifo_err_t fifo_push(FIFO_TYPE src) {
|
||||||
|
// FIFO is full, don't store anything
|
||||||
|
if (fifo.entries == FIFO_LEN) {
|
||||||
|
return FIFO_FULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIFO has space, write
|
||||||
|
fifo.buffer[fifo.wr_ptr] = src;
|
||||||
|
fifo.wr_ptr++;
|
||||||
|
fifo.entries++;
|
||||||
|
|
||||||
|
// Ensure pointers don't overflow!
|
||||||
|
if (fifo.wr_ptr == FIFO_LEN) {
|
||||||
|
fifo.wr_ptr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FIFO_SUCCESS;
|
||||||
|
}
|
36
final_project/sd_reader/fifo.h
Normal file
36
final_project/sd_reader/fifo.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#ifndef FIFO_H_
|
||||||
|
#define FIFO_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
FIFO_SUCCESS,
|
||||||
|
FIFO_FULL,
|
||||||
|
FIFO_EMPTY
|
||||||
|
} fifo_err_t;
|
||||||
|
|
||||||
|
#define FIFO_LEN 20
|
||||||
|
#define FIFO_TYPE uint8_t
|
||||||
|
|
||||||
|
/** @brief Initialises FIFO
|
||||||
|
*
|
||||||
|
* This MUST be called before any other fifo_* functions are called.
|
||||||
|
* Unless memory is initialised to 0. Then it's fine I guess.
|
||||||
|
*/
|
||||||
|
void fifo_init();
|
||||||
|
|
||||||
|
/** @brief Pops most recent addition off of FIFO buffer.
|
||||||
|
*
|
||||||
|
* @retval FIFO_SUCCESS Successfully read data from FIFO
|
||||||
|
* @retval FIFO_EMPTY Buffer was empty, no data read
|
||||||
|
*/
|
||||||
|
fifo_err_t fifo_pop(FIFO_TYPE* dest);
|
||||||
|
|
||||||
|
/** @brief Pushes entry onto FIFO buffer.
|
||||||
|
*
|
||||||
|
* @retval FIFO_SUCCESS successfully wrote data to FIFO buffer
|
||||||
|
* @retval FIFO_FULL buffer, was full, no data written
|
||||||
|
*/
|
||||||
|
fifo_err_t fifo_push(FIFO_TYPE src);
|
||||||
|
|
||||||
|
#endif
|
233
final_project/sd_reader/main.c
Normal file
233
final_project/sd_reader/main.c
Normal file
@ -0,0 +1,233 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2012 by Roland Riegel <feedback@roland-riegel.de>
|
||||||
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
#define DEBUG 1
|
||||||
|
|
||||||
|
const char* DATA_CHUNK_ID = "data";
|
||||||
|
|
||||||
|
/* ---- Control Flow Variables ---- */
|
||||||
|
// Commands
|
||||||
|
uint8_t cmd_depth = 0;
|
||||||
|
uint8_t cmd_state;
|
||||||
|
|
||||||
|
// Song playing
|
||||||
|
// TODO fix this atrocious naming
|
||||||
|
uint8_t song_buf[2][SONG_BUF_LEN]; //! Buffers to play song from
|
||||||
|
uint8_t song_position; //! where we are in the buffers
|
||||||
|
bool song_buf_select; //! which buffer we're using
|
||||||
|
bool song_selected; //! Flag to say we just selected the song, read data in
|
||||||
|
int8_t song_selection = -1; //! ID of selected song
|
||||||
|
uint32_t song_len;
|
||||||
|
uint32_t song_read_position;
|
||||||
|
bool send_number_of_songs = true;
|
||||||
|
uint8_t num_songs = 0;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
struct fat_file_struct* fd;
|
||||||
|
char* name;
|
||||||
|
} song_info_t;
|
||||||
|
|
||||||
|
song_info_t songs[MAX_SONG_NUM];
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
gpio_init();
|
||||||
|
timer_init();
|
||||||
|
usart_init();
|
||||||
|
sei();
|
||||||
|
|
||||||
|
// TODO set SPI to highest freq possible, might just need tweaking
|
||||||
|
sd_raw_init();
|
||||||
|
/* we will just use ordinary idle mode */
|
||||||
|
//set_sleep_mode(SLEEP_MODE_IDLE);
|
||||||
|
|
||||||
|
/* open first partition */
|
||||||
|
struct partition_struct* partition = partition_open(sd_raw_read,
|
||||||
|
sd_raw_read_interval,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
if(!partition)
|
||||||
|
{
|
||||||
|
/* If the partition did not open, assume the storage device
|
||||||
|
* is a "superfloppy", i.e. has no MBR.
|
||||||
|
*/
|
||||||
|
partition = partition_open(sd_raw_read,
|
||||||
|
sd_raw_read_interval,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
-1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* open file system */
|
||||||
|
struct fat_fs_struct* fs = fat_open(partition);
|
||||||
|
|
||||||
|
/* open root directory */
|
||||||
|
struct fat_dir_entry_struct directory;
|
||||||
|
fat_get_dir_entry_of_path(fs, "/", &directory);
|
||||||
|
|
||||||
|
struct fat_dir_struct* dd = fat_open_dir(fs, &directory);
|
||||||
|
|
||||||
|
// Get all of the song names
|
||||||
|
struct fat_dir_entry_struct dir_entry;
|
||||||
|
uint8_t song_id = 0;
|
||||||
|
while(fat_read_dir(dd, &dir_entry)) {
|
||||||
|
// too many files!
|
||||||
|
if (song_id == MAX_SONG_NUM) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is file, so add to list
|
||||||
|
if (!(dir_entry.attributes & FAT_ATTRIB_DIR)) {
|
||||||
|
// TODO add checking if its .wav
|
||||||
|
|
||||||
|
// Copy song name into memory
|
||||||
|
uint8_t len = strlen(dir_entry.long_name);
|
||||||
|
songs[song_id].name = malloc(len);
|
||||||
|
strcpy(songs[song_id].name, dir_entry.long_name);
|
||||||
|
|
||||||
|
// Open file and keep info in songs
|
||||||
|
fat_open_file(fs, (const struct fat_dir_entry_struct*) songs[song_id].fd);
|
||||||
|
|
||||||
|
// Move on to reading next song
|
||||||
|
song_id++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
num_songs = song_id;
|
||||||
|
|
||||||
|
|
||||||
|
// Print out all files/directories in top level
|
||||||
|
while (1) {
|
||||||
|
/// do stuff
|
||||||
|
|
||||||
|
// Handle incoming commands
|
||||||
|
if (cmd_depth == 0) {
|
||||||
|
if (fifo_pop(&cmd_state) == FIFO_SUCCESS) {
|
||||||
|
// Handle incoming command
|
||||||
|
switch(cmd_state) {
|
||||||
|
case (COMMS_CMD_PAUSE):
|
||||||
|
// Turn off interrupts for play timer to stop playing
|
||||||
|
TIFR0 &= ~(1 << OCF0A);
|
||||||
|
cmd_depth = 0;
|
||||||
|
break;
|
||||||
|
case (COMMS_CMD_PLAY):
|
||||||
|
// Turn on interrupts for play timer to start playing
|
||||||
|
TIFR0 |= (1 << OCF0A);
|
||||||
|
cmd_depth = 0;
|
||||||
|
break;
|
||||||
|
case (COMMS_CMD_SELECT_FILE):
|
||||||
|
// stop playing whatever song we have right now
|
||||||
|
// Wait for next loop to handle file
|
||||||
|
TIFR0 &= ~(1 << OCF0A);
|
||||||
|
cmd_depth = 1;
|
||||||
|
break;
|
||||||
|
case (COMMS_CMD_QUERY_NAME):
|
||||||
|
// Wait for next loop to handle file info
|
||||||
|
cmd_depth = 1;
|
||||||
|
break;
|
||||||
|
case (COMMS_CMD_QUERY_NUM):
|
||||||
|
comms_send(COMMS_CMD_NUM);
|
||||||
|
comms_send(num_songs);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd_depth == 1) {
|
||||||
|
uint8_t song_id;
|
||||||
|
while (fifo_pop(&song_id) != FIFO_SUCCESS);
|
||||||
|
switch (cmd_state) {
|
||||||
|
case (COMMS_CMD_SELECT_FILE):
|
||||||
|
// select proper song and begin reading in
|
||||||
|
song_selection = song_id;
|
||||||
|
song_selected = 1;
|
||||||
|
break;
|
||||||
|
case (COMMS_CMD_QUERY_NAME):
|
||||||
|
// Just going to hope we can bump the UART baudrate up high enough
|
||||||
|
comms_reply_name(songs[song_id].name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO check here if we are running into the end of our song buffer, and read in song data
|
||||||
|
if (song_position > 128 || song_selected) {
|
||||||
|
// Select opposite buffer
|
||||||
|
bool read_song_buf = !song_buf_select;
|
||||||
|
|
||||||
|
// Need to get past the metadata
|
||||||
|
if (song_selected) {
|
||||||
|
// Seek beginning of file
|
||||||
|
fat_seek_file(songs[song_selection].fd, 0, FAT_SEEK_SET);
|
||||||
|
|
||||||
|
// Iterate until we get the data
|
||||||
|
bool is_data = false;
|
||||||
|
ck_hdr_t header;
|
||||||
|
while (!is_data) {
|
||||||
|
fat_read_file(songs[song_selection].fd,
|
||||||
|
(uint8_t* ) &header, sizeof(ck_hdr_t));
|
||||||
|
|
||||||
|
// Ghetto strcmp
|
||||||
|
for (uint8_t i = 0; i < 4; i++) {
|
||||||
|
if (DATA_CHUNK_ID[i] == header.ckID[i]) {
|
||||||
|
is_data = true;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this is metadata, skip the chunk
|
||||||
|
int32_t* offset = NULL;
|
||||||
|
*offset = header.cksize;
|
||||||
|
if (!is_data) {
|
||||||
|
fat_seek_file(songs[song_selection].fd,
|
||||||
|
offset, FAT_SEEK_CUR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// We are now at the actual data
|
||||||
|
// divide by two to get uint16
|
||||||
|
song_len = header.cksize;
|
||||||
|
song_read_position = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// hit end of song, no more to read
|
||||||
|
if (song_read_position == song_len) {
|
||||||
|
song_read_position = 0;
|
||||||
|
TIFR0 &= ~(1 << OCF0A);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Read in file
|
||||||
|
// 512 bytes to read, 256 samples
|
||||||
|
fat_read_file(songs[song_selection].fd, (uint8_t*) song_buf[read_song_buf], 256);
|
||||||
|
song_read_position += 256;
|
||||||
|
|
||||||
|
// If we selected the song, make sure we start playing from the right buffer
|
||||||
|
if (song_selected) {
|
||||||
|
song_buf_select = read_song_buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure we don't "re-select" the song
|
||||||
|
song_selected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
33
final_project/sd_reader/main.h
Normal file
33
final_project/sd_reader/main.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#ifndef MAIN_H_
|
||||||
|
#define MAIN_H_
|
||||||
|
|
||||||
|
#define F_CPU 8000000UL
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include <avr/sleep.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <util/delay.h>
|
||||||
|
#include "fat.h"
|
||||||
|
#include "fat_config.h"
|
||||||
|
#include "partition.h"
|
||||||
|
#include "sd_raw.h"
|
||||||
|
#include "sd_raw_config.h"
|
||||||
|
#include "fifo.h"
|
||||||
|
#include "comms.h"
|
||||||
|
#include "periph.h"
|
||||||
|
#include "wav.h"
|
||||||
|
|
||||||
|
#define MAX_SONG_NUM 9
|
||||||
|
#define SONG_BUF_LEN 256 // NO MORE THAN 256!!!
|
||||||
|
|
||||||
|
|
||||||
|
// Song playing
|
||||||
|
extern uint8_t song_buf[2][SONG_BUF_LEN]; //! Buffers to play song from
|
||||||
|
extern uint8_t song_position; //! where we are in the buffers
|
||||||
|
extern bool song_buf_select; //! which buffer we're using
|
||||||
|
extern bool send_number_of_songs;
|
||||||
|
|
||||||
|
#endif
|
155
final_project/sd_reader/partition.c
Normal file
155
final_project/sd_reader/partition.c
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2012 by Roland Riegel <feedback@roland-riegel.de>
|
||||||
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of either the GNU General Public License version 2
|
||||||
|
* or the GNU Lesser General Public License version 2.1, both as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "byteordering.h"
|
||||||
|
#include "partition.h"
|
||||||
|
#include "partition_config.h"
|
||||||
|
#include "sd-reader_config.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#if USE_DYNAMIC_MEMORY
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup partition Partition table support
|
||||||
|
*
|
||||||
|
* Support for reading partition tables and access to partitions.
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* Partition table implementation (license: GPLv2 or LGPLv2.1)
|
||||||
|
*
|
||||||
|
* \author Roland Riegel
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup partition_config Configuration of partition table support
|
||||||
|
* Preprocessor defines to configure the partition support.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !USE_DYNAMIC_MEMORY
|
||||||
|
static struct partition_struct partition_handles[PARTITION_COUNT];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a partition.
|
||||||
|
*
|
||||||
|
* Opens a partition by its index number and returns a partition
|
||||||
|
* handle which describes the opened partition.
|
||||||
|
*
|
||||||
|
* \note This function does not support extended partitions.
|
||||||
|
*
|
||||||
|
* \param[in] device_read A function pointer which is used to read from the disk.
|
||||||
|
* \param[in] device_read_interval A function pointer which is used to read in constant intervals from the disk.
|
||||||
|
* \param[in] device_write A function pointer which is used to write to the disk.
|
||||||
|
* \param[in] device_write_interval A function pointer which is used to write a data stream to disk.
|
||||||
|
* \param[in] index The index of the partition which should be opened, range 0 to 3.
|
||||||
|
* A negative value is allowed as well. In this case, the partition opened is
|
||||||
|
* not checked for existance, begins at offset zero, has a length of zero
|
||||||
|
* and is of an unknown type. Use this in case you want to open the whole device
|
||||||
|
* as a single partition (e.g. for "super floppy" use).
|
||||||
|
* \returns 0 on failure, a partition descriptor on success.
|
||||||
|
* \see partition_close
|
||||||
|
*/
|
||||||
|
struct partition_struct* partition_open(device_read_t device_read, device_read_interval_t device_read_interval, device_write_t device_write, device_write_interval_t device_write_interval, int8_t index)
|
||||||
|
{
|
||||||
|
struct partition_struct* new_partition = 0;
|
||||||
|
uint8_t buffer[0x10];
|
||||||
|
|
||||||
|
if(!device_read || !device_read_interval || index >= 4)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if(index >= 0)
|
||||||
|
{
|
||||||
|
/* read specified partition table index */
|
||||||
|
if(!device_read(0x01be + index * 0x10, buffer, sizeof(buffer)))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* abort on empty partition entry */
|
||||||
|
if(buffer[4] == 0x00)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* allocate partition descriptor */
|
||||||
|
#if USE_DYNAMIC_MEMORY
|
||||||
|
new_partition = malloc(sizeof(*new_partition));
|
||||||
|
if(!new_partition)
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
new_partition = partition_handles;
|
||||||
|
uint8_t i;
|
||||||
|
for(i = 0; i < PARTITION_COUNT; ++i)
|
||||||
|
{
|
||||||
|
if(new_partition->type == PARTITION_TYPE_FREE)
|
||||||
|
break;
|
||||||
|
|
||||||
|
++new_partition;
|
||||||
|
}
|
||||||
|
if(i >= PARTITION_COUNT)
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
memset(new_partition, 0, sizeof(*new_partition));
|
||||||
|
|
||||||
|
/* fill partition descriptor */
|
||||||
|
new_partition->device_read = device_read;
|
||||||
|
new_partition->device_read_interval = device_read_interval;
|
||||||
|
new_partition->device_write = device_write;
|
||||||
|
new_partition->device_write_interval = device_write_interval;
|
||||||
|
|
||||||
|
if(index >= 0)
|
||||||
|
{
|
||||||
|
new_partition->type = buffer[4];
|
||||||
|
new_partition->offset = read32(&buffer[8]);
|
||||||
|
new_partition->length = read32(&buffer[12]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new_partition->type = 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new_partition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes a partition.
|
||||||
|
*
|
||||||
|
* This function destroys a partition descriptor which was
|
||||||
|
* previously obtained from a call to partition_open().
|
||||||
|
* When this function returns, the given descriptor will be
|
||||||
|
* invalid.
|
||||||
|
*
|
||||||
|
* \param[in] partition The partition descriptor to destroy.
|
||||||
|
* \returns 0 on failure, 1 on success.
|
||||||
|
* \see partition_open
|
||||||
|
*/
|
||||||
|
uint8_t partition_close(struct partition_struct* partition)
|
||||||
|
{
|
||||||
|
if(!partition)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* destroy partition descriptor */
|
||||||
|
#if USE_DYNAMIC_MEMORY
|
||||||
|
free(partition);
|
||||||
|
#else
|
||||||
|
partition->type = PARTITION_TYPE_FREE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
212
final_project/sd_reader/partition.h
Normal file
212
final_project/sd_reader/partition.h
Normal file
@ -0,0 +1,212 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2012 by Roland Riegel <feedback@roland-riegel.de>
|
||||||
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of either the GNU General Public License version 2
|
||||||
|
* or the GNU Lesser General Public License version 2.1, both as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PARTITION_H
|
||||||
|
#define PARTITION_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "sd_raw_config.h"
|
||||||
|
#include "partition_config.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup partition
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* Partition table header (license: GPLv2 or LGPLv2.1)
|
||||||
|
*
|
||||||
|
* \author Roland Riegel
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The partition table entry is not used.
|
||||||
|
*/
|
||||||
|
#define PARTITION_TYPE_FREE 0x00
|
||||||
|
/**
|
||||||
|
* The partition contains a FAT12 filesystem.
|
||||||
|
*/
|
||||||
|
#define PARTITION_TYPE_FAT12 0x01
|
||||||
|
/**
|
||||||
|
* The partition contains a FAT16 filesystem with 32MB maximum.
|
||||||
|
*/
|
||||||
|
#define PARTITION_TYPE_FAT16_32MB 0x04
|
||||||
|
/**
|
||||||
|
* The partition is an extended partition with its own partition table.
|
||||||
|
*/
|
||||||
|
#define PARTITION_TYPE_EXTENDED 0x05
|
||||||
|
/**
|
||||||
|
* The partition contains a FAT16 filesystem.
|
||||||
|
*/
|
||||||
|
#define PARTITION_TYPE_FAT16 0x06
|
||||||
|
/**
|
||||||
|
* The partition contains a FAT32 filesystem.
|
||||||
|
*/
|
||||||
|
#define PARTITION_TYPE_FAT32 0x0b
|
||||||
|
/**
|
||||||
|
* The partition contains a FAT32 filesystem with LBA.
|
||||||
|
*/
|
||||||
|
#define PARTITION_TYPE_FAT32_LBA 0x0c
|
||||||
|
/**
|
||||||
|
* The partition contains a FAT16 filesystem with LBA.
|
||||||
|
*/
|
||||||
|
#define PARTITION_TYPE_FAT16_LBA 0x0e
|
||||||
|
/**
|
||||||
|
* The partition is an extended partition with LBA.
|
||||||
|
*/
|
||||||
|
#define PARTITION_TYPE_EXTENDED_LBA 0x0f
|
||||||
|
/**
|
||||||
|
* The partition has an unknown type.
|
||||||
|
*/
|
||||||
|
#define PARTITION_TYPE_UNKNOWN 0xff
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A function pointer used to read from the partition.
|
||||||
|
*
|
||||||
|
* \param[in] offset The offset on the device where to start reading.
|
||||||
|
* \param[out] buffer The buffer into which to place the data.
|
||||||
|
* \param[in] length The count of bytes to read.
|
||||||
|
*/
|
||||||
|
typedef uint8_t (*device_read_t)(offset_t offset, uint8_t* buffer, uintptr_t length);
|
||||||
|
/**
|
||||||
|
* A function pointer passed to a \c device_read_interval_t.
|
||||||
|
*
|
||||||
|
* \param[in] buffer The buffer which contains the data just read.
|
||||||
|
* \param[in] offset The offset from which the data in \c buffer was read.
|
||||||
|
* \param[in] p An opaque pointer.
|
||||||
|
* \see device_read_interval_t
|
||||||
|
*/
|
||||||
|
typedef uint8_t (*device_read_callback_t)(uint8_t* buffer, offset_t offset, void* p);
|
||||||
|
/**
|
||||||
|
* A function pointer used to continuously read units of \c interval bytes
|
||||||
|
* and call a callback function.
|
||||||
|
*
|
||||||
|
* This function starts reading at the specified offset. Every \c interval bytes,
|
||||||
|
* it calls the callback function with the associated data buffer.
|
||||||
|
*
|
||||||
|
* By returning zero, the callback may stop reading.
|
||||||
|
*
|
||||||
|
* \param[in] offset Offset from which to start reading.
|
||||||
|
* \param[in] buffer Pointer to a buffer which is at least interval bytes in size.
|
||||||
|
* \param[in] interval Number of bytes to read before calling the callback function.
|
||||||
|
* \param[in] length Number of bytes to read altogether.
|
||||||
|
* \param[in] callback The function to call every interval bytes.
|
||||||
|
* \param[in] p An opaque pointer directly passed to the callback function.
|
||||||
|
* \returns 0 on failure, 1 on success
|
||||||
|
* \see device_read_t
|
||||||
|
*/
|
||||||
|
typedef uint8_t (*device_read_interval_t)(offset_t offset, uint8_t* buffer, uintptr_t interval, uintptr_t length, device_read_callback_t callback, void* p);
|
||||||
|
/**
|
||||||
|
* A function pointer used to write to the partition.
|
||||||
|
*
|
||||||
|
* \param[in] offset The offset on the device where to start writing.
|
||||||
|
* \param[in] buffer The buffer which to write.
|
||||||
|
* \param[in] length The count of bytes to write.
|
||||||
|
*/
|
||||||
|
typedef uint8_t (*device_write_t)(offset_t offset, const uint8_t* buffer, uintptr_t length);
|
||||||
|
/**
|
||||||
|
* A function pointer passed to a \c device_write_interval_t.
|
||||||
|
*
|
||||||
|
* \param[in] buffer The buffer which receives the data to write.
|
||||||
|
* \param[in] offset The offset to which the data in \c buffer will be written.
|
||||||
|
* \param[in] p An opaque pointer.
|
||||||
|
* \returns The number of bytes put into \c buffer
|
||||||
|
* \see device_write_interval_t
|
||||||
|
*/
|
||||||
|
typedef uintptr_t (*device_write_callback_t)(uint8_t* buffer, offset_t offset, void* p);
|
||||||
|
/**
|
||||||
|
* A function pointer used to continuously write a data stream obtained from
|
||||||
|
* a callback function.
|
||||||
|
*
|
||||||
|
* This function starts writing at the specified offset. To obtain the
|
||||||
|
* next bytes to write, it calls the callback function. The callback fills the
|
||||||
|
* provided data buffer and returns the number of bytes it has put into the buffer.
|
||||||
|
*
|
||||||
|
* By returning zero, the callback may stop writing.
|
||||||
|
*
|
||||||
|
* \param[in] offset Offset where to start writing.
|
||||||
|
* \param[in] buffer Pointer to a buffer which is used for the callback function.
|
||||||
|
* \param[in] length Number of bytes to write in total. May be zero for endless writes.
|
||||||
|
* \param[in] callback The function used to obtain the bytes to write.
|
||||||
|
* \param[in] p An opaque pointer directly passed to the callback function.
|
||||||
|
* \returns 0 on failure, 1 on success
|
||||||
|
* \see device_write_t
|
||||||
|
*/
|
||||||
|
typedef uint8_t (*device_write_interval_t)(offset_t offset, uint8_t* buffer, uintptr_t length, device_write_callback_t callback, void* p);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes a partition.
|
||||||
|
*/
|
||||||
|
struct partition_struct
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The function which reads data from the partition.
|
||||||
|
*
|
||||||
|
* \note The offset given to this function is relative to the whole disk,
|
||||||
|
* not to the start of the partition.
|
||||||
|
*/
|
||||||
|
device_read_t device_read;
|
||||||
|
/**
|
||||||
|
* The function which repeatedly reads a constant amount of data from the partition.
|
||||||
|
*
|
||||||
|
* \note The offset given to this function is relative to the whole disk,
|
||||||
|
* not to the start of the partition.
|
||||||
|
*/
|
||||||
|
device_read_interval_t device_read_interval;
|
||||||
|
/**
|
||||||
|
* The function which writes data to the partition.
|
||||||
|
*
|
||||||
|
* \note The offset given to this function is relative to the whole disk,
|
||||||
|
* not to the start of the partition.
|
||||||
|
*/
|
||||||
|
device_write_t device_write;
|
||||||
|
/**
|
||||||
|
* The function which repeatedly writes data to the partition.
|
||||||
|
*
|
||||||
|
* \note The offset given to this function is relative to the whole disk,
|
||||||
|
* not to the start of the partition.
|
||||||
|
*/
|
||||||
|
device_write_interval_t device_write_interval;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of the partition.
|
||||||
|
*
|
||||||
|
* Compare this value to the PARTITION_TYPE_* constants.
|
||||||
|
*/
|
||||||
|
uint8_t type;
|
||||||
|
/**
|
||||||
|
* The offset in blocks on the disk where this partition starts.
|
||||||
|
*/
|
||||||
|
uint32_t offset;
|
||||||
|
/**
|
||||||
|
* The length in blocks of this partition.
|
||||||
|
*/
|
||||||
|
uint32_t length;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct partition_struct* partition_open(device_read_t device_read, device_read_interval_t device_read_interval, device_write_t device_write, device_write_interval_t device_write_interval, int8_t index);
|
||||||
|
uint8_t partition_close(struct partition_struct* partition);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
44
final_project/sd_reader/partition_config.h
Normal file
44
final_project/sd_reader/partition_config.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2012 by Roland Riegel <feedback@roland-riegel.de>
|
||||||
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of either the GNU General Public License version 2
|
||||||
|
* or the GNU Lesser General Public License version 2.1, both as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PARTITION_CONFIG_H
|
||||||
|
#define PARTITION_CONFIG_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup partition
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* Partition configuration (license: GPLv2 or LGPLv2.1)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup partition_config
|
||||||
|
* Maximum number of partition handles.
|
||||||
|
*/
|
||||||
|
#define PARTITION_COUNT 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
89
final_project/sd_reader/periph.c
Normal file
89
final_project/sd_reader/periph.c
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
#include "main.h"
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
|
||||||
|
/** @brief intercepts incoming Serial commands
|
||||||
|
*/
|
||||||
|
ISR(USART_RX_vect) {
|
||||||
|
|
||||||
|
cli();
|
||||||
|
// Read byte into FIFO
|
||||||
|
uint8_t in_byte = UDR0;
|
||||||
|
fifo_push(in_byte);
|
||||||
|
|
||||||
|
// Flag is cleared by reading data from UDR
|
||||||
|
sei();
|
||||||
|
}
|
||||||
|
/** @brief Interrupt handler for actually playing music
|
||||||
|
*
|
||||||
|
* Will only be called if the TIFR OCF0A flag is high, using that as our play/pause flag
|
||||||
|
*
|
||||||
|
* This may be possible to hand-optimise better, but I cut it down to ~40 instructions
|
||||||
|
* which should be fine at 16MHz
|
||||||
|
*/
|
||||||
|
ISR(TIMER0_COMPA_vect) {
|
||||||
|
cli();
|
||||||
|
// Handle music playing
|
||||||
|
/* DAC0 -> DAC5 are on PC0 -> PC5
|
||||||
|
* Nothing relevent is on the rest of PORTC
|
||||||
|
*
|
||||||
|
* DAC6 -> DAC11 is PD2->PD7
|
||||||
|
*
|
||||||
|
* DAC12 and DAC13 are PB0 and PB1
|
||||||
|
*/
|
||||||
|
uint8_t in_data = song_buf[song_buf_select][song_position];
|
||||||
|
// DAC0 -> DAC5
|
||||||
|
// DAC6 -> DAC11
|
||||||
|
PORTD &= in_data & 0xFC;
|
||||||
|
PORTB &= in_data & 0x03;
|
||||||
|
|
||||||
|
// Go to next sample
|
||||||
|
song_position++;
|
||||||
|
// Can just wrap if it's 8 bit
|
||||||
|
sei();
|
||||||
|
}
|
||||||
|
|
||||||
|
void gpio_init() {
|
||||||
|
// Initialise all DAC outputs
|
||||||
|
/* DAC0 -> DAC5 are on PC0 -> PC5
|
||||||
|
* Nothing relevent is on the rest of PORTC
|
||||||
|
*
|
||||||
|
* DAC6 -> DAC11 is PD2->PD7
|
||||||
|
*
|
||||||
|
* DAC12 and DAC13 are PB0 and PB1
|
||||||
|
*/
|
||||||
|
DDRC |= 0x3F;
|
||||||
|
DDRD |= 0xFC;
|
||||||
|
DDRC |= 0x03;
|
||||||
|
}
|
||||||
|
|
||||||
|
void timer_init() {
|
||||||
|
// Compare outputs should be default, nothing
|
||||||
|
// Set to CTC, WGM = 0b010
|
||||||
|
TCCR0A = (1 << WGM01);
|
||||||
|
|
||||||
|
// Set timer to use clock input w/o prescaling
|
||||||
|
TCCR0B = 1;
|
||||||
|
|
||||||
|
// 16 MHz / 44kHz = 182 clock cycles
|
||||||
|
// Pushing it for time, may have to move to 8 bit...
|
||||||
|
OCR0A = 182;
|
||||||
|
|
||||||
|
// Don't enable the interrupt yet
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void usart_init() {
|
||||||
|
// set baudrate
|
||||||
|
UBRR0L = UBRR_VALUE & 255;
|
||||||
|
UBRR0H = UBRR_VALUE >> 8;
|
||||||
|
// Start it up
|
||||||
|
UCSR0B |= (1 << TXEN0) | (1 << RXEN0);
|
||||||
|
|
||||||
|
// Set data info, no parity, 1 stop, 8-bit
|
||||||
|
UCSR0C |= (1 << UCSZ01) | (1 << UCSZ00);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Enable interrupt
|
||||||
|
UCSR0B |= (1 << RXCIE0);
|
||||||
|
}
|
13
final_project/sd_reader/periph.h
Normal file
13
final_project/sd_reader/periph.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef PERIPH_H_
|
||||||
|
#define PERIPH_H_
|
||||||
|
|
||||||
|
#define USART_BAUDRATE 9600 //! USART baudrate, change this to set it.
|
||||||
|
#define UBRR_VALUE (((F_CPU/(USART_BAUDRATE*16UL)))-1)
|
||||||
|
|
||||||
|
// TODO comments
|
||||||
|
|
||||||
|
void gpio_init();
|
||||||
|
void timer_init();
|
||||||
|
void usart_init();
|
||||||
|
|
||||||
|
#endif
|
899
final_project/sd_reader/sd-reader.map
Normal file
899
final_project/sd_reader/sd-reader.map
Normal file
@ -0,0 +1,899 @@
|
|||||||
|
Archive member included to satisfy reference by file (symbol)
|
||||||
|
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_mulsi3.o)
|
||||||
|
fat.o (__mulsi3)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodhi4.o)
|
||||||
|
fat.o (__udivmodhi4)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodsi4.o)
|
||||||
|
fat.o (__udivmodsi4)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_exit.o)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o (exit)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_tablejump2.o)
|
||||||
|
sd_raw.o (__tablejump2__)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_copy_data.o)
|
||||||
|
fat.o (__do_copy_data)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_clear_bss.o)
|
||||||
|
partition.o (__do_clear_bss)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muluhisi3.o)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_mulsi3.o) (__muluhisi3)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3.o)
|
||||||
|
fat.o (__muldi3)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3_6.o)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3.o) (__muldi3_6)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulsidi3.o)
|
||||||
|
fat.o (__umulsidi3)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashldi3.o)
|
||||||
|
sd_raw.o (__ashldi3)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashrdi3.o)
|
||||||
|
sd_raw.o (__lshrdi3)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3.o)
|
||||||
|
sd_raw.o (__adddi3)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3_s8.o)
|
||||||
|
fat.o (__adddi3_s8)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_subdi3.o)
|
||||||
|
sd_raw.o (__subdi3)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2.o)
|
||||||
|
fat.o (__cmpdi2)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2_s8.o)
|
||||||
|
fat.o (__cmpdi2_s8)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulhisi3.o)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muluhisi3.o) (__umulhisi3)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(malloc.o)
|
||||||
|
main.o (malloc)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(memcpy.o)
|
||||||
|
main.o (memcpy)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(strchr.o)
|
||||||
|
fat.o (strchr)
|
||||||
|
/usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(strncmp.o)
|
||||||
|
fat.o (strncmp)
|
||||||
|
|
||||||
|
Allocating common symbols
|
||||||
|
Common symbol size file
|
||||||
|
|
||||||
|
cmd_state 0x1 main.o
|
||||||
|
song_buf 0x400 main.o
|
||||||
|
song_buf_select 0x1 main.o
|
||||||
|
__brkval 0x2 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(malloc.o)
|
||||||
|
song_len 0x4 main.o
|
||||||
|
ck_fmt_t 0x2a periph.o
|
||||||
|
song_read_position 0x4 main.o
|
||||||
|
song_selected 0x1 main.o
|
||||||
|
ck_master_t 0x4 periph.o
|
||||||
|
songs 0x24 main.o
|
||||||
|
song_position 0x1 main.o
|
||||||
|
__flp 0x2 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(malloc.o)
|
||||||
|
|
||||||
|
Memory Configuration
|
||||||
|
|
||||||
|
Name Origin Length Attributes
|
||||||
|
text 0x0000000000000000 0x0000000000020000 xr
|
||||||
|
data 0x0000000000800060 0x000000000000ffa0 rw !x
|
||||||
|
eeprom 0x0000000000810000 0x0000000000010000 rw !x
|
||||||
|
fuse 0x0000000000820000 0x0000000000000003 rw !x
|
||||||
|
lock 0x0000000000830000 0x0000000000000400 rw !x
|
||||||
|
signature 0x0000000000840000 0x0000000000000400 rw !x
|
||||||
|
user_signatures 0x0000000000850000 0x0000000000000400 rw !x
|
||||||
|
*default* 0x0000000000000000 0xffffffffffffffff
|
||||||
|
|
||||||
|
Linker script and memory map
|
||||||
|
|
||||||
|
Address of section .data set to 0x800100
|
||||||
|
LOAD /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o
|
||||||
|
LOAD partition.o
|
||||||
|
LOAD sd_raw.o
|
||||||
|
LOAD byteordering.o
|
||||||
|
LOAD periph.o
|
||||||
|
LOAD fat.o
|
||||||
|
LOAD main.o
|
||||||
|
LOAD fifo.o
|
||||||
|
START GROUP
|
||||||
|
LOAD /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a
|
||||||
|
LOAD /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libm.a
|
||||||
|
LOAD /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a
|
||||||
|
LOAD /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libatmega328p.a
|
||||||
|
END GROUP
|
||||||
|
0x0000000000020000 __TEXT_REGION_LENGTH__ = DEFINED (__TEXT_REGION_LENGTH__)?__TEXT_REGION_LENGTH__:0x20000
|
||||||
|
0x000000000000ffa0 __DATA_REGION_LENGTH__ = DEFINED (__DATA_REGION_LENGTH__)?__DATA_REGION_LENGTH__:0xffa0
|
||||||
|
0x0000000000010000 __EEPROM_REGION_LENGTH__ = DEFINED (__EEPROM_REGION_LENGTH__)?__EEPROM_REGION_LENGTH__:0x10000
|
||||||
|
[0x0000000000000003] __FUSE_REGION_LENGTH__ = DEFINED (__FUSE_REGION_LENGTH__)?__FUSE_REGION_LENGTH__:0x400
|
||||||
|
0x0000000000000400 __LOCK_REGION_LENGTH__ = DEFINED (__LOCK_REGION_LENGTH__)?__LOCK_REGION_LENGTH__:0x400
|
||||||
|
0x0000000000000400 __SIGNATURE_REGION_LENGTH__ = DEFINED (__SIGNATURE_REGION_LENGTH__)?__SIGNATURE_REGION_LENGTH__:0x400
|
||||||
|
0x0000000000000400 __USER_SIGNATURE_REGION_LENGTH__ = DEFINED (__USER_SIGNATURE_REGION_LENGTH__)?__USER_SIGNATURE_REGION_LENGTH__:0x400
|
||||||
|
|
||||||
|
.hash
|
||||||
|
*(.hash)
|
||||||
|
|
||||||
|
.dynsym
|
||||||
|
*(.dynsym)
|
||||||
|
|
||||||
|
.dynstr
|
||||||
|
*(.dynstr)
|
||||||
|
|
||||||
|
.gnu.version
|
||||||
|
*(.gnu.version)
|
||||||
|
|
||||||
|
.gnu.version_d
|
||||||
|
*(.gnu.version_d)
|
||||||
|
|
||||||
|
.gnu.version_r
|
||||||
|
*(.gnu.version_r)
|
||||||
|
|
||||||
|
.rel.init
|
||||||
|
*(.rel.init)
|
||||||
|
|
||||||
|
.rela.init
|
||||||
|
*(.rela.init)
|
||||||
|
|
||||||
|
.rel.text
|
||||||
|
*(.rel.text)
|
||||||
|
*(.rel.text.*)
|
||||||
|
*(.rel.gnu.linkonce.t*)
|
||||||
|
|
||||||
|
.rela.text
|
||||||
|
*(.rela.text)
|
||||||
|
*(.rela.text.*)
|
||||||
|
*(.rela.gnu.linkonce.t*)
|
||||||
|
|
||||||
|
.rel.fini
|
||||||
|
*(.rel.fini)
|
||||||
|
|
||||||
|
.rela.fini
|
||||||
|
*(.rela.fini)
|
||||||
|
|
||||||
|
.rel.rodata
|
||||||
|
*(.rel.rodata)
|
||||||
|
*(.rel.rodata.*)
|
||||||
|
*(.rel.gnu.linkonce.r*)
|
||||||
|
|
||||||
|
.rela.rodata
|
||||||
|
*(.rela.rodata)
|
||||||
|
*(.rela.rodata.*)
|
||||||
|
*(.rela.gnu.linkonce.r*)
|
||||||
|
|
||||||
|
.rel.data
|
||||||
|
*(.rel.data)
|
||||||
|
*(.rel.data.*)
|
||||||
|
*(.rel.gnu.linkonce.d*)
|
||||||
|
|
||||||
|
.rela.data
|
||||||
|
*(.rela.data)
|
||||||
|
*(.rela.data.*)
|
||||||
|
*(.rela.gnu.linkonce.d*)
|
||||||
|
|
||||||
|
.rel.ctors
|
||||||
|
*(.rel.ctors)
|
||||||
|
|
||||||
|
.rela.ctors
|
||||||
|
*(.rela.ctors)
|
||||||
|
|
||||||
|
.rel.dtors
|
||||||
|
*(.rel.dtors)
|
||||||
|
|
||||||
|
.rela.dtors
|
||||||
|
*(.rela.dtors)
|
||||||
|
|
||||||
|
.rel.got
|
||||||
|
*(.rel.got)
|
||||||
|
|
||||||
|
.rela.got
|
||||||
|
*(.rela.got)
|
||||||
|
|
||||||
|
.rel.bss
|
||||||
|
*(.rel.bss)
|
||||||
|
|
||||||
|
.rela.bss
|
||||||
|
*(.rela.bss)
|
||||||
|
|
||||||
|
.rel.plt
|
||||||
|
*(.rel.plt)
|
||||||
|
|
||||||
|
.rela.plt
|
||||||
|
*(.rela.plt)
|
||||||
|
|
||||||
|
.text 0x0000000000000000 0x3948
|
||||||
|
*(.vectors)
|
||||||
|
.vectors 0x0000000000000000 0x68 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o
|
||||||
|
0x0000000000000000 __vectors
|
||||||
|
0x0000000000000000 __vector_default
|
||||||
|
*(.vectors)
|
||||||
|
*(.progmem.gcc*)
|
||||||
|
.progmem.gcc_sw_table
|
||||||
|
0x0000000000000068 0x1e sd_raw.o
|
||||||
|
0x0000000000000086 . = ALIGN (0x2)
|
||||||
|
0x0000000000000086 __trampolines_start = .
|
||||||
|
*(.trampolines)
|
||||||
|
.trampolines 0x0000000000000086 0x0 linker stubs
|
||||||
|
*(.trampolines*)
|
||||||
|
0x0000000000000086 __trampolines_end = .
|
||||||
|
*libprintf_flt.a:*(.progmem.data)
|
||||||
|
*libc.a:*(.progmem.data)
|
||||||
|
*(.progmem*)
|
||||||
|
0x0000000000000086 . = ALIGN (0x2)
|
||||||
|
*(.jumptables)
|
||||||
|
*(.jumptables*)
|
||||||
|
*(.lowtext)
|
||||||
|
*(.lowtext*)
|
||||||
|
0x0000000000000086 __ctors_start = .
|
||||||
|
*(.ctors)
|
||||||
|
0x0000000000000086 __ctors_end = .
|
||||||
|
0x0000000000000086 __dtors_start = .
|
||||||
|
*(.dtors)
|
||||||
|
0x0000000000000086 __dtors_end = .
|
||||||
|
SORT(*)(.ctors)
|
||||||
|
SORT(*)(.dtors)
|
||||||
|
*(.init0)
|
||||||
|
.init0 0x0000000000000086 0x0 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o
|
||||||
|
0x0000000000000086 __init
|
||||||
|
*(.init0)
|
||||||
|
*(.init1)
|
||||||
|
*(.init1)
|
||||||
|
*(.init2)
|
||||||
|
.init2 0x0000000000000086 0xc /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o
|
||||||
|
*(.init2)
|
||||||
|
*(.init3)
|
||||||
|
*(.init3)
|
||||||
|
*(.init4)
|
||||||
|
.init4 0x0000000000000092 0x16 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_copy_data.o)
|
||||||
|
0x0000000000000092 __do_copy_data
|
||||||
|
.init4 0x00000000000000a8 0x10 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_clear_bss.o)
|
||||||
|
0x00000000000000a8 __do_clear_bss
|
||||||
|
*(.init4)
|
||||||
|
*(.init5)
|
||||||
|
*(.init5)
|
||||||
|
*(.init6)
|
||||||
|
*(.init6)
|
||||||
|
*(.init7)
|
||||||
|
*(.init7)
|
||||||
|
*(.init8)
|
||||||
|
*(.init8)
|
||||||
|
*(.init9)
|
||||||
|
.init9 0x00000000000000b8 0x8 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o
|
||||||
|
*(.init9)
|
||||||
|
*(.text)
|
||||||
|
.text 0x00000000000000c0 0x4 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o
|
||||||
|
0x00000000000000c0 __vector_22
|
||||||
|
0x00000000000000c0 __vector_1
|
||||||
|
0x00000000000000c0 __vector_24
|
||||||
|
0x00000000000000c0 __vector_12
|
||||||
|
0x00000000000000c0 __bad_interrupt
|
||||||
|
0x00000000000000c0 __vector_6
|
||||||
|
0x00000000000000c0 __vector_3
|
||||||
|
0x00000000000000c0 __vector_23
|
||||||
|
0x00000000000000c0 __vector_25
|
||||||
|
0x00000000000000c0 __vector_11
|
||||||
|
0x00000000000000c0 __vector_13
|
||||||
|
0x00000000000000c0 __vector_17
|
||||||
|
0x00000000000000c0 __vector_19
|
||||||
|
0x00000000000000c0 __vector_7
|
||||||
|
0x00000000000000c0 __vector_5
|
||||||
|
0x00000000000000c0 __vector_4
|
||||||
|
0x00000000000000c0 __vector_9
|
||||||
|
0x00000000000000c0 __vector_2
|
||||||
|
0x00000000000000c0 __vector_21
|
||||||
|
0x00000000000000c0 __vector_15
|
||||||
|
0x00000000000000c0 __vector_8
|
||||||
|
0x00000000000000c0 __vector_10
|
||||||
|
0x00000000000000c0 __vector_16
|
||||||
|
0x00000000000000c0 __vector_20
|
||||||
|
.text 0x00000000000000c4 0x16e partition.o
|
||||||
|
0x00000000000000c4 partition_open
|
||||||
|
0x0000000000000222 partition_close
|
||||||
|
.text 0x0000000000000232 0xb18 sd_raw.o
|
||||||
|
0x00000000000003cc sd_raw_init
|
||||||
|
0x00000000000005b6 sd_raw_available
|
||||||
|
0x00000000000005c2 sd_raw_locked
|
||||||
|
0x00000000000005d0 sd_raw_read
|
||||||
|
0x000000000000079e sd_raw_read_interval
|
||||||
|
0x0000000000000aae sd_raw_get_info
|
||||||
|
.text 0x0000000000000d4a 0x28 byteordering.o
|
||||||
|
0x0000000000000d4a read16
|
||||||
|
0x0000000000000d52 read32
|
||||||
|
0x0000000000000d5e write16
|
||||||
|
0x0000000000000d66 write32
|
||||||
|
.text 0x0000000000000d72 0x120 periph.o
|
||||||
|
0x0000000000000d72 __vector_18
|
||||||
|
0x0000000000000dc2 __vector_14
|
||||||
|
0x0000000000000e50 gpio_init
|
||||||
|
0x0000000000000e64 timer_init
|
||||||
|
0x0000000000000e72 usart_init
|
||||||
|
.text 0x0000000000000e92 0x20e8 fat.o
|
||||||
|
0x00000000000016ee fat_open
|
||||||
|
0x0000000000001bec fat_close
|
||||||
|
0x0000000000001bf8 fat_get_dir_entry_of_path
|
||||||
|
0x00000000000022ca fat_open_file
|
||||||
|
0x0000000000002346 fat_close_file
|
||||||
|
0x0000000000002352 fat_read_file
|
||||||
|
0x0000000000002730 fat_seek_file
|
||||||
|
0x00000000000027fa fat_open_dir
|
||||||
|
0x000000000000286e fat_close_dir
|
||||||
|
0x000000000000287a fat_read_dir
|
||||||
|
0x0000000000002d10 fat_reset_dir
|
||||||
|
0x0000000000002d32 fat_get_fs_size
|
||||||
|
0x0000000000002d9a fat_get_fs_free
|
||||||
|
.text 0x0000000000002f7a 0x0 main.o
|
||||||
|
.text 0x0000000000002f7a 0xbe fifo.o
|
||||||
|
0x0000000000002f7a fifo_init
|
||||||
|
0x0000000000002f8c fifo_pop
|
||||||
|
0x0000000000002fe4 fifo_push
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_mulsi3.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodhi4.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodsi4.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_exit.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_tablejump2.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_copy_data.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_clear_bss.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muluhisi3.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3_6.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulsidi3.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashldi3.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashrdi3.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3_s8.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_subdi3.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2_s8.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulhisi3.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(malloc.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(memcpy.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(strchr.o)
|
||||||
|
.text 0x0000000000003038 0x0 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(strncmp.o)
|
||||||
|
0x0000000000003038 . = ALIGN (0x2)
|
||||||
|
*(.text.*)
|
||||||
|
.text.startup 0x0000000000003038 0x3de main.o
|
||||||
|
0x0000000000003038 main
|
||||||
|
.text.libgcc.mul
|
||||||
|
0x0000000000003416 0x20 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_mulsi3.o)
|
||||||
|
0x0000000000003416 __mulsi3
|
||||||
|
.text.libgcc.div
|
||||||
|
0x0000000000003436 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_mulsi3.o)
|
||||||
|
.text.libgcc 0x0000000000003436 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_mulsi3.o)
|
||||||
|
.text.libgcc.prologue
|
||||||
|
0x0000000000003436 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_mulsi3.o)
|
||||||
|
.text.libgcc.builtins
|
||||||
|
0x0000000000003436 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_mulsi3.o)
|
||||||
|
.text.libgcc.fmul
|
||||||
|
0x0000000000003436 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_mulsi3.o)
|
||||||
|
.text.libgcc.fixed
|
||||||
|
0x0000000000003436 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_mulsi3.o)
|
||||||
|
.text.libgcc.mul
|
||||||
|
0x0000000000003436 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodhi4.o)
|
||||||
|
.text.libgcc.div
|
||||||
|
0x0000000000003436 0x28 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodhi4.o)
|
||||||
|
0x0000000000003436 __udivmodhi4
|
||||||
|
.text.libgcc 0x000000000000345e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodhi4.o)
|
||||||
|
.text.libgcc.prologue
|
||||||
|
0x000000000000345e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodhi4.o)
|
||||||
|
.text.libgcc.builtins
|
||||||
|
0x000000000000345e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodhi4.o)
|
||||||
|
.text.libgcc.fmul
|
||||||
|
0x000000000000345e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodhi4.o)
|
||||||
|
.text.libgcc.fixed
|
||||||
|
0x000000000000345e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodhi4.o)
|
||||||
|
.text.libgcc.mul
|
||||||
|
0x000000000000345e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodsi4.o)
|
||||||
|
.text.libgcc.div
|
||||||
|
0x000000000000345e 0x44 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodsi4.o)
|
||||||
|
0x000000000000345e __udivmodsi4
|
||||||
|
.text.libgcc 0x00000000000034a2 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodsi4.o)
|
||||||
|
.text.libgcc.prologue
|
||||||
|
0x00000000000034a2 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodsi4.o)
|
||||||
|
.text.libgcc.builtins
|
||||||
|
0x00000000000034a2 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodsi4.o)
|
||||||
|
.text.libgcc.fmul
|
||||||
|
0x00000000000034a2 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodsi4.o)
|
||||||
|
.text.libgcc.fixed
|
||||||
|
0x00000000000034a2 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodsi4.o)
|
||||||
|
.text.libgcc.mul
|
||||||
|
0x00000000000034a2 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_exit.o)
|
||||||
|
.text.libgcc.div
|
||||||
|
0x00000000000034a2 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_exit.o)
|
||||||
|
.text.libgcc 0x00000000000034a2 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_exit.o)
|
||||||
|
.text.libgcc.prologue
|
||||||
|
0x00000000000034a2 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_exit.o)
|
||||||
|
.text.libgcc.builtins
|
||||||
|
0x00000000000034a2 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_exit.o)
|
||||||
|
.text.libgcc.fmul
|
||||||
|
0x00000000000034a2 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_exit.o)
|
||||||
|
.text.libgcc.fixed
|
||||||
|
0x00000000000034a2 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_exit.o)
|
||||||
|
.text.libgcc.mul
|
||||||
|
0x00000000000034a2 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_tablejump2.o)
|
||||||
|
.text.libgcc.div
|
||||||
|
0x00000000000034a2 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_tablejump2.o)
|
||||||
|
.text.libgcc 0x00000000000034a2 0xc /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_tablejump2.o)
|
||||||
|
0x00000000000034a2 __tablejump2__
|
||||||
|
.text.libgcc.prologue
|
||||||
|
0x00000000000034ae 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_tablejump2.o)
|
||||||
|
.text.libgcc.builtins
|
||||||
|
0x00000000000034ae 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_tablejump2.o)
|
||||||
|
.text.libgcc.fmul
|
||||||
|
0x00000000000034ae 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_tablejump2.o)
|
||||||
|
.text.libgcc.fixed
|
||||||
|
0x00000000000034ae 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_tablejump2.o)
|
||||||
|
.text.libgcc.mul
|
||||||
|
0x00000000000034ae 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_copy_data.o)
|
||||||
|
.text.libgcc.div
|
||||||
|
0x00000000000034ae 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_copy_data.o)
|
||||||
|
.text.libgcc 0x00000000000034ae 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_copy_data.o)
|
||||||
|
.text.libgcc.prologue
|
||||||
|
0x00000000000034ae 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_copy_data.o)
|
||||||
|
.text.libgcc.builtins
|
||||||
|
0x00000000000034ae 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_copy_data.o)
|
||||||
|
.text.libgcc.fmul
|
||||||
|
0x00000000000034ae 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_copy_data.o)
|
||||||
|
.text.libgcc.fixed
|
||||||
|
0x00000000000034ae 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_copy_data.o)
|
||||||
|
.text.libgcc.mul
|
||||||
|
0x00000000000034ae 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_clear_bss.o)
|
||||||
|
.text.libgcc.div
|
||||||
|
0x00000000000034ae 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_clear_bss.o)
|
||||||
|
.text.libgcc 0x00000000000034ae 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_clear_bss.o)
|
||||||
|
.text.libgcc.prologue
|
||||||
|
0x00000000000034ae 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_clear_bss.o)
|
||||||
|
.text.libgcc.builtins
|
||||||
|
0x00000000000034ae 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_clear_bss.o)
|
||||||
|
.text.libgcc.fmul
|
||||||
|
0x00000000000034ae 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_clear_bss.o)
|
||||||
|
.text.libgcc.fixed
|
||||||
|
0x00000000000034ae 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_clear_bss.o)
|
||||||
|
.text.libgcc.mul
|
||||||
|
0x00000000000034ae 0x16 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muluhisi3.o)
|
||||||
|
0x00000000000034ae __muluhisi3
|
||||||
|
.text.libgcc.div
|
||||||
|
0x00000000000034c4 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muluhisi3.o)
|
||||||
|
.text.libgcc 0x00000000000034c4 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muluhisi3.o)
|
||||||
|
.text.libgcc.prologue
|
||||||
|
0x00000000000034c4 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muluhisi3.o)
|
||||||
|
.text.libgcc.builtins
|
||||||
|
0x00000000000034c4 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muluhisi3.o)
|
||||||
|
.text.libgcc.fmul
|
||||||
|
0x00000000000034c4 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muluhisi3.o)
|
||||||
|
.text.libgcc.fixed
|
||||||
|
0x00000000000034c4 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muluhisi3.o)
|
||||||
|
.text.libgcc.mul
|
||||||
|
0x00000000000034c4 0xa0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3.o)
|
||||||
|
0x00000000000034c4 __muldi3
|
||||||
|
.text.libgcc.div
|
||||||
|
0x0000000000003564 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3.o)
|
||||||
|
.text.libgcc 0x0000000000003564 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3.o)
|
||||||
|
.text.libgcc.prologue
|
||||||
|
0x0000000000003564 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3.o)
|
||||||
|
.text.libgcc.builtins
|
||||||
|
0x0000000000003564 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3.o)
|
||||||
|
.text.libgcc.fmul
|
||||||
|
0x0000000000003564 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3.o)
|
||||||
|
.text.libgcc.fixed
|
||||||
|
0x0000000000003564 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3.o)
|
||||||
|
.text.libgcc.mul
|
||||||
|
0x0000000000003564 0x12 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3_6.o)
|
||||||
|
0x0000000000003564 __muldi3_6
|
||||||
|
.text.libgcc.div
|
||||||
|
0x0000000000003576 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3_6.o)
|
||||||
|
.text.libgcc 0x0000000000003576 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3_6.o)
|
||||||
|
.text.libgcc.prologue
|
||||||
|
0x0000000000003576 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3_6.o)
|
||||||
|
.text.libgcc.builtins
|
||||||
|
0x0000000000003576 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3_6.o)
|
||||||
|
.text.libgcc.fmul
|
||||||
|
0x0000000000003576 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3_6.o)
|
||||||
|
.text.libgcc.fixed
|
||||||
|
0x0000000000003576 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3_6.o)
|
||||||
|
.text.libgcc.mul
|
||||||
|
0x0000000000003576 0x56 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulsidi3.o)
|
||||||
|
0x0000000000003576 __umulsidi3
|
||||||
|
0x0000000000003578 __umulsidi3_helper
|
||||||
|
.text.libgcc.div
|
||||||
|
0x00000000000035cc 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulsidi3.o)
|
||||||
|
.text.libgcc 0x00000000000035cc 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulsidi3.o)
|
||||||
|
.text.libgcc.prologue
|
||||||
|
0x00000000000035cc 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulsidi3.o)
|
||||||
|
.text.libgcc.builtins
|
||||||
|
0x00000000000035cc 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulsidi3.o)
|
||||||
|
.text.libgcc.fmul
|
||||||
|
0x00000000000035cc 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulsidi3.o)
|
||||||
|
.text.libgcc.fixed
|
||||||
|
0x00000000000035cc 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulsidi3.o)
|
||||||
|
.text.libgcc.mul
|
||||||
|
0x00000000000035cc 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashldi3.o)
|
||||||
|
.text.libgcc.div
|
||||||
|
0x00000000000035cc 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashldi3.o)
|
||||||
|
.text.libgcc 0x00000000000035cc 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashldi3.o)
|
||||||
|
.text.libgcc.prologue
|
||||||
|
0x00000000000035cc 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashldi3.o)
|
||||||
|
.text.libgcc.builtins
|
||||||
|
0x00000000000035cc 0x32 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashldi3.o)
|
||||||
|
0x00000000000035cc __ashldi3
|
||||||
|
.text.libgcc.fmul
|
||||||
|
0x00000000000035fe 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashldi3.o)
|
||||||
|
.text.libgcc.fixed
|
||||||
|
0x00000000000035fe 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashldi3.o)
|
||||||
|
.text.libgcc.mul
|
||||||
|
0x00000000000035fe 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashrdi3.o)
|
||||||
|
.text.libgcc.div
|
||||||
|
0x00000000000035fe 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashrdi3.o)
|
||||||
|
.text.libgcc 0x00000000000035fe 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashrdi3.o)
|
||||||
|
.text.libgcc.prologue
|
||||||
|
0x00000000000035fe 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashrdi3.o)
|
||||||
|
.text.libgcc.builtins
|
||||||
|
0x00000000000035fe 0x3c /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashrdi3.o)
|
||||||
|
0x00000000000035fe __ashrdi3
|
||||||
|
0x0000000000003602 __lshrdi3
|
||||||
|
.text.libgcc.fmul
|
||||||
|
0x000000000000363a 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashrdi3.o)
|
||||||
|
.text.libgcc.fixed
|
||||||
|
0x000000000000363a 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashrdi3.o)
|
||||||
|
.text.libgcc.mul
|
||||||
|
0x000000000000363a 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3.o)
|
||||||
|
.text.libgcc.div
|
||||||
|
0x000000000000363a 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3.o)
|
||||||
|
.text.libgcc 0x000000000000363a 0x12 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3.o)
|
||||||
|
0x000000000000363a __adddi3
|
||||||
|
.text.libgcc.prologue
|
||||||
|
0x000000000000364c 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3.o)
|
||||||
|
.text.libgcc.builtins
|
||||||
|
0x000000000000364c 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3.o)
|
||||||
|
.text.libgcc.fmul
|
||||||
|
0x000000000000364c 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3.o)
|
||||||
|
.text.libgcc.fixed
|
||||||
|
0x000000000000364c 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3.o)
|
||||||
|
.text.libgcc.mul
|
||||||
|
0x000000000000364c 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3_s8.o)
|
||||||
|
.text.libgcc.div
|
||||||
|
0x000000000000364c 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3_s8.o)
|
||||||
|
.text.libgcc 0x000000000000364c 0x18 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3_s8.o)
|
||||||
|
0x000000000000364c __adddi3_s8
|
||||||
|
.text.libgcc.prologue
|
||||||
|
0x0000000000003664 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3_s8.o)
|
||||||
|
.text.libgcc.builtins
|
||||||
|
0x0000000000003664 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3_s8.o)
|
||||||
|
.text.libgcc.fmul
|
||||||
|
0x0000000000003664 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3_s8.o)
|
||||||
|
.text.libgcc.fixed
|
||||||
|
0x0000000000003664 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3_s8.o)
|
||||||
|
.text.libgcc.mul
|
||||||
|
0x0000000000003664 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_subdi3.o)
|
||||||
|
.text.libgcc.div
|
||||||
|
0x0000000000003664 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_subdi3.o)
|
||||||
|
.text.libgcc 0x0000000000003664 0x12 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_subdi3.o)
|
||||||
|
0x0000000000003664 __subdi3
|
||||||
|
.text.libgcc.prologue
|
||||||
|
0x0000000000003676 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_subdi3.o)
|
||||||
|
.text.libgcc.builtins
|
||||||
|
0x0000000000003676 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_subdi3.o)
|
||||||
|
.text.libgcc.fmul
|
||||||
|
0x0000000000003676 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_subdi3.o)
|
||||||
|
.text.libgcc.fixed
|
||||||
|
0x0000000000003676 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_subdi3.o)
|
||||||
|
.text.libgcc.mul
|
||||||
|
0x0000000000003676 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2.o)
|
||||||
|
.text.libgcc.div
|
||||||
|
0x0000000000003676 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2.o)
|
||||||
|
.text.libgcc 0x0000000000003676 0x12 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2.o)
|
||||||
|
0x0000000000003676 __cmpdi2
|
||||||
|
.text.libgcc.prologue
|
||||||
|
0x0000000000003688 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2.o)
|
||||||
|
.text.libgcc.builtins
|
||||||
|
0x0000000000003688 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2.o)
|
||||||
|
.text.libgcc.fmul
|
||||||
|
0x0000000000003688 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2.o)
|
||||||
|
.text.libgcc.fixed
|
||||||
|
0x0000000000003688 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2.o)
|
||||||
|
.text.libgcc.mul
|
||||||
|
0x0000000000003688 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2_s8.o)
|
||||||
|
.text.libgcc.div
|
||||||
|
0x0000000000003688 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2_s8.o)
|
||||||
|
.text.libgcc 0x0000000000003688 0x18 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2_s8.o)
|
||||||
|
0x0000000000003688 __cmpdi2_s8
|
||||||
|
.text.libgcc.prologue
|
||||||
|
0x00000000000036a0 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2_s8.o)
|
||||||
|
.text.libgcc.builtins
|
||||||
|
0x00000000000036a0 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2_s8.o)
|
||||||
|
.text.libgcc.fmul
|
||||||
|
0x00000000000036a0 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2_s8.o)
|
||||||
|
.text.libgcc.fixed
|
||||||
|
0x00000000000036a0 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2_s8.o)
|
||||||
|
.text.libgcc.mul
|
||||||
|
0x00000000000036a0 0x1e /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulhisi3.o)
|
||||||
|
0x00000000000036a0 __umulhisi3
|
||||||
|
.text.libgcc.div
|
||||||
|
0x00000000000036be 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulhisi3.o)
|
||||||
|
.text.libgcc 0x00000000000036be 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulhisi3.o)
|
||||||
|
.text.libgcc.prologue
|
||||||
|
0x00000000000036be 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulhisi3.o)
|
||||||
|
.text.libgcc.builtins
|
||||||
|
0x00000000000036be 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulhisi3.o)
|
||||||
|
.text.libgcc.fmul
|
||||||
|
0x00000000000036be 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulhisi3.o)
|
||||||
|
.text.libgcc.fixed
|
||||||
|
0x00000000000036be 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulhisi3.o)
|
||||||
|
.text.avr-libc
|
||||||
|
0x00000000000036be 0x242 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(malloc.o)
|
||||||
|
0x00000000000036be malloc
|
||||||
|
0x00000000000037ee free
|
||||||
|
.text.avr-libc
|
||||||
|
0x0000000000003900 0x12 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(memcpy.o)
|
||||||
|
0x0000000000003900 memcpy
|
||||||
|
.text.avr-libc
|
||||||
|
0x0000000000003912 0x16 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(strchr.o)
|
||||||
|
0x0000000000003912 strchr
|
||||||
|
.text.avr-libc
|
||||||
|
0x0000000000003928 0x1c /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(strncmp.o)
|
||||||
|
0x0000000000003928 strncmp
|
||||||
|
0x0000000000003944 . = ALIGN (0x2)
|
||||||
|
*(.fini9)
|
||||||
|
.fini9 0x0000000000003944 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_exit.o)
|
||||||
|
0x0000000000003944 exit
|
||||||
|
0x0000000000003944 _exit
|
||||||
|
*(.fini9)
|
||||||
|
*(.fini8)
|
||||||
|
*(.fini8)
|
||||||
|
*(.fini7)
|
||||||
|
*(.fini7)
|
||||||
|
*(.fini6)
|
||||||
|
*(.fini6)
|
||||||
|
*(.fini5)
|
||||||
|
*(.fini5)
|
||||||
|
*(.fini4)
|
||||||
|
*(.fini4)
|
||||||
|
*(.fini3)
|
||||||
|
*(.fini3)
|
||||||
|
*(.fini2)
|
||||||
|
*(.fini2)
|
||||||
|
*(.fini1)
|
||||||
|
*(.fini1)
|
||||||
|
*(.fini0)
|
||||||
|
.fini0 0x0000000000003944 0x4 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_exit.o)
|
||||||
|
*(.fini0)
|
||||||
|
0x0000000000003948 _etext = .
|
||||||
|
|
||||||
|
.data 0x0000000000800100 0x1e load address 0x0000000000003948
|
||||||
|
0x0000000000800100 PROVIDE (__data_start, .)
|
||||||
|
*(.data)
|
||||||
|
.data 0x0000000000800100 0x0 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o
|
||||||
|
.data 0x0000000000800100 0x0 partition.o
|
||||||
|
.data 0x0000000000800100 0x0 sd_raw.o
|
||||||
|
.data 0x0000000000800100 0x0 byteordering.o
|
||||||
|
.data 0x0000000000800100 0x0 periph.o
|
||||||
|
.data 0x0000000000800100 0x0 fat.o
|
||||||
|
.data 0x0000000000800100 0x3 main.o
|
||||||
|
0x0000000000800100 song_selection
|
||||||
|
0x0000000000800101 DATA_CHUNK_ID
|
||||||
|
.data 0x0000000000800103 0x0 fifo.o
|
||||||
|
.data 0x0000000000800103 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_mulsi3.o)
|
||||||
|
.data 0x0000000000800103 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodhi4.o)
|
||||||
|
.data 0x0000000000800103 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodsi4.o)
|
||||||
|
.data 0x0000000000800103 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_exit.o)
|
||||||
|
.data 0x0000000000800103 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_tablejump2.o)
|
||||||
|
.data 0x0000000000800103 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_copy_data.o)
|
||||||
|
.data 0x0000000000800103 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_clear_bss.o)
|
||||||
|
.data 0x0000000000800103 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muluhisi3.o)
|
||||||
|
.data 0x0000000000800103 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3.o)
|
||||||
|
.data 0x0000000000800103 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3_6.o)
|
||||||
|
.data 0x0000000000800103 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulsidi3.o)
|
||||||
|
.data 0x0000000000800103 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashldi3.o)
|
||||||
|
.data 0x0000000000800103 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashrdi3.o)
|
||||||
|
.data 0x0000000000800103 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3.o)
|
||||||
|
.data 0x0000000000800103 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3_s8.o)
|
||||||
|
.data 0x0000000000800103 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_subdi3.o)
|
||||||
|
.data 0x0000000000800103 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2.o)
|
||||||
|
.data 0x0000000000800103 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2_s8.o)
|
||||||
|
.data 0x0000000000800103 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulhisi3.o)
|
||||||
|
.data 0x0000000000800103 0x6 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(malloc.o)
|
||||||
|
0x0000000000800103 __malloc_heap_end
|
||||||
|
0x0000000000800105 __malloc_heap_start
|
||||||
|
0x0000000000800107 __malloc_margin
|
||||||
|
.data 0x0000000000800109 0x0 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(memcpy.o)
|
||||||
|
.data 0x0000000000800109 0x0 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(strchr.o)
|
||||||
|
.data 0x0000000000800109 0x0 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(strncmp.o)
|
||||||
|
*(.data*)
|
||||||
|
*(.rodata)
|
||||||
|
.rodata 0x0000000000800109 0xd fat.o
|
||||||
|
*(.rodata*)
|
||||||
|
.rodata.str1.1
|
||||||
|
0x0000000000800116 0x7 main.o
|
||||||
|
*(.gnu.linkonce.d*)
|
||||||
|
0x000000000080011e . = ALIGN (0x2)
|
||||||
|
*fill* 0x000000000080011d 0x1
|
||||||
|
0x000000000080011e _edata = .
|
||||||
|
0x000000000080011e PROVIDE (__data_end, .)
|
||||||
|
|
||||||
|
.bss 0x000000000080011e 0x572
|
||||||
|
0x000000000080011e PROVIDE (__bss_start, .)
|
||||||
|
*(.bss)
|
||||||
|
.bss 0x000000000080011e 0x0 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o
|
||||||
|
.bss 0x000000000080011e 0x11 partition.o
|
||||||
|
.bss 0x000000000080012f 0x1 sd_raw.o
|
||||||
|
.bss 0x0000000000800130 0x0 byteordering.o
|
||||||
|
.bss 0x0000000000800130 0x0 periph.o
|
||||||
|
.bss 0x0000000000800130 0xe3 fat.o
|
||||||
|
.bss 0x0000000000800213 0x1 main.o
|
||||||
|
0x0000000000800213 cmd_depth
|
||||||
|
.bss 0x0000000000800214 0x1a fifo.o
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_mulsi3.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodhi4.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_udivmodsi4.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_exit.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_tablejump2.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_copy_data.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_clear_bss.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muluhisi3.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_muldi3_6.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulsidi3.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashldi3.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_ashrdi3.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_adddi3_s8.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_subdi3.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_cmpdi2_s8.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/avr5/libgcc.a(_umulhisi3.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(malloc.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(memcpy.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(strchr.o)
|
||||||
|
.bss 0x000000000080022e 0x0 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(strncmp.o)
|
||||||
|
*(.bss*)
|
||||||
|
*(COMMON)
|
||||||
|
COMMON 0x000000000080022e 0x2e periph.o
|
||||||
|
0x000000000080022e ck_fmt_t
|
||||||
|
0x0000000000800258 ck_master_t
|
||||||
|
COMMON 0x000000000080025c 0x430 main.o
|
||||||
|
0x000000000080025c cmd_state
|
||||||
|
0x000000000080025d song_buf
|
||||||
|
0x000000000080065d song_buf_select
|
||||||
|
0x000000000080065e song_len
|
||||||
|
0x0000000000800662 song_read_position
|
||||||
|
0x0000000000800666 song_selected
|
||||||
|
0x0000000000800667 songs
|
||||||
|
0x000000000080068b song_position
|
||||||
|
COMMON 0x000000000080068c 0x4 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(malloc.o)
|
||||||
|
0x000000000080068c __brkval
|
||||||
|
0x000000000080068e __flp
|
||||||
|
0x0000000000800690 PROVIDE (__bss_end, .)
|
||||||
|
0x0000000000003948 __data_load_start = LOADADDR (.data)
|
||||||
|
0x0000000000003966 __data_load_end = (__data_load_start + SIZEOF (.data))
|
||||||
|
|
||||||
|
.noinit 0x0000000000800690 0x0
|
||||||
|
[!provide] PROVIDE (__noinit_start, .)
|
||||||
|
*(.noinit*)
|
||||||
|
[!provide] PROVIDE (__noinit_end, .)
|
||||||
|
0x0000000000800690 _end = .
|
||||||
|
0x0000000000800690 PROVIDE (__heap_start, .)
|
||||||
|
|
||||||
|
.eeprom 0x0000000000810000 0x0
|
||||||
|
*(.eeprom*)
|
||||||
|
0x0000000000810000 __eeprom_end = .
|
||||||
|
|
||||||
|
.fuse
|
||||||
|
*(.fuse)
|
||||||
|
*(.lfuse)
|
||||||
|
*(.hfuse)
|
||||||
|
*(.efuse)
|
||||||
|
|
||||||
|
.lock
|
||||||
|
*(.lock*)
|
||||||
|
|
||||||
|
.signature
|
||||||
|
*(.signature*)
|
||||||
|
|
||||||
|
.user_signatures
|
||||||
|
*(.user_signatures*)
|
||||||
|
|
||||||
|
.stab 0x0000000000000000 0x5ff4
|
||||||
|
*(.stab)
|
||||||
|
.stab 0x0000000000000000 0x720 partition.o
|
||||||
|
.stab 0x0000000000000720 0x1980 sd_raw.o
|
||||||
|
0x1b30 (size before relaxing)
|
||||||
|
.stab 0x00000000000020a0 0x414 byteordering.o
|
||||||
|
0x594 (size before relaxing)
|
||||||
|
.stab 0x00000000000024b4 0x75c periph.o
|
||||||
|
0x9b4 (size before relaxing)
|
||||||
|
.stab 0x0000000000002c10 0x25f8 fat.o
|
||||||
|
0x2844 (size before relaxing)
|
||||||
|
.stab 0x0000000000005208 0x978 main.o
|
||||||
|
0xd5c (size before relaxing)
|
||||||
|
.stab 0x0000000000005b80 0x474 fifo.o
|
||||||
|
0x60c (size before relaxing)
|
||||||
|
|
||||||
|
.stabstr 0x0000000000000000 0x2c10
|
||||||
|
*(.stabstr)
|
||||||
|
.stabstr 0x0000000000000000 0x2c10 partition.o
|
||||||
|
|
||||||
|
.stab.excl
|
||||||
|
*(.stab.excl)
|
||||||
|
|
||||||
|
.stab.exclstr
|
||||||
|
*(.stab.exclstr)
|
||||||
|
|
||||||
|
.stab.index
|
||||||
|
*(.stab.index)
|
||||||
|
|
||||||
|
.stab.indexstr
|
||||||
|
*(.stab.indexstr)
|
||||||
|
|
||||||
|
.comment 0x0000000000000000 0x11
|
||||||
|
*(.comment)
|
||||||
|
.comment 0x0000000000000000 0x11 partition.o
|
||||||
|
0x12 (size before relaxing)
|
||||||
|
.comment 0x0000000000000011 0x12 sd_raw.o
|
||||||
|
.comment 0x0000000000000011 0x12 byteordering.o
|
||||||
|
.comment 0x0000000000000011 0x12 periph.o
|
||||||
|
.comment 0x0000000000000011 0x12 fat.o
|
||||||
|
.comment 0x0000000000000011 0x12 main.o
|
||||||
|
.comment 0x0000000000000011 0x12 fifo.o
|
||||||
|
.comment 0x0000000000000011 0x12 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/libc.a(malloc.o)
|
||||||
|
|
||||||
|
.note.gnu.avr.deviceinfo
|
||||||
|
0x0000000000000000 0x40
|
||||||
|
.note.gnu.avr.deviceinfo
|
||||||
|
0x0000000000000000 0x40 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o
|
||||||
|
|
||||||
|
.note.gnu.build-id
|
||||||
|
*(.note.gnu.build-id)
|
||||||
|
|
||||||
|
.debug
|
||||||
|
*(.debug)
|
||||||
|
|
||||||
|
.line
|
||||||
|
*(.line)
|
||||||
|
|
||||||
|
.debug_srcinfo
|
||||||
|
*(.debug_srcinfo)
|
||||||
|
|
||||||
|
.debug_sfnames
|
||||||
|
*(.debug_sfnames)
|
||||||
|
|
||||||
|
.debug_aranges
|
||||||
|
*(.debug_aranges)
|
||||||
|
|
||||||
|
.debug_pubnames
|
||||||
|
*(.debug_pubnames)
|
||||||
|
|
||||||
|
.debug_info 0x0000000000000000 0x5f4
|
||||||
|
*(.debug_info .gnu.linkonce.wi.*)
|
||||||
|
.debug_info 0x0000000000000000 0x5f4 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o
|
||||||
|
|
||||||
|
.debug_abbrev 0x0000000000000000 0x5a2
|
||||||
|
*(.debug_abbrev)
|
||||||
|
.debug_abbrev 0x0000000000000000 0x5a2 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o
|
||||||
|
|
||||||
|
.debug_line 0x0000000000000000 0x1a
|
||||||
|
*(.debug_line .debug_line.* .debug_line_end)
|
||||||
|
.debug_line 0x0000000000000000 0x1a /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o
|
||||||
|
|
||||||
|
.debug_frame
|
||||||
|
*(.debug_frame)
|
||||||
|
|
||||||
|
.debug_str 0x0000000000000000 0x208
|
||||||
|
*(.debug_str)
|
||||||
|
.debug_str 0x0000000000000000 0x208 /usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o
|
||||||
|
|
||||||
|
.debug_loc
|
||||||
|
*(.debug_loc)
|
||||||
|
|
||||||
|
.debug_macinfo
|
||||||
|
*(.debug_macinfo)
|
||||||
|
|
||||||
|
.debug_weaknames
|
||||||
|
*(.debug_weaknames)
|
||||||
|
|
||||||
|
.debug_funcnames
|
||||||
|
*(.debug_funcnames)
|
||||||
|
|
||||||
|
.debug_typenames
|
||||||
|
*(.debug_typenames)
|
||||||
|
|
||||||
|
.debug_varnames
|
||||||
|
*(.debug_varnames)
|
||||||
|
|
||||||
|
.debug_pubtypes
|
||||||
|
*(.debug_pubtypes)
|
||||||
|
|
||||||
|
.debug_ranges
|
||||||
|
*(.debug_ranges)
|
||||||
|
|
||||||
|
.debug_macro
|
||||||
|
*(.debug_macro)
|
||||||
|
OUTPUT(sd-reader.out elf32-avr)
|
||||||
|
LOAD linker stubs
|
BIN
final_project/sd_reader/sd-reader.out
Executable file
BIN
final_project/sd_reader/sd-reader.out
Executable file
Binary file not shown.
53
final_project/sd_reader/sd-reader_config.h
Normal file
53
final_project/sd_reader/sd-reader_config.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2012 by Roland Riegel <feedback@roland-riegel.de>
|
||||||
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of either the GNU General Public License version 2
|
||||||
|
* or the GNU Lesser General Public License version 2.1, both as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SD_READER_CONFIG_H
|
||||||
|
#define SD_READER_CONFIG_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup config Sd-reader configuration
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* Common sd-reader configuration used by all modules (license: GPLv2 or LGPLv2.1)
|
||||||
|
*
|
||||||
|
* \note This file contains only configuration items relevant to
|
||||||
|
* all sd-reader implementation files. For module specific configuration
|
||||||
|
* options, please see the files fat_config.h, partition_config.h
|
||||||
|
* and sd_raw_config.h.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controls allocation of memory.
|
||||||
|
*
|
||||||
|
* Set to 1 to use malloc()/free() for allocation of structures
|
||||||
|
* like file and directory handles, set to 0 to use pre-allocated
|
||||||
|
* fixed-size handle arrays.
|
||||||
|
*/
|
||||||
|
#define USE_DYNAMIC_MEMORY 0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
998
final_project/sd_reader/sd_raw.c
Normal file
998
final_project/sd_reader/sd_raw.c
Normal file
@ -0,0 +1,998 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2012 by Roland Riegel <feedback@roland-riegel.de>
|
||||||
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of either the GNU General Public License version 2
|
||||||
|
* or the GNU Lesser General Public License version 2.1, both as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include "sd_raw.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup sd_raw MMC/SD/SDHC card raw access
|
||||||
|
*
|
||||||
|
* This module implements read and write access to MMC, SD
|
||||||
|
* and SDHC cards. It serves as a low-level driver for the
|
||||||
|
* higher level modules such as partition and file system
|
||||||
|
* access.
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* MMC/SD/SDHC raw access implementation (license: GPLv2 or LGPLv2.1)
|
||||||
|
*
|
||||||
|
* \author Roland Riegel
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup sd_raw_config MMC/SD configuration
|
||||||
|
* Preprocessor defines to configure the MMC/SD support.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* commands available in SPI mode */
|
||||||
|
|
||||||
|
/* CMD0: response R1 */
|
||||||
|
#define CMD_GO_IDLE_STATE 0x00
|
||||||
|
/* CMD1: response R1 */
|
||||||
|
#define CMD_SEND_OP_COND 0x01
|
||||||
|
/* CMD8: response R7 */
|
||||||
|
#define CMD_SEND_IF_COND 0x08
|
||||||
|
/* CMD9: response R1 */
|
||||||
|
#define CMD_SEND_CSD 0x09
|
||||||
|
/* CMD10: response R1 */
|
||||||
|
#define CMD_SEND_CID 0x0a
|
||||||
|
/* CMD12: response R1 */
|
||||||
|
#define CMD_STOP_TRANSMISSION 0x0c
|
||||||
|
/* CMD13: response R2 */
|
||||||
|
#define CMD_SEND_STATUS 0x0d
|
||||||
|
/* CMD16: arg0[31:0]: block length, response R1 */
|
||||||
|
#define CMD_SET_BLOCKLEN 0x10
|
||||||
|
/* CMD17: arg0[31:0]: data address, response R1 */
|
||||||
|
#define CMD_READ_SINGLE_BLOCK 0x11
|
||||||
|
/* CMD18: arg0[31:0]: data address, response R1 */
|
||||||
|
#define CMD_READ_MULTIPLE_BLOCK 0x12
|
||||||
|
/* CMD24: arg0[31:0]: data address, response R1 */
|
||||||
|
#define CMD_WRITE_SINGLE_BLOCK 0x18
|
||||||
|
/* CMD25: arg0[31:0]: data address, response R1 */
|
||||||
|
#define CMD_WRITE_MULTIPLE_BLOCK 0x19
|
||||||
|
/* CMD27: response R1 */
|
||||||
|
#define CMD_PROGRAM_CSD 0x1b
|
||||||
|
/* CMD28: arg0[31:0]: data address, response R1b */
|
||||||
|
#define CMD_SET_WRITE_PROT 0x1c
|
||||||
|
/* CMD29: arg0[31:0]: data address, response R1b */
|
||||||
|
#define CMD_CLR_WRITE_PROT 0x1d
|
||||||
|
/* CMD30: arg0[31:0]: write protect data address, response R1 */
|
||||||
|
#define CMD_SEND_WRITE_PROT 0x1e
|
||||||
|
/* CMD32: arg0[31:0]: data address, response R1 */
|
||||||
|
#define CMD_TAG_SECTOR_START 0x20
|
||||||
|
/* CMD33: arg0[31:0]: data address, response R1 */
|
||||||
|
#define CMD_TAG_SECTOR_END 0x21
|
||||||
|
/* CMD34: arg0[31:0]: data address, response R1 */
|
||||||
|
#define CMD_UNTAG_SECTOR 0x22
|
||||||
|
/* CMD35: arg0[31:0]: data address, response R1 */
|
||||||
|
#define CMD_TAG_ERASE_GROUP_START 0x23
|
||||||
|
/* CMD36: arg0[31:0]: data address, response R1 */
|
||||||
|
#define CMD_TAG_ERASE_GROUP_END 0x24
|
||||||
|
/* CMD37: arg0[31:0]: data address, response R1 */
|
||||||
|
#define CMD_UNTAG_ERASE_GROUP 0x25
|
||||||
|
/* CMD38: arg0[31:0]: stuff bits, response R1b */
|
||||||
|
#define CMD_ERASE 0x26
|
||||||
|
/* ACMD41: arg0[31:0]: OCR contents, response R1 */
|
||||||
|
#define CMD_SD_SEND_OP_COND 0x29
|
||||||
|
/* CMD42: arg0[31:0]: stuff bits, response R1b */
|
||||||
|
#define CMD_LOCK_UNLOCK 0x2a
|
||||||
|
/* CMD55: arg0[31:0]: stuff bits, response R1 */
|
||||||
|
#define CMD_APP 0x37
|
||||||
|
/* CMD58: arg0[31:0]: stuff bits, response R3 */
|
||||||
|
#define CMD_READ_OCR 0x3a
|
||||||
|
/* CMD59: arg0[31:1]: stuff bits, arg0[0:0]: crc option, response R1 */
|
||||||
|
#define CMD_CRC_ON_OFF 0x3b
|
||||||
|
|
||||||
|
/* command responses */
|
||||||
|
/* R1: size 1 byte */
|
||||||
|
#define R1_IDLE_STATE 0
|
||||||
|
#define R1_ERASE_RESET 1
|
||||||
|
#define R1_ILL_COMMAND 2
|
||||||
|
#define R1_COM_CRC_ERR 3
|
||||||
|
#define R1_ERASE_SEQ_ERR 4
|
||||||
|
#define R1_ADDR_ERR 5
|
||||||
|
#define R1_PARAM_ERR 6
|
||||||
|
/* R1b: equals R1, additional busy bytes */
|
||||||
|
/* R2: size 2 bytes */
|
||||||
|
#define R2_CARD_LOCKED 0
|
||||||
|
#define R2_WP_ERASE_SKIP 1
|
||||||
|
#define R2_ERR 2
|
||||||
|
#define R2_CARD_ERR 3
|
||||||
|
#define R2_CARD_ECC_FAIL 4
|
||||||
|
#define R2_WP_VIOLATION 5
|
||||||
|
#define R2_INVAL_ERASE 6
|
||||||
|
#define R2_OUT_OF_RANGE 7
|
||||||
|
#define R2_CSD_OVERWRITE 7
|
||||||
|
#define R2_IDLE_STATE (R1_IDLE_STATE + 8)
|
||||||
|
#define R2_ERASE_RESET (R1_ERASE_RESET + 8)
|
||||||
|
#define R2_ILL_COMMAND (R1_ILL_COMMAND + 8)
|
||||||
|
#define R2_COM_CRC_ERR (R1_COM_CRC_ERR + 8)
|
||||||
|
#define R2_ERASE_SEQ_ERR (R1_ERASE_SEQ_ERR + 8)
|
||||||
|
#define R2_ADDR_ERR (R1_ADDR_ERR + 8)
|
||||||
|
#define R2_PARAM_ERR (R1_PARAM_ERR + 8)
|
||||||
|
/* R3: size 5 bytes */
|
||||||
|
#define R3_OCR_MASK (0xffffffffUL)
|
||||||
|
#define R3_IDLE_STATE (R1_IDLE_STATE + 32)
|
||||||
|
#define R3_ERASE_RESET (R1_ERASE_RESET + 32)
|
||||||
|
#define R3_ILL_COMMAND (R1_ILL_COMMAND + 32)
|
||||||
|
#define R3_COM_CRC_ERR (R1_COM_CRC_ERR + 32)
|
||||||
|
#define R3_ERASE_SEQ_ERR (R1_ERASE_SEQ_ERR + 32)
|
||||||
|
#define R3_ADDR_ERR (R1_ADDR_ERR + 32)
|
||||||
|
#define R3_PARAM_ERR (R1_PARAM_ERR + 32)
|
||||||
|
/* Data Response: size 1 byte */
|
||||||
|
#define DR_STATUS_MASK 0x0e
|
||||||
|
#define DR_STATUS_ACCEPTED 0x05
|
||||||
|
#define DR_STATUS_CRC_ERR 0x0a
|
||||||
|
#define DR_STATUS_WRITE_ERR 0x0c
|
||||||
|
|
||||||
|
/* status bits for card types */
|
||||||
|
#define SD_RAW_SPEC_1 0
|
||||||
|
#define SD_RAW_SPEC_2 1
|
||||||
|
#define SD_RAW_SPEC_SDHC 2
|
||||||
|
|
||||||
|
#if !SD_RAW_SAVE_RAM
|
||||||
|
/* static data buffer for acceleration */
|
||||||
|
static uint8_t raw_block[512];
|
||||||
|
/* offset where the data within raw_block lies on the card */
|
||||||
|
static offset_t raw_block_address;
|
||||||
|
#if SD_RAW_WRITE_BUFFERING
|
||||||
|
/* flag to remember if raw_block was written to the card */
|
||||||
|
static uint8_t raw_block_written;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* card type state */
|
||||||
|
static uint8_t sd_raw_card_type;
|
||||||
|
|
||||||
|
/* private helper functions */
|
||||||
|
static void sd_raw_send_byte(uint8_t b);
|
||||||
|
static uint8_t sd_raw_rec_byte();
|
||||||
|
static uint8_t sd_raw_send_command(uint8_t command, uint32_t arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup sd_raw
|
||||||
|
* Initializes memory card communication.
|
||||||
|
*
|
||||||
|
* \returns 0 on failure, 1 on success.
|
||||||
|
*/
|
||||||
|
uint8_t sd_raw_init()
|
||||||
|
{
|
||||||
|
/* enable inputs for reading card status */
|
||||||
|
configure_pin_available();
|
||||||
|
configure_pin_locked();
|
||||||
|
|
||||||
|
/* enable outputs for MOSI, SCK, SS, input for MISO */
|
||||||
|
configure_pin_mosi();
|
||||||
|
configure_pin_sck();
|
||||||
|
configure_pin_ss();
|
||||||
|
configure_pin_miso();
|
||||||
|
|
||||||
|
unselect_card();
|
||||||
|
|
||||||
|
/* initialize SPI with lowest frequency; max. 400kHz during identification mode of card */
|
||||||
|
SPCR = (0 << SPIE) | /* SPI Interrupt Enable */
|
||||||
|
(1 << SPE) | /* SPI Enable */
|
||||||
|
(0 << DORD) | /* Data Order: MSB first */
|
||||||
|
(1 << MSTR) | /* Master mode */
|
||||||
|
(0 << CPOL) | /* Clock Polarity: SCK low when idle */
|
||||||
|
(0 << CPHA) | /* Clock Phase: sample on rising SCK edge */
|
||||||
|
(1 << SPR1) | /* Clock Frequency: f_OSC / 128 */
|
||||||
|
(1 << SPR0);
|
||||||
|
SPSR &= ~(1 << SPI2X); /* No doubled clock frequency */
|
||||||
|
|
||||||
|
/* initialization procedure */
|
||||||
|
sd_raw_card_type = 0;
|
||||||
|
|
||||||
|
if(!sd_raw_available())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* card needs 74 cycles minimum to start up */
|
||||||
|
for(uint8_t i = 0; i < 10; ++i)
|
||||||
|
{
|
||||||
|
/* wait 8 clock cycles */
|
||||||
|
sd_raw_rec_byte();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* address card */
|
||||||
|
select_card();
|
||||||
|
|
||||||
|
/* reset card */
|
||||||
|
uint8_t response;
|
||||||
|
for(uint16_t i = 0; ; ++i)
|
||||||
|
{
|
||||||
|
response = sd_raw_send_command(CMD_GO_IDLE_STATE, 0);
|
||||||
|
if(response == (1 << R1_IDLE_STATE))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if(i == 0x1ff)
|
||||||
|
{
|
||||||
|
unselect_card();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SD_RAW_SDHC
|
||||||
|
/* check for version of SD card specification */
|
||||||
|
response = sd_raw_send_command(CMD_SEND_IF_COND, 0x100 /* 2.7V - 3.6V */ | 0xaa /* test pattern */);
|
||||||
|
if((response & (1 << R1_ILL_COMMAND)) == 0)
|
||||||
|
{
|
||||||
|
sd_raw_rec_byte();
|
||||||
|
sd_raw_rec_byte();
|
||||||
|
if((sd_raw_rec_byte() & 0x01) == 0)
|
||||||
|
return 0; /* card operation voltage range doesn't match */
|
||||||
|
if(sd_raw_rec_byte() != 0xaa)
|
||||||
|
return 0; /* wrong test pattern */
|
||||||
|
|
||||||
|
/* card conforms to SD 2 card specification */
|
||||||
|
sd_raw_card_type |= (1 << SD_RAW_SPEC_2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
/* determine SD/MMC card type */
|
||||||
|
sd_raw_send_command(CMD_APP, 0);
|
||||||
|
response = sd_raw_send_command(CMD_SD_SEND_OP_COND, 0);
|
||||||
|
if((response & (1 << R1_ILL_COMMAND)) == 0)
|
||||||
|
{
|
||||||
|
/* card conforms to SD 1 card specification */
|
||||||
|
sd_raw_card_type |= (1 << SD_RAW_SPEC_1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* MMC card */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* wait for card to get ready */
|
||||||
|
for(uint16_t i = 0; ; ++i)
|
||||||
|
{
|
||||||
|
if(sd_raw_card_type & ((1 << SD_RAW_SPEC_1) | (1 << SD_RAW_SPEC_2)))
|
||||||
|
{
|
||||||
|
uint32_t arg = 0;
|
||||||
|
#if SD_RAW_SDHC
|
||||||
|
if(sd_raw_card_type & (1 << SD_RAW_SPEC_2))
|
||||||
|
arg = 0x40000000;
|
||||||
|
#endif
|
||||||
|
sd_raw_send_command(CMD_APP, 0);
|
||||||
|
response = sd_raw_send_command(CMD_SD_SEND_OP_COND, arg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
response = sd_raw_send_command(CMD_SEND_OP_COND, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if((response & (1 << R1_IDLE_STATE)) == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if(i == 0x7fff)
|
||||||
|
{
|
||||||
|
unselect_card();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SD_RAW_SDHC
|
||||||
|
if(sd_raw_card_type & (1 << SD_RAW_SPEC_2))
|
||||||
|
{
|
||||||
|
if(sd_raw_send_command(CMD_READ_OCR, 0))
|
||||||
|
{
|
||||||
|
unselect_card();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(sd_raw_rec_byte() & 0x40)
|
||||||
|
sd_raw_card_type |= (1 << SD_RAW_SPEC_SDHC);
|
||||||
|
|
||||||
|
sd_raw_rec_byte();
|
||||||
|
sd_raw_rec_byte();
|
||||||
|
sd_raw_rec_byte();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* set block size to 512 bytes */
|
||||||
|
if(sd_raw_send_command(CMD_SET_BLOCKLEN, 512))
|
||||||
|
{
|
||||||
|
unselect_card();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* deaddress card */
|
||||||
|
unselect_card();
|
||||||
|
|
||||||
|
/* switch to highest SPI frequency possible */
|
||||||
|
SPCR &= ~((1 << SPR1) | (1 << SPR0)); /* Clock Frequency: f_OSC / 4 */
|
||||||
|
SPSR |= (1 << SPI2X); /* Doubled Clock Frequency: f_OSC / 2 */
|
||||||
|
|
||||||
|
#if !SD_RAW_SAVE_RAM
|
||||||
|
/* the first block is likely to be accessed first, so precache it here */
|
||||||
|
raw_block_address = (offset_t) -1;
|
||||||
|
#if SD_RAW_WRITE_BUFFERING
|
||||||
|
raw_block_written = 1;
|
||||||
|
#endif
|
||||||
|
if(!sd_raw_read(0, raw_block, sizeof(raw_block)))
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup sd_raw
|
||||||
|
* Checks wether a memory card is located in the slot.
|
||||||
|
*
|
||||||
|
* \returns 1 if the card is available, 0 if it is not.
|
||||||
|
*/
|
||||||
|
uint8_t sd_raw_available()
|
||||||
|
{
|
||||||
|
return get_pin_available() == 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup sd_raw
|
||||||
|
* Checks wether the memory card is locked for write access.
|
||||||
|
*
|
||||||
|
* \returns 1 if the card is locked, 0 if it is not.
|
||||||
|
*/
|
||||||
|
uint8_t sd_raw_locked()
|
||||||
|
{
|
||||||
|
return get_pin_locked() == 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup sd_raw
|
||||||
|
* Sends a raw byte to the memory card.
|
||||||
|
*
|
||||||
|
* \param[in] b The byte to sent.
|
||||||
|
* \see sd_raw_rec_byte
|
||||||
|
*/
|
||||||
|
void sd_raw_send_byte(uint8_t b)
|
||||||
|
{
|
||||||
|
SPDR = b;
|
||||||
|
/* wait for byte to be shifted out */
|
||||||
|
while(!(SPSR & (1 << SPIF)));
|
||||||
|
SPSR &= ~(1 << SPIF);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup sd_raw
|
||||||
|
* Receives a raw byte from the memory card.
|
||||||
|
*
|
||||||
|
* \returns The byte which should be read.
|
||||||
|
* \see sd_raw_send_byte
|
||||||
|
*/
|
||||||
|
uint8_t sd_raw_rec_byte()
|
||||||
|
{
|
||||||
|
/* send dummy data for receiving some */
|
||||||
|
SPDR = 0xff;
|
||||||
|
while(!(SPSR & (1 << SPIF)));
|
||||||
|
SPSR &= ~(1 << SPIF);
|
||||||
|
|
||||||
|
return SPDR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup sd_raw
|
||||||
|
* Send a command to the memory card which responses with a R1 response (and possibly others).
|
||||||
|
*
|
||||||
|
* \param[in] command The command to send.
|
||||||
|
* \param[in] arg The argument for command.
|
||||||
|
* \returns The command answer.
|
||||||
|
*/
|
||||||
|
uint8_t sd_raw_send_command(uint8_t command, uint32_t arg)
|
||||||
|
{
|
||||||
|
uint8_t response;
|
||||||
|
|
||||||
|
/* wait some clock cycles */
|
||||||
|
sd_raw_rec_byte();
|
||||||
|
|
||||||
|
/* send command via SPI */
|
||||||
|
sd_raw_send_byte(0x40 | command);
|
||||||
|
sd_raw_send_byte((arg >> 24) & 0xff);
|
||||||
|
sd_raw_send_byte((arg >> 16) & 0xff);
|
||||||
|
sd_raw_send_byte((arg >> 8) & 0xff);
|
||||||
|
sd_raw_send_byte((arg >> 0) & 0xff);
|
||||||
|
switch(command)
|
||||||
|
{
|
||||||
|
case CMD_GO_IDLE_STATE:
|
||||||
|
sd_raw_send_byte(0x95);
|
||||||
|
break;
|
||||||
|
case CMD_SEND_IF_COND:
|
||||||
|
sd_raw_send_byte(0x87);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sd_raw_send_byte(0xff);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* receive response */
|
||||||
|
for(uint8_t i = 0; i < 10; ++i)
|
||||||
|
{
|
||||||
|
response = sd_raw_rec_byte();
|
||||||
|
if(response != 0xff)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup sd_raw
|
||||||
|
* Reads raw data from the card.
|
||||||
|
*
|
||||||
|
* \param[in] offset The offset from which to read.
|
||||||
|
* \param[out] buffer The buffer into which to write the data.
|
||||||
|
* \param[in] length The number of bytes to read.
|
||||||
|
* \returns 0 on failure, 1 on success.
|
||||||
|
* \see sd_raw_read_interval, sd_raw_write, sd_raw_write_interval
|
||||||
|
*/
|
||||||
|
uint8_t sd_raw_read(offset_t offset, uint8_t* buffer, uintptr_t length)
|
||||||
|
{
|
||||||
|
offset_t block_address;
|
||||||
|
uint16_t block_offset;
|
||||||
|
uint16_t read_length;
|
||||||
|
while(length > 0)
|
||||||
|
{
|
||||||
|
/* determine byte count to read at once */
|
||||||
|
block_offset = offset & 0x01ff;
|
||||||
|
block_address = offset - block_offset;
|
||||||
|
read_length = 512 - block_offset; /* read up to block border */
|
||||||
|
if(read_length > length)
|
||||||
|
read_length = length;
|
||||||
|
|
||||||
|
#if !SD_RAW_SAVE_RAM
|
||||||
|
/* check if the requested data is cached */
|
||||||
|
if(block_address != raw_block_address)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#if SD_RAW_WRITE_BUFFERING
|
||||||
|
if(!sd_raw_sync())
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* address card */
|
||||||
|
select_card();
|
||||||
|
|
||||||
|
/* send single block request */
|
||||||
|
#if SD_RAW_SDHC
|
||||||
|
if(sd_raw_send_command(CMD_READ_SINGLE_BLOCK, (sd_raw_card_type & (1 << SD_RAW_SPEC_SDHC) ? block_address / 512 : block_address)))
|
||||||
|
#else
|
||||||
|
if(sd_raw_send_command(CMD_READ_SINGLE_BLOCK, block_address))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
unselect_card();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* wait for data block (start byte 0xfe) */
|
||||||
|
while(sd_raw_rec_byte() != 0xfe);
|
||||||
|
|
||||||
|
#if SD_RAW_SAVE_RAM
|
||||||
|
/* read byte block */
|
||||||
|
uint16_t read_to = block_offset + read_length;
|
||||||
|
for(uint16_t i = 0; i < 512; ++i)
|
||||||
|
{
|
||||||
|
uint8_t b = sd_raw_rec_byte();
|
||||||
|
if(i >= block_offset && i < read_to)
|
||||||
|
*buffer++ = b;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/* read byte block */
|
||||||
|
uint8_t* cache = raw_block;
|
||||||
|
for(uint16_t i = 0; i < 512; ++i)
|
||||||
|
*cache++ = sd_raw_rec_byte();
|
||||||
|
raw_block_address = block_address;
|
||||||
|
|
||||||
|
memcpy(buffer, raw_block + block_offset, read_length);
|
||||||
|
buffer += read_length;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* read crc16 */
|
||||||
|
sd_raw_rec_byte();
|
||||||
|
sd_raw_rec_byte();
|
||||||
|
|
||||||
|
/* deaddress card */
|
||||||
|
unselect_card();
|
||||||
|
|
||||||
|
/* let card some time to finish */
|
||||||
|
sd_raw_rec_byte();
|
||||||
|
}
|
||||||
|
#if !SD_RAW_SAVE_RAM
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* use cached data */
|
||||||
|
memcpy(buffer, raw_block + block_offset, read_length);
|
||||||
|
buffer += read_length;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
length -= read_length;
|
||||||
|
offset += read_length;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup sd_raw
|
||||||
|
* Continuously reads units of \c interval bytes and calls a callback function.
|
||||||
|
*
|
||||||
|
* This function starts reading at the specified offset. Every \c interval bytes,
|
||||||
|
* it calls the callback function with the associated data buffer.
|
||||||
|
*
|
||||||
|
* By returning zero, the callback may stop reading.
|
||||||
|
*
|
||||||
|
* \note Within the callback function, you can not start another read or
|
||||||
|
* write operation.
|
||||||
|
* \note This function only works if the following conditions are met:
|
||||||
|
* - (offset - (offset % 512)) % interval == 0
|
||||||
|
* - length % interval == 0
|
||||||
|
*
|
||||||
|
* \param[in] offset Offset from which to start reading.
|
||||||
|
* \param[in] buffer Pointer to a buffer which is at least interval bytes in size.
|
||||||
|
* \param[in] interval Number of bytes to read before calling the callback function.
|
||||||
|
* \param[in] length Number of bytes to read altogether.
|
||||||
|
* \param[in] callback The function to call every interval bytes.
|
||||||
|
* \param[in] p An opaque pointer directly passed to the callback function.
|
||||||
|
* \returns 0 on failure, 1 on success
|
||||||
|
* \see sd_raw_write_interval, sd_raw_read, sd_raw_write
|
||||||
|
*/
|
||||||
|
uint8_t sd_raw_read_interval(offset_t offset, uint8_t* buffer, uintptr_t interval, uintptr_t length, sd_raw_read_interval_handler_t callback, void* p)
|
||||||
|
{
|
||||||
|
if(!buffer || interval == 0 || length < interval || !callback)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#if !SD_RAW_SAVE_RAM
|
||||||
|
while(length >= interval)
|
||||||
|
{
|
||||||
|
/* as reading is now buffered, we directly
|
||||||
|
* hand over the request to sd_raw_read()
|
||||||
|
*/
|
||||||
|
if(!sd_raw_read(offset, buffer, interval))
|
||||||
|
return 0;
|
||||||
|
if(!callback(buffer, offset, p))
|
||||||
|
break;
|
||||||
|
offset += interval;
|
||||||
|
length -= interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
#else
|
||||||
|
/* address card */
|
||||||
|
select_card();
|
||||||
|
|
||||||
|
uint16_t block_offset;
|
||||||
|
uint16_t read_length;
|
||||||
|
uint8_t* buffer_cur;
|
||||||
|
uint8_t finished = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
/* determine byte count to read at once */
|
||||||
|
block_offset = offset & 0x01ff;
|
||||||
|
read_length = 512 - block_offset;
|
||||||
|
|
||||||
|
/* send single block request */
|
||||||
|
#if SD_RAW_SDHC
|
||||||
|
if(sd_raw_send_command(CMD_READ_SINGLE_BLOCK, (sd_raw_card_type & (1 << SD_RAW_SPEC_SDHC) ? offset / 512 : offset - block_offset)))
|
||||||
|
#else
|
||||||
|
if(sd_raw_send_command(CMD_READ_SINGLE_BLOCK, offset - block_offset))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
unselect_card();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* wait for data block (start byte 0xfe) */
|
||||||
|
while(sd_raw_rec_byte() != 0xfe);
|
||||||
|
|
||||||
|
/* read up to the data of interest */
|
||||||
|
for(uint16_t i = 0; i < block_offset; ++i)
|
||||||
|
sd_raw_rec_byte();
|
||||||
|
|
||||||
|
/* read interval bytes of data and execute the callback */
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if(read_length < interval || length < interval)
|
||||||
|
break;
|
||||||
|
|
||||||
|
buffer_cur = buffer;
|
||||||
|
for(uint16_t i = 0; i < interval; ++i)
|
||||||
|
*buffer_cur++ = sd_raw_rec_byte();
|
||||||
|
|
||||||
|
if(!callback(buffer, offset + (512 - read_length), p))
|
||||||
|
{
|
||||||
|
finished = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
read_length -= interval;
|
||||||
|
length -= interval;
|
||||||
|
|
||||||
|
} while(read_length > 0 && length > 0);
|
||||||
|
|
||||||
|
/* read rest of data block */
|
||||||
|
while(read_length-- > 0)
|
||||||
|
sd_raw_rec_byte();
|
||||||
|
|
||||||
|
/* read crc16 */
|
||||||
|
sd_raw_rec_byte();
|
||||||
|
sd_raw_rec_byte();
|
||||||
|
|
||||||
|
if(length < interval)
|
||||||
|
break;
|
||||||
|
|
||||||
|
offset = offset - block_offset + 512;
|
||||||
|
|
||||||
|
} while(!finished);
|
||||||
|
|
||||||
|
/* deaddress card */
|
||||||
|
unselect_card();
|
||||||
|
|
||||||
|
/* let card some time to finish */
|
||||||
|
sd_raw_rec_byte();
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DOXYGEN || SD_RAW_WRITE_SUPPORT
|
||||||
|
/**
|
||||||
|
* \ingroup sd_raw
|
||||||
|
* Writes raw data to the card.
|
||||||
|
*
|
||||||
|
* \note If write buffering is enabled, you might have to
|
||||||
|
* call sd_raw_sync() before disconnecting the card
|
||||||
|
* to ensure all remaining data has been written.
|
||||||
|
*
|
||||||
|
* \param[in] offset The offset where to start writing.
|
||||||
|
* \param[in] buffer The buffer containing the data to be written.
|
||||||
|
* \param[in] length The number of bytes to write.
|
||||||
|
* \returns 0 on failure, 1 on success.
|
||||||
|
* \see sd_raw_write_interval, sd_raw_read, sd_raw_read_interval
|
||||||
|
*/
|
||||||
|
uint8_t sd_raw_write(offset_t offset, const uint8_t* buffer, uintptr_t length)
|
||||||
|
{
|
||||||
|
if(sd_raw_locked())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
offset_t block_address;
|
||||||
|
uint16_t block_offset;
|
||||||
|
uint16_t write_length;
|
||||||
|
while(length > 0)
|
||||||
|
{
|
||||||
|
/* determine byte count to write at once */
|
||||||
|
block_offset = offset & 0x01ff;
|
||||||
|
block_address = offset - block_offset;
|
||||||
|
write_length = 512 - block_offset; /* write up to block border */
|
||||||
|
if(write_length > length)
|
||||||
|
write_length = length;
|
||||||
|
|
||||||
|
/* Merge the data to write with the content of the block.
|
||||||
|
* Use the cached block if available.
|
||||||
|
*/
|
||||||
|
if(block_address != raw_block_address)
|
||||||
|
{
|
||||||
|
#if SD_RAW_WRITE_BUFFERING
|
||||||
|
if(!sd_raw_sync())
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(block_offset || write_length < 512)
|
||||||
|
{
|
||||||
|
if(!sd_raw_read(block_address, raw_block, sizeof(raw_block)))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
raw_block_address = block_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(buffer != raw_block)
|
||||||
|
{
|
||||||
|
memcpy(raw_block + block_offset, buffer, write_length);
|
||||||
|
|
||||||
|
#if SD_RAW_WRITE_BUFFERING
|
||||||
|
raw_block_written = 0;
|
||||||
|
|
||||||
|
if(length == write_length)
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* address card */
|
||||||
|
select_card();
|
||||||
|
|
||||||
|
/* send single block request */
|
||||||
|
#if SD_RAW_SDHC
|
||||||
|
if(sd_raw_send_command(CMD_WRITE_SINGLE_BLOCK, (sd_raw_card_type & (1 << SD_RAW_SPEC_SDHC) ? block_address / 512 : block_address)))
|
||||||
|
#else
|
||||||
|
if(sd_raw_send_command(CMD_WRITE_SINGLE_BLOCK, block_address))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
unselect_card();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* send start byte */
|
||||||
|
sd_raw_send_byte(0xfe);
|
||||||
|
|
||||||
|
/* write byte block */
|
||||||
|
uint8_t* cache = raw_block;
|
||||||
|
for(uint16_t i = 0; i < 512; ++i)
|
||||||
|
sd_raw_send_byte(*cache++);
|
||||||
|
|
||||||
|
/* write dummy crc16 */
|
||||||
|
sd_raw_send_byte(0xff);
|
||||||
|
sd_raw_send_byte(0xff);
|
||||||
|
|
||||||
|
/* wait while card is busy */
|
||||||
|
while(sd_raw_rec_byte() != 0xff);
|
||||||
|
sd_raw_rec_byte();
|
||||||
|
|
||||||
|
/* deaddress card */
|
||||||
|
unselect_card();
|
||||||
|
|
||||||
|
buffer += write_length;
|
||||||
|
offset += write_length;
|
||||||
|
length -= write_length;
|
||||||
|
|
||||||
|
#if SD_RAW_WRITE_BUFFERING
|
||||||
|
raw_block_written = 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if DOXYGEN || SD_RAW_WRITE_SUPPORT
|
||||||
|
/**
|
||||||
|
* \ingroup sd_raw
|
||||||
|
* Writes a continuous data stream obtained from a callback function.
|
||||||
|
*
|
||||||
|
* This function starts writing at the specified offset. To obtain the
|
||||||
|
* next bytes to write, it calls the callback function. The callback fills the
|
||||||
|
* provided data buffer and returns the number of bytes it has put into the buffer.
|
||||||
|
*
|
||||||
|
* By returning zero, the callback may stop writing.
|
||||||
|
*
|
||||||
|
* \param[in] offset Offset where to start writing.
|
||||||
|
* \param[in] buffer Pointer to a buffer which is used for the callback function.
|
||||||
|
* \param[in] length Number of bytes to write in total. May be zero for endless writes.
|
||||||
|
* \param[in] callback The function used to obtain the bytes to write.
|
||||||
|
* \param[in] p An opaque pointer directly passed to the callback function.
|
||||||
|
* \returns 0 on failure, 1 on success
|
||||||
|
* \see sd_raw_read_interval, sd_raw_write, sd_raw_read
|
||||||
|
*/
|
||||||
|
uint8_t sd_raw_write_interval(offset_t offset, uint8_t* buffer, uintptr_t length, sd_raw_write_interval_handler_t callback, void* p)
|
||||||
|
{
|
||||||
|
#if SD_RAW_SAVE_RAM
|
||||||
|
#error "SD_RAW_WRITE_SUPPORT is not supported together with SD_RAW_SAVE_RAM"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(!buffer || !callback)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
uint8_t endless = (length == 0);
|
||||||
|
while(endless || length > 0)
|
||||||
|
{
|
||||||
|
uint16_t bytes_to_write = callback(buffer, offset, p);
|
||||||
|
if(!bytes_to_write)
|
||||||
|
break;
|
||||||
|
if(!endless && bytes_to_write > length)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* as writing is always buffered, we directly
|
||||||
|
* hand over the request to sd_raw_write()
|
||||||
|
*/
|
||||||
|
if(!sd_raw_write(offset, buffer, bytes_to_write))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
offset += bytes_to_write;
|
||||||
|
length -= bytes_to_write;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if DOXYGEN || SD_RAW_WRITE_SUPPORT
|
||||||
|
/**
|
||||||
|
* \ingroup sd_raw
|
||||||
|
* Writes the write buffer's content to the card.
|
||||||
|
*
|
||||||
|
* \note When write buffering is enabled, you should
|
||||||
|
* call this function before disconnecting the
|
||||||
|
* card to ensure all remaining data has been
|
||||||
|
* written.
|
||||||
|
*
|
||||||
|
* \returns 0 on failure, 1 on success.
|
||||||
|
* \see sd_raw_write
|
||||||
|
*/
|
||||||
|
uint8_t sd_raw_sync()
|
||||||
|
{
|
||||||
|
#if SD_RAW_WRITE_BUFFERING
|
||||||
|
if(raw_block_written)
|
||||||
|
return 1;
|
||||||
|
if(!sd_raw_write(raw_block_address, raw_block, sizeof(raw_block)))
|
||||||
|
return 0;
|
||||||
|
raw_block_written = 1;
|
||||||
|
#endif
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup sd_raw
|
||||||
|
* Reads informational data from the card.
|
||||||
|
*
|
||||||
|
* This function reads and returns the card's registers
|
||||||
|
* containing manufacturing and status information.
|
||||||
|
*
|
||||||
|
* \note: The information retrieved by this function is
|
||||||
|
* not required in any way to operate on the card,
|
||||||
|
* but it might be nice to display some of the data
|
||||||
|
* to the user.
|
||||||
|
*
|
||||||
|
* \param[in] info A pointer to the structure into which to save the information.
|
||||||
|
* \returns 0 on failure, 1 on success.
|
||||||
|
*/
|
||||||
|
uint8_t sd_raw_get_info(struct sd_raw_info* info)
|
||||||
|
{
|
||||||
|
if(!info || !sd_raw_available())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
memset(info, 0, sizeof(*info));
|
||||||
|
|
||||||
|
select_card();
|
||||||
|
|
||||||
|
/* read cid register */
|
||||||
|
if(sd_raw_send_command(CMD_SEND_CID, 0))
|
||||||
|
{
|
||||||
|
unselect_card();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
while(sd_raw_rec_byte() != 0xfe);
|
||||||
|
for(uint8_t i = 0; i < 18; ++i)
|
||||||
|
{
|
||||||
|
uint8_t b = sd_raw_rec_byte();
|
||||||
|
|
||||||
|
switch(i)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
info->manufacturer = b;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
info->oem[i - 1] = b;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
case 6:
|
||||||
|
case 7:
|
||||||
|
info->product[i - 3] = b;
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
info->revision = b;
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
case 10:
|
||||||
|
case 11:
|
||||||
|
case 12:
|
||||||
|
info->serial |= (uint32_t) b << ((12 - i) * 8);
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
info->manufacturing_year = b << 4;
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
info->manufacturing_year |= b >> 4;
|
||||||
|
info->manufacturing_month = b & 0x0f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read csd register */
|
||||||
|
uint8_t csd_read_bl_len = 0;
|
||||||
|
uint8_t csd_c_size_mult = 0;
|
||||||
|
#if SD_RAW_SDHC
|
||||||
|
uint16_t csd_c_size = 0;
|
||||||
|
#else
|
||||||
|
uint32_t csd_c_size = 0;
|
||||||
|
#endif
|
||||||
|
uint8_t csd_structure = 0;
|
||||||
|
if(sd_raw_send_command(CMD_SEND_CSD, 0))
|
||||||
|
{
|
||||||
|
unselect_card();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
while(sd_raw_rec_byte() != 0xfe);
|
||||||
|
for(uint8_t i = 0; i < 18; ++i)
|
||||||
|
{
|
||||||
|
uint8_t b = sd_raw_rec_byte();
|
||||||
|
|
||||||
|
if(i == 0)
|
||||||
|
{
|
||||||
|
csd_structure = b >> 6;
|
||||||
|
}
|
||||||
|
else if(i == 14)
|
||||||
|
{
|
||||||
|
if(b & 0x40)
|
||||||
|
info->flag_copy = 1;
|
||||||
|
if(b & 0x20)
|
||||||
|
info->flag_write_protect = 1;
|
||||||
|
if(b & 0x10)
|
||||||
|
info->flag_write_protect_temp = 1;
|
||||||
|
info->format = (b & 0x0c) >> 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if SD_RAW_SDHC
|
||||||
|
if(csd_structure == 0x01)
|
||||||
|
{
|
||||||
|
switch(i)
|
||||||
|
{
|
||||||
|
case 7:
|
||||||
|
b &= 0x3f;
|
||||||
|
case 8:
|
||||||
|
case 9:
|
||||||
|
csd_c_size <<= 8;
|
||||||
|
csd_c_size |= b;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(i == 9)
|
||||||
|
{
|
||||||
|
++csd_c_size;
|
||||||
|
info->capacity = (offset_t) csd_c_size * 512 * 1024;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(csd_structure == 0x00)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
switch(i)
|
||||||
|
{
|
||||||
|
case 5:
|
||||||
|
csd_read_bl_len = b & 0x0f;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
csd_c_size = b & 0x03;
|
||||||
|
csd_c_size <<= 8;
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
csd_c_size |= b;
|
||||||
|
csd_c_size <<= 2;
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
csd_c_size |= b >> 6;
|
||||||
|
++csd_c_size;
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
csd_c_size_mult = b & 0x03;
|
||||||
|
csd_c_size_mult <<= 1;
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
csd_c_size_mult |= b >> 7;
|
||||||
|
|
||||||
|
info->capacity = (uint32_t) csd_c_size << (csd_c_size_mult + csd_read_bl_len + 2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unselect_card();
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
148
final_project/sd_reader/sd_raw.h
Normal file
148
final_project/sd_reader/sd_raw.h
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2012 by Roland Riegel <feedback@roland-riegel.de>
|
||||||
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of either the GNU General Public License version 2
|
||||||
|
* or the GNU Lesser General Public License version 2.1, both as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SD_RAW_H
|
||||||
|
#define SD_RAW_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "sd_raw_config.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup sd_raw
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* MMC/SD/SDHC raw access header (license: GPLv2 or LGPLv2.1)
|
||||||
|
*
|
||||||
|
* \author Roland Riegel
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The card's layout is harddisk-like, which means it contains
|
||||||
|
* a master boot record with a partition table.
|
||||||
|
*/
|
||||||
|
#define SD_RAW_FORMAT_HARDDISK 0
|
||||||
|
/**
|
||||||
|
* The card contains a single filesystem and no partition table.
|
||||||
|
*/
|
||||||
|
#define SD_RAW_FORMAT_SUPERFLOPPY 1
|
||||||
|
/**
|
||||||
|
* The card's layout follows the Universal File Format.
|
||||||
|
*/
|
||||||
|
#define SD_RAW_FORMAT_UNIVERSAL 2
|
||||||
|
/**
|
||||||
|
* The card's layout is unknown.
|
||||||
|
*/
|
||||||
|
#define SD_RAW_FORMAT_UNKNOWN 3
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This struct is used by sd_raw_get_info() to return
|
||||||
|
* manufacturing and status information of the card.
|
||||||
|
*/
|
||||||
|
struct sd_raw_info
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A manufacturer code globally assigned by the SD card organization.
|
||||||
|
*/
|
||||||
|
uint8_t manufacturer;
|
||||||
|
/**
|
||||||
|
* A string describing the card's OEM or content, globally assigned by the SD card organization.
|
||||||
|
*/
|
||||||
|
uint8_t oem[3];
|
||||||
|
/**
|
||||||
|
* A product name.
|
||||||
|
*/
|
||||||
|
uint8_t product[6];
|
||||||
|
/**
|
||||||
|
* The card's revision, coded in packed BCD.
|
||||||
|
*
|
||||||
|
* For example, the revision value \c 0x32 means "3.2".
|
||||||
|
*/
|
||||||
|
uint8_t revision;
|
||||||
|
/**
|
||||||
|
* A serial number assigned by the manufacturer.
|
||||||
|
*/
|
||||||
|
uint32_t serial;
|
||||||
|
/**
|
||||||
|
* The year of manufacturing.
|
||||||
|
*
|
||||||
|
* A value of zero means year 2000.
|
||||||
|
*/
|
||||||
|
uint8_t manufacturing_year;
|
||||||
|
/**
|
||||||
|
* The month of manufacturing.
|
||||||
|
*/
|
||||||
|
uint8_t manufacturing_month;
|
||||||
|
/**
|
||||||
|
* The card's total capacity in bytes.
|
||||||
|
*/
|
||||||
|
offset_t capacity;
|
||||||
|
/**
|
||||||
|
* Defines wether the card's content is original or copied.
|
||||||
|
*
|
||||||
|
* A value of \c 0 means original, \c 1 means copied.
|
||||||
|
*/
|
||||||
|
uint8_t flag_copy;
|
||||||
|
/**
|
||||||
|
* Defines wether the card's content is write-protected.
|
||||||
|
*
|
||||||
|
* \note This is an internal flag and does not represent the
|
||||||
|
* state of the card's mechanical write-protect switch.
|
||||||
|
*/
|
||||||
|
uint8_t flag_write_protect;
|
||||||
|
/**
|
||||||
|
* Defines wether the card's content is temporarily write-protected.
|
||||||
|
*
|
||||||
|
* \note This is an internal flag and does not represent the
|
||||||
|
* state of the card's mechanical write-protect switch.
|
||||||
|
*/
|
||||||
|
uint8_t flag_write_protect_temp;
|
||||||
|
/**
|
||||||
|
* The card's data layout.
|
||||||
|
*
|
||||||
|
* See the \c SD_RAW_FORMAT_* constants for details.
|
||||||
|
*
|
||||||
|
* \note This value is not guaranteed to match reality.
|
||||||
|
*/
|
||||||
|
uint8_t format;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef uint8_t (*sd_raw_read_interval_handler_t)(uint8_t* buffer, offset_t offset, void* p);
|
||||||
|
typedef uintptr_t (*sd_raw_write_interval_handler_t)(uint8_t* buffer, offset_t offset, void* p);
|
||||||
|
|
||||||
|
uint8_t sd_raw_init();
|
||||||
|
uint8_t sd_raw_available();
|
||||||
|
uint8_t sd_raw_locked();
|
||||||
|
|
||||||
|
uint8_t sd_raw_read(offset_t offset, uint8_t* buffer, uintptr_t length);
|
||||||
|
uint8_t sd_raw_read_interval(offset_t offset, uint8_t* buffer, uintptr_t interval, uintptr_t length, sd_raw_read_interval_handler_t callback, void* p);
|
||||||
|
uint8_t sd_raw_write(offset_t offset, const uint8_t* buffer, uintptr_t length);
|
||||||
|
uint8_t sd_raw_write_interval(offset_t offset, uint8_t* buffer, uintptr_t length, sd_raw_write_interval_handler_t callback, void* p);
|
||||||
|
uint8_t sd_raw_sync();
|
||||||
|
|
||||||
|
uint8_t sd_raw_get_info(struct sd_raw_info* info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
139
final_project/sd_reader/sd_raw_config.h
Normal file
139
final_project/sd_reader/sd_raw_config.h
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2012 by Roland Riegel <feedback@roland-riegel.de>
|
||||||
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of either the GNU General Public License version 2
|
||||||
|
* or the GNU Lesser General Public License version 2.1, both as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SD_RAW_CONFIG_H
|
||||||
|
#define SD_RAW_CONFIG_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \addtogroup sd_raw
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* MMC/SD support configuration (license: GPLv2 or LGPLv2.1)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup sd_raw_config
|
||||||
|
* Controls MMC/SD write support.
|
||||||
|
*
|
||||||
|
* Set to 1 to enable MMC/SD write support, set to 0 to disable it.
|
||||||
|
*/
|
||||||
|
#define SD_RAW_WRITE_SUPPORT 0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup sd_raw_config
|
||||||
|
* Controls MMC/SD write buffering.
|
||||||
|
*
|
||||||
|
* Set to 1 to buffer write accesses, set to 0 to disable it.
|
||||||
|
*
|
||||||
|
* \note This option has no effect when SD_RAW_WRITE_SUPPORT is 0.
|
||||||
|
*/
|
||||||
|
#define SD_RAW_WRITE_BUFFERING 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup sd_raw_config
|
||||||
|
* Controls MMC/SD access buffering.
|
||||||
|
*
|
||||||
|
* Set to 1 to save static RAM, but be aware that you will
|
||||||
|
* lose performance.
|
||||||
|
*
|
||||||
|
* \note When SD_RAW_WRITE_SUPPORT is 1, SD_RAW_SAVE_RAM will
|
||||||
|
* be reset to 0.
|
||||||
|
*/
|
||||||
|
#define SD_RAW_SAVE_RAM 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup sd_raw_config
|
||||||
|
* Controls support for SDHC cards.
|
||||||
|
*
|
||||||
|
* Set to 1 to support so-called SDHC memory cards, i.e. SD
|
||||||
|
* cards with more than 2 gigabytes of memory.
|
||||||
|
*/
|
||||||
|
#define SD_RAW_SDHC 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* defines for customisation of sd/mmc port access */
|
||||||
|
#if defined(__AVR_ATmega8__) || \
|
||||||
|
defined(__AVR_ATmega48__) || \
|
||||||
|
defined(__AVR_ATmega48P__) || \
|
||||||
|
defined(__AVR_ATmega88__) || \
|
||||||
|
defined(__AVR_ATmega88P__) || \
|
||||||
|
defined(__AVR_ATmega168__) || \
|
||||||
|
defined(__AVR_ATmega168P__) || \
|
||||||
|
defined(__AVR_ATmega328P__)
|
||||||
|
#define configure_pin_mosi() DDRB |= (1 << DDB3)
|
||||||
|
#define configure_pin_sck() DDRB |= (1 << DDB5)
|
||||||
|
#define configure_pin_ss() DDRB |= (1 << DDB2)
|
||||||
|
#define configure_pin_miso() DDRB &= ~(1 << DDB4)
|
||||||
|
|
||||||
|
#define select_card() PORTB &= ~(1 << PORTB2)
|
||||||
|
#define unselect_card() PORTB |= (1 << PORTB2)
|
||||||
|
#elif defined(__AVR_ATmega16__) || \
|
||||||
|
defined(__AVR_ATmega32__)
|
||||||
|
#define configure_pin_mosi() DDRB |= (1 << DDB5)
|
||||||
|
#define configure_pin_sck() DDRB |= (1 << DDB7)
|
||||||
|
#define configure_pin_ss() DDRB |= (1 << DDB4)
|
||||||
|
#define configure_pin_miso() DDRB &= ~(1 << DDB6)
|
||||||
|
|
||||||
|
#define select_card() PORTB &= ~(1 << PORTB4)
|
||||||
|
#define unselect_card() PORTB |= (1 << PORTB4)
|
||||||
|
#elif defined(__AVR_ATmega64__) || \
|
||||||
|
defined(__AVR_ATmega128__) || \
|
||||||
|
defined(__AVR_ATmega169__)
|
||||||
|
#define configure_pin_mosi() DDRB |= (1 << DDB2)
|
||||||
|
#define configure_pin_sck() DDRB |= (1 << DDB1)
|
||||||
|
#define configure_pin_ss() DDRB |= (1 << DDB0)
|
||||||
|
#define configure_pin_miso() DDRB &= ~(1 << DDB3)
|
||||||
|
|
||||||
|
#define select_card() PORTB &= ~(1 << PORTB0)
|
||||||
|
#define unselect_card() PORTB |= (1 << PORTB0)
|
||||||
|
#else
|
||||||
|
#error "no sd/mmc pin mapping available!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define configure_pin_available() DDRC &= ~(1 << DDC4)
|
||||||
|
#define configure_pin_locked() DDRC &= ~(1 << DDC5)
|
||||||
|
|
||||||
|
#define get_pin_available() (PINC & (1 << PINC4))
|
||||||
|
#define get_pin_locked() (PINC & (1 << PINC5))
|
||||||
|
|
||||||
|
#if SD_RAW_SDHC
|
||||||
|
typedef uint64_t offset_t;
|
||||||
|
#else
|
||||||
|
typedef uint32_t offset_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* configuration checks */
|
||||||
|
#if SD_RAW_WRITE_SUPPORT
|
||||||
|
#undef SD_RAW_SAVE_RAM
|
||||||
|
#define SD_RAW_SAVE_RAM 0
|
||||||
|
#else
|
||||||
|
#undef SD_RAW_WRITE_BUFFERING
|
||||||
|
#define SD_RAW_WRITE_BUFFERING 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
43
final_project/sd_reader/wav.h
Normal file
43
final_project/sd_reader/wav.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/** @brief Struct to contain chunk header information
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
char ckID[4]; //! Chunk type
|
||||||
|
uint32_t cksize; //! Size of chunk in bytes
|
||||||
|
} ck_hdr_t;
|
||||||
|
|
||||||
|
/** @brief Struct to contain master WAV chunk info
|
||||||
|
*/
|
||||||
|
struct {
|
||||||
|
char WAVEID[4]; //! WAVE ID
|
||||||
|
} ck_master_t;
|
||||||
|
|
||||||
|
/** @brief Types of extension that a fmt type chunk can have
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
CK_FMT_STD = 0U,
|
||||||
|
CK_FMT_NOEXT,
|
||||||
|
CK_FMT_EXT,
|
||||||
|
} ck_fmt_ext_t;
|
||||||
|
|
||||||
|
/** @brief Struct to hold fmt chunk data
|
||||||
|
*/
|
||||||
|
struct {
|
||||||
|
struct {
|
||||||
|
uint16_t wFormatTag; //! Type of data format.
|
||||||
|
uint16_t nChannels; //! Number of channels
|
||||||
|
uint32_t nSamplesPerSec; //! Sample rate
|
||||||
|
uint32_t nAvgBytesPerSec; //! Data rate
|
||||||
|
uint16_t nBlockAlign; //! Block size in bytes for data
|
||||||
|
uint16_t wBitsPerSample; //! Bits per sample
|
||||||
|
uint16_t cbSize; //! Size of fmt type extension. Only valid if chunk size is 18 or 40.
|
||||||
|
uint16_t wValidBitsPerSample; //! Number of valid bits per sample. Only valid if chunk size is 40
|
||||||
|
uint32_t dwChannelMask; //! Speaker position mask. Only valid if chunk size is 40
|
||||||
|
uint8_t SubFormat[16]; //! GUID for data format. Only vaid if chunk size is 40
|
||||||
|
} data;
|
||||||
|
|
||||||
|
ck_fmt_ext_t type;
|
||||||
|
} ck_fmt_t;
|
18
final_project/testing/.vscode/c_cpp_properties.json
vendored
Normal file
18
final_project/testing/.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Linux",
|
||||||
|
"intelliSenseMode": "gcc-x64",
|
||||||
|
"compilerPath": "/usr/lib/ccache/avr-gcc",
|
||||||
|
"cStandard": "c99",
|
||||||
|
"cppStandard": "c++17",
|
||||||
|
"compilerArgs": [
|
||||||
|
"-Wall", "-pedantic", "-mmcu=atmega328"
|
||||||
|
],
|
||||||
|
"defines": [
|
||||||
|
"F_CPU=16000000"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
3
final_project/testing/.vscode/settings.json
vendored
Normal file
3
final_project/testing/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"C_Cpp.intelliSenseEngine": "Tag Parser"
|
||||||
|
}
|
19
final_project/testing/.vscode/tasks.json
vendored
Normal file
19
final_project/testing/.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||||
|
// for the documentation about the tasks.json format
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "make",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "make",
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
52
final_project/testing/Makefile
Normal file
52
final_project/testing/Makefile
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
|
||||||
|
NAME := sd-reader
|
||||||
|
HEX := $(NAME).hex
|
||||||
|
OUT := $(NAME).out
|
||||||
|
MAP := $(NAME).map
|
||||||
|
SOURCES := $(wildcard *.c)
|
||||||
|
HEADERS := $(wildcard *.h)
|
||||||
|
OBJECTS := $(patsubst %.c,%.o,$(SOURCES))
|
||||||
|
|
||||||
|
MCU := atmega328
|
||||||
|
MCU_AVRDUDE := m328
|
||||||
|
MCU_FREQ := 8000000UL
|
||||||
|
|
||||||
|
CC := avr-gcc
|
||||||
|
OBJCOPY := avr-objcopy
|
||||||
|
SIZE := avr-size -A
|
||||||
|
DOXYGEN := doxygen
|
||||||
|
|
||||||
|
CFLAGS := -Werror -Wall -pedantic -mmcu=$(MCU) -std=c99 -g -Os -DF_CPU=$(MCU_FREQ)
|
||||||
|
|
||||||
|
all: $(HEX)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(HEX) $(OUT) $(MAP) $(OBJECTS)
|
||||||
|
rm -rf doc/html
|
||||||
|
|
||||||
|
flash: $(HEX)
|
||||||
|
avrdude -y -c avr910 -p $(MCU_AVRDUDE) -U flash:w:$(HEX)
|
||||||
|
|
||||||
|
$(HEX): $(OUT)
|
||||||
|
$(OBJCOPY) -R .eeprom -O ihex $< $@
|
||||||
|
|
||||||
|
$(OUT): $(OBJECTS)
|
||||||
|
$(CC) $(CFLAGS) -o $@ -Wl,-Map,$(MAP) $^
|
||||||
|
@echo
|
||||||
|
@$(SIZE) $@
|
||||||
|
@echo
|
||||||
|
|
||||||
|
%.o: %.c $(HEADERS)
|
||||||
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
%.pp: %.c
|
||||||
|
$(CC) $(CFLAGS) -E -o $@ $<
|
||||||
|
|
||||||
|
%.ppo: %.c
|
||||||
|
$(CC) $(CFLAGS) -E $<
|
||||||
|
|
||||||
|
doc: $(HEADERS) $(SOURCES) Doxyfile
|
||||||
|
$(DOXYGEN) Doxyfile
|
||||||
|
|
||||||
|
.PHONY: all clean flash doc
|
||||||
|
|
97
final_project/testing/comms.h
Normal file
97
final_project/testing/comms.h
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
#ifndef COMMS_H_
|
||||||
|
#define COMMS_H_
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef __AVR_ATmega328P__
|
||||||
|
#define MEGA328
|
||||||
|
#endif
|
||||||
|
#ifdef __AVR_ATtiny2313__
|
||||||
|
#define TINY2313
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Our format goes like this:
|
||||||
|
*
|
||||||
|
* 1 byte command, with data after
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
COMMS_CMD_CLR = 0U, //! Clears LCD and all file names
|
||||||
|
COMMS_CMD_NUM, //! sends the total number of songs to choose from
|
||||||
|
COMMS_CMD_QUERY_NAME, //! Queries for the name of a given song ID
|
||||||
|
COMMS_CMD_REPLY_NAME, //! Responds with the name of the given song ID
|
||||||
|
COMMS_CMD_SELECT_FILE, //! selects a file from the given list to play, data is 1 byte for id
|
||||||
|
COMMS_CMD_PLAY, //! Starts playing file
|
||||||
|
COMMS_CMD_PAUSE //! pauses playing file
|
||||||
|
} comms_cmd_t;
|
||||||
|
|
||||||
|
/** @brief Inline function to send commands and values.
|
||||||
|
*/
|
||||||
|
inline void comms_send(comms_cmd_t cmd) {
|
||||||
|
#ifdef MEGA328
|
||||||
|
while (! (UCSR0A & (1 << TXC0)));
|
||||||
|
UDR0 = cmd;
|
||||||
|
#elif defined(TINY2313)
|
||||||
|
while (! (UCSRA) & (1 << TXC))
|
||||||
|
UDR = cmd;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Sends the number of songs to play
|
||||||
|
*/
|
||||||
|
inline void comms_send_num(uint8_t num) {
|
||||||
|
comms_send(COMMS_CMD_NUM);
|
||||||
|
comms_send(num);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Selects a file from the list on the DAC side.
|
||||||
|
*
|
||||||
|
* If another song is playing, this will stop
|
||||||
|
* that song from playing and select the new one.
|
||||||
|
*/
|
||||||
|
inline void comms_select_file(uint8_t id) {
|
||||||
|
comms_send(COMMS_CMD_SELECT_FILE);
|
||||||
|
comms_send((comms_cmd_t) id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Queries for the name of the given song ID.
|
||||||
|
*/
|
||||||
|
inline void comms_query_name(uint8_t id) {
|
||||||
|
comms_send(COMMS_CMD_QUERY_NAME);
|
||||||
|
comms_send(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Replies with name of song
|
||||||
|
*/
|
||||||
|
inline void comms_reply_name(char* name) {
|
||||||
|
comms_send(COMMS_CMD_REPLY_NAME);
|
||||||
|
|
||||||
|
uint8_t len = strlen(name);
|
||||||
|
comms_send(len);
|
||||||
|
for (uint8_t i = 0; i < len; i++) {
|
||||||
|
comms_send(name[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Clears the LCD list of files.
|
||||||
|
*/
|
||||||
|
inline void comms_clear() {
|
||||||
|
comms_send(COMMS_CMD_CLR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Starts playing song.
|
||||||
|
*/
|
||||||
|
inline void comms_play() {
|
||||||
|
comms_send(COMMS_CMD_PLAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Pauses playing song.
|
||||||
|
*/
|
||||||
|
inline void comms_pause() {
|
||||||
|
comms_send(COMMS_CMD_PLAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
42
final_project/testing/main.c
Normal file
42
final_project/testing/main.c
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#include "comms.h"
|
||||||
|
#include <util/delay.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define USART_BAUDRATE 9600 //! USART baudrate, change this to set it.
|
||||||
|
#define UBRR_VALUE (((F_CPU/(USART_BAUDRATE*16UL)))-1)
|
||||||
|
|
||||||
|
char* song_names[3] = {
|
||||||
|
"baila.wav",
|
||||||
|
"giorno.wav",
|
||||||
|
"nevergonnagiveyo"
|
||||||
|
};
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
// initialize USART
|
||||||
|
UBRR0L = UBRR_VALUE & 255;
|
||||||
|
UBRR0H = UBRR_VALUE >> 8;
|
||||||
|
UCSR0B = (1 << TXEN0) | (1 << RXEN0); // fire-up USART
|
||||||
|
UCSR0C = (1 << UCSZ01) | (1 << UCSZ00); // fire-up USART
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
// Send a clear command
|
||||||
|
comms_clear();
|
||||||
|
_delay_ms(1000);
|
||||||
|
|
||||||
|
// send a number of songs
|
||||||
|
comms_send_num(3);
|
||||||
|
|
||||||
|
// Wait for request, get song num, then send song info 3 times
|
||||||
|
for (uint8_t i = 0; i < 3; i++) {
|
||||||
|
while(! (UCSR0A & (1 << TXC0)));
|
||||||
|
uint8_t in_song = UDR0;
|
||||||
|
while(! (UCSR0A & (1 << TXC0)));
|
||||||
|
in_song = UDR0;
|
||||||
|
comms_reply_name(song_names[in_song]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// wait a while
|
||||||
|
_delay_ms(20000);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user