PortI2C::PortI2C (uint8_t num, uint8_t rate)
    : Port (num), uswait (rate)
{
    sdaOut(1);
    mode2(OUTPUT);
    sclHi();
}
Beispiel #2
0
void AoAPlug::read_inputs(uint16_t output_arr[]) {
  mode2(INPUT);
  for (uint8_t i=0; i < AOA_INPUTS_NUM; i++) {
    select(i);
    delay(1);
    select(i);
    delay(AOA_SWITCH_DELAY);
    output_arr[i] = anaRead();
  }
}
Beispiel #3
0
void SHT21::connReset() const {
    mode2(OUTPUT);
    clock(0);
    mode(OUTPUT);
    digiWrite(1);
    for (uint8_t i = 0; i < 9; ++i) {
        clock(1);
        clock(0);
    }
    start();
}
void BlinkPlug::ledOff (byte mask) {
    if (mask & 1) {
        mode(INPUT);
        digiWrite(1);
    }
    if (mask & 2) {
        mode2(INPUT);
        digiWrite2(1);
    }
    leds &= ~ mask;
}
void BlinkPlug::ledOn (byte mask) {
    if (mask & 1) {
        digiWrite(0);
        mode(OUTPUT);
    }
    if (mask & 2) {
        digiWrite2(0);
        mode2(OUTPUT);
    }
    leds |= mask;
}
Beispiel #6
0
int main()
{
	uint32_t *fbase, *imageaddr, *graybuffer;
	uint32_t i, j, k;
	float time, fps;
	clock_t t1, t2;

	cp_en(); /* Enable the coprocessor */
	fbase = svga_enable(); /* Configure and enable the svga controller */
	imageaddr = (uint32_t*)STARTADDR; /* Set the address of the first image */

	t1 = clock(); /* Get the start time */

    for (i = 0; i < NFRAMES-1; i++)
    {
    	switch(MODE)
    	{
    		default:
    		case 1: /* Copy images to framebuffer */
    			mode1(fbase, imageaddr);
    			break;
    		case 2: /* Floating point grayscale conversion in software */
    			mode2(fbase, imageaddr);
    			break;
    		/* Add more cases for new modes */
    		case 3: /* Fixed point grayscale conversion in software */
    			mode3(fbase, imageaddr);
    			break;
    		case 4: /* Mode to use the fixed point grayscale coprocessor */
    			mode4(fbase, imageaddr);
    			break;
    		case 5: /* Mode to do the Laplacian edge detection in software  */
    			mode5(fbase, imageaddr);
    			break;
            case 6:
                mode6(fbase, imageaddr);
    		// case 7: /* "Hack" the screen! */
    		// 	hackmode(fbase, imageaddr);
    		// 	break;
    	}

    	imageaddr += f->hactive_video*f->vactive_video/2; /* Move to the next image */
    }

    /* Report the time to process the frames */
    t2 = clock();
    time = (t2 - t1) / CLOCKS_PER_SEC;
    fps = NFRAMES / time;
    printf("FPS: %f\n", fps);
    t1 = t2;


	return 0;
}
Beispiel #7
0
/************ FUNCTION DEFINITIONS ****************/
void modeselect(void)
{
	if(GPIOIntStatus(GPIO_PORTF_BASE,false) & GPIO_INT_PIN_0)
	{
		GPIOIntClear(GPIO_PORTF_BASE,GPIO_PIN_0);
		for(i=0;i<2000;i++);
		if (GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_0)==0)
		{
			mode++;
			if (mode==6)
				mode = 1;
			switch(mode)	//According to mode, initialize peripherals and disable other peripherals
			{
			case 1:	mode2unset(); mode3unset();	mode4unset();	mode5unset();	mode1set();	break;
			case 2: mode1unset(); mode3unset();	mode4unset();	mode5unset();	mode2set();	break;
			case 3: mode2unset(); mode1unset();	mode4unset();	mode5unset();	mode3set();	break;
			case 4: mode2unset(); mode1unset();	mode3unset();	mode5unset();	mode4set();	break;
			case 5: mode2unset(); mode1unset();	mode4unset();	mode3unset();	mode5set();	break;
			}
		}
	}
	if((GPIOIntStatus(GPIO_PORTF_BASE,false)&GPIO_INT_PIN_4)&& (mode==2||mode==5))
	{
		GPIOIntClear(GPIO_PORTF_BASE,GPIO_PIN_4);
		if(!GPIOPinRead(GPIO_PORTF_BASE,GPIO_PIN_4))
		{
			mode2();
			TimerLoadSet(TIMER1_BASE, TIMER_A,SysCtlClockGet()/3);	//Set the Max Value of the timer
			TimerEnable(TIMER1_BASE,TIMER_A);	//Start the timer
		}
		else
		{
			TimerDisable(TIMER1_BASE,TIMER_A);
			fast_flag=0;
		}

	}
}
Beispiel #8
0
void mode()                                                           //Function for mode selection
{
	int j;
  	j=0;
 	menudisplay();
 	lcdcmd(0xC0);
	while(str1[j]!='\0')
  	{
       lcddata(str1[j]);
       j++;
  	}
	delay(10000000);
	while(PORTDbits.RD13==1&&PORTDbits.RD7==1);                           //Wait till any key press
	if(PORTDbits.RD7==0)
	{
	   i++;
	   lcdcmd(0x01);
	}
	else if(PORTDbits.RD13==0)
	{
	   mode2();
	}

}
Beispiel #9
0
int main(void) {
	SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);	//Configure System Clock
