add working Ultrasonic tests
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
set(KPI_Rover_Ultrasonic_Inc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
set(KPI_Rover_Ultrasonic_Src
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hwUltrasonic.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drvUltrasonic.c
|
||||
)
|
||||
|
||||
add_library(KPI_Rover_Ultrasonic STATIC)
|
||||
|
||||
target_include_directories(KPI_Rover_Ultrasonic PRIVATE
|
||||
${KPI_Rover_Ultrasonic_Inc}
|
||||
)
|
||||
|
||||
target_sources(KPI_Rover_Ultrasonic PRIVATE
|
||||
${KPI_Rover_Ultrasonic_Src}
|
||||
)
|
||||
|
||||
target_link_libraries(KPI_Rover_Ultrasonic PRIVATE
|
||||
HAL_H
|
||||
)
|
||||
|
||||
add_library(KPI_Rover_Ultrasonic_H INTERFACE)
|
||||
target_include_directories(KPI_Rover_Ultrasonic_H INTERFACE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "main.h"
|
||||
#include "drvUltrasonic.h"
|
||||
#include "hwUltrasonic.h"
|
||||
|
||||
bool drvUltrasonic_Init(void)
|
||||
{
|
||||
hwUltrasonic_Init();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef __DRV_ULTRASONIC
|
||||
#define __DRV_ULTRASONIC
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool drvUltrasonic_Init(void);
|
||||
|
||||
#endif /* __DRV_ULTRASONIC */
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "main.h"
|
||||
#include "hwUltrasonic.h"
|
||||
|
||||
void hwUltrasonic_Init(void)
|
||||
{
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_2 | GPIO_PIN_3;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_9;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef __HW_ULTRASONIC
|
||||
#define __HW_ULTRASONIC
|
||||
|
||||
#include "main.h"
|
||||
|
||||
void hwUltrasonic_Init(void);
|
||||
|
||||
#endif /* __HW_ULTRASONIC */
|
||||
Reference in New Issue
Block a user