Contiki-NG
Loading...
Searching...
No Matches

Files

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

Functions

static int pm_write_byte (uint8_t reg, uint8_t val)
 
static int pm_read_byte (uint8_t reg, uint8_t *val, uint8_t len)
 

Power Management functions

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

Power management controller

#define PWR_MNGMT_ADDR   0x7F
 Power Management slave address.
 

Detailed Description

RE-Mote power management functions.

Driver control the power management of the RE-Mote rev B platform. 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, and i2c_init().

◆ 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.

References pm_read_byte().

◆ pm_get_num_cycles()

uint32_t pm_get_num_cycles ( void )

Gets current cycles.

incremented each shutdown cycle

Returns
Number of shutdown cycles

< Power Management slave address

< Power Management slave address

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

References i2c_burst_receive(), i2c_single_send(), and PWR_MNGMT_ADDR.

◆ pm_get_timeout()

uint32_t pm_get_timeout ( void )

Gets the current timeout value configured in power management module.

Returns
value with timeout.

< Power Management slave address

< Power Management slave address

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

References i2c_burst_receive(), i2c_single_send(), and PWR_MNGMT_ADDR.

◆ 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

< Power Management slave address

< Power Management slave address

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

References i2c_burst_receive(), i2c_single_send(), and PWR_MNGMT_ADDR.

◆ pm_read_byte()

static int pm_read_byte ( uint8_t reg,
uint8_t * val,
uint8_t len )
static

< Power Management slave address

< Power Management slave address

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

References i2c_burst_receive(), i2c_single_send(), and PWR_MNGMT_ADDR.

Referenced by pm_get_fw_ver().

◆ 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

< Power Management slave address

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

References clock_delay_usec(), i2c_burst_send(), and PWR_MNGMT_ADDR.

◆ 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

< Power Management slave address

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

References i2c_burst_send(), and PWR_MNGMT_ADDR.

◆ 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.

References pm_write_byte().

◆ pm_write_byte()

static int pm_write_byte ( uint8_t reg,
uint8_t val )
static

< Power Management slave address

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

References i2c_burst_send(), and PWR_MNGMT_ADDR.

Referenced by pm_shutdown_now().