//功能:串口初始化、打开定时器中断,然后一直接收数据状态就好了。发送在中断中实现
#include "stm32f10x.h"
#include "usart.h"
u8 USART_rx_data
int main(void)
{
RCC_Configuration() /和中巧/系统时钟配置
GPIO_Configuration() //端口初始化
NVIC_Configuration() //中断源配置
USART_Configuration()/培念/串口1初始化
Time_Init() //唤键定时器初始化
#ifdef DEBUG
debug()
#endif
TIM_Cmd(TIM3,ENABLE)
while(1)
{
}
}
第一步:用tftpserver.c中的err_t tftp_send_message(struct udp_pcb *upcb, struct ip_addr *to_ip, int to_port, char *buf, int buflen)向指定地址发送写文件请求侍饥锋;第二步:用tftpserver.c中的void process_tftp_request(struct pbuf *pkt_buf, struct ip_addr *addr, u16_t port)函数处理回应,如果接收到回应后,process_tftp_request函数中的int tftp_process_write(struct udp_pcb *upcb, struct ip_addr *to, int to_port, char *FileName)函数发送数据文件。
基本流程就是上述所说,肢团但是tftp_send_message()函数中的参数struct udp_pcb *upcb,数据结构非常复老晌杂
struct udp_pcb {
/* Common members of all PCB types */
IP_PCB
/* Protocol specific PCB members */
struct udp_pcb *next
u8_t flags
/* ports are in host byte order */
u16_t local_port, remote_port
#if LWIP_IGMP
/* outgoing network interface for multicast packets */
struct ip_addr multicast_ip
#endif /* LWIP_IGMP */
#if LWIP_UDPLITE
/* used for UDP_LITE only */
u16_t chksum_len_rx, chksum_len_tx
#endif /* LWIP_UDPLITE */
/* receive callback function
* addr and port are in same byte order as in the pcb
* The callback is responsible for freeing the pbuf
* if it's not used any more.
*
* ATTENTION: Be aware that 'addr' points into the pbuf 'p' so freeing this pbuf
*makes 'addr' invalid, too.
*
* @param arg user supplied argument (udp_pcb.recv_arg)
* @param pcb the udp_pcb which received data
* @param p the packet buffer that was received
* @param addr the remote IP address from which the packet was received
* @param port the remote port from which the packet was received
*/
void (* recv)(void *arg, struct udp_pcb *pcb, struct pbuf *p,
struct ip_addr *addr, u16_t port)
/* user-supplied argument for the recv callback */
void *recv_arg
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)