You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.2 KiB
89 lines
2.2 KiB
7 years ago
|
/*
|
||
|
* BAGpio.cpp
|
||
|
*
|
||
7 years ago
|
* Created on: November 1, 2017
|
||
7 years ago
|
* Author: slascos
|
||
7 years ago
|
*
|
||
|
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||
|
*/
|
||
7 years ago
|
|
||
|
#include "Arduino.h"
|
||
|
#include "BAGpio.h"
|
||
|
|
||
|
namespace BAGuitar {
|
||
|
|
||
|
BAGpio::BAGpio()
|
||
|
{
|
||
|
// Set all GPIOs to input
|
||
|
pinMode(static_cast<uint8_t>(GPIO::GPIO0), INPUT);
|
||
|
pinMode(static_cast<uint8_t>(GPIO::GPIO1), INPUT);
|
||
|
pinMode(static_cast<uint8_t>(GPIO::GPIO2), INPUT);
|
||
|
pinMode(static_cast<uint8_t>(GPIO::GPIO3), INPUT);
|
||
|
pinMode(static_cast<uint8_t>(GPIO::GPIO4), INPUT);
|
||
|
pinMode(static_cast<uint8_t>(GPIO::GPIO5), INPUT);
|
||
|
pinMode(static_cast<uint8_t>(GPIO::GPIO6), INPUT);
|
||
|
pinMode(static_cast<uint8_t>(GPIO::GPIO7), INPUT);
|
||
|
pinMode(static_cast<uint8_t>(GPIO::TP1), INPUT);
|
||
|
pinMode(static_cast<uint8_t>(GPIO::TP2), INPUT);
|
||
|
|
||
7 years ago
|
// Set the LED ot ouput
|
||
7 years ago
|
pinMode(USR_LED_ID, OUTPUT);
|
||
7 years ago
|
clearLed(); // turn off the LED
|
||
7 years ago
|
|
||
|
}
|
||
|
|
||
|
BAGpio::~BAGpio()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void BAGpio::setGPIODirection(GPIO gpioId, int direction)
|
||
|
{
|
||
|
pinMode(static_cast<uint8_t>(gpioId), direction);
|
||
|
}
|
||
|
void BAGpio::setGPIO(GPIO gpioId)
|
||
|
{
|
||
|
digitalWrite(static_cast<uint8_t>(gpioId), 0x1);
|
||
|
}
|
||
|
void BAGpio::clearGPIO(GPIO gpioId)
|
||
|
{
|
||
|
digitalWrite(static_cast<uint8_t>(gpioId), 0);
|
||
|
|
||
|
}
|
||
7 years ago
|
int BAGpio::toggleGPIO(GPIO gpioId)
|
||
7 years ago
|
{
|
||
|
int data = digitalRead(static_cast<uint8_t>(gpioId));
|
||
|
digitalWrite(static_cast<uint8_t>(gpioId), ~data);
|
||
7 years ago
|
return ~data;
|
||
7 years ago
|
}
|
||
|
|
||
|
void BAGpio::setLed()
|
||
|
{
|
||
|
digitalWrite(USR_LED_ID, 0x1);
|
||
|
m_ledState = 1;
|
||
|
}
|
||
|
void BAGpio::clearLed()
|
||
|
{
|
||
|
digitalWrite(USR_LED_ID, 0);
|
||
|
m_ledState = 0;
|
||
|
}
|
||
7 years ago
|
int BAGpio::toggleLed()
|
||
7 years ago
|
{
|
||
|
m_ledState = ~m_ledState;
|
||
|
digitalWrite(USR_LED_ID, m_ledState);
|
||
7 years ago
|
return m_ledState;
|
||
7 years ago
|
}
|
||
|
|
||
|
|
||
|
} /* namespace BAGuitar */
|