예제 #1
0
파일: bsp_init.c 프로젝트: zhiyix/jlydemo
/**
  * @brief  Description 系统初始化
  * @param  None
  * @retval None
  */
void SysInit(void)
{
    FirstScanSysData();
    
//	set_time();
    read_time();
    
    while(LCD_GetFlagStatus(LCD_FLAG_UDR) != RESET); 
	displayTIME(Rtc.Hour,Rtc.Minute);
    showTIME; 
	LCD_UpdateDisplayRequest();
    
	Started_Channel = GetStartChanel(Channel_count);
	StartedChannelForDisplay = Started_Channel;
    
    Sensor1.sensor_infor[0] = 4;
    Sensor1.sensor_infor[1] = 2;
    
    Bat.Voltage_TestTime=11;
    Sensor1.sensor1_str.sensor_type = 1;
    
    Flag.MucReset = 1;
    Flag.IsDisplayRightNow = 1;    
    
    JlyParam.WorkStatueIsStop = 1;
	
	Queue.FlashSectorPoint = 0;
}
예제 #2
0
파일: main.c 프로젝트: Amna2013/stm32-test
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32l1xx_xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32l1xx.c file
     */

  /* LCD GLASS Configuration */
  LCD_Glass_Config();

  /* ADC1 configuration: channel (18 or 31)  and channel (5 or 1b)   */
  ADC_Config();

  /* Configure the STM32L1XX-EVAL KEY Push button */
  STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_EXTI); 
  
#ifdef USE_STM32L152D_EVAL 
  /* Set VALUEUNIT_MILLIAMPERE */
  LCD_GLASS_ValueUnitConfig(VALUEUNIT_MILLIAMPERE);
#endif
  
  /* TIM2 Configuration */
  TIM2_Config();
  /* Request LCD RAM update */
  LCD_UpdateDisplayRequest();

  while (1)
  {   
  }
}
/**
  * @brief  This function writes a char in the LCD RAM.
  * @param  ch: The character to dispaly.
  * @param  point: A point to add in front of char.
  *          This parameter  can be one of the following values:  
  *              @arg POINT_OFF: No point to add in front of char.
  *              @arg POINT_ON: Add a point in front of char.
  * @param  apostrophe: Flag indicating if a apostrophe has to be add in front 
  *                     of displayed character.
  *          This parameter  can be one of the following values:
  *              @arg APOSTROPHE_OFF: No apostrophe to add in back of char.
  *              @arg APOSTROPHE_ON: Add an apostrophe in back of char.
  * @param  position: Position in the LCD of the caracter to write.
  *                   This parameter can be any value in range [0:7].
  * @retval None
  */
void LCD_GLASS_DisplayChar(uint8_t* ch, Point_Typedef point, Apostrophe_Typedef apostrophe, uint8_t position)
{
  /*!< Wait Until the last LCD RAM update finish */
  while(LCD_GetFlagStatus(LCD_FLAG_UDR) != RESET)
  {
  }
  /*!< LCD Write Char */
  LCD_GLASS_WriteChar(ch, point, apostrophe, position);

  /*!< Requesy LCD RAM update */
  LCD_UpdateDisplayRequest();  
}
예제 #4
0
파일: cnp01_lcd.c 프로젝트: 21h/CNP01
// Interrupt for blinking
void lcd_blinker()
{
  //TIM6->SR &= ~TIM_SR_UIF; //厌疣覃忄屐 綦嚆 UIF
  lcd_Set();
  if (LCD_blinkflag)
  {
    //LCD_buf1=LCD1;
    //LCD_buf2=LCD2;
    //LCD_buf3=LCD3;
    LCD1&=LCD_blink1;
    LCD2&=LCD_blink2;
    LCD3&=LCD_blink3;
    LCD_blinkflag=0;
  }
  else
  {
    LCD_blinkflag=1;
  }
  LCD_UpdateDisplayRequest();
}
예제 #5
0
/**
  * @brief  Display the measured voltage on LCD glass.
  * @param  None
  * @retval None
  */
