资源简介
这是一个用stm32实现玉成控制家用太阳能或者是工业太阳能的远程控制器,使用了AD转换、看门狗、flash的读写,TCP/IP协议等。

代码片段和文件信息
#include “include.h“
#define pgm_read_byte(ptr) ((char)*(ptr))
static unsigned short wwwport = 80;
static unsigned char macaddr[6];
static unsigned char ipaddr[4];
static unsigned int info_hdr_len = 0;
static unsigned int info_data_len = 0;
static unsigned char seqnum = 0xa; // my initial tcp sequence number
// The Ip checksum is calculated over the ip header only starting
// with the header length field and a total length of 20 bytes
// unitl ip.dst
// You must set the IP checksum field to zero before you start
// the calculation.
// len for ip is 20.
//
// For UDP/TCP we do not make up the required pseudo header. Instead we
// use the ip.src and ip.dst fields of the real packet:
// The udp checksum calculation starts with the ip.src field
// Ip.src=4bytesIp.dst=4 bytesUdp header=8bytes + data length=16+len
// In other words the len here is 8 + length over which you actually
// want to calculate the checksum.
// You must set the checksum field to zero before you start
// the calculation.
// len for udp is: 8 + 8 + data length
// len for tcp is: 4+4 + 20 + option len + data length
//
// For more information on how this algorithm works see:
// http://www.netfor2.com/checksum.html
// http://www.msc.uky.edu/ken/cs471/notes/chap3.htm
// The RFC has also a C code example: http://www.faqs.org/rfcs/rfc1071.html
unsigned int checksum(unsigned char* buf unsigned int len unsigned char type)
{
// type 0=ip
// 1=udp
// 2=tcp
unsigned long sum = 0;
//if(type==0){
// // do not add anything
//}
if (type == 1)
{
sum += IP_PROTO_UDP_V; // protocol udp
// the length here is the length of udp (data+header len)
// =length given to this function - (IP.scr+IP.dst length)
sum += len - 8; // = real tcp len
}
if (type == 2)
{
sum += IP_PROTO_TCP_V;
// the length here is the length of tcp (data+header len)
// =length given to this function - (IP.scr+IP.dst length)
sum += len - 8; // = real tcp len
}
// build the sum of 16bit words
while (len > 1)
{
sum += 0xFFFF & (*buf << 8 | *(buf + 1));
buf += 2;
len -= 2;
}
// if there is a byte left then add it (padded with zero)
if (len)
{
sum += (0xFF & *buf) << 8;
}
// now calculate the sum over the bytes in the sum
// until the result is only 16bit long
while (sum >> 16)
{
sum = (sum & 0xFFFF) + (sum >> 16);
}
// build 1‘s complement:
return((unsigned int) sum ^ 0xFFFF);
}
// you must call this function once before you use any of the other functions:
void init_ip_arp_udp_tcp(unsigned char* mymac unsigned char* myip unsigned short wwwp)
{
unsigned char i = 0;
wwwport = wwwp;
while (i < 4)
{
ipaddr[i] = myip[i];
i++;
}
i = 0;
while (i < 6)
{
macaddr[i] = mymac[i];
i++;
}
}
void set_tcp_port(
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-04-10 19:49 智能热水工程控制系统(校验版)\
文件 9648 2012-04-05 22:09 智能热水工程控制系统(校验版)\ENC28J60.C
文件 9354 2012-04-05 22:09 智能热水工程控制系统(校验版)\ENC28J60.H
目录 0 2012-04-10 19:46 智能热水工程控制系统(校验版)\FATFS\
文件 8252 2012-04-05 22:09 智能热水工程控制系统(校验版)\FATFS\00readme.txt
文件 25104 2012-04-05 22:09 智能热水工程控制系统(校验版)\FATFS\SPI_SD_driver.c
文件 2408 2012-04-05 22:09 智能热水工程控制系统(校验版)\FATFS\SPI_SD_driver.h
文件 6235 2012-04-05 22:09 智能热水工程控制系统(校验版)\FATFS\diskio.c
文件 1864 2012-04-05 22:09 智能热水工程控制系统(校验版)\FATFS\diskio.h
文件 67089 2012-04-05 22:09 智能热水工程控制系统(校验版)\FATFS\ff.c
文件 11811 2012-04-05 22:09 智能热水工程控制系统(校验版)\FATFS\ff.h
文件 911 2012-04-05 22:09 智能热水工程控制系统(校验版)\FATFS\integer.h
文件 58520 2012-04-05 22:09 智能热水工程控制系统(校验版)\FATFS\tff.c
文件 10614 2012-04-05 22:09 智能热水工程控制系统(校验版)\FATFS\tff.h
文件 659780 2012-04-05 22:09 智能热水工程控制系统(校验版)\FS_CM3.lib
文件 12950 2012-04-05 22:09 智能热水工程控制系统(校验版)\File_Config.h
文件 319488 2012-04-05 22:09 智能热水工程控制系统(校验版)\Flex.ocx
文件 677 2012-04-05 22:09 智能热水工程控制系统(校验版)\JD.pic
文件 497 2012-04-10 19:48 智能热水工程控制系统(校验版)\Jli
文件 327741 2012-04-10 19:49 智能热水工程控制系统(校验版)\Jli
文件 285 2012-04-05 22:09 智能热水工程控制系统(校验版)\Jli
目录 0 2012-04-10 19:46 智能热水工程控制系统(校验版)\List\
文件 256903 2012-04-10 19:48 智能热水工程控制系统(校验版)\List\DLP.map
文件 91188 2012-04-05 22:09 智能热水工程控制系统(校验版)\List\STM3210E-EVAL.map
文件 26137 2012-04-10 19:48 智能热水工程控制系统(校验版)\List\cortexm3_macro.lst
文件 36908 2012-04-10 19:48 智能热水工程控制系统(校验版)\List\stm32f10x_vector.lst
文件 1081616 2012-04-05 22:09 智能热水工程控制系统(校验版)\MSCOMCTL.OCX
文件 162816 2012-04-05 22:09 智能热水工程控制系统(校验版)\MSCOMM32.OCX
文件 1388544 2012-04-05 22:09 智能热水工程控制系统(校验版)\MSVBVM60.DLL
文件 108336 2012-04-05 22:09 智能热水工程控制系统(校验版)\MSWINSCK.OCX
文件 49152 2012-04-05 22:09 智能热水工程控制系统(校验版)\NCset.exe
............此处省略223个文件信息
- 上一篇:金蝶K3服务器安装与配置方法详细图解
- 下一篇:八路彩灯循环显示控制电路课程设计
相关资源
- STM32F103RC+ADC+DMA多通道采样LCD显示
- I2C读写AT24C02 基于STM32F103 cube116540
- 基于stm32f103ve的程序——跑马灯实验
- 基于STM32RCT6的步进电机驱动程序
- stm32f407上的两个can发送和接收例程
- STM32 led 时钟
- STM32 2.4G通信例程
- 直流无刷电机方波驱动 stm32 例程代码
- STM32中文资料
- STM32蓝牙和串口程序
- STM32f103超声波模块例程
- stm32f103c8t6 4 oled.rar
- stm32f030 IAP Demo(原创)
- STM32基于rt_thread操作系统的SDHC卡文件
- NRF24L01实现51与STM32双向通讯
- STM32F103 串口程序(完整版)
- stm32 ds18b20 温度传感器 测试通过
- stm32官方例程
- STM32F103定时器中断程序
- [免费]基于stm32f103ze 的OLED驱动代码
- STM32F103RBT6驱动UC1698控制芯片的160160黑
- STM32F103 DS18B20 V3.5.0固件库驱动程序工
- STM32定时器使用入门。看了这个程序会
- SIM908 SDIO FSMC STM32 FIFO
- STM32F103 CC2500完整驱动(模拟SPI)
- AD7606采集程序
- PC-1D太阳能仿真软件
- stm32 用SPI 方式读写 SDHC
- stm32通过DMA方式采集ADC数据
- 意法半导体STM全系列微控制器STM32ST
评论
共有 条评论