Subversion Repositories NaviCtrl

Rev

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

Rev Author Line No. Line
41 ingob 1
#ifndef _SPI_SLAVE_H
2
#define _SPI_SLAVE_H
1 ingob 3
 
41 ingob 4
#include "fifo.h"
215 killagreg 5
#include "gps.h"
1 ingob 6
 
41 ingob 7
 
1 ingob 8
#define SS_PIN GPIO_ReadBit(GPIO2, GPIO_Pin_7)
9
 
202 killagreg 10
#define SPI_FCCMD_USER                  10
11
#define SPI_FCCMD_STICK                 11
12
#define SPI_FCCMD_MISC                  12
13
#define SPI_FCCMD_PARAMETER1    13
14
#define SPI_FCCMD_VERSION               14
15
#define SPI_FCCMD_SERVOS                15
206 killagreg 16
#define SPI_FCCMD_ACCU                  16
41 ingob 17
 
149 killagreg 18
extern s32 Kalman_K;
41 ingob 19
extern s32 Kalman_MaxDrift;
20
extern s32 Kalman_MaxFusion;
148 holgerb 21
extern s32 ToFcGpsZ;
222 holgerb 22
extern s32 ToFC_Rotate_C, ToFC_Rotate_S;
23
extern s32 HeadFreeStartAngle;
277 killagreg 24
extern s16 NewCompassDirectionSetpoint;
25
extern s16 FC_WP_EventChannel;
118 killagreg 26
 
41 ingob 27
typedef struct
118 killagreg 28
{
29
        u8   Command;
30
        s16  AngleNick;  // NickAngle in 0.1 deg
31
        s16  AngleRoll;  // RollAngle in 0.1 deg
32
        s16  AccNick;
33
        s16  AccRoll;
34
        s16  GyroHeading;        // Heading in 0.1 deg
35
        s16  GyroNick;
36
        s16  GyroRoll;
37
        s16  GyroYaw;
38
        union
39
        {
205 killagreg 40
                u8    Byte[12];
118 killagreg 41
                s8        sByte[12];
205 killagreg 42
                u16   Int[6];
43
                s16   sInt[6];
44
                u32   Long[3];
45
                s32   sLong[3];
118 killagreg 46
                float Float[3];
47
        } Param;
48
        u8 Chksum;
41 ingob 49
 } __attribute__((packed)) FromFlightCtrl_t;
50
 
202 killagreg 51
#define SPI_NCCMD_OSD_DATA              100
52
#define SPI_NCCMD_GPS_POS               101
53
#define SPI_NCCMD_GPS_TARGET    102
54
#define SPI_NCCMD_KALMAN                103
55
#define SPI_NCCMD_VERSION               104
204 killagreg 56
#define SPI_NCCMD_GPSINFO               105
1 ingob 57
 
41 ingob 58
typedef struct
59
{
60
        u8 Command;
215 killagreg 61
        GPS_Stick_t GPSStick;
41 ingob 62
        s16 CompassHeading;
63
        s16 Status;
64
        u16 BeepTime;
65
        union
66
        {
205 killagreg 67
                u8    Byte[12];
41 ingob 68
                s8    sByte[12];
205 killagreg 69
                u16       Int[6];
70
                s16   sInt[6];
71
                u32   Long[3];
72
                s32   sLong[3];
41 ingob 73
                float Float[3];
74
        }Param;
75
        u8 Chksum;
76
 } __attribute__((packed)) ToFlightCtrl_t;
1 ingob 77
 
78
 
41 ingob 79
typedef struct
1 ingob 80
{
41 ingob 81
   u8 Major;
82
   u8 Minor;
83
   u8 Patch;
84
   u8 Compatible;
61 holgerb 85
   u8 Hardware;
41 ingob 86
} __attribute__((packed)) SPI_Version_t;
1 ingob 87
 
215 killagreg 88
extern FromFlightCtrl_t   FromFlightCtrl;
89
extern ToFlightCtrl_t     ToFlightCtrl;
146 killagreg 90
extern volatile u32 SPI0_Timeout;
41 ingob 91
extern SPI_Version_t FC_Version;
1 ingob 92
 
41 ingob 93
void SPI0_Init(void);
94
void SPI0_GetFlightCtrlVersion(void);
95
void SPI0_UpdateBuffer(void);
1 ingob 96
 
97
 
98
 
41 ingob 99
#endif //_SPI_SLAVE_H