MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / xs_digital_static_read

Function xs_digital_static_read

modules/pins/digital/digital.c:146–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146void xs_digital_static_read(xsMachine *the)
147{
148 int pin = xsmcToInteger(xsArg(0));
149 uint8_t value;
150 modGPIOConfigurationRecord config;
151
152 if (modGPIOInit(&config, NULL, pin, kModGPIOInput))
153 xsUnknownError("can't init pin");
154
155 value = modGPIORead(&config);
156 modGPIOUninit(&config);
157
158 if (kModGPIOReadError == value)
159 xsUnknownError("can't read pin");
160
161 xsmcSetInteger(xsResult, value);
162}
163
164void xs_digital_static_write(xsMachine *the)
165{

Callers

nothing calls this directly

Calls 3

modGPIOInitFunction · 0.50
modGPIOReadFunction · 0.50
modGPIOUninitFunction · 0.50

Tested by

no test coverage detected