当前位置:网站首页>4G module board level control interface designed by charging pile
4G module board level control interface designed by charging pile
2022-07-03 09:59:00 【Wukong is so timid】
//0--off 1--on
void app4g_standby_io_init(void)//power
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; //PB6 Reuse as TIM4 The passage of 1
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
}
void app4g_standby_io_high(void)
{
GPIO_SetBits(GPIOC, GPIO_Pin_0);
}
void app4g_standby_io_low(void)
{
GPIO_ResetBits(GPIOC, GPIO_Pin_0);
}
void app4g_reset_io_init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; //PB6 Reuse as TIM4 The passage of 1
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
}
void app4g_reset_io_high(void)
{
GPIO_SetBits(GPIOC, GPIO_Pin_1);
}
void app4g_reset_io_low(void)
{
GPIO_ResetBits(GPIOC, GPIO_Pin_1);
}
uint32_t start_time_4g = 0;
uint32_t start_time2_4g = 0;
uint32_t end_time_4g = 0;
void app4g_reset_start_time(void)
{
start_time_4g =get_curtime2();
return ;
}
void app4g_reset_ok_time(void)
{
//start_time2_4g =osKernelGetTickCount();
start_time2_4g =get_curtime2();
return ;
}
void app4g_run_ok_time(void)
{
end_time_4g =get_curtime2();
return ;
}
uint32_t app4g_run_ok_need_time(void)
{
printf("4g_run_ok %d %d %d, %d\r\n",start_time_4g,start_time2_4g,end_time_4g,end_time_4g?(end_time_4g-start_time_4g)/1000:0);
return (end_time_4g-start_time_4g)/10;
}
STM32F103 UART1/UART2/UART3 DMA Sending and receiving program
uint16_t uart1_dma_send_data(unsigned char* buffer, uint16_t size)
{
uint16_t send_size = 0;
if(!buffer)
return 0;// Judge whether the length is valid
if(!size)
return 0;// Judge whether the length is valid
//printf("%s buffer=%s size=%d start\r\n",__func__,buffer,size);
// while (DMA_GetCurrDataCounter(DMA1_Channel4));// Check DMA Is there any data in the transmission channel
if(buffer)
{
send_size = (size > UART1_TX_BUFFER_LEN?UART1_TX_BUFFER_LEN:size);
reset_uart1_tx_buffer();
memcpy(TxBuffer1, buffer,send_size);
TxCounter1=send_size;
}
//printf("send_size=%d\r\n",send_size);
//DMA send data - We need to close it first Set the sending length Turn on DMA
DMA_Cmd(DMA1_Channel4, DISABLE);
//DMA1_Channel7->CNDTR = send_size;// Set the sending length
DMA_SetCurrDataCounter(DMA1_Channel4,send_size);
CurrDataCounterEnd_dma1_4 = DMA_GetCurrDataCounter(DMA1_Channel4);
/* Enable DMA1 Channel6 Transfer Complete interrupt */
DMA_ITConfig(DMA1_Channel4, DMA_IT_TC, ENABLE);
DMA_Cmd(DMA1_Channel4, ENABLE); // start-up DMA send out
/* Wait the end of transmission */
// time_start = get_curtime();
while (CurrDataCounterEnd_dma1_4 != 0 )
{
;
}
//printf("%s buffer=%s size=%d start\r\n",__func__,buffer,size);
return send_size;
}
uint16_t uart2_dma_send_data(unsigned char* buffer, uint16_t size)
{
uint16_t send_size = 0;
if(!buffer)
return 0;// Judge whether the length is valid
if(!size)
return 0;// Judge whether the length is valid
//printf("%s buffer=%s size=%d start\r\n",__func__,buffer,size);
//while (DMA_GetCurrDataCounter(DMA1_Channel7));// Check DMA Is there any data in the transmission channel
if(buffer)
{
send_size = (size > UART2_TX_BUFFER_LEN?UART2_TX_BUFFER_LEN:size);
reset_uart2_tx_buffer();
memcpy(TxBuffer2, buffer,send_size);
TxCounter2=send_size;
}
//printf("send_size=%d\r\n",send_size);
//DMA send data - We need to close it first Set the sending length Turn on DMA
DMA_Cmd(DMA1_Channel7, DISABLE);
//DMA1_Channel7->CNDTR = send_size;// Set the sending length
DMA_SetCurrDataCounter(DMA1_Channel7,send_size);
#if 0//(UART2_RX_DMA ==1)
DMA_Enable(DMA1_Channel7,UART2_RX_BUFFER_LEN);// Turn on the next time DMA receive
#endif
CurrDataCounterEnd_dma1_7 = DMA_GetCurrDataCounter(DMA1_Channel7);
/* Enable DMA1 Channel6 Transfer Complete interrupt */
DMA_ITConfig(DMA1_Channel7, DMA_IT_TC, ENABLE);
DMA_Cmd(DMA1_Channel7, ENABLE); // start-up DMA send out
/* Wait the end of transmission */
// time_start = get_curtime();
while (CurrDataCounterEnd_dma1_7 != 0 )
{
;
}
// go out;
//out:
// printf("send end\r\n");
DMA_ITConfig(DMA1_Channel7, DMA_IT_TC, DISABLE);
DMA_Cmd(DMA1_Channel7, DISABLE);
reset_uart2_tx_buffer();
//reset_uart2_rx_buffer();
//
//DMA_Enable(DMA1_Channel6,UART2_RX_BUFFER_LEN);// Turn on the next time DMA receive
//USART_DMACmd(USART2, USART_DMAReq_Rx, ENABLE);// Turn on DMA receive
//printf("%s buffer=%s size=%d start\r\n",__func__,buffer,size);
return send_size;
}
uint16_t uart3_dma_send_data(unsigned char* buffer, uint16_t size)
{
uint16_t send_size = 0;
if(!buffer)
return 0;// Judge whether the length is valid
if(!size)
return 0;// Judge whether the length is valid
//printf("%s buffer=%s size=%d start\r\n",__func__,buffer,size);
//send_size = DMA_GetCurrDataCounter(DMA1_Channel2);
//printf("uart3 tx de send_size=%d\r\n",send_size);
//while (DMA_GetCurrDataCounter(DMA1_Channel2));// Check DMA Is there any data in the transmission channel
if(buffer)
{
send_size = (size > UART3_TX_BUFFER_LEN?UART3_TX_BUFFER_LEN:size);
reset_uart3_tx_buffer();
memcpy(TxBuffer3, buffer,send_size);
TxCounter3=send_size;
}
//printf("send_size=%d\r\n",send_size);
//DMA send data - We need to close it first Set the sending length Turn on DMA
DMA_Cmd(DMA1_Channel2, DISABLE);
//DMA1_Channel7->CNDTR = send_size;// Set the sending length
DMA_SetCurrDataCounter(DMA1_Channel2,send_size);
#if 0//(UART3_RX_DMA ==1)
DMA_Enable(DMA1_Channel3,UART4_RX_BUFFER_LEN);// Turn on the next time DMA receive
#endif
CurrDataCounterEnd_dma1_2 = DMA_GetCurrDataCounter(DMA1_Channel2);
/* Enable DMA1 Channel6 Transfer Complete interrupt */
DMA_ITConfig(DMA1_Channel2, DMA_IT_TC, ENABLE);
DMA_Cmd(DMA1_Channel2, ENABLE); // start-up DMA send out
/* Wait the end of transmission */
// time_start = get_curtime();
while (CurrDataCounterEnd_dma1_2 != 0 )
{
;
}
// go out;
//out:
// printf("send end\r\n");
// DMA_ITConfig(DMA1_Channel2, DMA_IT_TC, DISABLE);
// DMA_Cmd(DMA1_Channel2, DISABLE);
// reset_uart3_tx_buffer();
//reset_uart2_rx_buffer();
//
//DMA_Enable(DMA1_Channel6,UART2_RX_BUFFER_LEN);// Turn on the next time DMA receive
//USART_DMACmd(USART2, USART_DMAReq_Rx, ENABLE);// Turn on DMA receive
//printf("%s buffer=%s size=%d start\r\n",__func__,buffer,size);
return send_size;
}
uint16_t uart4_dma_send_data(unsigned char* buffer, uint16_t size)
{
uint16_t send_size = 0;
if(!buffer)
return 0;// Judge whether the length is valid
if(!size)
return 0;// Judge whether the length is valid
//printf("%s buffer=%s size=%d start\r\n",__func__,buffer,size);
//while (DMA_GetCurrDataCounter(DMA2_Channel5));// Check DMA Is there any data in the transmission channel
if(buffer)
{
send_size = (size > UART4_TX_BUFFER_LEN?UART4_TX_BUFFER_LEN:size);
reset_uart4_tx_buffer();
memcpy(TxBuffer4, buffer,send_size);
TxCounter4=send_size;
}
//printf("send_size=%d\r\n",send_size);
//DMA send data - We need to close it first Set the sending length Turn on DMA
DMA_Cmd(DMA2_Channel5, DISABLE);
//DMA1_Channel7->CNDTR = send_size;// Set the sending length
DMA_SetCurrDataCounter(DMA2_Channel5,send_size);
#if 0//(UART2_RX_DMA ==1)
DMA_Enable(DMA1_Channel7,UART2_RX_BUFFER_LEN);// Turn on the next time DMA receive
#endif
CurrDataCounterEnd_dma2_5 = DMA_GetCurrDataCounter(DMA2_Channel5);
/* Enable DMA1 Channel6 Transfer Complete interrupt */
DMA_ITConfig(DMA2_Channel5, DMA_IT_TC, ENABLE);
DMA_Cmd(DMA2_Channel5, ENABLE); // start-up DMA send out
/* Wait the end of transmission */
// time_start = get_curtime();
while (CurrDataCounterEnd_dma2_5 != 0 )
{
;
}
// go out;
//out:
// printf("send end\r\n");
//DMA_ITConfig(DMA2_Channel5, DMA_IT_TC, DISABLE);
//DMA_Cmd(DMA2_Channel5, DISABLE);
//reset_uart4_tx_buffer();
return send_size;
}
边栏推荐
- It is difficult to quantify the extent to which a single-chip computer can find a job
- 单片机学到什么程度能找到工作,这个标准不好量化
- Design of charging pile mqtt transplantation based on 4G EC20 module
- Seven sorting of ten thousand words by hand (code + dynamic diagram demonstration)
- [keil5 debugging] warning:enumerated type mixed with other type
- Project cost management__ Plan value_ Earned value_ Relationship among actual cost and Countermeasures
- Quelle langue choisir pour programmer un micro - ordinateur à puce unique
- byte alignment
- 01仿B站项目业务架构
- Project cost management__ Cost management technology__ Article 6 prediction
猜你喜欢
Fundamentals of Electronic Technology (III)_ Integrated operational amplifier and its application__ Basic arithmetic circuit
干单片机这一行的时候根本没想过这么多,只想着先挣钱养活自己
UCI and data multiplexing are transmitted on Pusch (Part V) -- polar coding
单片机现在可谓是铺天盖地,种类繁多,让开发者们应接不暇
CEF下载,编译工程
[CSDN] C1 training problem analysis_ Part II_ Web Foundation
Fundamentals of Electronic Technology (III)__ Logic gate symbols in Chapter 5
openEuler kernel 技术分享 - 第1期 - kdump 基本原理、使用及案例介绍
Embedded systems are inherently flawed. Compared with the Internet, there are so many holes that it is simply difficult to walk away from
单片机职业发展:能做下去的都成牛人了,熬不动就辞职或者改行了
随机推荐
开学实验里要用到mysql,忘记基本的select语句怎么玩啦?补救来啦~
Sending and interrupt receiving of STM32 serial port
JMX、MBean、MXBean、MBeanServer 入门
Runtime. getRuntime(). GC () and runtime getRuntime(). The difference between runfinalization()
STM32 running lantern experiment - library function version
Runtime.getRuntime().gc() 和 Runtime.getRuntime().runFinalization() 的区别
Nr-prach:prach format and time-frequency domain
Which language should I choose to program for single chip microcomputer
STM32 port multiplexing and remapping
It is difficult to quantify the extent to which a single-chip computer can find a job
2020-08-23
QT qcombobox QSS style settings
Assignment to '*' form incompatible pointer type 'linkstack' {aka '*'} problem solving
uniapp 实现微信小程序全局分享及自定义分享按钮样式
Stm32 NVIC interrupt priority management
JS基础-原型原型链和宏任务/微任务/事件机制
GPIO port details, Hal library operation keys
Qt QComboBox QSS样式设置
The third paper of information system project manager in soft examination
STM32 general timer output PWM control steering gear