Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
spektrum_arch.c File Reference
#include <stdint.h>
#include <stm32/gpio.h>
#include <stm32/rcc.h>
#include <stm32/tim.h>
#include <stm32/misc.h>
#include <stm32/usart.h>
#include "subsystems/radio_control.h"
#include "subsystems/radio_control/spektrum_arch.h"
#include "mcu_periph/uart.h"
#include "pprz_baudrate.h"
+ Include dependency graph for spektrum_arch.c:

Go to the source code of this file.

Data Structures

struct  SpektrumStateStruct
 

Macros

#define SPEKTRUM_CHANNELS_PER_FRAME   7
 
#define MAX_SPEKTRUM_FRAMES   2
 
#define MAX_SPEKTRUM_CHANNELS   16
 
#define MAX_DELAY   INT16_MAX
 
#define DELAY_TIM_FREQUENCY   1000000
 
#define MASTER_RECEIVER_PULSES   5
 
#define SLAVE_RECEIVER_PULSES   6
 
#define BIND_PIN   GPIO_Pin_3
 
#define BIND_PIN_PORT   GPIOC
 
#define BIND_PIN_PERIPH   RCC_APB2Periph_GPIOC
 
#define TIM_FREQ_1000000   1000000
 
#define TIM_TICS_FOR_100us   100
 
#define MIN_FRAME_SPACE   70
 
#define MAX_BYTE_SPACE   3
 
#define __PrimaryUart(dev, _x)   dev##_x
 
#define _PrimaryUart(dev, _x)   __PrimaryUart(dev, _x)
 
#define PrimaryUart(_x)   _PrimaryUart(RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT, _x)
 
#define __SecondaryUart(dev, _x)   dev##_x
 
#define _SecondaryUart(dev, _x)   __SecondaryUart(dev, _x)
 
#define SecondaryUart(_x)   _SecondaryUart(RADIO_CONTROL_SPEKTRUM_SECONDARY_PORT, _x)
 
#define SpektrumParser(_c, _SpektrumState, _receiver)
 

Typedefs

typedef struct SpektrumStateStruct SpektrumStateType
 

Functions

void SpektrumUartInit (void)
 
void SpektrumTimerInit (void)
 
void DebugInit (void)
 
void tim6_irq_handler (void)
 
static void DelayUs (uint16_t uSecs)
 
static void DelayMs (uint16_t mSecs)
 
static void SpektrumDelayInit (void)
 
void radio_control_impl_init (void)
 
void RadioControlEventImp (void(*frame_handler)(void))
 
void PrimaryUart() _irq_handler (void)
 
void radio_control_spektrum_try_bind (void)
 

Variables

SpektrumStateType PrimarySpektrumState = {1,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
 

Macro Definition Documentation

#define __PrimaryUart (   dev,
  _x 
)    dev##_x

Definition at line 65 of file spektrum_arch.c.

#define __SecondaryUart (   dev,
  _x 
)    dev##_x

Definition at line 69 of file spektrum_arch.c.

#define _PrimaryUart (   dev,
  _x 
)    __PrimaryUart(dev, _x)

Definition at line 66 of file spektrum_arch.c.

#define _SecondaryUart (   dev,
  _x 
)    __SecondaryUart(dev, _x)

Definition at line 70 of file spektrum_arch.c.

#define BIND_PIN   GPIO_Pin_3

Definition at line 49 of file spektrum_arch.c.

Referenced by radio_control_spektrum_try_bind().

#define BIND_PIN_PERIPH   RCC_APB2Periph_GPIOC

Definition at line 51 of file spektrum_arch.c.

Referenced by radio_control_spektrum_try_bind().

#define BIND_PIN_PORT   GPIOC

Definition at line 50 of file spektrum_arch.c.

Referenced by radio_control_spektrum_try_bind().

#define DELAY_TIM_FREQUENCY   1000000

Definition at line 43 of file spektrum_arch.c.

Referenced by DelayMs(), and SpektrumDelayInit().

#define MASTER_RECEIVER_PULSES   5

Definition at line 45 of file spektrum_arch.c.

Referenced by radio_control_spektrum_try_bind().

#define MAX_BYTE_SPACE   3

Definition at line 56 of file spektrum_arch.c.

#define MAX_DELAY   INT16_MAX

Definition at line 41 of file spektrum_arch.c.

#define MAX_SPEKTRUM_CHANNELS   16

Definition at line 39 of file spektrum_arch.c.

#define MAX_SPEKTRUM_FRAMES   2

