基本的版本
有初始化用的相关文件 驱动文件包括软件IIC还有基于此的24C0X驱动,Flash覆写,还有涉及上位机的启动代码
This commit is contained in:
74
bsp_Device/bsp_Console.c
Normal file
74
bsp_Device/bsp_Console.c
Normal file
@@ -0,0 +1,74 @@
|
||||
/*----------------------------------------------------------------------------------------------------
|
||||
# THIS FILE IS A PART OF XerolySkinner's PROJECT
|
||||
#
|
||||
# THIS PROGRAM IS FREE SOFTWARE
|
||||
#
|
||||
# E-mail:ZABBCCCBBAZ@163.com
|
||||
# QQ:2715099320
|
||||
#
|
||||
# Copyright (c) 2022 XerolySkinner
|
||||
# All rights reserved.
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------
|
||||
名字:bsp_Console
|
||||
时间:20220805-0424
|
||||
程序员:梁源康
|
||||
说明:搭建上位机处理
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// 头文件
|
||||
#include "vartable.h"
|
||||
#include "string.h"
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// 变量和定义
|
||||
//
|
||||
#define console_num(num) (*((num*)(console_buff+1)))
|
||||
#define CONSOLE_BUFF_LEN 32
|
||||
uint8_t console_buff[CONSOLE_BUFF_LEN]={0};
|
||||
struct console_pack consolePack={0,0,0};
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// 程序
|
||||
//
|
||||
void bsp_ConsoleInit(UART_HandleTypeDef *huart){
|
||||
// 开启空闲中断
|
||||
__HAL_UART_ENABLE_IT(huart,UART_IT_IDLE);
|
||||
// 接收相关内容
|
||||
HAL_UART_Receive_DMA(huart,console_buff,CONSOLE_BUFF_LEN);}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void bsp_ConsoleJump(UART_HandleTypeDef *huart){
|
||||
// 空闲中断跳转
|
||||
if(__HAL_UART_GET_FLAG(huart,UART_FLAG_IDLE)!=RESET){
|
||||
__HAL_UART_CLEAR_IDLEFLAG(huart);
|
||||
HAL_UART_IdleCpltCallback(huart);}}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void HAL_UART_IdleCpltCallback(UART_HandleTypeDef *huart){
|
||||
HAL_UART_DMAStop(huart);
|
||||
if(huart==&huart1){
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// 按钮识别区
|
||||
if(console_buff[0]==0){
|
||||
switch(console_buff[1]){
|
||||
case 0:
|
||||
printf("按钮0");break;
|
||||
case 1:
|
||||
printf("按钮1");break;
|
||||
default:
|
||||
printf("按钮未知\r\n");break;}}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// 包识别区-默认小端接收方式
|
||||
if(console_buff[0]==1){
|
||||
memcpy(&consolePack,console_buff+1,sizeof(struct console_pack));}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// 数值识别区
|
||||
if(console_buff[0]==2)printf("2号:%d\r\n",console_num(int));
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
HAL_UART_Receive_DMA(huart,console_buff,CONSOLE_BUFF_LEN);}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Reference in New Issue
Block a user