mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-11 06:23:39 +00:00
feature: modify i2s interface/implementation to better match specification
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
+30
-4
@@ -1,4 +1,4 @@
|
||||
//go:build sam
|
||||
//go:build sam && atsamd21
|
||||
|
||||
// This is the definition for I2S bus functions.
|
||||
// Actual implementations if available for any given hardware
|
||||
@@ -9,6 +9,22 @@
|
||||
|
||||
package machine
|
||||
|
||||
import "errors"
|
||||
|
||||
// If you are getting a compile error on this line please check to see you've
|
||||
// correctly implemented the methods on the I2S type. They must match
|
||||
// the interface method signatures type to type perfectly.
|
||||
// If not implementing the I2S type please remove your target from the build tags
|
||||
// at the top of this file.
|
||||
var _ interface {
|
||||
SetSampleFrequency(freq uint32) error
|
||||
ReadMono(b []uint16) (int, error)
|
||||
ReadStereo(b []uint32) (int, error)
|
||||
WriteMono(b []uint16) (int, error)
|
||||
WriteStereo(b []uint32) (int, error)
|
||||
Enable(enabled bool)
|
||||
} = (*I2S)(nil)
|
||||
|
||||
type I2SMode uint8
|
||||
type I2SStandard uint8
|
||||
type I2SClockSource uint8
|
||||
@@ -18,6 +34,7 @@ const (
|
||||
I2SModeSource I2SMode = iota
|
||||
I2SModeReceiver
|
||||
I2SModePDM
|
||||
I2SModeSourceReceiver
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -39,11 +56,20 @@ const (
|
||||
I2SDataFormat32bit = 32
|
||||
)
|
||||
|
||||
var (
|
||||
ErrInvalidSampleFrequency = errors.New("i2s: invalid sample frequency")
|
||||
)
|
||||
|
||||
// All fields are optional and may not be required or used on a particular platform.
|
||||
type I2SConfig struct {
|
||||
SCK Pin
|
||||
WS Pin
|
||||
SD Pin
|
||||
// clock
|
||||
SCK Pin
|
||||
// word select
|
||||
WS Pin
|
||||
// data out
|
||||
SDO Pin
|
||||
// data in
|
||||
SDI Pin
|
||||
Mode I2SMode
|
||||
Standard I2SStandard
|
||||
ClockSource I2SClockSource
|
||||
|
||||
Reference in New Issue
Block a user