SmartOS/Sys.h

76 lines
1.7 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef _Sys_H_
#define _Sys_H_
#include <stdio.h>
#include <string.h>
#include "stm32.h"
/* 类型定义 */
typedef char sbyte;
typedef unsigned char byte;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long long ulong;
typedef char* string;
//typedef unsigned char bool;
#define true 1
#define false 0
/*
// 尚未决定是否采用下面这种类型
typedef char SByte;
typedef unsigned char Byte;
typedef short Int16;
typedef unsigned short UInt16;
typedef int Int32;
typedef unsigned int UInt32;
typedef long long Int64;
typedef unsigned long long UInt64;
typedef char* String;
*/
/* 引脚定义 */
typedef ushort Pin;
#include "Pin.h"
// 委托
typedef void (*Func)(void);
// 列表模版
#include "List.h"
// 系统类
class TSys
{
public:
bool Debug; // 是否调试
uint Clock; // 系统时钟
uint CystalClock; // 晶振时钟
byte MessagePort; // 消息口默认0表示USART1
uint ID[3]; // 芯片ID
uint FlashSize; // 芯片Flash容量
uint MCUID; // MCU编码。低字设备版本高字子版本
bool IsGD; // 是否GD芯片
TSys();
virtual ~TSys();
void Init(); // 初始化系统
void Sleep(uint ms); // 毫秒级延迟
void Delay(uint us); // 微秒级延迟
bool DisableInterrupts(); // 关闭中断
bool EnableInterrupts(); // 打开中断
void Reset(); // 重启系统
void (*OnError)(int code); // 系统出错时引发
Func OnStop;
};
extern TSys Sys;
#include "Time.h"
#include "Interrupt.h"
#endif //_Sys_H_