Paparazzi UAS
v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
|
#include <stdint.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/timer.h>
#include <libopencm3/stm32/usart.h>
#include <libopencm3/cm3/nvic.h>
#include "subsystems/radio_control.h"
#include "subsystems/radio_control/spektrum_arch.h"
#include "mcu_periph/uart.h"
#include "mcu_periph/gpio.h"
#include "mcu_periph/sys_time.h"
#include "mcu_arch.h"
#include "std.h"
#include <BOARD_CONFIG>
Go to the source code of this file.
Data Structures | |
struct | SpektrumStateStruct |
Typedefs | |
typedef struct SpektrumStateStruct | SpektrumStateType |
Functions | |
void | SpektrumTimerInit (void) |
void | radio_control_impl_init (void) |
static void | SpektrumParser (uint8_t _c, SpektrumStateType *spektrum_state, bool secondary_receiver) |
void | RadioControlEventImp (void(*frame_handler)(void)) |
timer_clear_flag (TIMx, TIM_SR_UIF) | |
if (PrimarySpektrumState.SpektrumTimer) | |
void | SpektrumUartInit (void) |
void PrimaryUart() | _ISR (void) |
void | radio_control_spektrum_try_bind (void) |
Variables | |
SpektrumStateType | PrimarySpektrumState = {1, 0, 0, 0, 0, 0, 0, 0, 0, {0}} |
int16_t | SpektrumBuf [SPEKTRUM_CHANNELS_PER_FRAME *MAX_SPEKTRUM_FRAMES] |
int8_t | SpektrumSigns [] = RADIO_CONTROL_SPEKTRUM_SIGNS |
static uint8_t | EncodingType = 0 |
static uint8_t | ExpectedFrames = 0 |
struct SpektrumStateStruct |
Definition at line 130 of file spektrum_arch.c.
Data Fields | ||
---|---|---|
uint8_t | ChannelCnt | |
uint8_t | FrameCnt | |
uint8_t | HighByte | |
uint16_t | LostFrameCnt | |
uint8_t | RcAvailable | |
uint8_t | ReSync | |
uint8_t | SecondFrame | |
uint8_t | SpektrumTimer | |
uint8_t | Sync | |
int16_t | values[SPEKTRUM_CHANNELS_PER_FRAME *MAX_SPEKTRUM_FRAMES] |
Definition at line 122 of file spektrum_arch.c.
Definition at line 126 of file spektrum_arch.c.
#define _PrimaryUart | ( | dev, | |
_x | |||
) | __PrimaryUart(dev, _x) |
Definition at line 123 of file spektrum_arch.c.
#define _SecondaryUart | ( | dev, | |
_x | |||
) | __SecondaryUart(dev, _x) |
Definition at line 127 of file spektrum_arch.c.
#define EVALUATOR2 | ( | x, | |
y | |||
) | PASTER2(x,y) |
Definition at line 69 of file spektrum_arch.c.
#define EVALUATOR3 | ( | x, | |
y, | |||
z | |||
) | PASTER3(x,y,z) |
Definition at line 62 of file spektrum_arch.c.
#define MASTER_RECEIVER_PULSES 5 |
Definition at line 52 of file spektrum_arch.c.
Referenced by radio_control_spektrum_try_bind().
#define MAX_BYTE_SPACE 3 |
Definition at line 57 of file spektrum_arch.c.
Referenced by SpektrumParser().
#define MAX_SPEKTRUM_CHANNELS 16 |
Definition at line 47 of file spektrum_arch.c.
#define MAX_SPEKTRUM_FRAMES 2 |
Definition at line 46 of file spektrum_arch.c.
#define MIN_FRAME_SPACE 70 |
Definition at line 56 of file spektrum_arch.c.
Referenced by SpektrumParser().
#define NVIC_PRIMARY_UART_PRIO 2 |
Definition at line 112 of file spektrum_arch.c.
Referenced by SpektrumUartInit().
#define NVIC_TIM6_DAC_IRQ_PRIO 2 |
Definition at line 85 of file spektrum_arch.c.
#define NVIC_TIM6_IRQ_PRIO 2 |
Definition at line 79 of file spektrum_arch.c.
#define NVIC_TIMx_DAC_IRQ EVALUATOR3(NVIC_TIM, SPEKTRUM_TIMER,_DAC_IRQ) |
Definition at line 64 of file spektrum_arch.c.
Referenced by SpektrumTimerInit().
#define NVIC_TIMx_DAC_IRQ_PRIO 2 |
Definition at line 86 of file spektrum_arch.c.
Referenced by SpektrumTimerInit().
#define NVIC_TIMx_IRQ EVALUATOR3(NVIC_TIM, SPEKTRUM_TIMER,_IRQ) |
Definition at line 63 of file spektrum_arch.c.
Referenced by SpektrumTimerInit().
#define NVIC_TIMx_IRQ_PRIO 2 |
Definition at line 80 of file spektrum_arch.c.
Referenced by SpektrumTimerInit().
#define ONE_MHZ 1000000 |
Definition at line 49 of file spektrum_arch.c.
Referenced by SpektrumTimerInit().
#define PASTER2 | ( | x, | |
y | |||
) | x ## y |
Definition at line 68 of file spektrum_arch.c.
#define PASTER3 | ( | x, | |
y, | |||
z | |||
) | x ## y ## z |
Definition at line 61 of file spektrum_arch.c.
#define PrimaryUart | ( | _x | ) | _PrimaryUart(RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT, _x) |
Definition at line 124 of file spektrum_arch.c.
Referenced by _ISR(), and SpektrumUartInit().
#define RC_SET_POLARITY gpio_clear |
Set polarity using RC_POLARITY_GPIO.
SBUS signal has a reversed polarity compared to normal UART this allows to using hardware UART peripheral by changing the input signal polarity. Setting this gpio ouput high inverts the signal, output low sets it to normal polarity. So for spektrum this is set to normal polarity.
Definition at line 193 of file spektrum_arch.c.
Referenced by radio_control_impl_init().
#define RCC_TIMx EVALUATOR2(RCC_TIM, SPEKTRUM_TIMER) |
Definition at line 71 of file spektrum_arch.c.
Referenced by SpektrumTimerInit().
#define SecondaryUart | ( | _x | ) | _SecondaryUart(RADIO_CONTROL_SPEKTRUM_SECONDARY_PORT, _x) |
Definition at line 128 of file spektrum_arch.c.
Referenced by SpektrumUartInit().
#define SLAVE_RECEIVER_PULSES 6 |
Definition at line 53 of file spektrum_arch.c.
Referenced by radio_control_spektrum_try_bind().
#define SPEKTRUM_CHANNELS_PER_FRAME 7 |
Definition at line 45 of file spektrum_arch.c.
Referenced by RadioControlEventImp(), and SpektrumParser().
#define SPEKTRUM_PRIMARY_BIND_CONF_PIN PrimaryUart(_PIN) |
Definition at line 730 of file spektrum_arch.c.
Referenced by radio_control_spektrum_try_bind().
#define SPEKTRUM_PRIMARY_BIND_CONF_PORT PrimaryUart(_BANK) |
Definition at line 727 of file spektrum_arch.c.
Referenced by radio_control_spektrum_try_bind().
#define SPEKTRUM_SECONDARY_BIND_CONF_PIN SecondaryUart(_PIN) |
Definition at line 736 of file spektrum_arch.c.
Referenced by radio_control_spektrum_try_bind().
#define SPEKTRUM_SECONDARY_BIND_CONF_PORT SecondaryUart(_BANK) |
Definition at line 733 of file spektrum_arch.c.
Referenced by radio_control_spektrum_try_bind().
#define SPEKTRUM_TIMER 6 |
Definition at line 74 of file spektrum_arch.c.
#define TIM_TICS_FOR_100us 100 |
Definition at line 55 of file spektrum_arch.c.
Referenced by SpektrumTimerInit().
#define TIMx EVALUATOR2(TIM, SPEKTRUM_TIMER) |
Definition at line 70 of file spektrum_arch.c.
Referenced by SpektrumTimerInit().
#define TIMx_DAC_ISR EVALUATOR3(tim, SPEKTRUM_TIMER,_dac_isr) |
Definition at line 66 of file spektrum_arch.c.
#define TIMx_ISR EVALUATOR3(tim, SPEKTRUM_TIMER,_isr) |
Definition at line 65 of file spektrum_arch.c.
typedef struct SpektrumStateStruct SpektrumStateType |
Definition at line 143 of file spektrum_arch.c.
void PrimaryUart() _ISR | ( | void | ) |
Definition at line 678 of file spektrum_arch.c.
References FALSE, PrimaryUart, and SpektrumParser().
if | ( | PrimarySpektrumState. | SpektrumTimer | ) |
Definition at line 600 of file spektrum_arch.c.
References SpektrumStateStruct::SpektrumTimer.
Referenced by alt_filter_periodic(), b2_hff_update_gps(), h_ctl_pitch_loop(), humid_sht_event_i2c(), i2c_idle(), i2c_irq(), i2c_setbitrate(), image_labeling(), marker(), ms5611_i2c_event(), ms5611_spi_event(), spi_submit(), texton_func(), udp_receive(), udp_send_message(), and vertical_ctrl_module_run().
void radio_control_impl_init | ( | void | ) |
Definition at line 201 of file spektrum_arch.c.
References gpio_setup_output(), RC_POLARITY_GPIO_PIN, RC_POLARITY_GPIO_PORT, RC_SET_POLARITY, SpektrumStateStruct::ReSync, SpektrumTimerInit(), and SpektrumUartInit().
void radio_control_spektrum_try_bind | ( | void | ) |
Definition at line 747 of file spektrum_arch.c.
References gpio_clear(), gpio_get(), gpio_set(), gpio_setup_input(), gpio_setup_input_pulldown(), gpio_setup_input_pullup(), gpio_setup_output(), MASTER_RECEIVER_PULSES, SLAVE_RECEIVER_PULSES, SPEKTRUM_BIND_PIN, SPEKTRUM_BIND_PIN_PORT, SPEKTRUM_PRIMARY_BIND_CONF_PIN, SPEKTRUM_PRIMARY_BIND_CONF_PORT, SPEKTRUM_SECONDARY_BIND_CONF_PIN, SPEKTRUM_SECONDARY_BIND_CONF_PORT, and sys_time_usleep().
void RadioControlEventImp | ( | void(*)(void) | frame_handler | ) |
Definition at line 448 of file spektrum_arch.c.
References SpektrumStateStruct::ChannelCnt, ExpectedFrames, RadioControl::frame_cpt, SpektrumStateStruct::LostFrameCnt, MAX_PPRZ, Min, radio_control, RADIO_CONTROL_NB_CHANNEL, RADIO_THROTTLE, RC_OK, SpektrumStateStruct::RcAvailable, spektrum_available, SPEKTRUM_CHANNELS_PER_FRAME, SPEKTRUM_NB_CHANNEL, RadioControl::status, RadioControl::time_since_last_frame, RadioControl::values, and SpektrumStateStruct::values.
|
inlinestatic |
Definition at line 327 of file spektrum_arch.c.
References SpektrumStateStruct::ChannelCnt, ExpectedFrames, SpektrumStateStruct::FrameCnt, SpektrumStateStruct::HighByte, SpektrumStateStruct::LostFrameCnt, MAX_BYTE_SPACE, MIN_FRAME_SPACE, SpektrumStateStruct::RcAvailable, SpektrumStateStruct::ReSync, SpektrumStateStruct::SecondFrame, SPEKTRUM_CHANNELS_PER_FRAME, SpektrumStateStruct::SpektrumTimer, SpektrumStateStruct::Sync, and SpektrumStateStruct::values.
Referenced by _ISR().
void SpektrumTimerInit | ( | void | ) |
Definition at line 553 of file spektrum_arch.c.
References NVIC_TIMx_DAC_IRQ, NVIC_TIMx_DAC_IRQ_PRIO, NVIC_TIMx_IRQ, NVIC_TIMx_IRQ_PRIO, ONE_MHZ, RCC_TIMx, TIM_TICS_FOR_100us, timer_clear_flag(), timer_get_frequency(), and TIMx.
Referenced by radio_control_impl_init().
void SpektrumUartInit | ( | void | ) |
Definition at line 615 of file spektrum_arch.c.
References B115200, FALSE, gpio_enable_clock(), gpio_setup_pin_af(), NVIC_PRIMARY_UART_PRIO, PrimaryUart, and SecondaryUart.
Referenced by radio_control_impl_init(), and received_spektrum_soft_bind().
timer_clear_flag | ( | TIMx | , |
TIM_SR_UIF | |||
) |
Referenced by clear_timer_flag(), and SpektrumTimerInit().
|
static |
Definition at line 178 of file spektrum_arch.c.
|
static |
Definition at line 179 of file spektrum_arch.c.
Referenced by RadioControlEventImp(), and SpektrumParser().
SpektrumStateType PrimarySpektrumState = {1, 0, 0, 0, 0, 0, 0, 0, 0, {0}} |
Definition at line 145 of file spektrum_arch.c.
int16_t SpektrumBuf[SPEKTRUM_CHANNELS_PER_FRAME *MAX_SPEKTRUM_FRAMES] |
Definition at line 156 of file spektrum_arch.c.
int8_t SpektrumSigns[] = RADIO_CONTROL_SPEKTRUM_SIGNS |
Definition at line 175 of file spektrum_arch.c.