使用单线程方式运行

This commit is contained in:
ranchuan
2023-07-14 18:52:42 +08:00
parent b15db16b91
commit e5abb86735
9 changed files with 817 additions and 93 deletions

View File

@@ -26,6 +26,8 @@
/* USER CODE BEGIN Includes */
#include "debug.h"
#include "board.h"
#include "mymain.h"
#include "string.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
@@ -66,6 +68,17 @@ static void MX_IPCC_Init(void);
/* USER CODE BEGIN PFP */
void VIRT_UART0_RxCpltCallback(VIRT_UART_HandleTypeDef *huart);
void VIRT_UART1_RxCpltCallback(VIRT_UART_HandleTypeDef *huart);
void send_str_to_a7(const char *str)
{
static uint8_t send_buff[512];
int len=strlen(str);
send_buff[0]=0xff;
send_buff[1]=len;
memcpy(send_buff+2,str,len);
VIRT_UART_Transmit(&huart0, send_buff, len+2);
}
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
@@ -79,12 +92,12 @@ void VIRT_UART1_RxCpltCallback(VIRT_UART_HandleTypeDef *huart);
int main(void)
{
/* USER CODE BEGIN 1 */
debug_init();
//debug_init();
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
DBG_LOG("mcu start.");
//DBG_LOG("mcu start.");
/* Reset of all peripherals, Initialize the Systick. */
HAL_Init();
@@ -141,10 +154,8 @@ int main(void)
Error_Handler();
}
pwm_def *pwm=dev_get("pwm");
pwm->init(pwm);
DBG_LOG("pwm start.");
pwm->start(pwm,1);
void *mymain=mymain_init();
/* USER CODE END 2 */
/* Infinite loop */
@@ -153,11 +164,13 @@ int main(void)
{
OPENAMP_check_for_message();
mymain_scan(mymain);
/* USER CODE END WHILE */
if (VirtUart0RxMsg) {
VirtUart0RxMsg = RESET;
// +2<><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡ͷ<D6A1>ͳ<EFBFBD><CDB3><EFBFBD>λ
VIRT_UART_Transmit(&huart0, VirtUart0ChannelBuffRx, VirtUart0ChannelRxSize);
mymain_loop(mymain,(char *)VirtUart0ChannelBuffRx+2);
}
if (VirtUart1RxMsg) {
@@ -307,6 +320,7 @@ void VIRT_UART0_RxCpltCallback(VIRT_UART_HandleTypeDef *huart)
/* copy received msg in a variable to sent it back to master processor in main infinite loop*/
VirtUart0ChannelRxSize = huart->RxXferSize < MAX_BUFFER_SIZE? huart->RxXferSize : MAX_BUFFER_SIZE-1;
memcpy(VirtUart0ChannelBuffRx, huart->pRxBuffPtr, VirtUart0ChannelRxSize);
VirtUart0ChannelBuffRx[VirtUart0ChannelRxSize]=0;
VirtUart0RxMsg = SET;
}
@@ -318,6 +332,7 @@ void VIRT_UART1_RxCpltCallback(VIRT_UART_HandleTypeDef *huart)
/* copy received msg in a variable to sent it back to master processor in main infinite loop*/
VirtUart1ChannelRxSize = huart->RxXferSize < MAX_BUFFER_SIZE? huart->RxXferSize : MAX_BUFFER_SIZE-1;
memcpy(VirtUart1ChannelBuffRx, huart->pRxBuffPtr, VirtUart1ChannelRxSize);
VirtUart1ChannelBuffRx[VirtUart1ChannelRxSize]=0;
VirtUart1RxMsg = SET;
}
/* USER CODE END 4 */