Пример #1
0
/**
  ******************************************************************************
  * @brief Main function.
  * @par Parameters:
  * None
  * @retval void None
  * @par Required preconditions:
  * None
  ******************************************************************************
  */
void main(void)
{

  /* Configures clocks */
  CLK_Configuration();

  /* Configures GPIOs */
  GPIO_Configuration();

  /* Initialize Touch Sensing library */
  TSL_Init();

	/* Initialize all the Touch Sensing keys */
  ExtraCode_Init();

  /* Start the 100ms timebase Timer */
  TSL_Tick_Flags.b.User_Start_100ms = 1;

  for (;;)
  {
    /* User code */
    ExtraCode_StateMachine();

	  /* Main function of the Touch Sensing library */
    TSL_Action();

  }

}
Пример #2
0
/**
  * @brief Example main entry point.
  * @par Parameters:
  * None
  * @retval 
  * None
  */
void main(void)
{

    u8 i = 0;
		u16 Timer2Count;

    /* Configuration of the GPIO*/
		GPIO_Configuration();
		
		/* Clock divider to HSI/1 */
    CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);

    /* BEEP calibration */
    BEEP_LSICalibrationConfig(LSIMeasurment());
		
		/* TS Library Initialisation */
		TSL_Init();

    /* TS Application Initialisation */
		ExtraCode_Init();

		/* Tim2 Configuration */
		InitializeTim2();

    while (1)
    {
			ExtraCode_StateMachine();
			TSL_Action();
			BeepDriver_Action();
			//SubCounterSounds();
    }

}
Пример #3
0
/**
  * @brief  Initialize the STMTouch Driver
  * @param  None
  * @retval None
  */
void tsl_user_Init(void)
{
  TSL_obj_GroupInit(&MyObjGroup); /* Init Objects */
  
  TSL_Init(MyBanks); /* Init acquisition module */
  
  tsl_user_SetThresholds(); /* Init thresholds for each object individually (optional) */
}
Пример #4
0
/**
  * @brief  Initialize the STMTouch Driver
  * @param  None
  * @retval None
  */
void TSL_user_Init(void)
{
#if TSLPRM_USE_SHIELD == 0
  TSL_user_InitGPIOs();
#endif

  TSL_obj_GroupInit(&MyObjGroup); // Init Objects
  
  TSL_Init(MyBanks); // Init timing and acquisition modules
  
  TSL_user_SetThresholds(); // Init thresholds for each object individually
}
Пример #5
0
/**
  * @brief  Initialize the STMTouch Driver
  * @param  None
  * @retval None
  */
void TSL_user_Init(void)
{
#if TSLPRM_TSC_GPIO_CONFIG == 0    
  /* Automatic GPIO configuration not selected:
   This function must be created by the user to initialize the Touch Sensing GPIOs. */
  TSL_user_InitGPIOs(); 
#endif
  
  TSL_obj_GroupInit(&MyObjGroup); /* Init Objects */
  
  TSL_Init(MyBanks); /* Init timing and acquisition modules */
  
}
Пример #6
0
/**
  * @brief  Initialize the STMTouch Driver
  * @param  None
  * @retval None
  */
