mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
Started to write the PPM, spectrum scanner and continuous packet stream modules.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2731 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
56d4d54a97
commit
9a5d099a79
@ -114,6 +114,9 @@ SRC += $(HOME_DIR)/crc.c
|
||||
SRC += $(HOME_DIR)/aes.c
|
||||
SRC += $(HOME_DIR)/rfm22b.c
|
||||
SRC += $(HOME_DIR)/packet_handler.c
|
||||
SRC += $(HOME_DIR)/stream.c
|
||||
SRC += $(HOME_DIR)/scan_spectrum.c
|
||||
SRC += $(HOME_DIR)/ppm.c
|
||||
SRC += $(HOME_DIR)/transparent_comms.c
|
||||
#SRC += $(HOME_DIR)/api_comms.c
|
||||
SRC += $(HOME_DIR)/api_config.c
|
||||
|
39
flight/PipXtreme/inc/ppm.h
Normal file
39
flight/PipXtreme/inc/ppm.h
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file ppm.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Sends or Receives the ppm values to/from the remote unit
|
||||
* @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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* for more details.
|
||||
*
|
||||
* 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.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef PPM_H_
|
||||
#define PPM_H_
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
// *************************************************************
|
||||
|
||||
void ppm_1ms_tick(void);
|
||||
void ppm_process(void);
|
||||
void ppm_init(void);
|
||||
|
||||
// *************************************************************
|
||||
|
||||
#endif
|
@ -36,8 +36,8 @@
|
||||
|
||||
// ************************************
|
||||
|
||||
#define rfm22_min_carrier_frequency_Hz 240000000ul
|
||||
#define rfm22_max_carrier_frequency_Hz 930000000ul
|
||||
#define RFM22_MIN_CARRIER_FREQUENCY_HZ 240000000ul
|
||||
#define RFM22_MAX_CARRIER_FREQUENCY_HZ 930000000ul
|
||||
|
||||
// ************************************
|
||||
|
||||
@ -50,14 +50,14 @@ enum { RX_WAIT_PREAMBLE_MODE = 0,
|
||||
|
||||
// ************************************
|
||||
|
||||
#define bit0 (1u << 0)
|
||||
#define bit1 (1u << 1)
|
||||
#define bit2 (1u << 2)
|
||||
#define bit3 (1u << 3)
|
||||
#define bit4 (1u << 4)
|
||||
#define bit5 (1u << 5)
|
||||
#define bit6 (1u << 6)
|
||||
#define bit7 (1u << 7)
|
||||
#define BIT0 (1u << 0)
|
||||
#define BIT1 (1u << 1)
|
||||
#define BIT2 (1u << 2)
|
||||
#define BIT3 (1u << 3)
|
||||
#define BIT4 (1u << 4)
|
||||
#define BIT5 (1u << 5)
|
||||
#define BIT6 (1u << 6)
|
||||
#define BIT7 (1u << 7)
|
||||
|
||||
// ************************************
|
||||
|
||||
@ -80,44 +80,44 @@ enum { RX_WAIT_PREAMBLE_MODE = 0,
|
||||
#define rfm22_ds_ffovfl 0x80 // RX/TX FIFO Overflow Status
|
||||
|
||||
#define rfm22_interrupt_status1 0x03 // R
|
||||
#define rfm22_is1_icrerror bit0 // CRC Error. When set to 1 the cyclic redundancy check is failed.
|
||||
#define rfm22_is1_ipkvalid bit1 // Valid Packet Received.When set to 1 a valid packet has been received.
|
||||
#define rfm22_is1_ipksent bit2 // Packet Sent Interrupt. When set to1 a valid packet has been transmitted.
|
||||
#define rfm22_is1_iext bit3 // External Interrupt. When set to 1 an interrupt occurred on one of the GPIO’s if it is programmed so. The status can be checked in register 0Eh. See GPIOx Configuration section for the details.
|
||||
#define rfm22_is1_irxffafull bit4 // RX FIFO Almost Full.When set to 1 the RX FIFO has met its almost full threshold and needs to be read by the microcontroller.
|
||||
#define rfm22_is1_ixtffaem bit5 // TX FIFO Almost Empty. When set to 1 the TX FIFO is almost empty and needs to be filled.
|
||||
#define rfm22_is1_itxffafull bit6 // TX FIFO Almost Full. When set to 1 the TX FIFO has met its almost full threshold and needs to be transmitted.
|
||||
#define rfm22_is1_ifferr bit7 // FIFO Underflow/Overflow Error. When set to 1 the TX or RX FIFO has overflowed or underflowed.
|
||||
#define rfm22_is1_icrerror BIT0 // CRC Error. When set to 1 the cyclic redundancy check is failed.
|
||||
#define rfm22_is1_ipkvalid BIT1 // Valid Packet Received.When set to 1 a valid packet has been received.
|
||||
#define rfm22_is1_ipksent BIT2 // Packet Sent Interrupt. When set to1 a valid packet has been transmitted.
|
||||
#define rfm22_is1_iext BIT3 // External Interrupt. When set to 1 an interrupt occurred on one of the GPIO’s if it is programmed so. The status can be checked in register 0Eh. See GPIOx Configuration section for the details.
|
||||
#define rfm22_is1_irxffafull BIT4 // RX FIFO Almost Full.When set to 1 the RX FIFO has met its almost full threshold and needs to be read by the microcontroller.
|
||||
#define rfm22_is1_ixtffaem BIT5 // TX FIFO Almost Empty. When set to 1 the TX FIFO is almost empty and needs to be filled.
|
||||
#define rfm22_is1_itxffafull BIT6 // TX FIFO Almost Full. When set to 1 the TX FIFO has met its almost full threshold and needs to be transmitted.
|
||||
#define rfm22_is1_ifferr BIT7 // FIFO Underflow/Overflow Error. When set to 1 the TX or RX FIFO has overflowed or underflowed.
|
||||
|
||||
#define rfm22_interrupt_status2 0x04 // R
|
||||
#define rfm22_is2_ipor bit0 // Power-on-Reset (POR). When the chip detects a Power on Reset above the desired setting this bit will be set to 1.
|
||||
#define rfm22_is2_ichiprdy bit1 // Chip Ready (XTAL). When a chip ready event has been detected this bit will be set to 1.
|
||||
#define rfm22_is2_ilbd bit2 // Low Battery Detect. When a low battery event is been detected this bit will be set to 1. This interrupt event is saved even if it is not enabled by the mask register bit and causes an interrupt after it is enabled.
|
||||
#define rfm22_is2_iwut bit3 // Wake-Up-Timer. On the expiration of programmed wake-up timer this bit will be set to 1.
|
||||
#define rfm22_is2_irssi bit4 // RSSI. When RSSI level exceeds the programmed threshold this bit will be set to 1.
|
||||
#define rfm22_is2_ipreainval bit5 // Invalid Preamble Detected. When the preamble is not found within a period of time set by the invalid preamble detection threshold in Register 54h, this bit will be set to 1.
|
||||
#define rfm22_is2_ipreaval bit6 // Valid Preamble Detected. When a preamble is detected this bit will be set to 1.
|
||||
#define rfm22_is2_iswdet bit7 // Sync Word Detected. When a sync word is detected this bit will be set to 1.
|
||||
#define rfm22_is2_ipor BIT0 // Power-on-Reset (POR). When the chip detects a Power on Reset above the desired setting this bit will be set to 1.
|
||||
#define rfm22_is2_ichiprdy BIT1 // Chip Ready (XTAL). When a chip ready event has been detected this bit will be set to 1.
|
||||
#define rfm22_is2_ilbd BIT2 // Low Battery Detect. When a low battery event is been detected this bit will be set to 1. This interrupt event is saved even if it is not enabled by the mask register bit and causes an interrupt after it is enabled.
|
||||
#define rfm22_is2_iwut BIT3 // Wake-Up-Timer. On the expiration of programmed wake-up timer this bit will be set to 1.
|
||||
#define rfm22_is2_irssi BIT4 // RSSI. When RSSI level exceeds the programmed threshold this bit will be set to 1.
|
||||
#define rfm22_is2_ipreainval BIT5 // Invalid Preamble Detected. When the preamble is not found within a period of time set by the invalid preamble detection threshold in Register 54h, this bit will be set to 1.
|
||||
#define rfm22_is2_ipreaval BIT6 // Valid Preamble Detected. When a preamble is detected this bit will be set to 1.
|
||||
#define rfm22_is2_iswdet BIT7 // Sync Word Detected. When a sync word is detected this bit will be set to 1.
|
||||
|
||||
#define rfm22_interrupt_enable1 0x05 // R/W
|
||||
#define rfm22_ie1_encrcerror bit0 // Enable CRC Error. When set to 1 the CRC Error interrupt will be enabled.
|
||||
#define rfm22_ie1_enpkvalid bit1 // Enable Valid Packet Received. When ipkvalid = 1 the Valid Packet Received Interrupt will be enabled.
|
||||
#define rfm22_ie1_enpksent bit2 // Enable Packet Sent. When ipksent =1 the Packet Sense Interrupt will be enabled.
|
||||
#define rfm22_ie1_enext bit3 // Enable External Interrupt. When set to 1 the External Interrupt will be enabled.
|
||||
#define rfm22_ie1_enrxffafull bit4 // Enable RX FIFO Almost Full. When set to 1 the RX FIFO Almost Full interrupt will be enabled.
|
||||
#define rfm22_ie1_entxffaem bit5 // Enable TX FIFO Almost Empty. When set to 1 the TX FIFO Almost Empty interrupt will be enabled.
|
||||
#define rfm22_ie1_entxffafull bit6 // Enable TX FIFO Almost Full. When set to 1 the TX FIFO Almost Full interrupt will be enabled.
|
||||
#define rfm22_ie1_enfferr bit7 // Enable FIFO Underflow/Overflow. When set to 1 the FIFO Underflow/Overflow interrupt will be enabled.
|
||||
#define rfm22_ie1_encrcerror BIT0 // Enable CRC Error. When set to 1 the CRC Error interrupt will be enabled.
|
||||
#define rfm22_ie1_enpkvalid BIT1 // Enable Valid Packet Received. When ipkvalid = 1 the Valid Packet Received Interrupt will be enabled.
|
||||
#define rfm22_ie1_enpksent BIT2 // Enable Packet Sent. When ipksent =1 the Packet Sense Interrupt will be enabled.
|
||||
#define rfm22_ie1_enext BIT3 // Enable External Interrupt. When set to 1 the External Interrupt will be enabled.
|
||||
#define rfm22_ie1_enrxffafull BIT4 // Enable RX FIFO Almost Full. When set to 1 the RX FIFO Almost Full interrupt will be enabled.
|
||||
#define rfm22_ie1_entxffaem BIT5 // Enable TX FIFO Almost Empty. When set to 1 the TX FIFO Almost Empty interrupt will be enabled.
|
||||
#define rfm22_ie1_entxffafull BIT6 // Enable TX FIFO Almost Full. When set to 1 the TX FIFO Almost Full interrupt will be enabled.
|
||||
#define rfm22_ie1_enfferr BIT7 // Enable FIFO Underflow/Overflow. When set to 1 the FIFO Underflow/Overflow interrupt will be enabled.
|
||||
|
||||
#define rfm22_interrupt_enable2 0x06 // R/W
|
||||
#define rfm22_ie2_enpor bit0 // Enable POR. When set to 1 the POR interrupt will be enabled.
|
||||
#define rfm22_ie2_enchiprdy bit1 // Enable Chip Ready (XTAL). When set to 1 the Chip Ready interrupt will be enabled.
|
||||
#define rfm22_ie2_enlbd bit2 // Enable Low Battery Detect. When set to 1 the Low Battery Detect interrupt will be enabled.
|
||||
#define rfm22_ie2_enwut bit3 // Enable Wake-Up Timer. When set to 1 the Wake-Up Timer interrupt will be enabled.
|
||||
#define rfm22_ie2_enrssi bit4 // Enable RSSI. When set to 1 the RSSI Interrupt will be enabled.
|
||||
#define rfm22_ie2_enpreainval bit5 // Enable Invalid Preamble Detected. When mpreadet =1 the Invalid Preamble Detected Interrupt will be enabled.
|
||||
#define rfm22_ie2_enpreaval bit6 // Enable Valid Preamble Detected. When mpreadet =1 the Valid Preamble Detected Interrupt will be enabled.
|
||||
#define rfm22_ie2_enswdet bit7 // Enable Sync Word Detected. When mpreadet =1 the Preamble Detected Interrupt will be enabled.
|
||||
#define rfm22_ie2_enpor BIT0 // Enable POR. When set to 1 the POR interrupt will be enabled.
|
||||
#define rfm22_ie2_enchiprdy BIT1 // Enable Chip Ready (XTAL). When set to 1 the Chip Ready interrupt will be enabled.
|
||||
#define rfm22_ie2_enlbd BIT2 // Enable Low Battery Detect. When set to 1 the Low Battery Detect interrupt will be enabled.
|
||||
#define rfm22_ie2_enwut BIT3 // Enable Wake-Up Timer. When set to 1 the Wake-Up Timer interrupt will be enabled.
|
||||
#define rfm22_ie2_enrssi BIT4 // Enable RSSI. When set to 1 the RSSI Interrupt will be enabled.
|
||||
#define rfm22_ie2_enpreainval BIT5 // Enable Invalid Preamble Detected. When mpreadet =1 the Invalid Preamble Detected Interrupt will be enabled.
|
||||
#define rfm22_ie2_enpreaval BIT6 // Enable Valid Preamble Detected. When mpreadet =1 the Valid Preamble Detected Interrupt will be enabled.
|
||||
#define rfm22_ie2_enswdet BIT7 // Enable Sync Word Detected. When mpreadet =1 the Preamble Detected Interrupt will be enabled.
|
||||
|
||||
#define rfm22_op_and_func_ctrl1 0x07 // R/W
|
||||
#define rfm22_opfc1_xton 0x01 // READY Mode (Xtal is ON).
|
||||
@ -572,15 +572,6 @@ enum { RX_WAIT_PREAMBLE_MODE = 0,
|
||||
|
||||
// ************************************
|
||||
|
||||
void rfm22_setFreqCalibration(uint8_t value);
|
||||
uint8_t rfm22_getFreqCalibration(void);
|
||||
|
||||
void rfm22_setDatarate(uint32_t datarate_bps);
|
||||
uint32_t rfm22_getDatarate(void);
|
||||
|
||||
void rfm22_setTxPower(uint8_t tx_pwr);
|
||||
uint8_t rfm22_getTxPower(void);
|
||||
|
||||
void rfm22_setNominalCarrierFrequency(uint32_t frequency_hz);
|
||||
uint32_t rfm22_getNominalCarrierFrequency(void);
|
||||
|
||||
@ -589,6 +580,9 @@ float rfm22_getFrequencyStepSize(void);
|
||||
void rfm22_setFreqHopChannel(uint8_t channel);
|
||||
uint8_t rfm22_freqHopChannel(void);
|
||||
|
||||
void rfm22_setDatarate(uint32_t datarate_bps);
|
||||
uint32_t rfm22_getDatarate(void);
|
||||
|
||||
int16_t rfm22_receivedRSSI(void);
|
||||
int32_t rfm22_receivedAFCHz(void);
|
||||
uint16_t rfm22_receivedLength(void);
|
||||
@ -597,6 +591,12 @@ void rfm22_receivedDone(void);
|
||||
|
||||
int32_t rfm22_sendData(void *data, uint16_t length, bool send_immediately);
|
||||
|
||||
void rfm22_setFreqCalibration(uint8_t value);
|
||||
uint8_t rfm22_getFreqCalibration(void);
|
||||
|
||||
void rfm22_setTxPower(uint8_t tx_pwr);
|
||||
uint8_t rfm22_getTxPower(void);
|
||||
|
||||
void rfm22_setTxCarrierMode(void);
|
||||
void rfm22_setTxPNMode(void);
|
||||
|
||||
|
39
flight/PipXtreme/inc/scan_spectrum.h
Normal file
39
flight/PipXtreme/inc/scan_spectrum.h
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file scan_spectrum.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Puts module into Rx mode and scan across the RF spectrum monitoring the RSSI
|
||||
* @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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* for more details.
|
||||
*
|
||||
* 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.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef SCAN_SPECTRUM_H_
|
||||
#define SCAN_SPECTRUM_H_
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
// *************************************************************
|
||||
|
||||
void ss_1ms_tick(void);
|
||||
void ss_process(void);
|
||||
void ss_init(void);
|
||||
|
||||
// *************************************************************
|
||||
|
||||
#endif
|
39
flight/PipXtreme/inc/stream.h
Normal file
39
flight/PipXtreme/inc/stream.h
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file stream.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Sends or Receives a continuous packet stream to/from the remote unit
|
||||
* @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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* for more details.
|
||||
*
|
||||
* 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.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef STREAM_H_
|
||||
#define STREAM_H_
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
// *************************************************************
|
||||
|
||||
void stream_1ms_tick(void);
|
||||
void stream_process(void);
|
||||
void stream_init(void);
|
||||
|
||||
// *************************************************************
|
||||
|
||||
#endif
|
@ -37,6 +37,9 @@
|
||||
#include "aes.h"
|
||||
#include "rfm22b.h"
|
||||
#include "packet_handler.h"
|
||||
#include "stream.h"
|
||||
#include "scan_spectrum.h"
|
||||
#include "ppm.h"
|
||||
#include "transparent_comms.h"
|
||||
//#include "api_comms.h"
|
||||
#include "api_config.h"
|
||||
@ -267,9 +270,23 @@ void TIMER_INT_FUNC(void)
|
||||
|
||||
// ***********
|
||||
|
||||
uint8_t mode = saved_settings.mode;
|
||||
// modeTxBlankCarrierTest, // blank carrier Tx mode (for calibrating the carrier frequency say)
|
||||
// modeTxSpectrumTest // pseudo random Tx data mode (for checking the Tx carrier spectrum)
|
||||
|
||||
rfm22_1ms_tick(); // rf module tick
|
||||
|
||||
ph_1ms_tick(); // packet handler tick
|
||||
if (mode == modeNormal)
|
||||
ph_1ms_tick(); // packet handler tick
|
||||
|
||||
if (mode == modeStreamTx || mode == modeStreamRx)
|
||||
stream_1ms_tick(); // continuous data stream tick
|
||||
|
||||
if (mode == modeScanSpectrum)
|
||||
ss_1ms_tick(); // spectrum scan tick
|
||||
|
||||
if (mode == modePPMTx || mode == modePPMRx)
|
||||
ppm_1ms_tick(); // ppm tick
|
||||
|
||||
if (!API_Mode)
|
||||
trans_1ms_tick(); // transparent communications tick
|
||||
@ -840,9 +857,14 @@ int main()
|
||||
#endif
|
||||
|
||||
// *************
|
||||
// initialize the RF module
|
||||
|
||||
init_RF_module();
|
||||
init_RF_module(); // initialise the RF module
|
||||
|
||||
stream_init(); // initialise the continuous packet stream module
|
||||
|
||||
ppm_init(); // initialise the ppm module
|
||||
|
||||
ss_init(); // initialise the spectrum scanning module
|
||||
|
||||
// *************
|
||||
|
||||
@ -914,7 +936,21 @@ int main()
|
||||
|
||||
rfm22_process(); // rf hardware layer processing
|
||||
|
||||
ph_process(); // packet handler processing
|
||||
uint8_t mode = saved_settings.mode;
|
||||
// modeTxBlankCarrierTest, // blank carrier Tx mode (for calibrating the carrier frequency say)
|
||||
// modeTxSpectrumTest // pseudo random Tx data mode (for checking the Tx carrier spectrum)
|
||||
|
||||
if (mode == modeNormal)
|
||||
ph_process(); // packet handler processing
|
||||
|
||||
if (mode == modeStreamTx || mode == modeStreamRx)
|
||||
stream_process(); // continuous data stream processing
|
||||
|
||||
if (mode == modeScanSpectrum)
|
||||
ss_process(); // spectrum scan processing
|
||||
|
||||
if (mode == modePPMTx || mode == modePPMRx)
|
||||
ppm_process(); // ppm processing
|
||||
|
||||
if (!API_Mode)
|
||||
trans_process(); // tranparent local communication processing (serial port and usb port)
|
||||
|
@ -1533,7 +1533,7 @@ void ph_set_remote_encryption(int connection_index, bool enabled, const void *ke
|
||||
void ph_1ms_tick(void)
|
||||
{ // call this once every ms
|
||||
|
||||
// help randomize the encrypter cbc bytes
|
||||
// help randomize the encryptor cbc bytes
|
||||
register uint32_t *cbc = (uint32_t *)&enc_cbc;
|
||||
for (int i = 0; i < sizeof(enc_cbc) / 4; i++)
|
||||
{
|
||||
|
58
flight/PipXtreme/ppm.c
Normal file
58
flight/PipXtreme/ppm.c
Normal file
@ -0,0 +1,58 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file ppm.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Sends or Receives the ppm values to/from the remote unit
|
||||
* @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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* for more details.
|
||||
*
|
||||
* 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.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
//#include <string.h> // memmove
|
||||
|
||||
#include "main.h"
|
||||
#include "rfm22b.h"
|
||||
#include "saved_settings.h"
|
||||
#include "ppm.h"
|
||||
|
||||
#if defined(PIOS_COM_DEBUG)
|
||||
// #define PPM_DEBUG
|
||||
#endif
|
||||
|
||||
// *************************************************************
|
||||
// can be called from an interrupt if you wish
|
||||
|
||||
void ppm_1ms_tick(void)
|
||||
{ // call this once every ms
|
||||
}
|
||||
|
||||
// *************************************************************
|
||||
// call this from the main loop (not interrupt) as often as possible
|
||||
|
||||
void ppm_process(void)
|
||||
{
|
||||
}
|
||||
|
||||
// *************************************************************
|
||||
|
||||
void ppm_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// *************************************************************
|
@ -182,7 +182,7 @@ uint32_t carrier_datarate_bps; // the RF data rate we are using
|
||||
uint32_t rf_bandwidth_used; // the RF bandwidth currently used
|
||||
|
||||
uint8_t hbsel; // holds the hbsel (1 or 2)
|
||||
float frequency_step_size; //
|
||||
float frequency_step_size; // holds the minimum frequency step size
|
||||
|
||||
uint8_t frequency_hop_channel; // current frequency hop channel
|
||||
|
||||
@ -419,6 +419,107 @@ uint8_t rfm22_getFreqCalibration(void)
|
||||
return osc_load_cap;
|
||||
}
|
||||
|
||||
// ************************************
|
||||
// set/get the current tx power setting
|
||||
|
||||
void rfm22_setTxPower(uint8_t tx_pwr)
|
||||
{
|
||||
switch (tx_pwr)
|
||||
{
|
||||
case 0: tx_power = rfm22_tx_pwr_txpow_0; break; // +1dBm ... 1.25mW
|
||||
case 1: tx_power = rfm22_tx_pwr_txpow_1; break; // +2dBm ... 1.6mW
|
||||
case 2: tx_power = rfm22_tx_pwr_txpow_2; break; // +5dBm ... 3.16mW
|
||||
case 3: tx_power = rfm22_tx_pwr_txpow_3; break; // +8dBm ... 6.3mW
|
||||
case 4: tx_power = rfm22_tx_pwr_txpow_4; break; // +11dBm .. 12.6mW
|
||||
case 5: tx_power = rfm22_tx_pwr_txpow_5; break; // +14dBm .. 25mW
|
||||
case 6: tx_power = rfm22_tx_pwr_txpow_6; break; // +17dBm .. 50mW
|
||||
case 7: tx_power = rfm22_tx_pwr_txpow_7; break; // +20dBm .. 100mW
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t rfm22_getTxPower(void)
|
||||
{
|
||||
return tx_power;
|
||||
}
|
||||
|
||||
// ************************************
|
||||
|
||||
void rfm22_setNominalCarrierFrequency(uint32_t frequency_hz)
|
||||
{
|
||||
|
||||
#if defined(RFM22_EXT_INT_USE)
|
||||
exec_using_spi = TRUE;
|
||||
#endif
|
||||
|
||||
// *******
|
||||
|
||||
if (frequency_hz < lower_carrier_frequency_limit_Hz) frequency_hz = lower_carrier_frequency_limit_Hz;
|
||||
else
|
||||
if (frequency_hz > upper_carrier_frequency_limit_Hz) frequency_hz = upper_carrier_frequency_limit_Hz;
|
||||
|
||||
carrier_frequency_hz = frequency_hz;
|
||||
|
||||
if (frequency_hz < 480000000)
|
||||
hbsel = 1;
|
||||
else
|
||||
hbsel = 2;
|
||||
uint8_t fb = (uint8_t)(frequency_hz / (10000000 * hbsel));
|
||||
|
||||
uint32_t fc = (uint32_t)(frequency_hz - (10000000 * hbsel * fb));
|
||||
|
||||
fc = (fc * 64u) / (10000ul * hbsel);
|
||||
fb -= 24;
|
||||
|
||||
if (hbsel > 1)
|
||||
fb |= rfm22_fbs_hbsel;
|
||||
|
||||
fb |= rfm22_fbs_sbse; // is this the RX LO polarity?
|
||||
|
||||
frequency_step_size = 156.25f * hbsel;
|
||||
|
||||
rfm22_write(rfm22_frequency_hopping_channel_select, frequency_hop_channel); // frequency hoppping channel (0-255)
|
||||
|
||||
rfm22_write(rfm22_frequency_offset1, 0); // no frequency offset
|
||||
rfm22_write(rfm22_frequency_offset2, 0); // no frequency offset
|
||||
|
||||
rfm22_write(rfm22_frequency_band_select, fb); // set the carrier frequency
|
||||
rfm22_write(rfm22_nominal_carrier_frequency1, fc >> 8); // " "
|
||||
rfm22_write(rfm22_nominal_carrier_frequency0, fc & 0xff); // " "
|
||||
|
||||
// *******
|
||||
|
||||
#if defined(RFM22_DEBUG)
|
||||
DEBUG_PRINTF("rf setFreq: %0.2f\r\n", carrier_frequency_hz);
|
||||
#endif
|
||||
|
||||
#if defined(RFM22_EXT_INT_USE)
|
||||
exec_using_spi = FALSE;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
uint32_t rfm22_getNominalCarrierFrequency(void)
|
||||
{
|
||||
return carrier_frequency_hz;
|
||||
}
|
||||
|
||||
float rfm22_getFrequencyStepSize(void)
|
||||
{
|
||||
return frequency_step_size;
|
||||
}
|
||||
|
||||
void rfm22_setFreqHopChannel(uint8_t channel)
|
||||
{ // set the frequency hopping channel
|
||||
frequency_hop_channel = channel;
|
||||
rfm22_write(rfm22_frequency_hopping_channel_select, frequency_hop_channel);
|
||||
}
|
||||
|
||||
uint8_t rfm22_freqHopChannel(void)
|
||||
{ // return the current frequency hopping channel
|
||||
return frequency_hop_channel;
|
||||
}
|
||||
|
||||
// ************************************
|
||||
// radio datarate about 19200 Baud
|
||||
// radio frequency deviation 45kHz
|
||||
@ -555,107 +656,6 @@ uint32_t rfm22_getDatarate(void)
|
||||
return carrier_datarate_bps;
|
||||
}
|
||||
|
||||
// ************************************
|
||||
// set/get the current tx power setting
|
||||
|
||||
void rfm22_setTxPower(uint8_t tx_pwr)
|
||||
{
|
||||
switch (tx_pwr)
|
||||
{
|
||||
case 0: tx_power = rfm22_tx_pwr_txpow_0; break; // +1dBm ... 1.25mW
|
||||
case 1: tx_power = rfm22_tx_pwr_txpow_1; break; // +2dBm ... 1.6mW
|
||||
case 2: tx_power = rfm22_tx_pwr_txpow_2; break; // +5dBm ... 3.16mW
|
||||
case 3: tx_power = rfm22_tx_pwr_txpow_3; break; // +8dBm ... 6.3mW
|
||||
case 4: tx_power = rfm22_tx_pwr_txpow_4; break; // +11dBm .. 12.6mW
|
||||
case 5: tx_power = rfm22_tx_pwr_txpow_5; break; // +14dBm .. 25mW
|
||||
case 6: tx_power = rfm22_tx_pwr_txpow_6; break; // +17dBm .. 50mW
|
||||
case 7: tx_power = rfm22_tx_pwr_txpow_7; break; // +20dBm .. 100mW
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t rfm22_getTxPower(void)
|
||||
{
|
||||
return tx_power;
|
||||
}
|
||||
|
||||
// ************************************
|
||||
|
||||
void rfm22_setNominalCarrierFrequency(uint32_t frequency_hz)
|
||||
{
|
||||
|
||||
#if defined(RFM22_EXT_INT_USE)
|
||||
exec_using_spi = TRUE;
|
||||
#endif
|
||||
|
||||
// *******
|
||||
|
||||
if (frequency_hz < lower_carrier_frequency_limit_Hz) frequency_hz = lower_carrier_frequency_limit_Hz;
|
||||
else
|
||||
if (frequency_hz > upper_carrier_frequency_limit_Hz) frequency_hz = upper_carrier_frequency_limit_Hz;
|
||||
|
||||
carrier_frequency_hz = frequency_hz;
|
||||
|
||||
if (frequency_hz < 480000000)
|
||||
hbsel = 1;
|
||||
else
|
||||
hbsel = 2;
|
||||
uint8_t fb = (uint8_t)(frequency_hz / (10000000 * hbsel));
|
||||
|
||||
uint32_t fc = (uint32_t)(frequency_hz - (10000000 * hbsel * fb));
|
||||
|
||||
fc = (fc * 64u) / (10000ul * hbsel);
|
||||
fb -= 24;
|
||||
|
||||
if (hbsel > 1)
|
||||
fb |= rfm22_fbs_hbsel;
|
||||
|
||||
fb |= rfm22_fbs_sbse; // is this the RX LO polarity?
|
||||
|
||||
frequency_step_size = 156.25f * hbsel;
|
||||
|
||||
rfm22_write(rfm22_frequency_hopping_channel_select, frequency_hop_channel); // frequency hoppping channel (0-255)
|
||||
|
||||
rfm22_write(rfm22_frequency_offset1, 0); // no frequency offset
|
||||
rfm22_write(rfm22_frequency_offset2, 0); // no frequency offset
|
||||
|
||||
rfm22_write(rfm22_frequency_band_select, fb); // set the carrier frequency
|
||||
rfm22_write(rfm22_nominal_carrier_frequency1, fc >> 8); // " "
|
||||
rfm22_write(rfm22_nominal_carrier_frequency0, fc & 0xff); // " "
|
||||
|
||||
// *******
|
||||
|
||||
#if defined(RFM22_DEBUG)
|
||||
DEBUG_PRINTF("rf setFreq: %0.2f\r\n", carrier_frequency_hz);
|
||||
#endif
|
||||
|
||||
#if defined(RFM22_EXT_INT_USE)
|
||||
exec_using_spi = FALSE;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
uint32_t rfm22_getNominalCarrierFrequency(void)
|
||||
{
|
||||
return carrier_frequency_hz;
|
||||
}
|
||||
|
||||
float rfm22_getFrequencyStepSize(void)
|
||||
{
|
||||
return frequency_step_size;
|
||||
}
|
||||
|
||||
void rfm22_setFreqHopChannel(uint8_t channel)
|
||||
{ // set the frequency hopping channel
|
||||
frequency_hop_channel = channel;
|
||||
rfm22_write(rfm22_frequency_hopping_channel_select, frequency_hop_channel);
|
||||
}
|
||||
|
||||
uint8_t rfm22_freqHopChannel(void)
|
||||
{ // return the current frequency hopping channel
|
||||
return frequency_hop_channel;
|
||||
}
|
||||
|
||||
// ************************************
|
||||
|
||||
void rfm22_reenableRx(void)
|
||||
@ -1782,13 +1782,13 @@ int rfm22_init(uint32_t min_frequency_hz, uint32_t max_frequency_hz, uint32_t fr
|
||||
// ****************
|
||||
// set the minimum and maximum carrier frequency allowed
|
||||
|
||||
if (min_frequency_hz < rfm22_min_carrier_frequency_Hz) min_frequency_hz = rfm22_min_carrier_frequency_Hz;
|
||||
if (min_frequency_hz < RFM22_MIN_CARRIER_FREQUENCY_HZ) min_frequency_hz = RFM22_MIN_CARRIER_FREQUENCY_HZ;
|
||||
else
|
||||
if (min_frequency_hz > rfm22_max_carrier_frequency_Hz) min_frequency_hz = rfm22_max_carrier_frequency_Hz;
|
||||
if (min_frequency_hz > RFM22_MAX_CARRIER_FREQUENCY_HZ) min_frequency_hz = RFM22_MAX_CARRIER_FREQUENCY_HZ;
|
||||
|
||||
if (max_frequency_hz < rfm22_min_carrier_frequency_Hz) max_frequency_hz = rfm22_min_carrier_frequency_Hz;
|
||||
if (max_frequency_hz < RFM22_MIN_CARRIER_FREQUENCY_HZ) max_frequency_hz = RFM22_MIN_CARRIER_FREQUENCY_HZ;
|
||||
else
|
||||
if (max_frequency_hz > rfm22_max_carrier_frequency_Hz) max_frequency_hz = rfm22_max_carrier_frequency_Hz;
|
||||
if (max_frequency_hz > RFM22_MAX_CARRIER_FREQUENCY_HZ) max_frequency_hz = RFM22_MAX_CARRIER_FREQUENCY_HZ;
|
||||
|
||||
if (min_frequency_hz > max_frequency_hz)
|
||||
{ // swap them over
|
||||
|
58
flight/PipXtreme/scan_spectrum.c
Normal file
58
flight/PipXtreme/scan_spectrum.c
Normal file
@ -0,0 +1,58 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file scan_spectrum.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Puts module into Rx mode and scan across the RF spectrum monitoring the RSSI
|
||||
* @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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* for more details.
|
||||
*
|
||||
* 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.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
//#include <string.h> // memmove
|
||||
|
||||
#include "main.h"
|
||||
#include "rfm22b.h"
|
||||
#include "saved_settings.h"
|
||||
#include "scan_spectrum.h"
|
||||
|
||||
#if defined(PIOS_COM_DEBUG)
|
||||
// #define SS_DEBUG
|
||||
#endif
|
||||
|
||||
// *************************************************************
|
||||
// can be called from an interrupt if you wish
|
||||
|
||||
void ss_1ms_tick(void)
|
||||
{ // call this once every ms
|
||||
}
|
||||
|
||||
// *************************************************************
|
||||
// call this from the main loop (not interrupt) as often as possible
|
||||
|
||||
void ss_process(void)
|
||||
{
|
||||
}
|
||||
|
||||
// *************************************************************
|
||||
|
||||
void ss_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// *************************************************************
|
61
flight/PipXtreme/stream.c
Normal file
61
flight/PipXtreme/stream.c
Normal file
@ -0,0 +1,61 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file stream.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Sends or Receives a continuous packet stream to/from the remote unit
|
||||
* @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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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
|
||||
* for more details.
|
||||
*
|
||||
* 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.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
//#include <string.h> // memmove
|
||||
|
||||
#include "main.h"
|
||||
#include "rfm22b.h"
|
||||
#include "fifo_buffer.h"
|
||||
#include "aes.h"
|
||||
#include "crc.h"
|
||||
#include "saved_settings.h"
|
||||
#include "stream.h"
|
||||
|
||||
#if defined(PIOS_COM_DEBUG)
|
||||
// #define STREAM_DEBUG
|
||||
#endif
|
||||
|
||||
// *************************************************************
|
||||
// can be called from an interrupt if you wish
|
||||
|
||||
void stream_1ms_tick(void)
|
||||
{ // call this once every ms
|
||||
}
|
||||
|
||||
// *************************************************************
|
||||
// call this from the main loop (not interrupt) as often as possible
|
||||
|
||||
void stream_process(void)
|
||||
{
|
||||
}
|
||||
|
||||
// *************************************************************
|
||||
|
||||
void stream_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// *************************************************************
|
Loading…
x
Reference in New Issue
Block a user