Esempio n. 1
0
/**
  * @brief  Manage the activity on sensors when touched/released (example)
  * @param  None
  * @retval None
  */
void ProcessSensors(void)
{
  uint16_t Max_Value = 256/(9-TSLPRM_LINROT_RESOLUTION);

  uint16_t Message[6];  
  uint32_t percent_value;
  Message[0] = ' ';
  Message[1] = ' ';
  Message[2] = ' ';
  /*Add "%" in message*/ 
  Message[3] = '°' ;
  Message[4] = '/' ;
  Message[5] = '%' ;

    if (!process_sensor) 
  {
    /*Display message*/
    LCD_GLASS_DisplayStrDeci(Message);  
    return;
  }
  
  /* get Slider position and convert it in percent*/
  percent_value = MyLinRots[0].p_Data->Position ;
  percent_value *= 10000;
  percent_value /= Max_Value;
  /*Convert percent value in char and store it in message*/    
  convert_into_char(percent_value,Message);
  /*Add "%" in message*/ 
  Message[3] = '°' ;
  Message[4] = '/' ;
  Message[5] = '%' ;
  /*Display message*/
  LCD_GLASS_DisplayStrDeci(Message);  
   
}
void LCDPrint(char *fmt, ...)
{

    char buffer[80];
    char *a=buffer;
    int cnt;


    va_list argptr;
    va_start(argptr, fmt);
    cnt = vsprintf(buffer,(char *)fmt, argptr);
    va_end(argptr);

   	strupr(buffer);
	
		 strcat(buffer,"\n");
		UART1_Write(buffer, strlen(buffer));
	/*
	BAR0_ON;
  BAR1_ON;
  BAR2_ON;
  BAR3_ON;	
	*/
	for(i=0;i<6;i++)
	   tab[i]=buffer[i];
	
	
  LCD_GLASS_DisplayStrDeci(tab);
}
Esempio n. 3
0
/**
  * @brief  Run auto test
  * @caller main 
  * @param None
  * @retval None
  */ 
void auto_test(void)
{
  uint16_t tab[6]={0x20,0x20,0x20,0x20,0x20,0x20};
  
  Auto_test = TRUE;
	
	/* Switch off leds*/
  GPIO_LOW(LED_GREEN_PORT,LED_GREEN_PIN);	
  GPIO_LOW(LED_BLUE_PORT,LED_BLUE_PIN);		
  
  /* To display version */
  LCD_GLASS_DisplayString(" TEST ");
  delay_ms(150);
  STR_VERSION;
  LCD_GLASS_DisplayStrDeci(tab);
  delay_ms(200);
			
	/* And launch the tests*/
  test_LSE();
  test_vdd();
  test_icc_Run();
  test_icc_HALT();
  test_icc_LP();
  
  Auto_test = FALSE;

  /* Infinite loop: Press reset button at the end of test for exit*/
  while (1)
  {
    LCD_GLASS_ScrollSentence("TEST OK ",1,SCROLL_SPEED);
    KeyPressed = FALSE;
  }
}
Esempio n. 4
0
/**
  * @brief Function to measure VDD
  * @caller main
  * @param None   
  * @retval Vdd value in mV
  */
uint16_t Vref_measure(void)
{
  uint16_t tab[6];	
  uint16_t Vdd_mV ;
  
  Vdd_mV = (uint16_t)Vdd_appli();

  convert_into_char (Vdd_mV, tab);
	
  /* To add unit and decimal point  */
  tab[5] = 'V';
  tab[4] = ' ';
  tab[1] |= DOT; /* To add decimal point for display in volt */
  tab[0] = ' ';
	
  LCD_GLASS_DisplayStrDeci(tab);

  return Vdd_mV;
}
Esempio n. 5
0
/**
  * @brief this functions displays a temperature measurement on the LCD screen.
	* @par data_sensor : temperature measurement
  * @retval none
  */
