work ebati kak
This commit is contained in:
@@ -18,12 +18,12 @@
|
||||
/* USER CODE END Header */
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
#include "gyro_mes.h"
|
||||
#include "stdio.h"
|
||||
#include "string.h"
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include "gyro_mes.h"
|
||||
#include "stdio.h"
|
||||
#include "string.h"
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
@@ -113,6 +113,7 @@ int main(void)
|
||||
|
||||
/* Infinite loop */
|
||||
/* USER CODE BEGIN WHILE */
|
||||
struct sData data[3];
|
||||
int8_t res = comand_mes(data_in, sizeof(data_in) / sizeof(data_in[0]));
|
||||
if(res != 0) return res;
|
||||
while (1)
|
||||
@@ -120,29 +121,24 @@ int main(void)
|
||||
flag_cs = 1;
|
||||
CS1_ON();
|
||||
res = HAL_SPI_TransmitReceive_IT(&hspi1, data_in, data_out, sizeof(data_in) / sizeof(data_in[0]));
|
||||
while(!flag_receive && res == 0) {
|
||||
HAL_Delay(1);
|
||||
}
|
||||
while(!flag_receive && res == 0);
|
||||
|
||||
CS1_OFF();
|
||||
flag_receive = 0;
|
||||
flag_cs = 2;
|
||||
CS2_ON();
|
||||
res = HAL_SPI_TransmitReceive_IT(&hspi1, data_in, &data_out[6], sizeof(data_in) / sizeof(data_in[0]));
|
||||
while(!flag_receive && res == 0) {
|
||||
HAL_Delay(1);
|
||||
}
|
||||
while(!flag_receive && res == 0);
|
||||
|
||||
CS2_OFF();
|
||||
flag_receive = 0;
|
||||
flag_cs = 3;
|
||||
CS3_ON();
|
||||
res = HAL_SPI_TransmitReceive_IT(&hspi1, data_in, &data_out[12], sizeof(data_in) / sizeof(data_in[0]));
|
||||
while(!flag_receive && res == 0) {
|
||||
HAL_Delay(1);
|
||||
}
|
||||
while(!flag_receive && res == 0) ;
|
||||
CS3_OFF();
|
||||
flag_receive = 0;
|
||||
|
||||
struct sData data[3];
|
||||
int8_t res = status_mes(&data_out[0], 6u, &data[0]);
|
||||
res += status_mes(&data_out[6], 6u, &data[1]);
|
||||
res += status_mes(&data_out[12], 6u, &data[2]);
|
||||
@@ -181,11 +177,16 @@ void SystemClock_Config(void)
|
||||
/** Initializes the RCC Oscillators according to the specified parameters
|
||||
* in the RCC_OscInitTypeDef structure.
|
||||
*/
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
|
||||
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
|
||||
RCC_OscInitStruct.MSICalibrationValue = 0;
|
||||
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
|
||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
|
||||
RCC_OscInitStruct.PLL.PLLM = 1;
|
||||
RCC_OscInitStruct.PLL.PLLN = 10;
|
||||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7;
|
||||
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
|
||||
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
@@ -194,12 +195,12 @@ void SystemClock_Config(void)
|
||||
*/
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
||||
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
||||
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
@@ -261,7 +262,7 @@ static void MX_USART1_UART_Init(void)
|
||||
|
||||
/* USER CODE END USART1_Init 1 */
|
||||
huart1.Instance = USART1;
|
||||
huart1.Init.BaudRate = 115200;
|
||||
huart1.Init.BaudRate = 921600;
|
||||
huart1.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
huart1.Init.StopBits = UART_STOPBITS_1;
|
||||
huart1.Init.Parity = UART_PARITY_NONE;
|
||||
|
||||
Reference in New Issue
Block a user