当前位置:网站首页>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;
}
边栏推荐
- 新系列单片机还延续了STM32产品家族的低电压和节能两大优势
- Sending and interrupt receiving of STM32 serial port
- 2020-08-23
- PIP references domestic sources
- Stm32-hal library learning, using cubemx to generate program framework
- [keil5 debugging] warning:enumerated type mixed with other type
- Nr--- Pusch I: sorting out the agreement process
- PRACH --- originator
- 自动装箱与拆箱了解吗?原理是什么?
- There is no specific definition of embedded system
猜你喜欢
万字手撕七大排序(代码+动图演示)
手机都算是单片机的一种,只不过它用的硬件不是51的芯片
2021-10-28
Getting started with JMX, MBean, mxbean, mbeanserver
Fundamentals of Electronic Technology (III)_ Integrated operational amplifier and its application__ Basic arithmetic circuit
For new students, if you have no contact with single-chip microcomputer, it is recommended to get started with 51 single-chip microcomputer
STM32 serial communication principle
Fundamentals of Electronic Technology (III)__ Fundamentals of circuit analysis__ Basic amplifier operating principle
Hal library sets STM32 clock
Windows下MySQL的安装和删除
随机推荐
Fundamentals of Electronic Technology (III)__ Fundamentals of circuit analysis__ Basic amplifier operating principle
Uniapp realizes global sharing of wechat applet and custom sharing button style
(2)接口中新增的方法
Successful graduation [2] - student health management system function development...
手机都算是单片机的一种,只不过它用的硬件不是51的芯片
openEuler kernel 技術分享 - 第1期 - kdump 基本原理、使用及案例介紹
没有多少人能够最终把自己的兴趣带到大学毕业上
A lottery like scissors, stone and cloth (C language)
SSB Introduction (PbCH and DMRs need to be supplemented)
Fundamentals of Electronic Technology (III)__ Chapter 6 combinational logic circuit
Application of external interrupts
STM32 general timer 1s delay to realize LED flashing
Notes on C language learning of migrant workers majoring in electronic information engineering
干单片机这一行的时候根本没想过这么多,只想着先挣钱养活自己
Idea remote breakpoint debugging jar package project
【力扣刷题笔记(二)】特别技巧,模块突破,45道经典题目分类总结,在不断巩固中精进
嵌入式本来就很坑,相对于互联网来说那个坑多得简直是难走
Raspberry pie installation SciPy
Blue Bridge Cup for migrant workers majoring in electronic information engineering
PRACH --- originator