summaryrefslogtreecommitdiff
path: root/README.md
blob: 2326cbe439922f8adfa1ac21b88adb5f4a7cdb5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# legato-util

Small collection of helper functions required by some of our open source code

## API

### File I/O

Functions to handle boilerplate when reading and writing from files.

```C
le_result_t readFromFile (const char *path, void *value,
  int (*scanCallback) (FILE *f, void *val));
int scanIntCallback (FILE *f, void *value);
int scanDoubleCallback (FILE *f, void *value);
le_result_t ioutil_readIntFromFile (const char *path, int *value);
le_result_t ioutil_readDoubleFromFile (const char *filePath, double *value);
le_result_t ioutil_writeToFile (const char *path, void *value, size_t size, size_t count);

```

### GPIO

Functions to manipulate sysfs GPIO.

```C
void getGpioPath (char *outputStr, int pin, char *subDir);
le_result_t gpio_exportPin (int pin);
le_result_t gpio_unexportPin (int pin);
le_result_t gpio_setDirection (int pin, char *direction);
le_result_t gpio_setInput (int pin);
le_result_t gpio_setOutput (int pin);
le_result_t gpio_setActiveState (int pin, bool isActiveLow);
le_result_t gpio_isActive (int pin, bool *isActive);
le_result_t gpio_setValue (int pin, bool state);
le_result_t gpio_setLow (int pin);
le_result_t gpio_setHigh (int pin);

```

### Timing

Functions to help with sample timing. Could potentially be replaced with system calls

```C
// TODO give these a quasi "namespace"
void delayMicro (unsigned long microsecs);
void delayMilli (unsigned long millisecs);
long getTimeMicrosecs ();
```