Esempio n. 1
0
void I2C2_Handler(void)
{
        SEGGER_SYSTEMVIEW_ISR_ENTER();

        uint16_t mask = I2C2->I2C2_INTR_STAT_REG;

        intr_handler(HW_I2C2, mask);

        SEGGER_SYSTEMVIEW_ISR_EXIT();
}
Esempio n. 2
0
void CALLBACK intr_async( ULONG_PTR sig ) {
    CancelIo( intr_handle );    /* interrupt system calls */
    if ( (uint32_t)sig == intr_sig ) { intr_handler( (uint32_t)sig ); }
}
Esempio n. 3
0
int
main(int argc, char *argv[])
{
	int r;
	endpoint_t user, caller;
	message m;
	int ipc_status;

	env_setargs(argc, argv);

	r = i2cdriver_env_parse(&bus, &address, valid_addrs);
	if (r < 0) {
		log_warn(&log, "Expecting -args 'bus=X address=0xYY'\n");
		log_warn(&log, "Example -args 'bus=1 address=0x24'\n");
		return EXIT_FAILURE;
	} else if (r > 0) {
		log_warn(&log,
		    "Invalid slave address for device, expecting 0x24\n");
		return EXIT_FAILURE;
	}

	sef_local_startup();

	while (TRUE) {

		/* Receive Message */
		r = sef_receive_status(ANY, &m, &ipc_status);
		if (r != OK) {
			log_warn(&log, "sef_receive_status() failed\n");
			continue;
		}

		log_trace(&log, "Got a message 0x%x from 0x%x\n", m.m_type,
		    m.m_source);

		if (is_ipc_notify(ipc_status)) {

			switch (m.m_source) {

			case DS_PROC_NR:
				/* bus driver changed state, update endpoint */
				i2cdriver_handle_bus_update(&bus_endpoint, bus,
				    address);
				break;
			case HARDWARE:
				intr_handler();
				break;
			default:
				break;
			}

			/* Do not reply to notifications. */
			continue;
		}

		caller = m.m_source;
		user = m.USER_ENDPT;

		/*
		 * Handle Message
		 *
		 * So far this driver only deals with notifications
		 * so it always replies to non-notifications with EINVAL.
		 */

		/* Send Reply */
		m.m_type = TASK_REPLY;
		m.REP_ENDPT = user;
		m.REP_STATUS = EINVAL;

		r = sendnb(caller, &m);
		if (r != OK) {
			log_warn(&log, "sendnb() failed\n");
			continue;
		}
	}

	return 0;
}