Subversion Repositories FlightCtrl

Rev

Rev 598 | Rev 617 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 598 Rev 606
1
// ######################## SPI - FlightCtrl ###################
1
// ######################## SPI - FlightCtrl ###################
2
#ifndef _SPI_H
2
#ifndef _SPI_H
3
#define _SPI_H
3
#define _SPI_H
4
 
4
 
5
#define USE_SPI_COMMUNICATION 
5
#define USE_SPI_COMMUNICATION 
6
 
6
 
7
#define SPI_PROTOCOL_COMP   1
7
#define SPI_PROTOCOL_COMP   1
8
 
8
 
9
//-----------------------------------------
9
//-----------------------------------------
10
#define DDR_SPI DDRB
10
#define DDR_SPI DDRB
11
#define DD_SS   PB4
11
#define DD_SS   PB4
12
#define DD_SCK  PB7
12
#define DD_SCK  PB7
13
#define DD_MOSI PB5
13
#define DD_MOSI PB5
14
#define DD_MISO PB6 
14
#define DD_MISO PB6 
15
 
15
 
16
// for compatibility reasons gcc3.x <-> gcc4.x 
16
// for compatibility reasons gcc3.x <-> gcc4.x 
17
#ifndef SPCR  
17
#ifndef SPCR  
18
#define SPCR   SPCR0
18
#define SPCR   SPCR0
19
#endif    
19
#endif    
20
#ifndef SPE  
20
#ifndef SPE  
21
#define SPE   SPE0
21
#define SPE   SPE0
22
#endif    
22
#endif    
23
#ifndef MSTR  
23
#ifndef MSTR  
24
#define MSTR   MSTR0
24
#define MSTR   MSTR0
25
#endif    
25
#endif    
26
#ifndef SPR1  
26
#ifndef SPR1  
27
#define SPR1   SPR01
27
#define SPR1   SPR01
28
#endif    
28
#endif    
-
 
29
#ifndef SPR0  
-
 
30
#define SPR0   SPR00
-
 
31
#endif    
29
#ifndef SPIE  
32
#ifndef SPIE  
30
#define SPIE   SPIE0
33
#define SPIE   SPIE0
31
#endif    
34
#endif    
32
#ifndef SPDR  
35
#ifndef SPDR  
33
#define SPDR   SPDR0
36
#define SPDR   SPDR0
34
#endif    
37
#endif    
35
#ifndef SPIF  
38
#ifndef SPIF  
36
#define SPIF   SPIF0
39
#define SPIF   SPIF0
37
#endif    
40
#endif    
38
#ifndef SPSR  
41
#ifndef SPSR  
39
#define SPSR   SPSR0
42
#define SPSR   SPSR0
40
#endif    
43
#endif    
41
// -------------------------
44
// -------------------------
42
 
45
 
43
#define SLAVE_SELECT_DDR_PORT   DDRC
46
#define SLAVE_SELECT_DDR_PORT   DDRC
44
#define SLAVE_SELECT_PORT       PORTC
47
#define SLAVE_SELECT_PORT       PORTC
45
#define SPI_SLAVE_SELECT        PC5
48
#define SPI_SLAVE_SELECT        PC5
46
 
49
 
47
struct str_ToNaviCtrl
50
struct str_ToNaviCtrl
48
{
51
{
-
 
52
 unsigned char Sync1, Sync2;
49
 unsigned char Comp;
53
 unsigned char Comp;
50
 int IntegralNick;
54
 int IntegralNick;
51
 int IntegralRoll;
55
 int IntegralRoll;
52
 char StickNick,StickRoll,StickGier;
56
 char StickNick,StickRoll,StickGier;
53
};
57
};
54
 
58
 
55
struct str_FromNaviCtrl
59
struct str_FromNaviCtrl
56
{
60
{
57
 unsigned int Dummy;
61
 unsigned int Dummy;
58
 unsigned char Comp;
62
 unsigned char Comp;
59
 int GPS_Nick;
63
 int GPS_Nick;
60
 int GPS_Roll;
64
 int GPS_Roll;
61
 int CompassValue;
65
 int CompassValue;
62
};
66
};
63
 
67
 
64
#ifdef USE_SPI_COMMUNICATION
68
#ifdef USE_SPI_COMMUNICATION
65
extern struct str_ToNaviCtrl   ToNaviCtrl;
69
extern struct str_ToNaviCtrl   ToNaviCtrl;
66
extern struct str_FromNaviCtrl   FromNaviCtrl;
70
extern struct str_FromNaviCtrl   FromNaviCtrl;
67
 
71
 
68
 
72
 
69
extern void SPI_MasterInit(void);
73
extern void SPI_MasterInit(void);
70
extern void SPI_StartTransmitPacket(void);
74
extern void SPI_StartTransmitPacket(void);
71
extern void UpdateSPI_Buffer(void);
75
extern void UpdateSPI_Buffer(void);
72
extern void SPI_TransmitByte(void);
76
extern void SPI_TransmitByte(void);
73
#else
77
#else
74
 
78
 
75
 
79
 
76
// -------------------------------- Dummy -----------------------------------------
80
// -------------------------------- Dummy -----------------------------------------
77
#define  SPI_MasterInit() ; 
81
#define  SPI_MasterInit() ; 
78
#define  SPI_StartTransmitPacket() ;
82
#define  SPI_StartTransmitPacket() ;
79
#define  UpdateSPI_Buffer() ;
83
#define  UpdateSPI_Buffer() ;
80
#define  SPI_TransmitByte() ;
84
#define  SPI_TransmitByte() ;
81
#endif
85
#endif
82
 
86
 
83
 
87
 
84
#endif
88
#endif
85
 
89