             MAP_SHARED,          //Shared with other processes
             mem_fd,              //File to map
             off_t(GPIO_BASE)     //Offset to GPIO peripheral
-            )
-
+            )!
+        
         close(mem_fd)
-
-        let gpioBasePointer = UnsafeMutablePointer<Int>(gpio_map)!
+        
+        let gpioBasePointer = gpio_map.load(as: UnsafeMutablePointer<Int>.self)
         if (gpioBasePointer.pointee == -1) {    //MAP_FAILED not available, but its value is (void*)-1
-            print("mmap error: " + String(gpioBasePointer))
+            print("mmap error: " + "\(gpioBasePointer)")
             abort()
         }
         
         gpioGetPointer = gpioBasePointer.advanced(by: 13)
         gpioSetPointer = gpioBasePointer.advanced(by: 7)
-        gpioClearPointer = gpioBasePointer.advanced(by: 10) 
-
+        gpioClearPointer = gpioBasePointer.advanced(by: 10)
+        
         inited = true
     }
- 
+    
     private func gpioAsInput(){
         let ptr = gpioBasePointer.advanced(by: id/10)
         ptr.pointee &= ~(7<<((id%10)*3))
     }
-
+    
     private func gpioAsOutput(){
         let ptr = gpioBasePointer.advanced(by: id/10)
         ptr.pointee &= ~(7<<((id%10)*3))
         ptr.pointee |=  (1<<((id%10)*3))
-    }  
+    }
     
     private func gpioGet()->Int{
         return ((gpioGetPointer.pointee & setGetId)>0) ? 1 : 0
     }
-
+    
     private func gpioSet(_ value:Int){
         let ptr = value==1 ? gpioSetPointer : gpioClearPointer
         ptr!.pointee = setGetId
-    } 
- 
-}
- 
+    }
+    
+}
+
 // MARK: SPI
 
 public protocol SPIOutput {

    var setGetId=0
    var baseAddr:Int=0
    var inited=false

    let BCM2708_PERI_BASE:Int
    let GPIO_BASE:Int
    let PAGE_SIZE = 4*1024
    let BLOCK_SIZE = 4*1024

    var gpioBasePointer:UnsafeMutablePointer<Int>!
    var gpioGetPointer:UnsafeMutablePointer<Int>!
    var gpioSetPointer:UnsafeMutablePointer<Int>!
    var gpioClearPointer:UnsafeMutablePointer<Int>!

    public init(name:String, id:Int, baseAddr:Int) {
        self.setGetId = 1<<id
        self.BCM2708_PERI_BASE = baseAddr
        self.GPIO_BASE = BCM2708_PERI_BASE + 0x200000 /* GPIO controller */
        super.init(name:name,id:id)
    }

    public override var value:Int{
        set(val){
            if !inited {initIO(id)}

    //the pins, and i realize it could not be that useful(likely to change
    //in the future in favor of a better alternative).
    //
    //Only the pins described as gpio in the official documentation are
    //included here: https://github.com/CircuitCo/BeagleBone-Black/blob/master/BBB_SRM.pdf?raw=true
    //Clearly this does not support mode change.
    //
