add working Ultrasonic tests
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
set(KPI_Rover_Ultrasonic_Test_Inc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
set(KPI_Rover_Ultrasonic_Test_Src
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Ultrasonic_Test.c
|
||||
)
|
||||
|
||||
add_library(KPI_Rover_Ultrasonic_Test STATIC)
|
||||
|
||||
target_include_directories(KPI_Rover_Ultrasonic_Test PRIVATE
|
||||
${KPI_Rover_Ultrasonic_Test_Inc}
|
||||
)
|
||||
|
||||
target_sources(KPI_Rover_Ultrasonic_Test PRIVATE
|
||||
${KPI_Rover_Ultrasonic_Test_Src}
|
||||
)
|
||||
|
||||
target_link_libraries(KPI_Rover_Ultrasonic_Test PRIVATE
|
||||
HAL_H
|
||||
KPI_Rover_Ultrasonic_H
|
||||
KPI_Rover_Ultrasonic
|
||||
FREERTOS_H
|
||||
)
|
||||
|
||||
add_library(KPI_Rover_Ultrasonic_Test_H INTERFACE)
|
||||
target_include_directories(KPI_Rover_Ultrasonic_Test_H INTERFACE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "Ultrasonic_Test.h"
|
||||
#include "drvUltrasonic.h"
|
||||
#include "cmsis_os2.h"
|
||||
#include "main.h"
|
||||
|
||||
static const osThreadAttr_t task_attrs = {
|
||||
.stack_size = 256
|
||||
};
|
||||
|
||||
static void Ultrasonic_Test_Task(void *arg)
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
for ( ; ; )
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_2, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_3, GPIO_PIN_SET);
|
||||
osDelay(20);
|
||||
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_2, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_3, GPIO_PIN_RESET);
|
||||
osDelay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
void Ultrasonic_Test_Init(void)
|
||||
{
|
||||
(void) drvUltrasonic_Init();
|
||||
|
||||
osThreadNew(Ultrasonic_Test_Task, (void *) 0, &task_attrs);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef __TEST_ULTRASONIC
|
||||
#define __TEST_ULTRASONIC
|
||||
|
||||
void Ultrasonic_Test_Init(void);
|
||||
|
||||
#endif /* __TEST_ULTRASONIC */
|
||||
Reference in New Issue
Block a user