Browse Source

update

master
zhaohe 1 year ago
parent
commit
af8bf2676a
  1. 54
      usrc/main.cpp
  2. 2
      usrc/project_configs.h
  3. 13
      usrc/public_service/stm32irq.c
  4. 47
      usrc/subboards/subboard60_inlet_and_outlet_module/subboard60_inlet_and_outlet_module_board.c

54
usrc/main.cpp

@ -5,9 +5,15 @@
#include "public_service/public_service.hpp" #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 "sysmgr/sys_mgr.hpp"
//
#include "subboards/subboard30_shake_module/subboard30_shake_module.hpp" #include "subboards/subboard30_shake_module/subboard30_shake_module.hpp"
#include "subboards/subboard30_shake_module/subboard30_shake_module_board.h" #include "subboards/subboard30_shake_module/subboard30_shake_module_board.h"
#include "sysmgr/sys_mgr.hpp"
#include "subboards/subboard60_inlet_and_outlet_module/subboard60_inlet_and_outlet_module.hpp"
#include "subboards/subboard60_inlet_and_outlet_module/subboard60_inlet_and_outlet_module_board.h"
//
#define TAG "main" #define TAG "main"
using namespace std; using namespace std;
using namespace iflytop; using namespace iflytop;
@ -16,16 +22,42 @@ extern void umain();
extern "C" { extern "C" {
void StartDefaultTask(void const* argument) { umain(); } void StartDefaultTask(void const* argument) { umain(); }
} }
void umain() {
int32_t id = zdevice_id_mgr_get_device_id();
switch (id) {
int32_t deviceId = 0;
static void board_init() {
switch (deviceId) {
case 30: // 摇匀模组 case 30: // 摇匀模组
subboard30_shake_module_board_init(); subboard30_shake_module_board_init();
break; break;
case 60: // 进出料模组
subboard60_inlet_and_outlet_module_board_init();
break;
default: default:
common_hardware_init(); common_hardware_init();
break; break;
} }
}
static void board_post_init() {
GService::inst()->initialize();
switch (deviceId) {
case 30: // 摇匀模组
Subboard30ShakeModule::ins()->initialize();
break;
case 60: // 进出料模组
Subboard60InjectAndOutletModule::ins()->initialize();
break;
default:
break;
}
}
void umain() {
deviceId = zdevice_id_mgr_get_device_id();
board_init();
zos_cfg_t zoscfg = {0}; zos_cfg_t zoscfg = {0};
chip_cfg_t chipcfg = {}; chip_cfg_t chipcfg = {};
@ -44,9 +76,9 @@ void umain() {
ZEARLY_LOGI("SYS", "= version : %d", PC_VERSION); ZEARLY_LOGI("SYS", "= version : %d", PC_VERSION);
ZEARLY_LOGI("SYS", "= freq : %d", HAL_RCC_GetSysClockFreq()); ZEARLY_LOGI("SYS", "= freq : %d", HAL_RCC_GetSysClockFreq());
ZEARLY_LOGI("SYS", "= build time : %s", __DATE__ " " __TIME__); ZEARLY_LOGI("SYS", "= build time : %s", __DATE__ " " __TIME__);
ZEARLY_LOGI("SYS", "= device id : %d", id);
ZEARLY_LOGI("SYS", "= device id : %d", deviceId);
if (id <= 0) {
if (deviceId <= 0) {
chip_set_error(); chip_set_error();
ZEARLY_LOGE("SYS", "device id is not set"); ZEARLY_LOGE("SYS", "device id is not set");
while (true) { while (true) {
@ -54,15 +86,7 @@ void umain() {
} }
} }
GService::inst()->initialize();
switch (id) {
case 30: // 摇匀模组
Subboard30ShakeModule::ins()->initialize();
break;
default:
break;
}
board_post_init();
ZLOGI(TAG, "======================= sysinfo ======================= "); ZLOGI(TAG, "======================= sysinfo ======================= ");
SysMgr::ins()->initedFinished(); SysMgr::ins()->initedFinished();

2
usrc/project_configs.h

@ -1,5 +1,5 @@
#pragma once #pragma once
#define PC_VERSION 100
#define PC_VERSION 101
#define PC_MANUFACTURER "http://www.iflytop.com/" #define PC_MANUFACTURER "http://www.iflytop.com/"
#define PC_PROJECT_NAME "a8000_subboard" #define PC_PROJECT_NAME "a8000_subboard"
#define PC_IFLYTOP_ENABLE_OS 1 #define PC_IFLYTOP_ENABLE_OS 1

13
usrc/public_service/stm32irq.c

@ -63,19 +63,24 @@ void CAN1_RX1_IRQHandler(void) {
void CAN1_SCE_IRQHandler(void) { void CAN1_SCE_IRQHandler(void) {
if (hcan1_enable) HAL_CAN_IRQHandler(&hcan1); if (hcan1_enable) HAL_CAN_IRQHandler(&hcan1);
} }
//
void TIM1_TRG_COM_TIM11_IRQHandler(void) { void TIM1_TRG_COM_TIM11_IRQHandler(void) {
if (htim11_enable) HAL_TIM_IRQHandler(&htim11); if (htim11_enable) HAL_TIM_IRQHandler(&htim11);
} }
void USART1_IRQHandler(void) {
if (huart1_enable) HAL_UART_IRQHandler(&huart1);
}
void TIM6_DAC_IRQHandler(void) { void TIM6_DAC_IRQHandler(void) {
if (htim6_enable) HAL_TIM_IRQHandler(&htim6); if (htim6_enable) HAL_TIM_IRQHandler(&htim6);
} }
void TIM7_IRQHandler(void) { void TIM7_IRQHandler(void) {
if (htim7_enable) HAL_TIM_IRQHandler(&htim7); if (htim7_enable) HAL_TIM_IRQHandler(&htim7);
} }
//
void USART1_IRQHandler(void) {
if (huart1_enable) HAL_UART_IRQHandler(&huart1);
}
void USART3_IRQHandler(void) {
if (huart3_enable) HAL_UART_IRQHandler(&huart3);
}
/*********************************************************************************************************************** /***********************************************************************************************************************
* EXT * * EXT *
***********************************************************************************************************************/ ***********************************************************************************************************************/

47
usrc/subboards/subboard60_inlet_and_outlet_module/subboard60_inlet_and_outlet_module_board.c

@ -37,7 +37,6 @@ static void UART3_Init() {
__HAL_RCC_USART3_CLK_ENABLE(); __HAL_RCC_USART3_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_DMA1_CLK_ENABLE();
huart3.Instance = USART3; huart3.Instance = USART3;
huart3.Init.BaudRate = 9600; huart3.Init.BaudRate = 9600;
@ -58,48 +57,12 @@ static void UART3_Init() {
GPIO_InitStruct.Alternate = GPIO_AF7_USART3; GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
hdma1_stream1.Instance = DMA1_Stream1;
hdma1_stream1.Init.Channel = DMA_CHANNEL_4;
hdma1_stream1.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma1_stream1.Init.PeriphInc = DMA_PINC_DISABLE;
hdma1_stream1.Init.MemInc = DMA_MINC_ENABLE;
hdma1_stream1.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma1_stream1.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma1_stream1.Init.Mode = DMA_NORMAL;
hdma1_stream1.Init.Priority = DMA_PRIORITY_LOW;
hdma1_stream1.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
if (HAL_DMA_Init(&hdma1_stream1) != HAL_OK) {
Error_Handler();
}
__HAL_LINKDMA(&huart3, hdmarx, hdma1_stream1);
hdma1_stream3.Instance = DMA1_Stream3;
hdma1_stream3.Init.Channel = DMA_CHANNEL_4;
hdma1_stream3.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma1_stream3.Init.PeriphInc = DMA_PINC_DISABLE;
hdma1_stream3.Init.MemInc = DMA_MINC_ENABLE;
hdma1_stream3.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma1_stream3.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma1_stream3.Init.Mode = DMA_NORMAL;
hdma1_stream3.Init.Priority = DMA_PRIORITY_LOW;
hdma1_stream3.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
if (HAL_DMA_Init(&hdma1_stream3) != HAL_OK) {
Error_Handler();
}
__HAL_LINKDMA(&huart3, hdmatx, hdma1_stream3);
hdma_usart3_rx = &hdma1_stream1;
hdma_usart3_tx = &hdma1_stream3;
hdma1_stream1_enable = true;
hdma1_stream3_enable = true;
HAL_NVIC_SetPriority(DMA1_Stream1_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(DMA1_Stream1_IRQn);
/* USART3 interrupt Init */
HAL_NVIC_SetPriority(USART3_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(USART3_IRQn);
huart3_enable = true;
HAL_NVIC_SetPriority(DMA1_Stream3_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(DMA1_Stream3_IRQn);
// HAL_UART_IRQHandler(&huart3);
} }
void subboard60_inlet_and_outlet_module_board_init() { void subboard60_inlet_and_outlet_module_board_init() {

Loading…
Cancel
Save