void DisplayVoltage(uint32_t ADCVoltage)
{
  uint32_t Digit1, Digit2, Digit3, Digit4 = 0;

  ADCVoltage = ADCVoltage * 3300;
  ADCVoltage = ADCVoltage / 4095; 
  Digit1 = ADCVoltage / 1000;
  LCD_String[1] = Digit1 + 0x30;
  VoltageDisplay[1] = Digit1 + 0x30;
  Digit2 = (ADCVoltage - (Digit1 * 1000)) / 100;
  LCD_String[2] = Digit2 + 0x30;
  VoltageDisplay[3] = Digit2 + 0x30;
  Digit3 = ((ADCVoltage - ((Digit1 * 1000) + (Digit2 * 100))) / 10);
  LCD_String[3] = Digit3 + 0x30;
  VoltageDisplay[4] = Digit3 + 0x30;
  Digit4 = (ADCVoltage - ((Digit1 * 1000) + (Digit2 * 100) + (Digit3 * 10)));
  LCD_String[4] = Digit4 + 0x30;
  VoltageDisplay[5] = Digit4 + 0x30;

  /*!< Wait Until the last LCD RAM update finish */
  while(LCD_GetFlagStatus(LCD_FLAG_UDR) != RESET)
  {
  }
#ifdef USE_STM32L152_EVAL
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCD_String[1], POINT_ON, APOSTROPHE_OFF, 1);
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCD_String[2], POINT_OFF, APOSTROPHE_OFF, 2);
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCD_String[3], POINT_OFF, APOSTROPHE_OFF, 3);
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCD_String[4], POINT_OFF, APOSTROPHE_OFF, 4);
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCD_String[5], POINT_OFF, APOSTROPHE_OFF, 5);
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCD_String[6], POINT_OFF, APOSTROPHE_OFF, 6);
#endif
  
  /*!< Request LCD RAM update */
  LCD_UpdateDisplayRequest();
}
/**
  * @brief  This function writes a char in the LCD RAM.
  * @param  ptr: Pointer to string to display on the LCD Glass.
  * @retval None
  */
void LCD_GLASS_DisplayString(uint8_t* ptr)
{
  uint32_t i = 0x00;

  /*!< Wait Until the last LCD RAM update finish */
  while(LCD_GetFlagStatus(LCD_FLAG_UDR) != RESET)
  {
  }

  /*!< Send the string character by character on lCD */
  while ((*ptr != 0) & (i < 8))
  {
    /*!< Display one character on LCD */
    LCD_GLASS_WriteChar(ptr, POINT_OFF, APOSTROPHE_OFF, i);
    /*!< Point on the next character */
    ptr++;
    /*!< Increment the character counter */
    i++;
  }
  /*!< Requesy LCD RAM update */
  LCD_UpdateDisplayRequest();
}
예제 #7
0
파일: main.c 프로젝트: Amna2013/stm32-test
/**
  * @brief  Display the IDD measured Value On the LCD Glass.
  * @param  IDD measure
  * @retval None
  */
void DisplayIDDrunmA(uint32_t IDDmeas)
{ 
  /* x  current value*/
  LCDString[0] =((uint8_t)(IDDrunuA / 100000)) + 0x30;
  
  /* Hundreds current value */
  LCDString[1] =((uint8_t)((IDDrunuA % 100000) / 10000)) + 0x30;
  
  /* Tens current value */
  LCDString[2] =((uint8_t)((IDDrunuA % 10000) / 1000)) + 0x30;
  
  /* 1mA current value */
  LCDString[3] =((uint8_t)((IDDrunuA % 1000) / 100)) + 0x30;
  
  /* 0.1 mA current value */
  LCDString[4] =((uint8_t)((IDDrunuA % 100 ) / 10)) + 0x30;
  
  /* 0.01 mA current value */
  LCDString[5] = ((uint8_t)(IDDrunuA % 10)) + 0x30;

  
#ifdef USE_STM32L152_EVAL 
    /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[0], POINT_OFF, APOSTROPHE_OFF, 0);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[1], POINT_OFF, APOSTROPHE_OFF, 1);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[2], POINT_ON, APOSTROPHE_OFF, 2);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[3], POINT_OFF, APOSTROPHE_OFF, 3);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[4], POINT_OFF, APOSTROPHE_OFF, 4);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[5], POINT_OFF, APOSTROPHE_OFF, 5);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar("M", POINT_OFF, APOSTROPHE_OFF, 6);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar("A", POINT_OFF, APOSTROPHE_OFF, 7);
  
