Remove button example.

With further testing this doesn't currently work on a stock Dash.  More investigation needs to be done to understand how the button is connected to the Dash CPU.
This commit is contained in:
Tony DiCola 2015-08-10 18:49:29 +00:00
parent fa3cdcdf4c
commit 845e853aed
3 changed files with 0 additions and 58 deletions

View file

@ -10,7 +10,6 @@ and a little more investigation of how the CPU is connected to the WiFi module.
The following examples are available:
* Blink - Blink each red, green, blue LED individually for a second.
* Button - Show how to read the Dash's button and turn on the blue LED when pressed.
* PWM - Use PWM to set the red, green, blue LEDs to any RGB color.
* UART - Use the UART exposed on PC6 & PC7 to send out data from the Dash.

View file

@ -1,12 +0,0 @@
# Dash Blink Example Makefile
# Copyright (c) 2015 Tony DiCola
# Released under a MIT license: http://opensource.org/licenses/MIT
BINARY = button
# Note if you have multiple source files, list them all in an OBJS variable.
# The Makefile rules will pick them up and compile their source appropriately.
# For example if you have a foo.c and bar.c to include set the OBJS variable:
# OBJS = foo.o bar.o
include ../Makefile.include

View file

@ -1,45 +0,0 @@
// Dash Button Example
//
// Demonstrates how to read the button on the dash by turning on the blue LED
// when the button is pressed. One side of the button is connected to PA0 and
// the other side is connected through a pull down to ground. By enabling PA0
// as an input with a pullup resistor you can detect when the button is pressed.
//
// Copyright (c) 2015 Tony DiCola
// Released under a MIT license: http://opensource.org/licenses/MIT
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/stm32/rcc.h>
// Setup and configure the GPIOs to read the button and control the blue LED.
static void gpio_setup(void) {
// Enable the GPIO clock for port A.
rcc_periph_clock_enable(RCC_GPIOA);
// Set the blue LED GPIO (PA8) as an output.
gpio_mode_setup(GPIOA, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO8);
// Set the button GPIO (PA0) as an input with an internal pull-up resistor.
gpio_mode_setup(GPIOA, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, GPIO0);
}
int main(void) {
// Setup GPIOs.
gpio_setup();
// Main loop.
while (true) {
// Check if the button is pressed by reading PA0 to see if it's at a high level.
if (gpio_get(GPIOA, GPIO0) > 0) {
// Button is pressed, light up the blue LED (pull its GPIO low to light).
gpio_clear(GPIOA, GPIO8);
}
else {
// Button is not pressed, turn off the blue LED by pulling its GPIO high.
gpio_set(GPIOA, GPIO8);
}
}
return 0;
}