cash2ecash

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

gpiod_wrapper.h (2173B)


      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 #ifndef GPIOD_WRAPPER_H
     21 #define GPIOD_WRAPPER_H
     22 
     23 /* Use GPIO to enable coin insert*/
     24 //heavily inspired from gpiod source example of Gent Gibson toggle_line_value.c
     25 
     26 #include <gpiod.h>
     27 #include <stdlib.h>
     28 #include <stdio.h>
     29 
     30 /**
     31  * @param name
     32  * @return
     33  */
     34 struct gpiod_chip *
     35 gpiod_chip_open_by_name(const char *name);
     36 
     37 /**
     38  * Init settings for line-request
     39  * @param direction 
     40  * @param bias
     41  * @param drive
     42  * @param active_los
     43  * @return NULL on errors
     44  */
     45 struct gpiod_line_settings*
     46 gpiod_make_settings(enum gpiod_line_direction direction,
     47                     enum gpiod_line_bias bias,
     48                     enum gpiod_line_drive drive,
     49                     enum gpiod_line_drive active_low);
     50 
     51 /**
     52  * 
     53  * @param chipname
     54  * @param linename
     55  * @param settings
     56  * @return must release line request with gpiod_line_request_release()
     57  */
     58 struct gpiod_line_request*
     59 gpiod_make_line_request_by_name(const char* chipname,
     60                                 const char* linename,
     61                                 struct gpiod_line_settings* settings);
     62 
     63 /**
     64  * 
     65  * @param chip_path
     66  * @param line_offset
     67  * @param settings
     68  * @return 
     69  */                          
     70 struct gpiod_line_request* 
     71 gpiod_make_line_request(const char* chip_path,
     72                         const unsigned int line_offset,
     73                         struct gpiod_line_settings* settings);
     74 
     75 #endif