Appiko
radio_drv.h
1 /******************************************************************************
2  * Filename: radio_drv.h
3  *
4  * Description: Radio driver abstraction layer, this uses the same concept
5  * as found in Contiki OS.
6  *
7  * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
8  *
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  *
17  * Redistributions in binary form must reproduce the above copyright
18  * notice, this list of conditions and the following disclaimer in the
19  * documentation and/or other materials provided with the distribution.
20  *
21  * Neither the name of Texas Instruments Incorporated nor the names of
22  * its contributors may be used to endorse or promote products derived
23  * from this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37  *******************************************************************************/
38 #include "stdint.h"
39 
40 
41 /* Initialize the radio hardware */
42 int radio_init(uint8_t config_select);
43 
44 /* Prepare the radio with a packet to be sent */
45 int radio_prepare(uint8_t *payload, uint16_t payload_len);
46 
47 /* Send the packet that has previously been prepared (used for exact timing)*/
48 int radio_transmit(void);
49 
50 /* Enter recieve mode */
51 int radio_receive_on(void);
52 
53 /* Prepare & transmit a packet in same call (slightly worse timing jitter) */
54 int radio_send(uint8_t *payload, uint16_t payload_len);
55 
56 /* Read a received packet into a buffer */
57 int radio_read(uint8_t * buf, uint8_t *buf_len);
58 
59 /* Perform a Clear-Channel Assessment (CCA) to find out if channel is clear */
60 int radio_channel_clear(void);
61 
62 /* Wait for radio to become idle (currently receiving or transmitting) */
63 int radio_wait_for_idle(uint16_t max_hold);
64 
65 /* Check if the radio driver has just received a packet */
66 int radio_pending_packet(void);
67 
68 /* Clear the flag that the driver has just received a packet */
69 int radio_clear_pending_packet(void);
70 
71 /* Change rf transmit power of radio */
72 int radio_set_pwr(int tx_pwr);
73 
74 /* Change channel of radio */
75 int radio_set_freq(uint64_t freq);
76 
77 /* Idle the radio, used when leaving low power modes (below)*/
78 int radio_idle(void);
79 
80 /* Put the radio into sleep mode */
81 int radio_sleep(void);
82 
83 /* Wake the radio from sleep mode */
84 int radio_wakeup(void);
85 
86 /* Force PLL calibration, used enabling manual calibration for ultra low power */
87 int radio_calibrate_on(void);
88 
89 /* extract the frequency error estimate of the previous packet */
90 int radio_freq_error(void);
91 
92 /* Function to check certain status flag */
93 int radio_check_status_flag (uint8_t status_bits);
94 
95 /* Function to get RSSI Value */
96 int radio_get_rssi_val ();