52 lines
1.3 KiB
C
52 lines
1.3 KiB
C
#include "serial_port.h"
|
|
#include "main.h"
|
|
#include "usart.h"
|
|
#include "string.h"
|
|
#include "app.h"
|
|
#include "Uart1.h"
|
|
// HAL_UART_Transmit( &huartx, &data, timeout )//不带中断,不连续传输
|
|
// HAL_UART_Receive( &huartx, &data, timeout )
|
|
// HAL_UART_Transmit_IT( &huartx, &data, data_size )//带中断,连续传输
|
|
// HAL_UART_Receive_IT( &huartx, &data, data_size )
|
|
|
|
// HAL_SPI_Transmit( &hspix, &data, data_size,timeout )//不带中断,不连续传输
|
|
// HAL_SPI_Receive( &hspix, &data, data_size,timeout )
|
|
// HAL_SPI_Transmit_IT( &hspix, &data, data_size )//带中断,连续传输
|
|
// HAL_SPI_Receive_IT( &hspix, &data, data_size )
|
|
|
|
|
|
|
|
// 使用LP-300-SP的Type-A接口与计算机进行通信
|
|
// DATA_MAX defined in serial_port.h
|
|
char text_r[20] = {0};
|
|
char text_t[20] = {0};
|
|
unsigned char text_r8 = 0;
|
|
unsigned char uart_rx_temp[DATA_MAX];
|
|
char uart_rx_flag = 0;
|
|
|
|
unsigned int OrderNum = 0xF001;
|
|
unsigned int addr = 0x00A100B1;
|
|
unsigned char sData[9] = {0x00,0x01,0x01,0x00,0x01,0x03,0xE8,0x00,0x10};
|
|
|
|
void uart_test(void)
|
|
{
|
|
// if( it_1000ms_flag == 1)
|
|
// {
|
|
// it_1000ms_flag = 0;
|
|
// send_set_resp(OrderNum,addr,9,sData);
|
|
// }
|
|
|
|
// if(uart_rx_flag == 0)
|
|
// {
|
|
// uart_rx_flag = 1;
|
|
// HAL_UART_Receive_IT( &huart1,&text_r8, 1);
|
|
// }
|
|
|
|
// if(uart_rx_flag == 2)
|
|
// {
|
|
// HAL_UART_Transmit_IT( &huart1,uart_rx_temp, 20);
|
|
// }
|
|
|
|
}
|
|
|