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