Skip to content

Commit

Permalink
[ArDrone] Add protection to lowlevel driver that can short-circuit th…
Browse files Browse the repository at this point in the history
…e board.
  • Loading branch information
dewagter committed Aug 31, 2013
1 parent 1fac821 commit 0a8d097
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sw/airborne/boards/ardrone/actuators_ardrone2_raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
*/
int mot_fd; /**< File descriptor for the port */

#define ARDRONE_GPIO_PORT 0 // Dummy for paparazzi compatibility
#define ARDRONE_GPIO_PORT 0x32524

#define ARDRONE_GPIO_PIN_MOTOR1 171
#define ARDRONE_GPIO_PIN_MOTOR2 172
Expand Down
7 changes: 6 additions & 1 deletion sw/airborne/boards/ardrone/gpio_ardrone.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct gpio_direction {

void gpio_set(uint32_t port, uint16_t pin)
{
if (port != 0x32524) return; // protect ardrone board from unauthorized use
struct gpio_data data;
// Open the device if not open
if (gpiofp == 0)
Expand All @@ -67,6 +68,7 @@ void gpio_set(uint32_t port, uint16_t pin)

void gpio_clear(uint32_t port, uint16_t pin)
{
if (port != 0x32524) return; // protect ardrone board from unauthorized use
struct gpio_data data;
// Open the device if not open
if (gpiofp == 0)
Expand All @@ -81,6 +83,7 @@ void gpio_clear(uint32_t port, uint16_t pin)

void gpio_setup_input(uint32_t port, uint16_t pin)
{
if (port != 0x32524) return; // protect ardrone board from unauthorized use
struct gpio_direction dir;
// Open the device if not open
if (gpiofp == 0)
Expand All @@ -95,6 +98,7 @@ void gpio_setup_input(uint32_t port, uint16_t pin)

void gpio_setup_output(uint32_t port, uint16_t pin)
{
if (port != 0x32524) return; // protect ardrone board from unauthorized use
struct gpio_direction dir;
// Open the device if not open
if (gpiofp == 0)
Expand All @@ -108,8 +112,9 @@ void gpio_setup_output(uint32_t port, uint16_t pin)



uint16_t gpio_get(uint32_t gpioport, uint16_t pin)
uint16_t gpio_get(uint32_t port, uint16_t pin)
{
if (port != 0x32524) return 0; // protect ardrone board from unauthorized use
struct gpio_data data;
// Open the device if not open
if (gpiofp == 0)
Expand Down

0 comments on commit 0a8d097

Please sign in to comment.