2012-02-29 05:30:06 +01:00
|
|
|
/**
|
2013-05-19 16:37:30 +02:00
|
|
|
******************************************************************************
|
|
|
|
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
|
|
|
* @{
|
|
|
|
* @addtogroup PIOS_RFM22B Radio Functions
|
|
|
|
* @brief PIOS interface for RFM22B Radio
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file pios_rfm22b.h
|
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
|
|
|
* @brief RFM22B functions header.
|
|
|
|
* @see The GNU Public License (GPL) Version 3
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2012-02-29 05:30:06 +01:00
|
|
|
* (at your option) any later version.
|
2013-05-19 16:37:30 +02:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
2012-02-29 05:30:06 +01:00
|
|
|
* for more details.
|
2013-05-19 16:37:30 +02:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
2012-02-29 05:30:06 +01:00
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PIOS_RFM22B_H
|
|
|
|
#define PIOS_RFM22B_H
|
|
|
|
|
2012-09-17 04:33:30 +02:00
|
|
|
#include <packet_handler.h>
|
2012-11-26 03:40:49 +01:00
|
|
|
#include <oplinksettings.h>
|
2012-09-17 04:33:30 +02:00
|
|
|
|
2013-04-06 02:32:15 +02:00
|
|
|
/* Constant definitions */
|
2013-05-19 16:37:30 +02:00
|
|
|
enum gpio_direction { GPIO0_TX_GPIO1_RX, GPIO0_RX_GPIO1_TX };
|
2012-09-05 06:22:56 +02:00
|
|
|
|
2012-02-29 05:30:06 +01:00
|
|
|
/* Global Types */
|
2012-04-11 05:22:53 +02:00
|
|
|
struct pios_rfm22b_cfg {
|
2013-05-19 16:37:30 +02:00
|
|
|
const struct pios_spi_cfg *spi_cfg; /* Pointer to SPI interface configuration */
|
|
|
|
const struct pios_exti_cfg *exti_cfg; /* Pointer to the EXTI configuration */
|
2013-04-13 18:43:50 +02:00
|
|
|
uint8_t RFXtalCap;
|
|
|
|
uint8_t slave_num;
|
|
|
|
enum gpio_direction gpio_direction;
|
2012-04-11 05:22:53 +02:00
|
|
|
};
|
|
|
|
|
2012-10-04 05:03:35 +02:00
|
|
|
enum rfm22b_tx_power {
|
2013-05-19 16:37:30 +02:00
|
|
|
RFM22_tx_pwr_txpow_0 = 0x00, // +1dBm .. 1.25mW
|
|
|
|
RFM22_tx_pwr_txpow_1 = 0x01, // +2dBm .. 1.6mW
|
|
|
|
RFM22_tx_pwr_txpow_2 = 0x02, // +5dBm .. 3.16mW
|
|
|
|
RFM22_tx_pwr_txpow_3 = 0x03, // +8dBm .. 6.3mW
|
|
|
|
RFM22_tx_pwr_txpow_4 = 0x04, // +11dBm .. 12.6mW
|
|
|
|
RFM22_tx_pwr_txpow_5 = 0x05, // +14dBm .. 25mW
|
|
|
|
RFM22_tx_pwr_txpow_6 = 0x06, // +17dBm .. 50mW
|
|
|
|
RFM22_tx_pwr_txpow_7 = 0x07 // +20dBm .. 100mW
|
2012-10-04 05:03:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum rfm22b_datarate {
|
2013-05-19 16:37:30 +02:00
|
|
|
RFM22_datarate_500 = 0,
|
|
|
|
RFM22_datarate_1000 = 1,
|
|
|
|
RFM22_datarate_2000 = 2,
|
|
|
|
RFM22_datarate_4000 = 3,
|
|
|
|
RFM22_datarate_8000 = 4,
|
|
|
|
RFM22_datarate_9600 = 5,
|
|
|
|
RFM22_datarate_16000 = 6,
|
|
|
|
RFM22_datarate_19200 = 7,
|
|
|
|
RFM22_datarate_24000 = 8,
|
|
|
|
RFM22_datarate_32000 = 9,
|
|
|
|
RFM22_datarate_57600 = 10,
|
|
|
|
RFM22_datarate_64000 = 11,
|
2013-04-13 18:43:50 +02:00
|
|
|
RFM22_datarate_128000 = 12,
|
|
|
|
RFM22_datarate_192000 = 13,
|
|
|
|
RFM22_datarate_256000 = 14,
|
2012-10-04 05:03:35 +02:00
|
|
|
};
|
|
|
|
|
2013-04-26 05:57:17 +02:00
|
|
|
typedef enum {
|
|
|
|
PIOS_RFM22B_INT_FAILURE,
|
|
|
|
PIOS_RFM22B_INT_SUCCESS,
|
|
|
|
PIOS_RFM22B_TX_COMPLETE,
|
|
|
|
PIOS_RFM22B_RX_COMPLETE
|
|
|
|
} pios_rfm22b_int_result;
|
|
|
|
|
2012-10-13 21:06:17 +02:00
|
|
|
struct rfm22b_stats {
|
2013-04-13 18:43:50 +02:00
|
|
|
uint16_t packets_per_sec;
|
|
|
|
uint16_t tx_byte_count;
|
|
|
|
uint16_t rx_byte_count;
|
|
|
|
uint16_t tx_seq;
|
|
|
|
uint16_t rx_seq;
|
2013-05-19 16:37:30 +02:00
|
|
|
uint8_t rx_good;
|
|
|
|
uint8_t rx_corrected;
|
|
|
|
uint8_t rx_error;
|
|
|
|
uint8_t rx_missed;
|
|
|
|
uint8_t rx_failure;
|
|
|
|
uint8_t tx_dropped;
|
|
|
|
uint8_t tx_resent;
|
|
|
|
uint8_t tx_failure;
|
|
|
|
uint8_t resets;
|
|
|
|
uint8_t timeouts;
|
|
|
|
uint8_t link_quality;
|
|
|
|
int8_t rssi;
|
|
|
|
int8_t afc_correction;
|
|
|
|
uint8_t link_state;
|
2012-10-13 21:06:17 +02:00
|
|
|
};
|
|
|
|
|
2012-11-26 03:40:49 +01:00
|
|
|
/* Callback function prototypes */
|
2013-02-18 02:49:13 +01:00
|
|
|
typedef void (*PIOS_RFM22B_ComConfigCallback)(OPLinkSettingsRemoteMainPortOptions main_port, OPLinkSettingsRemoteFlexiPortOptions flexi_port,
|
2013-05-22 04:48:21 +02:00
|
|
|
OPLinkSettingsRemoteVCPPortOptions vcp_port, OPLinkSettingsComSpeedOptions com_speed);
|
2012-11-26 03:40:49 +01:00
|
|
|
|
2012-02-29 05:30:06 +01:00
|
|
|
/* Public Functions */
|
2012-09-05 07:25:06 +02:00
|
|
|
extern int32_t PIOS_RFM22B_Init(uint32_t *rfb22b_id, uint32_t spi_id, uint32_t slave_num, const struct pios_rfm22b_cfg *cfg);
|
2013-01-31 14:37:03 +01:00
|
|
|
extern void PIOS_RFM22B_Reinit(uint32_t rfb22b_id);
|
2012-10-04 05:03:35 +02:00
|
|
|
extern void PIOS_RFM22B_SetTxPower(uint32_t rfm22b_id, enum rfm22b_tx_power tx_pwr);
|
2013-04-06 02:32:15 +02:00
|
|
|
extern void PIOS_RFM22B_SetFrequencyRange(uint32_t rfm22b_id, uint32_t min_freq, uint32_t max_freq, uint32_t step_size);
|
|
|
|
extern void PIOS_RFM22B_SetInitialFrequency(uint32_t rfm22b_id, uint32_t init_freq);
|
2012-10-04 05:03:35 +02:00
|
|
|
extern void PIOS_RFM22B_SetDestinationId(uint32_t rfm22b_id, uint32_t dest_id);
|
2012-11-26 03:40:49 +01:00
|
|
|
extern void PIOS_RFM22B_SetComConfigCallback(uint32_t rfm22b_id, PIOS_RFM22B_ComConfigCallback cb);
|
2013-02-18 02:49:13 +01:00
|
|
|
extern void PIOS_RFM22B_SetBindings(uint32_t rfm22b_id, const uint32_t bindingPairIDs[], const uint8_t mainPortSettings[],
|
2013-05-19 16:37:30 +02:00
|
|
|
const uint8_t flexiPortSettings[], const uint8_t vcpPortSettings[], const uint8_t comSpeeds[]);
|
2012-04-11 05:22:53 +02:00
|
|
|
extern uint32_t PIOS_RFM22B_DeviceID(uint32_t rfb22b_id);
|
2013-01-31 14:37:03 +01:00
|
|
|
extern bool PIOS_RFM22B_IsCoordinator(uint32_t rfb22b_id);
|
2012-10-13 21:06:17 +02:00
|
|
|
extern void PIOS_RFM22B_GetStats(uint32_t rfm22b_id, struct rfm22b_stats *stats);
|
2012-10-20 20:48:22 +02:00
|
|
|
extern uint8_t PIOS_RFM2B_GetPairStats(uint32_t rfm22b_id, uint32_t *device_ids, int8_t *RSSIs, uint8_t max_pairs);
|
2013-04-26 05:57:17 +02:00
|
|
|
extern bool PIOS_RFM22B_InRxWait(uint32_t rfb22b_id);
|
2012-10-26 23:25:41 +02:00
|
|
|
extern bool PIOS_RFM22B_LinkStatus(uint32_t rfm22b_id);
|
2013-04-26 05:57:17 +02:00
|
|
|
extern bool PIOS_RFM22B_ReceivePacket(uint32_t rfm22b_id, PHPacketHandle p);
|
2013-04-22 02:12:55 +02:00
|
|
|
extern bool PIOS_RFM22B_TransmitPacket(uint32_t rfm22b_id, PHPacketHandle p);
|
2013-04-26 05:57:17 +02:00
|
|
|
extern pios_rfm22b_int_result PIOS_RFM22B_ProcessTx(uint32_t rfm22b_id);
|
|
|
|
extern pios_rfm22b_int_result PIOS_RFM22B_ProcessRx(uint32_t rfm22b_id);
|
2012-10-20 20:48:22 +02:00
|
|
|
|
|
|
|
/* Global Variables */
|
|
|
|
extern const struct pios_com_driver pios_rfm22b_com_driver;
|
2012-02-29 05:30:06 +01:00
|
|
|
|
|
|
|
#endif /* PIOS_RFM22B_H */
|
|
|
|
|
|
|
|
/**
|
2013-04-13 18:43:50 +02:00
|
|
|
* @}
|
|
|
|
* @}
|
|
|
|
*/
|