增加Sys.Inited表示系统是否已经初始化,系统初始化之前不输出printf日志
This commit is contained in:
parent
9f050709d3
commit
20a14b44b7
|
@ -1,4 +1,4 @@
|
|||
#include "Flash.h"
|
||||
#include "Flash.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FLASH_DEBUG 1
|
||||
|
@ -270,6 +270,10 @@ bool Flash::Erase(uint address, uint numBytes)
|
|||
{
|
||||
if(address < StartAddress || address + numBytes > StartAddress + Size) return false;
|
||||
|
||||
#if FLASH_DEBUG
|
||||
printf( "Flash::Erase( 0x%08x, 0x%08x )", address, numBytes );
|
||||
#endif
|
||||
|
||||
if(numBytes == 0) numBytes = StartAddress + Size - address;
|
||||
|
||||
// 该地址所在的块
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "Sys.h"
|
||||
#include "Sys.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Port.h"
|
||||
|
@ -241,6 +241,8 @@ extern "C"
|
|||
/* 重载fputc可以让用户程序使用printf函数 */
|
||||
int fputc(int ch, FILE *f)
|
||||
{
|
||||
if(!Sys.Inited) return ch;
|
||||
|
||||
int _com = Sys.MessagePort;
|
||||
if(_com == COM_NONE) return ch;
|
||||
|
||||
|
|
3
Sys.cpp
3
Sys.cpp
|
@ -222,6 +222,7 @@ TSys::TSys()
|
|||
#else
|
||||
Debug = false;
|
||||
#endif
|
||||
Inited = false;
|
||||
|
||||
Clock = 72000000;
|
||||
CystalClock = 8000000; // 晶振时钟
|
||||
|
@ -281,6 +282,8 @@ void TSys::Init(void)
|
|||
#ifdef STM32F10X
|
||||
NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4); //中断优先级分配方案4 四位都是抢占优先级
|
||||
#endif
|
||||
|
||||
Inited = true;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
|
|
3
Sys.h
3
Sys.h
|
@ -1,4 +1,4 @@
|
|||
#ifndef _Sys_H_
|
||||
#ifndef _Sys_H_
|
||||
#define _Sys_H_
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -44,6 +44,7 @@ class TSys
|
|||
{
|
||||
public:
|
||||
bool Debug; // 是否调试
|
||||
bool Inited; // 是否已完成初始化
|
||||
uint Clock; // 系统时钟
|
||||
uint CystalClock; // 晶振时钟
|
||||
byte MessagePort; // 消息口,默认0表示USART1
|
||||
|
|
Loading…
Reference in New Issue