*/
void Pin_Init()
{
- for (int i = 0; i < GPIO_NUM_PINS; ++i)
+/* for (int i = 0; i < GPIO_NUM_PINS; ++i)
GPIO_Export(i);
for (int i = 0; i < ADC_NUM_PINS; ++i)
ADC_Export();
-
+*/
for (int i = 0; i < PWM_NUM_PINS; ++i)
PWM_Export(i);
}
FCGIValue values[] = {
{"type", &type, FCGI_REQUIRED(FCGI_STRING_T)},
{"num", &num, FCGI_REQUIRED(FCGI_INT_T)},
- {"set", &set, FCGI_INT_T},
- {"pol", &pol, FCGI_INT_T},
+ {"set", &set, FCGI_BOOL_T},
+ {"pol", &pol, FCGI_BOOL_T},
{"freq", &freq, FCGI_DOUBLE_T},
{"duty", &duty, FCGI_DOUBLE_T}
};
TYPE,
NUM,
SET,
+ POL,
FREQ,
DUTY
} SensorParams;
if (set)
{
Log(LOGDEBUG, "Setting PWM%d", num);
+ duty = duty < 0 ? 0 : duty > 1 ? 1 : duty;
long period_ns = (long)(1e9 / freq);
long duty_ns = (long)(duty * period_ns);
PWM_Set(num, pol, period_ns, duty_ns);
- FCGI_PrintRaw("PWM%d set to period_ns = %lu (%f Hz), duty_ns = %lu (%d), polarity = %d", num, period_ns, freq, duty_ns, duty*100, pol);
+ FCGI_PrintRaw("PWM%d set to period_ns = %lu (%f Hz), duty_ns = %lu (%f), polarity = %d",
+ num, period_ns, freq, duty_ns, duty*100, (int)pol);
}
else
{
# Identify cape-manager slots
slot=$(echo /sys/devices/bone_capemgr.*/slots | awk '{print $1}')
+pwm=/sys/class/pwm/
# Load PWM module
-modprobe pwm_test
+#modprobe pwm_test
(echo am33xx_pwm > $slot) 1>&2 >> /dev/null
-for port in P9_21 P9_22 P9_14 P9_16 P9_29 P9_31 P9_42 P8_13 P8_19 P8_34 P8_36 P8_45 P8_46; do
- echo bone_pwm_$port > $slot
-done
+#for port in P9_21 P9_22 P9_14 P9_16 P9_29 P9_31 P9_42 P8_13 P8_19 P8_34 P8_36 P8_45 P8_46; do
+# echo bone_pwm_$port > $slot
+#done
+echo 0 > $pwm/export
+echo 1 > $pwm/export
+echo bone_pwm_P9_21 > $slot
+echo bone_pwm_P9_22 > $slot
# Load ADCs
(echo cape-bone-iio > $slot) 1>&2 >> /dev/null