static void User_DisplayOneTemperature (uint8_t data_sensor)
{
uint16_t 	TempChar16[6];
	
	TempChar16[5] = 'C';
	TempChar16[4] = ' ';
	// check if the temperature is negative
	if ((data_sensor & 0x80) != 0)
	{
		data_sensor = (~data_sensor) +1;
		TempChar16[1] = '-';
	}
	else 
		TempChar16[1] = ' ';							
	
	TempChar16[3] = (data_sensor %10) + 0x30 ;
	TempChar16[2] = (data_sensor /10) + 0x30;
	TempChar16[0] = ' ';
	LCD_GLASS_DisplayStrDeci(TempChar16);		
}
Esempio n. 6
0
/**
  * @brief funtion to display the current in µA
  * @caller several funcions
  * @param Current value.
  * @retval none
  */ 
void display_MuAmp (uint16_t Current)
{
  uint16_t tab[6];
          
  convert_into_char((int)Current, tab);
  tab[5] = 'A';
  tab[4] = 'µ';
		
/* Test the significant digit for displays 3 or 4 digits*/
  if ( tab[0] != '0')
  {
    tab[1] |= DOT; /* To add decimal point */
  }  else  {
    /* To shift for suppress '0' before decimal */
    tab[0] = tab[1] | DOT ;	
    tab[1] = tab[2] ;
    tab[2] = tab[3] ;		
    tab[3] = ' ';
  }
	
  LCD_GLASS_DisplayStrDeci(tab);
}
Esempio n. 7
0
/**
  * @brief funtion Current measurement in RUN mode
  * @caller main and test_icc_RUN
  * @param none
  * @retval Current (mA)
  */ 
float Icc_measure_RUN(void)
{
  float Run_Conso;
  uint16_t MeasurINT;
  uint16_t tab[6];	
	
  MeasurINT = ADC_Icc_Test(MCU_RUN);
  
  Run_Conso = MeasurINT * Vdd_appli()/ADC_CONV;
  Run_Conso *= 10L; 
  
  convert_into_char((int)(Run_Conso*10), tab);

  /* To add unit and decimal point  */
  tab[5] = 'A';
  tab[4] = 'm';
  tab[3] = ' ';
  tab[0] |= DOT; /* To add decimal point for display in volt */

  LCD_GLASS_DisplayStrDeci(tab);
	
  return (Run_Conso);
}
Esempio n. 8
0
/**
  * @brief main entry point.
  * @par Parameters None
  * @retval void None
  * @par Required preconditions: None
  */
