mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-12 06:53:40 +00:00
machine: add simulated PWM/timer peripherals
I will soon use these as part of the TinyGo tour, to explain the PWM peripherals on common chips.
This commit is contained in:
committed by
Ron Evans
parent
612a38e363
commit
72b19555dc
@@ -0,0 +1,96 @@
|
||||
//go:build !baremetal && (ae_rp2040 || badger2040_w || badger2040 || challenger_rp2040 || elecrow_rp2040 || feather_rp2040 || gopher_badge || kb2040 || macropad_rp2040 || nano_rp2040 || pico || qtpy_rp2040 || thingplus_rp2040 || thumby || trinkey_qt2040 || tufty2040 || waveshare_rp2040_tiny || waveshare_rp2040_zero || xiao_rp2040)
|
||||
|
||||
// Simulator support for the RP2040.
|
||||
//
|
||||
// This is *only* for the RP2040. RP2350 is a different chip with slightly
|
||||
// different characteristics.
|
||||
|
||||
package machine
|
||||
|
||||
var PWM0 = timerType{
|
||||
instance: 0,
|
||||
frequency: 200e6,
|
||||
bits: 16,
|
||||
prescalers: []int{1, 2, 4, 8, 16, 32, 64, 128, 256}, // actually a continuing range, TODO
|
||||
channelPins: [][]Pin{
|
||||
{GPIO0, GPIO16}, // channel A (0)
|
||||
{GPIO1, GPIO17}, // channel B (1)
|
||||
},
|
||||
}
|
||||
|
||||
var PWM1 = timerType{
|
||||
instance: 0,
|
||||
frequency: 200e6,
|
||||
bits: 16,
|
||||
prescalers: []int{1, 2, 4, 8, 16, 32, 64, 128, 256},
|
||||
channelPins: [][]Pin{
|
||||
{GPIO2, GPIO18}, // channel A (0)
|
||||
{GPIO3, GPIO19}, // channel B (1)
|
||||
},
|
||||
}
|
||||
|
||||
var PWM2 = timerType{
|
||||
instance: 0,
|
||||
frequency: 200e6,
|
||||
bits: 16,
|
||||
prescalers: []int{1, 2, 4, 8, 16, 32, 64, 128, 256},
|
||||
channelPins: [][]Pin{
|
||||
{GPIO4, GPIO20}, // channel A (0)
|
||||
{GPIO5, GPIO21}, // channel B (1)
|
||||
},
|
||||
}
|
||||
|
||||
var PWM3 = timerType{
|
||||
instance: 0,
|
||||
frequency: 200e6,
|
||||
bits: 16,
|
||||
prescalers: []int{1, 2, 4, 8, 16, 32, 64, 128, 256},
|
||||
channelPins: [][]Pin{
|
||||
{GPIO6, GPIO22}, // channel A (0)
|
||||
{GPIO7, GPIO23}, // channel B (1)
|
||||
},
|
||||
}
|
||||
|
||||
var PWM4 = timerType{
|
||||
instance: 0,
|
||||
frequency: 200e6,
|
||||
bits: 16,
|
||||
prescalers: []int{1, 2, 4, 8, 16, 32, 64, 128, 256},
|
||||
channelPins: [][]Pin{
|
||||
{GPIO8, GPIO24}, // channel A (0)
|
||||
{GPIO9, GPIO25}, // channel B (1)
|
||||
},
|
||||
}
|
||||
|
||||
var PWM5 = timerType{
|
||||
instance: 0,
|
||||
frequency: 200e6,
|
||||
bits: 16,
|
||||
prescalers: []int{1, 2, 4, 8, 16, 32, 64, 128, 256},
|
||||
channelPins: [][]Pin{
|
||||
{GPIO10, GPIO26}, // channel A (0)
|
||||
{GPIO11, GPIO27}, // channel B (1)
|
||||
},
|
||||
}
|
||||
|
||||
var PWM6 = timerType{
|
||||
instance: 0,
|
||||
frequency: 200e6,
|
||||
bits: 16,
|
||||
prescalers: []int{1, 2, 4, 8, 16, 32, 64, 128, 256},
|
||||
channelPins: [][]Pin{
|
||||
{GPIO12, GPIO28}, // channel A (0)
|
||||
{GPIO13, GPIO29}, // channel B (1)
|
||||
},
|
||||
}
|
||||
|
||||
var PWM7 = timerType{
|
||||
instance: 0,
|
||||
frequency: 200e6,
|
||||
bits: 16,
|
||||
prescalers: []int{1, 2, 4, 8, 16, 32, 64, 128, 256},
|
||||
channelPins: [][]Pin{
|
||||
{GPIO14}, // channel A (0)
|
||||
{GPIO15}, // channel B (1)
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user