-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecu_relay.c
79 lines (75 loc) · 2.65 KB
/
ecu_relay.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* File : ecu_relay.c
* Author : Mohamed Ahmed Abdel Wahab
* LinkedIn : https://www.linkedin.com/in/mohamed-abdel-wahab-162413253/
* Github : https://github.com/moabdelwahab6611
* Created on May 28, 2023, 2:51 AM
*/
/**************************Includes-Section*****************************/
#include "ecu_relay.h"
/***********************************************************************/
/*****************Software Interfaces Functions-Section*****************/
/*
* @Brief : Initialize the assigned pin to be OUTPUT and turn the Relay OFF or ON.
* @Param _relay : Pointer to the Relay module configurations.
* @Return Status of the function.
* (E_OK) : The function done successfully.
* (E_NOT_OK) : The function has issue while performing this action.
*/
Std_ReturnType relay_initialize(const relay_t *_relay)
{
Std_ReturnType ret = E_OK;
if(NULL == _relay)
{
ret = E_NOT_OK;
}
else
{
pin_config_t pin_obj = {.port = _relay->relay_port, .pin = _relay->relay_pin, .direction = GPIO_DIRECTION_OUTPUT, .logic = _relay->relay_status};
gpio_pin_intialize(&pin_obj);
}
return ret;
}
/*
* @Brief : Turn the Relay ON.
* @Param _relay : Pointer to the Relay module configurations.
* @Return Status of the function.
* (E_OK) : The function done successfully.
* (E_NOT_OK) : The function has issue while performing this action.
*/
Std_ReturnType relay_turn_on(const relay_t *_relay)
{
Std_ReturnType ret = E_OK;
if(NULL == _relay)
{
ret = E_NOT_OK;
}
else
{
pin_config_t pin_obj = {.port = _relay->relay_port, .pin = _relay->relay_pin, .direction = GPIO_DIRECTION_OUTPUT, .logic = _relay->relay_status};
gpio_pin_write_logic(&pin_obj, GPIO_HIGH);
}
return ret;
}
/*
* @Brief : Turn the Relay OFF.
* @Param _relay : Pointer to the Relay module configurations.
* @Return Status of the function.
* (E_OK) : The function done successfully.
* (E_NOT_OK) : The function has issue while performing this action.
*/
Std_ReturnType relay_turn_off(const relay_t *_relay)
{
Std_ReturnType ret = E_OK;
if(NULL == _relay)
{
ret = E_NOT_OK;
}
else
{
pin_config_t pin_obj = {.port = _relay->relay_port, .pin = _relay->relay_pin, .direction = GPIO_DIRECTION_OUTPUT, .logic = _relay->relay_status};
gpio_pin_write_logic(&pin_obj, GPIO_LOW);
}
return ret;
}
/***********************************************************************/