Skip to content
Snippets Groups Projects
Select Git revision
  • main default protected
  • cont-frb/moberg-review
  • v0.9.26
  • v0.9.25
  • v0.9.24
  • v0.9.23
  • v0.9.22
  • v0.9.21
  • v0.9.20
  • v0.9.19
  • v0.9.18
  • v0.9.17
  • v0.9.16
  • v0.9.15
  • v0.9.14
  • v0.9.13
  • v0.9.12
  • v0.9.11
  • v0.9.10
  • v0.9.9
  • v0.9.8
  • v0.9.7
22 results

moberg_channel.h

Blame
  • moberg_channel.h 2.17 KiB
    /*
        moberg_channel.h -- moberg channel interface
    
        Copyright (C) 2019 Anders Blomdell <anders.blomdell@gmail.com>
    
        This file is part of Moberg.
    
        Moberg is free software: you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation, either version 3 of the License, or
        (at your option) any later version.
    
        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.
    
        You should have received a copy of the GNU General Public License
        along with this program.  If not, see <https://www.gnu.org/licenses/>.
    */
        
    #ifndef __MOBERG_CHANNEL_H__
    #define __MOBERG_CHANNEL_H__
    
    #include <moberg.h>
    
    enum moberg_channel_kind {
        chan_ANALOGIN,
        chan_ANALOGOUT,
        chan_DIGITALIN,
        chan_DIGITALOUT,
        chan_ENCODERIN
    };
    
    struct moberg_channel {
      struct moberg_channel_context *context;
      
      /* Use-count of channel, when it reaches zero, channel will be free'd */
      int (*up)(struct moberg_channel *channel);
      int (*down)(struct moberg_channel *channel);
    
      /* Channel open and close */
      struct moberg_status (*open)(struct moberg_channel *channel);
      struct moberg_status (*close)(struct moberg_channel *channel);
    
      /* I/O operations */
      enum moberg_channel_kind kind;
      union moberg_channel_action {
        struct moberg_analog_in analog_in;
        struct moberg_analog_out analog_out;
        struct moberg_digital_in digital_in;
        struct moberg_digital_out digital_out;
        struct moberg_encoder_in encoder_in;
      } action;
    };
      
    struct moberg_channel_map {
      struct moberg_device *device;
      struct moberg_status (*map)(struct moberg_device* device,
                                  struct moberg_channel *channel);
    };
    
    struct moberg_channel_install {
      struct moberg *context;
      struct moberg_status (*channel)(struct moberg *context,
                                      int index,
                                      struct moberg_device* device,
                                      struct moberg_channel *channel);
    };
    
    #endif