MCPcopy Create free account
hub / github.com/apache/nuttx / phyplus_parse_timer_param

Function phyplus_parse_timer_param

arch/arm/src/phy62xx/phyplus_stub.c:310–479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308
309#if 0
310static int phyplus_parse_timer_param(
311 char *buff, struct AP_TIM_TYPEDEF *timer_param)
312{
313 char *ptr;
314 int temp_val;
315
316 /* setup default params.. */
317
318 timer_param->idx = 0;
319 timer_param->enable = 0;
320 timer_param->mask = 0;
321 timer_param->mode = 0; /* 0:freerun, 1:count */
322 timer_param->value = 0;
323
324 ptr = strtok(buff, ",");
325 if (ptr != NULL)
326 {
327 if (0 == strncmp("idx", ptr, 3))
328 {
329 ptr = ptr + 4;
330 temp_val = atoi(ptr);
331 if ((temp_val < 1) || (temp_val > 6))
332 {
333 fprintf(stderr, "parse timer_idx failure");
334 return -1;
335 }
336 else
337 {
338 timer_param->idx = temp_val;
339 }
340 }
341 else if (0 == strncmp("mode", ptr, 4))
342 {
343 ptr = ptr + 5;
344 if (0 == strncmp(ptr, "freerun", 7))
345 {
346 timer_param->mode = 0;
347 }
348 else if (0 == strncmp(ptr, "count", 5))
349 {
350 timer_param->mode = 1;
351 }
352 else
353 {
354 fprintf(stderr, "parse timer_mode failure");
355 return -1;
356 }
357 }
358 else if (0 == strncmp("enable", ptr, 6))
359 {
360 ptr = ptr + 7;
361 if (0 == strncmp(ptr, "true", 4))
362 {
363 timer_param->mode = 1;
364 }
365 else if (0 == strncmp(ptr, "false", 5))
366 {
367 timer_param->mode = 0;

Callers 1

Calls 4

strtokFunction · 0.85
atoiFunction · 0.85
fprintfFunction · 0.85
strncmpFunction · 0.50

Tested by

no test coverage detected