@@ -115,6 +115,8 @@ const (
115115
116116TWI_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
120122const Device = deviceName
@@ -127,6 +129,17 @@ The constant is some hardcoded default value if the program does not target a
127129particular 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
131144const 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
239252const (
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
649662cycle, in other words the fraction of time the channel output is high (or low
650663when 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
654667pwm.Set(channel, 0) will set the output to low and pwm.Set(channel,
655668pwm.Top()) will set the output to high, assuming the output isn't inverted.
@@ -680,7 +693,7 @@ func (pwm PWM) SetPeriod(period uint64) error
680693SetPeriod updates the period of this PWM peripheral.
681694To set a particular frequency, use the following formula:
682695
683- period = 1e9 / frequency
696+ period = 1e9 / frequency
684697
685698If 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.
961974This form sends the bytes in tx buffer, putting the resulting bytes read into the rx buffer.
962975Note that the tx and rx buffers must be the same size:
963976
964- spi.Tx(tx, rx)
977+ spi.Tx(tx, rx)
965978
966979This form sends the tx buffer, ignoring the result. Useful for sending "commands" that return zeros
967980until all the bytes in the command packet have been received:
968981
969- spi.Tx(tx, nil)
982+ spi.Tx(tx, nil)
970983
971984This 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
11051118UARTParity is the parity setting to be used for UART communication.
0 commit comments