/* Set derivative constant, Kd, for the PID controller. */
int32_t cn0415_pid_set_kd(struct cn0415_dev *dev, uint8_t *args)
/* Set derivative constant, Kd, for the PID controller. */
int32_t cn0415_pid_set_kd(struct cn0415_dev *dev, uint8_t *args)
{
	float kp, ki, kd;
	kd = atof((char *)args);
	ki = dev->controller->ki * dev->controller->f_loop;
	kp = dev->controller->kp;
	pid_set_constants(dev->controller, kp, ki, kd);
	dev->param_array[PID_KD_INT] = dev->controller->kd;
	dev->param_array[PID_KD_DEC] =
		(uint32_t)(dev->controller->kd * 10000) % 10000;
	return flash_write(dev->param_array, FLASH_PARAM_SIZE);
}