コード例 #1
0
static int command_usart_info(int argc, char **argv)
{
	struct usart_configs configs = usart_get_configs();
	size_t i;

	for (i = 0; i < configs.count; i++) {
		struct usart_config const *config = configs.configs[i];

		if (config == NULL)
			continue;

		ccprintf("USART%d\n"
			 "    dropped %d bytes\n"
			 "    overran %d times\n",
			 config->hw->index + 1,
			 atomic_read_clear(&(config->state->rx_dropped)),
			 atomic_read_clear(&(config->state->rx_overrun)));

		if (config->rx->info)
			config->rx->info(config);

		if (config->tx->info)
			config->tx->info(config);
	}

	return EC_SUCCESS;
}
コード例 #2
0
ファイル: usb_hid_keyboard.c プロジェクト: coreboot/chrome-ec
void set_keyboard_report(uint64_t rpt)
{
	/* Prevent the interrupt handler from sending the data (which would use
	 * an incomplete buffer).
	 */
	hid_ep_data_ready = 0;
	hid_current_buf = hid_current_buf ? 0 : 1;
	memcpy_to_usbram((void *) usb_sram_addr(hid_ep_buf[hid_current_buf]),
			 &rpt, sizeof(rpt));

	/* Tell the interrupt handler to send the next buffer. */
	hid_ep_data_ready = 1;
	if ((STM32_USB_EP(USB_EP_HID_KEYBOARD) & EP_TX_MASK) == EP_TX_VALID) {
		/* Endpoint is busy: we sneak in an address change to give us a
		 * chance to send the most updated report. However, there is no
		 * guarantee that this buffer is the one actually sent, so we
		 * keep hid_ep_data_ready = 1, which will send a duplicated
		 * report.
		 */
		btable_ep[USB_EP_HID_KEYBOARD].tx_addr =
			usb_sram_addr(hid_ep_buf[hid_current_buf]);
		hid_ep_data_ready = 1;
	} else if (atomic_read_clear(&hid_ep_data_ready)) {
		/* Endpoint is not busy, and interrupt handler did not just
		 * send our last buffer: swap buffer, enable TX.
		 */
		btable_ep[USB_EP_HID_KEYBOARD].tx_addr =
			usb_sram_addr(hid_ep_buf[hid_current_buf]);
		STM32_TOGGLE_EP(USB_EP_HID_KEYBOARD, EP_TX_MASK,
				EP_TX_VALID, 0);
	}
}
コード例 #3
0
ファイル: motion_sense.c プロジェクト: fourier49/BIZ_EC
static int motion_sense_process(struct motion_sensor_t *sensor,
				uint32_t event,
				const timestamp_t *ts,
				int *flush_needed)
{
	int ret = EC_SUCCESS;

#ifdef CONFIG_ACCEL_INTERRUPTS
	if ((event & TASK_EVENT_MOTION_INTERRUPT_MASK) &&
	    (sensor->drv->irq_handler != NULL)) {
		sensor->drv->irq_handler(sensor, event);
		sensor->last_collection = ts->le.lo;
	}
#endif
#ifdef CONFIG_ACCEL_FIFO
	if (sensor->drv->load_fifo != NULL) {
		/* Load fifo is filling raw_xyz sensor vector */
		sensor->drv->load_fifo(sensor);
	} else if (motion_sensor_time_to_read(ts, sensor)) {
		struct ec_response_motion_sensor_data vector;
		ret = motion_sense_read(sensor);
		if (ret == EC_SUCCESS) {
			vector.flags = 0;
			vector.data[X] = sensor->raw_xyz[X];
			vector.data[Y] = sensor->raw_xyz[Y];
			vector.data[Z] = sensor->raw_xyz[Z];
			motion_sense_fifo_add_unit(&vector, sensor, 3);
			sensor->last_collection = ts->le.lo;
		}
	} else {
		ret = EC_ERROR_BUSY;
	}
	if (event & TASK_EVENT_MOTION_FLUSH_PENDING) {
		int flush_pending;
		flush_pending = atomic_read_clear(&sensor->flush_pending);
		for (; flush_pending > 0; flush_pending--) {
			*flush_needed = 1;
			motion_sense_insert_flush(sensor);
		}
	}
#else
	if (motion_sensor_time_to_read(ts, sensor)) {
		/* Get latest data for local calculation */
		ret = motion_sense_read(sensor);
	} else {
		ret = EC_ERROR_BUSY;
	}
	if (ret == EC_SUCCESS) {
		sensor->last_collection = ts->le.lo;
		mutex_lock(&g_sensor_mutex);
		memcpy(sensor->xyz, sensor->raw_xyz, sizeof(sensor->xyz));
		mutex_unlock(&g_sensor_mutex);
	}

#endif
	return ret;
}
コード例 #4
0
ファイル: board.c プロジェクト: coreboot/chrome-ec
static int host_event_status_host_cmd(struct host_cmd_handler_args *args)
{
	struct ec_response_host_event_status *r = args->response;

	/* Read and clear the host event status to return to AP */
	r->status = atomic_read_clear(&(host_event_status.status));

	args->response_size = sizeof(*r);
	return EC_RES_SUCCESS;
}