Subversion Repositories FlightCtrl

Rev

Rev 989 | Rev 992 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
827 ingob 1
// ######################## SPI - FlightCtrl ###################
2
#ifndef _SPI_H
3
#define _SPI_H
4
 
5
#include <util/delay.h>
6
 
7
#define USE_SPI_COMMUNICATION 
8
 
9
#define SPI_PROTOCOL_COMP   1
10
 
11
//-----------------------------------------
12
#define DDR_SPI DDRB
13
#define DD_SS   PB4
14
#define DD_SCK  PB7
15
#define DD_MOSI PB5
16
#define DD_MISO PB6 
17
 
18
// for compatibility reasons gcc3.x <-> gcc4.x 
19
#ifndef SPCR  
20
#define SPCR   SPCR0
21
#endif    
22
#ifndef SPE  
23
#define SPE   SPE0
24
#endif    
25
#ifndef MSTR  
26
#define MSTR   MSTR0
27
#endif    
28
#ifndef SPR1  
29
#define SPR1   SPR01
30
#endif    
31
#ifndef SPR0  
32
#define SPR0   SPR00
33
#endif    
34
#ifndef SPIE  
35
#define SPIE   SPIE0
36
#endif    
37
#ifndef SPDR  
38
#define SPDR   SPDR0
39
#endif    
40
#ifndef SPIF  
41
#define SPIF   SPIF0
42
#endif    
43
#ifndef SPSR  
44
#define SPSR   SPSR0
45
#endif    
46
// -------------------------
47
 
48
#define SLAVE_SELECT_DDR_PORT   DDRC
49
#define SLAVE_SELECT_PORT       PORTC
50
#define SPI_SLAVE_SELECT        PC5
51
 
52
 
53
#define SPI_CMD_USER        10
54
#define SPI_CMD_STICK       11
55
#define SPI_CMD_CAL_COMPASS 12
921 hbuss 56
#define SPI_CMD_PARAMETER1  13
991 ingob 57
#define SPI_CMD_VERSION     14
58
 
827 ingob 59
struct str_ToNaviCtrl
60
{
61
 unsigned char Sync1, Sync2;
62
 unsigned char Command;
63
 signed int  IntegralNick;
64
 signed int  IntegralRoll;
65
 signed int  AccNick;
66
 signed int  AccRoll;
67
 signed int  GyroCompass;
68
 signed int  GyroNick;
69
 signed int  GyroRoll;
70
 signed int  GyroGier;
71
 union  
72
 { char Byte[12];
73
   int  Int[6];
74
   long Long[3];
75
   float Float[3];
76
 } Param;
77
 unsigned char Chksum;
78
};
79
 
80
#define SPI_CMD_OSD_DATA         100
81
#define SPI_CMD_GPS_POS          101
82
#define SPI_CMD_GPS_TARGET   102 
83
struct str_FromNaviCtrl
84
{
85
 unsigned char Command;
86
  signed int  GPS_Nick;
87
  signed int  GPS_Roll;
88
  signed int  GPS_Gier;
89
  signed int  CompassValue;
90
  signed int  Status;
989 hbuss 91
  unsigned int BeepTime;
827 ingob 92
  union  
93
  { char Byte[12];
94
    int  Int[6];
95
    long Long[3];
96
    float Float[3];
97
  } Param;
98
  unsigned char Chksum;
99
};
100
 
978 hbuss 101
struct str_FromNaviCtrl_Value
102
{
103
 signed int OsdBar;
104
 signed int Distance;
105
};
827 ingob 106
 
107
#ifdef USE_SPI_COMMUNICATION
108
 
978 hbuss 109
extern struct str_FromNaviCtrl_Value FromNaviCtrl_Value;
827 ingob 110
extern struct str_ToNaviCtrl   ToNaviCtrl;
111
extern struct str_FromNaviCtrl FromNaviCtrl;
921 hbuss 112
extern unsigned char SPI_CommandCounter;
827 ingob 113
 
114
//#define SPI_CMD_VALUE   0x03
115
 
116
extern void SPI_MasterInit(void);
117
extern void SPI_StartTransmitPacket(void);
118
extern void UpdateSPI_Buffer(void);
119
extern void SPI_TransmitByte(void);
120
#else
121
 
122
 
123
// -------------------------------- Dummy -----------------------------------------
124
#define  SPI_MasterInit() ; 
125
#define  SPI_StartTransmitPacket() ;
126
#define  UpdateSPI_Buffer() ;
127
#define  SPI_TransmitByte() ;
128
#endif
129
 
130
 
131
#endif