2011-06-13 02:04:49 +02:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
|
|
|
* @{
|
|
|
|
* @addtogroup PIOS_SBUS S.Bus Functions
|
|
|
|
* @brief PIOS interface to read and write from Futaba S.Bus port
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file pios_sbus_priv.h
|
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011.
|
|
|
|
* @brief Futaba S.Bus Private structures.
|
|
|
|
* @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 PIOS_SBUS_PRIV_H
|
|
|
|
#define PIOS_SBUS_PRIV_H
|
|
|
|
|
|
|
|
#include <pios.h>
|
|
|
|
#include <pios_stm32.h>
|
|
|
|
#include <pios_usart_priv.h>
|
|
|
|
|
2011-06-18 22:19:57 +02:00
|
|
|
/*
|
|
|
|
* S.Bus serial port settings:
|
|
|
|
* 100000bps inverted serial stream, 8 bits, even parity, 2 stop bits
|
|
|
|
* frame period is 7ms (HS) or 14ms (FS)
|
|
|
|
*
|
|
|
|
* Frame structure:
|
|
|
|
* 1 byte - 0x0f (start of frame byte)
|
|
|
|
* 22 bytes - channel data (11 bit/channel, 16 channels, LSB first)
|
|
|
|
* 1 byte - bit flags:
|
2011-09-11 21:04:03 +02:00
|
|
|
* 0x01 - discrete channel 1,
|
|
|
|
* 0x02 - discrete channel 2,
|
2011-06-18 22:19:57 +02:00
|
|
|
* 0x04 - lost frame flag,
|
|
|
|
* 0x08 - failsafe flag,
|
|
|
|
* 0xf0 - reserved
|
|
|
|
* 1 byte - 0x00 (end of frame byte)
|
|
|
|
*/
|
|
|
|
#define SBUS_FRAME_LENGTH (1+22+1+1)
|
|
|
|
#define SBUS_SOF_BYTE 0x0f
|
|
|
|
#define SBUS_EOF_BYTE 0x00
|
2011-09-11 21:04:03 +02:00
|
|
|
#define SBUS_FLAG_DC1 0x01
|
|
|
|
#define SBUS_FLAG_DC2 0x02
|
2011-06-18 22:19:57 +02:00
|
|
|
#define SBUS_FLAG_FL 0x04
|
|
|
|
#define SBUS_FLAG_FS 0x08
|
|
|
|
|
|
|
|
/*
|
2011-09-11 21:04:03 +02:00
|
|
|
* S.Bus protocol provides 16 proportional and 2 discrete channels.
|
|
|
|
* Do not change unless driver code is updated accordingly.
|
2011-06-18 22:19:57 +02:00
|
|
|
*/
|
2011-09-11 21:04:03 +02:00
|
|
|
#define SBUS_NUMBER_OF_CHANNELS (16 + 2)
|
|
|
|
|
|
|
|
/* Discrete channels represented as bits, provide values for them */
|
|
|
|
#define SBUS_VALUE_MIN 352
|
|
|
|
#define SBUS_VALUE_MAX 1696
|
2011-06-18 22:19:57 +02:00
|
|
|
|
2011-06-19 13:30:13 +02:00
|
|
|
/*
|
bootcfg: use UAVobj to control boot-time HW config
This should mark an end to the compile-time selection of HW
configurations.
Minor changes in board initialization for all platforms:
- Most config structs are marked static to prevent badly written
drivers from directly referring to config data.
- Adapt to changes in .irq fields in config data.
- Adapt to changes in USART IRQ handling.
Major changes in board initialization for CC:
- Use HwSettings UAVObj to decide which drivers to attach to
the "main" port and the flexi port, and select the appropriate
device configuration data.
- HwSettings allows choosing between Disabled, Telemetry, SBUS,
Spektrum,GPS, and I2C for each of the two ports.
- Use ManualControlSettings.InputMode to init/configure the
appropriate receiver module, and register its available rx channels
with the PIOS_RCVR layer. Can choose between PWM, Spektrum and PPM
at board init time. PPM driver is broken, and SBUS will work once
it is added to this UAVObj as an option.
- CC build now includes code for SBUS, Spektrum and PWM receivers in
every firmware image.
PIOS_USART driver:
- Now handles its own low-level IRQs internally
- If NULL upper-level IRQ handler is bound in at board init time
then rx/tx is satisfied by internal PIOS_USART buffered IO routines
which are (typically) attached to the COM layer.
- If an alternate upper-level IRQ handler is bound in at board init
then that handler is called and expected to clear down the USART
IRQ sources. This is used by Spektrum and SBUS drivers.
PIOS_SBUS and PIOS_SPEKTRUM drivers:
- Improved data/API hiding
- No longer assume they know where their config data is stored which
allows for boot-time alternate configurations for the driver.
- Now registers an upper-level IRQ handlerwith the USART layer to
decouple the driver from which USART it is actually attached to.
2011-07-06 02:21:00 +02:00
|
|
|
* S.Bus configuration programmable invertor
|
2011-06-19 13:30:13 +02:00
|
|
|
*/
|
2011-06-13 02:04:49 +02:00
|
|
|
struct pios_sbus_cfg {
|
bootcfg: use UAVobj to control boot-time HW config
This should mark an end to the compile-time selection of HW
configurations.
Minor changes in board initialization for all platforms:
- Most config structs are marked static to prevent badly written
drivers from directly referring to config data.
- Adapt to changes in .irq fields in config data.
- Adapt to changes in USART IRQ handling.
Major changes in board initialization for CC:
- Use HwSettings UAVObj to decide which drivers to attach to
the "main" port and the flexi port, and select the appropriate
device configuration data.
- HwSettings allows choosing between Disabled, Telemetry, SBUS,
Spektrum,GPS, and I2C for each of the two ports.
- Use ManualControlSettings.InputMode to init/configure the
appropriate receiver module, and register its available rx channels
with the PIOS_RCVR layer. Can choose between PWM, Spektrum and PPM
at board init time. PPM driver is broken, and SBUS will work once
it is added to this UAVObj as an option.
- CC build now includes code for SBUS, Spektrum and PWM receivers in
every firmware image.
PIOS_USART driver:
- Now handles its own low-level IRQs internally
- If NULL upper-level IRQ handler is bound in at board init time
then rx/tx is satisfied by internal PIOS_USART buffered IO routines
which are (typically) attached to the COM layer.
- If an alternate upper-level IRQ handler is bound in at board init
then that handler is called and expected to clear down the USART
IRQ sources. This is used by Spektrum and SBUS drivers.
PIOS_SBUS and PIOS_SPEKTRUM drivers:
- Improved data/API hiding
- No longer assume they know where their config data is stored which
allows for boot-time alternate configurations for the driver.
- Now registers an upper-level IRQ handlerwith the USART layer to
decouple the driver from which USART it is actually attached to.
2011-07-06 02:21:00 +02:00
|
|
|
struct stm32_gpio inv;
|
2011-06-19 13:30:13 +02:00
|
|
|
void (*gpio_clk_func)(uint32_t periph, FunctionalState state);
|
|
|
|
uint32_t gpio_clk_periph;
|
|
|
|
BitAction gpio_inv_enable;
|
2011-06-13 02:04:49 +02:00
|
|
|
};
|
|
|
|
|
2011-06-25 15:27:28 +02:00
|
|
|
extern const struct pios_rcvr_driver pios_sbus_rcvr_driver;
|
|
|
|
|
2011-07-26 06:27:03 +02:00
|
|
|
extern int32_t PIOS_SBUS_Init(uint32_t * sbus_id, const struct pios_sbus_cfg *cfg, const struct pios_com_driver * driver, uint32_t lower_id);
|
2011-06-13 02:04:49 +02:00
|
|
|
|
|
|
|
#endif /* PIOS_SBUS_PRIV_H */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
* @}
|
|
|
|
*/
|