Handle GPIO command from host.
199{
202 return;
203 }
204
207 uint8_t response[8] = {0};
208 uint8_t response_len = 0;
209
211
214
216 uint8_t level = cmd->
payload[0];
221 }
222 } else {
224 }
225 break;
226
228
229 {
230 uint8_t level = 0;
233 response[0] = level;
234 response_len = 1;
235 }
236 }
237 break;
238
240
243
244 uint8_t level = 0;
246 response[0] = level;
247 response_len = 1;
248 }
249 break;
250
252
254 uint32_t args[1] = { cmd->
payload[0] };
257 args, 1);
258 } else {
260 }
261 break;
262
264
266 uint32_t frequency = (cmd->
payload[0]) |
270 uint32_t args[1] = { frequency };
273 args, 1);
274 } else {
276 }
277 break;
278
280
282 bool enable = (cmd->
payload[0] != 0);
284 } else {
286 }
287 break;
288
290
292 break;
293
295
296 {
300
301 response[0] = config.
mode;
302 response[1] = config.
pull;
306 response_len = 5;
307 }
308 }
309 break;
310
312
313 {
317
318 response[0] =
state.current_level;
319 response[1] =
state.interrupt_registered ? 1 : 0;
320 response[2] =
state.intr_type;
321 response_len = 3;
322 }
323 }
324 break;
325
326 default:
329 break;
330 }
331
332
334}
@ MESHX_INVALID_ARG
Definition meshx_err.h:46
meshx_err_t meshx_gpio_set_level(uint8_t logical_pin, uint8_t level)
Set GPIO pin level.
Definition meshx_gpio.c:322
meshx_err_t meshx_gpio_execute_function(uint8_t logical_pin, meshx_io_function_t function, const uint32_t *args, uint8_t arg_count)
Execute IO function on GPIO pin.
Definition meshx_gpio.c:616
meshx_err_t meshx_gpio_get_level(uint8_t logical_pin, uint8_t *level)
Get GPIO pin level.
Definition meshx_gpio.c:392
meshx_err_t meshx_gpio_intr_enable(uint8_t logical_pin, bool enable)
Enable/disable GPIO interrupt.
Definition meshx_gpio.c:591
meshx_err_t meshx_gpio_get_pin_state(uint8_t logical_pin, meshx_gpio_pin_state_t *state)
Get pin runtime state.
Definition meshx_gpio.c:689
meshx_err_t meshx_gpio_get_pin_config(uint8_t logical_pin, meshx_gpio_pin_config_t *config)
Get pin configuration.
Definition meshx_gpio.c:663
meshx_err_t meshx_gpio_toggle(uint8_t logical_pin)
Toggle GPIO pin level.
Definition meshx_gpio.c:453
@ MESHX_IO_FUNCTION_SET_PWM_FREQUENCY
Definition meshx_gpio.h:68
@ MESHX_IO_FUNCTION_SET_PWM_DUTY
Definition meshx_gpio.h:67
#define MESHX_LOGW(module_id, format,...)
Definition meshx_log.h:120
uint8_t state
Definition meshx_serial.c:39
meshx_err_t mxsp_send_gpio_rsp(uint8_t cmd, uint8_t logical_pin, uint8_t status, const uint8_t *response, uint8_t response_len)
Send GPIO response via MXSP.
Definition meshx_serial.c:153
@ MXSP_GPIO_CMD_SET_PWM_FREQ
Definition meshx_serial.h:58
@ MXSP_GPIO_CMD_GET_CONFIG
Definition meshx_serial.h:61
@ MXSP_GPIO_CMD_GET_STATE
Definition meshx_serial.h:62
@ MXSP_GPIO_CMD_INTR_ENABLE
Definition meshx_serial.h:59
@ MXSP_GPIO_CMD_TOGGLE
Definition meshx_serial.h:56
@ MXSP_GPIO_CMD_SET_LEVEL
Definition meshx_serial.h:54
@ MXSP_GPIO_CMD_GET_LEVEL
Definition meshx_serial.h:55
@ MXSP_GPIO_CMD_INTR_DISABLE
Definition meshx_serial.h:60
@ MXSP_GPIO_CMD_SET_PWM_DUTY
Definition meshx_serial.h:57
GPIO Pin Configuration Structure.
Definition meshx_gpio_types.h:51
uint8_t mode
Definition meshx_gpio_types.h:54
uint8_t drive_strength
Definition meshx_gpio_types.h:56
uint8_t initial_level
Definition meshx_gpio_types.h:57
bool signal_inversion
Definition meshx_gpio_types.h:58
uint8_t pull
Definition meshx_gpio_types.h:55
GPIO Pin State Structure.
Definition meshx_gpio_types.h:91
GPIO Command Payload (Host -> Engine).
Definition meshx_serial.h:79
uint8_t cmd
Definition meshx_serial.h:80
uint8_t logical_pin
Definition meshx_serial.h:81
uint8_t payload[8]
Definition meshx_serial.h:84
uint8_t payload_len
Definition meshx_serial.h:83