void main(void)
{ 
uint8_t PayloadLength,
				data_sensor,
				*bufMessage;
		
	/* deinit I/O ports */
	DeInitClock();
	DeInitGPIO();
	
	/* Select HSI as system clock source */
	#ifdef USE_HSI
		CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_HSI);
		CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_16);	
	 #else
		CLK_SYSCLKSourceSwitchCmd(ENABLE);
		/* Select 2MHz HSE as system clock source */
		CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_HSE);
		CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_4);	
		CLK_HSICmd(DISABLE);
	#endif

	// Initializes the LCD glass 
  LCD_GLASS_Init();

	
	/* LED button init: GPIO set in push pull */
	GPIO_Init( LED_GPIO_PORT, LED_GPIO_PIN, GPIO_Mode_Out_PP_Low_Fast);
	// set to 0 
	GPIOE->ODR &= ~LED_GPIO_PIN;
	
	/* USER button init: GPIO set in input interrupt active mode */
  GPIO_Init( BUTTON_GPIO_PORT, USER_GPIO_PIN, GPIO_Mode_In_FL_IT);
	EXTI_SetPinSensitivity(EXTI_Pin_7, EXTI_Trigger_Falling);

  //* Init Bar on LCD all are OFF
  BAR0_OFF;
  BAR1_OFF;
  BAR2_OFF;
  BAR3_OFF;	
	
	enableInterrupts();
	
  
  //* At power on VDD diplays 
	bufMessage = NDEFmessage;
	
	if (EEMenuState > STATE_TEMPMEAS) 
		EEMenuState = STATE_CHECKNDEFMESSAGE;
		
	FLASH_Unlock(FLASH_MemType_Data );

	
	state_machine = EEMenuState ; 
	
	delayLFO_ms (1);
	
	if (EEInitial == 0)
	{
			User_WriteFirmwareVersion ();
			EEInitial =1;
	}
	
  while (1)
  {
    
    switch (state_machine)
    {
			  
				case STATE_VREFF:
					// measure the voltage available at the output of the M24LR04E-R

					Vref_measure();
					delayLFO_ms (2);
					//turn on led
					GPIO_SetBits(GPIOE, GPIO_Pin_6);
			
        break;
				
				case STATE_VBIO:
				//measure the output voltage of biosensor through Pin 7 Port E
				
					CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, ENABLE);
						ADC_DeInit(ADC1);
					ADC_VrefintCmd(ENABLE);
					delay_10us(3);
					GPIO_DeInit(GPIOE);
					GPIO_Init(GPIOE,GPIO_Pin_7 ,/*GPIO_Mode_In_FL_No_IT*/GPIO_Mode_In_PU_No_IT);
					ADC_Cmd(ADC1, ENABLE);
					
					ADC_Init(ADC1, ADC_ConversionMode_Single,ADC_Resolution_12Bit, ADC_Prescaler_1);
					
					ADC_SamplingTimeConfig(ADC1, ADC_Group_FastChannels, ADC_SamplingTime_9Cycles);
					ADC_ChannelCmd(ADC1, ADC_Channel_3, ENABLE);
					delay_10us(3); // Important delay
					res = 0;
					res_2 = 0;
					i=0;
					for(i=8; i>0; i--)
						{
						/* start ADC convertion by software */
							ADC_SoftwareStartConv(ADC1);
						/* wait until end-of-covertion */
							while( ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == 0 );
						/* read ADC convertion result */
							res += ADC_GetConversionValue(ADC1);
						}
					/* de-initialize ADC*/ 
					ADC_VrefintCmd(DISABLE);

					ADC_DeInit(ADC1);
 
					/* disable SchmittTrigger for ADC_Channel_24, to save power */
					ADC_SchmittTriggerConfig(ADC1, ADC_Channel_3, DISABLE);
	
					CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, DISABLE);
					ADC_ChannelCmd(ADC1, ADC_Channel_3, DISABLE);
					res = res>>3;
					P_VREFINT_Factory = VREFINT_Factory_CONV_ADDRESS;
					
					
					#ifdef VREFINT_FACTORY_CONV
						if ((*P_VREFINT_Factory>VREFINT_Factory_CONV_MIN ) && (*P_VREFINT_Factory<VREFINT_Factory_CONV_MAX ))
						{
							/* If the value exists:
							Adds the hight byte to FullVREF_FACTORY */
							FullVREF_FACTORY = VREFINT_Factory_CONV_MSB;
							FullVREF_FACTORY += *P_VREFINT_Factory;
							res_2 = (float)(FullVREF_FACTORY*VDD_FACTORY);
							res_2 /= res;
							} else {
											res_2 = (VREF/res) * ADC_CONV; // usally res>>3
											}
											#else
										/* We use the theorcial value */
											res_2 = (VREF/res) * ADC_CONV;
												#endif
						/* Vdd_appli in mV */  
						res_2*= 1000L;
					

						convert_into_char (res_2, tab);
	
							/* To add unit and decimal point  */
						tab[5] = 'V';
						tab[4] = ' ';
						tab[1] |= DOT; /* To add decimal point for display in volt */
						tab[0] = ' ';

						LCD_GLASS_DisplayStrDeci(tab);
						delayLFO_ms (2);
						
					
					//LCD_GLASS_DisplayString("V BIO");
					
					break;
			
			
			
			
        case STATE_CHECKNDEFMESSAGE:
				
						// read the NDEF message from the M24LR04E-R EEPROM and display it if it is found 				
					if (User_ReadNDEFMessage (&PayloadLength) == SUCCESS)						
						User_DisplayMessage (bufMessage,PayloadLength);
	//					User_DisplayMessageActiveHaltMode (PayloadLength);
					else 
						User_DisplayMessage(ErrorMessage,20);		
		
	
        break;
				
				case STATE_TEMPMEAS:
						
						// read the ambiant tempserature from the STTS751
						User_GetOneTemperature (&data_sensor);
						// display the temperature
						User_DisplayOneTemperature (data_sensor);
			
						delayLFO_ms (2);
						
				break;
			
			break;
  
        /* for safe: normaly never reaches */ 			
        default:
					LCD_GLASS_Clear();
					LCD_GLASS_DisplayString("Error");
					state_machine = STATE_VREFF;
        break;
      }
    
		
    }
}