Pazartesi, 24 Nisan 2017 12:10

MyBoard ARM STM32F303 Deney Kartı İlk Kullanımı Özel

Yazan
Öğeyi Oyla
(0 oy)

Bir tarla sulama sistemi yapılacaktır. Bu sistemde 8 adet nem sensörü ve 1 adet sulama motoru mevcuttur. Nem sensörü 1 veya 0 verisi göndermektedir. Herhangi 4 adet nem sensöründen 1 verisi geldiğinde tarlanın kuru olduğunu anlaşılacaktır ve motora çalışma komutu olarak 1 verisi gönderilerek motor çalıştırılacaktır. Yukarıda anlatılan düzeneği çalıştıran programı yazınız.

Aşağıdaki Kodlar Proje içerisinde inc klasörü içerisine oluşturulmuş

 

define_io.h

/*
 * define_io.h
 *
 *  Created on: 24 Nis 2017
 *      Author: BARIS
 */

#ifndef DEFINE_IO_H_
#define DEFINE_IO_H_

#define Red_1_Port    GPIOB
#define Red_1_Pin     GPIO_Pin_3
#define Red_1_ON      GPIO_SetBits(Red_1_Port,Red_1_Pin)
#define Red_1_OFF     GPIO_ResetBits(Red_1_Port,Red_1_Pin)
#define Red_1_Toggle  GPIO_ToggleBits(Red_1_Port,Red_1_Pin)

#define Red_2_Port    GPIOD
#define Red_2_Pin     GPIO_Pin_7
#define Red_2_ON      GPIO_SetBits(Red_2_Port,Red_2_Pin)
#define Red_2_OFF     GPIO_ResetBits(Red_2_Port,Red_2_Pin)
#define Red_2_Toggle  GPIO_ToggleBits(Red_2_Port,Red_2_Pin)

#define Red_3_Port    GPIOB
#define Red_3_Pin     GPIO_Pin_5
#define Red_3_ON      GPIO_SetBits(Red_3_Port,Red_3_Pin)
#define Red_3_OFF     GPIO_ResetBits(Red_3_Port,Red_3_Pin)
#define Red_3_Toggle  GPIO_ToggleBits(Red_3_Port,Red_3_Pin)

#define Blue_1_Port    GPIOB
#define Blue_1_Pin     GPIO_Pin_4
#define Blue_1_ON  	   GPIO_SetBits(Blue_1_Port,Blue_1_Pin)
#define Blue_1_OFF     GPIO_ResetBits(Blue_1_Port,Blue_1_Pin)
#define Blue_1_Toggle  GPIO_ToggleBits(Blue_1_Port,Blue_1_Pin)

#define Blue_2_Port    GPIOB
#define Blue_2_Pin     GPIO_Pin_7
#define Blue_2_ON      GPIO_SetBits(Blue_2_Port,Blue_2_Pin)
#define Blue_2_OFF     GPIO_ResetBits(Blue_2_Port,Blue_2_Pin)
#define Blue_2_Toggle  GPIO_ToggleBits(Blue_2_Port,Blue_2_Pin)

#define Blue_3_Port    GPIOB
#define Blue_3_Pin     GPIO_Pin_6
#define Blue_3_ON      GPIO_SetBits(Blue_3_Port,Blue_3_Pin)
#define Blue_3_OFF     GPIO_ResetBits(Blue_3_Port,Blue_3_Pin)
#define Blue_3_Toggle  GPIO_ToggleBits(Blue_3_Port,Blue_3_Pin)

#define Green_1_Port   GPIOE
#define Green_1_Pin    GPIO_Pin_0
#define Green_1_ON     GPIO_SetBits(Green_1_Port,Green_1_Pin)
#define Green_1_OFF    GPIO_ResetBits(Green_1_Port,Green_1_Pin)
#define Green_1_Toggle GPIO_ToggleBits(Green_1_Port,Green_1_Pin)

#define Green_2_Port   GPIOE
#define Green_2_Pin    GPIO_Pin_1
#define Green_2_ON     GPIO_SetBits(Green_2_Port,Green_2_Pin)
#define Green_2_OFF    GPIO_ResetBits(Green_2_Port,Green_2_Pin)
#define Green_2_Toggle GPIO_ToggleBits(Green_2_Port,Green_2_Pin)

#define Buzzer_Port    GPIOD
#define Buzzer_Pin     GPIO_Pin_10
#define Buzzer_ON      GPIO_SetBits(Buzzer_Port,Buzzer_Pin)
#define Buzzer_OFF     GPIO_ResetBits(Buzzer_Port,Buzzer_Pin)
#define Buzzer_Toggle  GPIO_ToggleBits(Buzzer_Port,Buzzer_Pin)

#define Button_Left_Port GPIOE
#define Button_Left_Pin  GPIO_Pin_14
#define Button_Left_Read GPIO_ReadInputDataBit(Button_Left_Port,Button_Left_Pin)

#define Button_Right_Port GPIOD
#define Button_Right_Pin  GPIO_Pin_14
#define Button_Right_Read GPIO_ReadInputDataBit(Button_Right_Port,Button_Right_Pin)

#define Button_Middle_Port GPIOB
#define Button_Middle_Pin  GPIO_Pin_11
#define Button_Middle_Read GPIO_ReadInputDataBit(Button_Middle_Port,Button_Middle_Pin)

#define Button_Up_Port GPIOD
#define Button_Up_Pin  GPIO_Pin_15
#define Button_Up_Read GPIO_ReadInputDataBit(Button_Up_Port,Button_Up_Pin)

#define Button_Down_Port GPIOE
#define Button_Down_Pin  GPIO_Pin_13
#define Button_Down_Read GPIO_ReadInputDataBit(Button_Down_Port,Button_Down_Pin)

#define Button_ESC_Port GPIOB
#define Button_ESC_Pin  GPIO_Pin_10
#define Button_ESC_Read GPIO_ReadInputDataBit(Button_ESC_Port,Button_ESC_Pin)

#define Button_OK_Port GPIOD
#define Button_OK_Pin  GPIO_Pin_12
#define Button_OK_Read GPIO_ReadInputDataBit(Button_OK_Port,Button_OK_Pin)


#endif /* DEFINE_IO_H_ */

 

 

config_io.h dosyasının içeriğidir.

 

 

#ifndef CONFIG_IO_H_
#define CONFIG_IO_H_

#include  <stdio.h>
#include  <stdint.h>
#include  "stm32f30x_conf.h"
#include  "stm32f30x.h"
#include  "define_io.h"

#define HIGH 1
#define LOW  0

void GPIO_ToggleBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);

void configurasyon_io(void);

void init_pin(GPIO_TypeDef*     GPIOx,
		      uint32_t          GPIO_Pin,
		      GPIOMode_TypeDef  GPIO_Mode,
			  GPIOSpeed_TypeDef GPIO_Speed,
			  GPIOOType_TypeDef GPIO_OType,
			  GPIOPuPd_TypeDef  GPIO_PuPd);

void Delay(uint32_t nTime);


#endif /* CONFIG_IO_H_ */
Okunma 1240 defa Son Düzenlenme Pazar, 30 Nisan 2017 20:22