Ignore:
Timestamp:
2013-12-31T19:44:11Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7858acbf
Parents:
7f620e8
Message:

libc,libdrv: Move battery iface to libdrv.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/remote_battery_dev.c

    r7f620e8 r26c03dbd  
    3636#include <errno.h>
    3737#include <ops/battery_dev.h>
    38 #include <device/battery_dev.h>
     38#include <battery_iface.h>
    3939#include <ddf/driver.h>
    4040#include <macros.h>
     41
     42/** Read the current battery status from the device
     43 *
     44 * @param sess     Session of the device
     45 * @param status   Current status of the battery
     46 *
     47 * @return         EOK on success or a negative error code
     48 */
     49int
     50battery_status_get(async_sess_t *sess, battery_status_t *batt_status)
     51{
     52        sysarg_t status;
     53
     54        async_exch_t *exch = async_exchange_begin(sess);
     55
     56        int const rc = async_req_1_1(exch, DEV_IFACE_ID(BATTERY_DEV_IFACE),
     57            BATTERY_STATUS_GET, &status);
     58
     59        async_exchange_end(exch);
     60
     61        if (rc == EOK)
     62                *batt_status = (battery_status_t) status;
     63
     64        return rc;
     65}
     66
     67/** Read the current battery charge level from the device
     68 *
     69 * @param sess     Session of the device
     70 * @param level    Battery charge level (0 - 100)
     71 *
     72 * @return         EOK on success or a negative error code
     73 */
     74int
     75battery_charge_level_get(async_sess_t *sess, int *level)
     76{
     77        sysarg_t charge_level;
     78
     79        async_exch_t *exch = async_exchange_begin(sess);
     80
     81        int const rc = async_req_1_1(exch, DEV_IFACE_ID(BATTERY_DEV_IFACE),
     82            BATTERY_CHARGE_LEVEL_GET, &charge_level);
     83
     84        async_exchange_end(exch);
     85
     86        if (rc == EOK)
     87                *level = (int) charge_level;
     88
     89        return rc;
     90}
    4191
    4292static void remote_battery_status_get(ddf_fun_t *, void *, ipc_callid_t,
Note: See TracChangeset for help on using the changeset viewer.