1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-10 18:24:11 +01:00
LibrePilot/flight/PiOS/inc/pios_sbus_priv.h
Stacey Sheldon 5f8760a55c com: Move buffering out of USART/HID layer and into COM layer
This allows the spektrum and sbus receiver drivers to bind
directly to the usart layer using a properly exported API
rather than overriding the interrupt handler.

Bytes are now pushed directly from the usart layer into the
com layer without any buffering.  The com layer performs all
of the buffering.

A further benefit from this approach is that we can put all
blocking/non-blocking behaviour into the COM layer and not
in the underlying drivers.

Misc related changes:
 - Remove obsolete .handler field from irq configs
 - Adapt all users of PIOS_COM_* functions to new API
 - Fixup callers of PIOS_USB_HID_Init()
2011-07-27 19:45:38 -04:00

88 lines
2.8 KiB
C

/**
******************************************************************************
* @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>
/*
* 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:
* 0x01 - digital channel 1,
* 0x02 - digital channel 2,
* 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
#define SBUS_FLAG_DG1 0x01
#define SBUS_FLAG_DG2 0x02
#define SBUS_FLAG_FL 0x04
#define SBUS_FLAG_FS 0x08
/*
* S.Bus protocol provides up to 16 analog and 2 digital channels.
* Only 8 channels are currently supported by the OpenPilot.
*/
#define SBUS_NUMBER_OF_CHANNELS 8
/*
* S.Bus configuration programmable invertor
*/
struct pios_sbus_cfg {
struct stm32_gpio inv;
void (*gpio_clk_func)(uint32_t periph, FunctionalState state);
uint32_t gpio_clk_periph;
BitAction gpio_inv_enable;
};
extern const struct pios_rcvr_driver pios_sbus_rcvr_driver;
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);
#endif /* PIOS_SBUS_PRIV_H */
/**
* @}
* @}
*/