@@ -20,8 +20,18 @@ func loopGPIO() {
20
20
let basePointer : UnsafeMutablePointer < UInt32 > = rawPointer. bindMemory ( to: UInt32 . self, capacity: 30 )
21
21
22
22
// Configure GPIO pin 4 & 6 as output (3 bits/pin)
23
- // pin numbers: 6 5 4 3 2 1 0
24
- basePointer. pointee = 0b001001000000000000000
23
+ // pin numbers: 8 7 6 5 4 3 2 1 0
24
+ // basePointer.pointee = 0b000001001000000000000000
25
+
26
+
27
+ guard let rawPointer2 = mmap ( nil , 1024 * 4 , PROT_READ | PROT_WRITE, MAP_SHARED, file, 0x3f200000 ) else {
28
+ perror ( " Cannot mmap bytes for path " )
29
+ return
30
+ }
31
+ // let basePointer2: UnsafeMutabl ePointer<UInt32> = rawPointer2.bindMemory(to: UInt32.self, capacity: 30)
32
+
33
+ // pin numbers: 22 21 20 19 18 17 16 15 14 13 12 11 // 10 9 8 7 6 5 4 3 2 1 0
34
+ // basePointer2.pointee = 0b00001000000000000000000000000000 //000000000000001001000000000000000
25
35
26
36
// Set up set/clear pointer objects
27
37
// Offsets from docs were given in byte-size values
@@ -41,11 +51,11 @@ func loopGPIO() {
41
51
// Loop through and show the LED turning on and off
42
52
for i in 0 ... 5 {
43
53
print ( " High \( setPointer) " )
44
- setPointer. pointee = 0b1100000 // Pin 6 & 4
54
+ setPointer. pointee = 0b100000100000000000001100000 // Pin 20, 6 & 5
45
55
usleep ( 500000 )
46
56
print ( " Counter: \( i) " )
47
57
print ( " Low \( clearPointer) " )
48
- clearPointer. pointee = 0b1100000 // Pin 6 & 4
58
+ clearPointer. pointee = 0b100000100000000000001100000 // Pin 20, 6 & 5
49
59
usleep ( 500000 )
50
60
}
51
61
}
0 commit comments