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