转 UTF8 编码

This commit is contained in:
WangQiang 2015-01-19 05:25:44 +00:00
parent cb6db52617
commit e1e22d3646
34 changed files with 105 additions and 105 deletions

90
ADC.cpp
View File

@ -1,23 +1,23 @@
#include "ADC.h"
#include "ADC.h"
#include "sys.h"
#include "Interrupt.h"
#include "Pin.h"
ADConverter::ADC_Channel _PinList[18]; // 记录注册顺序 三个ADC 每个ADC最多分配6个通道
//volatile byte _ADC_ChanelNum[3]={0,0,0}; // 记录每个ADC 有多少个通道在线 ->ADC_NbrOfChannel 此参数即可
volatile int _isChangeEvent=0x00000000; //使用18位 标志通道是否被修改顺序
ADConverter::ADC_Channel _PinList[18]; // 记录注册顺序 三个ADC 每个ADC最多分配6个通道
//volatile byte _ADC_ChanelNum[3]={0,0,0}; // 记录每个ADC 有多少个通道在线 ->ADC_NbrOfChannel 此参数即可
volatile int _isChangeEvent=0x00000000; //使用18位 标志通道是否被修改顺序
static ADC_TypeDef * const g_ADCs[3]= {ADC1,ADC2,ADC3}; // flash内
static ADC_TypeDef * const g_ADCs[3]= {ADC1,ADC2,ADC3}; // flash内
ADC_Stru * adc_IntStrs[3]={NULL,NULL,NULL}; // 三个ADC的类
ADC_Stru * adc_IntStrs[3]={NULL,NULL,NULL}; // 三个ADC的类
byte ADConverter::isSmall()
{ // 避免飞出
{ // 避免飞出
if(adc_IntStrs[0] == NULL)return 0;
if(adc_IntStrs[1] == NULL)return 1;
if(adc_IntStrs[2] == NULL)return 2;
// 已经有对象的时候 判断line数目
// 已经有对象的时候 判断line数目
if(adc_IntStrs[1]->adc_intstr.ADC_NbrOfChannel <= adc_IntStrs[2]->adc_intstr.ADC_NbrOfChannel)
{
if(adc_IntStrs[0]->adc_intstr.ADC_NbrOfChannel <= adc_IntStrs[1]->adc_intstr.ADC_NbrOfChannel)return 0;
@ -66,30 +66,30 @@ ADConverter:: ADConverter(ADC_Channel line)
{
assert_param( (line < PA10) || ((PC0 <= line) && (line < PC6)) || (0x80 == line)||(line == 0x81) );
ReallyChannel(line);
byte _ADC_group = isSmall(); // 选取负担最轻的ADC
ADC_TypeDef * _ADC = g_ADCs[_ADC_group]; // 取得对象所对应的ADC配置寄存器地址 配置必须参数
byte _ADC_group = isSmall(); // 选取负担最轻的ADC
ADC_TypeDef * _ADC = g_ADCs[_ADC_group]; // 取得对象所对应的ADC配置寄存器地址 配置必须参数
if(adc_IntStrs[_ADC_group] == NULL) //没有初始化 ADC 初始化参数class
if(adc_IntStrs[_ADC_group] == NULL) //没有初始化 ADC 初始化参数class
{
adc_IntStrs[_ADC_group] = new ADC_Stru(_ADC_group); // 申请一个ADC配置类结构体class 初始化参数由构造函数完成
// ADC_InitTypeDef * adc_intstr = & adc_IntStrs[_ADC_group]->adc_intstr; // 取得对象
RCC_ADCCLKConfig(RCC_PCLK2_Div6);// 时钟分频数 需要根据时钟进行调整
ADC_DeInit(_ADC); // 复位到默认值
adc_IntStrs[_ADC_group] = new ADC_Stru(_ADC_group); // 申请一个ADC配置类结构体class 初始化参数由构造函数完成
// ADC_InitTypeDef * adc_intstr = & adc_IntStrs[_ADC_group]->adc_intstr; // 取得对象
RCC_ADCCLKConfig(RCC_PCLK2_Div6);// 时钟分频数 需要根据时钟进行调整
ADC_DeInit(_ADC); // 复位到默认值
}
ADC_InitTypeDef * adc_intstr = & adc_IntStrs[_ADC_group]->adc_intstr; // 取得对象
ADC_DeInit(_ADC); // 每次修改通道数的时候先复位 // 是否有需要 不确定
ADC_InitTypeDef * adc_intstr = & adc_IntStrs[_ADC_group]->adc_intstr; // 取得对象
ADC_DeInit(_ADC); // 每次修改通道数的时候先复位 // 是否有需要 不确定
/* ADC_ScanConvMode:
DISABLE
ENABLE */
DISABLE
ENABLE */
if(adc_intstr->ADC_NbrOfChannel == 1)
adc_intstr->ADC_ScanConvMode=ENABLE;
/* ADC_NbrOfChannel:
*/
adc_intstr->ADC_NbrOfChannel += 1; //添加一个通道
*/
adc_intstr->ADC_NbrOfChannel += 1; //添加一个通道
ADC_Init(ADC1,adc_intstr);
if(line >= Vrefint) ADC_TempSensorVrefintCmd(ENABLE); // 启用 PVD 和 温度通道
if(line >= Vrefint) ADC_TempSensorVrefintCmd(ENABLE); // 启用 PVD 和 温度通道
}
//bool ADConverter::AddLine(ADC_Channel line)
@ -104,7 +104,7 @@ void ADConverter::OnConfig()
}
int ADConverter::Read() // 读取转换出来的结果
int ADConverter::Read() // 读取转换出来的结果
{
return adc_IntStrs[_ADC_group]->_AnalogValue[_ChannelNum];
}
@ -115,27 +115,27 @@ ADConverter:: ~ADConverter()
ADC_Stru::ADC_Stru(byte ADC_group)
{
/* ADC_Mode 模式:
ADC_Mode_Independent
ADC_Mode_RegInjecSimult
ADC_Mode_RegSimult_AlterTrig
ADC_Mode_InjecSimult_FastInterl
ADC_Mode_InjecSimult_SlowInterl
ADC_Mode_InjecSimult
ADC_Mode_RegSimult
ADC_Mode_FastInterl
ADC_Mode_SlowInterl
ADC_Mode_AlterTrig */
/* ADC_Mode 模式:
ADC_Mode_Independent
ADC_Mode_RegInjecSimult
ADC_Mode_RegSimult_AlterTrig
ADC_Mode_InjecSimult_FastInterl
ADC_Mode_InjecSimult_SlowInterl
ADC_Mode_InjecSimult
ADC_Mode_RegSimult
ADC_Mode_FastInterl
ADC_Mode_SlowInterl
ADC_Mode_AlterTrig */
adc_intstr.ADC_Mode = ADC_Mode_Independent;
/* ADC_ScanConvMode 转换模式:
DISABLE
ENABLE */
/* ADC_ScanConvMode 转换模式:
DISABLE
ENABLE */
adc_intstr.ADC_ScanConvMode = DISABLE;
/* ADC_ContinuousConvMode 是否连续转换:
DISABLE
ENABLE */
/* ADC_ContinuousConvMode 是否连续转换:
DISABLE
ENABLE */
adc_intstr.ADC_ContinuousConvMode = ENABLE;
/* ADC_ExternalTrigConv 触发方式:
/* ADC_ExternalTrigConv 触发方式:
ADC_ExternalTrigConv_T1_CC1 For ADC1 and ADC2
ADC_ExternalTrigConv_T1_CC2 For ADC1 and ADC2
ADC_ExternalTrigConv_T2_CC2 For ADC1 and ADC2
@ -143,7 +143,7 @@ ADC_Stru::ADC_Stru(byte ADC_group)
ADC_ExternalTrigConv_T4_CC4 For ADC1 and ADC2
ADC_ExternalTrigConv_Ext_IT11_TIM8_TRGO For ADC1 and ADC2
ADC_ExternalTrigConv_T1_CC3 For ADC1, ADC2 and ADC3
ADC_ExternalTrigConv_None For ADC1, ADC2 and ADC3
ADC_ExternalTrigConv_None For ADC1, ADC2 and ADC3
ADC_ExternalTrigConv_T3_CC1 For ADC3 only
ADC_ExternalTrigConv_T2_CC3 For ADC3 only
ADC_ExternalTrigConv_T8_CC1 For ADC3 only
@ -151,11 +151,11 @@ ADC_Stru::ADC_Stru(byte ADC_group)
ADC_ExternalTrigConv_T5_CC1 For ADC3 only
ADC_ExternalTrigConv_T5_CC3 For ADC3 only*/
adc_intstr.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
/* ADC_DataAlign 转换结果对齐方式:
/* ADC_DataAlign 转换结果对齐方式:
ADC_DataAlign_Right
ADC_DataAlign_Left */
adc_intstr.ADC_DataAlign = ADC_DataAlign_Right;
/* ADC_NbrOfChannel:
*/
adc_intstr.ADC_NbrOfChannel = 0; // 初始化为零
*/
adc_intstr.ADC_NbrOfChannel = 0; // 初始化为零
}

2
ADC.h
View File

@ -1,4 +1,4 @@
#ifndef __ADC_H__
#ifndef __ADC_H__
#define __ADC_H__
#include "Sys.h"

View File

@ -1,4 +1,4 @@
#ifndef __AT45DB_H__
#ifndef __AT45DB_H__
#define __AT45DB_H__
#include "Sys.h"

View File

@ -1,4 +1,4 @@
#include "Sys.h"
#include "Sys.h"
#include "Port.h"
#include "CAN.h"

2
CAN.h
View File

@ -1,4 +1,4 @@
#ifndef __CAN_H__
#ifndef __CAN_H__
#define __CAN_H__
#include "Sys.h"

View File

@ -1,4 +1,4 @@
#include "DMA.h"
#include "DMA.h"
bool DMA::Start()
{

12
DMA.h
View File

@ -1,4 +1,4 @@
#ifndef __DMA_H__
#ifndef __DMA_H__
#define __DMA_H__
#include "Sys.h"
@ -7,18 +7,18 @@
class DMA
{
private:
byte _index; // 第几个定时器从0开始
byte _index; // 第几个定时器从0开始
bool _started;
public:
DMA(byte index);
~DMA();
int Retry; // 等待重试次数默认200
int Error; // 错误次数
int Retry; // 等待重试次数默认200
int Error; // 错误次数
bool Start(); // 开始
bool WaitForStop(); // 停止
bool Start(); // 开始
bool WaitForStop(); // 停止
//typedef void (*TimerHandler)(Timer* tim, void* param);
//void Register(TimerHandler handler, void* param = NULL);

View File

@ -1,4 +1,4 @@
#ifndef _Delegate_H_
#ifndef _Delegate_H_
#define _Delegate_H_
/*

View File

@ -1,4 +1,4 @@
#include "Enc28j60.h"
#include "Enc28j60.h"
#define ENC_DEBUG 0

View File

@ -1,4 +1,4 @@
#ifndef __Enc28j60_H__
#ifndef __Enc28j60_H__
#define __Enc28j60_H__
#include "Sys.h"

View File

@ -1,4 +1,4 @@
#include "Flash.h"
#include "Flash.h"
#include <stdlib.h>
#define FLASH_DEBUG 1

View File

@ -1,4 +1,4 @@
#ifndef __SPI_H__
#ifndef __SPI_H__
#define __SPI_H__
#include "Sys.h"

View File

@ -1,4 +1,4 @@
#include "I2C_Port.h"
#include "I2C_Port.h"
//static I2C_TypeDef* const g_I2Cs[] = I2CS;
//static const Pin g_I2C_Pins_Map[][2] = I2C_PINS_FULLREMAP;
@ -52,7 +52,7 @@ void I2C_Port::GetPin(Pin* acl , Pin* sda )
void I2C_Port::Open()
{
// gpio 复用开漏输出
// gpio 复用开漏输出
SCL = new AlternatePort(Pins[0], true);
SDA = new AlternatePort(Pins[1], true);
@ -63,7 +63,7 @@ void I2C_Port::Open()
//RCC_APB1PeriphResetCmd(sEE_I2C_CLK, DISABLE);
#if defined(STM32F0)
// SPI都在GPIO_AF_0分组内
// SPI都在GPIO_AF_0分组内
GPIO_PinAFConfig(_GROUP(Pins[0]), _PIN(Pins[0]), GPIO_AF_0);
GPIO_PinAFConfig(_GROUP(Pins[1]), _PIN(Pins[1]), GPIO_AF_0);
#elif defined(STM32F4)
@ -74,7 +74,7 @@ void I2C_Port::Open()
I2C_InitTypeDef i2c;
I2C_StructInit(&i2c);
I2C_DeInit(_IIC); // 复位
I2C_DeInit(_IIC); // 复位
// I2C_Timing
// I2C_AnalogFilter
@ -84,9 +84,9 @@ void I2C_Port::Open()
// I2C_Ack
// I2C_AcknowledgedAddress
/*i2c.I2C_AnalogFilter = I2C_AnalogFilter_Disable; // 关闭滤波器
// i2c.I2C_DigitalFilter // 数字滤波器 不知道怎么设置 跟 cr1 的8-11位有关
i2c.I2C_Mode =I2C_Mode_I2C; // IIC 模式
/*i2c.I2C_AnalogFilter = I2C_AnalogFilter_Disable; // 关闭滤波器
// i2c.I2C_DigitalFilter // 数字滤波器 不知道怎么设置 跟 cr1 的8-11位有关
i2c.I2C_Mode =I2C_Mode_I2C; // IIC 模式
// i2c.I2C_OwnAddress1
i2c.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
if(addressLen == ADDR_LEN_10)
@ -125,27 +125,27 @@ bool I2C_Port::WaitForEvent(uint event)
int retry = Retry;
while(!I2C_CheckEvent(_IIC, event));
{
if(--retry <= 0) return ++Error; // 超时处理
if(--retry <= 0) return ++Error; // 超时处理
}
return retry > 0;
}
bool I2C_Port::SetID(byte id, bool tx)
{
// 产生起始条件
// 产生起始条件
I2C_GenerateSTART(_IIC, ENABLE);
// 等待ACK
// 等待ACK
if(!WaitForEvent(I2C_EVENT_MASTER_MODE_SELECT)) return false;
if(tx)
{
// 向设备发送设备地址
// 向设备发送设备地址
I2C_Send7bitAddress(_IIC, id, I2C_Direction_Transmitter);
// 等待ACK
// 等待ACK
if(!WaitForEvent(I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)) return false;
}
else
{
// 发送读地址
// 发送读地址
I2C_Send7bitAddress(_IIC, id, I2C_Direction_Receiver);
// EV6
if(!WaitForEvent(I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)) return 0;
@ -158,37 +158,37 @@ void I2C_Port::Write(byte id, byte addr, byte dat)
{
if(!SetID(id)) return;
// 寄存器地址
// 寄存器地址
I2C_SendData(_IIC, addr);
// 等待ACK
// 等待ACK
if(!WaitForEvent(I2C_EVENT_MASTER_BYTE_TRANSMITTED)) return;
// 发送数据
// 发送数据
I2C_SendData(_IIC, dat);
// 发送完成
// 发送完成
if(!WaitForEvent(I2C_EVENT_MASTER_BYTE_TRANSMITTED)) return;
// 产生结束信号
// 产生结束信号
I2C_GenerateSTOP(_IIC, ENABLE);
}
byte I2C_Port::Read(byte id, byte addr)
{
// 等待I2C
// 等待I2C
while(I2C_GetFlagStatus(_IIC, I2C_FLAG_BUSY));
if(!SetID(id)) return 0;
// 重新设置可以清楚EV6
// 重新设置可以清楚EV6
I2C_Cmd(_IIC, ENABLE);
// 发送读得地址
// 发送读得地址
I2C_SendData(_IIC, addr);
// EV8
if(!WaitForEvent(I2C_EVENT_MASTER_BYTE_TRANSMITTED)) return 0;
if(!SetID(id, false)) return 0;
// 关闭应答
// 关闭应答
I2C_AcknowledgeConfig(_IIC, DISABLE);
// 停止条件产生
// 停止条件产生
I2C_GenerateSTOP(_IIC, ENABLE);
if(!WaitForEvent(I2C_EVENT_MASTER_BYTE_RECEIVED)) return 0;

View File

@ -1,4 +1,4 @@
#ifndef _I2C_PORT_H_
#ifndef _I2C_PORT_H_
#define _I2C_PORT_H_
#include "Sys.h"

View File

@ -1,4 +1,4 @@
#include "Interrupt.h"
#include "Interrupt.h"
// GD32全系列无法把向量表映射到RAMF103只能映射到Flash别的地方
/*#if defined(GD32)// || defined(STM32F4)

View File

@ -1,4 +1,4 @@
#ifndef __INTERRUPT_H__
#ifndef __INTERRUPT_H__
#define __INTERRUPT_H__
#include "Sys.h"

2
List.h
View File

@ -1,4 +1,4 @@
#ifndef _List_H_
#ifndef _List_H_
#define _List_H_
#include <stddef.h>

View File

@ -1,4 +1,4 @@
#include "Memory.h"
#include "Memory.h"
int __fastcall malloc(int a1)
{

View File

@ -1,4 +1,4 @@
#ifndef __Memory_H__
#ifndef __Memory_H__
#define __Memory_H__
#include "Sys.h"

View File

@ -1,4 +1,4 @@
#include "Port.h"
#include "Port.h"
#if defined(STM32F1) || defined(STM32F4)
static const int PORT_IRQns[] = {

2
Port.h
View File

@ -1,4 +1,4 @@
#ifndef _Port_H_
#ifndef _Port_H_
#define _Port_H_
#include "Sys.h"

View File

@ -1,4 +1,4 @@
#include "RTC.h"
#include "RTC.h"

2
RTC.h
View File

@ -1,4 +1,4 @@
#ifndef __RTC_H__
#ifndef __RTC_H__
#define __RTC_H__
#include "Sys.h"

View File

@ -1,4 +1,4 @@
#include "Sys.h"
#include "Sys.h"
#include <stdio.h>
#include "Port.h"

View File

@ -1,4 +1,4 @@
#ifndef __SerialPort_H__
#ifndef __SerialPort_H__
#define __SerialPort_H__
#include "Sys.h"

View File

@ -1,4 +1,4 @@
#include "Sys.h"
#include "Sys.h"
#include "Port.h"
#include "Spi.h"

2
Sys.h
View File

@ -1,4 +1,4 @@
#ifndef _Sys_H_
#ifndef _Sys_H_
#define _Sys_H_
#include <stdio.h>

2
Task.h
View File

@ -1,4 +1,4 @@
#ifndef __Task_H__
#ifndef __Task_H__
#define __Task_H__
#include "Sys.h"

View File

@ -1,4 +1,4 @@
#include "Time.h"
#include "Time.h"
#define TIME_Completion_IdleValue 0xFFFFFFFFFFFFFFFFull

View File

@ -1,4 +1,4 @@
#include "Timer.h"
#include "Timer.h"
static TIM_TypeDef* const g_Timers[] = TIMS;
Timer** Timer::Timers = NULL;

View File

@ -1,4 +1,4 @@
#ifndef __Timer_H__
#ifndef __Timer_H__
#define __Timer_H__
#include "Sys.h"

View File

@ -1,4 +1,4 @@
#include "WatchDog.h"
#include "WatchDog.h"
/*
IWDGLSI---40KHz 

View File

@ -1,4 +1,4 @@
#ifndef __WatchDog_H__
#ifndef __WatchDog_H__
#define __WatchDog_H__
#include "Sys.h"

View File

@ -1,4 +1,4 @@
#ifndef __NRF24L01_H__
#ifndef __NRF24L01_H__
#define __NRF24L01_H__
#include "Sys.h"