Ejemplo n.º 1
0
/**
  * @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_stm32f4xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */     

  /* Configure MEMS */
  MEMS_Config();

  /* TIM4 config pins and PWM */
  TIM_Config();

  while (1)
  {
  }
}
Ejemplo n.º 2
0
/**
	 * @brief Main thread of computation running in superloop to update sensor data and transmit
	 * and also subsequently run logic for PWM LED display and double tap detection
	 * @param void
   */
int main(void){	
		
	/* INITIALIZE SYSTEM CLOCK AND PERIPHERALS */
  HAL_Init();
  SystemClock_Config();	
	SPI_Init1();
	MEMS_Config();
	MEMS_Config_IT();
	ADC_Config();
	LED_Config();
	PWM_Config();
	
	/* CONFIG FOR PWM */
	#ifdef LED_SPEED_SLOWER
		speed = 1500;
	#endif

	#ifdef LED_SPEED_SLOW
		speed = 1000;
	#endif

	#ifdef LED_SPEED_MEDIUM
		speed = 800;
	#endif

	#ifdef LED_SPEED_FAST
		speed = 400;
	#endif

	#ifdef LED_SPEED_FASTER
		speed = 200;
	#endif			
	
	#ifdef LED_ALL_ON
		speed = 100;
	#endif
	
	/* CONFIG FOR DOUBLE TAP */
	counter2 = 0;
	thresh1 = 1300;
	assert1 = 0;
	assert2 = 0;
	assertFall = 0;
	assertRise2 = 0;
	assertDoubleTap = 0;
	
	/* BEGIN SUPERLOOP */
	while(1){
		
		/* SET SAMPLING DELAY FOR SENSORS */
		if(interrupt != 0){
			interrupt = 0;
			get_readings();			
		}		
		
		/* TRANSMIT SENSOR DATA TO MASTER */
		HAL_SPI_Transmit(&SpiHandle_2, txBuffer, 4, 10000);				
		
		/* LOGIC FOR IMPLEMENTING PWM DISPLAY LED */
		pwm_display();		
		
		/* LOGIG FOR IMPLEMENTING DOUBLE TAP DETECTION */
		double_tap();
	}
}