Subversion Repositories FlightCtrl

Rev

Rev 1241 | Rev 1448 | 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
 
1051 killagreg 7
#define USE_SPI_COMMUNICATION
827 ingob 8
 
9
//-----------------------------------------
10
#define DDR_SPI DDRB
11
#define DD_SS   PB4
12
#define DD_SCK  PB7
13
#define DD_MOSI PB5
1051 killagreg 14
#define DD_MISO PB6
827 ingob 15
 
1051 killagreg 16
// for compatibility reasons gcc3.x <-> gcc4.x
17
#ifndef SPCR
827 ingob 18
#define SPCR   SPCR0
1051 killagreg 19
#endif
20
#ifndef SPE
827 ingob 21
#define SPE   SPE0
1051 killagreg 22
#endif
23
#ifndef MSTR
827 ingob 24
#define MSTR   MSTR0
1051 killagreg 25
#endif
26
#ifndef SPR1
827 ingob 27
#define SPR1   SPR01
1051 killagreg 28
#endif
29
#ifndef SPR0
827 ingob 30
#define SPR0   SPR00
1051 killagreg 31
#endif
32
#ifndef SPIE
827 ingob 33
#define SPIE   SPIE0
1051 killagreg 34
#endif
35
#ifndef SPDR
827 ingob 36
#define SPDR   SPDR0
1051 killagreg 37
#endif
38
#ifndef SPIF
827 ingob 39
#define SPIF   SPIF0
1051 killagreg 40
#endif
41
#ifndef SPSR
827 ingob 42
#define SPSR   SPSR0
1051 killagreg 43
#endif
827 ingob 44
// -------------------------
45
 
46
#define SLAVE_SELECT_DDR_PORT   DDRC
47
#define SLAVE_SELECT_PORT       PORTC
48
#define SPI_SLAVE_SELECT        PC5
49
 
50
 
51
#define SPI_CMD_USER        10
52
#define SPI_CMD_STICK       11
1036 hbuss 53
#define SPI_CMD_MISC        12
921 hbuss 54
#define SPI_CMD_PARAMETER1  13
991 ingob 55
#define SPI_CMD_VERSION     14
1241 killagreg 56
#define SPI_CMD_SERVOS          15
991 ingob 57
 
827 ingob 58
struct str_ToNaviCtrl
59
{
1231 killagreg 60
        unsigned char Sync1, Sync2;
61
        unsigned char Command;
62
        signed int  IntegralNick;
63
        signed int  IntegralRoll;
64
        signed int  AccNick;
65
        signed int  AccRoll;
66
        signed int  GyroCompass;
67
        signed int  GyroNick;
68
        signed int  GyroRoll;
69
        signed int  GyroGier;
70
        union
71
        {
72
                char sByte[12];
73
                unsigned char Byte[12];
74
                int  Int[6];
75
                long Long[3];
76
                float Float[3];
77
        } Param;
78
        unsigned char Chksum;
1051 killagreg 79
};
827 ingob 80
 
1231 killagreg 81
#define SPI_KALMAN          103
1241 killagreg 82
 
827 ingob 83
struct str_FromNaviCtrl
84
{
1231 killagreg 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;
91
        unsigned int BeepTime;
92
        union
93
        {
94
                char sByte[12];
95
                unsigned char Byte[12];
96
                int  Int[6];
97
                long Long[3];
98
                float Float[3];
99
        } Param;
100
        unsigned char Chksum;
1051 killagreg 101
};
827 ingob 102
 
978 hbuss 103
struct str_FromNaviCtrl_Value
104
{
992 hbuss 105
 signed char Kalman_K;
106
 signed char Kalman_MaxDrift;
107
 signed char Kalman_MaxFusion;
1215 hbuss 108
 unsigned char SerialDataOkay;
1283 hbuss 109
 signed char GpsZ;
978 hbuss 110
};
827 ingob 111
 
1051 killagreg 112
struct str_SPI_VersionInfo
113
{
114
  unsigned char Major;
115
  unsigned char Minor;
116
  unsigned char Patch;
117
  unsigned char Compatible;
118
};
119
 
827 ingob 120
#ifdef USE_SPI_COMMUNICATION
121
 
978 hbuss 122
extern struct str_FromNaviCtrl_Value FromNaviCtrl_Value;
827 ingob 123
extern struct str_ToNaviCtrl   ToNaviCtrl;
124
extern struct str_FromNaviCtrl FromNaviCtrl;
1215 hbuss 125
extern unsigned char SPI_CommandCounter,NaviDataOkay;
827 ingob 126
 
127
//#define SPI_CMD_VALUE   0x03
128
 
129
extern void SPI_MasterInit(void);
130
extern void SPI_StartTransmitPacket(void);
131
extern void UpdateSPI_Buffer(void);
132
extern void SPI_TransmitByte(void);
133
#else
134
 
135
 
136
// -------------------------------- Dummy -----------------------------------------
1051 killagreg 137
#define  SPI_MasterInit() ;
827 ingob 138
#define  SPI_StartTransmitPacket() ;
139
#define  UpdateSPI_Buffer() ;
140
#define  SPI_TransmitByte() ;
141
#endif
142
 
143
 
144
#endif