Contiki-NG
Loading...
Searching...
No Matches
rf-switch.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015, Texas Instruments Incorporated - http://www.ti.com/
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28 * OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30/*---------------------------------------------------------------------------*/
31/**
32 * \addtogroup rf-switch
33 * @{
34 *
35 * \file
36 * CC1350 LP RF switch driver
37 */
38/*---------------------------------------------------------------------------*/
39#include "contiki.h"
40#include "lpm.h"
41#include "rf-core/rf-switch.h"
42#include "ti-lib.h"
43
44#include <stdint.h>
45#include <string.h>
46#include <stdbool.h>
47/*---------------------------------------------------------------------------*/
48#define POWER_PIN IOID_30
49#define SELECT_PIN IOID_1
50/*---------------------------------------------------------------------------*/
51static void
52shutdown_handler(uint8_t mode)
53{
54 ti_lib_gpio_clear_dio(POWER_PIN);
55}
56/*---------------------------------------------------------------------------*/
57/*
58 * Declare a data structure to register with LPM. Always turn off the switch
59 * when we are dropping to deep sleep. We let the RF driver turn it on though.
60 */
61LPM_MODULE(rf_switch_module, NULL, shutdown_handler, NULL, LPM_DOMAIN_NONE);
62/*---------------------------------------------------------------------------*/
63void
64rf_switch_init()
65{
66 ti_lib_ioc_pin_type_gpio_output(POWER_PIN);
67 ti_lib_gpio_clear_dio(POWER_PIN);
68 ti_lib_ioc_pin_type_gpio_output(SELECT_PIN);
69 ti_lib_gpio_clear_dio(SELECT_PIN);
70
71 lpm_register_module(&rf_switch_module);
72}
73/*---------------------------------------------------------------------------*/
74void
75rf_switch_power_up()
76{
77 ti_lib_gpio_set_dio(POWER_PIN);
78}
79/*---------------------------------------------------------------------------*/
80void
81rf_switch_power_down()
82{
83 ti_lib_gpio_clear_dio(POWER_PIN);
84}
85/*---------------------------------------------------------------------------*/
86void
87rf_switch_select_path(uint8_t path)
88{
89 ti_lib_gpio_write_dio(SELECT_PIN, path);
90}
91/*---------------------------------------------------------------------------*/
92/** @} */
#define LPM_MODULE(n, m, s, w, l)
Declare a variable to be used in order to get notifications from LPM.
Definition lpm.h:96
void lpm_register_module(lpm_registered_module_t *module)
Register a module for LPM notifications.
Definition lpm.c:545
Header file with definitions related to RF switch support.
Header file with macros which rename TI CC26xxware functions.