Definition at line 38 of file spektrum_arch.c.

#define MIN_FRAME_SPACE   70

Definition at line 55 of file spektrum_arch.c.

#define PrimaryUart (   _x)    _PrimaryUart(RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT, _x)

Definition at line 67 of file spektrum_arch.c.

Referenced by _irq_handler(), radio_control_spektrum_try_bind(), and SpektrumUartInit().

#define SecondaryUart (   _x)    _SecondaryUart(RADIO_CONTROL_SPEKTRUM_SECONDARY_PORT, _x)

Definition at line 71 of file spektrum_arch.c.

Referenced by radio_control_spektrum_try_bind(), and SpektrumUartInit().

#define SLAVE_RECEIVER_PULSES   6

Definition at line 46 of file spektrum_arch.c.

Referenced by radio_control_spektrum_try_bind().

#define SPEKTRUM_CHANNELS_PER_FRAME   7

Definition at line 37 of file spektrum_arch.c.

Referenced by RadioControlEventImp().

#define SpektrumParser (   _c,
  _SpektrumState,
  _receiver 
)

Definition at line 253 of file spektrum_arch.c.

Referenced by _irq_handler().

#define TIM_FREQ_1000000   1000000

Definition at line 53 of file spektrum_arch.c.

Referenced by SpektrumTimerInit().

#define TIM_TICS_FOR_100us   100

Definition at line 54 of file spektrum_arch.c.

Referenced by SpektrumTimerInit().

Typedef Documentation

Definition at line 86 of file spektrum_arch.c.

Function Documentation

void PrimaryUart() _irq_handler ( void  )

Definition at line 603 of file spektrum_arch.c.

References PrimaryUart, RESET, and SpektrumParser.

void DebugInit ( void  )

Definition at line 640 of file spektrum_arch.c.

static void DelayMs ( uint16_t  mSecs)
static

Definition at line 759 of file spektrum_arch.c.

References DELAY_TIM_FREQUENCY, and DelayUs().

Referenced by radio_control_spektrum_try_bind().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void DelayUs ( uint16_t  uSecs)
static

Definition at line 752 of file spektrum_arch.c.

Referenced by DelayMs(), and radio_control_spektrum_try_bind().

+ Here is the caller graph for this function:

void radio_control_impl_init ( void  )

Definition at line 140 of file spektrum_arch.c.

References SpektrumTimerInit(), and SpektrumUartInit().

+ Here is the call graph for this function:

void radio_control_spektrum_try_bind ( void  )

Definition at line 665 of file spektrum_arch.c.

References BIND_PIN, BIND_PIN_PERIPH, BIND_PIN_PORT, DelayMs(), DelayUs(), MASTER_RECEIVER_PULSES, PrimaryUart, SecondaryUart, SLAVE_RECEIVER_PULSES, and SpektrumDelayInit().

+ Here is the call graph for this function:

static void SpektrumDelayInit ( void  )
static

Definition at line 735 of file spektrum_arch.c.

References AHB_CLK, and DELAY_TIM_FREQUENCY.

Referenced by radio_control_spektrum_try_bind().

+ Here is the caller graph for this function:

void SpektrumTimerInit ( void  )

Definition at line 468 of file spektrum_arch.c.

References AHB_CLK, TIM_FREQ_1000000, and TIM_TICS_FOR_100us.

Referenced by radio_control_impl_init().

+ Here is the caller graph for this function:

void SpektrumUartInit ( void  )

Definition at line 523 of file spektrum_arch.c.

References B115200, pprz_usart_set_baudrate, PrimaryUart, and SecondaryUart.

Referenced by radio_control_impl_init().

+ Here is the caller graph for this function:

void tim6_irq_handler ( void  )

Definition at line 506 of file spektrum_arch.c.

References SpektrumStateStruct::SpektrumTimer.

Variable Documentation

uint8_t EncodingType = 0
static

Definition at line 118 of file spektrum_arch.c.

Referenced by RadioControlEventImp().

uint8_t ExpectedFrames = 0
static

Definition at line 119 of file spektrum_arch.c.

Referenced by RadioControlEventImp().

SpektrumStateType PrimarySpektrumState = {1,0,0,0,0,0,0,0,0}

Definition at line 88 of file spektrum_arch.c.

Definition at line 96 of file spektrum_arch.c.

Referenced by RadioControlEventImp().

Definition at line 115 of file spektrum_arch.c.

Referenced by RadioControlEventImp().