-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecu_led.c
101 lines (96 loc) · 3.22 KB
/
ecu_led.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* File : ecu_led.c
* Author : Mohamed Ahmed Abdel Wahab
* LinkedIn : https://www.linkedin.com/in/mohamed-abdel-wahab-162413253/
* Github : https://github.com/moabdelwahab6611
* Created on May 21, 2023, 6:33 PM
*/
/**************************Includes-Section*****************************/
#include "ecu_led.h"
/***********************************************************************/
/*****************Software Interfaces Functions-Section*****************/
/*
* @Brief : Initialize the assigned pin to be OUTPUT and turn the LED OFF or ON.
* @param led : Pointer to the LED 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 led_initialize(const led_t *led)
{
Std_ReturnType ret = E_OK;
if(NULL == led)
{
ret = E_NOT_OK;
}
else
{
pin_config_t pin_obj = { .port = led->port_name, .pin = led->pin, .direction = GPIO_DIRECTION_OUTPUT,.logic = led->led_status };
gpio_pin_intialize(&pin_obj);
}
return ret;
}
/*
* @Brief : Turn the LED ON.
* @Param led : Pointer to the LED 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 led_turn_on(const led_t *led)
{
Std_ReturnType ret = E_OK;
if(NULL == led)
{
ret = E_NOT_OK;
}
else
{
pin_config_t pin_obj = { .port = led->port_name, .pin = led->pin, .direction = GPIO_DIRECTION_OUTPUT,.logic = led->led_status };
gpio_pin_write_logic(&pin_obj, GPIO_HIGH);
}
return ret;
}
/*
* @Brief : Turn the LED OFF.
* @Param led : Pointer to the LED 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 led_turn_off(const led_t *led)
{
Std_ReturnType ret = E_OK;
if(NULL == led)
{
ret = E_NOT_OK;
}
else
{
pin_config_t pin_obj = { .port = led->port_name, .pin = led->pin, .direction = GPIO_DIRECTION_OUTPUT,.logic = led->led_status };
gpio_pin_write_logic(&pin_obj, GPIO_LOW);
}
return ret;
}
/*
* @Brief : Toggle the LED.
* @Param led : Pointer to the LED 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 led_turn_toggle(const led_t *led)
{
Std_ReturnType ret = E_OK;
if(NULL == led)
{
ret = E_NOT_OK;
}
else
{
pin_config_t pin_obj = { .port = led->port_name, .pin = led->pin, .direction = GPIO_DIRECTION_OUTPUT,.logic = led->led_status };
gpio_pin_toggle_logic(&pin_obj);
}
return ret;
}
/***********************************************************************/