Subversion Repositories FlightCtrl

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
304 ingob 1
// ######################## SPI - FlightCtrl ###################
2
#ifndef _SPI_H
3
#define _SPI_H
4
 
708 ingob 5
#include <util/delay.h>
597 ingob 6
 
708 ingob 7
#define USE_SPI_COMMUNICATION 
8
 
619 ingob 9
#define SPI_PROTOCOL_COMP   1
304 ingob 10
 
11
//-----------------------------------------
12
#define DDR_SPI DDRB
13
#define DD_SS   PB4
14
#define DD_SCK  PB7
15
#define DD_MOSI PB5
16
#define DD_MISO PB6 
17
 
596 ingob 18
// for compatibility reasons gcc3.x <-> gcc4.x 
19
#ifndef SPCR  
20
#define SPCR   SPCR0
21
#endif    
22
#ifndef SPE  
23
#define SPE   SPE0
24
#endif    
25
#ifndef MSTR  
26
#define MSTR   MSTR0
27
#endif    
28
#ifndef SPR1  
29
#define SPR1   SPR01
30
#endif    
606 ingob 31
#ifndef SPR0  
32
#define SPR0   SPR00
33
#endif    
596 ingob 34
#ifndef SPIE  
35
#define SPIE   SPIE0
36
#endif    
37
#ifndef SPDR  
38
#define SPDR   SPDR0
39
#endif    
40
#ifndef SPIF  
41
#define SPIF   SPIF0
42
#endif    
43
#ifndef SPSR  
44
#define SPSR   SPSR0
45
#endif    
46
// -------------------------
304 ingob 47
 
48
#define SLAVE_SELECT_DDR_PORT   DDRC
49
#define SLAVE_SELECT_PORT       PORTC
50
#define SPI_SLAVE_SELECT        PC5
51
 
823 ingob 52
 
53
#define SPI_CMD_USER        10
54
#define SPI_CMD_STICK       11
55
#define SPI_CMD_CAL_COMPASS 12
56
struct str_ToNaviCtrl
304 ingob 57
{
606 ingob 58
 unsigned char Sync1, Sync2;
708 ingob 59
 unsigned char Command;
805 hbuss 60
 signed int  IntegralNick;
708 ingob 61
 signed int  IntegralRoll;
805 hbuss 62
 signed int  AccNick;
63
 signed int  AccRoll;
709 ingob 64
 signed int  GyroCompass;
823 ingob 65
 signed int  GyroNick;
66
 signed int  GyroRoll;
67
 signed int  GyroGier;
68
 union  
69
 { char Byte[12];
70
   int  Int[6];
71
   long Long[3];
72
   float Float[3];
73
 } Param;
709 ingob 74
 unsigned char Chksum;
304 ingob 75
};
76
 
823 ingob 77
#define SPI_CMD_OSD_DATA         100
78
#define SPI_CMD_GPS_POS          101
79
#define SPI_CMD_GPS_TARGET   102 
80
struct str_FromNaviCtrl
304 ingob 81
{
708 ingob 82
 unsigned char Command;
83
  signed int  GPS_Nick;
84
  signed int  GPS_Roll;
85
  signed int  GPS_Gier;
86
  signed int  CompassValue;
87
  signed int  Status;
720 ingob 88
  unsigned char BeepTime;
823 ingob 89
  union  
90
  { char Byte[12];
91
    int  Int[6];
92
    long Long[3];
93
    float Float[3];
94
  } Param;
708 ingob 95
  unsigned char Chksum;
304 ingob 96
};
97
 
708 ingob 98
 
597 ingob 99
#ifdef USE_SPI_COMMUNICATION
304 ingob 100
 
823 ingob 101
extern struct str_ToNaviCtrl   ToNaviCtrl;
102
extern struct str_FromNaviCtrl FromNaviCtrl;
304 ingob 103
 
823 ingob 104
//#define SPI_CMD_VALUE   0x03
708 ingob 105
 
304 ingob 106
extern void SPI_MasterInit(void);
823 ingob 107
extern void SPI_StartTransmitPacket(void);
304 ingob 108
extern void UpdateSPI_Buffer(void);
109
extern void SPI_TransmitByte(void);
597 ingob 110
#else
304 ingob 111
 
112
 
597 ingob 113
// -------------------------------- Dummy -----------------------------------------
114
#define  SPI_MasterInit() ; 
115
#define  SPI_StartTransmitPacket() ;
116
#define  UpdateSPI_Buffer() ;
117
#define  SPI_TransmitByte() ;
118
#endif
304 ingob 119
 
597 ingob 120
 
121
#endif