e0f9d51fe00129b1a499abd34be99ca9ceb1b4a4
[apps/native/gear-racing-car.git] / inc / resource / resource_motor_driver_L298N.h
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
4  * Contact: Jeonghoon Park <jh1979.park@samsung.com>
5  *
6  * Licensed under the Flora License, Version 1.1 (the License);
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://floralicense.org/license/
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an AS IS BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #ifndef __RESOURCE_MOTOR_DRIVER_L298N_H__
20 #define __RESOURCE_MOTOR_DRIVER_L298N_H__
21
22 /* connected GPIO pin numbers of raspberry pi 3 with IN pins of L298N */
23 #define DEFAULT_MOTOR1_PIN1 26
24 #define DEFAULT_MOTOR1_PIN2 20
25
26 #define DEFAULT_MOTOR2_PIN1 19
27 #define DEFAULT_MOTOR2_PIN2 16
28
29 #define DEFAULT_MOTOR3_PIN1 6
30 #define DEFAULT_MOTOR3_PIN2 12
31
32 #define DEFAULT_MOTOR4_PIN1 22
33 #define DEFAULT_MOTOR4_PIN2 23
34
35 /* connected channel numbers of PCA9685 with enable pins of L298N */
36 #define DEFAULT_MOTOR1_EN_CH 1
37 #define DEFAULT_MOTOR2_EN_CH 2
38 #define DEFAULT_MOTOR3_EN_CH 3
39 #define DEFAULT_MOTOR4_EN_CH 4
40
41 typedef enum {
42         MOTOR_ID_1,
43         MOTOR_ID_2,
44         MOTOR_ID_3,
45         MOTOR_ID_4,
46         MOTOR_ID_MAX
47 } motor_id_e;
48
49 int resource_set_motor_driver_L298N_configuration(motor_id_e id,
50         unsigned int pin1, unsigned int pin2, unsigned en_ch);
51
52 int resource_set_motor_driver_L298N_speed(motor_id_e id, int speed);
53
54 #endif /* __RESOURCE_MOTOR_DRIVER_L298N_H__ */