Subversion Repositories FlightCtrl

Rev

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

Rev Author Line No. Line
1612 dongfang 1
// ######################## SPI - FlightCtrl ###################
2
#ifndef _SPI_H
3
#define _SPI_H
4
 
5
//#include <util/delay.h>
6
#include <inttypes.h>
7
#define SPI_PROTOCOL_COMP   1
8
 
9
#define SPI_CMD_USER        10
10
#define SPI_CMD_STICK       11
11
#define SPI_CMD_MISC            12
12
#define SPI_CMD_PARAMETER1      13
13
#define SPI_CMD_VERSION         14
14
 
1645 - 15
typedef struct {
1775 - 16
  uint8_t Sync1;
17
  uint8_t Sync2;
18
  uint8_t Command;
19
  int16_t IntegralPitch;
20
  int16_t IntegralRoll;
21
  int16_t AccPitch;
22
  int16_t AccRoll;
23
  int16_t GyroHeading;
24
  int16_t GyroPitch;
25
  int16_t GyroRoll;
26
  int16_t GyroYaw;
27
  union {
28
    int8_t  sByte[12];
29
    uint8_t Byte[12];
30
    int16_t Int[6];
31
    int32_t Long[3];
32
    float   Float[3];
33
  } Param;
34
  uint8_t Chksum;
1612 dongfang 35
} __attribute__((packed)) ToNaviCtrl_t;
36
 
37
#define SPI_CMD_OSD_DATA        100
38
#define SPI_CMD_GPS_POS         101
39
#define SPI_CMD_GPS_TARGET      102
40
#define SPI_KALMAN                      103
41
 
1645 - 42
typedef struct {
1775 - 43
  uint8_t Command;
44
  int16_t GPSStickPitch;
45
  int16_t GPSStickRoll;
46
  int16_t GPS_Yaw;
47
  int16_t CompassHeading;
48
  int16_t Status;
49
  uint16_t BeepTime;
50
  union {
51
    int8_t  Byte[12];
52
    int16_t Int[6];
53
    int32_t Long[3];
54
    float   Float[3];
55
  } Param;
56
  uint8_t Chksum;
1612 dongfang 57
} __attribute__((packed)) FromNaviCtrl_t;
58
 
1645 - 59
typedef struct {
1775 - 60
  uint8_t Major;
61
  uint8_t Minor;
62
  uint8_t Patch;
63
  uint8_t Compatible;
64
  //    unsigned char Hardware;
1612 dongfang 65
} __attribute__((packed)) SPI_VersionInfo_t;
66
 
1775 - 67
extern ToNaviCtrl_t                     toNaviCtrl;
68
extern FromNaviCtrl_t                   fromNaviCtrl;
1612 dongfang 69
 
1645 - 70
typedef struct {
1775 - 71
  int8_t        KalmanK;
72
  int8_t        KalmanMaxDrift;
73
  int8_t        KalmanMaxFusion;
74
  uint8_t       SerialDataOkay;
1612 dongfang 75
} __attribute__((packed)) NCData_t;
76
 
77
extern uint8_t NCDataOkay;
78
extern uint8_t NCSerialDataOkay;
79
 
80
void SPI_MasterInit(void);
81
void SPI_StartTransmitPacket(void);
82
void SPI_TransmitByte(void);
1775 - 83
// new:
84
// extern void UpdateSPI_Buffer(void);
1612 dongfang 85
 
86
#endif //_SPI_H