cash2ecash

cash2ecash: cash acceptor that issues digital cash (experimental)
Log | Files | Refs | README | LICENSE

gpiod_wrapper.h (2264B)


      1 /*
      2   This file is part of TALER cash2ecash
      3   Copyright (C) 2026 GNUnet e.V.
      4 
      5   This program is free software: you can redistribute it and/or modify
      6   it under the terms of the GNU Affero General Public License as
      7   published by the Free Software Foundation, either version 3 of the
      8   License, or (at your option) any later version.
      9 
     10   This program is distributed in the hope that it will be useful,
     11   but WITHOUT ANY WARRANTY; without even the implied warranty of
     12   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14   GNU Affero General Public License for more details.
     15 
     16   You should have received a copy of the GNU Affero General Public License
     17   along with this program.  If not, see <https://www.gnu.org/licenses/>.
     18 */
     19 
     20 /**
     21  * @file gpiod_wrapper.h
     22  * @brief controll gpio pins
     23  * @author Reto Tellenbach
     24  */
     25 
     26 
     27 #ifndef GPIOD_WRAPPER_H
     28 #define GPIOD_WRAPPER_H
     29 
     30 /* Use GPIO to enable coin insert*/
     31 //heavily inspired from gpiod source example of Gent Gibson toggle_line_value.c
     32 
     33 #include <gpiod.h>
     34 #include <stdlib.h>
     35 #include <stdio.h>
     36 
     37 /**
     38  * @param name
     39  * @return
     40  */
     41 struct gpiod_chip *
     42 gpiod_chip_open_by_name(const char *name);
     43 
     44 /**
     45  * Init settings for line-request
     46  * @param direction 
     47  * @param bias
     48  * @param drive
     49  * @param active_los
     50  * @return NULL on errors
     51  */
     52 struct gpiod_line_settings*
     53 gpiod_make_settings(enum gpiod_line_direction direction,
     54                     enum gpiod_line_bias bias,
     55                     enum gpiod_line_drive drive,
     56                     enum gpiod_line_drive active_low);
     57 
     58 /**
     59  * 
     60  * @param chipname
     61  * @param linename
     62  * @param settings
     63  * @return must release line request with gpiod_line_request_release()
     64  */
     65 struct gpiod_line_request*
     66 gpiod_make_line_request_by_name(const char* chipname,
     67                                 const char* linename,
     68                                 struct gpiod_line_settings* settings);
     69 
     70 /**
     71  * 
     72  * @param chip_path
     73  * @param line_offset
     74  * @param settings
     75  * @return 
     76  */                          
     77 struct gpiod_line_request* 
     78 gpiod_make_line_request(const char* chip_path,
     79                         const unsigned int line_offset,
     80                         struct gpiod_line_settings* settings);
     81 
     82 #endif