roneos
Operating System for the r-one robot
 All Data Structures Files Functions Variables Typedefs Groups
ir_comms.h
Go to the documentation of this file.
1 
8 #ifndef IR_COMMS_H_
9 #define IR_COMMS_H_
10 
11 /******** Defines ********/
12 
13 #define IR_COMMS_MESSAGE_LENGTH_MAX 6
14 #define IR_COMMS_MESSAGE_BIT_LENGTH_MAX (IR_COMMS_MESSAGE_LENGTH_MAX * 8)
15 
16 
17 #define IR_COMMS_NUM_OF_RECEIVERS 8
18 #define IR_COMMS_RECEIVER_FRONT_LEFT 0
19 #define IR_COMMS_RECEIVER_LEFT_FRONT 1
20 #define IR_COMMS_RECEIVER_LEFT_REAR 2
21 #define IR_COMMS_RECEIVER_REAR_LEFT 3
22 #define IR_COMMS_RECEIVER_REAR_RIGHT 4
23 #define IR_COMMS_RECEIVER_RIGHT_REAR 5
24 #define IR_COMMS_RECEIVER_RIGHT_FRONT 6
25 #define IR_COMMS_RECEIVER_FRONT_RIGHT 7
26 
27 #define IR_COMMS_RECEIVER_FRONT_LEFT_BIT (1 << IR_COMMS_RECEIVER_FRONT_LEFT)
28 #define IR_COMMS_RECEIVER_LEFT_FRONT_BIT (1 << IR_COMMS_RECEIVER_LEFT_FRONT)
29 #define IR_COMMS_RECEIVER_LEFT_REAR_BIT (1 << IR_COMMS_RECEIVER_LEFT_REAR)
30 #define IR_COMMS_RECEIVER_REAR_LEFT_BIT (1 << IR_COMMS_RECEIVER_REAR_LEFT)
31 #define IR_COMMS_RECEIVER_REAR_RIGHT_BIT (1 << IR_COMMS_RECEIVER_REAR_RIGHT)
32 #define IR_COMMS_RECEIVER_RIGHT_REAR_BIT (1 << IR_COMMS_RECEIVER_RIGHT_REAR)
33 #define IR_COMMS_RECEIVER_RIGHT_FRONT_BIT (1 << IR_COMMS_RECEIVER_RIGHT_FRONT)
34 #define IR_COMMS_RECEIVER_FRONT_RIGHT_BIT (1 << IR_COMMS_RECEIVER_FRONT_RIGHT)
35 
36 #define IR_COMMS_RECEIVER_0_ANGLE 0.3927
37 #define IR_COMMS_RECEIVER_1_ANGLE 1.1781
38 #define IR_COMMS_RECEIVER_2_ANGLE 1.9635
39 #define IR_COMMS_RECEIVER_3_ANGLE 2.7489
40 #define IR_COMMS_RECEIVER_4_ANGLE 3.5343
41 #define IR_COMMS_RECEIVER_5_ANGLE 4.3197
42 #define IR_COMMS_RECEIVER_6_ANGLE 5.1051
43 #define IR_COMMS_RECEIVER_7_ANGLE 5.8905
44 
45 #define IR_COMMS_NUM_OF_TRANSMITTERS 8
46 #define IR_COMMS_POWER_MAX 256
47 
48 /******** Structs ********/
49 
56 typedef struct IRCommsMessage {
57  uint8 data[IR_COMMS_MESSAGE_LENGTH_MAX];
58  uint8 orientationBitMatrix[IR_COMMS_NUM_OF_RECEIVERS];
59  uint8 rangeBits[IR_COMMS_NUM_OF_RECEIVERS];
60  uint32 timeStamp;
62 
63 /******** Functions ********/
64 
70 void irCommsSetSize(uint8 size);
71 
78 void irCommsSetXmitPower(uint16 power);
79 
80 
87 boolean irCommsSendMessage(irCommsMessage* irMessagePtr);
88 
89 
96 boolean irCommsGetMessage(irCommsMessage* irMessagePtr);
97 
99 //void ir_comms_set_message_length(uint8 msg_length);
100 
101 
109 void irCommsOrientationBitMatrixPrint(uint8* orientationBitsMatrixPtr, uint8* rangeBitsMatrixPtr);
110 
111 
112 /*
113  * @brief returns the number of bits received in a given ir message
114  *
115  * @param irMessagePtr the message received
116  * @return number of bits received in message
117  */
118 uint8 irCommsGetMessageReceiveBits(irCommsMessage* irMessagePtr);
119 
130 void irCommsInit(void);
131 
132 
133 #endif /* IR_COMMS_H_ */