Skip to content

Commit b417247

Browse files
aykevldeadprogram
authored andcommitted
microcontrollers: update machine package documentation to v0.26.0
1 parent 3e6ddd1 commit b417247

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+4707
-2889
lines changed

content/docs/reference/microcontrollers/machine/arduino-mega1280.md

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ const (
115115

116116
TWI_FREQ is the I2C bus speed. Normally either 100 kHz, or 400 kHz for high-speed bus.
117117

118+
Deprecated: use 100 * machine.KHz or 400 * machine.KHz instead.
119+
118120

119121
```go
120122
const Device = deviceName
@@ -127,6 +129,17 @@ The constant is some hardcoded default value if the program does not target a
127129
particular chip but instead runs in WebAssembly for example.
128130

129131

132+
```go
133+
const (
134+
KHz = 1000
135+
MHz = 1000_000
136+
GHz = 1000_000_000
137+
)
138+
```
139+
140+
Generic constants.
141+
142+
130143
```go
131144
const NoPin = Pin(0xff)
132145
```
@@ -149,10 +162,10 @@ const (
149162
PB1 = portB + 1
150163
PB2 = portB + 2
151164
PB3 = portB + 3
152-
PB4 = portB + 4
153-
PB5 = portB + 5
154-
PB6 = portB + 6
155-
PB7 = portB + 7
165+
PB4 = portB + 4 // peripherals: Timer2 channel A
166+
PB5 = portB + 5 // peripherals: Timer1 channel A
167+
PB6 = portB + 6 // peripherals: Timer1 channel B
168+
PB7 = portB + 7 // peripherals: Timer0 channel A
156169
PC0 = portC + 0
157170
PC1 = portC + 1
158171
PC2 = portC + 2
@@ -168,9 +181,9 @@ const (
168181
PD7 = portD + 7
169182
PE0 = portE + 0
170183
PE1 = portE + 1
171-
PE3 = portE + 3
172-
PE4 = portE + 4
173-
PE5 = portE + 5
184+
PE3 = portE + 3 // peripherals: Timer3 channel A
185+
PE4 = portE + 4 // peripherals: Timer3 channel B
186+
PE5 = portE + 5 // peripherals: Timer3 channel C
174187
PE6 = portE + 6
175188
PF0 = portF + 0
176189
PF1 = portF + 1
@@ -183,13 +196,13 @@ const (
183196
PG0 = portG + 0
184197
PG1 = portG + 1
185198
PG2 = portG + 2
186-
PG5 = portG + 5
199+
PG5 = portG + 5 // peripherals: Timer0 channel B
187200
PH0 = portH + 0
188201
PH1 = portH + 1
189-
PH3 = portH + 3
190-
PH4 = portH + 4
191-
PH5 = portH + 5
192-
PH6 = portH + 6
202+
PH3 = portH + 3 // peripherals: Timer4 channel A
203+
PH4 = portH + 4 // peripherals: Timer4 channel B
204+
PH5 = portH + 5 // peripherals: Timer4 channel C
205+
PH6 = portH + 6 // peripherals: Timer0 channel B
193206
PJ0 = portJ + 0
194207
PJ1 = portJ + 1
195208
PK0 = portK + 0
@@ -203,9 +216,9 @@ const (
203216
PL0 = portL + 0
204217
PL1 = portL + 1
205218
PL2 = portL + 2
206-
PL3 = portL + 3
207-
PL4 = portL + 4
208-
PL5 = portL + 5
219+
PL3 = portL + 3 // peripherals: Timer5 channel A
220+
PL4 = portL + 4 // peripherals: Timer5 channel B
221+
PL5 = portL + 5 // peripherals: Timer5 channel C
209222
PL6 = portL + 6
210223
PL7 = portL + 7
211224
)
@@ -239,15 +252,15 @@ SPI phase and polarity configs CPOL and CPHA
239252
const (
240253
// ParityNone means to not use any parity checking. This is
241254
// the most common setting.
242-
ParityNone UARTParity = 0
255+
ParityNone UARTParity = iota
243256

244257
// ParityEven means to expect that the total number of 1 bits sent
245258
// should be an even number.
246-
ParityEven UARTParity = 1
259+
ParityEven
247260

248261
// ParityOdd means to expect that the total number of 1 bits sent
249262
// should be an odd number.
250-
ParityOdd UARTParity = 2
263+
ParityOdd
251264
)
252265
```
253266

@@ -649,7 +662,7 @@ Set updates the channel value. This is used to control the channel duty
649662
cycle, in other words the fraction of time the channel output is high (or low
650663
when inverted). For example, to set it to a 25% duty cycle, use:
651664

652-
pwm.Set(channel, pwm.Top() / 4)
665+
pwm.Set(channel, pwm.Top() / 4)
653666

654667
pwm.Set(channel, 0) will set the output to low and pwm.Set(channel,
655668
pwm.Top()) will set the output to high, assuming the output isn't inverted.
@@ -680,7 +693,7 @@ func (pwm PWM) SetPeriod(period uint64) error
680693
SetPeriod updates the period of this PWM peripheral.
681694
To set a particular frequency, use the following formula:
682695

683-
period = 1e9 / frequency
696+
period = 1e9 / frequency
684697

685698
If you use a period of 0, a period that works well for LEDs will be picked.
686699

@@ -961,16 +974,16 @@ The Tx method knows about this, and offers a few different ways of calling it.
961974
This form sends the bytes in tx buffer, putting the resulting bytes read into the rx buffer.
962975
Note that the tx and rx buffers must be the same size:
963976

964-
spi.Tx(tx, rx)
977+
spi.Tx(tx, rx)
965978

966979
This form sends the tx buffer, ignoring the result. Useful for sending "commands" that return zeros
967980
until all the bytes in the command packet have been received:
968981

969-
spi.Tx(tx, nil)
982+
spi.Tx(tx, nil)
970983

971984
This form sends zeros, putting the result into the rx buffer. Good for reading a "result packet":
972985

973-
spi.Tx(nil, rx)
986+
spi.Tx(nil, rx)
974987

975988

976989

@@ -1099,7 +1112,7 @@ depending on the chip and the type of object.
10991112
## type UARTParity
11001113

11011114
```go
1102-
type UARTParity int
1115+
type UARTParity uint8
11031116
```
11041117

11051118
UARTParity is the parity setting to be used for UART communication.

content/docs/reference/microcontrollers/machine/arduino-mega2560.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ const (
133133

134134
TWI_FREQ is the I2C bus speed. Normally either 100 kHz, or 400 kHz for high-speed bus.
135135

136+
Deprecated: use 100 * machine.KHz or 400 * machine.KHz instead.
137+
136138

137139
```go
138140
const Device = deviceName
@@ -145,6 +147,17 @@ The constant is some hardcoded default value if the program does not target a
145147
particular chip but instead runs in WebAssembly for example.
146148

147149

150+
```go
151+
const (
152+
KHz = 1000
153+
MHz = 1000_000
154+
GHz = 1000_000_000
155+
)
156+
```
157+
158+
Generic constants.
159+
160+
148161
```go
149162
const NoPin = Pin(0xff)
150163
```
@@ -257,15 +270,15 @@ SPI phase and polarity configs CPOL and CPHA
257270
const (
258271
// ParityNone means to not use any parity checking. This is
259272
// the most common setting.
260-
ParityNone UARTParity = 0
273+
ParityNone UARTParity = iota
261274

262275
// ParityEven means to expect that the total number of 1 bits sent
263276
// should be an even number.
264-
ParityEven UARTParity = 1
277+
ParityEven
265278

266279
// ParityOdd means to expect that the total number of 1 bits sent
267280
// should be an odd number.
268-
ParityOdd UARTParity = 2
281+
ParityOdd
269282
)
270283
```
271284

@@ -876,16 +889,16 @@ The Tx method knows about this, and offers a few different ways of calling it.
876889
This form sends the bytes in tx buffer, putting the resulting bytes read into the rx buffer.
877890
Note that the tx and rx buffers must be the same size:
878891

879-
spi.Tx(tx, rx)
892+
spi.Tx(tx, rx)
880893

881894
This form sends the tx buffer, ignoring the result. Useful for sending "commands" that return zeros
882895
until all the bytes in the command packet have been received:
883896

884-
spi.Tx(tx, nil)
897+
spi.Tx(tx, nil)
885898

886899
This form sends zeros, putting the result into the rx buffer. Good for reading a "result packet":
887900

888-
spi.Tx(nil, rx)
901+
spi.Tx(nil, rx)
889902

890903

891904

@@ -1014,7 +1027,7 @@ depending on the chip and the type of object.
10141027
## type UARTParity
10151028

10161029
```go
1017-
type UARTParity int
1030+
type UARTParity uint8
10181031
```
10191032

10201033
UARTParity is the parity setting to be used for UART communication.

0 commit comments

Comments
 (0)