int main() { check(0, "", 0); check(1, "\0", 1); check(1, "a", 1); check(2, "ab", 2); check(3, "abc", 3); assert(sizeof("a\303\237cd") == 6); check(4, "a\303\237cd", 5); check(3, "a\370\211\200\201\257c", 7); check(3, "\320\273\320\265\320\262", 6); check(-1, "a\303", 2); /* Truncated */ check(-2, "\377", 1); /* Invalid UTF-8 sequence start */ check(-2, "\200", 1); check(-2, "\320\273\265\320\262", 5); check(-3, "\320c", 2); /* Not continuation */ check(-3, "a\370\200\200\200c", 6); check(-4, "a\370\200\200\200\257c", 7); check(-4, "\320\273\320\265\340\200\262", 7); check(-5, 0, 0); check_speed(); return 0; }
int output_speed(int channel, int speed) { check_channel(channel); check_speed(speed); if (channel == 0) { timer_set_oc_value(TIM2, TIM_OC2, speed*20); } else { timer_set_oc_value(TIM2, TIM_OC1, speed*20); } return 0; }