Exemplo n.º 1
0
int main() {
    int i;
    int id1, id2;
    struct _pulse pulse;

    // Request I/O privileges
    ThreadCtl( _NTO_TCTL_IO, 0 );

    chid = ChannelCreate( 0 );
	coid = ConnectAttach( 0, 0, chid, _NTO_SIDE_CHANNEL, 0 );

	SIGEV_PULSE_INIT( &event1, coid, getprio(0), MY_PULSE_CODE1, 0 );
    id1=InterruptAttach( SYSPAGE_ENTRY(qtime)->intr, &handler1,
                        NULL, 0, 0 );

	SIGEV_PULSE_INIT( &event2, coid, getprio(0), MY_PULSE_CODE2, 0 );
    id2=InterruptAttach( SYSPAGE_ENTRY(qtime)->intr, &handler2,
                        NULL, 0, 0 );

    for( i = 0; i < 10; ++i ) {
        // Wait for ISR to wake us up
    	MsgReceivePulse( chid, &pulse, sizeof( pulse ), NULL );
    	if(pulse.code == MY_PULSE_CODE1) {
            printf( "1000 events\n" );
    	} else if(pulse.code == MY_PULSE_CODE2) {
    		printf( "2500 events\n" );
    	}
    }

    // Disconnect the ISR handler
    InterruptDetach(id1);
    InterruptDetach(id2);
    return 0;
}
Exemplo n.º 2
0
void omap3_dinit(void *hdl)
{
	omap3_spi_t	*dev = hdl;
    
	/*
	 * unmap the register, detach the interrupt
	 */
	InterruptDetach(dev->iid_spi);
	munmap_device_io(dev->vbase, OMAP3_SPI_REGLEN);
	
	/*
	 * Disable EDMA
	 */
	if (dev->edma) {
		omap3_edma_disablespi(dev);
		InterruptDetach(dev->iid_edma);
		omap3_edma_detach (dev);
		munmap_device_memory((void *)dev->edmavbase, DM6446_EDMA_SIZE); 
		munmap(dev->dmabuf, OMAP3_SPI_MAXDMALEN);
		ConnectDetach(dev->edma_coid);
	}
	ConnectDetach(dev->coid);
	ChannelDestroy(dev->chid);
	
	free(hdl);
}
Exemplo n.º 3
0
inline void
isr_cleanup(omapl1xx_context_t *omapl1xx)
{
	ConnectDetach(omapl1xx->lcd_coid);
	ChannelDestroy(omapl1xx->lcd_chid);
	InterruptDetach(omapl1xx->lcd_iid);
}
Exemplo n.º 4
0
static err_t gpio_destory(Drive_Gpio *t)
{
	Drive_Gpio 		*cthis = ( Drive_Gpio *)t ;

	cthis->disableIrq( cthis);
	GPIOModuleDisable( cthis->gpio_vbase);
	InterruptDetach( cthis->irq_id);
	munmap_device_io( cthis->gpio_vbase, AM335X_GPIO_SIZE);
	lw_oopc_delete( cthis);
	return EXIT_SUCCESS;

}
Exemplo n.º 5
0
void
omap_fini(void *hdl)
{
    omap_dev_t  *dev = hdl;

    out16(dev->regbase + OMAP_I2C_CON, 0);
    out16(dev->regbase + OMAP_I2C_IE, 0);
	InterruptDetach(dev->iid);
	ConnectDetach(dev->coid);
	ChannelDestroy(dev->chid);
	munmap_device_io (dev->regbase, dev->reglen);
	free (hdl);
}
Exemplo n.º 6
0
Arquivo: uio.c Projeto: matthoosier/os
int main (int argc, char *argv[])
{
    int chid;
    int coid;

    my_msg_type msg;

    chid = ChannelCreate();
    coid = Connect(SELF_PID, chid);

    void * zeroPtr = MapPhysical(0, 4096 * 4);
    zeroPtr = zeroPtr;

    int handler_id = InterruptAttach(coid, 4, NULL);

    for (;;) {
        int msgid;
        int num = MessageReceive(chid, &msgid, &msg, sizeof(msg));

        if (msgid != 0) {
            MessageReply(msgid, ERROR_NO_SYS, NULL, 0);
        }
        else {
            // Pulse received
            switch (msg.async.type) {
                case PULSE_TYPE_INTERRUPT:
                {
                    InterruptComplete(handler_id);
                    break;
                }
                default:
                {
                    *((char *)NULL) = '\0';
                    break;
                }
            }
        }

        num = num;
    }

    InterruptDetach(handler_id);

    return 0;
}
Exemplo n.º 7
0
void SensorHAL::stopInterrupt() {
	if (-1 == ThreadCtl(_NTO_TCTL_IO, 0)) {
		printf("ThreadCtl access failed\n");
		exit(EXIT_FAILURE);
	}

	if (InterruptDetach(interruptId) == -1) {
		printf("SensorHAL: Error InterruptDetach\n");
	}

	if (ConnectDetach(coid) == -1) {
		printf("SensorHAL: Error in ConnectDetach\n");
	}

	if (ChannelDestroy(chid) == -1) {
		printf("SensorHAL: Error in ChannelDestroy\n");
	}
}
Exemplo n.º 8
0
/****************************************************************************
REMARKS:
Function to execute a service at ring 0. This is done using the clock
interrupt handler since the code we attach to it will always run at ring 0.
****************************************************************************/
static void CallRing0(void)
{
#ifdef __QNXNTO__
    uint    clock_intno = SYSPAGE_ENTRY(qtime)->intr;
#else
    uint    clock_intno = 0;    /* clock irq */
#endif
    int     intrid;

#ifdef __QNXNTO__
    mlock((void*)&_PM_R0, sizeof(_PM_R0));
    ThreadCtl(_NTO_TCTL_IO, 0);
#endif
#ifdef __QNXNTO__
    if ((intrid = InterruptAttach(_NTO_INTR_CLASS_EXTERNAL | clock_intno,
        _PM_ring0_isr, (void*)&_PM_R0, sizeof(_PM_R0), _NTO_INTR_FLAGS_END)) == -1) {
#else
    if ((intrid = qnx_hint_attach(clock_intno, _PM_ring0_isr, FP_SEG(&_PM_R0))) == -1) {
#endif
        perror("Attach");
        exit(-1);
        }
    while (_PM_R0.service != -1)
        ;
#ifdef __QNXNTO__
    InterruptDetach(intrid);
#else
    qnx_hint_detach(intrid);
#endif
}

/****************************************************************************
REMARKS:
Flush the translation lookaside buffer.
****************************************************************************/
void PMAPI PM_flushTLB(void)
{
    _PM_R0.service = R0_FLUSH_TLB;
    CallRing0();
}
Exemplo n.º 9
0
int main(int argc, char *argv[]) {
	uint32_t l;
	int id, id2;
	my_data_t msg;
	int rcvid;

	name_attach_t *name;

	printf("Welcome Onda\n");

	if (ThreadCtl(_NTO_TCTL_IO, 0) < 0) {
		perror(NULL);
		return -1;
	}

	name = name_attach(NULL, "onda", NAME_FLAG_ATTACH_GLOBAL);
	if (name == NULL) {
		perror("Error0\n");
		return -1;
	}

	/* attach GPIO interrupt */
	id = InterruptAttach (33, gpio_isr_handler, NULL, 0, _NTO_INTR_FLAGS_PROCESS);

	/* attach timer interrupt */
	id2 = InterruptAttach (45, timer_isr_handler, NULL, 0,  _NTO_INTR_FLAGS_PROCESS);

	gpio5 = mmap_device_io(OMAP3530_GPIO_SIZE, OMAP3530_GPIO5_BASE);
	if (gpio5 == MAP_DEVICE_FAILED) {
		perror(NULL);
		return -1;
	}

	//gpt3 = mmap_device_io(OMAP3530_GPT_SIZE, OMAP3530_GPT3_BASE);
	gpt9 = mmap_device_io(OMAP3530_GPT_SIZE, OMAP3530_GPT9_BASE);
	if (gpt9 == MAP_DEVICE_FAILED) {
		perror(NULL);
		return -1;
	}

	sys = mmap_device_io(OMAP3530_SYSCTL_SIZE, OMAP3530_SYSCTL_BASE);
	if (sys == MAP_DEVICE_FAILED) {
		perror(NULL);
		return -1;
	}

	/* selecting mode 4 function - GPIO 139
	 * selecting pullup and mode 4 function - GPIO 138 */
#define SYS_CONF	((4 << 16) | ((1 << 8) | (1<<3) | 4))
#define SYS_MASK	~(0x10F010F)
	l = (in32(sys + 0x168) &  SYS_MASK) | SYS_CONF;
	//l = (in32(sys + 0x168) & ~(7<<16) ) | (4 << 16);
	//out32(sys + 0x168, ((1<<3 | 4) << 16) | (1<<3) | 4);
	out32(sys + 0x168, l);

	/* setting mode 2 - PWM */
	l = (in32(sys + 0x174) & ~7 ) | 2;
	out32(sys + 0x174, l);

	/* setting the PIN 138 to input
	 * setting the PIN 139 to output */
	l = (in32(gpio5 + OMAP2420_GPIO_OE) & ~(1 << 11)) | 1 << 10;
	out32(gpio5 + OMAP2420_GPIO_OE, l);

	/* enabling interrupt on both levels on GPIO 139 */
	out32(gpio5 + OMAP2420_GPIO_RISINGDETECT, l << 10);
	out32(gpio5 + OMAP2420_GPIO_FALLINGDETECT, l << 10);
	out32(gpio5 + OMAP2420_GPIO_SETIRQENABLE1, l << 10);

	/* make sure timer has stop */
	out32(gpt9 + OMAP3530_GPT_TCLR, 0);

	/* enabling the interrupt */
	out32(gpt9 + OMAP3530_GPT_TIER, 2); //comentar se PWM

	/* configuring PWM */
	out32(gpt9 + OMAP3530_GPT_TCLR, (1<<12) | (1<<10) | (1<<7)); //-- PWM

	out32(gpio5 + OMAP2420_GPIO_SETDATAOUT, (1 << 11));

	printf("Esperando requisições\n");

	while (1) {
		rcvid = MsgReceive(name->chid, &msg, sizeof(msg), NULL);

		if (rcvid == -1) {/* Error condition, exit */
			break;
		}
		/* name_open() sends a connect message, must EOK this */
		if (msg.hdr.type == _IO_CONNECT) {
			MsgReply(rcvid, EOK, NULL, 0);
			continue;
		}

		/* Some other QNX IO message was received; reject it */
		if (msg.hdr.type > _IO_BASE && msg.hdr.type <= _IO_MAX) {
			MsgError(rcvid, ENOSYS);
			continue;
		}
		switch (msg.hdr.subtype) {
		case 0x55:
			MsgReply(rcvid, EOK, &pincount, sizeof(pincount));
			break;

		case 0x65:
			MsgReply(rcvid, EOK, &interval, sizeof(interval));
			break;

		case 0x66:
			interval = msg.data;
			MsgReply(rcvid, EOK, &interval, sizeof(interval));
			break;

		default:
			MsgReply(rcvid, EOK, NULL, 0);
		}
	}
	out32(gpt9 + OMAP3530_GPT_TCLR, 0);
	out32(gpt9 + OMAP3530_GPT_TIER, 0);
	InterruptDetach (id);
	InterruptDetach (id2);
	printf("Fim\n");

	return EXIT_SUCCESS;
}