Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. void swiec(void);
  2. /* USER CODE END 0 */
  3.  
  4. short int tab[2];
  5. int main(void)
  6. {
  7.  
  8. /* USER CODE BEGIN 1 */
  9.  
  10. /* USER CODE END 1 */
  11.  
  12. /* MCU Configuration----------------------------------------------------------*/
  13.  
  14. /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  15. HAL_Init();
  16.  
  17. /* USER CODE BEGIN Init */
  18.  
  19. /* USER CODE END Init */
  20.  
  21. /* Configure the system clock */
  22. SystemClock_Config();
  23.  
  24. /* USER CODE BEGIN SysInit */
  25.  
  26. /* USER CODE END SysInit */
  27.  
  28. /* Initialize all configured peripherals */
  29. MX_GPIO_Init();
  30. MX_DMA_Init();
  31. MX_ADC_Init();
  32.  
  33. /* USER CODE BEGIN 2 */
  34. HAL_ADC_Start_DMA (&hadc,(uint32_t*)&tab,2);
  35. /* USER CODE END 2 */
  36.  
  37. /* Infinite loop */
  38. /* USER CODE BEGIN WHILE */
  39. while (1)
  40. {
  41. /* USER CODE END WHILE */
  42.  
  43.  
  44. /* USER CODE BEGIN 3 */
  45. //swiec();
  46. /* USER CODE END 3 */
  47. }
  48. }
  49.  
  50. void swiec(void) {
  51. if (tab[0] > tab[1]) {
  52. HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET);
  53. HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_SET);
  54. HAL_Delay(200);
  55. HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_RESET);
  56. HAL_Delay(200);
  57.  
  58. }
  59. else {
  60. HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_RESET);
  61. HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET);
  62. HAL_Delay(200);
  63. HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET);
  64. HAL_Delay(200);
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement