Skip to content

Commit c10499b

Browse files
committed
Initial Upload
0 parents  commit c10499b

File tree

6 files changed

+850
-0
lines changed

6 files changed

+850
-0
lines changed

.gitattributes

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
*.sln merge=union
7+
*.csproj merge=union
8+
*.vbproj merge=union
9+
*.fsproj merge=union
10+
*.dbproj merge=union
11+
12+
# Standard to msysgit
13+
*.doc diff=astextplain
14+
*.DOC diff=astextplain
15+
*.docx diff=astextplain
16+
*.DOCX diff=astextplain
17+
*.dot diff=astextplain
18+
*.DOT diff=astextplain
19+
*.pdf diff=astextplain
20+
*.PDF diff=astextplain
21+
*.rtf diff=astextplain
22+
*.RTF diff=astextplain

.gitignore

+215
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
#################
2+
## Eclipse
3+
#################
4+
5+
*.pydevproject
6+
.project
7+
.metadata
8+
bin/
9+
tmp/
10+
*.tmp
11+
*.bak
12+
*.swp
13+
*~.nib
14+
local.properties
15+
.classpath
16+
.settings/
17+
.loadpath
18+
19+
# External tool builders
20+
.externalToolBuilders/
21+
22+
# Locally stored "Eclipse launch configurations"
23+
*.launch
24+
25+
# CDT-specific
26+
.cproject
27+
28+
# PDT-specific
29+
.buildpath
30+
31+
32+
#################
33+
## Visual Studio
34+
#################
35+
36+
## Ignore Visual Studio temporary files, build results, and
37+
## files generated by popular Visual Studio add-ons.
38+
39+
# User-specific files
40+
*.suo
41+
*.user
42+
*.sln.docstates
43+
44+
# Build results
45+
46+
[Dd]ebug/
47+
[Rr]elease/
48+
x64/
49+
build/
50+
[Bb]in/
51+
[Oo]bj/
52+
53+
# MSTest test Results
54+
[Tt]est[Rr]esult*/
55+
[Bb]uild[Ll]og.*
56+
57+
*_i.c
58+
*_p.c
59+
*.ilk
60+
*.meta
61+
*.obj
62+
*.pch
63+
*.pdb
64+
*.pgc
65+
*.pgd
66+
*.rsp
67+
*.sbr
68+
*.tlb
69+
*.tli
70+
*.tlh
71+
*.tmp
72+
*.tmp_proj
73+
*.log
74+
*.vspscc
75+
*.vssscc
76+
.builds
77+
*.pidb
78+
*.log
79+
*.scc
80+
81+
# Visual C++ cache files
82+
ipch/
83+
*.aps
84+
*.ncb
85+
*.opensdf
86+
*.sdf
87+
*.cachefile
88+
89+
# Visual Studio profiler
90+
*.psess
91+
*.vsp
92+
*.vspx
93+
94+
# Guidance Automation Toolkit
95+
*.gpState
96+
97+
# ReSharper is a .NET coding add-in
98+
_ReSharper*/
99+
*.[Rr]e[Ss]harper
100+
101+
# TeamCity is a build add-in
102+
_TeamCity*
103+
104+
# DotCover is a Code Coverage Tool
105+
*.dotCover
106+
107+
# NCrunch
108+
*.ncrunch*
109+
.*crunch*.local.xml
110+
111+
# Installshield output folder
112+
[Ee]xpress/
113+
114+
# DocProject is a documentation generator add-in
115+
DocProject/buildhelp/
116+
DocProject/Help/*.HxT
117+
DocProject/Help/*.HxC
118+
DocProject/Help/*.hhc
119+
DocProject/Help/*.hhk
120+
DocProject/Help/*.hhp
121+
DocProject/Help/Html2
122+
DocProject/Help/html
123+
124+
# Click-Once directory
125+
publish/
126+
127+
# Publish Web Output
128+
*.Publish.xml
129+
*.pubxml
130+
131+
# NuGet Packages Directory
132+
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
133+
#packages/
134+
135+
# Windows Azure Build Output
136+
csx
137+
*.build.csdef
138+
139+
# Windows Store app package directory
140+
AppPackages/
141+
142+
# Others
143+
sql/
144+
*.Cache
145+
ClientBin/
146+
[Ss]tyle[Cc]op.*
147+
~$*
148+
*~
149+
*.dbmdl
150+
*.[Pp]ublish.xml
151+
*.pfx
152+
*.publishsettings
153+
154+
# RIA/Silverlight projects
155+
Generated_Code/
156+
157+
# Backup & report files from converting an old project file to a newer
158+
# Visual Studio version. Backup files are not needed, because we have git ;-)
159+
_UpgradeReport_Files/
160+
Backup*/
161+
UpgradeLog*.XML
162+
UpgradeLog*.htm
163+
164+
# SQL Server files
165+
App_Data/*.mdf
166+
App_Data/*.ldf
167+
168+
#############
169+
## Windows detritus
170+
#############
171+
172+
# Windows image file caches
173+
Thumbs.db
174+
ehthumbs.db
175+
176+
# Folder config file
177+
Desktop.ini
178+
179+
# Recycle Bin used on file shares
180+
$RECYCLE.BIN/
181+
182+
# Mac crap
183+
.DS_Store
184+
185+
186+
#############
187+
## Python
188+
#############
189+
190+
*.py[co]
191+
192+
# Packages
193+
*.egg
194+
*.egg-info
195+
dist/
196+
build/
197+
eggs/
198+
parts/
199+
var/
200+
sdist/
201+
develop-eggs/
202+
.installed.cfg
203+
204+
# Installer logs
205+
pip-log.txt
206+
207+
# Unit test / coverage reports
208+
.coverage
209+
.tox
210+
211+
#Translations
212+
*.mo
213+
214+
#Mr Developer
215+
.mr.developer.cfg

Spektrum.c

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/*
2+
* Spektrum.c
3+
*
4+
* Created on: Jan 15, 2014
5+
* Author: Kevin
6+
*/
7+
8+
#include <avr/io.h>
9+
#include <avr/interrupt.h>
10+
#include <string.h>
11+
#include <util/twi.h>
12+
13+
#define MSG_LENGTH 16
14+
15+
void TWISlaveInit();
16+
17+
18+
extern uint8_t alt_buf[16];
19+
extern uint8_t cur_buf[16];
20+
extern uint8_t pwr_buf[16];
21+
extern uint8_t air_buf[16];
22+
extern uint8_t gps_buf16[16];
23+
extern uint8_t gps_buf17[16];
24+
25+
uint8_t addresses[]={0x03,0x0A,0x11,0x12,0x16,0x17,0x00};
26+
uint8_t initializing=1;
27+
uint8_t addrIdx=0;
28+
uint8_t twi_buf[17];
29+
volatile uint8_t twi_buf_ptr=0;
30+
volatile uint8_t addrCount=0;
31+
32+
void TWISlaveInit()
33+
{
34+
TWAR=addresses[0]<<1;
35+
36+
TWSR=0;
37+
TWBR=0;
38+
39+
TWCR=(1<<TWEN)|(1<<TWEA)|(1<<TWIE);
40+
41+
42+
for(int n=0;n<16;n++)
43+
twi_buf[n]=alt_buf[n];
44+
sei();
45+
46+
47+
}
48+
49+
ISR(TWI_vect)
50+
{
51+
52+
uint8_t dummy;
53+
switch (TW_STATUS)
54+
{
55+
case TW_SR_SLA_ACK:
56+
dummy=TWDR;
57+
TWCR |= (1<<TWINT);
58+
break;
59+
case TW_ST_SLA_ACK:
60+
if(initializing)
61+
{
62+
addrCount++;
63+
if(addrCount==2)
64+
{
65+
addrCount=0;
66+
if(addresses[++addrIdx]==0)
67+
{
68+
TWAR=addresses[0]<<1;
69+
initializing=0;
70+
}
71+
else
72+
TWAR=addresses[addrIdx]<<1;
73+
}
74+
}
75+
else
76+
TWAMR=0xFF;
77+
78+
uint8_t funct=TWDR>>1;
79+
switch(funct)
80+
{
81+
case 0x03:
82+
memcpy(twi_buf,cur_buf,16);
83+
break;
84+
case 0x0A:
85+
memcpy(twi_buf,pwr_buf,16);
86+
break;
87+
case 0x11:
88+
memcpy(twi_buf,air_buf,16);
89+
break;
90+
case 0x12:
91+
memcpy(twi_buf,alt_buf,16);
92+
break;
93+
case 0x16:
94+
memcpy(twi_buf,gps_buf16,16);
95+
break;
96+
case 0x17:
97+
memcpy(twi_buf,gps_buf17,16);
98+
break;
99+
default:
100+
for (int n=0;n<16;n++)
101+
twi_buf[n]=0;
102+
break;
103+
}
104+
case TW_ST_DATA_ACK:
105+
TWDR=twi_buf[twi_buf_ptr++];
106+
if(twi_buf_ptr==MSG_LENGTH)
107+
{
108+
twi_buf_ptr=0;
109+
TWCR = (1<<TWINT) | (1<<TWEN) | (0<<TWEA) | (1<<TWIE);
110+
}
111+
else
112+
{
113+
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWEA) | (1<<TWIE);
114+
}
115+
break;
116+
case TW_ST_LAST_DATA:
117+
case TW_ST_DATA_NACK:
118+
TWCR=(1<<TWEN)|(1<<TWEA)|(1<<TWINT)| (1<<TWIE);
119+
break;
120+
default:
121+
TWCR|=(1<<TWINT);
122+
123+
break;
124+
}
125+
126+
sei();
127+
128+
}

0 commit comments

Comments
 (0)