ODROID-COMMON: modify pwmSetRange to to call just once.
Signed-off-by: steve.jeong <jkhpro1003@gmail.com> Change-Id: Ie05850032dea81d03eacfdf21fea96006886585d
This commit is contained in:
@@ -135,7 +135,13 @@ static char pwmPinPath[10][(BLOCK_SIZE)] = {
|
|||||||
"None","None","None","None"
|
"None","None","None","None"
|
||||||
};
|
};
|
||||||
|
|
||||||
static char setupedPwmPinPath[BLOCK_SIZE];
|
static char setupedPwmPinPath[10][BLOCK_SIZE] = {
|
||||||
|
"None","None",
|
||||||
|
"None","None",
|
||||||
|
"None","None",
|
||||||
|
"None","None",
|
||||||
|
"None","None"
|
||||||
|
};
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
//
|
//
|
||||||
@@ -419,7 +425,7 @@ static int pwmSetup (int pin) {
|
|||||||
pwmClock = C4_PWM_INTERNAL_CLK;
|
pwmClock = C4_PWM_INTERNAL_CLK;
|
||||||
sprintf(pwmExport, "%d", (pwmPin % 2));
|
sprintf(pwmExport, "%d", (pwmPin % 2));
|
||||||
sprintf(pwmPinPath[pwmPin], "%s/pwm%d", sysPwmPath, (pwmPin % 2));
|
sprintf(pwmPinPath[pwmPin], "%s/pwm%d", sysPwmPath, (pwmPin % 2));
|
||||||
strncpy(setupedPwmPinPath, pwmPinPath[pwmPin], (sizeof(setupedPwmPinPath) - 1));
|
strncpy(setupedPwmPinPath[pwmPin], pwmPinPath[pwmPin], (BLOCK_SIZE - 1));
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
sprintf(cmd, "su -s sh -c %s %s", PWM_ACCESS_SCRIPT, pwmPinPath[pwmPin]);
|
sprintf(cmd, "su -s sh -c %s %s", PWM_ACCESS_SCRIPT, pwmPinPath[pwmPin]);
|
||||||
#else
|
#else
|
||||||
@@ -872,14 +878,14 @@ static void _pwmSetRange (unsigned int range)
|
|||||||
freq = (pwmClock / pwmRange);
|
freq = (pwmClock / pwmRange);
|
||||||
period = (1000000000 / freq); // period: s to ns.
|
period = (1000000000 / freq); // period: s to ns.
|
||||||
sprintf(pwmPeriod, "%d", period);
|
sprintf(pwmPeriod, "%d", period);
|
||||||
if (strstr(setupedPwmPinPath, "pwm") == NULL) {
|
|
||||||
printf("Not setuped pwm target.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
inputToSysNode(setupedPwmPinPath, "period", pwmPeriod);
|
for (int i = 0; i < 10; i++) {
|
||||||
inputToSysNode(setupedPwmPinPath, "polarity", "normal");
|
if (strstr(setupedPwmPinPath[i], "None") != NULL)
|
||||||
inputToSysNode(setupedPwmPinPath, "enable", "1");
|
continue;
|
||||||
|
inputToSysNode(setupedPwmPinPath[i], "period", pwmPeriod);
|
||||||
|
inputToSysNode(setupedPwmPinPath[i], "polarity", "normal");
|
||||||
|
inputToSysNode(setupedPwmPinPath[i], "enable", "1");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,13 @@ static char pwmPinPath[10][(BLOCK_SIZE)] = {
|
|||||||
"None","None","None","None"
|
"None","None","None","None"
|
||||||
};
|
};
|
||||||
|
|
||||||
static char setupedPwmPinPath[BLOCK_SIZE];
|
static char setupedPwmPinPath[10][BLOCK_SIZE] = {
|
||||||
|
"None","None",
|
||||||
|
"None","None",
|
||||||
|
"None","None",
|
||||||
|
"None","None",
|
||||||
|
"None","None"
|
||||||
|
};
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
//
|
//
|
||||||
// Global variable define
|
// Global variable define
|
||||||
@@ -332,7 +338,7 @@ static int pwmSetup (int pin) {
|
|||||||
pwmClock = (M1_PWM_INTERNAL_CLK / 2);
|
pwmClock = (M1_PWM_INTERNAL_CLK / 2);
|
||||||
sprintf(pwmExport, "%d", 0);
|
sprintf(pwmExport, "%d", 0);
|
||||||
sprintf(pwmPinPath[pwmPin], "%s/pwm%d", sysPwmPath, 0);
|
sprintf(pwmPinPath[pwmPin], "%s/pwm%d", sysPwmPath, 0);
|
||||||
strncpy(setupedPwmPinPath, pwmPinPath[pwmPin], (sizeof(setupedPwmPinPath) - 1));
|
strncpy(setupedPwmPinPath[pwmPin], pwmPinPath[pwmPin], (BLOCK_SIZE - 1));
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
sprintf(cmd, "su -s sh -c %s %s", PWM_ACCESS_SCRIPT, pwmPinPath[pwmPin]);
|
sprintf(cmd, "su -s sh -c %s %s", PWM_ACCESS_SCRIPT, pwmPinPath[pwmPin]);
|
||||||
#else
|
#else
|
||||||
@@ -1447,14 +1453,14 @@ static void _pwmSetRange (unsigned int range)
|
|||||||
freq = (pwmClock / pwmRange);
|
freq = (pwmClock / pwmRange);
|
||||||
period = (1000000000 / freq); // period: s to ns.
|
period = (1000000000 / freq); // period: s to ns.
|
||||||
sprintf(pwmPeriod, "%d", period);
|
sprintf(pwmPeriod, "%d", period);
|
||||||
if (strstr(setupedPwmPinPath, "pwm") == NULL) {
|
|
||||||
printf("Not setuped pwm target.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
inputToSysNode(setupedPwmPinPath, "period", pwmPeriod);
|
for (int i = 0; i < 10; i++) {
|
||||||
inputToSysNode(setupedPwmPinPath, "polarity", "normal");
|
if (strstr(setupedPwmPinPath[i], "None") != NULL)
|
||||||
inputToSysNode(setupedPwmPinPath, "enable", "1");
|
continue;
|
||||||
|
inputToSysNode(setupedPwmPinPath[i], "period", pwmPeriod);
|
||||||
|
inputToSysNode(setupedPwmPinPath[i], "polarity", "normal");
|
||||||
|
inputToSysNode(setupedPwmPinPath[i], "enable", "1");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|||||||
@@ -135,7 +135,13 @@ static char pwmPinPath[10][(BLOCK_SIZE)] = {
|
|||||||
"None","None","None","None"
|
"None","None","None","None"
|
||||||
};
|
};
|
||||||
|
|
||||||
static char setupedPwmPinPath[BLOCK_SIZE];
|
static char setupedPwmPinPath[10][BLOCK_SIZE] = {
|
||||||
|
"None","None",
|
||||||
|
"None","None",
|
||||||
|
"None","None",
|
||||||
|
"None","None",
|
||||||
|
"None","None"
|
||||||
|
};
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
//
|
//
|
||||||
@@ -404,7 +410,7 @@ static int pwmSetup (int pin) {
|
|||||||
pwmClock = N2_PWM_INTERNAL_CLK;
|
pwmClock = N2_PWM_INTERNAL_CLK;
|
||||||
sprintf(pwmExport, "%d", (pwmPin % 2));
|
sprintf(pwmExport, "%d", (pwmPin % 2));
|
||||||
sprintf(pwmPinPath[pwmPin], "%s/pwm%d", sysPwmPath, (pwmPin % 2));
|
sprintf(pwmPinPath[pwmPin], "%s/pwm%d", sysPwmPath, (pwmPin % 2));
|
||||||
strncpy(setupedPwmPinPath, pwmPinPath[pwmPin], (sizeof(setupedPwmPinPath) - 1));
|
strncpy(setupedPwmPinPath[pwmPin], pwmPinPath[pwmPin], (BLOCK_SIZE - 1));
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
sprintf(cmd, "su -s sh -c %s %s", PWM_ACCESS_SCRIPT, pwmPinPath[pwmPin]);
|
sprintf(cmd, "su -s sh -c %s %s", PWM_ACCESS_SCRIPT, pwmPinPath[pwmPin]);
|
||||||
#else
|
#else
|
||||||
@@ -830,14 +836,14 @@ static void _pwmSetRange (unsigned int range)
|
|||||||
freq = (pwmClock / pwmRange);
|
freq = (pwmClock / pwmRange);
|
||||||
period = (1000000000 / freq); // period: s to ns.
|
period = (1000000000 / freq); // period: s to ns.
|
||||||
sprintf(pwmPeriod, "%d", period);
|
sprintf(pwmPeriod, "%d", period);
|
||||||
if (strstr(setupedPwmPinPath, "pwm") == NULL) {
|
|
||||||
printf("Not setuped pwm target.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
inputToSysNode(setupedPwmPinPath, "period", pwmPeriod);
|
for (int i = 0; i < 10; i++) {
|
||||||
inputToSysNode(setupedPwmPinPath, "polarity", "normal");
|
if (strstr(setupedPwmPinPath[i], "None") != NULL)
|
||||||
inputToSysNode(setupedPwmPinPath, "enable", "1");
|
continue;
|
||||||
|
inputToSysNode(setupedPwmPinPath[i], "period", pwmPeriod);
|
||||||
|
inputToSysNode(setupedPwmPinPath[i], "polarity", "normal");
|
||||||
|
inputToSysNode(setupedPwmPinPath[i], "enable", "1");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user