PCintPort Help for Project

Hello

I need to know what this snippet of the following code exactly does.

Also, please do tell me what does PCintPort and the doublle colon (::slight_smile: mean in an arduino code.

Thank You for your help.

#define RX_PINS_OFFSET 2
#define PIN_RX_THROTTLE 4

volatile int pwm_start_time[4];
uint8_t latest_interrupted_pin;

void initialize()

{

pinMode(PIN_RX_THROTTLE, INPUT); digitalWrite(PIN_RX_THROTTLE, HIGH);
PCintPort::attachInterrupt(PIN_RX_THROTTLE, &rising, RISING);

}

void rising()
{
latest_interrupted_pin=PCintPort::arduinoPin;
PCintPort::attachInterrupt(latest_interrupted_pin, &falling, FALLING);
pwm_start_time[latest_interrupted_pin-RX_PINS_OFFSET] = micros();

}

void falling() {
latest_interrupted_pin=PCintPort::arduinoPin;
PCintPort::attachInterrupt(latest_interrupted_pin, &rising, RISING);
rx_values[latest_interrupted_pin-RX_PINS_OFFSET] = micros()-pwm_start_time[latest_interrupted_pin-RX_PINS_OFFSET];

}

what does PCintPort and the doublle colon

PCintPort is the name of a class. The double colon is the scope resolution operator.

PCintPort::attachInterrupt(PIN_RX_THROTTLE, &rising, RISING);

Here, it means call the (static) method, attachInterrupt(), of the PCintPort class.

Once you know that, the rest of the code is pretty straightforward. Each time there is a change detected on a pin, the other kind of change is looked for next. So, a FALLING edge will cause the interrupt handler trigger to be changed to RISING, and each time a RISING edge is detected, the interrupt handler trigger type will be changed to FALLING.

By the way, Arduino code is C++ code. The double colon is the C++ scope resolution operator as PaulS wrote.