Files
AMI/examples/ami_debug_send.c

20 lines
493 B
C

#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
extern void UART_SendBytes(const uint8_t *data, size_t len);
int ami_set_debug(unsigned id, unsigned state)
{
uint8_t buf[24];
if (id > 15 || state > 2) return -1;
int n = snprintf((char *)buf, sizeof buf,
"d%u=%u", id, state);
if (n < 0 || (size_t)n > sizeof buf - 4) return -1;
buf[n++] = 0xFF;
buf[n++] = 0xFF;
buf[n++] = 0xFF;
UART_SendBytes(buf, (size_t)n);
return 0;
}