void tsl_user_Init(void)
{
  TSL_obj_GroupInit(&MyObjGroup); /* Init Objects */
  
  TSL_Init(MyBanks); /* Init acquisition module */
  
  tsl_user_SetThresholds(); /* Init thresholds for each object individually (optional) */

  /* Configure first bank and start acquisition in Interrupt mode */
  idx_bank = 0;
  TSL_acq_BankConfig(idx_bank);
  TSL_acq_BankStartAcq_IT();
}
Пример #7
0
int main(void)
{ 
    bool StanbyWakeUp ;
    float Current_STBY;
  
 /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32l1xx_md.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32l1xx.c file
     */ 
  
    Int_CurrentSTBY = Current_Measurement();
  
    /* Check if the StandBy flag is set */
    if (PWR_GetFlagStatus(PWR_FLAG_SB) != RESET)
    {
        /* System resumed from STANDBY mode */
        /* Clear StandBy flag */
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR,ENABLE);
        PWR_ClearFlag(PWR_FLAG_SB); 
        
        StanbyWakeUp = TRUE;
    
    } else
    {
        StanbyWakeUp = FALSE;    
    } 

    PWR_PVDCmd(DISABLE);
    
    RCC_Configuration();
    
    PWR_VoltageScalingConfig(PWR_VoltageScaling_Range1);
    
    /* Wait Until the Voltage Regulator is ready */
    while (PWR_GetFlagStatus(PWR_FLAG_VOS) != RESET) ;
     
    /* Init I/O ports */
    Init_GPIOs ();
    
    /* Initializes ADC */
    ADC_Icc_Init();
    
    enableInterrupts();	
    
    /* Warning ! in TSL Init the sysTick interrupt is setted to:
    SysTick_Config(RCC_Clocks.HCLK_Frequency / 2000 ---> 500 µs*/
    
    /* Init Touch Sensing configuration */  
    TSL_Init();
    
    sMCKeyInfo[0].Setting.b.IMPLEMENTED = 1;
    sMCKeyInfo[0].Setting.b.ENABLED = 1;
    sMCKeyInfo[0].DxSGroup = 0x00; 
 
    /* Initializes the LCD glass */
    LCD_GLASS_Init();
  
      
      while (1)
    {
        
        switch( State ) 
        {
            case 0:
                //LED3 off and LED4 off
                blink = 0;
                GPIOB_ODR_value = 0x00000000;
                ptr_PORTB->GPIOx_ODR = GPIOB_ODR_value;
                break;
            case 1:
                //LED3 on and LED4 off
                blink = 0;
                GPIOB_ODR_value = 0x00000080;
                ptr_PORTB->GPIOx_ODR = GPIOB_ODR_value;
                break;
            case 2:
                //LED3 off and LED4 on
                blink = 0;
                GPIOB_ODR_value = 0x00000040;
                ptr_PORTB->GPIOx_ODR = GPIOB_ODR_value;
                break;
            case 3:
                //LED3 and LED4 blink with 2 second period
                blink = 1;
                break;
        }    
        
        if(blink == 1)
        {
          GPIOB_ODR_value = 0x000000C0;
          ptr_PORTB->GPIOx_ODR = GPIOB_ODR_value;
          Delay(100);
          GPIOB_ODR_value = 0x00000000;
          ptr_PORTB->GPIOx_ODR = GPIOB_ODR_value;
          Delay(100);
          
        }
        
    }
    
    
    return(0);
}		
Пример #8
0
void Tsense_to_default_config(void)
{
	uint8_t i;
	// Enable Comparator clock
  	//RCC_APB1PeriphClockCmd(RCC_APB1Periph_COMP, ENABLE);
	/* Init TSL RC */
	TSL_Init();

	#if NUMBER_OF_SINGLE_CHANNEL_KEYS > 0
	for (i = 0; i < NUMBER_OF_SINGLE_CHANNEL_KEYS; i++)
	{
		sSCKeyInfo[i].Setting.b.IMPLEMENTED = 1;
		sSCKeyInfo[i].Setting.b.ENABLED = 1;
		sSCKeyInfo[i].DxSGroup = 0x01;
	}
	#endif


	//Light
	sSCKeyInfo[1].DetectThreshold = 138; //38
	sSCKeyInfo[1].EndDetectThreshold = 138;
	sSCKeyInfo[1].RecalibrationThreshold = -8;
	//Minus
	sSCKeyInfo[3].DetectThreshold =288;//99
	sSCKeyInfo[3].EndDetectThreshold =288;
	sSCKeyInfo[3].RecalibrationThreshold =-8;
	//Plus
	sSCKeyInfo[0].DetectThreshold = 168;//88
	sSCKeyInfo[0].EndDetectThreshold = 168;
	sSCKeyInfo[0].RecalibrationThreshold = -8;
	//Power
	sSCKeyInfo[2].DetectThreshold = 188;
	sSCKeyInfo[2].EndDetectThreshold = 188;
	sSCKeyInfo[2].RecalibrationThreshold = -8;

	//sSCKeyInfo[1].DetectThreshold = 93;
	//sSCKeyInfo[1].EndDetectThreshold = 99;
	//sSCKeyInfo[1].RecalibrationThreshold = -22;

	// Change thresholds of specific keys
	/*
	sSCKeyInfo[0].DetectThreshold = 99;
	sSCKeyInfo[0].EndDetectThreshold = 96;
	sSCKeyInfo[0].RecalibrationThreshold = -22;

	sSCKeyInfo[1].DetectThreshold = 99;
	sSCKeyInfo[1].EndDetectThreshold = 96;
	sSCKeyInfo[1].RecalibrationThreshold = -22;

	sSCKeyInfo[2].DetectThreshold = 88;
	sSCKeyInfo[2].EndDetectThreshold = 86;
	sSCKeyInfo[2].RecalibrationThreshold = -22;

	sSCKeyInfo[3].DetectThreshold = 99;
	sSCKeyInfo[3].EndDetectThreshold = 96;
	sSCKeyInfo[3].RecalibrationThreshold = -22;

	sSCKeyInfo[4].DetectThreshold = 79;
	sSCKeyInfo[4].EndDetectThreshold = 76;
	sSCKeyInfo[4].RecalibrationThreshold = -22;
	*/
}
Пример #9
0
int main(void)
{ 
    bool StanbyWakeUp ;
    float Current_STBY;
  
 /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32l1xx_md.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32l1xx.c file
     */ 
  
    Int_CurrentSTBY = Current_Measurement();
  
    /* Check if the StandBy flag is set */
    if (PWR_GetFlagStatus(PWR_FLAG_SB) != RESET)
    {
        /* System resumed from STANDBY mode */
        /* Clear StandBy flag */
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR,ENABLE);
        PWR_ClearFlag(PWR_FLAG_SB); 
        
        StanbyWakeUp = TRUE;
    
    } else
    {
        StanbyWakeUp = FALSE;    
    } 

    PWR_PVDCmd(DISABLE);
    
    RCC_Configuration();
    
    PWR_VoltageScalingConfig(PWR_VoltageScaling_Range1);
    
    /* Wait Until the Voltage Regulator is ready */
    while (PWR_GetFlagStatus(PWR_FLAG_VOS) != RESET) ;
     
    /* Init I/O ports */
    Init_GPIOs ();
    
    /* Initializes ADC */
    ADC_Icc_Init();
    
    enableInterrupts();	
    
    /* Warning ! in TSL Init the sysTick interrupt is setted to:
    SysTick_Config(RCC_Clocks.HCLK_Frequency / 2000 ---> 500 µs*/
    
    /* Init Touch Sensing configuration */  
    TSL_Init();
    
    sMCKeyInfo[0].Setting.b.IMPLEMENTED = 1;
    sMCKeyInfo[0].Setting.b.ENABLED = 1;
    sMCKeyInfo[0].DxSGroup = 0x00; 
 
    /* Initializes the LCD glass */
    LCD_GLASS_Init();
  
    // EECE 337 Code -- Start
    int N;
    int f;
    
    char str[8];   
    
    N = 10;
    
    // Call to original factorial algorithm in C - for debugging
    //f = factorial_orig( N );
    
    factorial(&f, N);
    
    // Copy result to f
    sprintf (str, "%X", f);
    
    //printf( "factorial of %i is %i\n", N, f);
    LCD_GLASS_DisplayString(str);
    
    // EECE 337 Code -- End
    
    return(0);
}		
Пример #10
0
int main(void)
{ 
    bool StanbyWakeUp ;
    float Current_STBY;
  
 /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32l1xx_md.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32l1xx.c file
     */ 
  
    Int_CurrentSTBY = Current_Measurement();
  
    /* Check if the StandBy flag is set */
    if (PWR_GetFlagStatus(PWR_FLAG_SB) != RESET)
    {
        /* System resumed from STANDBY mode */
        /* Clear StandBy flag */
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR,ENABLE);
        PWR_ClearFlag(PWR_FLAG_SB); 
        
        StanbyWakeUp = TRUE;
    
    } else
    {
        StanbyWakeUp = FALSE;    
    } 

    PWR_PVDCmd(DISABLE);
    
    RCC_Configuration();
    
    PWR_VoltageScalingConfig(PWR_VoltageScaling_Range1);
    
    /* Wait Until the Voltage Regulator is ready */
    while (PWR_GetFlagStatus(PWR_FLAG_VOS) != RESET) ;
     
    /* Init I/O ports */
    Init_GPIOs ();
    
    /* Initializes ADC */
    ADC_Icc_Init();
    
    enableInterrupts();	
    
    /* Warning ! in TSL Init the sysTick interrupt is setted to:
    SysTick_Config(RCC_Clocks.HCLK_Frequency / 2000 ---> 500 µs*/
    
    /* Init Touch Sensing configuration */  
    TSL_Init();
    
    sMCKeyInfo[0].Setting.b.IMPLEMENTED = 1;
    sMCKeyInfo[0].Setting.b.ENABLED = 1;
    sMCKeyInfo[0].DxSGroup = 0x00; 
 
    /* Initializes the LCD glass */
    LCD_GLASS_Init();
  
    // EECE 337 Code -- Start
        
    char str[50];                       // Used to display results
    unsigned int delay_time = 5000;      // Will delay for 5 seconds
    const unsigned int numItems = 10;          // # items in array
	int MyArray[10] = { 365, 245, -499, 0, 23, 8, 200, -4, -50, 25 };

	int minimum = 0;                    // Will hold minimum value
	int maximum = 0;                    // Will hold maximum value
    
    // Call Function to obtain Min and Max values from array
	min_max(MyArray, numItems, &minimum, &maximum);	
    
    // Copy min result to str
    sprintf (str, "%d", minimum);
    
    // Display on LCD
    LCD_GLASS_DisplayString(str);
    
    // Pause for 5 seconds
    Delay(delay_time);
    
    // Clear LCD
    LCD_GLASS_Clear();
    
    // Copy max result to str
    sprintf (str, "%d", maximum);
    
    // Display on LCD
    LCD_GLASS_DisplayString(str);
    
    // Pause for 5 seconds
    Delay(delay_time);
    
    // EECE 337 Code -- End
    
    return(0);
}