-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.c
77 lines (71 loc) · 2.67 KB
/
application.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
/*
* File : application.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, 5:38 PM
*/
/**************************Includes-Section*****************************/
#include "application.h"
/***********************************************************************/
/***********************************************************************/
dc_motor_t dc_motor_1 =
{
.dc_motor_pin[0].port = PORTC_INDEX,
.dc_motor_pin[0].pin = GPIO_PIN0,
.dc_motor_pin[0].logic = DC_MOTOR_STATUS_OFF,
.dc_motor_pin[0].direction = GPIO_DIRECTION_OUTPUT,
.dc_motor_pin[1].port = PORTC_INDEX,
.dc_motor_pin[1].pin = GPIO_PIN1,
.dc_motor_pin[1].logic = DC_MOTOR_STATUS_OFF,
.dc_motor_pin[1].direction = GPIO_DIRECTION_OUTPUT
};
dc_motor_t dc_motor_2 =
{
.dc_motor_pin[0].port = PORTC_INDEX,
.dc_motor_pin[0].pin = GPIO_PIN2,
.dc_motor_pin[0].logic = DC_MOTOR_STATUS_OFF,
.dc_motor_pin[0].direction = GPIO_DIRECTION_OUTPUT,
.dc_motor_pin[1].port = PORTC_INDEX,
.dc_motor_pin[1].pin = GPIO_PIN3,
.dc_motor_pin[1].logic = DC_MOTOR_STATUS_OFF,
.dc_motor_pin[1].direction = GPIO_DIRECTION_OUTPUT
};
/***********************************************************************/
/***********************Main Function-Section***************************/
int main()
{
Std_ReturnType ret = E_NOT_OK;
application_intialize();
while(1)
{
ret = dc_motor_move_right(&dc_motor_1);
ret = dc_motor_move_right(&dc_motor_2);
__delay_ms(3000);
ret = dc_motor_move_left(&dc_motor_1);
ret = dc_motor_move_left(&dc_motor_2);
__delay_ms(3000);
ret = dc_motor_stop(&dc_motor_1);
ret = dc_motor_stop(&dc_motor_2);
__delay_ms(3000);
ret = dc_motor_move_right(&dc_motor_1);
ret = dc_motor_move_left(&dc_motor_2);
__delay_ms(3000);
ret = dc_motor_stop(&dc_motor_1);
ret = dc_motor_stop(&dc_motor_2);
__delay_ms(3000);
ret = dc_motor_move_left(&dc_motor_1);
ret = dc_motor_move_right(&dc_motor_2);
__delay_ms(3000);
}
return (EXIT_SUCCESS);
}
/***********************************************************************/
/*************************Functions-Section*****************************/
void application_intialize(void)
{
Std_ReturnType ret = E_NOT_OK;
ret = dc_motor_initialize(&dc_motor_1);
ret = dc_motor_initialize(&dc_motor_2);
}
/***********************************************************************/