add servo motor module
authorJeonghoon Park <jh1979.park@samsung.com>
Thu, 7 Dec 2017 08:38:43 +0000 (17:38 +0900)
committerJeonghoon Park <jh1979.park@samsung.com>
Thu, 7 Dec 2017 08:38:43 +0000 (17:38 +0900)
CMakeLists.txt
inc/servo_motor.h [new file with mode: 0644]
src/servo_motor.c [new file with mode: 0644]

index bc5c2d9..73084d3 100644 (file)
@@ -30,6 +30,7 @@ ADD_EXECUTABLE(${PROJECT_NAME}
        ${PROJECT_ROOT_DIR}/src/app.c
        ${PROJECT_ROOT_DIR}/src/log.c
        ${PROJECT_ROOT_DIR}/src/dc_motor.c
+       ${PROJECT_ROOT_DIR}/src/servo_motor.c
        ${PROJECT_ROOT_DIR}/src/pca9685.c
 )
 
diff --git a/inc/servo_motor.h b/inc/servo_motor.h
new file mode 100644 (file)
index 0000000..4b927fb
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jeonghoon Park <jh1979.park@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __CAR_APP_SERVO_MOTOR_H__
+#define __CAR_APP_SERVO_MOTOR_H__
+
+int servo_motor_init(void);
+int servo_motor_fini(void);
+int servo_motor_value_set(int motor_id, int value);
+
+#endif /* __CAR_APP_SERVO_MOTOR_H__ */
\ No newline at end of file
diff --git a/src/servo_motor.c b/src/servo_motor.c
new file mode 100644 (file)
index 0000000..444c91e
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Jeonghoon Park <jh1979.park@samsung.com>
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "log.h"
+#include "pca9685.h"
+
+int servo_motor_init(void)
+{
+       int ret = 0;
+       ret = pca9685_init();
+       if (ret) {
+               _E("failed to init PCA9685");
+               return -1;
+       }
+}
+
+int servo_motor_fini(void)
+{
+       pca9685_fini();
+       return 0;
+}
+
+int servo_motor_value_set(int motor_id, int value)
+{
+       int ret = 0;
+       ret = pca9685_set_value_to_channel(motor_id, 0, value);
+       return ret;
+}