Beispiel #1
0
Pin& Pin::SetAnalogValue(float value) {
    analogVal.setA(value);

     CalcPin();

     return *this;
 }
Beispiel #2
0
Pin& Pin::operator= (char c) {
    switch(c) {
        case 'S':
            outState = SHORTED;
            analogVal.setD(AnalogValue::ST_GND);
            break;
            
        case 'H':
            outState = HIGH;
            analogVal.setD(AnalogValue::ST_VCC);
            break;
            
        case 'h':
            outState = PULLUP;
            analogVal.setD(AnalogValue::ST_VCC);
            break;
            
        case 't':
            outState = TRISTATE;
            analogVal.setD(AnalogValue::ST_FLOATING);
            break;
            
        case 'l':
            outState = PULLDOWN;
            analogVal.setD(AnalogValue::ST_GND);
            break;
            
        case 'L':
            outState = LOW;
            analogVal.setD(AnalogValue::ST_GND);
            break;
            
        case 'a':
            outState = ANALOG;
            analogVal.setD(AnalogValue::ST_FLOATING); // set to floating state, analog value, but not set
            break;
            
        case 'A':
            outState = ANALOG_SHORTED;
            analogVal.setD(AnalogValue::ST_GND);
            break;
    }

    CalcPin();

    return *this;
}
Beispiel #3
0
bool PortPin::CalcPinOverride(bool ddr, bool port, bool pud) {
    unsigned char ddov = DDOE & DDOV; // masking values
    unsigned char pvov = PVOE & PVOV;
    unsigned char pvovwddr = PVOEwDDR & PVOV;
    bool resultingDDR = (!DDOE && ddr) || (DDOE && ddov);
    bool resultingPort = (!(PVOE || PVOEwDDR) && port) || (PVOE && pvov) || (PVOEwDDR && pvovwddr && ddr);
    bool pu = !pud && !ddr && port;
    bool resultingPU = (!PUOE && pu) || (PUOE && PUOV);

    if(resultingDDR) {
        if(resultingPort)
            outState = Pin::HIGH;
        else
            outState = Pin::LOW;
    } else {
        if(resultingPU)
            outState = Pin::PULLUP;
        else
            outState = Pin::TRISTATE;
    }

    return CalcPin();
}