Newer
Older
/****************************************************************************
* include/nuttx/wireless/generic/si4463.h
*
* Copyright (C) 2017 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_WIRELESS_GENERIC_SI4463_H
#define __INCLUDE_NUTTX_WIRELESS_GENERIC_SI4463_H
/****************************************************************************
* Included files
****************************************************************************/
#include <nuttx/arch.h>
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* identifiers for the si4463 IO lines */
#define SI4463_IO0 0
#define SI4463_IO1 1
/****************************************************************************
* Public Types
****************************************************************************/
/* The SI4463 provides interrupts to the MCU via a GPIO pin. The
* following structure provides an MCU-independent mechanism for controlling
int (*attach)(FAR const struct si4463_lower_s *lower, xcpt_t handler, FAR void *arg);
void (*enable)(FAR const struct si4463_lower_s *lower, int state);
};
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Initialize the radio driver. The SI4463 device is assumed to be
* in the post-reset state upon entry to this function.
*
* Parameters:
* spi - A reference to the platform's SPI driver for the SI4463
* devnum - The SPI device index (within SPIDEVTYPE_GENRADIO)
* xtal - the frequency of the on-board xtal connected to the SI4463
* papin - the index of the GPIO pin connected to the TXANT pin (PA enable)
* lnapin - the index of the GPIO pin connected to the RXANT pin (LNA enable)
* lower - The MCU-specific interrupt used to control low-level MCU
* functions (i.e., SI4463 GPIO interrupts).
*
* Returned Value:
* OK on success; Negated errno on failure.
*
* Assumptions:
*
****************************************************************************/
struct spi_dev_s; /* Forward reference */
FAR struct genradio_dev_s *si4463_init(FAR struct spi_dev_s *spi, int devnum,
/* these wrappers can be used to initialize radio modules with known params */
/* RFM26 has a 30 MHz crystal and active-low antenna switch control */
static inline FAR struct genradio_dev_s *
Sebastien Lorquet
committed
RFM26_init(FAR struct spi_dev_s *spi, int devnum, int papin, int lnapin,
FAR const struct si4463_lower_s *lower)
{
return si4463_init(spi, devnum, 30000000, papin, lnapin, true, false, lower);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __INCLUDE_NUTTX_WIRELESS_GENERIC_SI4463_H */