Subversion Repositories FlightCtrl

Rev

Rev 1036 | Rev 1083 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1036 Rev 1051
Line 2... Line 2...
2
#ifndef _SPI_H
2
#ifndef _SPI_H
3
#define _SPI_H
3
#define _SPI_H
Line 4... Line 4...
4
 
4
 
Line 5... Line 5...
5
#include <util/delay.h>
5
#include <util/delay.h>
Line 6... Line 6...
6
 
6
 
Line 7... Line 7...
7
#define USE_SPI_COMMUNICATION 
7
#define USE_SPI_COMMUNICATION
8
 
8
 
9
#define SPI_PROTOCOL_COMP   1
9
#define SPI_PROTOCOL_COMP   1
10
 
10
 
11
//-----------------------------------------
11
//-----------------------------------------
12
#define DDR_SPI DDRB
12
#define DDR_SPI DDRB
Line 13... Line 13...
13
#define DD_SS   PB4
13
#define DD_SS   PB4
14
#define DD_SCK  PB7
14
#define DD_SCK  PB7
15
#define DD_MOSI PB5
15
#define DD_MOSI PB5
16
#define DD_MISO PB6 
16
#define DD_MISO PB6
17
 
17
 
18
// for compatibility reasons gcc3.x <-> gcc4.x 
18
// for compatibility reasons gcc3.x <-> gcc4.x
19
#ifndef SPCR  
19
#ifndef SPCR
20
#define SPCR   SPCR0
20
#define SPCR   SPCR0
21
#endif    
21
#endif
22
#ifndef SPE  
22
#ifndef SPE
23
#define SPE   SPE0
23
#define SPE   SPE0
24
#endif    
24
#endif
25
#ifndef MSTR  
25
#ifndef MSTR
26
#define MSTR   MSTR0
26
#define MSTR   MSTR0
27
#endif    
27
#endif
28
#ifndef SPR1  
28
#ifndef SPR1
29
#define SPR1   SPR01
29
#define SPR1   SPR01
30
#endif    
30
#endif
31
#ifndef SPR0  
31
#ifndef SPR0
32
#define SPR0   SPR00
32
#define SPR0   SPR00
33
#endif    
33
#endif
34
#ifndef SPIE  
34
#ifndef SPIE
35
#define SPIE   SPIE0
35
#define SPIE   SPIE0
36
#endif    
36
#endif
37
#ifndef SPDR  
37
#ifndef SPDR
38
#define SPDR   SPDR0
38
#define SPDR   SPDR0
39
#endif    
39
#endif
40
#ifndef SPIF  
40
#ifndef SPIF
41
#define SPIF   SPIF0
41
#define SPIF   SPIF0
Line 42... Line 42...
42
#endif    
42
#endif
43
#ifndef SPSR  
43
#ifndef SPSR
44
#define SPSR   SPSR0
44
#define SPSR   SPSR0
Line 66... Line 66...
66
 signed int  AccRoll;
66
 signed int  AccRoll;
67
 signed int  GyroCompass;
67
 signed int  GyroCompass;
68
 signed int  GyroNick;
68
 signed int  GyroNick;
69
 signed int  GyroRoll;
69
 signed int  GyroRoll;
70
 signed int  GyroGier;
70
 signed int  GyroGier;
71
 union  
71
 union
72
 { char Byte[12];
72
 { char Byte[12];
73
   int  Int[6];
73
   int  Int[6];
74
   long Long[3];
74
   long Long[3];
75
   float Float[3];
75
   float Float[3];
76
 } Param;
76
 } Param;
77
 unsigned char Chksum;
77
 unsigned char Chksum;
78
};
78
};
Line 79... Line 79...
79
 
79
 
80
#define SPI_CMD_OSD_DATA         100
80
#define SPI_CMD_OSD_DATA         100
81
#define SPI_CMD_GPS_POS          101
81
#define SPI_CMD_GPS_POS          101
82
#define SPI_CMD_GPS_TARGET   102
82
#define SPI_CMD_GPS_TARGET   102
Line 89... Line 89...
89
  signed int  GPS_Roll;
89
  signed int  GPS_Roll;
90
  signed int  GPS_Gier;
90
  signed int  GPS_Gier;
91
  signed int  CompassValue;
91
  signed int  CompassValue;
92
  signed int  Status;
92
  signed int  Status;
93
  unsigned int BeepTime;
93
  unsigned int BeepTime;
94
  union  
94
  union
95
  { char Byte[12];
95
  { char Byte[12];
96
    int  Int[6];
96
    int  Int[6];
97
    long Long[3];
97
    long Long[3];
98
    float Float[3];
98
    float Float[3];
99
  } Param;
99
  } Param;
100
  unsigned char Chksum;
100
  unsigned char Chksum;
101
};
101
};
Line 102... Line 102...
102
 
102
 
103
struct str_FromNaviCtrl_Value
103
struct str_FromNaviCtrl_Value
104
{
104
{
105
 signed int OsdBar;
105
 signed int OsdBar;
106
 signed int Distance;
106
 signed int Distance;
107
 signed char Kalman_K;
107
 signed char Kalman_K;
108
 signed char Kalman_MaxDrift;
108
 signed char Kalman_MaxDrift;
109
 signed char Kalman_MaxFusion;
109
 signed char Kalman_MaxFusion;
Line -... Line 110...
-
 
110
};
-
 
111
 
-
 
112
struct str_SPI_VersionInfo
-
 
113
{
-
 
114
  unsigned char Major;
-
 
115
  unsigned char Minor;
-
 
116
  unsigned char Patch;
-
 
117
  unsigned char Compatible;
110
};
118
};
Line 111... Line 119...
111
 
119
 
112
#ifdef USE_SPI_COMMUNICATION
120
#ifdef USE_SPI_COMMUNICATION
113
 
121
 
Line 124... Line 132...
124
extern void SPI_TransmitByte(void);
132
extern void SPI_TransmitByte(void);
125
#else
133
#else
Line 126... Line 134...
126
 
134
 
127
 
135
 
128
// -------------------------------- Dummy -----------------------------------------
136
// -------------------------------- Dummy -----------------------------------------
129
#define  SPI_MasterInit() ; 
137
#define  SPI_MasterInit() ;
130
#define  SPI_StartTransmitPacket() ;
138
#define  SPI_StartTransmitPacket() ;
131
#define  UpdateSPI_Buffer() ;
139
#define  UpdateSPI_Buffer() ;