Subversion Repositories NaviCtrl

Rev

Rev 1 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 ingob 1
#ifndef _SPI_H
2
#define _SPI_H
3
 
4
#define SPI_PROTOCOL_COMP   1
5
 
6
 
7
#define SS_PIN GPIO_ReadBit(GPIO2, GPIO_Pin_7)
8
 
9
// IMPORTANT: no syncbytes in structure !
10
#define SPI_CMD_USER             10
11
#define SPI_CMD_STICK            11
12
#define SPI_CMD_CAL_COMPASS  12
13
 
14
struct str_FromFlightCtrl
15
 {
16
         u8   Command;
17
         s16  IntegralNick;
18
         s16  IntegralRoll;
19
         s16  AccNick;
20
         s16  AccRoll;
21
         s16  GyroCompass;
22
         s16  GyroNick;
23
         s16  GyroRoll;
24
         s16  GyroGier;          
25
         union  
26
         { u8  Byte[12];
27
           s8 sByte[12];
28
           s16  Int[6];
29
           float Float[3];
30
           int Long[3];
31
         } Param;
32
         u8 Chksum;
33
 } __attribute__((packed));
34
 
35
#define SPI_CMD_OSD_DATA         100
36
#define SPI_CMD_GPS_POS          101
37
#define SPI_CMD_GPS_TARGET   102
38
 
39
struct str_ToFlightCtrl
40
 {
41
  unsigned char Sync1, Sync2;
42
  unsigned char Command;
43
  s16 GPS_Nick;
44
  s16 GPS_Roll;
45
  s16 GPS_Gier;
46
  s16 CompassValue;
47
  s16 Status;
48
  unsigned char BeepTime;
49
         union  
50
         { u8 Byte[12];
51
           s16  Int[6];
52
           float Float[3];
53
           int Long[3];
54
         } Param;
55
  unsigned char Chksum;
56
 } __attribute__((packed));
57
 
58
 
59
#define X_AXIS 1
60
#define Y_AXIS 2
61
#define Z_AXIS 3
62
 
63
 
64
 
65
struct str_MicroMag
66
{
67
 unsigned char ReadAxis, WaitingforMeasurement;
68
 s16 Axis[3];
69
 s16 Heading;
70
} __attribute__((packed));
71
 
72
 
73
extern struct str_FromFlightCtrl   FromFlightCtrl;
74
extern struct str_ToFlightCtrl     ToFlightCtrl;
75
 
76
extern volatile struct str_MicroMag  MicroMag;
77
 
78
extern s16 GPS_Nick, GPS_Roll, CompassValue;
79
 
80
extern void SPI0_Init(void);
81
extern void SPI_CheckSlaveSelect(void);
82
extern void UpdateSPI_Buffer(void);
83
#endif