29 #include "generated/airframe.h"
33 #if SERVOS_SBUS_NB > ACTUATORS_SBUS_MAX_NB
34 #error SBUS actuators only support less then 7 servos
38 #if PERIODIC_FREQUENCY < 150
39 #error Sbus actuators need at leest a frequency of 150 Hz
41 static uint8_t freq_trig = PERIODIC_FREQUENCY / 142.0 + 0.5;
68 if (cnt == freq_trig) {
86 #define SBUS_START_BYTE 0x0f
87 #define SBUS_END_BYTE 0x00
89 #define SBUS_BIT_PER_CHANNEL 11
101 for (i = 0; i < 22; i++) {
108 data[ind] |= (chn >> (3 + shift)) & 0xff;
110 data[ind + 1] |= (chn >> (shift - 5)) & 0xff;
111 data[ind + 2] |= (chn << (3 - shift)) &
114 data[ind + 1] |= (chn << (5 - shift)) &
121 for (i = 0; i < 22; i++) {
122 dev->put_byte(
dev->periph, 0, data[i]);
126 dev->put_byte(
dev->periph, 0, 0x00);
void actuators_sbus_set(void)
static void actuators_sbus_send(struct link_device *dev)
struct ActuatorsSbus actuators_sbus
void actuators_sbus_init(void)
#define SBUS_BIT_PER_CHANNEL
Sbus actuator driver, which can output as 7 sbus channels at ~11ms.
int32_t cmds[ACTUATORS_SBUS_MAX_NB]
#define ACTUATORS_SBUS_MAX_NB
struct link_device * device
void uart_periph_set_bits_stop_parity(struct uart_periph *periph, uint8_t bits, uint8_t stop, uint8_t parity)
void uart_periph_set_baudrate(struct uart_periph *periph, uint32_t baud)
Hardware independent API for actuators (servos, motor controllers).
static const struct usb_device_descriptor dev
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.