Exemple #1
0
func (mgr *Gpio) Set(states uint32, mask uint32) {
	val := states & mask
	if val != 0 {
		C.range_set_u32(mgr.hdl, gpioOffSet, C.uint32_t(val))
	}
	val = ^states & mask
	if val != 0 {
		C.range_set_u32(mgr.hdl, gpioOffClear, C.uint32_t(val))
	}
}
Exemple #2
0
func (mgr *Gpio) setFunc(pin Pin, mode uint) {
	off := gpioOffFunc + 4*(C.size_t(pin)/10)
	shift := 3 * (pin % 10)
	cur := uint(C.range_get_u32(mgr.hdl, off))
	val := (cur &^ (0x7 << shift)) | (mode << shift)
	C.range_set_u32(mgr.hdl, off, C.uint32_t(val))
}