| [17] | 1 | #include "relais.h" | 
|---|
 | 2 | #include "main.h" | 
|---|
 | 3 |  | 
|---|
 | 4 |  | 
|---|
 | 5 | #define PULS_TIME   50 | 
|---|
 | 6 |  | 
|---|
 | 7 |  | 
|---|
 | 8 |  | 
|---|
 | 9 | unsigned int onTimeCounterSET;   //Set Coil | 
|---|
 | 10 | unsigned int onTimeCounterRESET; //Reset Coil | 
|---|
 | 11 | unsigned int relaisState; | 
|---|
 | 12 |  | 
|---|
 | 13 |  | 
|---|
 | 14 | void 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 |  | 
|---|
 | 28 | if (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 |  | 
|---|
 | 39 | void 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 |  | 
|---|
 | 52 | void 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 |  | 
|---|
 | 66 | unsigned int RELAIS_GetState(void) | 
|---|
 | 67 | { | 
|---|
 | 68 |   return relaisState; | 
|---|
 | 69 | } | 
|---|