func SpiChipSelectPolarity(chip uint8, polarity uint8) {
	if chip > 2 {
		return
	}
	cspol := uint32(1 << (21 + chip))  
	if polarity == 0 {  
		spiMem[csReg] &^= cspol
	} else {  
		spiMem[csReg] |= cspol
	}
}
SpiChipSelectPolarity: Sets polarity (0/1) of active chip select
default active=0
package rpio
import (
	"errors"
)
type SpiDev int
const (
	Spi0 SpiDev = iota
	Spi1         
	Spi2         
)
const (
	csReg     = 0
	fifoReg   = 1  
	clkDivReg = 2
)
var (
	SpiMapError = errors.New("SPI registers not mapped correctly - are you root?")
)
func SpiBegin(dev SpiDev) error {
	spiMem[csReg] = 0  
	if spiMem[csReg] == 0 {
		return SpiMapError
	}
	for _, pin := range getSpiPins(dev) {
		pin.Mode(Spi)
	}
	clearSpiTxRxFifo()
	setSpiDiv(128)
	return nil
}
func SpiEnd(dev SpiDev) {
	var pins = getSpiPins(dev)
	for _, pin := range pins {
		pin.Mode(Input)
	}
}
func SpiSpeed(speed int) {
	const baseFreq = 250 * 1000000
	cdiv := uint32(baseFreq / speed)
	setSpiDiv(cdiv)
}
func SpiChipSelect(chip uint8) {
	const csMask = 3  
	cs := uint32(chip & csMask)
	spiMem[csReg] = spiMem[csReg]&^csMask | cs
}