mock: added mraa mock platform infra and GPIO implementation
Mock platform allows one to use mraa without having any real HW. This commit makes necessary foundational changes and implements GPIO functionality as well as adds respective tests. Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com> Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
committed by
Brendan Le Foll
parent
593fd0be54
commit
bcb6adc551
@@ -382,6 +382,10 @@ mraa_gpio_isr(mraa_gpio_context dev, mraa_gpio_edge_t mode, void (*fptr)(void*),
|
||||
return MRAA_ERROR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (IS_FUNC_DEFINED(dev, gpio_isr_replace)) {
|
||||
return dev->advance_func->gpio_isr_replace(dev, mode, fptr, args);
|
||||
}
|
||||
|
||||
// we only allow one isr per mraa_gpio_context
|
||||
if (dev->thread_id != 0) {
|
||||
return MRAA_ERROR_NO_RESOURCES;
|
||||
@@ -417,6 +421,10 @@ mraa_gpio_isr_exit(mraa_gpio_context dev)
|
||||
return MRAA_ERROR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (IS_FUNC_DEFINED(dev, gpio_isr_exit_replace)) {
|
||||
return dev->advance_func->gpio_isr_exit_replace(dev);
|
||||
}
|
||||
|
||||
// wasting our time, there is no isr to exit from
|
||||
if (dev->thread_id == 0 && dev->isr_value_fp == -1) {
|
||||
return ret;
|
||||
@@ -610,6 +618,10 @@ mraa_gpio_read_dir(mraa_gpio_context dev, mraa_gpio_dir_t *dir)
|
||||
return MRAA_ERROR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (IS_FUNC_DEFINED(dev, gpio_read_dir_replace)) {
|
||||
return dev->advance_func->gpio_read_dir_replace(dev, dir);
|
||||
}
|
||||
|
||||
snprintf(filepath, MAX_SIZE, SYSFS_CLASS_GPIO "/gpio%d/direction", dev->pin);
|
||||
fd = open(filepath, O_RDONLY);
|
||||
if (fd == -1) {
|
||||
|
||||
Reference in New Issue
Block a user