Contiki-NG
cc1200-arch.h
1/*
2 * Copyright (c) 2015, Weptech elektronik GmbH Germany
3 * http://www.weptech.de
4 *
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
30 * OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * This file is part of the Contiki operating system.
33 */
34
35#ifndef CC1200_ARCH_H
36#define CC1200_ARCH_H
37
38#include <stdint.h>
39/*---------------------------------------------------------------------------*/
40/*
41 * Initialize SPI module & Pins.
42 *
43 * The function has to accomplish the following tasks:
44 * - Enable SPI and configure SPI (CPOL = 0, CPHA = 0)
45 * - Configure MISO, MOSI, SCLK accordingly
46 * - Configure GPIOx (input)
47 * - Configure RESET_N (output high)
48 * - Configure CSn (output high)
49 */
50void
51cc1200_arch_init(void);
52/*---------------------------------------------------------------------------*/
53/* Select CC1200 (pull down CSn pin). */
54void
55cc1200_arch_spi_select(void);
56/*---------------------------------------------------------------------------*/
57/* De-select CC1200 (release CSn pin). */
58void
59cc1200_arch_spi_deselect(void);
60/*---------------------------------------------------------------------------*/
61/*
62 * Configure port IRQ for GPIO0.
63 * If rising == 1: configure IRQ for rising edge, else falling edge
64 * Interrupt has to call cc1200_rx_interrupt()!
65 */
66void
67cc1200_arch_gpio0_setup_irq(int rising);
68/*---------------------------------------------------------------------------*/
69/*
70 * Configure port IRQ for GPIO2.
71 *
72 * GPIO2 might not be needed at all depending on the driver's
73 * configuration (see cc1200-conf.h)
74 *
75 * If rising == 1: configure IRQ for rising edge, else falling edge
76 * Interrupt has to call cc1200_rx_interrupt()!
77 */
78void
79cc1200_arch_gpio2_setup_irq(int rising);
80/*---------------------------------------------------------------------------*/
81/* Reset interrupt flag and enable GPIO0 port IRQ. */
82void
83cc1200_arch_gpio0_enable_irq(void);
84/*---------------------------------------------------------------------------*/
85/* Disable GPIO0 port IRQ. */
86void
87cc1200_arch_gpio0_disable_irq(void);
88/*---------------------------------------------------------------------------*/
89/*
90 * Reset interrupt flag and enable GPIO2 port IRQ
91 *
92 * GPIO2 might not be needed at all depending on the driver's
93 * configuration (see cc1200-conf.h)
94 */
95void
96cc1200_arch_gpio2_enable_irq(void);
97/*---------------------------------------------------------------------------*/
98/*
99 * Disable GPIO2 port IRQ.
100 *
101 * GPIO2 might not be needed at all depending on the driver's
102 * configuration (see cc1200-conf.h)
103 */
104void
105cc1200_arch_gpio2_disable_irq(void);
106/*---------------------------------------------------------------------------*/
107/*
108 * Read back the status of the GPIO0 pin.
109 * Returns 0 if the pin is low, otherwise 1
110 */
111int
112cc1200_arch_gpio0_read_pin(void);
113/*---------------------------------------------------------------------------*/
114/*
115 * Read back the status of the GPIO2 pin.
116 *
117 * GPIO2 might not be needed at all depending on the driver's
118 * configuration (see cc1200-conf.h)
119 *
120 * Returns 0 if the pin is low, otherwise 1
121 */
122int
123cc1200_arch_gpio2_read_pin(void);
124/*---------------------------------------------------------------------------*/
125/*
126 * Read back the status of the GPIO3 pin.
127 *
128 * Currently only used for rf test modes.
129 *
130 * Returns 0 if the pin is low, otherwise 1
131 */
132int
133cc1200_arch_gpio3_read_pin(void);
134/*---------------------------------------------------------------------------*/
135/* Write a single byte via SPI, return response. */
136int
137cc1200_arch_spi_rw_byte(uint8_t c);
138/*---------------------------------------------------------------------------*/
139/*
140 * Write a sequence of bytes while reading back the response.
141 * Either read_buf or write_buf can be NULL.
142 */
143int
144cc1200_arch_spi_rw(uint8_t *read_buf,
145 const uint8_t *write_buf,
146 uint16_t len);
147/*---------------------------------------------------------------------------*/
148/*
149 * The CC1200 interrupt handler exported from the cc1200 driver.
150 *
151 * To be called by the hardware interrupt handler(s),
152 * which are defined as part of the cc1200-arch interface.
153 */
154int
155cc1200_rx_interrupt(void);
156
157#endif /* CC1200_ARCH_H */