Commit c56d0c38 authored by Projects's avatar Projects

vibra: Driver, basic functions.

parent cb02bd4e
/*
* Copyright (C) 2014 Julian Lewis
* @author Maciej Suminski <maciej.suminski@cern.ch>
* @author Matthieu Cattin <matthieu.cattin@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @brief Vibration motor control.
*/
#include "vibra.h"
#include <em_cmu.h>
#include <em_gpio.h>
#define VIBRA_PORT gpioPortA
#define VIBRA_PIN 3
void vibra_init(void)
{
GPIO_PinModeSet(VIBRA_PORT, VIBRA_PIN, gpioModePushPull, 0);
}
void vibra_enable(void)
{
GPIO_PinOutSet(VIBRA_PORT, VIBRA_PIN);
}
void vibra_disable(void)
{
GPIO_PinOutClear(VIBRA_PORT, VIBRA_PIN);
}
/*
* Copyright (C) 2014 Julian Lewis
* @author Maciej Suminski <maciej.suminski@cern.ch>
* @author Matthieu Cattin <matthieu.cattin@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @brief Vibration motor control.
*/
#ifndef VIBRA_H
#define VIBRA_H
/**
* @brief Initialize vibration motor.
*/
void vibra_init(void);
/**
* @brief Turns on the vibration motor.
*/
void vibra_enable(void);
/**
* @brief Turns off the vibration motor.
*/
void vibra_disable(void);
#endif /* VIBRA_H */
......@@ -142,6 +142,7 @@ C_SRC += \
../common/drivers/buttons.c \
../common/drivers/buzzer.c \
../common/drivers/rtc.c \
../common/drivers/vibra.c \
../common/gfx/font_helv11.c \
../common/gfx/font_helv17.c \
../common/gfx/font_helv17b.c \
......
......@@ -27,6 +27,7 @@
#include "application.h"
#include "widgets/status_bar.h"
#include "drivers/buzzer.h"
#include "drivers/vibra.h"
#include <string.h> // for strcpy
......@@ -61,6 +62,11 @@ static void widget_event(struct ui_widget *w, const struct event *evt)
case BUT_TL: // this should not happen, it is handled
break; // in the main loop
}
// short vibration
vibra_enable();
vTaskDelay(100);
vibra_disable();
break;
case RTC_TICK:
......
......@@ -34,6 +34,7 @@
#include <drivers/buzzer.h>
#include <drivers/lcd.h>
#include <drivers/rtc.h>
#include <drivers/vibra.h>
#include <gfx/ui.h>
int main(void)
......@@ -47,6 +48,7 @@ int main(void)
buttons_init();
buzzer_init();
vibra_init();
rtc_init();
lcd_init();
ui_init();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment