add working test for PCA9685 and servos
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
set(KPI_Rover_Servos_Inc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
set(KPI_Rover_Servos_Src
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hwServos.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drvServos.c
|
||||
)
|
||||
|
||||
add_library(KPI_Rover_Servos STATIC)
|
||||
|
||||
target_include_directories(KPI_Rover_Servos PRIVATE
|
||||
${KPI_Rover_Servos_Inc}
|
||||
)
|
||||
|
||||
target_sources(KPI_Rover_Servos PRIVATE
|
||||
${KPI_Rover_Servos_Src}
|
||||
)
|
||||
|
||||
target_link_libraries(KPI_Rover_Servos PRIVATE
|
||||
HAL_H
|
||||
)
|
||||
|
||||
add_library(KPI_Rover_Servos_H INTERFACE)
|
||||
target_include_directories(KPI_Rover_Servos_H INTERFACE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
@@ -0,0 +1,24 @@
|
||||
#include "main.h"
|
||||
#include "drvServos.h"
|
||||
#include "hwServos.h"
|
||||
|
||||
bool drvServos_Init(void)
|
||||
{
|
||||
hwServos_Init();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool drvServos_Enable(void)
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_8, GPIO_PIN_SET);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool drvServos_Disable(void)
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_8, GPIO_PIN_RESET);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef __DRV_SERVOS
|
||||
#define __DRV_SERVOS
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool drvServos_Init(void);
|
||||
bool drvServos_Enable(void);
|
||||
bool drvServos_Disable(void);
|
||||
|
||||
#endif /* __DRV_SERVOS */
|
||||
@@ -0,0 +1,13 @@
|
||||
#include "main.h"
|
||||
#include "hwServos.h"
|
||||
|
||||
void hwServos_Init(void)
|
||||
{
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_8;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef __HW_SERVOS
|
||||
#define __HW_SERVOS
|
||||
|
||||
void hwServos_Init(void);
|
||||
|
||||
#endif /* __HW_SERVOS */
|
||||
Reference in New Issue
Block a user