title: BeagleBone SPI using mmap
body: <p>I am having trouble configuring my BBB for SPI using a python mmap.</p>
  
  <p>Rather than rolling a device tree overlay myself, I've been using Adafruit_BBIO.SPI (A similar approach has been working for Adafruit_BBIO.GPIO).  This works well, and through SPIdev, I can send data.  But as soon as I use mmap to SPI_TX0, I get a bus error.</p>
  
  <p>I can resolve the bus error by turning on the clock domain to the SPI peripheral:</p>
  
  <pre><code>ctrl = struct.unpack('&lt;L', CM_PER[CM_PER_SPI0_CLKCTRL:CM_PER_SPI0_CLKCTRL+4])[0]
  ctrl &amp;= ~(0b11 &lt;&lt; 16 | 0b11)
  ctrl |= 2
  CM_PER[CM_PER_SPI0_CLKCTRL:CM_PER_SPI0_CLKCTRL+4] = struct.pack('&lt;L', ctrl)
  </code></pre>
  
  <p>But I don't understand why this is necessary; shouldn't Adafruit_BBIO have already turned the clock domain on?</p>
  
  <p>More importantly, though, is that SPI0[SPI_TX0:SPI_TX0+4] = struct.pack('<code>&lt;</code>L', data) does nothing.</p>