本文整理汇总了C++中digitalPinToPort函数的典型用法代码示例。如果您正苦于以下问题:C++ digitalPinToPort函数的具体用法?C++ digitalPinToPort怎么用?C++ digitalPinToPort使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了digitalPinToPort函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: digitalWrite
TFTLCD::TFTLCD(uint8_t cs, uint8_t cd, uint8_t wr, uint8_t rd, uint8_t reset) {
_cs = cs;
_cd = cd;
_wr = wr;
_rd = rd;
_reset = reset;
rotation = 0;
_width = TFTWIDTH;
_height = TFTHEIGHT;
// disable the LCD
digitalWrite(_cs, HIGH);
pinMode(_cs, OUTPUT);
digitalWrite(_cd, HIGH);
pinMode(_cd, OUTPUT);
digitalWrite(_wr, HIGH);
pinMode(_wr, OUTPUT);
digitalWrite(_rd, HIGH);
pinMode(_rd, OUTPUT);
digitalWrite(_reset, HIGH);
pinMode(_reset, OUTPUT);
csport = digitalPinToPort(_cs);
cdport = digitalPinToPort(_cd);
wrport = digitalPinToPort(_wr);
rdport = digitalPinToPort(_rd);
cspin = digitalPinToBitMask(_cs);
cdpin = digitalPinToBitMask(_cd);
wrpin = digitalPinToBitMask(_wr);
rdpin = digitalPinToBitMask(_rd);
cursor_y = cursor_x = 0;
textsize = 1;
textcolor = 0xFFFF;
}
开发者ID:frankiechan107,项目名称:MACRB,代码行数:41,代码来源:TFTLCD.cpp
示例2: Adafruit_GFX
// Constructor for breakout board (configurable LCD control lines).
// Can still use this w/shield, but parameters are ignored.
Adafruit_TFTLCD::Adafruit_TFTLCD(
uint8_t cs, uint8_t cd, uint8_t wr, uint8_t rd, uint8_t reset) :
Adafruit_GFX(TFTWIDTH, TFTHEIGHT) {
#ifndef USE_ADAFRUIT_SHIELD_PINOUT
// Convert pin numbers to registers and bitmasks
_reset = reset;
#ifdef __AVR__
csPort = portOutputRegister(digitalPinToPort(cs));
cdPort = portOutputRegister(digitalPinToPort(cd));
wrPort = portOutputRegister(digitalPinToPort(wr));
rdPort = portOutputRegister(digitalPinToPort(rd));
#endif
#if defined(__SAM3X8E__)
csPort = digitalPinToPort(cs);
cdPort = digitalPinToPort(cd);
wrPort = digitalPinToPort(wr);
rdPort = digitalPinToPort(rd);
#endif
csPinSet = digitalPinToBitMask(cs);
cdPinSet = digitalPinToBitMask(cd);
wrPinSet = digitalPinToBitMask(wr);
rdPinSet = digitalPinToBitMask(rd);
csPinUnset = ~csPinSet;
cdPinUnset = ~cdPinSet;
wrPinUnset = ~wrPinSet;
rdPinUnset = ~rdPinSet;
#ifdef __AVR__
*csPort |= csPinSet; // Set all control bits to HIGH (idle)
*cdPort |= cdPinSet; // Signals are ACTIVE LOW
*wrPort |= wrPinSet;
*rdPort |= rdPinSet;
#endif
#if defined(__SAM3X8E__)
csPort->PIO_SODR |= csPinSet; // Set all control bits to HIGH (idle)
cdPort->PIO_SODR |= cdPinSet; // Signals are ACTIVE LOW
wrPort->PIO_SODR |= wrPinSet;
rdPort->PIO_SODR |= rdPinSet;
#endif
pinMode(cs, OUTPUT); // Enable outputs
pinMode(cd, OUTPUT);
pinMode(wr, OUTPUT);
pinMode(rd, OUTPUT);
if(reset) {
digitalWrite(reset, HIGH);
pinMode(reset, OUTPUT);
}
#endif
init();
}
开发者ID:arduino245,项目名称:lcd,代码行数:53,代码来源:Adafruit_TFTLCD.cpp
示例3: digitalPinToBitMask
void Shift74HC595::fastWrite(uint8_t pin, uint8_t val) {
uint8_t bit = digitalPinToBitMask(pin);
volatile uint8_t *out = portOutputRegister(digitalPinToPort(pin));
if (val == LOW) {
*out &= ~bit;
}
else {
*out |= bit;
}
};
开发者ID:phillipthomasjamessteiner,项目名称:Shift_74HC595_Register_Lib,代码行数:12,代码来源:shift_74HC595.cpp
示例4: digitalWrite
void digitalWrite(uint8_t pin, uint8_t val) {
uint8_t bit = digitalPinToBitMask(pin);
uint8_t port = digitalPinToPort(pin);
volatile uint8_t *out;
if (port == NOT_A_PIN) return;
out = portOutputRegister(port);
if (val == LOW) *out &= ~bit;
else *out |= bit;
}
开发者ID:derkling,项目名称:DerkGPS,代码行数:12,代码来源:digitals.c
示例5: defined
ITDB02::ITDB02(int RS, int WR,int CS, int RST, byte display)
{
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
DDRA = 0xFF;
#else
DDRD = 0xFF;
#endif
P_RS = portOutputRegister(digitalPinToPort(RS));
B_RS = digitalPinToBitMask(RS);
P_WR = portOutputRegister(digitalPinToPort(WR));
B_WR = digitalPinToBitMask(WR);
P_CS = portOutputRegister(digitalPinToPort(CS));
B_CS = digitalPinToBitMask(CS);
P_RST = portOutputRegister(digitalPinToPort(RST));
B_RST = digitalPinToBitMask(RST);
pinMode(RS,OUTPUT);
pinMode(WR,OUTPUT);
pinMode(CS,OUTPUT);
pinMode(RST,OUTPUT);
displaymodel = display;
}
开发者ID:AbdulButt,项目名称:Arduino-Reef,代码行数:21,代码来源:ITDB02_Graph.cpp
示例6: tone
//************************************************************************
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
{
uint32_t tonePeriod;
uint8_t port;
// Should have an error check here for pin number out of range.
//* there is no standard on the number of pins. Since we want this to work on all versions of the PIC32
//* I have set it to 112 for now which is the largest I/O pin count on a pic32
if ((frequency > 0) && (_pin < 112))
{
// If a tone is currently playing on a different pin, the function is
// documented to have no effect. If playing on the same pin, change
// the frequency. If not currently playing, initialize the timer.
// This is currently hard coded to use timer1.
if (tone_pin == 255)
{
// No tone currently playing. Init the timer.
T1CON = T1_PS_1_256;
mT1ClearIntFlag();
ConfigIntTimer1(T1_INT_ON | T1_INT_PRIOR_3 | T1_INT_SUB_PRIOR_1);
}
else if (_pin != tone_pin)
{
// Tone currently playing on another pin. ignore this call.
return;
}
// Determine which port and bit are requested.
tone_pin = _pin;
port = digitalPinToPort(_pin);
tone_pin_port = portOutputRegister(port);
tone_pin_mask = digitalPinToBitMask(_pin);
// Ensure that the pin is a digital output
pinMode(_pin, OUTPUT);
// Duration 0 means to play forever until stopped. Other values
// mean to play for that many milliseconds.
if (duration > 0)
{
timer1_toggle_count = (2 * frequency * duration) / 1000;
}
else
{
timer1_toggle_count = -1;
}
TMR1 = 0;
PR1 = ((F_CPU / 256) / 2 / frequency);
T1CONSET = T1_ON;
}
}
开发者ID:edanielreyes,项目名称:chipKIT32-MAX,代码行数:54,代码来源:Tone.cpp
示例7: pinMode
// Change pin assignments post-constructor, using arbitrary pins:
void Adafruit_WS2801::updatePins(uint8_t dpin, uint8_t cpin) {
if(begun == true) { // If begin() was previously invoked...
// If previously using hardware SPI, turn that off:
if(hardwareSPI == true) SPI.end();
// Regardless, now enable output on 'soft' SPI pins:
pinMode(dpin, OUTPUT);
pinMode(cpin, OUTPUT);
} // Otherwise, pins are not set to outputs until begin() is called.
// Note: any prior clock/data pin directions are left as-is and are
// NOT restored as inputs!
hardwareSPI = false;
datapin = dpin;
clkpin = cpin;
clkport = portOutputRegister(digitalPinToPort(cpin));
clkpinmask = digitalPinToBitMask(cpin);
dataport = portOutputRegister(digitalPinToPort(dpin));
datapinmask = digitalPinToBitMask(dpin);
}
开发者ID:zoa,项目名称:Zoa_WS2801,代码行数:22,代码来源:Zoa_WS2801.cpp
示例8: _pin
/*
* Constructor for the sensor. It remembers the pin number and the
* type of sensor, and initializes internal variables.
*/
DHT_nonblocking::DHT_nonblocking( uint8_t pin, uint8_t type )
: _pin( pin ),
_type( type ),
_bit( digitalPinToBitMask( pin ) ),
_port( digitalPinToPort( pin ) ),
_maxcycles( microsecondsToClockCycles( 1000 ) )
{
dht_state = DHT_IDLE;
pinMode( _pin, INPUT );
digitalWrite( _pin, HIGH );
}
开发者ID:olewolf,项目名称:DHT_nonblocking,代码行数:16,代码来源:dht_nonblocking.cpp
示例9: pinMode
// ------------------------------------------------------------------------------
// Initialize, set the baudrate and enable RX
// ------------------------------------------------------------------------------
void gSoftSerial::begin(uint16_t baudRate)
{
pinMode(rxPin, INPUT_PULLUP);
pinMode(txPin, OUTPUT);
*txPort |= txBitMask; // high = idle
delay(1); // need some idle time
rxBitMask = digitalPinToBitMask(rxPin);
rxPort = portInputRegister(digitalPinToPort(rxPin));
txBitMask = digitalPinToBitMask(txPin);
txPort = portOutputRegister(digitalPinToPort(txPin));
#if F_CPU == 8000000L
// Have to use timer 2 for an 8 MHz system.
TCCR2A = 0x00;
TCCR2B = 0x03; // divide by 32
#endif
setBaudRate(baudRate);
listen();
}
开发者ID:night-ghost,项目名称:gsm-modem,代码行数:24,代码来源:gSoftSerial.cpp
示例10: digitalWrite
void SendOnlySoftwareSerial::setTX(uint8_t tx)
{
// First write, then set output. If we do this the other way around,
// the pin would be output low for a short while before switching to
// output hihg. Now, it is input with pullup for a short while, which
// is fine. With inverse logic, either order is fine.
digitalWrite(tx, _inverse_logic ? LOW : HIGH);
pinMode(tx, OUTPUT);
_transmitBitMask = digitalPinToBitMask(tx);
uint8_t port = digitalPinToPort(tx);
_transmitPortRegister = portOutputRegister(port);
}
开发者ID:stahlfabrik,项目名称:TinyTX-TinyRX-Project,代码行数:12,代码来源:SendOnlySoftwareSerial.cpp
示例11: ADS7843
ADS7843 :: ADS7843(uint32_t cs, uint32_t dclk, uint32_t din, uint32_t dout, uint32_t irq)
{
_cs = cs;
_dclk = dclk;
_din = din;
_dout = dout;
_irq = irq;
_cs_port = digitalPinToPort(_cs);
_dclk_port = digitalPinToPort(_dclk);
_din_port = digitalPinToPort(_din);
_dout_port = digitalPinToPort(_dout);
_irq_port = digitalPinToPort(_irq);
_cs_pin = digitalPinToBitMask(_cs);
_dclk_pin = digitalPinToBitMask(_dclk);
_din_pin = digitalPinToBitMask(_din);
_dout_pin = digitalPinToBitMask(_dout);
_irq_pin = digitalPinToBitMask(_irq);
}
开发者ID:petmo338,项目名称:ignitioncontrol,代码行数:21,代码来源:ads7843.cpp
示例12: defined
ArduCAM::ArduCAM(byte model,int CS)
{
#if defined(ESP8266)
B_CS = CS;
#else
P_CS = portOutputRegister(digitalPinToPort(CS));
B_CS = digitalPinToBitMask(CS);
#endif
pinMode(CS,OUTPUT);
//Must initialize the Bus default status
sbi(P_CS, B_CS);
//flush_fifo();
sensor_model=model;
switch(sensor_model)
{
case OV7660:
case OV7670:
case OV7675:
case OV7725:
sensor_addr = 0x42;
break;
case MT9D111_A: //Standard MT9D111 module
sensor_addr = 0xba;
break;
case MT9D111_B: //Flex MT9D111 AF module
sensor_addr = 0x90;
break;
case MT9M112:
sensor_addr = 0x90;
break;
case MT9M001:
sensor_addr = 0xba;
break;
case OV3640:
case OV5640:
case OV5642:
case MT9T112:
case MT9D112:
sensor_addr = 0x78;
break;
case OV2640:
case OV9650:
case OV9655:
sensor_addr = 0x60;
break;
case MT9V111:
sensor_addr = 0xB8;
break;
default:
sensor_addr = 0x42;
break;
}
}
开发者ID:ballasl,项目名称:ArduCAM_ESP8266_UNO,代码行数:53,代码来源:ArduCAM.cpp
示例13: digitalSwitch
void digitalSwitch(uint8_t pin) {
uint8_t bit = digitalPinToBitMask(pin);
uint8_t port = digitalPinToPort(pin);
volatile uint8_t *out;
if (port == NOT_A_PIN) return;
out = portOutputRegister(port);
if ( *out & bit) *out &= ~bit;
else *out |= bit;
}
开发者ID:derkling,项目名称:DerkGPS,代码行数:12,代码来源:digitals.c
示例14: digitalPinToBitMask
DHT::DHT(uint8_t pin, uint8_t type/*, uint8_t count*/) {
_pin = pin;
_type = type;
#ifdef __AVR
_bit = digitalPinToBitMask(pin);
_port = digitalPinToPort(pin);
#endif
_maxcycles = microsecondsToClockCycles(1000); // 1 millisecond timeout for
// reading pulses from DHT sensor.
// Note that count is now ignored as the DHT reading algorithm adjusts itself
// basd on the speed of the processor.
}
开发者ID:LasGIS,项目名称:Arduino,代码行数:12,代码来源:DHT.cpp
示例15: digitalPinToPort
void SoftSPIClass::begin(BYTE SSpin, BYTE SCKpin, BYTE MOSIpin, BYTE MISOpin) {
_SCKpin = SCKpin;
_MOSIpin = MOSIpin;
_MISOpin = MISOpin;
uint8_t p = digitalPinToPort(SSpin) - 1;
uint8_t b = digitalPinToBitMask(SSpin);
_SSset = __sets[p];
_SSclr = __clrs[p];
_SSport = __ports[p];
_SSpin = b;
p = digitalPinToPort(SCKpin) - 1;
b = digitalPinToBitMask(SCKpin);
_SCKset = __sets[p];
_SCKclr = __clrs[p];
_SCKport = __ports[p];
_SCKpin = b;
p = digitalPinToPort(MOSIpin) - 1;
b = digitalPinToBitMask(MOSIpin);
_MOSIset = __sets[p];
_MOSIclr = __clrs[p];
_MOSIport = __ports[p];
_MOSIpin = b;
p = digitalPinToPort(MISOpin) - 1;
b = digitalPinToBitMask(MISOpin);
_MISOset = __sets[p];
_MISOclr = __clrs[p];
_MISOport = __ports[p];
_MISOpin = b;
pinMode(SSpin, OUTPUT);
pinMode(SCKpin, OUTPUT);
pinMode(MISOpin, INPUT);
pinMode(MOSIpin, OUTPUT);
digitalWrite(SSpin, HIGH);
digitalWrite(SCKpin, LOW);
}
开发者ID:rmd6502,项目名称:SoftSPI,代码行数:40,代码来源:SoftSPI.cpp
示例16: digitalPinToBitMask
CapacitiveSensor::CapacitiveSensor(uint8_t sendPin, uint8_t receivePin)
{
uint8_t sPort, rPort;
// initialize this instance's variables
// Serial.begin(9600); // for debugging
error = 1;
loopTimingFactor = 310; // determined empirically - a hack
CS_Timeout_Millis = (2000 * (float)loopTimingFactor * (float)F_CPU) / 16000000;
CS_AutocaL_Millis = 20000;
// Serial.print("timwOut = ");
// Serial.println(CS_Timeout_Millis);
// get pin mapping and port for send Pin - from PinMode function in core
#ifdef NUM_DIGITAL_PINS
if (sendPin >= NUM_DIGITAL_PINS) error = -1;
if (receivePin >= NUM_DIGITAL_PINS) error = -1;
#endif
sBit = digitalPinToBitMask(sendPin); // get send pin's ports and bitmask
sPort = digitalPinToPort(sendPin);
sReg = portModeRegister(sPort);
sOut = portOutputRegister(sPort); // get pointer to output register
rBit = digitalPinToBitMask(receivePin); // get receive pin's ports and bitmask
rPort = digitalPinToPort(receivePin);
rReg = portModeRegister(rPort);
rIn = portInputRegister(rPort);
rOut = portOutputRegister(rPort);
// get pin mapping and port for receive Pin - from digital pin functions in Wiring.c
noInterrupts();
*sReg |= sBit; // set sendpin to OUTPUT
interrupts();
leastTotal = 0x0FFFFFFFL; // input large value for autocalibrate begin
lastCal = millis(); // set millis for start
}
开发者ID:0xPIT,项目名称:RefloLeo,代码行数:40,代码来源:CapacitiveSensor.cpp
示例17: getRawOutputChannels
void ServoOut::update(bool p_pinsChanged)
{
uint16_t remainingTime = m_pauseLength;
uint8_t idx = 0;
const uint16_t* values = getRawOutputChannels();
for (uint8_t i = 0; i < RC_MAX_CHANNELS; ++i)
{
if (m_pins[i] != 0 && values[i] != 0)
{
if (p_pinsChanged)
{
uint8_t mask = digitalPinToBitMask(m_pins[i]);
uint8_t port = digitalPinToPort(m_pins[i]);
volatile uint8_t* out = portInputRegister(port);
RC_ASSERT_MINMAX(values[i], 0, 32766);
TIMSK1 &= ~(1 << OCIE1B);
m_timings[idx] = values[i] << 1;
m_ports[idx] = static_cast<uint8_t>(reinterpret_cast<uint16_t>(out) & 0xFF);
m_masks[idx] = mask;
TIMSK1 |= (1 << OCIE1B);
}
else
{
RC_ASSERT_MINMAX(values[i], 0, 32766);
TIMSK1 &= ~(1 << OCIE1B);
m_timings[idx] = values[i] << 1;
TIMSK1 |= (1 << OCIE1B);
}
if (remainingTime < values[i])
{
remainingTime = 0;
}
else
{
remainingTime -= values[i];
}
++idx;
}
}
TIMSK1 &= ~(1 << OCIE1B);
m_timings[idx] = remainingTime << 1;
m_ports[idx] = 0;
m_masks[idx] = 0;
TIMSK1 = (1 << OCIE1B);
}
开发者ID:etienne57620,项目名称:t5x,代码行数:52,代码来源:ServoOut.cpp
示例18: _sensorID
DHT::DHT(uint8_t pin) : _sensorID(-1)
{
_pin = pin;
#ifdef __AVR
_bit = digitalPinToBitMask(pin);
_port = digitalPinToPort(pin);
#endif
// 1 millisecond timeout for reading pulses from DHT sensor.
// The DHT reading algorithm adjusts itself based on the speed of the processor.
_maxcycles = microsecondsToClockCycles(1000);
}
开发者ID:moa,项目名称:dht22,代码行数:13,代码来源:DHT22.cpp
示例19: digitalPinToBitMask
void pwm::pinSetting(uint8_t pin){
uint8_t bit = digitalPinToBitMask(pin); // get pin bit
uint8_t port = digitalPinToPort(pin); // get pin port
volatile uint8_t *sel;
if (port == NOT_A_PORT) return; // pin on timer?
sel = portSelRegister(port); // get the port function select register address
*sel |= bit; // set bit in pin function select register
/// set pin in output mode
pinMode(pin, OUTPUT);
}
开发者ID:Lucaserf,项目名称:testPwm,代码行数:13,代码来源:pwm.cpp
示例20: pinMode
void pinMode(uint8_t pin, uint8_t mode) {
uint8_t bit = digitalPinToBitMask(pin);
uint8_t port = digitalPinToPort(pin);
volatile uint8_t *reg;
if (port == NOT_A_PIN) return;
// JWS: can I let the optimizer do this?
reg = portModeRegister(port);
if (mode == INPUT) *reg &= ~bit;
else *reg |= bit;
}
开发者ID:derkling,项目名称:DerkGPS,代码行数:13,代码来源:digitals.c
注:本文中的digitalPinToPort函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论