Changeset efcfab9 in mainline


Ignore:
Timestamp:
2012-09-16T11:17:34Z (12 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3322d95
Parents:
69a13a4
Message:

rtc: Add support to the battery_status_get() request

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/time/cmos-rtc/cmos-rtc.c

    r69a13a4 refcfab9  
    8282static rtc_t *dev_rtc(ddf_dev_t *dev);
    8383static rtc_t *fun_rtc(ddf_fun_t *fun);
     84static int
     85rtc_battery_status_get(ddf_fun_t *fun, battery_status_t *status);
    8486static int  rtc_time_get(ddf_fun_t *fun, struct tm *t);
    8587static int  rtc_time_set(ddf_fun_t *fun, struct tm *t);
     
    120122/** Battery powered device interface */
    121123static battery_dev_ops_t rtc_battery_dev_ops = {
    122         .battery_status_get = NULL,
     124        .battery_status_get = rtc_battery_status_get,
    123125        .battery_charge_level_get = NULL,
    124126};
     
    503505}
    504506
     507/** Get the status of the real time clock battery
     508 *
     509 * @param fun    The RTC function
     510 * @param status The status of the battery
     511 *
     512 * @return       EOK on success or a negative error code
     513 */
     514static int
     515rtc_battery_status_get(ddf_fun_t *fun, battery_status_t *status)
     516{
     517        rtc_t *rtc = fun_rtc(fun);
     518        const bool batt_ok = rtc_register_read(rtc, RTC_STATUS_D) &
     519            RTC_D_BATTERY_OK;
     520
     521        *status = batt_ok ? BATTERY_OK : BATTERY_LOW;
     522
     523        return EOK;
     524}
     525
    505526/** The dev_add callback of the rtc driver
    506527 *
Note: See TracChangeset for help on using the changeset viewer.