Browse Source

Don't build joystick code on BSD.

Add 't_off' parameter to am335 pwm block.
t_off will be the minimum time the bridge is switched low per pwm period.
(To allow boost C to recharge)
beaglebone
Jeroen Vreeken 6 years ago
parent
commit
c75128e542
2 changed files with 23 additions and 4 deletions
  1. +5
    -1
      common/command/build.mk
  2. +18
    -3
      controller/am335x/block_am335x_pwm.c

+ 5
- 1
common/command/build.mk View File

@ -1,7 +1,11 @@
COMMAND_TARGETS += $(LIBDIR)/libcommand.la
COMMAND_TARGETS += $(DIR)/command_list $(DIR)/command_send $(DIR)/command_joystick
COMMAND_TARGETS += $(DIR)/command_list $(DIR)/command_send
ifneq ($(OS), FreeBSD)
COMMAND_TARGETS += $(DIR)/command_joystick
endif
ARCHSRCS := $(DIR)/command.c $(DIR)/command_tcp.c


+ 18
- 3
controller/am335x/block_am335x_pwm.c View File

@ -28,6 +28,7 @@ struct controller_block_private {
float tbprd; // period
double freq;
double t_off;
bool sym;
void *base;
@ -63,16 +64,19 @@ static void set_freq(struct controller_block *pwm)
int clkdiv = 0;
int div = 1;
double period, freq;
double t_off;
uint16_t tbprd;
uint16_t aqctl;
/* double divider for symmetric use */
period = AM335X_SYSCLK / (priv->freq * ( priv->sym ? 2.0 : 1.0));
t_off = AM335X_SYSCLK * priv->t_off / (priv->sym ? 2.0 : 1.0);
while (period > AM335X_PWMSS_EPWM_TBPRD_MAX) {
clkdiv++;
div *= 2;
period /= 2.0;
t_off /= 2.0;
if (clkdiv == AM335X_PWMSS_EPWM_TBCTL_CLKDIV_MAX)
break;
}
@ -126,13 +130,14 @@ static void set_freq(struct controller_block *pwm)
am335x_write16(base, AM335X_PWMSS_REG_EPWM_CMPA, 0);
am335x_write16(base, AM335X_PWMSS_REG_EPWM_CMPB, 0);
priv->tbprd = tbprd;
t_off = ceil(t_off);
priv->tbprd = fmax(tbprd - (priv->t_off != 0.0 ? t_off : 0.0), 0.0);
freq = AM335X_SYSCLK / (tbprd * div * ( priv->sym ? 2.0 : 1.0));
log_send(LOG_T_DEBUG,
"%s: Frequency: %gHz, period: %d ticks, divider: %d",
pwm->name, freq, tbprd, div);
"%s: Frequency: %gHz, period: %d ticks (%d available), divider: %d",
pwm->name, freq, tbprd, (int)priv->tbprd, div);
priv->freq = freq;
}
@ -152,9 +157,19 @@ static int param_set_sym(struct controller_block *pwm, char *param, int argc,
return 0;
}
static int param_set_t_off(struct controller_block *pwm, char *param, int argc,
va_list val)
{
pwm->private->t_off = va_arg(val, double);
set_freq(pwm);
return 0;
}
static struct controller_block_param_list params[] = {
{ "frequency", false, param_set_freq, .args = { "double", NULL } },
{ "symmetrical", false, param_set_sym, .args = { "int", NULL } },
{ "t_off", false, param_set_t_off, .args = { "double", NULL } },
{ NULL },
};


Loading…
Cancel
Save