Contiki-NG
Files

Driver control the power management of the RE-Mote rev B platform. More...

Files

file  power-mgmt.h
 Header file for the RE-Mote Power Management driver.
 
file  power-mgmt.h
 Header file for the RE-Mote Power Management driver.
 

Power management controller

#define PWR_MNGMT_ADDR   0x7F
 Power Management slave address.
 

Power Management return values

#define PM_SUCCESS   0
 
#define PM_ERROR   (-1)
 

Power Management Registers

enum  pm_registers_t
 

Power Management status and masks

enum  pm_charge_current_states
 
#define PM_ENABLE   1 /* Pin status on */
 
#define PM_DISABLE   0 /* Pin status off */
 
#define BATT_CHARGED_VAL   0
 
#define BATT_UNCHARGED_VAL   1
 
#define PM_REFERENCE_INTERNAL   0
 
#define PM_REFERENCE_EXTERNAL   1
 
#define PM_SOFT_SHTDN_INTERVAL   5720
 
#define PM_SOFT_SHTDN_0_5_SEC   8
 
#define PM_SOFT_SHTDN_1_SEC   17
 
#define PM_SOFT_SHTDN_1_4_SEC   25
 
#define PM_SOFT_SHTDN_5_7_SEC   100
 
#define PM_SOFT_SHTDN_30_SEC   524
 
#define PM_SOFT_SHTDN_1_MIN   1049
 
#define PM_SOFT_SHTDN_5_MIN   5245
 
#define PM_SOFT_SHTDN_10_MIN   10490
 
#define PM_SOFT_SHTDN_1_H   62937
 
#define PM_SOFT_SHTDN_24_H   1510490
 
#define PM_SOFT_SHTDN_7_DAYS   10573427
 
#define PM_SOFT_SHTDN_14_DAYS   21146853
 
#define PM_SOFT_SHTDN_28_DAYS   42383709
 
#define PM_SOFT_SHTDN_TEST   0xCC00FFEE
 
#define PM_VBAT_MULT   (float)-181.9
 
#define PM_VBAT_OFF   (float)1294.72
 

Power Management functions

int8_t pm_enable (void)
 Initializes the Power Management driver. More...
 
int8_t pm_reset_system (void)
 Restarts the on-board low-power PIC, provoking a board reset. More...
 
int8_t pm_set_timeout (uint32_t time)
 Configure Internal Timeout for Hard and Soft shutdown modes. More...
 
uint32_t pm_get_timeout (void)
 Gets the current timeout value configured in power management module. More...
 
uint32_t pm_get_num_cycles (void)
 Gets current cycles. More...
 
int8_t pm_shutdown_now (uint8_t type)
 Disconnects the board battery and enter shutdown mode PM_SOFT/HARD_SLEEP_CONFIG. More...
 
int8_t pm_get_voltage (uint16_t *state)
 Reads the voltage of the external battery if connected to VIN pin. More...
 
int8_t pm_get_fw_ver (uint8_t *fwver)
 Gets the current firmware version of power management module. More...
 

Detailed Description

Driver control the power management of the RE-Mote rev B platform.

RE-Mote power management functions.

This driver is an I2C communication with external power manager chip that controls few functions of the board. Note the driver will work if powered both over USB and external battery, but the shutdown mode will only be actually working with external battery

Author
Aitor Mejias ameji.nosp@m.as@z.nosp@m.olert.nosp@m.ia.c.nosp@m.om Antonio Lignan alina.nosp@m.n@zo.nosp@m.lerti.nosp@m.a.co.nosp@m.m

Function Documentation

◆ pm_enable()

int8_t pm_enable ( void  )

Initializes the Power Management driver.

Returns
PM_SUCCESS if initialized, else PM_ERROR

Definition at line 74 of file power-mgmt.c.

References GPIO_SOFTWARE_CONTROL.

◆ pm_get_fw_ver()

int8_t pm_get_fw_ver ( uint8_t *  fwver)

Gets the current firmware version of power management module.

Parameters
fwverpointer to get the value of firmware
Returns
PM_SUCCESS if success, else PM_ERROR

Definition at line 280 of file power-mgmt.c.

◆ pm_get_num_cycles()

uint32_t pm_get_num_cycles ( void  )

Gets current cycles.

incremented each shutdown cycle

Returns
Number of shutdown cycles

Definition at line 203 of file power-mgmt.c.

◆ pm_get_timeout()

uint32_t pm_get_timeout ( void  )

Gets the current timeout value configured in power management module.

Returns
value with timeout.

Definition at line 180 of file power-mgmt.c.

◆ pm_get_voltage()

int8_t pm_get_voltage ( uint16_t *  state)

Reads the voltage of the external battery if connected to VIN pin.

Parameters
statepointer to get the voltage value
Returns
PM_SUCCESS if success, else PM_ERROR

Definition at line 250 of file power-mgmt.c.

◆ pm_reset_system()

int8_t pm_reset_system ( void  )

Restarts the on-board low-power PIC, provoking a board reset.

Returns
PM_SUCCESS if success, else PM_ERROR

Definition at line 128 of file power-mgmt.c.

◆ pm_set_timeout()

int8_t pm_set_timeout ( uint32_t  time)

Configure Internal Timeout for Hard and Soft shutdown modes.

In Hard mode, any positive value counts as internal security timeout. In Soft mode, this value is needed.

Parameters
timevalue as timeout maximum
Returns
PM_SUCCESS if success, else PM_ERROR

Definition at line 149 of file power-mgmt.c.

◆ pm_shutdown_now()

int8_t pm_shutdown_now ( uint8_t  type)

Disconnects the board battery and enter shutdown mode PM_SOFT/HARD_SLEEP_CONFIG.

Parameters
typeHard shutdown (RTCC based) or soft (PIC-governed)
Returns
Value byte of the register requested.

Definition at line 223 of file power-mgmt.c.