Add MAX2837 mode set/get functions.

This commit is contained in:
Jared Boone
2013-09-06 22:29:57 -07:00
parent a5c0b5deeb
commit a367f84d15
2 changed files with 47 additions and 0 deletions

View File

@ -260,6 +260,43 @@ void max2837_mode_rx(void) {
(PIN_XCVR_ENABLE | PIN_XCVR_RXENABLE)); (PIN_XCVR_ENABLE | PIN_XCVR_RXENABLE));
} }
max2837_mode_t max2837_mode(void) {
if( gpio_get(PORT_XCVR_ENABLE, PIN_XCVR_ENABLE) ) {
if( gpio_get(PORT_XCVR_ENABLE, PIN_XCVR_TXENABLE) ) {
return MAX2837_MODE_TX;
} else if( gpio_get(PORT_XCVR_ENABLE, PIN_XCVR_RXENABLE) ) {
return MAX2837_MODE_RX;
} else {
return MAX2837_MODE_STANDBY;
}
} else {
return MAX2837_MODE_SHUTDOWN;
}
}
void max2837_set_mode(const max2837_mode_t new_mode) {
switch(new_mode) {
case MAX2837_MODE_SHUTDOWN:
max2837_mode_shutdown();
break;
case MAX2837_MODE_STANDBY:
max2837_mode_standby();
break;
case MAX2837_MODE_TX:
max2837_mode_tx();
break;
case MAX2837_MODE_RX:
max2837_mode_rx();
break;
default:
break;
}
}
void max2837_start(void) void max2837_start(void)
{ {
LOG("# max2837_start\n"); LOG("# max2837_start\n");

View File

@ -37,11 +37,21 @@ 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);
typedef enum {
MAX2837_MODE_SHUTDOWN,
MAX2837_MODE_STANDBY,
MAX2837_MODE_TX,
MAX2837_MODE_RX
} max2837_mode_t;
void max2837_mode_shutdown(void); void max2837_mode_shutdown(void);
void max2837_mode_standby(void); void max2837_mode_standby(void);
void max2837_mode_tx(void); void max2837_mode_tx(void);
void max2837_mode_rx(void); void max2837_mode_rx(void);
max2837_mode_t max2837_mode(void);
void max2837_set_mode(const max2837_mode_t new_mode);
/* 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);