Skip to content

Commit b926084

Browse files
committed
test the config_pin() function
1 parent 26c9393 commit b926084

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

source/c_pinmux.c

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ BBIO_err set_pin_mode(const char *key, const char *mode)
1414
FILE *f = NULL;
1515
fprintf(stderr, "DEBUG: set_pin_mode(): key=%s\n", key);
1616
fprintf(stderr, "DEBUG: set_pin_mode(): mode=%s\n", mode);
17+
config_pin(key, mode);
1718

1819
if (strlen(key) == 4) // Key P#_# format, must inject '0' to be P#_0#
1920
snprintf(pin, sizeof(pin), "%.3s0%c", key,key[3]);

source/common.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -491,15 +491,15 @@ int uboot_overlay_enabled(void) {
491491
*/
492492
/* WORK IN PROGRESS */
493493
#define BUFFER_SIZE 255
494-
int config_pin(char *pin, char *mode) {
494+
int config_pin(const char *pin, const char *mode) {
495495
const char *cmd = "/usr/bin/config-pin";
496496
char buffer[BUFFER_SIZE] = "";
497497
char *result;
498498
FILE *file = NULL;
499499

500-
fprintf(stderr, "DEBUG: config_pin(): pin=%s", pin);
501-
fprintf(stderr, "DEBUG: config_pin(): mode=%s", mode);
502-
fprintf(stderr, "DEBUG: config_pin(): cmd=%s", cmd);
500+
fprintf(stderr, "DEBUG: config_pin(): pin=%s\n", pin);
501+
fprintf(stderr, "DEBUG: config_pin(): mode=%s\n", mode);
502+
fprintf(stderr, "DEBUG: config_pin(): cmd=%s\n", cmd);
503503

504504
file = popen(cmd, "r");
505505
if (file == NULL) {
@@ -509,9 +509,9 @@ int config_pin(char *pin, char *mode) {
509509
result = fgets(buffer, BUFFER_SIZE, file);
510510
pclose(file);
511511

512-
fprintf(stderr, "DEBUG: config_pin(): buffer=%s", buffer);
513-
fprintf(stderr, "DEBUG: config_pin(): result=%p", result);
514-
fprintf(stderr, "DEBUG: config_pin(): NULL=%p", NULL);
512+
fprintf(stderr, "DEBUG: config_pin(): buffer=%s\n", buffer);
513+
fprintf(stderr, "DEBUG: config_pin(): result=%p\n", result);
514+
fprintf(stderr, "DEBUG: config_pin(): NULL=%p\n", NULL);
515515

516516
if(result == NULL) {
517517
return -2;

source/common.h

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ BBIO_err load_device_tree(const char *name);
8080
BBIO_err unload_device_tree(const char *name);
8181
int device_tree_loaded(const char *name);
8282
BBIO_err get_pwm_by_key(const char *key, pwm_t **pwm);
83+
int config_pin(const char *pin, const char *mode);
8384

8485
#define BBIO_LOG_OPTION LOG_CONS | LOG_PID | LOG_NDELAY
8586
void initlog(int level, const char* ident, int option);

0 commit comments

Comments
 (0)