+DIP, add mode switching at boot
This commit is contained in:
@@ -13,11 +13,13 @@ set(KPIROVER_ARBITERS
|
|||||||
set(KPIROVER_COMPONENTS
|
set(KPIROVER_COMPONENTS
|
||||||
ADC
|
ADC
|
||||||
Communication
|
Communication
|
||||||
|
DIP
|
||||||
Database
|
Database
|
||||||
Logger
|
|
||||||
Motors
|
|
||||||
Encoders
|
Encoders
|
||||||
IMU
|
IMU
|
||||||
|
LEDMode
|
||||||
|
Logger
|
||||||
|
Motors
|
||||||
#Storage
|
#Storage
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
set(KPI_Rover_DIP_Inc
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(KPI_Rover_DIP_Src
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hwDIP.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/drvDip.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/ulDip.c
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(KPI_Rover_DIP STATIC)
|
||||||
|
|
||||||
|
target_include_directories(KPI_Rover_DIP PRIVATE
|
||||||
|
${KPI_Rover_DIP_Inc}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_sources(KPI_Rover_DIP PRIVATE
|
||||||
|
${KPI_Rover_DIP_Src}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(KPI_Rover_DIP PRIVATE
|
||||||
|
FREERTOS_H
|
||||||
|
HAL_H
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(KPI_Rover_DIP_H INTERFACE)
|
||||||
|
target_include_directories(KPI_Rover_DIP_H INTERFACE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#include "main.h"
|
||||||
|
#include "hwDIP.h"
|
||||||
|
|
||||||
|
void drvDip_Init(void)
|
||||||
|
{
|
||||||
|
HW_DIP_Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char drvDip_read(void)
|
||||||
|
{
|
||||||
|
return (unsigned char) (GPIOE->IDR >> 12);
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#ifndef __DRV_DIP_H
|
||||||
|
#define __DRV_DIP_H
|
||||||
|
|
||||||
|
void drvDip_Init(void);
|
||||||
|
unsigned char drvDip_read(void);
|
||||||
|
|
||||||
|
#endif /* __DRV_DIP_H */
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
void HW_DIP_Init(void)
|
||||||
|
{
|
||||||
|
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef __HW_DIP_H
|
||||||
|
#define __HW_DIP_H
|
||||||
|
|
||||||
|
void HW_DIP_Init(void);
|
||||||
|
|
||||||
|
#endif /* __HW_DIP_H */
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#include "ulDip.h"
|
||||||
|
#include "drvDip.h"
|
||||||
|
|
||||||
|
bool ulDip_Init(void)
|
||||||
|
{
|
||||||
|
drvDip_Init();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ulDip_Read(bool * const target)
|
||||||
|
{
|
||||||
|
unsigned char v = drvDip_read();
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
target[i] = !(v & 1);
|
||||||
|
v >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#ifndef __UL_DIP_H
|
||||||
|
#define __UL_DIP_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
bool ulDip_Init(void);
|
||||||
|
bool ulDip_Read(bool * const target);
|
||||||
|
|
||||||
|
#endif /* __UL_DIP_H */
|
||||||
+15
-3
@@ -1,12 +1,14 @@
|
|||||||
#include "KPIRover.h"
|
#include "KPIRover.h"
|
||||||
|
|
||||||
//#include "ulAdc.h"
|
|
||||||
#include "ProtocolHandler.h"
|
#include "ProtocolHandler.h"
|
||||||
#include "ulDatabase.h"
|
#include "ulDatabase.h"
|
||||||
|
#include "ulDip.h"
|
||||||
#include "ulEncoder.h"
|
#include "ulEncoder.h"
|
||||||
#include "ulImu.h"
|
#include "ulImu.h"
|
||||||
|
#include "ulLEDMode.h"
|
||||||
#include "ulMotorsController.h"
|
#include "ulMotorsController.h"
|
||||||
//#include "Storage/ulStorage.h"
|
//#include "Storage/ulStorage.h"
|
||||||
|
//#include "ulAdc.h"
|
||||||
|
|
||||||
#include "ulog.h"
|
#include "ulog.h"
|
||||||
#include "ulUlog.h"
|
#include "ulUlog.h"
|
||||||
@@ -65,9 +67,19 @@ static struct ulDatabase_ParamMetadata ulDatabase_params[] = {
|
|||||||
{0, UINT32, false, 0}, // UART_LINE_ERROR_COUNT
|
{0, UINT32, false, 0}, // UART_LINE_ERROR_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
//extern I2C_HandleTypeDef hi2c3;
|
|
||||||
|
|
||||||
void KPIRover_Init(void) {
|
void KPIRover_Init(void) {
|
||||||
|
static bool dip[4];
|
||||||
|
ulDip_Init();
|
||||||
|
if (ulDip_Read(dip))
|
||||||
|
{
|
||||||
|
if (dip[0] == true)
|
||||||
|
{
|
||||||
|
ulLEDMode_Start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// normal boot sequence
|
||||||
|
|
||||||
ULOG_INIT();
|
ULOG_INIT();
|
||||||
ULOG_SUBSCRIBE(ul_ulog_send, ULOG_DEBUG_LEVEL);
|
ULOG_SUBSCRIBE(ul_ulog_send, ULOG_DEBUG_LEVEL);
|
||||||
ulDatabase_init(ulDatabase_params, sizeof(ulDatabase_params) / sizeof(struct ulDatabase_ParamMetadata));
|
ulDatabase_init(ulDatabase_params, sizeof(ulDatabase_params) / sizeof(struct ulDatabase_ParamMetadata));
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
set(KPI_Rover_LEDMode_Inc
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(KPI_Rover_LEDMode_Src
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/ulLEDMode.c
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(KPI_Rover_LEDMode STATIC)
|
||||||
|
|
||||||
|
target_include_directories(KPI_Rover_LEDMode PRIVATE
|
||||||
|
${KPI_Rover_LEDMode_Inc}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_sources(KPI_Rover_LEDMode PRIVATE
|
||||||
|
${KPI_Rover_LEDMode_Src}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(KPI_Rover_LEDMode PRIVATE
|
||||||
|
FREERTOS_H
|
||||||
|
HAL_H
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(KPI_Rover_LEDMode_H INTERFACE)
|
||||||
|
target_include_directories(KPI_Rover_LEDMode_H INTERFACE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#include "ulLEDMode.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
void ulLEDMode_Start(void)
|
||||||
|
{
|
||||||
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
|
GPIOB->MODER |= 0x55000000;
|
||||||
|
|
||||||
|
for ( ; ; )
|
||||||
|
{
|
||||||
|
GPIOB->ODR |= 0xF000;
|
||||||
|
GPIOB->ODR &= ~(~GPIOE->IDR & 0xF000);
|
||||||
|
|
||||||
|
for (volatile int i = 10000; i > 0; i--)
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef __UL_LEDMODE_H
|
||||||
|
#define __UL_LEDMODE_H
|
||||||
|
|
||||||
|
void ulLEDMode_Start(void);
|
||||||
|
|
||||||
|
#endif /* __UL_LEDMODE_H */
|
||||||
Reference in New Issue
Block a user