#elif defined USE_STM32L152D_EVAL
    /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[0], POINT_OFF, APOSTROPHE_OFF, 0);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[1], POINT_OFF, APOSTROPHE_OFF, 1);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[2], POINT_OFF, APOSTROPHE_OFF, 2);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[3], POINT_ON, APOSTROPHE_OFF, 3);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[4], POINT_OFF, APOSTROPHE_OFF, 4);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[5], POINT_OFF, APOSTROPHE_OFF, 5);
  
    /* Display one character on LCD */
  LCD_GLASS_WriteChar("", POINT_OFF, APOSTROPHE_OFF, 6);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar("", POINT_OFF, APOSTROPHE_OFF, 7);

#endif 
  
  /*!< Request LCD RAM update */
  LCD_UpdateDisplayRequest();
}
예제 #8
0
파일: bsp_adc.c 프로젝트: zhiyix/jlydemo
/**
  * @brief  Description 电池电压检测数据处理
  * @param  无
  * @retval 无
  */
static void Voltage_ADC1config(void)
{
    unsigned char i=0,j=0;
    unsigned int temp=0;
    unsigned int sum=0,adc_temp[vtest_cnt];
    float temp2=0;
    unsigned char        voltage_zhengshu=0;    //电压整数位
    unsigned char        voltage_xiaoshu=0;     //电压小数位
    
    BATTEST_POWER(ON);  //开启电池电压检测电源
    
    for(i=0;i<vtest_cnt;i++)//????
    { 
        /* 由于没有采用外部触发,所以使用软件触发ADC转换 */ 
        ADC_SoftwareStartConv(ADC1);
        Delay_ms(5);    //延时5ms
        adc_temp[i] = Bat.ADC_BatConvertedValue;
    }
    
    BATTEST_POWER(OFF);  //关闭电池电压检测电源
    
    for(i=1;i<=vtest_cnt;i++)//
    for(j=0;j<=vtest_cnt-i;j++)
    if(adc_temp[j]>=adc_temp[j+1])
    {
        temp=adc_temp[j];
        adc_temp[j]=adc_temp[j+1];
        adc_temp[j+1]=temp;
    }

    for(i=0;i<(vtest_cnt-2);i++)//舍弃最大、最小值,求累加和
    { 
        sum=sum+adc_temp[1+i];
    }

    temp2=5.0/4095;
    temp2=temp2*sum;
    temp2=temp2/(vtest_cnt-2);
    temp =(uint16_t)(temp2*100);

    voltage_zhengshu=temp/100;
    voltage_xiaoshu=temp-voltage_zhengshu*100;
    voltage_xiaoshu=((voltage_xiaoshu/10)<<4)+(voltage_xiaoshu%10);
    
    if(Flag.ExPwOn==0)  //没外接电,电池电压检测
    {
        
        if(temp>=400)
            {while(LCD_GetFlagStatus(LCD_FLAG_UDR) != RESET){} showBATT;LCD_UpdateDisplayRequest();}
        else if((temp>=380)&&(temp<400))
            {while(LCD_GetFlagStatus(LCD_FLAG_UDR) != RESET){} showBATT2;LCD_UpdateDisplayRequest();}
        else if((temp>=350)&&(temp<380))
            {while(LCD_GetFlagStatus(LCD_FLAG_UDR) != RESET){} showBATT1;LCD_UpdateDisplayRequest();}
        else if(temp<350)
            {while(LCD_GetFlagStatus(LCD_FLAG_UDR) != RESET){} showBATT0;LCD_UpdateDisplayRequest();}
            
        if(temp<=340)  
            Flag.Low_Voltage = 1;
        else 
            Flag.Low_Voltage = 0;
    }
    else
    {
        if(temp>=390)
        {
            //在外接电下,电压>4.1v,认为充满电,这里置充满电标志位!
            Flag.BatteryFull=1;
        }
        else
        {
            Flag.BatteryFull=0;
        }
    }
}
예제 #9
0
파일: main.c 프로젝트: Amna2013/stm32-test
/**
  * @brief  Display the ADC converted Values on the LCD Glass.
  * @param  data1: VDD voltage.
  * @param  data2: RV3 voltage.
  * @retval None
  */
