Browse Source

init

master
zhaohe 1 year ago
parent
commit
a53d176633
  1. 4
      usrc/main.cpp
  2. 4
      usrc/public_service/gins.c
  3. 10
      usrc/public_service/gins.h
  4. 0
      usrc/public_service/gservice.cpp
  5. 0
      usrc/public_service/gservice.hpp
  6. 4
      usrc/public_service/public_service.h
  7. 5
      usrc/public_service/public_service.hpp
  8. 2
      usrc/subboards/subboard30_shake_module/subboard30_shake_module.cpp
  9. 49
      usrc/subboards/subboard30_shake_module/subboard30_shake_module_board.c

4
usrc/main.cpp

@ -2,9 +2,7 @@
#include <stdio.h> #include <stdio.h>
#include "configs/device_id_mgr.hpp" #include "configs/device_id_mgr.hpp"
#include "gservice.hpp"
#include "public_service/common_hardware_init.h"
#include "public_service/gins.h"
#include "public_service/public_service.hpp"
#include "sdk/chip/chip.hpp" #include "sdk/chip/chip.hpp"
#include "sdk/os/zos.hpp" #include "sdk/os/zos.hpp"
#include "subboards/subboard30_shake_module/subboard30_shake_module.hpp" #include "subboards/subboard30_shake_module/subboard30_shake_module.hpp"

4
usrc/public_service/gins.c

@ -15,6 +15,8 @@ DMA_HandleTypeDef hdma1_stream1;
DMA_HandleTypeDef hdma2_stream2; DMA_HandleTypeDef hdma2_stream2;
DMA_HandleTypeDef hdma1_stream3; DMA_HandleTypeDef hdma1_stream3;
SPI_HandleTypeDef hspi1;
bool htim6_enable; bool htim6_enable;
bool htim7_enable; bool htim7_enable;
bool htim11_enable = true; bool htim11_enable = true;
@ -24,3 +26,5 @@ bool huart3_enable;
bool hdma1_stream1_enable; bool hdma1_stream1_enable;
bool hdma2_stream2_enable; bool hdma2_stream2_enable;
bool hdma1_stream3_enable; bool hdma1_stream3_enable;
bool hspi1_enable;

10
usrc/public_service/gins.h

@ -4,16 +4,20 @@
#include "main.h" #include "main.h"
#ifdef __cplusplus
extern "C" {
#endif
extern TIM_HandleTypeDef htim6; extern TIM_HandleTypeDef htim6;
extern TIM_HandleTypeDef htim7; extern TIM_HandleTypeDef htim7;
extern TIM_HandleTypeDef htim11; extern TIM_HandleTypeDef htim11;
extern CAN_HandleTypeDef hcan1; extern CAN_HandleTypeDef hcan1;
extern UART_HandleTypeDef huart1; extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart3; extern UART_HandleTypeDef huart3;
extern DMA_HandleTypeDef hdma1_stream1; extern DMA_HandleTypeDef hdma1_stream1;
extern DMA_HandleTypeDef hdma2_stream2; extern DMA_HandleTypeDef hdma2_stream2;
extern DMA_HandleTypeDef hdma1_stream3; extern DMA_HandleTypeDef hdma1_stream3;
extern SPI_HandleTypeDef hspi1;
extern bool htim6_enable; extern bool htim6_enable;
extern bool htim7_enable; extern bool htim7_enable;
@ -24,3 +28,7 @@ extern bool huart3_enable;
extern bool hdma1_stream1_enable; extern bool hdma1_stream1_enable;
extern bool hdma2_stream2_enable; extern bool hdma2_stream2_enable;
extern bool hdma1_stream3_enable; extern bool hdma1_stream3_enable;
extern bool hspi1_enable;
#ifdef __cplusplus
}
#endif

0
usrc/gservice.cpp → usrc/public_service/gservice.cpp

0
usrc/gservice.hpp → usrc/public_service/gservice.hpp

4
usrc/public_service/public_service.h

@ -0,0 +1,4 @@
#pragma once
#include "common_hardware_init.h"
#include "gins.h"

5
usrc/public_service/public_service.hpp

@ -0,0 +1,5 @@
#pragma once
#include "common_hardware_init.h"
#include "gins.h"
#include "gservice.hpp"

2
usrc/subboards/subboard30_shake_module/subboard30_shake_module.cpp

@ -2,7 +2,7 @@
extern "C" { extern "C" {
#include "subboard30_shake_module_board.h" #include "subboard30_shake_module_board.h"
} }
#include "usrc/gservice.hpp"
#define TAG "ShakeModule" #define TAG "ShakeModule"

49
usrc/subboards/subboard30_shake_module/subboard30_shake_module_board.c

@ -1,20 +1,11 @@
#include "main.h" #include "main.h"
#include "public_service/common_hardware_init.h"
#if 0
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
SPI_HandleTypeDef hspi1;
#include "public_service/public_service.h"
/* SPI1 init function */ /* SPI1 init function */
void MX_SPI1_Init(void) { void MX_SPI1_Init(void) {
/* USER CODE BEGIN SPI1_Init 0 */
/* USER CODE END SPI1_Init 0 */
/* USER CODE BEGIN SPI1_Init 1 */
__HAL_RCC_SPI1_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/* USER CODE END SPI1_Init 1 */
hspi1.Instance = SPI1; hspi1.Instance = SPI1;
hspi1.Init.Mode = SPI_MODE_MASTER; hspi1.Init.Mode = SPI_MODE_MASTER;
hspi1.Init.Direction = SPI_DIRECTION_2LINES; hspi1.Init.Direction = SPI_DIRECTION_2LINES;
@ -31,28 +22,6 @@ void MX_SPI1_Init(void) {
Error_Handler(); Error_Handler();
} }
GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitTypeDef GPIO_InitStruct = {0};
/* USER CODE BEGIN SPI1_Init 2 */
/* USER CODE END SPI1_Init 2 */
}
void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle) {
GPIO_InitTypeDef GPIO_InitStruct = {0};
if (spiHandle->Instance == SPI1) {
/* USER CODE BEGIN SPI1_MspInit 0 */
/* USER CODE END SPI1_MspInit 0 */
/* SPI1 clock enable */
__HAL_RCC_SPI1_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/**SPI1 GPIO Configuration
PA5 ------> SPI1_SCK
PA6 ------> SPI1_MISO
PA7 ------> SPI1_MOSI
*/
GPIO_InitStruct.Pin = GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7; GPIO_InitStruct.Pin = GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
@ -60,12 +29,10 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle) {
GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* USER CODE BEGIN SPI1_MspInit 1 */
/* USER CODE END SPI1_MspInit 1 */
hspi1_enable = true;
} }
}
#endif
#include "public_service/gins.h"
void subboard30_shake_module_board_init() { common_hardware_init(); }
void subboard30_shake_module_board_init() {
common_hardware_init();
MX_SPI1_Init();
}
Loading…
Cancel
Save