Ejemplo n.º 1
0
int uiSyncToggle(Ihandle *ih, int state) {
    short *togglePtr = (short*)IupGetAttribute(ih, SYNCED_VALUE);
    InterlockedExchange16(togglePtr, I2S(state));
    return IUP_DEFAULT;
}
static int
imx214_sunny_match_id(
        hwsensor_intf_t* si, void * data)
{
    sensor_t* sensor = I2S(si);
//  hwsensor_board_info_t *board_info = sensor->board_info;
    struct sensor_cfg_data *cdata = (struct sensor_cfg_data *)data;
//    int sensor_index = CAMERA_SENSOR_INVALID;
//    int ret = 0;
//    int camif_id = -1;

    cam_info("%s TODO.", __func__);
#if	0
    if(0 == board_info->gpios[FSIN].gpio) {
		cam_err("%s gpio type[FSIN] is not actived.", __func__);
		ret = -1;
		goto out;
    }

    ret = gpio_request(board_info->gpios[FSIN].gpio, "camif_id");
    if(ret < 0) {
		cam_err("failed to request gpio[%d]", board_info->gpios[FSIN].gpio);
		goto out;
	}
    ret = gpio_direction_input(board_info->gpios[FSIN].gpio);
    if(ret < 0) {
		cam_err("failed to control gpio[%d]", board_info->gpios[FSIN].gpio);
		goto out_gpio;
	}

    ret = gpio_get_value(board_info->gpios[FSIN].gpio);
    if(ret < 0) {
		cam_err("failed to get gpio[%d]", board_info->gpios[FSIN].gpio);
		goto out_gpio;
	} else {
		camif_id = ret;
		cam_notice("%s camif id = %d.", __func__, camif_id);
	}

	if (camif_id != board_info->camif_id) {
		cam_notice("%s camera[%s] module is not match.", __func__, board_info->name);
		board_info->sensor_index = CAMERA_SENSOR_INVALID;
		ret = -1;
	} else {
		cam_notice("%s camera[%s] match successfully.", __func__, board_info->name);
		sensor_index = board_info->sensor_index;
		ret = 0;
	}

out_gpio:
	gpio_free(board_info->gpios[FSIN].gpio);
out:
    cdata->data = sensor_index;
    return ret;
#endif
    cdata->data = sensor->board_info->sensor_index;

    hwsensor_writefile(sensor->board_info->sensor_index,
		sensor->board_info->name);
	return 0;

}
Ejemplo n.º 3
0
int main(void)
{
//    double Datav=123.4;

    str = a;
    int i;

//    char *str_1 = "abc" ;


  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT


  //Timer0
  TA0CCTL0 = CCIE;                          // CCR0 interrupt enabled
  TA0CCR0 = 5000;
  TA0CTL = TASSEL_2 + MC_1 + TACLR;         // SMCLK, upmode, clear TAR

  //GPIO
  P4DIR |= BIT7;                            // Set P4.7 to output direction
  P1DIR |= BIT0;                            // Set P1.0 to output direction
  P1DIR |= 0x3C;
  P3DIR |= BIT5+BIT6;
  P1OUT |= BIT5+BIT4;

  //buttom
  P2REN |= BIT1;
  P2OUT |= BIT1;
  P2IES |= BIT1;
  P2IFG &= ~BIT1;
  P2IE |= BIT1;

  P1REN |= BIT1;
  P1OUT |= BIT1;
  P1IES |= BIT1;
  P1IFG &= ~BIT1;
  P1IE |= BIT1;

  //IIC
  OLED_Init();
  OLED_ShowStr(0,2,"Please Set:",99,2);
//  Delay_ms(100);
//  OLED_Clear(0x00);
//end of IIC

  DMAInit();
  ADCInit();   //启动需要在增加 enable

  //UART
  UART_Init(UARTA0); //bluetooth
  UART_Init(UARTB0); //SPI

  UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt
  //  UCB0IE |= UCRXIE;                         // Enable USCI_B0 RX interrupt

  //SPI
    P2OUT |= BIT5;                            // reset slave
    P2OUT &= ~BIT5;                           // Now with SPI signals initialized,
    for(i=50;i>0;i--);                        // Wait for slave to initialize

    MST_Data = 0x8FFF;                          // Initialize data values
    SLV_Data = 0x00;                          //
    while (!(UCB0IFG&UCTXIFG));               // USCI_B0 TX buffer ready?
  //end of SPI


  __bis_SR_register(LPM3_bits + GIE);       // Enter LPM0, enable interrupts
  while(1)
  {
//    OLED_ShowStr(12,2,(unsigned char *)F2S(Datav,tstr),6,1); //6*8
//    UartTX_Send("Done!\r\n",7);

      if(buttom_fct_flag != 0)
      {
    	  buttom_fct_stc_opt();
    	  buttom_fct_flag = 0;
      }

      if(buttom_fct_flags != 0)
      {
    	  buttom_fct_stcs_opt();
    	  buttom_fct_flags = 0;
      }


//    OLED_ShowStr(0,0,(unsigned char *)F2S(DMA_A1,tstr),8,1); //6*8
      if(fct_stc_flag != 0)
      {
          fct_stc_flag = 0;
          fct_stc_opt();
      }

      if(function!=0) // not off
      {
          ADC12CTL0 |= ADC12SC;   // Start sampling/conversion
      }

      switch(function)
      {
          case 0:
          {
//            OLED_OFF();
              __bis_SR_register(LPM3_bits + GIE);       // Enter LPM3, interrupts enabled;
          }
          break;

          case 1:
          {
              if(mode == 0)
              {
                    if(set_ack_flag == 1)
                    {
//                      OLED_ON();
//                      OLED_Clear(0x00);
                        set_ack_flag = 0;
                        MST_Data = (u16)(Datavin);
                        MST_Data |= 0x8000;
                        SPISend(MST_Data);
                        OLED_ShowStr(0,1,"I:",2,1); //6*8
                        OLED_ShowStr(16,1,(unsigned char *)F2S(Datai,tstr),8,1); //6*8
                        OLED_ShowStr(0,2,"stalls:",7,1); //6*8
                        OLED_ShowStr(42,2,(unsigned char *)I2S(stalls,tstr),6,1); //6*8
                    }
              }
              else   // current_pot
              {
                  Datavin = (double)DMA_A1*4/3.3;
                  MST_Data = (u16)(Datavin*4095/4);
                  MST_Data |= 0x8000;
                  SPISend(MST_Data);
                  I_out = (double)DMA_A2*3.3/4095*10;
                  OLED_ShowStr(0,2,"stalls:",7,1); //6*8
				  OLED_ShowStr(42,2,(unsigned char *)I2S(stalls,tstr),6,1); //6*8
//                OLED_ShowStr(0,2,"I_out:",6,1); //6*8
//                OLED_ShowStr(36,2,(unsigned char *)F2S(I_out,tstr),6,1); //6*8
                  if(!((Pre_A3 - ADC12MEM3)<40 | (ADC12MEM3 - Pre_A3)<40))
                  {
                      OLED_ShowStr(24,6,(unsigned char *)F2S(ADC12MEM3,tstr),4,1); //6*8
                  }
                  Pre_A3 = ADC12MEM3;

              }

          }
          break;

          case 2:
          {
            if(set_ack_flag == 1)
            {
                OLED_ON();
                set_ack_flag = 0;
            }
          }
          break;

          case 3:   //off
          {
//            OLED_OFF();
              //shutdown the circuit
              __bis_SR_register(LPM3_bits + GIE);       // Enter LPM3, interrupts enabled;
          }
          break;

      }//end of function switch;
      OLED_ShowStr(0,4,(unsigned char *)F2S(DMA_A0,tstr),4,1); //6*8
      OLED_ShowStr(0,5,(unsigned char *)F2S(DMA_A1,tstr),4,1); //6*8
      OLED_ShowStr(0,6,(unsigned char *)F2S(DMA_A2,tstr),4,1); //6*8
      OLED_ShowStr(0,7,(unsigned char *)F2S(ADC12MEM3,tstr),4,1); //6*8

//      Delay_ms(200);
      // if(strcmp(str_1,str)==0)
      // {
      //     P1OUT |= BIT0;
      //     UartTX_Send("Great!\r\n",8);
      //     Delay_ms(200);
      // }
      // else P1OUT &= ~BIT0;
  } //end of while

}