📄 platform.h
字号:
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This software is copyrighted by and is the sole property of
* VIA Networking Technologies, Inc. This software may only be used
* in accordance with the corresponding license agreement. Any unauthorized
* use, duplication, transmission, distribution, or disclosure of this
* software is expressly forbidden.
*
* This software is provided by VIA Networking Technologies, Inc. "as is"
* and any express or implied warranties, including, but not limited to, the
* implied warranties of merchantability and fitness for a particular purpose
* are disclaimed. In no event shall VIA Networking Technologies, Inc.
* be liable for any direct, indirect, incidental, special, exemplary, or
* consequential damages.
*
*
* File: platform.h
*
* Purpose: Functions of platform to support tasks/timers/ISRs
*
* Author: Tevin Chen
*
* Date: Jan 08, 2002
*
*/
#ifndef __PLATFORM_H__
#define __PLATFORM_H__
#include <reg51.h>
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
/*--------------------- Export Definitions ------------------------*/
sbit CPU51_PORT_1_6 = P1^6; // mac reset
sbit CPU51_PORT_1_7 = P1^7; // phy reset
#define TICK_PER_SEC (32)
#define TICK_PER_MIN ((UINT16)(TICK_PER_SEC * 60))
/*--------------------- Export Types ------------------------------*/
typedef void (* PFN_CALLBACK)(void) DIRECT_FUNTYPE_REENT;
/*--------------------- Export Macros -----------------------------*/
// CPU functions
// store CPU interrupt enabling status, then disable it
#define PLATvCpuEnterCritical() do { g_fCpuIntShadow = EA; EA = 0; } while (0)
// restore CPU interrupt status
#define PLATvCpuExitCritical() do { if (g_fCpuIntShadow == 1) EA = 1; } while (0)
#define PLATvCpuIntEnable() EA = 1
#define PLATvCpuIntDisable() EA = 0
#define PLATvCpuIrqMskInit() IE = 0x92 // Enable all CPU intr, enable UART intr, enable timer 0 intr
#define PLATvCpuIrqMskClear() IE = 0
// Timer0 functions
#define PLATvTimer0Init() do { TL0 = 0xB0; TH0 = 0x01; } while (0)
#define PLATvTimer0Start() TR0 = 1
#define PLATvTimer0Stop() TR0 = 0
#define PLATvSetMacResetPin(val) CPU51_PORT_1_6 = (val)
#define PLATvSetPhyResetPin(val) CPU51_PORT_1_7 = (val)
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
extern bit g_fCpuIntShadow;
#ifdef __MODULE_WEB_SMART
extern DIRECT_MEMTYPE_DATA UINT16 g_wWebAutoLogoutTime;
extern DIRECT_MEMTYPE_DATA UINT16 g_wWebAutoLogoutCntr;
#endif
extern DIRECT_MEMTYPE_DATA UINT16 g_wAutoLogoutTime;
extern DIRECT_MEMTYPE_DATA UINT16 g_wAutoLogoutCntr;
extern DIRECT_MEMTYPE_DATA BYTE g_byTimer;
#ifdef __MODULE_WEB_SMART
extern PFN_CALLBACK g_pfnIdleTaskFunc[3];
#else
extern PFN_CALLBACK g_pfnIdleTaskFunc[1];
#endif
/*--------------------- Export Functions --------------------------*/
// UART functions
void PLATvUartInit(void) DIRECT_FUNTYPE_REENT;
BYTE PLATbyUartGetKeyMultiTask(void) DIRECT_FUNTYPE_REENT;
void PLATvDelay(UINT16 wDelay) DIRECT_FUNTYPE_REENT;
void PLATvCpuInit(void) DIRECT_FUNTYPE_REENT;
void PLATvCpuReset(void) DIRECT_FUNTYPE_REENT;
#endif /* __PLATFORM_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -