04bbba6c12
Rename guhRF platform to osd-merkur-256, previous osd-merkur platform is now osd-merkur-128. Also check that everything is consistent. Add both platforms to the regression tests. Move redundant files in platform dev directory of both platforms to cpu/avr/dev. Note that this probably needs some rework. Already discovered some inconsistency in io definitions of both devices in the avr/io.h includes. Added a workaround in the obvious cases. The platform makefiles now set correct parameters for bootloader and for reading mac-address from flash memory. Factor the flash programming into cpu/avr and platform/osd-merkur* and rework *all* osd example makefiles to use the new settings. Also update all the flash.sh and run.sh to use the new settings. The suli ledstrip modules (and osd example) have also been removed.
105 lines
2.6 KiB
C
105 lines
2.6 KiB
C
/*
|
|
wiring_digital.c - digital input and output functions
|
|
Part of Arduino - http://www.arduino.cc/
|
|
|
|
Copyright (c) 2005-2006 David A. Mellis
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
This library 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
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General
|
|
Public License along with this library; if not, write to the
|
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
Boston, MA 02111-1307 USA
|
|
|
|
Modified 28 September 2010 by Mark Sproul
|
|
|
|
$Id: wiring.c 248 2007-02-03 15:36:30Z mellis $
|
|
*/
|
|
|
|
#define ARDUINO_MAIN
|
|
#include "wiring_private.h"
|
|
#include "pins_arduino.h"
|
|
|
|
void pinMode(uint8_t pin, uint8_t mode)
|
|
{
|
|
uint8_t bit = digitalPinToBitMask(pin);
|
|
uint8_t port = digitalPinToPort(pin);
|
|
volatile uint8_t *reg, *out;
|
|
|
|
if (port == NOT_A_PIN) return;
|
|
|
|
// JWS: can I let the optimizer do this?
|
|
reg = portModeRegister(port);
|
|
out = portOutputRegister(port);
|
|
|
|
if (mode == INPUT) {
|
|
uint8_t oldSREG = SREG;
|
|
cli();
|
|
*reg &= ~bit;
|
|
*out &= ~bit;
|
|
SREG = oldSREG;
|
|
} else if (mode == INPUT_PULLUP) {
|
|
uint8_t oldSREG = SREG;
|
|
cli();
|
|
*reg &= ~bit;
|
|
*out |= bit;
|
|
SREG = oldSREG;
|
|
} else {
|
|
uint8_t oldSREG = SREG;
|
|
cli();
|
|
*reg |= bit;
|
|
SREG = oldSREG;
|
|
}
|
|
}
|
|
|
|
void digitalWrite(uint8_t pin, uint8_t val)
|
|
{
|
|
uint8_t timer = digitalPinToTimer(pin);
|
|
uint8_t bit = digitalPinToBitMask(pin);
|
|
uint8_t port = digitalPinToPort(pin);
|
|
volatile uint8_t *out;
|
|
|
|
if (port == NOT_A_PIN) return;
|
|
|
|
// If the pin that support PWM output, we need to turn it off
|
|
// before doing a digital write.
|
|
if (timer != NOT_ON_TIMER) turnOffPWM(timer);
|
|
|
|
out = portOutputRegister(port);
|
|
|
|
uint8_t oldSREG = SREG;
|
|
cli();
|
|
|
|
if (val == LOW) {
|
|
*out &= ~bit;
|
|
} else {
|
|
*out |= bit;
|
|
}
|
|
|
|
SREG = oldSREG;
|
|
}
|
|
|
|
int digitalRead(uint8_t pin)
|
|
{
|
|
uint8_t timer = digitalPinToTimer(pin);
|
|
uint8_t bit = digitalPinToBitMask(pin);
|
|
uint8_t port = digitalPinToPort(pin);
|
|
|
|
if (port == NOT_A_PIN) return LOW;
|
|
|
|
// If the pin that support PWM output, we need to turn it off
|
|
// before getting a digital reading.
|
|
if (timer != NOT_ON_TIMER) turnOffPWM(timer);
|
|
|
|
if (*portInputRegister(port) & bit) return HIGH;
|
|
return LOW;
|
|
}
|