增加调试日志。

调试发现,IR的Lamda可能有问题
This commit is contained in:
nnhy 2015-11-26 17:02:15 +00:00
parent 8f31d7f80d
commit 34522fe95d
3 changed files with 34 additions and 1 deletions

View File

@ -19,10 +19,13 @@ bool IR::Open()
{
if(Opened) return true;
TS("IR::Open");
// 申请一个定时器
if(_Tim == NULL) _Tim = Timer::Create();
// 配置定时器的参数
if(_Tim == NULL) return false;
//if(_Tim == NULL) return false;
assert_param2(_Tim, "无法申请得到定时器");
Tx = true;
@ -46,6 +49,8 @@ bool IR::Close()
{
if(!Opened) return true;
TS("IR::Close");
if(_Tim != NULL) _Tim->Close();
Opened = false;
@ -58,6 +63,8 @@ bool IR::Send(const Array& bs)
if(bs.Length() < 2) return false;
if(!Open()) return false;
TS("IR::Send");
_Arr = (Array*)&bs;
_Index = 0;
_Ticks = bs[0];
@ -101,6 +108,8 @@ int IR::Receive(Array& bs)
{
if(!Open()) return false;
TS("IR::Receive");
bs.SetLength(0);
_Arr = &bs;
_Index = -1;

View File

@ -53,6 +53,8 @@ bool ConfigBlock::Init(const char* name, const Array& bs)
{
assert_param2(name, "配置块名称不能为空");
TS("ConfigBlock::Init");
uint slen = strlen(name);
if(slen > sizeof(Name)) return false;
@ -78,6 +80,8 @@ bool ConfigBlock::Write(Storage* storage, uint addr, const Array& bs)
{
assert_ptr(storage);
TS("ConfigBlock::Write");
// 如果大小超标,并且下一块有效,那么这是非法操作
if(bs.Length() > Size && Next()->Valid())
{
@ -111,6 +115,8 @@ Config::Config(Storage* st, uint addr)
// 循环查找配置块
const void* Config::Find(const char* name, int size)
{
TS("Config::Find");
const uint c_Version = 0x534F5453; // STOS
assert_param2(name, "配置段名称不能为空");
@ -162,6 +168,8 @@ bool Config::Invalid(const char* name)
// 根据名称更新块
const void* Config::Set(const char* name, const Array& bs)
{
TS("Config::Set");
//if(name == NULL) return NULL;
assert_param2(name, "配置块名称不能为空");
assert_param2(Device, "未指定配置段的存储设备");
@ -183,6 +191,8 @@ const void* Config::Set(const char* name, const Array& bs)
// 获取配置数据
bool Config::Get(const char* name, Array& bs)
{
TS("Config::Get");
//if(name == NULL) return false;
assert_param2(name, "配置块名称不能为空");
@ -201,6 +211,8 @@ bool Config::Get(const char* name, Array& bs)
// 获取配置数据,如果不存在则覆盖
bool Config::GetOrSet(const char* name, Array& bs)
{
TS("Config::GetOrSet");
//if(name == NULL) return false;
assert_param2(name, "配置块名称不能为空");
@ -215,6 +227,8 @@ bool Config::GetOrSet(const char* name, Array& bs)
const void* Config::Get(const char* name)
{
TS("Config::GetByName");
//if(name == NULL) return NULL;
assert_param2(name, "配置块名称不能为空");

View File

@ -55,6 +55,8 @@ Timer::~Timer()
// 创建指定索引的定时器如果已有则直接返回默认0xFF表示随机分配
Timer* Timer::Create(byte index)
{
TS("Timer::Create");
byte tcount = ArrayLength(g_Timers);
// 特殊处理随机分配
if(index == 0xFF)
@ -82,6 +84,8 @@ Timer* Timer::Create(byte index)
void Timer::Config()
{
TS("Timer::Config");
// 配置时钟
TIM_TimeBaseInitTypeDef tr;
TIM_TimeBaseStructInit(&tr);
@ -105,6 +109,8 @@ void Timer::Open()
{
if(Opened) return;
TS("Timer::Open");
#if DEBUG
// 获取当前频率
uint clk = RCC_GetPCLK();
@ -137,6 +143,8 @@ void Timer::Close()
{
if(!Opened) return;
TS("Timer::Close");
debug_printf("Timer%d::Close\r\n", _index + 1);
// 关闭计数器时钟
@ -318,6 +326,8 @@ PWM::PWM(byte index) : Timer(g_Timers[index])
void PWM::Config()
{
TS("PWM::Config");
// const Pin _Pin[]=TIM_PINS;
Timer::Config(); // 主要是配置时钟基础部分 TIM_TimeBaseInit