add MP45DT02 testing function
This commit is contained in:
+124
-10
@@ -30,6 +30,8 @@
|
||||
#include "CS43L22.h"
|
||||
#include "SST25VF016B.h"
|
||||
#include "LIS302DL.h"
|
||||
#include "DHT11.h"
|
||||
#include "MP45DT02.h"
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
@@ -56,8 +58,12 @@ ADC_HandleTypeDef hadc1;
|
||||
|
||||
I2C_HandleTypeDef hi2c1;
|
||||
|
||||
I2S_HandleTypeDef hi2s2;
|
||||
|
||||
SPI_HandleTypeDef hspi1;
|
||||
|
||||
TIM_HandleTypeDef htim2;
|
||||
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
void ((*executors[])(void)) = {
|
||||
@@ -68,7 +74,8 @@ void ((*executors[])(void)) = {
|
||||
CS43L22_run_test,
|
||||
SST25VF016B_run_test,
|
||||
LIS302DL_run_test,
|
||||
LIS302DL_run_test_dynamic
|
||||
LIS302DL_run_test_dynamic,
|
||||
MP45DT02_run_test
|
||||
};
|
||||
|
||||
void ((*cleanup_functions[])(void)) = {
|
||||
@@ -79,10 +86,21 @@ void ((*cleanup_functions[])(void)) = {
|
||||
CS43L22_cleanup,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
int delay_between_runs[] = {250, 250, -1, -1, -1, -1, -1, 200};
|
||||
int delay_between_runs[] = {
|
||||
250,
|
||||
250,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
200,
|
||||
-1
|
||||
};
|
||||
|
||||
size_t current_executor_id = 0;
|
||||
|
||||
@@ -96,6 +114,8 @@ static void MX_GPIO_Init(void);
|
||||
static void MX_ADC1_Init(void);
|
||||
static void MX_I2C1_Init(void);
|
||||
static void MX_SPI1_Init(void);
|
||||
static void MX_TIM2_Init(void);
|
||||
static void MX_I2S2_Init(void);
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
@@ -106,7 +126,7 @@ static void MX_SPI1_Init(void);
|
||||
void switch_to_next_test(void)
|
||||
{
|
||||
current_executor_id += 1;
|
||||
current_executor_id %= 8;
|
||||
current_executor_id %= 9;
|
||||
}
|
||||
|
||||
void buttons_switch_to_interrupt(void)
|
||||
@@ -263,9 +283,15 @@ int main(void)
|
||||
MX_ADC1_Init();
|
||||
MX_I2C1_Init();
|
||||
MX_SPI1_Init();
|
||||
MX_TIM2_Init();
|
||||
MX_I2S2_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
buttons_interrupt_enabled = 0;
|
||||
|
||||
HAL_TIM_Base_Start(&htim2);
|
||||
TIM2->CNT = 0;
|
||||
HAL_TIM_Base_Stop(&htim2);
|
||||
|
||||
GPIOD->ODR = 0x1000;
|
||||
display_init();
|
||||
|
||||
@@ -317,6 +343,14 @@ void SystemClock_Config(void)
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||
|
||||
/** Macro to configure the PLL multiplication factor
|
||||
*/
|
||||
__HAL_RCC_PLL_PLLM_CONFIG(16);
|
||||
|
||||
/** Macro to configure the PLL clock source
|
||||
*/
|
||||
__HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_HSI);
|
||||
|
||||
/** Configure the main internal regulator output voltage
|
||||
*/
|
||||
__HAL_RCC_PWR_CLK_ENABLE();
|
||||
@@ -329,6 +363,7 @@ void SystemClock_Config(void)
|
||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
@@ -435,6 +470,40 @@ static void MX_I2C1_Init(void)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief I2S2 Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_I2S2_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN I2S2_Init 0 */
|
||||
|
||||
/* USER CODE END I2S2_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN I2S2_Init 1 */
|
||||
|
||||
/* USER CODE END I2S2_Init 1 */
|
||||
hi2s2.Instance = SPI2;
|
||||
hi2s2.Init.Mode = I2S_MODE_MASTER_RX;
|
||||
hi2s2.Init.Standard = I2S_STANDARD_PHILIPS;
|
||||
hi2s2.Init.DataFormat = I2S_DATAFORMAT_16B;
|
||||
hi2s2.Init.MCLKOutput = I2S_MCLKOUTPUT_DISABLE;
|
||||
hi2s2.Init.AudioFreq = I2S_AUDIOFREQ_48K;
|
||||
hi2s2.Init.CPOL = I2S_CPOL_LOW;
|
||||
hi2s2.Init.ClockSource = I2S_CLOCK_PLL;
|
||||
hi2s2.Init.FullDuplexMode = I2S_FULLDUPLEXMODE_DISABLE;
|
||||
if (HAL_I2S_Init(&hi2s2) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN I2S2_Init 2 */
|
||||
|
||||
/* USER CODE END I2S2_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SPI1 Initialization Function
|
||||
* @param None
|
||||
@@ -473,6 +542,51 @@ static void MX_SPI1_Init(void)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TIM2 Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_TIM2_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN TIM2_Init 0 */
|
||||
|
||||
/* USER CODE END TIM2_Init 0 */
|
||||
|
||||
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
|
||||
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
||||
|
||||
/* USER CODE BEGIN TIM2_Init 1 */
|
||||
|
||||
/* USER CODE END TIM2_Init 1 */
|
||||
htim2.Instance = TIM2;
|
||||
htim2.Init.Prescaler = 0;
|
||||
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim2.Init.Period = 0xffffffff;
|
||||
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
||||
if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN TIM2_Init 2 */
|
||||
|
||||
/* USER CODE END TIM2_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief GPIO Initialization Function
|
||||
* @param None
|
||||
@@ -485,19 +599,19 @@ static void MX_GPIO_Init(void)
|
||||
/* USER CODE END MX_GPIO_Init_1 */
|
||||
|
||||
/* GPIO Ports Clock Enable */
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_7|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12
|
||||
|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15
|
||||
|GPIO_PIN_4|GPIO_PIN_7, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|
||||
|GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_7, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET);
|
||||
@@ -517,10 +631,10 @@ static void MX_GPIO_Init(void)
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PD12 PD13 PD14 PD15
|
||||
PD4 PD7 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15
|
||||
|GPIO_PIN_4|GPIO_PIN_7;
|
||||
/*Configure GPIO pins : PD11 PD12 PD13 PD14
|
||||
PD15 PD4 PD7 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|
||||
|GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_7;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
|
||||
Reference in New Issue
Block a user