FlexBook / Mbed 2 deprecated FlexBook171204a

Dependencies:   SDFileSystem app epson mbed msp430 pl tests

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers epdpsu.h Source File

epdpsu.h

00001 /*
00002   Plastic Logic EPD project on MSP430
00003 
00004   Copyright (C) 2014 Plastic Logic Limited
00005 
00006   This program is free software: you can redistribute it and/or modify
00007   it under the terms of the GNU General Public License as published by
00008   the Free Software Foundation, either version 3 of the License, or
00009   (at your option) any later version.
00010 
00011   This program is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014   GNU General Public License for more details.
00015 
00016   You should have received a copy of the GNU General Public License
00017   along with this program.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 /*
00020  * epdpsu.h -- EPD PSU interface abstraction layer
00021  *
00022  * Authors:
00023  *   Guillaume Tucker <guillaume.tucker@plasticlogic.com>
00024  *
00025  */
00026 
00027 #ifndef INCLUDE_PL_EPDPSU_H
00028 #define INCLUDE_PL_EPDPSU_H 1
00029 
00030 /**
00031    @file pl/epdpsu.h
00032 
00033    Abstract interface and generic implementation to the EPD PSU
00034 */
00035 
00036 /** Set to 1 to enable stub  */
00037 #define PL_EPDPSU_STUB 0
00038 
00039 struct pl_epdc;
00040 
00041 /** Interface */
00042 struct pl_epdpsu {
00043     /**
00044        turn the EPD PSU on
00045        @param[in] psu pl_epdpsu instance
00046        @return -1 if an error occured, 0 otherwise
00047      */
00048     int (*on)(struct pl_epdpsu *psu);
00049 
00050     /**
00051        turn the EPD PSU off
00052        @param[in] psu pl_epdpsu instance
00053        @return -1 if an error occured, 0 otherwise
00054      */
00055     int (*off)(struct pl_epdpsu *psu);
00056 
00057     int state;            /**< current power state (1=on, 0=off) */
00058     void *data;           /**< private data for the implementation */
00059 };
00060 
00061 /** Generic GPIO-based implementation */
00062 struct pl_epdpsu_gpio {
00063     struct pl_gpio *gpio; /**< pl_gpio instance to control the GPIOs */
00064     unsigned hv_en;       /**< GPIO number to turn the power on/off */
00065     unsigned com_close;   /**< GPIO number to close the COM switch */
00066     unsigned pok;         /**< GPIO number to read Power OK */
00067     unsigned flt;         /**< GPIO number to read Power FLT status */
00068     unsigned timeout_ms;  /**< Maximum time in ms to wait for POK */
00069     unsigned on_delay_ms; /**< Delay after turning the power on */
00070     unsigned off_delay_ms;/**< Delay after turning the power off */
00071 };
00072 
00073 /**
00074    Initialise a pl_epdpsu instance with generic GPIO-based implamentation.
00075 
00076    Both the pl_epdpsu and pl_epdpsu_gpio structures need to be managed by the
00077    caller, so they can be either on the heap or the caller's stack.
00078 
00079    @param[in] psu pl_epdpsu instance
00080    @param[in] p pl_epdpsu_gpio instance
00081    @return -1 if an error occured, 0 otherwise
00082 */
00083 extern int pl_epdpsu_gpio_init(struct pl_epdpsu *psu,
00084                    struct pl_epdpsu_gpio *p);
00085 
00086 /**
00087    Initialise a pl_epdpsu instance to use the generic epdc->set_epd_power
00088 
00089    @param[in] psu pl_epdpsu instance
00090    @param[in] epdc pl_epdc instance
00091    @return -1 if an error occured, 0 otherwise
00092  */
00093 extern int pl_epdpsu_epdc_init(struct pl_epdpsu *psu, struct pl_epdc *epdc);
00094 
00095 #if PL_EPDPSU_STUB
00096 /** Initialise an pl_epdpsu instance with stub implementation.
00097 
00098     This is especially useful with automatic power control or for debugging.
00099 
00100     @param[in] psu pl_epdpsu instance
00101     @return 0 unless something went really wrong
00102 */
00103 extern int pl_epdpsu_stub_init(struct pl_epdpsu *psu);
00104 #endif
00105 
00106 #endif /* INCLUDE_PL_EPDPSU_H */