Changeset 5902:b82b16021032 in roaraudio for include


Ignore:
Timestamp:
04/21/13 00:03:55 (11 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:
  • Added GPIO service.
  • Added GPIO driver: piface.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/services.h

    r5887 r5902  
    212212}; 
    213213 
     214// GPIO/Sensors: 
     215#define ROAR_SERVICE_GPIO_NAME "gpio" 
     216#define ROAR_SERVICE_GPIO_ABI  "1.0beta10-pr0" 
     217 
     218#define ROAR_SERVICE_GPIO_FINPUT    ((uint_least32_t)0x00000001UL) 
     219#define ROAR_SERVICE_GPIO_FOUTPUT   ((uint_least32_t)0x00000002UL) 
     220#define ROAR_SERVICE_GPIO_FPULLDOWN ((uint_least32_t)0x00000004UL) 
     221#define ROAR_SERVICE_GPIO_FPULLUP   ((uint_least32_t)0x00000008UL) 
     222#define ROAR_SERVICE_GPIO_FCACHED   ((uint_least32_t)0x00000010UL) 
     223 
     224enum roar_service_gpio_type { 
     225 ROAR_SERVICE_GPIO_TERROR = -1, 
     226 ROAR_SERVICE_GPIO_TUNKNOWN = 0, 
     227 ROAR_SERVICE_GPIO_TINT, 
     228 ROAR_SERVICE_GPIO_TENUM, 
     229 ROAR_SERVICE_GPIO_TBOOL, 
     230 ROAR_SERVICE_GPIO_TTRISTATE, 
     231 ROAR_SERVICE_GPIO_TFLOAT 
     232}; 
     233 
     234enum roar_service_gpio_state { 
     235 ROAR_SERVICE_GPIO_SERROR = -1, 
     236 ROAR_SERVICE_GPIO_SUNKNOWN = 0, 
     237 ROAR_SERVICE_GPIO_SFREE, 
     238 ROAR_SERVICE_GPIO_SUNINITED, 
     239 ROAR_SERVICE_GPIO_SREADY, 
     240 ROAR_SERVICE_GPIO_SBUSY, 
     241 ROAR_SERVICE_GPIO_SDISCONNECTED, 
     242 ROAR_SERVICE_GPIO_SDISABLED, 
     243 ROAR_SERVICE_GPIO_SINERROR 
     244}; 
     245 
     246struct roar_service_gpio_port { 
     247 int id; 
     248 const char * name; 
     249 uint_least32_t mode; 
     250 const char * unit; 
     251 enum roar_service_gpio_type type; 
     252 enum roar_service_gpio_state state; 
     253 int irange_min; 
     254 int irange_max; 
     255 double frange_min; 
     256 double frange_max; 
     257}; 
     258 
     259struct roar_service_gpio { 
     260 // get list of gpio IDs. 
     261 // buffer is passed as ids, buffer size (in elements) is passed as len. 
     262 // returns the number of elements stored in ids or -1 on error. 
     263 ssize_t (*list)(int * ids, size_t len); 
     264 // get the number of gpios. See also comments above on what. 
     265 ssize_t (*num)(enum roar_service_num what); 
     266 // get a gpio by ID. The object returned is a copy and must not be motified or freed. 
     267 int (*get)(int id, struct roar_service_gpio_port * port); 
     268 
     269 // Sets up ports. 
     270 // the controler should set mode and state of port to given target mode and state. 
     271 // If id is given as -1 this is about the controler. mode MUST NOT contain any 
     272 // flags beside ROAR_SERVICE_GPIO_FCACHED. If ROAR_SERVICE_GPIO_FCACHED 
     273 // is set it is applied all ports. 
     274 int (*setup)(int id, uint_least32_t mode, enum roar_service_gpio_state state); 
     275 
     276 // get value of port (input or output) as int or float. 
     277 int (*get_int)(int id); 
     278 double (*get_float)(int id); 
     279 
     280 // set value of output (as int or float). 
     281 int (*set_int)(int id, int val); 
     282 int (*set_float)(int id, double val); 
     283 
     284 // convert the value val as returned by the port to the base unit of the port. 
     285 // if rev is set converst from the base unit to the value as used by the port. 
     286 int (*convert_int)(int id, int val, int rev); 
     287 double (*convert_float)(int id, double val, int rev); 
     288}; 
     289 
    214290#endif 
    215291 
Note: See TracChangeset for help on using the changeset viewer.