tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/sx126x/radiocontrol_lorae5.go (about)

     1  //go:build lorae5
     2  
     3  /*
     4  LoRa-E5 module ONLY transmits through RFO_HP:
     5  
     6  Receive: PA4=1, PA5=0
     7  Transmit(high output power, SMPS mode): PA4=0, PA5=1
     8  */
     9  
    10  package sx126x
    11  
    12  import (
    13  	"machine"
    14  )
    15  
    16  // RadioControl for LoRa-E5 board.
    17  type RadioControl struct {
    18  	STM32RadioControl
    19  }
    20  
    21  func NewRadioControl() *RadioControl {
    22  	return &RadioControl{STM32RadioControl: STM32RadioControl{}}
    23  }
    24  
    25  // Init pins needed for controlling rx/tx
    26  func (rc *RadioControl) Init() error {
    27  	machine.PA4.Configure(machine.PinConfig{Mode: machine.PinOutput})
    28  	machine.PB5.Configure(machine.PinConfig{Mode: machine.PinOutput})
    29  
    30  	return nil
    31  }
    32  
    33  func (rc *RadioControl) SetRfSwitchMode(mode int) error {
    34  	switch mode {
    35  
    36  	case RFSWITCH_RX:
    37  		machine.PA4.Set(true)
    38  		machine.PB5.Set(false)
    39  	case RFSWITCH_TX_LP:
    40  		return errLowPowerTxNotSupported
    41  	case RFSWITCH_TX_HP:
    42  		machine.PA4.Set(false)
    43  		machine.PB5.Set(true)
    44  
    45  	}
    46  	return nil
    47  }