static void spiinit(void) { spi.regs = (Spiregs*)SPIREGS; spi.regs->clkdiv = 250; /* 1 MHz */ gpiosel(SPI0_MISO, Alt0); gpiosel(SPI0_MOSI, Alt0); gpiosel(SPI0_SCLK, Alt0); gpiosel(SPI0_CE0_N, Alt0); gpiosel(SPI0_CE1_N, Alt0); }
static void i2cinit(void) { i2c.regs = (Bsc*)I2CREGS; i2c.regs->clkdiv = 2500; gpiosel(SDA0Pin, Alt0); gpiosel(SCL0Pin, Alt0); gpiopullup(SDA0Pin); gpiopullup(SCL0Pin); intrenable(IRQi2c, i2cinterrupt, 0, 0, "i2c"); }
void okay(int on) { static int first; static int okled, polarity; char *p; if(!first++){ p = getconf("bcm2709.disk_led_gpio"); if(p == nil) p = getconf("bcm2708.disk_led_gpio"); if(p != nil) okled = strtol(p, 0, 0); else okled = 'v'; p = getconf("bcm2709.disk_led_active_low"); if(p == nil) p = getconf("bcm2708.disk_led_active_low"); polarity = (p == nil || *p == '1'); if(okled != 'v') gpiosel(okled, Output); } if(okled == 'v') vgpset(0, on); else if(okled != 0) gpioout(okled, on^polarity); }
void okay(int on) { static int first; if(!first++) gpiosel(OkLed, Output); gpioout(OkLed, !on); }
static void enable(Uart *uart, int ie) { u32int *ap; ap = (u32int*)uart->regs; delay(10); gpiosel(TxPin, Alt5); gpiosel(RxPin, Alt5); gpiopulloff(TxPin); gpiopulloff(RxPin); ap[Enables] |= UartEn; ap[MuIir] = 6; ap[MuLcr] = Bits8; ap[MuCntl] = TxEn|RxEn; ap[MuBaud] = 250000000/(115200*8) - 1; if(ie){ intrenable(IRQaux, interrupt, uart, 0, "uart"); ap[MuIer] = RxIen|TxIen; }else ap[MuIer] = 0; }