source: trunk/firmware_v2/SES/src/relais.c@ 22

Last change on this file since 22 was 17, checked in by f.jahn, 4 months ago
File size: 1.5 KB
Line 
1#include "relais.h"
2#include "main.h"
3
4
5#define PULS_TIME 50
6
7
8
9unsigned int onTimeCounterSET; //Set Coil
10unsigned int onTimeCounterRESET; //Reset Coil
11unsigned int relaisState;
12
13
14void RELAIS_Exec(void)
15{
16
17 if (onTimeCounterSET > 0)
18 {
19 onTimeCounterSET--;
20 if (onTimeCounterSET == 0)
21 {
22 HAL_GPIO_WritePin(GPIO_OUTPUT_RELAIS_SET_GPIO_Port, GPIO_OUTPUT_RELAIS_SET_Pin, GPIO_PIN_RESET);
23 }
24 }
25
26
27
28if (onTimeCounterRESET > 0)
29 {
30 onTimeCounterRESET--;
31 if (onTimeCounterRESET == 0)
32 {
33 HAL_GPIO_WritePin(GPIO_OUTPUT_RELAIS_RESET_GPIO_Port, GPIO_OUTPUT_RELAIS_RESET_Pin, GPIO_PIN_RESET);
34 }
35 }
36
37}
38
39void RELAIS_SetPuls(void)
40{
41
42 //Sicherstellen das nicht noch die Reset Spule aktiv geschaltet ist
43 HAL_GPIO_WritePin(GPIO_OUTPUT_RELAIS_RESET_GPIO_Port, GPIO_OUTPUT_RELAIS_RESET_Pin, GPIO_PIN_RESET);
44
45 //Puls starten
46 HAL_GPIO_WritePin(GPIO_OUTPUT_RELAIS_SET_GPIO_Port, GPIO_OUTPUT_RELAIS_SET_Pin, GPIO_PIN_SET);
47 onTimeCounterSET = PULS_TIME;
48 relaisState = 1;
49
50}
51
52void RELAIS_ResetPuls(void)
53{
54
55 //Sicherstellen das nicht noch die Set Spule aktiv geschaltet ist
56 HAL_GPIO_WritePin(GPIO_OUTPUT_RELAIS_SET_GPIO_Port, GPIO_OUTPUT_RELAIS_SET_Pin, GPIO_PIN_RESET);
57
58 //Puls starten
59 HAL_GPIO_WritePin(GPIO_OUTPUT_RELAIS_RESET_GPIO_Port, GPIO_OUTPUT_RELAIS_RESET_Pin, GPIO_PIN_SET);
60 onTimeCounterRESET = PULS_TIME;
61 relaisState = 0;
62
63}
64
65
66unsigned int RELAIS_GetState(void)
67{
68 return relaisState;
69}
Note: See TracBrowser for help on using the repository browser.