37 lines
788 B
C
37 lines
788 B
C
#include "mgos.h"
|
|
#include "mgos_mcp23xxx.h"
|
|
#include "tests_autogen.h"
|
|
|
|
uint32_t test_mcp23xxx_period_ms = 100;
|
|
bool test_mcp23xxx_enabled = true;
|
|
|
|
static struct mgos_mcp23xxx *s_dev;
|
|
|
|
bool test_mcp23xxx_create(void) {
|
|
uint8_t i;
|
|
s_dev = mgos_mcp23017_create(mgos_i2c_get_global(), 0x20, -1);
|
|
if (!s_dev) return NULL;
|
|
|
|
for (i=0; i<8; i++)
|
|
mgos_mcp23xxx_gpio_setup_input(s_dev, i, MGOS_GPIO_PULL_UP);
|
|
|
|
for (i=8; i<16; i++)
|
|
mgos_mcp23xxx_gpio_set_mode(s_dev, i, MGOS_GPIO_MODE_OUTPUT);
|
|
return true;
|
|
}
|
|
|
|
bool test_mcp23xxx_run(void) {
|
|
uint8_t i;
|
|
mgos_mcp23xxx_gpio_read(s_dev, 0);
|
|
|
|
for (i=8; i<16; i++)
|
|
mgos_mcp23xxx_gpio_write(s_dev, i, random()%2);
|
|
|
|
return true;
|
|
}
|
|
|
|
bool test_mcp23xxx_destroy(void) {
|
|
mgos_mcp23xxx_destroy(&s_dev);
|
|
return true;
|
|
}
|