mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
LP-484 This change removes custom PIOS_OpenLRS_Rcvr_UpdateChannels() api in favor of PIOS_OpenLRS_RegisterPPMCallback() to be in line with other receiver modules. Furthermore, this commit moves the openlrs/oplink ppm callback from pios_board.c into *rcvr* module itself.
This commit is contained in:
parent
556c2e9e99
commit
45d1eb7493
@ -110,16 +110,16 @@ static int32_t comUsbBridgeInitialize(void)
|
||||
usart_port);
|
||||
}
|
||||
|
||||
#ifdef MODULE_COMUSBBRIDGE_BUILTIN
|
||||
bridge_enabled = true;
|
||||
#else
|
||||
|
||||
// #ifdef MODULE_COMUSBBRIDGE_BUILTIN
|
||||
// bridge_enabled = true;
|
||||
// #else
|
||||
//
|
||||
if (usart_port && vcp_port) {
|
||||
bridge_enabled = true;
|
||||
} else {
|
||||
bridge_enabled = false;
|
||||
}
|
||||
#endif
|
||||
// #endif
|
||||
|
||||
if (bridge_enabled) {
|
||||
com2usb_buf = pios_malloc(BRIDGE_BUF_LEN);
|
||||
|
@ -870,13 +870,8 @@ static void pios_openlrs_rx_loop(struct pios_openlrs_dev *openlrs_dev)
|
||||
rescaleChannels(openlrs_dev->ppm);
|
||||
|
||||
// Call the PPM received callback if it's available.
|
||||
if (openlrs_dev->openlrs_rcvr_id) {
|
||||
#if defined(PIOS_INCLUDE_OPENLRS_RCVR)
|
||||
PIOS_OpenLRS_Rcvr_UpdateChannels(openlrs_dev->openlrs_rcvr_id, openlrs_dev->ppm);
|
||||
#endif
|
||||
}
|
||||
if (openlrs_dev->ppm_callback) {
|
||||
openlrs_dev->ppm_callback(openlrs_dev->ppm);
|
||||
openlrs_dev->ppm_callback(openlrs_dev->ppm_context, openlrs_dev->ppm);
|
||||
}
|
||||
} else {
|
||||
// Not PPM data. Push into serial RX buffer.
|
||||
@ -1084,31 +1079,13 @@ uint8_t PIOS_OpenLRS_RSSI_Get(void)
|
||||
* PPM Code
|
||||
*****************************************************************************/
|
||||
|
||||
/**
|
||||
* Register a OpenLRS_Rcvr interface to inform of PPM packets
|
||||
*
|
||||
* @param[in] rfm22b_dev The RFM22B device ID.
|
||||
* @param[in] rfm22b_rcvr_id The receiver device to inform of PPM packets
|
||||
*/
|
||||
void PIOS_OpenLRS_RegisterRcvr(uint32_t openlrs_id, uint32_t openlrs_rcvr_id)
|
||||
{
|
||||
struct pios_openlrs_dev *openlrs_dev =
|
||||
(struct pios_openlrs_dev *)openlrs_id;
|
||||
|
||||
if (!pios_openlrs_validate(openlrs_dev)) {
|
||||
return;
|
||||
}
|
||||
|
||||
openlrs_dev->openlrs_rcvr_id = openlrs_rcvr_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a OpenLRS_Rcvr interface to inform of PPM packets using a generic callback.
|
||||
*
|
||||
* @param[in] openlrs_id The OpenLRS device ID.
|
||||
* @param[in] callback The callback function.
|
||||
*/
|
||||
void PIOS_OpenLRS_RegisterPPMCallback(uint32_t openlrs_id, PIOS_OpenLRS_PPMReceivedCallback callback)
|
||||
void PIOS_OpenLRS_RegisterPPMCallback(uint32_t openlrs_id, PIOS_OpenLRS_PPMReceivedCallback callback, uint32_t context)
|
||||
{
|
||||
struct pios_openlrs_dev *openlrs_dev =
|
||||
(struct pios_openlrs_dev *)openlrs_id;
|
||||
@ -1117,6 +1094,7 @@ void PIOS_OpenLRS_RegisterPPMCallback(uint32_t openlrs_id, PIOS_OpenLRS_PPMRecei
|
||||
return;
|
||||
}
|
||||
|
||||
openlrs_dev->ppm_context = context;
|
||||
openlrs_dev->ppm_callback = callback;
|
||||
}
|
||||
|
||||
@ -1166,12 +1144,12 @@ int32_t PIOS_OpenLRS_Init(uint32_t *openlrs_id, uint32_t spi_id,
|
||||
}
|
||||
|
||||
// Initialize the com callbacks.
|
||||
openlrs_dev->rx_in_cb = NULL;
|
||||
openlrs_dev->tx_out_cb = NULL;
|
||||
openlrs_dev->rx_in_cb = NULL;
|
||||
openlrs_dev->tx_out_cb = NULL;
|
||||
|
||||
// Initialize the "PPM" callback.
|
||||
openlrs_dev->openlrs_rcvr_id = 0;
|
||||
openlrs_dev->ppm_callback = 0;
|
||||
openlrs_dev->ppm_callback = 0;
|
||||
openlrs_dev->ppm_context = 0;
|
||||
|
||||
OPLinkSettingsInitialize();
|
||||
OPLinkStatusInitialize();
|
||||
|
@ -44,6 +44,7 @@
|
||||
/* Provide a RCVR driver */
|
||||
static int32_t PIOS_OpenLRS_Rcvr_Get(uint32_t rcvr_id, uint8_t channel);
|
||||
static void PIOS_OpenLRS_Rcvr_Supervisor(uint32_t ppm_id);
|
||||
static void PIOS_OpenLRS_Rcvr_ppm_callback(uint32_t openlrs_rcvr_id, const int16_t *channels);
|
||||
|
||||
const struct pios_rcvr_driver pios_openlrs_rcvr_driver = {
|
||||
.read = PIOS_OpenLRS_Rcvr_Get,
|
||||
@ -102,7 +103,7 @@ extern int32_t PIOS_OpenLRS_Rcvr_Init(uint32_t *openlrs_rcvr_id, uintptr_t openl
|
||||
OPLinkReceiverInitialize();
|
||||
|
||||
*openlrs_rcvr_id = (uintptr_t)openlrs_rcvr_dev;
|
||||
PIOS_OpenLRS_RegisterRcvr(openlrs_id, *openlrs_rcvr_id);
|
||||
PIOS_OpenLRS_RegisterPPMCallback(openlrs_id, PIOS_OpenLRS_Rcvr_ppm_callback, *openlrs_rcvr_id);
|
||||
|
||||
/* Register the failsafe timer callback. */
|
||||
if (!PIOS_RTC_RegisterTickCallback
|
||||
@ -118,7 +119,7 @@ extern int32_t PIOS_OpenLRS_Rcvr_Init(uint32_t *openlrs_rcvr_id, uintptr_t openl
|
||||
* PPM packet is received. This method stores the data locally as well
|
||||
* as sets the data into the OPLinkReceiver UAVO for visibility
|
||||
*/
|
||||
int32_t PIOS_OpenLRS_Rcvr_UpdateChannels(uint32_t openlrs_rcvr_id, int16_t *channels)
|
||||
static void PIOS_OpenLRS_Rcvr_ppm_callback(uint32_t openlrs_rcvr_id, const int16_t *channels)
|
||||
{
|
||||
/* Recover our device context */
|
||||
struct pios_openlrs_rcvr_dev *openlrs_rcvr_dev =
|
||||
@ -126,7 +127,7 @@ int32_t PIOS_OpenLRS_Rcvr_UpdateChannels(uint32_t openlrs_rcvr_id, int16_t *chan
|
||||
|
||||
if (!PIOS_OpenLRS_Rcvr_Validate(openlrs_rcvr_dev)) {
|
||||
/* Invalid device specified */
|
||||
return -1;
|
||||
return;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < OPENLRS_PPM_NUM_CHANNELS; i++) {
|
||||
@ -137,8 +138,6 @@ int32_t PIOS_OpenLRS_Rcvr_UpdateChannels(uint32_t openlrs_rcvr_id, int16_t *chan
|
||||
|
||||
// let supervisor know we have new data
|
||||
openlrs_rcvr_dev->fresh = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include <oplinkstatus.h>
|
||||
#include <pios_oplinkrcvr_priv.h>
|
||||
|
||||
static OPLinkReceiverData oplinkreceiverdata;
|
||||
|
||||
/* Provide a RCVR driver */
|
||||
static int32_t PIOS_OPLinkRCVR_Get(uint32_t rcvr_id, uint8_t channel);
|
||||
@ -56,18 +55,34 @@ enum pios_oplinkrcvr_dev_magic {
|
||||
|
||||
struct pios_oplinkrcvr_dev {
|
||||
enum pios_oplinkrcvr_dev_magic magic;
|
||||
|
||||
uint8_t supv_timer;
|
||||
OPLinkReceiverData oplinkreceiverdata;
|
||||
bool Fresh;
|
||||
};
|
||||
|
||||
static struct pios_oplinkrcvr_dev *global_oplinkrcvr_dev;
|
||||
|
||||
static bool PIOS_oplinkrcvr_validate(struct pios_oplinkrcvr_dev *oplinkrcvr_dev)
|
||||
{
|
||||
return oplinkrcvr_dev->magic == PIOS_OPLINKRCVR_DEV_MAGIC;
|
||||
}
|
||||
|
||||
static void PIOS_oplinkrcvr_ppm_callback(uint32_t oplinkrcvr_id, const int16_t *channels)
|
||||
{
|
||||
/* Recover our device context */
|
||||
struct pios_oplinkrcvr_dev *oplinkrcvr_dev = (struct pios_oplinkrcvr_dev *)oplinkrcvr_id;
|
||||
|
||||
if (!PIOS_oplinkrcvr_validate(oplinkrcvr_dev)) {
|
||||
/* Invalid device specified */
|
||||
return;
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < OPLINKRECEIVER_CHANNEL_NUMELEM; ++i) {
|
||||
oplinkrcvr_dev->oplinkreceiverdata.Channel[i] = (i < RFM22B_PPM_NUM_CHANNELS) ? channels[i] : PIOS_RCVR_TIMEOUT;
|
||||
}
|
||||
OPLinkReceiverSet(&oplinkrcvr_dev->oplinkreceiverdata);
|
||||
|
||||
oplinkrcvr_dev->Fresh = true;
|
||||
}
|
||||
|
||||
#if defined(PIOS_INCLUDE_FREERTOS)
|
||||
static struct pios_oplinkrcvr_dev *PIOS_oplinkrcvr_alloc(void)
|
||||
{
|
||||
@ -82,9 +97,6 @@ static struct pios_oplinkrcvr_dev *PIOS_oplinkrcvr_alloc(void)
|
||||
oplinkrcvr_dev->Fresh = false;
|
||||
oplinkrcvr_dev->supv_timer = 0;
|
||||
|
||||
/* The update callback cannot receive the device pointer, so set it in a global */
|
||||
global_oplinkrcvr_dev = oplinkrcvr_dev;
|
||||
|
||||
return oplinkrcvr_dev;
|
||||
}
|
||||
#else
|
||||
@ -103,23 +115,11 @@ static struct pios_oplinkrcvr_dev *PIOS_oplinkrcvr_alloc(void)
|
||||
oplinkrcvr_dev->Fresh = false;
|
||||
oplinkrcvr_dev->supv_timer = 0;
|
||||
|
||||
global_oplinkrcvr_dev = oplinkrcvr_dev;
|
||||
|
||||
return oplinkrcvr_dev;
|
||||
}
|
||||
#endif /* if defined(PIOS_INCLUDE_FREERTOS) */
|
||||
|
||||
static void oplinkreceiver_updated(UAVObjEvent *ev)
|
||||
{
|
||||
struct pios_oplinkrcvr_dev *oplinkrcvr_dev = global_oplinkrcvr_dev;
|
||||
|
||||
if (ev->obj == OPLinkReceiverHandle()) {
|
||||
OPLinkReceiverGet(&oplinkreceiverdata);
|
||||
oplinkrcvr_dev->Fresh = true;
|
||||
}
|
||||
}
|
||||
|
||||
extern int32_t PIOS_OPLinkRCVR_Init(__attribute__((unused)) uint32_t *oplinkrcvr_id)
|
||||
extern int32_t PIOS_OPLinkRCVR_Init(uint32_t *oplinkrcvr_id, uint32_t rfm22b_id)
|
||||
{
|
||||
struct pios_oplinkrcvr_dev *oplinkrcvr_dev;
|
||||
|
||||
@ -131,17 +131,19 @@ extern int32_t PIOS_OPLinkRCVR_Init(__attribute__((unused)) uint32_t *oplinkrcvr
|
||||
|
||||
for (uint8_t i = 0; i < OPLINKRECEIVER_CHANNEL_NUMELEM; i++) {
|
||||
/* Flush channels */
|
||||
oplinkreceiverdata.Channel[i] = PIOS_RCVR_TIMEOUT;
|
||||
oplinkrcvr_dev->oplinkreceiverdata.Channel[i] = PIOS_RCVR_TIMEOUT;
|
||||
}
|
||||
|
||||
/* Register uavobj callback */
|
||||
OPLinkReceiverConnectCallback(oplinkreceiver_updated);
|
||||
/* Register ppm callback */
|
||||
PIOS_RFM22B_SetPPMCallback(rfm22b_id, PIOS_oplinkrcvr_ppm_callback, (uint32_t)oplinkrcvr_dev);
|
||||
|
||||
/* Register the failsafe timer callback. */
|
||||
if (!PIOS_RTC_RegisterTickCallback(PIOS_oplinkrcvr_Supervisor, (uint32_t)oplinkrcvr_dev)) {
|
||||
PIOS_DEBUG_Assert(0);
|
||||
}
|
||||
|
||||
*oplinkrcvr_id = (uint32_t)oplinkrcvr_dev;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -152,14 +154,22 @@ extern int32_t PIOS_OPLinkRCVR_Init(__attribute__((unused)) uint32_t *oplinkrcvr
|
||||
* \output PIOS_RCVR_TIMEOUT failsafe condition or missing receiver
|
||||
* \output >=0 channel value
|
||||
*/
|
||||
static int32_t PIOS_OPLinkRCVR_Get(__attribute__((unused)) uint32_t rcvr_id, uint8_t channel)
|
||||
static int32_t PIOS_OPLinkRCVR_Get(uint32_t oplinkrcvr_id, uint8_t channel)
|
||||
{
|
||||
/* Recover our device context */
|
||||
struct pios_oplinkrcvr_dev *oplinkrcvr_dev = (struct pios_oplinkrcvr_dev *)oplinkrcvr_id;
|
||||
|
||||
if (!PIOS_oplinkrcvr_validate(oplinkrcvr_dev)) {
|
||||
/* Invalid device specified */
|
||||
return PIOS_RCVR_INVALID;
|
||||
}
|
||||
|
||||
if (channel >= OPLINKRECEIVER_CHANNEL_NUMELEM) {
|
||||
/* channel is out of range */
|
||||
return PIOS_RCVR_INVALID;
|
||||
}
|
||||
|
||||
return oplinkreceiverdata.Channel[channel];
|
||||
return oplinkrcvr_dev->oplinkreceiverdata.Channel[channel];
|
||||
}
|
||||
|
||||
static void PIOS_oplinkrcvr_Supervisor(uint32_t oplinkrcvr_id)
|
||||
@ -182,7 +192,7 @@ static void PIOS_oplinkrcvr_Supervisor(uint32_t oplinkrcvr_id)
|
||||
|
||||
if (!oplinkrcvr_dev->Fresh) {
|
||||
for (int32_t i = 0; i < OPLINKRECEIVER_CHANNEL_NUMELEM; i++) {
|
||||
oplinkreceiverdata.Channel[i] = PIOS_RCVR_TIMEOUT;
|
||||
oplinkrcvr_dev->oplinkreceiverdata.Channel[i] = PIOS_RCVR_TIMEOUT;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -424,6 +424,7 @@ int32_t PIOS_RFM22B_Init(uint32_t *rfm22b_id, uint32_t spi_id, uint32_t slave_nu
|
||||
rfm22b_dev->aux_tx_out_cb = NULL;
|
||||
// Initialize the PPM callback.
|
||||
rfm22b_dev->ppm_callback = NULL;
|
||||
rfm22b_dev->ppm_context = 0;
|
||||
|
||||
// Initialize the stats.
|
||||
rfm22b_dev->stats.packets_per_sec = 0;
|
||||
@ -1123,7 +1124,7 @@ pios_rfm22b_int_result PIOS_RFM22B_ProcessRx(uint32_t rfm22b_id)
|
||||
* @param[in] rfm22b_dev The RFM22B device ID.
|
||||
* @param[in] cb The callback function pointer.
|
||||
*/
|
||||
void PIOS_RFM22B_SetPPMCallback(uint32_t rfm22b_id, PPMReceivedCallback cb)
|
||||
void PIOS_RFM22B_SetPPMCallback(uint32_t rfm22b_id, PPMReceivedCallback cb, uint32_t cb_context)
|
||||
{
|
||||
struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id;
|
||||
|
||||
@ -1131,6 +1132,7 @@ void PIOS_RFM22B_SetPPMCallback(uint32_t rfm22b_id, PPMReceivedCallback cb)
|
||||
return;
|
||||
}
|
||||
|
||||
rfm22b_dev->ppm_context = cb_context;
|
||||
rfm22b_dev->ppm_callback = cb;
|
||||
}
|
||||
|
||||
@ -2071,7 +2073,7 @@ static enum pios_radio_event radio_receivePacket(struct pios_rfm22b_dev *radio_d
|
||||
|
||||
// Call the PPM received callback if it's available.
|
||||
if (radio_dev->ppm_callback) {
|
||||
radio_dev->ppm_callback(radio_dev->ppm);
|
||||
radio_dev->ppm_callback(radio_dev->ppm_context, radio_dev->ppm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,13 +39,12 @@ struct pios_openlrs_cfg {
|
||||
enum gpio_direction gpio_direction; /* Definition comes from pios_rfm22b.h */
|
||||
};
|
||||
|
||||
typedef void (*PIOS_OpenLRS_PPMReceivedCallback)(const int16_t *channels);
|
||||
typedef void (*PIOS_OpenLRS_PPMReceivedCallback)(uint32_t context, const int16_t *channels);
|
||||
|
||||
extern int32_t PIOS_OpenLRS_Init(uint32_t *openlrs_id, uint32_t spi_id,
|
||||
uint32_t slave_num, const struct pios_openlrs_cfg *cfg);
|
||||
|
||||
extern void PIOS_OpenLRS_RegisterRcvr(uint32_t openlrs_id, uint32_t rfm22b_rcvr_id);
|
||||
extern void PIOS_OpenLRS_RegisterPPMCallback(uint32_t openlrs_id, PIOS_OpenLRS_PPMReceivedCallback callback);
|
||||
extern void PIOS_OpenLRS_RegisterPPMCallback(uint32_t openlrs_id, PIOS_OpenLRS_PPMReceivedCallback callback, uint32_t context);
|
||||
extern uint8_t PIOS_OpenLRS_RSSI_Get(void);
|
||||
#endif /* PIOS_OPENLRS_H */
|
||||
/**
|
||||
|
@ -155,16 +155,15 @@ struct pios_openlrs_dev {
|
||||
struct pios_semaphore *sema_isr;
|
||||
|
||||
// The PPM buffer
|
||||
int16_t ppm[OPENLRS_PPM_NUM_CHANNELS];
|
||||
|
||||
// RFM22B RCVR interface
|
||||
uintptr_t openlrs_rcvr_id;
|
||||
int16_t ppm[OPENLRS_PPM_NUM_CHANNELS];
|
||||
|
||||
// PPM callback.
|
||||
PIOS_OpenLRS_PPMReceivedCallback ppm_callback;
|
||||
// PPM context
|
||||
uint32_t ppm_context;
|
||||
|
||||
// Flag to indicate if link every acquired
|
||||
bool link_acquired;
|
||||
bool link_acquired;
|
||||
|
||||
// Active bound information data
|
||||
struct bind_data bind_data;
|
||||
|
@ -37,7 +37,6 @@
|
||||
extern const struct pios_rcvr_driver pios_openlrs_rcvr_driver;
|
||||
|
||||
extern int32_t PIOS_OpenLRS_Rcvr_Init(uint32_t *openlrs_rcvr_id, uintptr_t openlrs_id);
|
||||
extern int32_t PIOS_OpenLRS_Rcvr_UpdateChannels(uint32_t openlrs_rcvr_id, int16_t *channels);
|
||||
|
||||
#endif /* PIOS_OPENLRS_RCVR_PRIV_H */
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
extern const struct pios_rcvr_driver pios_oplinkrcvr_rcvr_driver;
|
||||
|
||||
extern int32_t PIOS_OPLinkRCVR_Init(uint32_t *oplinkrcvr_id);
|
||||
extern int32_t PIOS_OPLinkRCVR_Init(uint32_t *oplinkrcvr_id, uint32_t rfm22b_id);
|
||||
|
||||
#endif /* PIOS_OPLINKRCVR_PRIV_H */
|
||||
|
||||
|
@ -47,7 +47,7 @@ struct pios_rfm22b_cfg {
|
||||
uint8_t slave_num;
|
||||
enum gpio_direction gpio_direction;
|
||||
};
|
||||
typedef void (*PPMReceivedCallback)(const int16_t *channels);
|
||||
typedef void (*PPMReceivedCallback)(uint32_t context, const int16_t *channels);
|
||||
|
||||
enum rfm22b_tx_power {
|
||||
RFM22_tx_pwr_txpow_0 = 0x00, // +1dBm .. 1.25mW
|
||||
@ -117,7 +117,7 @@ extern bool PIOS_RFM22B_ReceivePacket(uint32_t rfm22b_id, uint8_t *p);
|
||||
extern bool PIOS_RFM22B_TransmitPacket(uint32_t rfm22b_id, uint8_t *p, uint8_t len);
|
||||
extern pios_rfm22b_int_result PIOS_RFM22B_ProcessTx(uint32_t rfm22b_id);
|
||||
extern pios_rfm22b_int_result PIOS_RFM22B_ProcessRx(uint32_t rfm22b_id);
|
||||
extern void PIOS_RFM22B_SetPPMCallback(uint32_t rfm22b_id, PPMReceivedCallback cb);
|
||||
extern void PIOS_RFM22B_SetPPMCallback(uint32_t rfm22b_id, PPMReceivedCallback cb, uint32_t cb_context);
|
||||
extern void PIOS_RFM22B_PPMSet(uint32_t rfm22b_id, int16_t *channels, uint8_t nchan);
|
||||
extern void PIOS_RFM22B_PPMGet(uint32_t rfm22b_id, int16_t *channels, uint8_t nchan);
|
||||
|
||||
|
@ -273,6 +273,8 @@ struct pios_rfm22b_dev {
|
||||
int16_t ppm[RFM22B_PPM_NUM_CHANNELS];
|
||||
// The PPM packet received callback.
|
||||
PPMReceivedCallback ppm_callback;
|
||||
// The PPM callback context
|
||||
uint32_t ppm_context;
|
||||
|
||||
// The id that the packet was received from
|
||||
uint32_t rx_destination_id;
|
||||
|
@ -780,7 +780,6 @@ void PIOS_Board_Init(void)
|
||||
bool is_coordinator = (oplinkSettings.Coordinator == OPLINKSETTINGS_COORDINATOR_TRUE);
|
||||
bool is_oneway = (oplinkSettings.OneWay == OPLINKSETTINGS_ONEWAY_TRUE);
|
||||
bool ppm_mode = (oplinkSettings.PPM == OPLINKSETTINGS_PPM_TRUE);
|
||||
bool ppm_only = (oplinkSettings.PPMOnly == OPLINKSETTINGS_PPMONLY_TRUE);
|
||||
if (oplinkSettings.MaxRFPower != OPLINKSETTINGS_MAXRFPOWER_0) {
|
||||
/* Configure the RFM22B device. */
|
||||
const struct pios_rfm22b_cfg *rfm22b_cfg = PIOS_BOARD_HW_DEFS_GetRfm22Cfg(bdinfo->board_rev);
|
||||
@ -829,11 +828,6 @@ void PIOS_Board_Init(void)
|
||||
PIOS_RFM22B_SetXtalCap(pios_rfm22b_id, oplinkSettings.RFXtalCap);
|
||||
PIOS_RFM22B_SetChannelConfig(pios_rfm22b_id, datarate, oplinkSettings.MinChannel, oplinkSettings.MaxChannel, is_coordinator, data_mode, ppm_mode);
|
||||
|
||||
/* Set the PPM callback if we should be receiving PPM. */
|
||||
if (ppm_mode || (ppm_only && !is_coordinator)) {
|
||||
PIOS_RFM22B_SetPPMCallback(pios_rfm22b_id, PIOS_Board_PPM_callback);
|
||||
}
|
||||
|
||||
/* Set the modem Tx power level */
|
||||
switch (oplinkSettings.MaxRFPower) {
|
||||
case OPLINKSETTINGS_MAXRFPOWER_125:
|
||||
@ -969,7 +963,7 @@ void PIOS_Board_Init(void)
|
||||
{
|
||||
OPLinkReceiverInitialize();
|
||||
uint32_t pios_oplinkrcvr_id;
|
||||
PIOS_OPLinkRCVR_Init(&pios_oplinkrcvr_id);
|
||||
PIOS_OPLinkRCVR_Init(&pios_oplinkrcvr_id, pios_rfm22b_id);
|
||||
uint32_t pios_oplinkrcvr_rcvr_id;
|
||||
if (PIOS_RCVR_Init(&pios_oplinkrcvr_rcvr_id, &pios_oplinkrcvr_rcvr_driver, pios_oplinkrcvr_id)) {
|
||||
PIOS_Assert(0);
|
||||
|
@ -122,7 +122,7 @@ static void PIOS_Board_configure_com(const struct pios_usart_cfg *usart_port_cfg
|
||||
|
||||
|
||||
// Forward definitions
|
||||
static void PIOS_Board_PPM_callback(const int16_t *channels);
|
||||
static void PIOS_Board_PPM_callback(uint32_t context, const int16_t *channels);
|
||||
|
||||
/**
|
||||
* PIOS_Board_Init()
|
||||
@ -408,7 +408,7 @@ void PIOS_Board_Init(void)
|
||||
oplinkStatus.LinkState = OPLINKSTATUS_LINKSTATE_ENABLED;
|
||||
|
||||
PIOS_OpenLRS_Init(&openlrs_id, PIOS_RFM22_SPI_PORT, 0, openlrs_cfg);
|
||||
PIOS_OpenLRS_RegisterPPMCallback(openlrs_id, PIOS_Board_PPM_callback);
|
||||
PIOS_OpenLRS_RegisterPPMCallback(openlrs_id, PIOS_Board_PPM_callback, 0);
|
||||
#endif /* PIOS_INCLUDE_OPENLRS */
|
||||
} else {
|
||||
oplinkStatus.LinkState = OPLINKSTATUS_LINKSTATE_ENABLED;
|
||||
@ -493,7 +493,7 @@ void PIOS_Board_Init(void)
|
||||
|
||||
/* Set the PPM callback if we should be receiving PPM. */
|
||||
if (ppm_mode || (ppm_only && !is_coordinator)) {
|
||||
PIOS_RFM22B_SetPPMCallback(pios_rfm22b_id, PIOS_Board_PPM_callback);
|
||||
PIOS_RFM22B_SetPPMCallback(pios_rfm22b_id, PIOS_Board_PPM_callback, 0);
|
||||
}
|
||||
|
||||
// Reinitialize the modem to affect the changes.
|
||||
@ -558,7 +558,7 @@ void PIOS_Board_Init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void PIOS_Board_PPM_callback(const int16_t *channels)
|
||||
static void PIOS_Board_PPM_callback(__attribute__((unused)) uint32_t context, const int16_t *channels)
|
||||
{
|
||||
#if defined(PIOS_INCLUDE_PPM) && defined(PIOS_INCLUDE_PPM_OUT)
|
||||
if (pios_ppm_out_id) {
|
||||
|
@ -391,16 +391,6 @@ static void PIOS_Board_configure_ppm(const struct pios_ppm_cfg *ppm_cfg)
|
||||
pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_PPM] = pios_ppm_rcvr_id;
|
||||
}
|
||||
|
||||
static void PIOS_Board_PPM_callback(const int16_t *channels)
|
||||
{
|
||||
OPLinkReceiverData opl_rcvr;
|
||||
|
||||
for (uint8_t i = 0; i < OPLINKRECEIVER_CHANNEL_NUMELEM; ++i) {
|
||||
opl_rcvr.Channel[i] = (i < RFM22B_PPM_NUM_CHANNELS) ? channels[i] : PIOS_RCVR_TIMEOUT;
|
||||
}
|
||||
OPLinkReceiverSet(&opl_rcvr);
|
||||
}
|
||||
|
||||
/**
|
||||
* PIOS_Board_Init()
|
||||
* initializes all the core subsystems on this specific hardware
|
||||
@ -891,7 +881,6 @@ void PIOS_Board_Init(void)
|
||||
(oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_DATAANDCONTROL));
|
||||
bool ppm_mode = ((oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_CONTROL) ||
|
||||
(oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_DATAANDCONTROL));
|
||||
bool ppm_only = (oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_CONTROL);
|
||||
bool is_enabled = ((oplinkSettings.Protocol != OPLINKSETTINGS_PROTOCOL_DISABLED) &&
|
||||
((oplinkSettings.MaxRFPower != OPLINKSETTINGS_MAXRFPOWER_0) || openlrs));
|
||||
if (is_enabled) {
|
||||
@ -961,11 +950,6 @@ void PIOS_Board_Init(void)
|
||||
PIOS_RFM22B_SetXtalCap(pios_rfm22b_id, oplinkSettings.RFXtalCap);
|
||||
PIOS_RFM22B_SetChannelConfig(pios_rfm22b_id, datarate, oplinkSettings.MinChannel, oplinkSettings.MaxChannel, is_coordinator, data_mode, ppm_mode);
|
||||
|
||||
/* Set the PPM callback if we should be receiving PPM. */
|
||||
if (ppm_mode || (ppm_only && !is_coordinator)) {
|
||||
PIOS_RFM22B_SetPPMCallback(pios_rfm22b_id, PIOS_Board_PPM_callback);
|
||||
}
|
||||
|
||||
/* Set the modem Tx power level */
|
||||
switch (oplinkSettings.MaxRFPower) {
|
||||
case OPLINKSETTINGS_MAXRFPOWER_125:
|
||||
@ -1131,7 +1115,7 @@ void PIOS_Board_Init(void)
|
||||
{
|
||||
OPLinkReceiverInitialize();
|
||||
uint32_t pios_oplinkrcvr_id;
|
||||
PIOS_OPLinkRCVR_Init(&pios_oplinkrcvr_id);
|
||||
PIOS_OPLinkRCVR_Init(&pios_oplinkrcvr_id, pios_rfm22b_id);
|
||||
uint32_t pios_oplinkrcvr_rcvr_id;
|
||||
if (PIOS_RCVR_Init(&pios_oplinkrcvr_rcvr_id, &pios_oplinkrcvr_rcvr_driver, pios_oplinkrcvr_id)) {
|
||||
PIOS_Assert(0);
|
||||
|
@ -391,16 +391,6 @@ static void PIOS_Board_configure_hott(const struct pios_usart_cfg *usart_cfg, en
|
||||
pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_HOTT] = pios_hott_rcvr_id;
|
||||
}
|
||||
|
||||
static void PIOS_Board_PPM_callback(const int16_t *channels)
|
||||
{
|
||||
OPLinkReceiverData opl_rcvr;
|
||||
|
||||
for (uint8_t i = 0; i < OPLINKRECEIVER_CHANNEL_NUMELEM; ++i) {
|
||||
opl_rcvr.Channel[i] = (i < RFM22B_PPM_NUM_CHANNELS) ? channels[i] : PIOS_RCVR_TIMEOUT;
|
||||
}
|
||||
OPLinkReceiverSet(&opl_rcvr);
|
||||
}
|
||||
|
||||
/**
|
||||
* PIOS_Board_Init()
|
||||
* initializes all the core subsystems on this specific hardware
|
||||
@ -831,7 +821,6 @@ void PIOS_Board_Init(void)
|
||||
(oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_DATAANDCONTROL));
|
||||
bool ppm_mode = ((oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_CONTROL) ||
|
||||
(oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_DATAANDCONTROL));
|
||||
bool ppm_only = (oplinkSettings.LinkType == OPLINKSETTINGS_LINKTYPE_CONTROL);
|
||||
bool is_enabled = ((oplinkSettings.Protocol != OPLINKSETTINGS_PROTOCOL_DISABLED) &&
|
||||
((oplinkSettings.MaxRFPower != OPLINKSETTINGS_MAXRFPOWER_0) || openlrs));
|
||||
if (is_enabled) {
|
||||
@ -901,11 +890,6 @@ void PIOS_Board_Init(void)
|
||||
PIOS_RFM22B_SetXtalCap(pios_rfm22b_id, oplinkSettings.RFXtalCap);
|
||||
PIOS_RFM22B_SetChannelConfig(pios_rfm22b_id, datarate, oplinkSettings.MinChannel, oplinkSettings.MaxChannel, is_coordinator, data_mode, ppm_mode);
|
||||
|
||||
/* Set the PPM callback if we should be receiving PPM. */
|
||||
if (ppm_mode || (ppm_only && !is_coordinator)) {
|
||||
PIOS_RFM22B_SetPPMCallback(pios_rfm22b_id, PIOS_Board_PPM_callback);
|
||||
}
|
||||
|
||||
/* Set the modem Tx poer level */
|
||||
switch (oplinkSettings.MaxRFPower) {
|
||||
case OPLINKSETTINGS_MAXRFPOWER_125:
|
||||
@ -1066,7 +1050,7 @@ void PIOS_Board_Init(void)
|
||||
{
|
||||
OPLinkReceiverInitialize();
|
||||
uint32_t pios_oplinkrcvr_id;
|
||||
PIOS_OPLinkRCVR_Init(&pios_oplinkrcvr_id);
|
||||
PIOS_OPLinkRCVR_Init(&pios_oplinkrcvr_id, pios_rfm22b_id);
|
||||
uint32_t pios_oplinkrcvr_rcvr_id;
|
||||
if (PIOS_RCVR_Init(&pios_oplinkrcvr_rcvr_id, &pios_oplinkrcvr_rcvr_driver, pios_oplinkrcvr_id)) {
|
||||
PIOS_Assert(0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user