Contiki 3.x
avr-handler.h
1 #ifndef AVR_HANDLER
2 #define AVR_HANDLER
3 
4 #include <stdbool.h>
5 #include <stdint.h>
6 #include "contiki.h"
7 
8 PROCESS_NAME(avr_process);
9 
10 /**
11  * A struct used to request data from an AVR
12  */
13 struct avr_data {
14 
15  /**
16  * The ID of the AVR to sample from.
17  */
18  uint8_t id;
19 
20  /**
21  * The size of data. (ie the bytes of memory allocated for data).
22  */
23  uint8_t size;
24 
25  /**
26  * The data.
27  */
28  uint8_t *data;
29 
30  /**
31  * The length of data. (ie the number of bytes used).
32  */
33  uint8_t *len;
34 };
35 
36 /**
37  * Get data from an AVR with a given ID
38  * @param data Pointer to a avr_data struct that will be filled with the data obtained from the AVR. It's size should be set to
39  * the max_size of the buffer it points to.
40  * @return True on success, false otherwise
41  */
42 bool avr_get_data(struct avr_data *data);
43 
44 /**
45  * Set the function to use to output data.
46  * This function should typically be the output function of the serial port
47  * we're set to receive data from.
48  */
49 void avr_set_output(void (*out)(uint8_t *data, int len));
50 
51 /**
52  * Give us a single input byte received from the serial port.
53  * @param byte The byte received.
54  */
55 int avr_input_byte(uint8_t byte);
56 
57 /**
58  * Set the call back to use on succesfully processing an AVR request.
59  */
60 void avr_set_callback(void (*callback)(bool isSuccess));
61 
62 #endif // AVR_HANDLER
uint8_t id
The ID of the AVR to sample from.
Definition: avr-handler.h:18
uint8_t * data
The data.
Definition: avr-handler.h:28
uint8_t * len
The length of data.
Definition: avr-handler.h:33
PROCESS_NAME(sample_process)
Process the sampler runs as.
uint8_t size
The size of data.
Definition: avr-handler.h:23
A struct used to request data from an AVR.
Definition: avr-handler.h:13