Example #1
0
static int config_channel(struct timer *tr, char **arg_text)
{
	char *which_text = get_arg(arg_text);
	char *value_text = get_arg(arg_text);
	address_t which;
	address_t value;

	if (!(which_text && value_text)) {
		printc_err("timer: config: expected channel and value\n");
		return -1;
	}

	if (expr_eval(which_text, &which) < 0) {
		printc_err("timer: can't parse channel number: %s\n",
			   which_text);
		return -1;
	}

	if (expr_eval(value_text, &value) < 0) {
		printc_err("timer: can't parse channel value: %s\n",
			   value_text);
		return -1;
	}

	if (which > tr->size) {
		printc_err("timer: invalid channel number: %d\n", which);
		return -1;
	}

	trigger_capture(tr, which, tr->ctls[which] & CCI, value);

	return 0;
}
Example #2
0
static int timer_write(struct simio_device *dev,
		       address_t addr, uint16_t data)
{
	struct timer *tr = (struct timer *)dev;

	if (addr == tr->base_addr) {
		tr->tactl = data & ~(TACLR | 0x08);
		if (data & TACLR)
			tr->tar = 0;

		return 0;
	}

	if (addr == tr->base_addr + 0x10) {
		tr->tar = data & tar_mask(tr);
		return 0;
	}

	if (addr >= tr->base_addr + 2 &&
	    addr < tr->base_addr + (tr->size << 1) + 2) {
		int index = ((addr & 0xf) - 2) >> 1;
		uint16_t oldval = tr->ctls[index];
		uint16_t mask;

		if (tr->timer_type == TIMER_TYPE_A)
			mask = 0x0608;
		if (tr->timer_type == TIMER_TYPE_B)
			mask = 0x0008;
		tr->ctls[index] = (data & ~mask) | (oldval & mask);
		/* Check capture initiated by Software */
		if ((data & (CAP | CCIS1)) == (CAP | CCIS1))
			trigger_capture(tr, index, oldval & CCI, data & CCIS0);
		return 0;
	}
Example #3
0
static PyObject *
chameleon_trigger(PyObject *self, PyObject *args)
{
	int handle = -1;
	int status;
	struct chameleon_camera* cam = NULL;
	bool continuous;
	PyObject *continuous_obj;

	if (!PyArg_ParseTuple(args, "iO", &handle, &continuous_obj))
		return NULL;

	continuous = PyObject_IsTrue(continuous_obj);

	if (handle >= 0 && handle < NUM_CAMERA_HANDLES && cameras[handle]) {
		cam = cameras[handle];
	} else {
		PyErr_SetString(ChameleonError, "Invalid handle");
		return NULL;
	}

	Py_BEGIN_ALLOW_THREADS;
	status = trigger_capture(cam, shutters[handle], continuous);
	Py_END_ALLOW_THREADS;

	if (status < 0) {
		PyErr_SetString(ChameleonError, "Failed to capture");
		return NULL;
	}

	Py_RETURN_NONE;
}