Subversion Repositories NaviCtrl

Rev

Rev 149 | Blame | Compare with Previous | Last modification | View Log | RSS feed

#ifndef _SPI_SLAVE_H
#define _SPI_SLAVE_H

#include "fifo.h"


#define SS_PIN GPIO_ReadBit(GPIO2, GPIO_Pin_7)

#define SPI_CMD_USER             10
#define SPI_CMD_STICK            11
#define SPI_CMD_MISC         12
#define SPI_CMD_PARAMETER1       13
#define SPI_CMD_VERSION      14
#define SPI_CMD_SERVOS           15

extern s32 Kalman_K;
extern s32 Kalman_MaxDrift;
extern s32 Kalman_MaxFusion;
extern s32 ToFcGpsZ;

typedef struct
{
        u8   Command;
        s16  AngleNick;  // NickAngle in 0.1 deg
        s16  AngleRoll;  // RollAngle in 0.1 deg
        s16  AccNick;
        s16  AccRoll;
        s16  GyroHeading;        // Heading in 0.1 deg
        s16  GyroNick;
        s16  GyroRoll;
        s16  GyroYaw;
        union
        {
                s8        sByte[12];
                u8    Byte[12];
                s16   Int[6];
                s32   Long[3];
                float Float[3];
        } Param;
        u8 Chksum;
 } __attribute__((packed)) FromFlightCtrl_t;


#define SPI_KALMAN          103

typedef struct
{
        u8 Command;
        s16 GPS_Nick;
        s16 GPS_Roll;
        s16 GPS_Yaw;
        s16 CompassHeading;
        s16 Status;
        u16 BeepTime;
        union
        {
                s8    sByte[12];
                u8    Byte[12];
                s16   Int[6];
                s32   Long[3];
                float Float[3];
        }Param;
        u8 Chksum;
 } __attribute__((packed)) ToFlightCtrl_t;


typedef struct
{
   u8 Major;
   u8 Minor;
   u8 Patch;
   u8 Compatible;
   u8 Hardware;
} __attribute__((packed)) SPI_Version_t;

extern volatile FromFlightCtrl_t   FromFlightCtrl;
extern volatile ToFlightCtrl_t     ToFlightCtrl;
extern volatile u32 SPI0_Timeout;
extern SPI_Version_t FC_Version;
extern fifo_t CompassCalcStateFiFo;

void SPI0_Init(void);
void SPI0_GetFlightCtrlVersion(void);
void SPI0_UpdateBuffer(void);



#endif //_SPI_SLAVE_H