Rev 744 |
Rev 819 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
// ######################## SPI - FlightCtrl ###################
#ifndef _SPI_H
#define _SPI_H
#include <util/delay.h>
#define USE_SPI_COMMUNICATION
#define SPI_PROTOCOL_COMP 1
//-----------------------------------------
#define DDR_SPI DDRB
#define DD_SS PB4
#define DD_SCK PB7
#define DD_MOSI PB5
#define DD_MISO PB6
// for compatibility reasons gcc3.x <-> gcc4.x
#ifndef SPCR
#define SPCR SPCR0
#endif
#ifndef SPE
#define SPE SPE0
#endif
#ifndef MSTR
#define MSTR MSTR0
#endif
#ifndef SPR1
#define SPR1 SPR01
#endif
#ifndef SPR0
#define SPR0 SPR00
#endif
#ifndef SPIE
#define SPIE SPIE0
#endif
#ifndef SPDR
#define SPDR SPDR0
#endif
#ifndef SPIF
#define SPIF SPIF0
#endif
#ifndef SPSR
#define SPSR SPSR0
#endif
// -------------------------
#define SLAVE_SELECT_DDR_PORT DDRC
#define SLAVE_SELECT_PORT PORTC
#define SPI_SLAVE_SELECT PC5
struct str_ToNaviCtrl_Value
{
unsigned char Sync1, Sync2;
unsigned char Command;
signed int IntegralNick;
signed int IntegralRoll;
signed int AccNick;
signed int AccRoll;
char StickNick,StickRoll,
StickGier, StickGas;
signed int GyroCompass;
char User1, User2, User3, User4, User5, User6, User7, User8;
unsigned char Chksum;
};
struct str_ToNaviCtrl_Version
{
unsigned char Sync1, Sync2;
unsigned char Command;
unsigned char HVersion;
unsigned char NVersion;
unsigned char Comp;
unsigned char ActualSettingNo;
unsigned char MinimumSatNo;
unsigned char d1;
signed int d2;
signed int d3;
signed int d4;
signed int d5;
signed int d6;
signed int d7;
unsigned char Chksum;
};
struct str_FromNaviCtrl_Value
{
unsigned char Command;
signed int GPS_Nick;
signed int GPS_Roll;
signed int GPS_Gier;
signed int GPS_Height;
signed int CompassValue;
signed int Status;
unsigned char BeepTime;
unsigned char OsdBar;
signed int Distance;
signed int d2;
signed int d3;
signed int d4;
unsigned char Chksum;
};
struct str_FromNaviCtrl_Version
{
unsigned char Command;
unsigned char HVersion;
unsigned char NVersion;
unsigned char Comp;
unsigned char d0;
signed int d1;
signed int d2;
signed int d3;
signed int d4;
signed int d5;
signed int d6;
signed int d7;
unsigned char Chksum;
};
#ifdef USE_SPI_COMMUNICATION
extern struct str_ToNaviCtrl_Version ToNaviCtrl_Version;
extern struct str_FromNaviCtrl_Version FromNaviCtrl_Version;
extern struct str_ToNaviCtrl_Value ToNaviCtrl_Value;
extern struct str_FromNaviCtrl_Value FromNaviCtrl_Value;
#define SPI_CMD_VERSION 0x02
#define SPI_CMD_VALUE 0x03
extern void SPI_MasterInit(void);
extern void SPI_StartTransmitPacket(unsigned char command);
extern void UpdateSPI_Buffer(void);
extern void SPI_TransmitByte(void);
#else
// -------------------------------- Dummy -----------------------------------------
#define SPI_MasterInit() ;
#define SPI_StartTransmitPacket() ;
#define UpdateSPI_Buffer() ;
#define SPI_TransmitByte() ;
#endif
#endif