mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-04 23:17:47 +00:00
b6c750ccd1
This first version of the driver has been tested with STM32WL SoC, which embeddeds SX1262 radio on the same die.
44 lines
776 B
Go
44 lines
776 B
Go
//go:build lorae5
|
|
// +build lorae5
|
|
|
|
package radio
|
|
|
|
/*
|
|
/!\ LoRa-E5 module ONLY transmits through RFO_HP:
|
|
|
|
Receive: PA4=1, PA5=0
|
|
Transmit(high output power, SMPS mode): PA4=0, PA5=1
|
|
|
|
*/
|
|
|
|
import (
|
|
"errors"
|
|
"machine"
|
|
|
|
"tinygo.org/x/drivers/sx126x"
|
|
)
|
|
|
|
type CustomSwitch struct {
|
|
}
|
|
|
|
func (s CustomSwitch) InitRFSwitch() {
|
|
machine.PA4.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
|
machine.PB5.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
|
}
|
|
|
|
func (s CustomSwitch) SetRfSwitchMode(mode int) error {
|
|
switch mode {
|
|
|
|
case sx126x.RFSWITCH_RX:
|
|
machine.PA4.Set(true)
|
|
machine.PB5.Set(false)
|
|
case sx126x.RFSWITCH_TX_LP:
|
|
errors.New("RFSWITCH_TX_LP not supported ")
|
|
case sx126x.RFSWITCH_TX_HP:
|
|
machine.PA4.Set(false)
|
|
machine.PB5.Set(true)
|
|
|
|
}
|
|
return nil
|
|
}
|