//SSD
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);	//Enable Port D
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);	//Enable Port B
	GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE,0x0F);
	GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE,0xFF);
//S1 and S2
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);	//Enable Port F
//Mode 1
	SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);		//Enable ADC0 Module
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);	//Enable Port E
	GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_1);	//Select ADC Function of PE 1
	ADCSequenceConfigure(ADC0_BASE, 2, ADC_TRIGGER_PROCESSOR, 0);	//Configure ADC0 Sequencer
	ADCSequenceStepConfigure(ADC0_BASE, 2, 0, ADC_CTL_CH2 | ADC_CTL_IE | ADC_CTL_END);	//Configure the step of the sequencer
//Mode 2
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);	//Enable TIMER1 Module
	GPIOPinTypeGPIOInput(GPIO_PORTF_BASE,GPIO_PIN_4);	//Set PF4 as Input
	GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);		//Configuring the PF4
	GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_BOTH_EDGES);		//Setting Interrupt to trigger on both edges
	TimerConfigure(TIMER1_BASE,TIMER_CFG_PERIODIC);	//Configure TIMER1 into a Continuous Mode
	TimerIntRegister(TIMER1_BASE, TIMER_A, fast);	//Register interrupt if PF4 pressed for more than 1s
//Mode 3
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER4);	//Enable TIMER4 Module
	SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER0);	//Enable WTIMER0 Module
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);	//Enable Port C
	GPIOPinConfigure(GPIO_PC4_WT0CCP0);
	GPIOPinTypeTimer(GPIO_PORTC_BASE,GPIO_PIN_4);	//Set PC4 as a Timer Capture pin
	TimerIntRegister(TIMER4_BASE,TIMER_A,freqfind);	//Register a timer interrupt for TIMER4
	TimerConfigure(TIMER4_BASE,TIMER_CFG_PERIODIC);	//Configure Timer4 in continuous mode
	TimerConfigure(WTIMER0_BASE,TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_CAP_COUNT);
	TimerControlEvent(WTIMER0_BASE,TIMER_A,TIMER_EVENT_POS_EDGE);	//Configure WTIMER0 for Positive Edge Capture

	IntMasterEnable();
	GPIOPinWrite(GPIO_PORTB_BASE,0xFF,0x00);	//Initialize SSD to 0x00
	GPIOPinWrite(GPIO_PORTD_BASE, 0x0F, 0x00);	//Turn off all the digits of the SSD
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);	//Enable TIMER0 Module
	TimerConfigure(TIMER0_BASE,TIMER_CFG_PERIODIC);	//Configure TIMER0 into a Continuous Mode
	TimerIntRegister(TIMER0_BASE, TIMER_A, ssdmux);	//Register ISR for TIMER0 Interrupt to update SSD
	TimerLoadSet(TIMER0_BASE, TIMER_A,SysCtlClockGet()/3000);	//Set the refresh rate of the SSD
	IntEnable(INT_TIMER0A);
	TimerIntEnable(TIMER0_BASE,TIMER_TIMA_TIMEOUT);	//Enable the timer interrupt
	TimerEnable(TIMER0_BASE,TIMER_A);	//Start the timer

	HWREG(GPIO_PORTF_BASE|GPIO_O_LOCK) = GPIO_LOCK_KEY;
	HWREG(GPIO_PORTF_BASE|GPIO_O_CR) = GPIO_PIN_0;	//Unlock PF0 from the NMI mode
	HWREG(GPIO_PORTF_BASE|GPIO_O_LOCK) = 0;

	ssdset(0);
	mode1set();

	GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0);	//Setting PF0 to Input
	GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);		//Configuring the pins
	GPIOIntRegister(GPIO_PORTF_BASE, modeselect);		//Register Interrupt for Port F with ISR modeselect()
	GPIOIntClear(GPIO_PORTF_BASE, GPIO_PIN_0);		//Clear any existing interrupts
	GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_FALLING_EDGE);		//Setting Interrupt to trigger on falling edges
	GPIOIntEnable(GPIO_PORTF_BASE, GPIO_PIN_0);		//Enable the GPIO Interrupts on Port F
	IntEnable(INT_GPIOF);	//Enable Interrupts on Port F

	while(1){
		switch(mode)	//Select operation according to mode
		{
		case 1: mode1();
				break;
		case 2: ssdsetHex(hex_count);
				if(fast_flag)
				{
					mode2();
					SysCtlDelay(SysCtlClockGet()/300);
				}
				break;
		case 3: mode3(); break;
		case 4: mode1(); break;
		case 5: ssdsetHex(hex_count);
				if(fast_flag)
				{
					mode2();
					SysCtlDelay(SysCtlClockGet()/300);
				} break;
				}
		SysCtlDelay(SysCtlClockGet()/3000);
	}
	return 0;
}
void QLCFixtureMode_Test::load()
{
    QDomDocument doc;

    QDomElement root = doc.createElement("Mode");
    root.setAttribute("Name", "Mode1");
    doc.appendChild(root);

    QDomElement ch1 = doc.createElement("Channel");
    ch1.setAttribute("Number", 0);
    QDomText ch1Text = doc.createTextNode("Channel 1");
    ch1.appendChild(ch1Text);
    root.appendChild(ch1);

    /* Shouldn't appear in the mode since Channel 1 is already added */
    QDomElement ch2 = doc.createElement("Channel");
    ch2.setAttribute("Number", 1);
    QDomText ch2Text = doc.createTextNode("Channel 1");
    ch2.appendChild(ch2Text);
    root.appendChild(ch2);

    QDomElement ch3 = doc.createElement("Channel");
    ch3.setAttribute("Number", 1);
    QDomText ch3Text = doc.createTextNode("Channel 3");
    ch3.appendChild(ch3Text);
    root.appendChild(ch3);

    /* Physical */
    QDomElement phys = doc.createElement("Physical");
    root.appendChild(phys);

    /* Bulb */
    QDomElement bulb = doc.createElement("Bulb");
    bulb.setAttribute("Type", "LED");
    bulb.setAttribute("Lumens", 18000);
    bulb.setAttribute("ColourTemperature", 6500);
    phys.appendChild(bulb);

    /* Unrecognized tag on top level */
    QDomElement foo = doc.createElement("Foo");
    root.appendChild(foo);

    QLCFixtureMode mode(m_fixtureDef);
    QVERIFY(mode.physical().bulbType() != "LED");
    QVERIFY(mode.physical().bulbLumens() != 18000);
    QVERIFY(mode.physical().bulbColourTemperature() != 6500);

    QVERIFY(mode.loadXML(&root) == true);
    QVERIFY(mode.physical().bulbType() == "LED");
    QVERIFY(mode.physical().bulbLumens() == 18000);
    QVERIFY(mode.physical().bulbColourTemperature() == 6500);

    QVERIFY(mode.channels().size() == 2);
    QVERIFY(mode.channels()[0] == m_ch1);
    QVERIFY(mode.channels()[1] == m_ch3);

    QLCFixtureMode mode2(m_fixtureDef, &root);
    QVERIFY(mode2.physical().bulbType() == "LED");
    QVERIFY(mode2.physical().bulbLumens() == 18000);
    QVERIFY(mode2.physical().bulbColourTemperature() == 6500);

    QVERIFY(mode2.channels().size() == 2);
    QVERIFY(mode2.channels()[0] == m_ch1);
    QVERIFY(mode2.channels()[1] == m_ch3);
}
Beispiel #11
0
void main()
{
    OLED_Init();           //初始化oled
    qd=1;
    ftm_pwm_init(FTM0,FTM_CH3,10000,0);
    ftm_pwm_init(FTM0,FTM_CH4,10000,0);
    ftm_pwm_init(FTM2,FTM_CH0,10000,0);
    ftm_pwm_init(FTM2,FTM_CH1,10000,0);
    adc_init (ADC1_SE10);
    adc_init (ADC1_SE11);
    adc_init (ADC1_SE12);
    adc_init (ADC1_SE13);                               //按键初始化
    gpio_init (PTA13, GPI,HIGH);//拨码开关初始化
    gpio_init (PTA19, GPI,HIGH);
    gpio_init (PTA24, GPI,HIGH);
    gpio_init (PTA25, GPI,HIGH);
    gpio_init (PTA26, GPI,HIGH);
    gpio_init (PTA27, GPI,HIGH);
    gpio_init (PTA28, GPI,HIGH);
    gpio_init (PTA29, GPI,HIGH);

    led_init (LED0);
    mpu6050_init();

    lptmr_delay_ms(1000);

    gyro_zero=ad_ave(100);

    gyro_zero1=ad_ave1(100);

    mpu6050_read();

    accel_accel=(accel_x-accel_zero)/16384.0;
    if(accel_accel>1)   accel_accel=1;
    if(accel_accel<-1)  accel_accel=-1;
    angle_fuse=180/pi*(asin(accel_accel));

    accel_accel1=(accel_y-accel_zero1)/16384.0;
    if(accel_accel1>1)   accel_accel1=1;
    if(accel_accel1<-1)  accel_accel1=-1;
    angle_fuse1=180/3.1415926*(asin(accel_accel1));

    pit_init_ms(PIT0, 5);                                //初始化PIT0,定时时间为: 5ms
    set_vector_handler(PIT0_VECTORn ,PIT0_IRQHandler);      //设置PIT0的中断服务函数为 PIT0_IRQHandler
    enable_irq (PIT0_IRQn);                                 //使能PIT0中断

    uart_init(UART3, 115200);
    while(aa<200);   //初始化 1秒


    DIP_switch();
    while(1)
    {


        //display[0]=angle_fuse;
        //display[1]=angle_fuse1;
        display[0]=angle_fuse3;



        oledplay();


        if(flag==1)
            mode1();
        else if (flag==2)
            mode2();
        else if (flag==3)
            mode3();
        else if (flag==4)
            mode4();



        vcan_sendware((unsigned char *)display, 20);

    }
}