// enable GPIO module. It doesn't allocate any pins immediately.
555906
func (module *BBAnalogModule) Enable() error {
	// once-off initialisation of analog
	if !module.analogInitialised {
		path, e := findFirstMatchingFile("/sys/devices/bone_capemgr.*/slots")
		if e != nil {
			return e
		}

		// determine if cape-bone-iio is already in the file. If so, we've already initialised it.
		if !module.hasCapeBoneIIO(path) {
			// enable analog
			e = WriteStringToFile(path, "cape-bone-iio")
			if e != nil {
				return e
			}
		}

		// determine path where analog files are
		path, e = findFirstMatchingFile("/sys/devices/ocp.*/helper.*/AIN0")
		if e != nil {
			return e
		}
		if path == "" {
			return errors.New("Could not locate /sys/devices/ocp.*/helper.*/AIN0")
		}

		// remove AIN0 to get the path where these files are
		module.analogValueFilesPath = strings.TrimSuffix(path, "AIN0")

		module.analogInitialised = true

		// attempt to assign all pins to this module
		for pin, _ := range module.definedPins {
			// attempt to assign this pin for this module.
			e = AssignPin(pin, module)
			if e != nil {
				return e
			}
		}
	}
	return nil
}
170891
func (module *DTGPIOModule) Disable() error {
	for _, openPin := range module.openPins {
		openPin.gpioUnexport()
	}
	return nil
}
810761
func Enable() {
	go func() {
		if err := http.ListenAndServe(apiAddress, nil); err != nil {
			log.WithError(err).Warn("Unable to serve pprof API")
		}
	}()
}
368207
func Enable(addr string) <-chan error {
	errs := make(chan error, 1)

	go func() {
		// The Handler function provides a default handler to expose metrics
		// via an HTTP server. "/metrics" is the usual endpoint for that.
		http.Handle("/metrics", promhttp.HandlerFor(registry, promhttp.HandlerOpts{}))
		errs <- http.ListenAndServe(addr, nil)
	}()

	return errs
}
627355
func (db *DB) EnableConnFail() {
	db.mu.Lock()
	defer db.mu.Unlock()
	db.isConnFail = true
}
988913
func InitGPIO() error {
	if gpioDriverInitialized {
		return nil
	}

	desc, err := DescribeHost()
	if err != nil {
		return err
	}

	if desc.GPIODriver == nil {
		return ErrFeatureNotSupported
	}

	gpioDriverInstance = desc.GPIODriver()
	gpioDriverInitialized = true

	return nil
}
604249
func ClosePin(pin Pin) error {
	gpio, e := GetGPIOModule()
	if e != nil {
		return e
	}

	return gpio.ClosePin(pin)
}
564249
func (r *recorder) Enable() {
	r.mu.Lock()
	defer r.mu.Unlock()
	r.enabled = true

}
1149696
func PinMode(pin Pin, mode PinIOMode) error {
	gpio, e := GetGPIOModule()
	if e != nil {
		return e
	}

	return gpio.PinMode(pin, mode)
}
451394
func Enable(name string) {
	logger := loggers[name]
	if logger == nil {
		Default.Warn("cannot find logger " + name)
		return
	}

	logger.disabled = false
}
812427
func PinMode(pin Pin, mode Mode) {

	// Pin fsel register, 0 or 1 depending on bank
	fselReg := uint8(pin) / 10
	shift := (uint8(pin) % 10) * 3
	f := uint32(0)

	const in = 0   // 000
	const out = 1  // 001
	const alt0 = 4 // 100
	const alt4 = 3 // 011
	const alt5 = 2 // 010

	switch mode {
	case Input:
		f = in
	case Output:
		f = out
	case Clock:
		switch pin {
		case 4, 5, 6, 32, 34, 42, 43, 44:
			f = alt0
		case 20, 21:
			f = alt5
		default:
			return
		}
	case Pwm:
		switch pin {
		case 12, 13, 40, 41, 45:
			f = alt0
		case 18, 19:
			f = alt5
		default:
			return
		}
	case Spi:
		switch pin {
		case 7, 8, 9, 10, 11: // SPI0
			f = alt0
		case 35, 36, 37, 38, 39: // SPI0
			f = alt0
		case 16, 17, 18, 19, 20, 21: // SPI1
			f = alt4
		case 40, 41, 42, 43, 44, 45: // SPI2
			f = alt4
		default:
			return
		}
	}

	memlock.Lock()
	defer memlock.Unlock()

	const pinMask = 7 // 111 - pinmode is 3 bits

	gpioMem[fselReg] = (gpioMem[fselReg] &^ (pinMask << shift)) | (f << shift)
}
279172
func (module *DTI2CModule) Disable() error {
	if e := module.fd.Close(); e != nil {
		return e
	}

	for _, pin := range module.definedPins {
		UnassignPin(pin)
	}

	return nil
}
649618
func (conn *GPIOConnection) Close() error {
	glog.V(2).Info("hd44780: closing all GPIO pins")
	pins := []embd.DigitalPin{
		conn.RS,
		conn.EN,
		conn.D4,
		conn.D5,
		conn.D6,
		conn.D7,
		conn.Backlight,
	}

	for _, pin := range pins {
		err := pin.Close()
		if err != nil {
			glog.Errorf("hd44780: error closing pin %+v: %s", pin, err)
			return err
		}
	}
	return nil
}
659590
func Enabled(n FeatureFlag) bool {
	fMu.RLock()
	defer fMu.RUnlock()
	v, present := features[n]
	if !present {
		panic(fmt.Sprintf("feature '%s' doesn't exist", n.String()))
	}
	return v
}
958244
func GetGPIOModule() (GPIOModule, error) {
	m, e := GetModule("gpio")
	if e != nil {
		return nil, e
	}

	if m == nil {
		return nil, errors.New("Driver does not support GPIO")
	}

	return m.(GPIOModule), nil
}
1072204
func (m *ARPMechanism) Enable(c *mech.MechanismContext) {
	m.BaseMechanism.Enable(c)

	// Register resolve function by function address.
	m.C.Func.RegisterFunc((*ARPMechanism).Lookup, resolveFuncWrapper)

	m.filter.Mux = m.C.Mux
	// Handle incoming ARP requests.
	m.filter.HandleFunc(of.T_PACKET_IN, m.packetInHandler)
	// Handle removed flows notifications
	m.filter.HandleFunc(of.T_FLOW_REMOVED, m.flowRemovedHandler)

	log.InfoLog("arp/ENABLE_HOOK", "Mechanism ARP enabled")
}
658398
func changePinMode(a *Adaptor, pin, mode string) (err error) {
	_, err = a.writeFile(
		"/sys/kernel/debug/gpio_debug/gpio"+pin+"/current_pinmux",
		[]byte("mode"+mode),
	)
	return
}