From 8ffa245080e38509783169e7f7446ebcbecea9d7 Mon Sep 17 00:00:00 2001 From: Nick Van Doorn Date: Tue, 5 Dec 2017 00:47:09 -0800 Subject: Add intial readme --- README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..2326cbe --- /dev/null +++ b/README.md @@ -0,0 +1,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 (); +``` -- cgit v1.2.3