taler-xotp_fw

xOTP generator firmware
Log | Files | Refs | Submodules | README

deviceInterface.h (2231B)


      1 /**
      2  * @file deviceInterface.h
      3  * @author Adrian STEINER (steia19@bfh.ch)
      4  * @brief device interface to get the current tick to poll events and to
      5  * shutdown the device The tick is used to poll in a desired frequency and the
      6  * shutdown is needed to move the device in a low energy part. All components
      7  * are set to power off before calling this function.
      8  * @version 0.1
      9  * @date 17-02-2025
     10  *
     11  * @copyright (C) 2025 Adrian STEINER
     12  * This program is free software: you can redistribute it and/or modify
     13  * it under the terms of the GNU General Public License as published by
     14  * the Free Software Foundation, either version 3 of the License, or
     15  * (at your option) any later version.
     16  *
     17  * This program is distributed in the hope that it will be useful,
     18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     20  * GNU General Public License for more details.
     21  *
     22  * You should have received a copy of the GNU General Public License
     23  * along with this program.  If not, see <https: //www.gnu.org/licenses/>.
     24  *
     25  */
     26 
     27 #ifndef DEVICE_INTERFACE_H
     28 #define DEVICE_INTERFACE_H
     29 
     30 #ifdef __cplusplus
     31 extern "C" {
     32 #endif
     33 
     34 #include <stdint.h>
     35 
     36 /**
     37  * @brief Device shutdown callback
     38  *
     39  */
     40 typedef void (*deviceShutdownCB)(void);
     41 
     42 /**
     43  * @brief Device getTick callback
     44  *
     45  */
     46 typedef uint32_t (*deviceGetTickCB)(void);
     47 
     48 /**
     49  * @brief Device interface handler
     50  *
     51  */
     52 typedef struct {
     53   deviceGetTickCB getTick; ///< Get the current system tick for polling
     54   deviceShutdownCB
     55       shutdown; ///< Moves the device in low energy consumption mode, expect to
     56                 ///< stay in this function during shutdown
     57 } deviceInterface;
     58 
     59 /**
     60  * @brief Initialise the device interface structure
     61  *
     62  * @param interfaceHandler The deviceInterface structure to initialise
     63  * @param getTickCB  getTick callback function
     64  * @param shutdownCB shutdown callback function
     65  * @return uint8_t EXIT_SUCCESS in success, EXIT_FAILURE otherwise
     66  */
     67 uint8_t device_initInterface(deviceInterface *interfaceHandler,
     68                              deviceGetTickCB getTickCB,
     69                              deviceShutdownCB shutdownCB);
     70 
     71 #ifdef __cplusplus
     72 }
     73 #endif
     74 
     75 #endif /* DEVICEINTERFACE_H*/