Add MAX2837 functions to control operating mode.
Replace direct manipulation of GPIOs controlling MAX2837 with operating mode functions.
This commit is contained in:
@ -220,14 +220,53 @@ void max2837_regs_commit(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void max2837_mode_shutdown(void) {
|
||||||
|
/* All circuit blocks are powered down, except the 4-wire serial bus
|
||||||
|
* and its internal programmable registers.
|
||||||
|
*/
|
||||||
|
gpio_clear(PORT_XCVR_ENABLE,
|
||||||
|
(PIN_XCVR_ENABLE | PIN_XCVR_RXENABLE | PIN_XCVR_TXENABLE));
|
||||||
|
}
|
||||||
|
|
||||||
|
void max2837_mode_standby(void) {
|
||||||
|
/* Used to enable the frequency synthesizer block while the rest of the
|
||||||
|
* device is powered down. In this mode, PLL, VCO, and LO generator
|
||||||
|
* are on, so that Tx or Rx modes can be quickly enabled from this mode.
|
||||||
|
* These and other blocks can be selectively enabled in this mode.
|
||||||
|
*/
|
||||||
|
gpio_clear(PORT_XCVR_ENABLE, (PIN_XCVR_RXENABLE | PIN_XCVR_TXENABLE));
|
||||||
|
gpio_set(PORT_XCVR_ENABLE, PIN_XCVR_ENABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void max2837_mode_tx(void) {
|
||||||
|
/* All Tx circuit blocks are powered on. The external PA is powered on
|
||||||
|
* after a programmable delay using the on-chip PA bias DAC. The slow-
|
||||||
|
* charging Rx circuits are in a precharged “idle-off” state for fast
|
||||||
|
* Tx-to-Rx turnaround time.
|
||||||
|
*/
|
||||||
|
gpio_clear(PORT_XCVR_ENABLE, PIN_XCVR_RXENABLE);
|
||||||
|
gpio_set(PORT_XCVR_ENABLE,
|
||||||
|
(PIN_XCVR_ENABLE | PIN_XCVR_TXENABLE));
|
||||||
|
}
|
||||||
|
|
||||||
|
void max2837_mode_rx(void) {
|
||||||
|
/* All Rx circuit blocks are powered on and active. Antenna signal is
|
||||||
|
* applied; RF is downconverted, filtered, and buffered at Rx BB I and Q
|
||||||
|
* outputs. The slow- charging Tx circuits are in a precharged “idle-off”
|
||||||
|
* state for fast Rx-to-Tx turnaround time.
|
||||||
|
*/
|
||||||
|
gpio_clear(PORT_XCVR_ENABLE, PIN_XCVR_TXENABLE);
|
||||||
|
gpio_set(PORT_XCVR_ENABLE,
|
||||||
|
(PIN_XCVR_ENABLE | PIN_XCVR_RXENABLE));
|
||||||
|
}
|
||||||
|
|
||||||
void max2837_start(void)
|
void max2837_start(void)
|
||||||
{
|
{
|
||||||
LOG("# max2837_start\n");
|
LOG("# max2837_start\n");
|
||||||
set_MAX2837_EN_SPI(1);
|
set_MAX2837_EN_SPI(1);
|
||||||
max2837_regs_commit();
|
max2837_regs_commit();
|
||||||
#if !defined TEST
|
#if !defined TEST
|
||||||
gpio_clear(PORT_XCVR_ENABLE, (PIN_XCVR_RXENABLE | PIN_XCVR_TXENABLE));
|
max2837_mode_standby();
|
||||||
gpio_set(PORT_XCVR_ENABLE, PIN_XCVR_ENABLE);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,9 +277,7 @@ void max2837_tx(void)
|
|||||||
|
|
||||||
set_MAX2837_ModeCtrl(MAX2837_ModeCtrl_TxLPF);
|
set_MAX2837_ModeCtrl(MAX2837_ModeCtrl_TxLPF);
|
||||||
max2837_regs_commit();
|
max2837_regs_commit();
|
||||||
|
max2837_mode_tx();
|
||||||
gpio_clear(PORT_XCVR_ENABLE, PIN_XCVR_RXENABLE);
|
|
||||||
gpio_set(PORT_XCVR_ENABLE, PIN_XCVR_TXENABLE);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,8 +289,7 @@ void max2837_rx(void)
|
|||||||
max2837_regs_commit();
|
max2837_regs_commit();
|
||||||
|
|
||||||
#if !defined TEST
|
#if !defined TEST
|
||||||
gpio_clear(PORT_XCVR_ENABLE, PIN_XCVR_TXENABLE);
|
max2837_mode_rx();
|
||||||
gpio_set(PORT_XCVR_ENABLE, PIN_XCVR_RXENABLE);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,8 +299,7 @@ void max2837_stop(void)
|
|||||||
set_MAX2837_EN_SPI(0);
|
set_MAX2837_EN_SPI(0);
|
||||||
max2837_regs_commit();
|
max2837_regs_commit();
|
||||||
#if !defined TEST
|
#if !defined TEST
|
||||||
gpio_clear(PORT_XCVR_ENABLE,
|
max2837_mode_shutdown();
|
||||||
(PIN_XCVR_ENABLE | PIN_XCVR_RXENABLE | PIN_XCVR_TXENABLE));
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +37,11 @@ extern void max2837_regs_read(void);
|
|||||||
* provided routines for those operations. */
|
* provided routines for those operations. */
|
||||||
extern void max2837_regs_commit(void);
|
extern void max2837_regs_commit(void);
|
||||||
|
|
||||||
|
void max2837_mode_shutdown(void);
|
||||||
|
void max2837_mode_standby(void);
|
||||||
|
void max2837_mode_tx(void);
|
||||||
|
void max2837_mode_rx(void);
|
||||||
|
|
||||||
/* Turn on/off all chip functions. Does not control oscillator and CLKOUT */
|
/* Turn on/off all chip functions. Does not control oscillator and CLKOUT */
|
||||||
extern void max2837_start(void);
|
extern void max2837_start(void);
|
||||||
extern void max2837_stop(void);
|
extern void max2837_stop(void);
|
||||||
|
@ -115,7 +115,7 @@ bool set_freq(uint32_t freq_mhz, uint32_t freq_hz)
|
|||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
|
|
||||||
gpio_clear(PORT_XCVR_ENABLE, (PIN_XCVR_RXENABLE | PIN_XCVR_TXENABLE));
|
max2837_mode_standby();
|
||||||
if(freq_mhz >= MIN_LP_FREQ_MHZ)
|
if(freq_mhz >= MIN_LP_FREQ_MHZ)
|
||||||
{
|
{
|
||||||
if(freq_mhz < MAX_LP_FREQ_MHZ)
|
if(freq_mhz < MAX_LP_FREQ_MHZ)
|
||||||
@ -172,10 +172,9 @@ bool set_freq(uint32_t freq_mhz, uint32_t freq_hz)
|
|||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
if(transceiver_mode == TRANSCEIVER_MODE_RX)
|
if(transceiver_mode == TRANSCEIVER_MODE_RX)
|
||||||
gpio_set(PORT_XCVR_ENABLE, PIN_XCVR_RXENABLE);
|
max2837_mode_rx();
|
||||||
else if(transceiver_mode == TRANSCEIVER_MODE_TX)
|
else if(transceiver_mode == TRANSCEIVER_MODE_TX)
|
||||||
gpio_set(PORT_XCVR_ENABLE, PIN_XCVR_TXENABLE);
|
max2837_mode_tx();
|
||||||
|
|
||||||
freq_mhz_cache = freq_mhz;
|
freq_mhz_cache = freq_mhz;
|
||||||
freq_hz_cache = freq_hz;
|
freq_hz_cache = freq_hz;
|
||||||
return success;
|
return success;
|
||||||
|
Reference in New Issue
Block a user