Example #1
0
__initfunc(static void output_check(struct hfmodem_state *dev))
{
    enum uart u = c_uart_unknown;

    if (((u = check_uart(dev->ptt_out.seriobase))) != c_uart_unknown)
        printk(KERN_INFO "%s: PTT output: uart found at address 0x%x type %s\n",
               hfmodem_drvname, dev->ptt_out.seriobase, uart_str[u]);
    else {
        if (dev->ptt_out.seriobase > 0)
            printk(KERN_WARNING "%s: PTT output: no uart found at address 0x%x\n",
                   hfmodem_drvname, dev->ptt_out.seriobase);
        dev->ptt_out.seriobase = 0;
    }
    if (check_lpt(dev, dev->ptt_out.pariobase))
        printk(KERN_INFO "%s: PTT output: parallel port found at address 0x%x\n",
               hfmodem_drvname, dev->ptt_out.pariobase);
    else {
        if (dev->ptt_out.pariobase > 0)
            printk(KERN_WARNING "%s: PTT output: no parallel port found at address 0x%x\n",
                   hfmodem_drvname, dev->ptt_out.pariobase);
        dev->ptt_out.pariobase = 0;
        dev->ptt_out.pardev = NULL;
    }
    if (dev->ptt_out.midiiobase > 0 && dev->ptt_out.midiiobase <= 0x1000-MIDI_EXTENT &&
            check_midi(dev->ptt_out.midiiobase))
        printk(KERN_INFO "%s: PTT output: midi port found at address 0x%x\n",
               hfmodem_drvname, dev->ptt_out.midiiobase);
    else {
        if (dev->ptt_out.midiiobase > 0)
            printk(KERN_WARNING "%s: PTT output: no midi port found at address 0x%x\n",
                   hfmodem_drvname, dev->ptt_out.midiiobase);
        dev->ptt_out.midiiobase = 0;
    }
}
Example #2
0
// ==============================================================================
// - main
// ------------------------------------------------------------------------------
int main(void)
{
    // ------------------------- Initialize Hardware

    //PORTB: LEDs

    DDRB = 0x0f;
    PORTB = 0x00;

    // PORTC: Buttons
    DDRC 	= 0x00;		// set all pins to input
    PORTC 	= 0x0f;		// pullups

    // PORTD: 4066 control, interrupt, rx/tx
    DDRD = 0xf2;


    // init UART
    UCSR0B = ( 1 << UCSZ02);
    UCSR0C = /*( 1 << UPM1) | */( 1 << UCSZ01) | ( 1 << UCSZ00 );		// Even Parity, 9 bit, 1 stop bit
    UBRR0H = 0;
    UBRR0L = 249; 												// 5000 baud (F_CPU/16/BAUD - 1)
    //TODO check speed, we're on 20mhz now!!!

    // enable Pinchange Interrupt on PC5 -> PCINT13
    PCICR = (1 << PCIE1);
    PCMSK1 = (1 << PCINT13);

    // enable external interrupt
    /*EICRA = (1 << ISC01) | (1 << ISC00);
    EIMSK = (1 << INT0);*/

    sei();

    tx_state = idle_tx;

    UCSR0B |= (1 << TXEN0); // turn on uart

    select_cam(0);

    unsigned long tt;
    unsigned char idx;

    // ------------------------- Main Loop
    while(1) {
        /*tt++;
        if (tt > 100000) {
        tt = 0;
        idx++;
        idx%=4;
        PORTB = 1 << idx;
        }*/
        wdt_reset();
        check_uart();
        //check_buttons();
    }
    return 0;
}
Example #3
0
// ==============================================================================
// - main
// ------------------------------------------------------------------------------
int main(void)
{
    // ------------------------- Initialize Hardware
    //PORTB: LEDs

    DDRB = 0x0f;
    PORTB = 0x00;

    // PORTC: Buttons
    DDRC 	= 0x00;		// set all pins to input
    PORTC 	= 0x0f;		// pullups

    // PORTD: 4066 control, interrupt, rx/tx, USB
    DDRD = 0xf2;


    // init UART
    UCSR0B = ( 1 << UCSZ02);
    UCSR0C = /*( 1 << UPM1) | */( 1 << UCSZ01) | ( 1 << UCSZ00 );		// Even Parity, 9 bit, 1 stop bit
    UBRR0H = 0;
    UBRR0L = 249; 												// 5000 baud (F_CPU/16/BAUD - 1)

    // enable Pinchange Interrupt on PC5 -> PCINT13
    PCICR = (1 << PCIE1);
    PCMSK1 = (1 << PCINT13);


    usbDeviceConnect();
    usbReset();
    usbInit();

    wdt_enable(WDTO_1S);	// enable watchdog timer

    sei();

    tx_state = idle_tx;

    UCSR0B |= (1 << TXEN0); // turn on uart

    select_cam(0);

    unsigned long tt;
    unsigned char idx;

    // ------------------------- Main Loop
    while(1) {
        wdt_reset();
        usbPoll();			// see if there's something going on on the usb bus
        check_uart();
    }
    return 0;
}
Example #4
0
static void sm_output_open(struct sm_state *sm, const char *ifname)
{
	enum uart u = c_uart_unknown;
	struct parport *pp = NULL;

	sm->hdrv.ptt_out.flags = 0;
	if (sm->hdrv.ptt_out.seriobase > 0 &&
	    sm->hdrv.ptt_out.seriobase <= 0x1000-SER_EXTENT &&
	    ((u = check_uart(sm->hdrv.ptt_out.seriobase))) != c_uart_unknown) {
		sm->hdrv.ptt_out.flags |= SP_SER;
		request_region(sm->hdrv.ptt_out.seriobase, SER_EXTENT, "sm ser ptt");
		outb(0, UART_IER(sm->hdrv.ptt_out.seriobase));
		/* 5 bits, 1 stop, no parity, no break, Div latch access */
		outb(0x80, UART_LCR(sm->hdrv.ptt_out.seriobase));
		outb(0, UART_DLM(sm->hdrv.ptt_out.seriobase));
		outb(1, UART_DLL(sm->hdrv.ptt_out.seriobase)); /* as fast as possible */
		/* LCR and MCR set by output_status */
	}
	sm->pardev = NULL;
	if (sm->hdrv.ptt_out.pariobase > 0) {
		pp = parport_enumerate();
		while (pp && pp->base != sm->hdrv.ptt_out.pariobase) 
			pp = pp->next;
		if (!pp)
			printk(KERN_WARNING "%s: parport at address 0x%x not found\n", sm_drvname, sm->hdrv.ptt_out.pariobase);
		else if ((~pp->modes) & (PARPORT_MODE_PCSPP | PARPORT_MODE_SAFEININT))
			printk(KERN_WARNING "%s: parport at address 0x%x cannot be used\n", sm_drvname, sm->hdrv.ptt_out.pariobase);
		else {
			sm->pardev = parport_register_device(pp, ifname, NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL);
			if (!sm->pardev) {
				pp = NULL;
				printk(KERN_WARNING "%s: cannot register parport device (address 0x%x)\n", sm_drvname, sm->hdrv.ptt_out.pariobase);
			} else {
				if (parport_claim(sm->pardev)) {
					parport_unregister_device(sm->pardev);
					sm->pardev = NULL;
					printk(KERN_WARNING "%s: cannot claim parport at address 0x%x\n", sm_drvname, sm->hdrv.ptt_out.pariobase);
				} else
					sm->hdrv.ptt_out.flags |= SP_PAR;
			}
		}
	}
	if (sm->hdrv.ptt_out.midiiobase > 0 &&
	    sm->hdrv.ptt_out.midiiobase <= 0x1000-MIDI_EXTENT &&
	    check_midi(sm->hdrv.ptt_out.midiiobase)) {
		sm->hdrv.ptt_out.flags |= SP_MIDI;
		request_region(sm->hdrv.ptt_out.midiiobase, MIDI_EXTENT,
			       "sm midi ptt");
	}
	sm_output_status(sm);

	printk(KERN_INFO "%s: ptt output:", sm_drvname);
	if (sm->hdrv.ptt_out.flags & SP_SER)
		printk(" serial interface at 0x%x, uart %s", sm->hdrv.ptt_out.seriobase,
		       uart_str[u]);
	if (sm->hdrv.ptt_out.flags & SP_PAR)
		printk(" parallel interface at 0x%x", sm->hdrv.ptt_out.pariobase);
	if (sm->hdrv.ptt_out.flags & SP_MIDI)
		printk(" mpu401 (midi) interface at 0x%x", sm->hdrv.ptt_out.midiiobase);
	if (!sm->hdrv.ptt_out.flags)
		printk(" none");
	printk("\n");
}
Example #5
0
// ==============================================================================
// - main
// ------------------------------------------------------------------------------
int main(void)
{

	// ------------------------- Initialize Hardware
	//PORTB: LEDs
	
	DDRB = 0x0f;
	PORTB = 0x00;

	// PORTC: Buttons
	DDRC 	= 0x00;		// set all pins to input
	PORTC 	= 0x0f;		// pullups
		
	// PORTD: 4066 control, interrupt, rx/tx, USB
	DDRD = 0xf2;
	
	// timer 0	-> millisecond clock
	ticks 	= 0;
	TCCR0A 	= (1 << WGM01);									// CTC
	TCCR0B 	= (0 << CS02) | (1 << CS01) | (0 << CS00);		// 8 prescaler @ 20Mhz -> 2'500'000 Hz
	TIMSK0 	= (1 << OCIE0A);								// enable interrupt
	OCR0A	= 249;											// 10000 Hz -> 10 ticks / Millisecond

	// init UART
	UCSR0B = ( 1 << UCSZ02); 						
	UCSR0C = /*( 1 << UPM1) | */( 1 << UCSZ01) | ( 1 << UCSZ00 );		// Even Parity, 9 bit, 1 stop bit
	UBRR0H = 0;
	UBRR0L = 249; 												// 5000 baud (F_CPU/16/BAUD - 1)

	// enable Pinchange Interrupt on PC5 -> PCINT13
	PCICR = (1 << PCIE1);
    PCMSK1 = (1 << PCINT13);
	

	usbDeviceConnect();
	usbReset();
    usbInit();

	wdt_enable(WDTO_1S);	// enable watchdog timer

	sei();
	
	tx_state = idle_tx;
	
	UCSR0B |= (1 << TXEN0); // turn on uart
	
	select_cam(0);
	
	unsigned long tt;
	unsigned char idx;
	
	// ------------------------- Main Loop
	while(1) {
        wdt_reset();
		usbPoll();			// see if there's something going on on the usb bus
        check_uart();	
        
        if (millis()-lastTime >= 80) {
        	 check_buttons();
        }
	}
	return 0;
}