Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
actuators.c File Reference

Actuator driver for ardrone2 version. More...

#include "modules/actuators/actuators.h"
#include "actuators.h"
#include "mcu_periph/gpio.h"
#include "led_hw.h"
#include "mcu_periph/sys_time.h"
#include "navdata.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <stdint.h>
#include "autopilot.h"
+ Include dependency graph for actuators.c:

Go to the source code of this file.

Macros

#define ARDRONE_GPIO_PORT   0x32524
 
#define ARDRONE_GPIO_PIN_MOTOR1   171
 
#define ARDRONE_GPIO_PIN_MOTOR2   172
 
#define ARDRONE_GPIO_PIN_MOTOR3   173
 
#define ARDRONE_GPIO_PIN_MOTOR4   174
 
#define ARDRONE_GPIO_PIN_IRQ_FLIPFLOP   175
 
#define ARDRONE_GPIO_PIN_IRQ_INPUT   176
 
#define BIT_NUMBER(VAL, BIT)   (((VAL)>>BIT)&0x03)
 

Functions

static void actuators_ardrone_reset_flipflop (void)
 
void actuators_ardrone_init (void)
 
int actuators_ardrone_cmd (uint8_t cmd, uint8_t *reply, int replylen)
 
void actuators_ardrone_motor_status (void)
 
void actuators_ardrone_led_run (void)
 
void actuators_ardrone_commit (void)
 
void actuators_ardrone_set_pwm (uint16_t pwm0, uint16_t pwm1, uint16_t pwm2, uint16_t pwm3)
 Write motor speed command cmd = 001aaaaa aaaabbbb bbbbbccc ccccccdd ddddddd0. More...
 
void actuators_ardrone_set_leds (uint8_t led0, uint8_t led1, uint8_t led2, uint8_t led3)
 Write LED command cmd = 011rrrr0 000gggg0 (this is ardrone1 format, we need ardrone2 format) More...
 
void actuators_ardrone_close (void)
 

Variables

int actuator_ardrone2_fd
 Power consumption @ 11V all 4 motors running PWM A 0 0.2 80 1.3 100 1.5 150 2.0 190 2.5 130 3.0. More...
 
uint32_t led_hw_values
 
uint16_t actuators_pwm_values [ACTUATORS_ARDRONE_NB]
 

Detailed Description

Actuator driver for ardrone2 version.

Definition in file actuators.c.

Macro Definition Documentation

◆ ARDRONE_GPIO_PIN_IRQ_FLIPFLOP

#define ARDRONE_GPIO_PIN_IRQ_FLIPFLOP   175

Definition at line 65 of file actuators.c.

◆ ARDRONE_GPIO_PIN_IRQ_INPUT

#define ARDRONE_GPIO_PIN_IRQ_INPUT   176

Definition at line 66 of file actuators.c.

◆ ARDRONE_GPIO_PIN_MOTOR1

#define ARDRONE_GPIO_PIN_MOTOR1   171

Definition at line 60 of file actuators.c.

◆ ARDRONE_GPIO_PIN_MOTOR2

#define ARDRONE_GPIO_PIN_MOTOR2   172

Definition at line 61 of file actuators.c.

◆ ARDRONE_GPIO_PIN_MOTOR3

#define ARDRONE_GPIO_PIN_MOTOR3   173

Definition at line 62 of file actuators.c.

◆ ARDRONE_GPIO_PIN_MOTOR4

#define ARDRONE_GPIO_PIN_MOTOR4   174

Definition at line 63 of file actuators.c.

◆ ARDRONE_GPIO_PORT

#define ARDRONE_GPIO_PORT   0x32524

Definition at line 58 of file actuators.c.

◆ BIT_NUMBER

#define BIT_NUMBER (   VAL,
  BIT 
)    (((VAL)>>BIT)&0x03)

Definition at line 208 of file actuators.c.

Function Documentation

◆ actuators_ardrone_close()

void actuators_ardrone_close ( void  )

Definition at line 272 of file actuators.c.

References actuator_ardrone2_fd.

◆ actuators_ardrone_cmd()

int actuators_ardrone_cmd ( uint8_t  cmd,
uint8_t reply,
int  replylen 
)

Definition at line 159 of file actuators.c.

References actuator_ardrone2_fd, full_read(), and full_write().

Referenced by actuators_ardrone_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ actuators_ardrone_commit()

void actuators_ardrone_commit ( void  )

Definition at line 221 of file actuators.c.

References actuators_ardrone_motor_status(), actuators_ardrone_set_pwm(), and actuators_pwm_values.

+ Here is the call graph for this function:

◆ actuators_ardrone_init()

◆ actuators_ardrone_led_run()

void actuators_ardrone_led_run ( void  )

Definition at line 211 of file actuators.c.

References actuators_ardrone_set_leds(), BIT_NUMBER, and led_hw_values.

Referenced by actuators_ardrone_set_pwm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ actuators_ardrone_motor_status()

void actuators_ardrone_motor_status ( void  )

Definition at line 171 of file actuators.c.

References ARDRONE_GPIO_PIN_IRQ_FLIPFLOP, ARDRONE_GPIO_PIN_IRQ_INPUT, ARDRONE_GPIO_PORT, autopilot_get_motors_on(), autopilot_set_motors_on(), gpio_clear(), gpio_get(), gpio_set(), and gpio_setup_output().

Referenced by actuators_ardrone_commit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ actuators_ardrone_reset_flipflop()

static void actuators_ardrone_reset_flipflop ( void  )
inlinestatic

Definition at line 71 of file actuators.c.

References ARDRONE_GPIO_PIN_IRQ_FLIPFLOP, ARDRONE_GPIO_PORT, gpio_clear(), gpio_set(), gpio_setup_output(), and sys_time::nb_sec.

Referenced by actuators_ardrone_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ actuators_ardrone_set_leds()

void actuators_ardrone_set_leds ( uint8_t  led0,
uint8_t  led1,
uint8_t  led2,
uint8_t  led3 
)

Write LED command cmd = 011rrrr0 000gggg0 (this is ardrone1 format, we need ardrone2 format)

led0 = RearLeft led1 = RearRight led2 = FrontRight led3 = FrontLeft

Definition at line 255 of file actuators.c.

References actuator_ardrone2_fd, and full_write().

Referenced by actuators_ardrone_init(), and actuators_ardrone_led_run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ actuators_ardrone_set_pwm()

void actuators_ardrone_set_pwm ( uint16_t  pwm0,
uint16_t  pwm1,
uint16_t  pwm2,
uint16_t  pwm3 
)

Write motor speed command cmd = 001aaaaa aaaabbbb bbbbbccc ccccccdd ddddddd0.

Definition at line 232 of file actuators.c.

References actuator_ardrone2_fd, actuators_ardrone_led_run(), and full_write().

Referenced by actuators_ardrone_commit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ actuator_ardrone2_fd

int actuator_ardrone2_fd

Power consumption @ 11V all 4 motors running PWM A 0 0.2 80 1.3 100 1.5 150 2.0 190 2.5 130 3.0.

File descriptor for the port

Definition at line 56 of file actuators.c.

Referenced by actuators_ardrone_close(), actuators_ardrone_cmd(), actuators_ardrone_init(), actuators_ardrone_set_leds(), and actuators_ardrone_set_pwm().

◆ actuators_pwm_values

uint16_t actuators_pwm_values[ACTUATORS_ARDRONE_NB]

Definition at line 69 of file actuators.c.

Referenced by actuators_ardrone_commit().

◆ led_hw_values

uint32_t led_hw_values