资源简介
HT-001 RN8209电表套件(STM32带电能),带全部的电路原理图,源代码和相关文档说明。
代码片段和文件信息
#include “include.h“
#include“Config.h“
#include“delay.h“
//#include“control.h“
//#include“suanfa.h“
#include “RN8209.h“
//#include “OLED.h“
#include “LCD1353.h“
#include “key.h“ //按键
#include “commucation.h“ //通讯子程序
extern unsigned int HDP;
extern unsigned int VDP;
void Delay(vu32 nCount);
void Delay2(vu32 nCount);
void RCC_Configuration(void);
void GPIO_Configuration(void);
void NVIC_Configuration(void);
void USART_Configuration(void);
//void USART2_Configuration(void);
void stm32fsmc_init(void);
void SysTick_Configuration(void);
void Adc_Init(void);
void saveini(void)
{
char i;
// u32 tmp;
/* Unlock the Flash Program Erase controller */
FLASH_Unlock();
/* Clear All pending flags */
FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
FLASH_ErasePage(FLASH_ADDR);
FLASH_ProgramWord(FLASH_ADDR ((addr<<16)|mywwwport));
FLASH_ProgramWord(FLASH_ADDR+4 ((mytcpport<<16)|myudpport));
FLASH_ProgramWord(FLASH_ADDR+8 ((myip[0]<<24)|(myip[1]<<16)|(myip[2]<<8)|myip[3]));
FLASH_ProgramWord(FLASH_ADDR+12 ((bps<<16)));
}
void loadini(void) {
// char i;
u32 j;
j=*(pp);
addr=j>>16;
mywwwport=j&0xffff;
j=*(pp+1);
mytcpport=j>>16;
myudpport=j&0xffff;
j=*(pp+2);
myip[0]=j>>24;
myip[1]=(j>>16)&0xff;
myip[2]=(j>>8)&0xff;
myip[3]=j&0xff;
}
//默认设置
void defaultset(void)
{
myip[0]=192;
myip[1]=168;
myip[2]=1;
myip[3]=200;
myudpport=1200;
mytcpport=1300;
mywwwport=80;
addr=1;
bps=192;
vset[0]=10;
vset[1]=10;
vset[2]=10;
vset[3]=10;
vset[4]=10;
vset[5]=10;
vset[6]=10;
vset[7]=10;
vset[8]=10; //2013-3-12
vset[9]=10; //2013-3-12
ad_fx[0]=10;
ad_fx[1]=10;
ad_fx[2]=10;
ad_fx[3]=10;
ad_fx[4]=10;
ad_fx[5]=10;
ad_fx[6]=10;
ad_fx[7]=10;
}
//spi初始化
void SPI1_Init(void)
{
SPI_InitTypeDef SPI_InitStructure;
/* SPI1 configuration */
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(SPI2 &SPI_InitStructure);
/* Enable SPI1 */
SPI_Cmd(SPI2 ENABLE);
}
//SPI1读写一字节数据
unsigned char SPI2_ReadWrite(unsigned char writedat)
{
/* Loop while DR register in not emplty */
while (SPI_I2S_GetFlagStatus(SPI2 SPI_I2S_FLAG_TXE) == RESET);
/* Send byte through the SPI1 peripheral */
SPI_I2S_SendData(SPI2 writedat);
/* Wait to receive a byte */
while (SPI_I2S_GetFlagStatus(SPI2 SPI_I2S_FLAG_RXNE) == RESET);
/* Return the byte read from the SPI bus
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3057807 2009-03-19 14:16 PL2303\PL2303_Prolific_GPS_1013_20090319.exe
文件 2262196 2011-08-18 15:33 PL2303\pl2303_prolific_gps_1013_20090319.zip
文件 1081 2009-08-18 15:37 PL2303\releasenote.txt
目录 0 2016-02-11 07:48 PL2303
----------- --------- ---------- ----- ----
5321084 4
评论
共有 条评论