mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
RFM22B/OPLink: Auto-configuration of remote com port now working.
This commit is contained in:
parent
6ffe518509
commit
fecc23eb49
@ -32,6 +32,7 @@
|
||||
|
||||
#include <uavobjectmanager.h>
|
||||
#include <gcsreceiver.h>
|
||||
#include <oplinksettings.h>
|
||||
|
||||
// Public defines / macros
|
||||
#define PHPacketSize(p) ((uint8_t*)(p->data) + p->header.data_size - (uint8_t*)p)
|
||||
@ -94,6 +95,8 @@ typedef struct {
|
||||
uint32_t min_frequency;
|
||||
uint32_t max_frequency;
|
||||
uint8_t max_tx_power;
|
||||
OPLinkSettingsOutputConnectionOptions port;
|
||||
OPLinkSettingsComSpeedOptions com_speed;
|
||||
uint8_t ecc[RS_ECC_NPARITY];
|
||||
} PHConnectionPacket, *PHConnectionPacketHandle;
|
||||
|
||||
|
@ -96,6 +96,7 @@ static int32_t UAVTalkSendHandler(uint8_t *buf, int32_t length);
|
||||
static int32_t RadioSendHandler(uint8_t *buf, int32_t length);
|
||||
static void ProcessInputStream(UAVTalkConnection connectionHandle, uint8_t rxbyte);
|
||||
static void queueEvent(xQueueHandle queue, void *obj, uint16_t instId, UAVObjEventType type);
|
||||
static void configureComCallback(OPLinkSettingsOutputConnectionOptions com_port, OPLinkSettingsComSpeedOptions com_speed);
|
||||
static void updateSettings();
|
||||
|
||||
// ****************
|
||||
@ -112,6 +113,9 @@ static int32_t RadioComBridgeStart(void)
|
||||
{
|
||||
if(data) {
|
||||
|
||||
// Configure the com port configuration callback
|
||||
PIOS_RFM22B_SetComConfigCallback(pios_rfm22b_id, &configureComCallback);
|
||||
|
||||
// Set the baudrates, etc.
|
||||
updateSettings();
|
||||
|
||||
@ -459,12 +463,54 @@ static void queueEvent(xQueueHandle queue, void *obj, uint16_t instId, UAVObjEve
|
||||
xQueueSend(queue, &ev, portMAX_DELAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the telemetry settings, called on startup.
|
||||
* FIXME: This should be in the TelemetrySettings object. But objects
|
||||
* have too much overhead yet. Also the telemetry has no any specific
|
||||
* settings, etc. Thus the HwSettings object which contains the
|
||||
* telemetry port speed is used for now.
|
||||
/**
|
||||
* Configure the output port based on a configuration event from the remote coordinator.
|
||||
* \param[in] com_port The com port to configure
|
||||
* \param[in] com_speed The com port speed
|
||||
*/
|
||||
static void configureComCallback(OPLinkSettingsOutputConnectionOptions com_port, OPLinkSettingsComSpeedOptions com_speed)
|
||||
{
|
||||
|
||||
// Get the settings.
|
||||
OPLinkSettingsData oplinkSettings;
|
||||
OPLinkSettingsGet(&oplinkSettings);
|
||||
|
||||
// Set the output telemetry port and speed.
|
||||
switch (com_port)
|
||||
{
|
||||
case OPLINKSETTINGS_OUTPUTCONNECTION_REMOTEHID:
|
||||
oplinkSettings.InputConnection = OPLINKSETTINGS_INPUTCONNECTION_HID;
|
||||
break;
|
||||
case OPLINKSETTINGS_OUTPUTCONNECTION_REMOTEVCP:
|
||||
oplinkSettings.InputConnection = OPLINKSETTINGS_INPUTCONNECTION_VCP;
|
||||
break;
|
||||
case OPLINKSETTINGS_OUTPUTCONNECTION_REMOTETELEMETRY:
|
||||
oplinkSettings.InputConnection = OPLINKSETTINGS_INPUTCONNECTION_TELEMETRY;
|
||||
break;
|
||||
case OPLINKSETTINGS_OUTPUTCONNECTION_REMOTEFLEXI:
|
||||
oplinkSettings.InputConnection = OPLINKSETTINGS_INPUTCONNECTION_FLEXI;
|
||||
break;
|
||||
case OPLINKSETTINGS_OUTPUTCONNECTION_TELEMETRY:
|
||||
oplinkSettings.InputConnection = OPLINKSETTINGS_INPUTCONNECTION_HID;
|
||||
break;
|
||||
case OPLINKSETTINGS_OUTPUTCONNECTION_FLEXI:
|
||||
oplinkSettings.InputConnection = OPLINKSETTINGS_INPUTCONNECTION_HID;
|
||||
break;
|
||||
}
|
||||
oplinkSettings.ComSpeed = com_speed;
|
||||
|
||||
// A non-coordinator modem should not set a remote telemetry connection.
|
||||
oplinkSettings.OutputConnection = OPLINKSETTINGS_OUTPUTCONNECTION_REMOTEHID;
|
||||
|
||||
// Update the OPLinkSettings object.
|
||||
OPLinkSettingsSet(&oplinkSettings);
|
||||
|
||||
// Perform the update.
|
||||
updateSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the oplink settings, called on startup.
|
||||
*/
|
||||
static void updateSettings()
|
||||
{
|
||||
@ -472,70 +518,111 @@ static void updateSettings()
|
||||
// Get the settings.
|
||||
OPLinkSettingsData oplinkSettings;
|
||||
OPLinkSettingsGet(&oplinkSettings);
|
||||
|
||||
|
||||
bool is_coordinator = (oplinkSettings.Coordinator == OPLINKSETTINGS_COORDINATOR_TRUE);
|
||||
if (is_coordinator)
|
||||
{
|
||||
// Set the remote com configuration parameters
|
||||
PIOS_RFM22B_SetRemoteComConfig(pios_rfm22b_id, oplinkSettings.OutputConnection, oplinkSettings.ComSpeed);
|
||||
|
||||
// Configure the RFM22B device as coordinator or not
|
||||
PIOS_RFM22B_SetCoordinator(pios_rfm22b_id, true);
|
||||
|
||||
// Set the frequencies.
|
||||
PIOS_RFM22B_SetFrequencyRange(pios_rfm22b_id, oplinkSettings.MinFrequency, oplinkSettings.MaxFrequency);
|
||||
|
||||
// Set the maximum radio RF power.
|
||||
switch (oplinkSettings.MaxRFPower)
|
||||
{
|
||||
case OPLINKSETTINGS_MAXRFPOWER_125:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_0);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_16:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_1);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_316:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_2);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_63:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_3);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_126:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_4);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_25:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_5);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_50:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_6);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_100:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_7);
|
||||
break;
|
||||
}
|
||||
|
||||
// Set the radio destination ID.
|
||||
PIOS_RFM22B_SetDestinationId(pios_rfm22b_id, oplinkSettings.PairID);
|
||||
}
|
||||
|
||||
// Determine what com ports we're using.
|
||||
switch (oplinkSettings.InputConnection)
|
||||
{
|
||||
case OPLINKSETTINGS_INPUTCONNECTION_VCP:
|
||||
PIOS_COM_TELEMETRY = PIOS_COM_TELEM_VCP;
|
||||
break;
|
||||
case OPLINKSETTINGS_INPUTCONNECTION_TELEMETRY:
|
||||
PIOS_COM_TELEMETRY = PIOS_COM_TELEM_UART_TELEM;
|
||||
break;
|
||||
case OPLINKSETTINGS_INPUTCONNECTION_FLEXI:
|
||||
PIOS_COM_TELEMETRY = PIOS_COM_TELEM_UART_FLEXI;
|
||||
break;
|
||||
default:
|
||||
PIOS_COM_TELEMETRY = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (oplinkSettings.OutputConnection)
|
||||
{
|
||||
case OPLINKSETTINGS_OUTPUTCONNECTION_FLEXI:
|
||||
PIOS_COM_RADIO = PIOS_COM_TELEM_UART_FLEXI;
|
||||
break;
|
||||
case OPLINKSETTINGS_OUTPUTCONNECTION_TELEMETRY:
|
||||
PIOS_COM_RADIO = PIOS_COM_TELEM_UART_TELEM;
|
||||
break;
|
||||
default:
|
||||
PIOS_COM_RADIO = PIOS_COM_RFM22B;
|
||||
break;
|
||||
}
|
||||
|
||||
// Configure the com port speeds.
|
||||
switch (oplinkSettings.ComSpeed) {
|
||||
case OPLINKSETTINGS_COMSPEED_2400:
|
||||
if (PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 2400);
|
||||
if (is_coordinator && PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 2400);
|
||||
if (PIOS_COM_TELEMETRY) PIOS_COM_ChangeBaud(PIOS_COM_TELEMETRY, 2400);
|
||||
break;
|
||||
case OPLINKSETTINGS_COMSPEED_4800:
|
||||
if (PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 4800);
|
||||
if (is_coordinator && PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 4800);
|
||||
if (PIOS_COM_TELEMETRY) PIOS_COM_ChangeBaud(PIOS_COM_TELEMETRY, 4800);
|
||||
break;
|
||||
case OPLINKSETTINGS_COMSPEED_9600:
|
||||
if (PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 9600);
|
||||
if (is_coordinator && PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 9600);
|
||||
if (PIOS_COM_TELEMETRY) PIOS_COM_ChangeBaud(PIOS_COM_TELEMETRY, 9600);
|
||||
break;
|
||||
case OPLINKSETTINGS_COMSPEED_19200:
|
||||
if (PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 19200);
|
||||
if (is_coordinator && PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 19200);
|
||||
if (PIOS_COM_TELEMETRY) PIOS_COM_ChangeBaud(PIOS_COM_TELEMETRY, 19200);
|
||||
break;
|
||||
case OPLINKSETTINGS_COMSPEED_38400:
|
||||
if (PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 38400);
|
||||
if (is_coordinator && PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 38400);
|
||||
if (PIOS_COM_TELEMETRY) PIOS_COM_ChangeBaud(PIOS_COM_TELEMETRY, 38400);
|
||||
break;
|
||||
case OPLINKSETTINGS_COMSPEED_57600:
|
||||
if (PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 57600);
|
||||
if (is_coordinator && PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 57600);
|
||||
if (PIOS_COM_TELEMETRY) PIOS_COM_ChangeBaud(PIOS_COM_TELEMETRY, 57600);
|
||||
break;
|
||||
case OPLINKSETTINGS_COMSPEED_115200:
|
||||
if (PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 115200);
|
||||
if (is_coordinator && PIOS_COM_RADIO) PIOS_COM_ChangeBaud(PIOS_COM_RADIO, 115200);
|
||||
if (PIOS_COM_TELEMETRY) PIOS_COM_ChangeBaud(PIOS_COM_TELEMETRY, 115200);
|
||||
break;
|
||||
}
|
||||
|
||||
// Set the frequencies.
|
||||
PIOS_RFM22B_SetFrequencyRange(pios_rfm22b_id, oplinkSettings.MinFrequency, oplinkSettings.MaxFrequency);
|
||||
|
||||
// Set the maximum radio RF power.
|
||||
switch (oplinkSettings.MaxRFPower)
|
||||
{
|
||||
case OPLINKSETTINGS_MAXRFPOWER_125:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_0);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_16:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_1);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_316:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_2);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_63:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_3);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_126:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_4);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_25:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_5);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_50:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_6);
|
||||
break;
|
||||
case OPLINKSETTINGS_MAXRFPOWER_100:
|
||||
PIOS_RFM22B_SetTxPower(pios_rfm22b_id, RFM22_tx_pwr_txpow_7);
|
||||
break;
|
||||
}
|
||||
|
||||
// Set the radio destination ID.
|
||||
PIOS_RFM22B_SetDestinationId(pios_rfm22b_id, oplinkSettings.PairID);
|
||||
}
|
||||
|
@ -151,12 +151,20 @@ extern uint32_t pios_i2c_flexi_adapter_id;
|
||||
#define PIOS_COM_MAX_DEVS 5
|
||||
|
||||
extern uint32_t pios_com_telem_usb_id;
|
||||
extern uint32_t pios_com_telem_vcp_id;
|
||||
extern uint32_t pios_com_telem_uart_telem_id;
|
||||
extern uint32_t pios_com_telem_uart_flexi_id;
|
||||
extern uint32_t pios_com_telemetry_id;
|
||||
extern uint32_t pios_com_rfm22b_id;
|
||||
extern uint32_t pios_com_radio_id;
|
||||
extern uint32_t pios_ppm_rcvr_id;
|
||||
#define PIOS_COM_TELEMETRY (pios_com_telemetry_id)
|
||||
#define PIOS_COM_TELEM_USB (pios_com_telem_usb_id)
|
||||
#define PIOS_COM_RADIO (pios_com_rfm22b_id)
|
||||
#define PIOS_COM_TELEM_VCP (pios_com_telem_vcp_id)
|
||||
#define PIOS_COM_TELEM_UART_FLEXI (pios_com_telem_uart_flexi_id)
|
||||
#define PIOS_COM_TELEM_UART_TELEM (pios_com_telem_uart_telem_id)
|
||||
#define PIOS_COM_TELEMETRY (pios_com_telemetry_id)
|
||||
#define PIOS_COM_RFM22B (pios_com_rfm22b_id)
|
||||
#define PIOS_COM_RADIO (pios_com_radio_id)
|
||||
#define PIOS_PPM_RECEIVER (pios_ppm_rcvr_id)
|
||||
|
||||
#define DEBUG_LEVEL 2
|
||||
|
@ -578,6 +578,9 @@ int32_t PIOS_RFM22B_Init(uint32_t *rfm22b_id, uint32_t spi_id, uint32_t slave_nu
|
||||
rfm22b_dev->send_ppm = false;
|
||||
rfm22b_dev->datarate = RFM22B_DEFAULT_RX_DATARATE;
|
||||
|
||||
// Initialize the com configuration callback.
|
||||
rfm22b_dev->com_config_cb = NULL;
|
||||
|
||||
// Initialize the stats.
|
||||
rfm22b_dev->stats.packets_per_sec = 0;
|
||||
rfm22b_dev->stats.rx_good = 0;
|
||||
@ -753,6 +756,34 @@ void PIOS_RFM22B_SetCoordinator(uint32_t rfm22b_id, bool coordinator)
|
||||
PIOS_RFM22B_InjectEvent(rfm22b_dev, RFM22B_EVENT_INITIALIZE, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the remote com port configuration parameters.
|
||||
* \param[in] rfm22b_id The rfm22b device.
|
||||
* \param[in] com_port The remote com port
|
||||
* \param[in] com_speed The remote com port speed
|
||||
*/
|
||||
void PIOS_RFM22B_SetRemoteComConfig(uint32_t rfm22b_id, OPLinkSettingsOutputConnectionOptions com_port, OPLinkSettingsComSpeedOptions com_speed)
|
||||
{
|
||||
struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id;
|
||||
if(!PIOS_RFM22B_validate(rfm22b_dev))
|
||||
return;
|
||||
rfm22b_dev->con_packet.port = com_port;
|
||||
rfm22b_dev->con_packet.com_speed = com_speed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the com port configuration callback (to receive com configuration over the air)
|
||||
* \param[in] rfm22b_id The rfm22b device.
|
||||
* \param[in] cb A pointer to the callback function
|
||||
*/
|
||||
void PIOS_RFM22B_SetComConfigCallback(uint32_t rfm22b_id, PIOS_RFM22B_ComConfigCallback cb)
|
||||
{
|
||||
struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id;
|
||||
if(!PIOS_RFM22B_validate(rfm22b_dev))
|
||||
return;
|
||||
rfm22b_dev->com_config_cb = cb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the device statistics RFM22B device.
|
||||
* \param[in] rfm22b_id The RFM22B device index.
|
||||
@ -1987,6 +2018,10 @@ static void rfm22_setConnectionParameters(struct pios_rfm22b_dev *rfm22b_dev)
|
||||
rfm22b_dev->min_frequency = cph->min_frequency;
|
||||
rfm22b_dev->max_frequency = cph->max_frequency;
|
||||
rfm22_setNominalCarrierFrequency(rfm22b_dev, cph->frequency_hz);
|
||||
|
||||
// Call the com port configuration function
|
||||
if (rfm22b_dev->com_config_cb && !rfm22b_dev->coordinator)
|
||||
rfm22b_dev->com_config_cb(cph->port, cph->com_speed);
|
||||
}
|
||||
|
||||
static enum pios_rfm22b_event rfm22_acceptConnection(struct pios_rfm22b_dev *rfm22b_dev)
|
||||
|
@ -32,6 +32,7 @@
|
||||
#define PIOS_RFM22B_H
|
||||
|
||||
#include <packet_handler.h>
|
||||
#include <oplinksettings.h>
|
||||
|
||||
enum gpio_direction {GPIO0_TX_GPIO1_RX, GPIO0_RX_GPIO1_TX};
|
||||
|
||||
@ -94,6 +95,9 @@ struct rfm22b_stats {
|
||||
uint8_t link_state;
|
||||
};
|
||||
|
||||
/* Callback function prototypes */
|
||||
typedef void (*PIOS_RFM22B_ComConfigCallback)(OPLinkSettingsOutputConnectionOptions com_port, OPLinkSettingsComSpeedOptions com_speed);
|
||||
|
||||
/* Public Functions */
|
||||
extern int32_t PIOS_RFM22B_Init(uint32_t *rfb22b_id, uint32_t spi_id, uint32_t slave_num, const struct pios_rfm22b_cfg *cfg);
|
||||
extern void PIOS_RFM22B_SetFrequencyRange(uint32_t rfm22b_id, uint32_t min_frequency, uint32_t max_frequency);
|
||||
@ -101,6 +105,8 @@ extern void PIOS_RFM22B_SetTxPower(uint32_t rfm22b_id, enum rfm22b_tx_power tx_p
|
||||
extern void PIOS_RFM22B_SetDatarate(uint32_t rfm22b_id, enum rfm22b_datarate datarate, bool data_whitening);
|
||||
extern void PIOS_RFM22B_SetDestinationId(uint32_t rfm22b_id, uint32_t dest_id);
|
||||
extern void PIOS_RFM22B_SetCoordinator(uint32_t rfm22b_id, bool coordinator);
|
||||
extern void PIOS_RFM22B_SetRemoteComConfig(uint32_t rfm22b_id, OPLinkSettingsOutputConnectionOptions com_port, OPLinkSettingsComSpeedOptions com_speed);
|
||||
extern void PIOS_RFM22B_SetComConfigCallback(uint32_t rfm22b_id, PIOS_RFM22B_ComConfigCallback cb);
|
||||
extern uint32_t PIOS_RFM22B_DeviceID(uint32_t rfb22b_id);
|
||||
extern void PIOS_RFM22B_GetStats(uint32_t rfm22b_id, struct rfm22b_stats *stats);
|
||||
extern uint8_t PIOS_RFM2B_GetPairStats(uint32_t rfm22b_id, uint32_t *device_ids, int8_t *RSSIs, uint8_t max_pairs);
|
||||
|
@ -672,6 +672,9 @@ struct pios_rfm22b_dev {
|
||||
// ISR pending
|
||||
xSemaphoreHandle isrPending;
|
||||
|
||||
// The com configuration callback
|
||||
PIOS_RFM22B_ComConfigCallback com_config_cb;
|
||||
|
||||
// The COM callback functions.
|
||||
pios_com_callback rx_in_cb;
|
||||
uint32_t rx_in_context;
|
||||
|
@ -39,15 +39,24 @@
|
||||
#define PIOS_COM_TELEM_USB_RX_BUF_LEN 256
|
||||
#define PIOS_COM_TELEM_USB_TX_BUF_LEN 256
|
||||
|
||||
#define PIOS_COM_TELEM_VCP_RX_BUF_LEN 256
|
||||
#define PIOS_COM_TELEM_VCP_TX_BUF_LEN 256
|
||||
|
||||
#define PIOS_COM_RFM22B_RF_RX_BUF_LEN 256
|
||||
#define PIOS_COM_RFM22B_RF_TX_BUF_LEN 256
|
||||
|
||||
uint32_t pios_com_telem_usb_id = 0;
|
||||
uint32_t pios_com_telem_vcp_id = 0;
|
||||
uint32_t pios_com_telem_uart_telem_id = 0;
|
||||
uint32_t pios_com_telem_uart_flexi_id = 0;
|
||||
uint32_t pios_com_telemetry_id = 0;
|
||||
#if defined(PIOS_INCLUDE_PPM)
|
||||
uint32_t pios_ppm_rcvr_id = 0;
|
||||
#endif
|
||||
#if defined(PIOS_INCLUDE_RFM22B)
|
||||
uint32_t pios_rfm22b_id = 0;
|
||||
uint32_t pios_com_rfm22b_id = 0;
|
||||
uint32_t pios_com_radio_id = 0;
|
||||
uint32_t pios_packet_handler = 0;
|
||||
#endif
|
||||
|
||||
@ -132,14 +141,14 @@ void PIOS_Board_Init(void) {
|
||||
uint32_t pios_usb_id;
|
||||
PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg);
|
||||
|
||||
/* We always onfigure the usb HID port */
|
||||
/* Configure the USB HID port */
|
||||
{
|
||||
uint32_t pios_usb_hid_id;
|
||||
if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
|
||||
uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
|
||||
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
|
||||
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
|
||||
PIOS_Assert(rx_buffer);
|
||||
PIOS_Assert(tx_buffer);
|
||||
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id,
|
||||
@ -149,54 +158,45 @@ void PIOS_Board_Init(void) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Configure the requested com port */
|
||||
switch (oplinkSettings.InputConnection)
|
||||
{
|
||||
case OPLINKSETTINGS_INPUTCONNECTION_HID:
|
||||
// This is always configured
|
||||
break;
|
||||
case OPLINKSETTINGS_INPUTCONNECTION_VCP:
|
||||
{
|
||||
/* Configure the USB virtual com port (VCP) */
|
||||
#if defined(PIOS_INCLUDE_USB_CDC)
|
||||
if (!usb_cdc_present)
|
||||
break;
|
||||
if (usb_cdc_present)
|
||||
{
|
||||
uint32_t pios_usb_cdc_id;
|
||||
if (PIOS_USB_CDC_Init(&pios_usb_cdc_id, &pios_usb_cdc_cfg, pios_usb_id)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RX_BUF_LEN);
|
||||
uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_TX_BUF_LEN);
|
||||
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_VCP_RX_BUF_LEN);
|
||||
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_VCP_TX_BUF_LEN);
|
||||
PIOS_Assert(rx_buffer);
|
||||
PIOS_Assert(tx_buffer);
|
||||
if (PIOS_COM_Init(&pios_com_telemetry_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id,
|
||||
rx_buffer, PIOS_COM_TELEM_RX_BUF_LEN,
|
||||
tx_buffer, PIOS_COM_TELEM_TX_BUF_LEN)) {
|
||||
if (PIOS_COM_Init(&pios_com_telem_vcp_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id,
|
||||
rx_buffer, PIOS_COM_TELEM_VCP_RX_BUF_LEN,
|
||||
tx_buffer, PIOS_COM_TELEM_VCP_TX_BUF_LEN)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case OPLINKSETTINGS_INPUTCONNECTION_TELEMETRY:
|
||||
#endif
|
||||
|
||||
/* Configure the telemetry serial port */
|
||||
{
|
||||
// Configure the telemetry port.
|
||||
uint32_t pios_usart1_id;
|
||||
if (PIOS_USART_Init(&pios_usart1_id, &pios_usart_serial_cfg)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RX_BUF_LEN);
|
||||
uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_TX_BUF_LEN);
|
||||
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_RX_BUF_LEN);
|
||||
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_TX_BUF_LEN);
|
||||
PIOS_Assert(rx_buffer);
|
||||
PIOS_Assert(tx_buffer);
|
||||
if (PIOS_COM_Init(&pios_com_telemetry_id, &pios_usart_com_driver, pios_usart1_id,
|
||||
if (PIOS_COM_Init(&pios_com_telem_uart_telem_id, &pios_usart_com_driver, pios_usart1_id,
|
||||
rx_buffer, PIOS_COM_TELEM_RX_BUF_LEN,
|
||||
tx_buffer, PIOS_COM_TELEM_TX_BUF_LEN)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case OPLINKSETTINGS_INPUTCONNECTION_FLEXI:
|
||||
|
||||
/* Configure the flexi serial port */
|
||||
{
|
||||
// Configure the flexi port.
|
||||
uint32_t pios_usart3_id;
|
||||
if (PIOS_USART_Init(&pios_usart3_id, &pios_usart_telem_flexi_cfg)) {
|
||||
PIOS_Assert(0);
|
||||
@ -205,13 +205,11 @@ void PIOS_Board_Init(void) {
|
||||
uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_TX_BUF_LEN);
|
||||
PIOS_Assert(rx_buffer);
|
||||
PIOS_Assert(tx_buffer);
|
||||
if (PIOS_COM_Init(&pios_com_telemetry_id, &pios_usart_com_driver, pios_usart3_id,
|
||||
if (PIOS_COM_Init(&pios_com_telem_uart_flexi_id, &pios_usart_com_driver, pios_usart3_id,
|
||||
rx_buffer, PIOS_COM_TELEM_RX_BUF_LEN,
|
||||
tx_buffer, PIOS_COM_TELEM_TX_BUF_LEN)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Configure PPM input */
|
||||
@ -236,9 +234,6 @@ void PIOS_Board_Init(void) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
|
||||
/* Configure the RFM22B device as coordinator or not */
|
||||
PIOS_RFM22B_SetCoordinator(pios_rfm22b_id, oplinkSettings.Coordinator == OPLINKSETTINGS_COORDINATOR_TRUE);
|
||||
|
||||
uint8_t *rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_RFM22B_RF_RX_BUF_LEN);
|
||||
uint8_t *tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_RFM22B_RF_TX_BUF_LEN);
|
||||
PIOS_Assert(rx_buffer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user