Rev 606 | Rev 618 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 606 | Rev 617 | ||
---|---|---|---|
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 |
29 | #ifndef SPR0 |
30 | #define SPR0 SPR00 |
30 | #define SPR0 SPR00 |
31 | #endif |
31 | #endif |
32 | #ifndef SPIE |
32 | #ifndef SPIE |
33 | #define SPIE SPIE0 |
33 | #define SPIE SPIE0 |
34 | #endif |
34 | #endif |
35 | #ifndef SPDR |
35 | #ifndef SPDR |
36 | #define SPDR SPDR0 |
36 | #define SPDR SPDR0 |
37 | #endif |
37 | #endif |
38 | #ifndef SPIF |
38 | #ifndef SPIF |
39 | #define SPIF SPIF0 |
39 | #define SPIF SPIF0 |
40 | #endif |
40 | #endif |
41 | #ifndef SPSR |
41 | #ifndef SPSR |
42 | #define SPSR SPSR0 |
42 | #define SPSR SPSR0 |
43 | #endif |
43 | #endif |
44 | // ------------------------- |
44 | // ------------------------- |
45 | 45 | ||
46 | #define SLAVE_SELECT_DDR_PORT DDRC |
46 | #define SLAVE_SELECT_DDR_PORT DDRC |
47 | #define SLAVE_SELECT_PORT PORTC |
47 | #define SLAVE_SELECT_PORT PORTC |
48 | #define SPI_SLAVE_SELECT PC5 |
48 | #define SPI_SLAVE_SELECT PC5 |
49 | 49 | ||
50 | struct str_ToNaviCtrl |
50 | struct str_ToNaviCtrl |
51 | { |
51 | { |
52 | unsigned char Sync1, Sync2; |
52 | unsigned char Sync1, Sync2; |
53 | unsigned char Comp; |
53 | unsigned char Comp; |
54 | int IntegralNick; |
54 | int IntegralNick; |
55 | int IntegralRoll; |
55 | int IntegralRoll; |
56 | char StickNick,StickRoll,StickGier; |
56 | char StickNick,StickRoll,StickGier; |
- | 57 | unsigned char ChkSum; |
|
57 | }; |
58 | }; |
58 | 59 | ||
59 | struct str_FromNaviCtrl |
60 | struct str_FromNaviCtrl |
60 | { |
61 | { |
61 | unsigned int Dummy; |
62 | unsigned int Dummy; |
62 | unsigned char Comp; |
63 | unsigned char Comp; |
63 | int GPS_Nick; |
64 | int GPS_Nick; |
64 | int GPS_Roll; |
65 | int GPS_Roll; |
65 | int CompassValue; |
66 | int CompassValue; |
66 | }; |
67 | }; |
67 | 68 | ||
68 | #ifdef USE_SPI_COMMUNICATION |
69 | #ifdef USE_SPI_COMMUNICATION |
69 | extern struct str_ToNaviCtrl ToNaviCtrl; |
70 | extern struct str_ToNaviCtrl ToNaviCtrl; |
70 | extern struct str_FromNaviCtrl FromNaviCtrl; |
71 | extern struct str_FromNaviCtrl FromNaviCtrl; |
71 | 72 | ||
72 | 73 | ||
73 | extern void SPI_MasterInit(void); |
74 | extern void SPI_MasterInit(void); |
74 | extern void SPI_StartTransmitPacket(void); |
75 | extern void SPI_StartTransmitPacket(void); |
75 | extern void UpdateSPI_Buffer(void); |
76 | extern void UpdateSPI_Buffer(void); |
76 | extern void SPI_TransmitByte(void); |
77 | extern void SPI_TransmitByte(void); |
77 | #else |
78 | #else |
78 | 79 | ||
79 | 80 | ||
80 | // -------------------------------- Dummy ----------------------------------------- |
81 | // -------------------------------- Dummy ----------------------------------------- |
81 | #define SPI_MasterInit() ; |
82 | #define SPI_MasterInit() ; |
82 | #define SPI_StartTransmitPacket() ; |
83 | #define SPI_StartTransmitPacket() ; |
83 | #define UpdateSPI_Buffer() ; |
84 | #define UpdateSPI_Buffer() ; |
84 | #define SPI_TransmitByte() ; |
85 | #define SPI_TransmitByte() ; |
85 | #endif |
86 | #endif |
86 | 87 | ||
87 | 88 | ||
88 | #endif |
89 | #endif |
89 | 90 |