// Driver for serial esc (konze protocol) on UART2
#define SESC_SYNCBYTE 0xF5
#define SESC_MAX_CHANNEL 4
void sEscInit(void)
{
core.sescport = uartOpen(USART2, NULL, 38400, MODE_RXTX);
}
void sEscSend(void)
{
int i;
uint8_t sEscData;
serialWrite(core.sescport,SESC_SYNCBYTE);
for (i = 0; i < SESC_MAX_CHANNEL; i++)
{
sEscData = constrain(((motor[i] - 1000) >> 2),0,200);
serialWrite(core.sescport,sEscData);
}
}