52 #define PRINTF(...) printf(__VA_ARGS__) 57 #define PM_CMD_LINE_SET GPIO_SET_PIN(PM_CMD_PORT_BASE, PM_CMD_PIN_MASK) 58 #define PM_CMD_LINE_CLR GPIO_CLR_PIN(PM_CMD_PORT_BASE, PM_CMD_PIN_MASK) 59 #define PM_CMD_LINE_READ GPIO_READ_PIN(PM_CMD_PORT_BASE, PM_CMD_PIN_MASK) 60 #define PM_CMD_AS_OUTPUT GPIO_SET_OUTPUT(PM_CMD_PORT_BASE, PM_CMD_PIN_MASK) 61 #define PM_CMD_AS_INPUT GPIO_SET_INPUT(PM_CMD_PORT_BASE, PM_CMD_PIN_MASK) 63 #define PM_NUMBITS(X) (1 << ((X) - 1)) 65 static uint8_t initialized = 0;
66 static uint8_t getData = 0;
71 uint16_t error = PM_ERROR;
74 if(PM_CMD_LINE_READ) {
84 pm_send_cmd(uint8_t cmd)
88 PRINTF(
"PM: cmd %u\n", cmd);
96 for (i = PM_MAX_BITS; i > 0; i--) {
99 if (cmd & PM_NUMBITS(i)) {
102 else PM_CMD_LINE_CLR;
109 if((cmd == PM_CMD_GET_STATE) || (cmd == PM_CMD_GET_FW_VERSION)) {
112 for (i = PM_MAX_BITS; i > 0; i--) {
114 PM_CMD_LINE_READ ? (getData |= PM_NUMBITS(i)) : (getData &= ~PM_NUMBITS(i));
117 PRINTF(
"PM: getData = 0x%02X\n", getData);
150 if(pm_send_cmd(PM_CMD_PWR_ON) == PM_SUCCESS) {
152 PRINTF(
"PM: Initialized\n");
156 PRINTF(
"PM: Failed to initialize\n");
167 if(pm_send_cmd(PM_CMD_DTIMER_ON) == PM_SUCCESS) {
180 if(pm_send_cmd(PM_CMD_DTIMER_OFF) == PM_SUCCESS) {
193 if(pm_send_cmd(PM_CMD_GET_STATE) == PM_SUCCESS) {
195 PRINTF(
"PM: state %u\n", getData);
209 if (pm_send_cmd(PM_CMD_GET_FW_VERSION) == PM_SUCCESS) {
211 printf(
"PM: FW Version %u\n", getData);
int8_t pm_get_state(uint8_t *state)
Get the current state of the power management module.
Header file with register and macro declarations for the cc2538 GPIO module.
#define GPIO_CLR_PIN(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE low.
void clock_delay_usec(uint16_t dt)
Delay a given number of microseconds.
int8_t pm_init(void)
Initializes the Power Management driver.
int8_t pm_get_firmware_version(uint8_t *state)
Get the firmware version of the power management module.
#define GPIO_SOFTWARE_CONTROL(PORT_BASE, PIN_MASK)
Configure the pin to be software controlled with PIN_MASK of port with PORT_BASE. ...
Header file for the RE-Mote Power Management driver.
Header file for the real-time timer module.
#define GPIO_SET_OUTPUT(PORT_BASE, PIN_MASK)
Set pins with PIN_MASK of port with PORT_BASE to output.
int8_t pm_enable_timer(void)
Enable the shutdown mode, periodically driven by the Nano Timer.
int8_t pm_disable_timer(void)
Disable the Nano Timer.