void DisplayOnLCD(uint16_t data1, uint16_t data2) 
{
  uint16_t rv3voltage=0;
  uint32_t iddrun = 0;

  
#ifdef USE_STM32L152D_EVAL 
  uint8_t LCDString[7]="00V 00";
#elif defined USE_STM32L152_EVAL 
  uint8_t LCDString[9]="00V 00MA";
#endif 

  /* Calculate the current consumption */
#ifdef USE_STM32L152D_EVAL 
  iddrun = (uint32_t) ((uint32_t)(((data1 * 1000 * EVAL_RESISTOR_RATIO) / EVAL_MAX9938_GAIN))\
                           / (uint32_t)(EVAL_RESISTOR_R62));
  
#elif defined USE_STM32L152_EVAL 
  iddrun = (uint32_t) ((uint32_t)(((data1 * 1000 * EVAL_RESISTOR_RATIO) / EVAL_MAX9938_GAIN))\
                           / (uint32_t)(EVAL_RESISTOR_R36));  
#endif 

  /* digit1 value*/
  digit1 = (uint8_t)(iddrun / 1000);
  /* digit2 value */
  digit2 = (uint8_t)((iddrun % 1000) / 100);
  
  /* Fill the LCDString fields with the current Voltage */
#ifdef USE_STM32L152D_EVAL 
  LCDString[5] = (uint8_t)((uint8_t)(digit1) + ASCII_NUM_0);
  LCDString[6] = (uint8_t)((uint8_t)(digit2) + ASCII_NUM_0);
#elif defined USE_STM32L152_EVAL  
  LCDString[4] = (uint8_t)((uint8_t)(digit1) + ASCII_NUM_0);
  LCDString[5] = (uint8_t)((uint8_t)(digit2) + ASCII_NUM_0);
#endif 

  /* Calculate RV3 voltage value*/
  rv3voltage = (uint16_t)((uint32_t)((uint32_t)data2 * (uint32_t)ADC_RATIO) / (uint32_t)1000);
  
  /* digit1 value*/
  digit1 = (uint8_t)(rv3voltage / 1000);
  /* digit2 value */
  digit2 = (uint8_t)((rv3voltage % 1000) / 100);

  /* Fill the LCDString fields with the current Voltage */
  LCDString[0] = (uint8_t)((uint8_t)(digit1) + ASCII_NUM_0);
  LCDString[1] = (uint8_t)((uint8_t)(digit2) + ASCII_NUM_0);
 
  /*!< Wait Until the last LCD RAM update finish */
  while(LCD_GetFlagStatus(LCD_FLAG_UDR) != RESET)
  {
  }
  
#ifdef USE_STM32L152_EVAL  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[0], POINT_ON, APOSTROPHE_OFF, 0);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[1], POINT_OFF, APOSTROPHE_OFF, 1);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[2], POINT_OFF, APOSTROPHE_OFF, 2);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[3], POINT_OFF, APOSTROPHE_OFF, 3);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[4], POINT_ON, APOSTROPHE_OFF , 4);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[5], POINT_OFF, APOSTROPHE_OFF, 5);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[6], POINT_OFF, APOSTROPHE_OFF, 6);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[7], POINT_OFF, APOSTROPHE_OFF, 7);
  
#elif defined USE_STM32L152D_EVAL 
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[0], POINT_OFF, DOUBLEPOINT_OFF, 0);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[1], POINT_ON, DOUBLEPOINT_OFF, 1);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[2], POINT_OFF, DOUBLEPOINT_OFF, 2);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[3], POINT_OFF, DOUBLEPOINT_OFF, 3);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[4], POINT_OFF, DOUBLEPOINT_OFF , 4);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[5], POINT_OFF, DOUBLEPOINT_OFF, 5);
  
  /* Display one character on LCD */
  LCD_GLASS_WriteChar(&LCDString[6], POINT_ON, DOUBLEPOINT_OFF, 6);

#endif 
  
  /* Request LCD RAM update */
  LCD_UpdateDisplayRequest();
}
예제 #10
0
파일: cnp01_lcd.c 프로젝트: 21h/CNP01
void lcd_no_blink()
 {
  lcd_Set();
  LCD_UpdateDisplayRequest();
 }