Skip to content

Commit edaf877

Browse files
aykevldeadprogram
authored andcommitted
machine: use pointer receiver in simulated PWM peripherals
I only discovered this issue after a while. All the baremetal PWM implementations use pointers to a PWM instance, instead of the PWM instance itself. For consistency (and because it's a better idea in general), the simulated PWMs need to work the same.
1 parent 4574340 commit edaf877

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/machine/machine_atsamd21_simulator.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package machine
77
// The timer channels/pins match the hardware, and encode the same information
88
// as pinTimerMapping but in a more generic (less efficient) way.
99

10-
var TCC0 = timerType{
10+
var TCC0 = &timerType{
1111
instance: 0,
1212
frequency: 48e6,
1313
bits: 24,
@@ -20,7 +20,7 @@ var TCC0 = timerType{
2020
},
2121
}
2222

23-
var TCC1 = timerType{
23+
var TCC1 = &timerType{
2424
instance: 1,
2525
frequency: 48e6,
2626
bits: 24,
@@ -33,7 +33,7 @@ var TCC1 = timerType{
3333
},
3434
}
3535

36-
var TCC2 = timerType{
36+
var TCC2 = &timerType{
3737
instance: 2,
3838
frequency: 48e6,
3939
bits: 16,

src/machine/machine_nrf52840_simulator.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package machine
77
// Channel values below are nil, so that they get filled in on the first use.
88
// This is the same as what happens on baremetal.
99

10-
var PWM0 = timerType{
10+
var PWM0 = &timerType{
1111
instance: 0,
1212
frequency: 16e6,
1313
bits: 15,
@@ -20,7 +20,7 @@ var PWM0 = timerType{
2020
},
2121
}
2222

23-
var PWM1 = timerType{
23+
var PWM1 = &timerType{
2424
instance: 1,
2525
frequency: 16e6,
2626
bits: 15,
@@ -33,7 +33,7 @@ var PWM1 = timerType{
3333
},
3434
}
3535

36-
var PWM2 = timerType{
36+
var PWM2 = &timerType{
3737
instance: 2,
3838
frequency: 16e6,
3939
bits: 15,
@@ -46,7 +46,7 @@ var PWM2 = timerType{
4646
},
4747
}
4848

49-
var PWM3 = timerType{
49+
var PWM3 = &timerType{
5050
instance: 3,
5151
frequency: 16e6,
5252
bits: 15,

src/machine/machine_rp2040_simulator.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
package machine
99

10-
var PWM0 = timerType{
10+
var PWM0 = &timerType{
1111
instance: 0,
1212
frequency: 200e6,
1313
bits: 16,
@@ -18,7 +18,7 @@ var PWM0 = timerType{
1818
},
1919
}
2020

21-
var PWM1 = timerType{
21+
var PWM1 = &timerType{
2222
instance: 0,
2323
frequency: 200e6,
2424
bits: 16,
@@ -29,7 +29,7 @@ var PWM1 = timerType{
2929
},
3030
}
3131

32-
var PWM2 = timerType{
32+
var PWM2 = &timerType{
3333
instance: 0,
3434
frequency: 200e6,
3535
bits: 16,
@@ -40,7 +40,7 @@ var PWM2 = timerType{
4040
},
4141
}
4242

43-
var PWM3 = timerType{
43+
var PWM3 = &timerType{
4444
instance: 0,
4545
frequency: 200e6,
4646
bits: 16,
@@ -51,7 +51,7 @@ var PWM3 = timerType{
5151
},
5252
}
5353

54-
var PWM4 = timerType{
54+
var PWM4 = &timerType{
5555
instance: 0,
5656
frequency: 200e6,
5757
bits: 16,
@@ -62,7 +62,7 @@ var PWM4 = timerType{
6262
},
6363
}
6464

65-
var PWM5 = timerType{
65+
var PWM5 = &timerType{
6666
instance: 0,
6767
frequency: 200e6,
6868
bits: 16,
@@ -73,7 +73,7 @@ var PWM5 = timerType{
7373
},
7474
}
7575

76-
var PWM6 = timerType{
76+
var PWM6 = &timerType{
7777
instance: 0,
7878
frequency: 200e6,
7979
bits: 16,
@@ -84,7 +84,7 @@ var PWM6 = timerType{
8484
},
8585
}
8686

87-
var PWM7 = timerType{
87+
var PWM7 = &timerType{
8888
instance: 0,
8989
frequency: 200e6,
9090
bits: 16,

0 commit comments

Comments
 (0)