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