📄 minimos.h.sav
字号:
/*============================================================================
____________________________________________________________________________
______________________________________________
SSSS M M CCCC Standard Microsystems Corporation
S MM MM SSSS C Austin Design Center
SSS M M M S C 11000 N. Mopac Expressway
S M M SSS C Stonelake Bldg. 6, Suite 500
SSSS M M S CCCC Austin, Texas 78759
SSSS ______________________________________________
____________________________________________________________________________
Copyright(C) 1999, Standard Microsystems Corporation
All Rights Reserved.
This program code listing is proprietary to SMSC and may not be copied,
distributed, or used without a license to do so. Such license may have
Limited or Restricted Rights. Please refer to the license for further
clarification.
____________________________________________________________________________
Notice: The program contained in this listing is a proprietary trade
secret of SMSC, Hauppauge, New York, and is copyrighted
under the United States Copyright Act of 1976 as an unpublished work,
pursuant to Section 104 and Section 408 of Title XVII of the United
States code. Unauthorized copying, adaption, distribution, use, or
display is prohibited by this law.
____________________________________________________________________________
Use, duplication, or disclosure by the Government is subject to
restrictions as set forth in subparagraph(c)(1)(ii) of the Rights
in Technical Data and Computer Software clause at DFARS 52.227-7013.
Contractor/Manufacturer is Standard Microsystems Corporation,
80 Arkay Drive, Hauppauge, New York, 1178-8847.
____________________________________________________________________________
____________________________________________________________________________
minimos.h - minimOS fundamental types
____________________________________________________________________________
naming conventions
entity prefix example
================== ======== ===================
constant k_ k_constant
constant bit mask kbm_ kbm_constant_bitmask
system global g_ g_system_global
module golbal _ _module_global
parameter (none) parameter
local variable (none) local_variable
function (none) function()
macro _ _macro()
structure s_ s_struct
typedef t_ t_type
____________________________________________________________________________
Revision History
Date Who Comment
________ ___ _____________________________________________________________
05/31/00 tbh -initial version
03/08/01 tbh -reorganized for improved modularity
03/15/01 tbh -all regisers are accessed via wrappers, facilitating
relocation to different memory spaces (fpga vs asic, etc),
and for self documenting mnemonics
-register naming convention changed from using a prefix to
indicate the memory space of the register to using a prefix
to indicate the type of register: cpu, mcu, isa
08/29/01 tbh added t_code_fragment
10/01/01 tbh added k_usbreset to the e_result enums
11/29/01 tbh added knlcfg.h
12/14/01 cds added k_success=0 to the enum just to 'enforce' that success
is a zero value. should not affect code that does not depend
on the value, but allows libraries like the smart media interface
library easier to import.
02/21/02 tbh added _stack_dump() and _stack_check() macros, dev attributes.
06/10/02 tbh added t_isr_fragment for high priority threads
09/20/02 tbh deleted 97200, added 97211
09/23/02 ds added 97223
05/13/03 sbs added 97226
06/20/03 ds 226 should not have pwr mgmt enabled. Removed the code that enables it.
07/03/03 ds Added 97243 to the chips. Also added a new compile time option for the kind of cpu used.
============================================================================*/
//------------------------------------------------------------------------------
// constants
//------------------------------------------------------------------------------
// shorthand definitions to identify the specified mcu family
#if defined(k_mcu_97100) || defined(k_mcu_97102) || defined(k_mcu_97FDC)
#define k_10x_family
#endif
#if defined(k_mcu_97201) || defined(k_mcu_97210) || defined(k_mcu_97211) || defined(k_mcu_97242) || defined(k_mcu_97223) ||defined(k_mcu_97226) ||defined(k_mcu_97243)
#define k_20x_family
#endif
#if defined(k_mcu_97210) || defined(k_mcu_97211) || defined(k_mcu_97242) || defined(k_mcu_97223) ||defined(k_mcu_97226) ||defined(k_mcu_97243)
#define k_flash_family
#endif
//Select the appropriate CPU
#ifdef k_mcu_97243
#define k_cpu_flip8051
#else
#define k_cpu_dw8051
#endif
// these constants are properly named according to the conventions...
#define k_true (1==1)
#define k_false (!k_true)
// ...while these (legacy) constants aspire to be integrated into the language
#define t (1==1)
#define f (!t)
// ...and these are just there in case someone likes them
#define k_yes (1==1)
#define k_no (!k_yes)
//------------------------------------------------------------------------------
// macros
//------------------------------------------------------------------------------
// min and max are, oddly enough, not present in the Keil runtime library...
#define _max(a,b) (((a)>(b))?(a):(b))
#define _min(a,b) (((a)<(b))?(a):(b))
// hi byte of word
#define _h(w) ((uint16)(w)>>8)
// lo byte of word
#define _l(w) ((uint16)(w)&0x00FF)
//------------------------------------------------------------------------------
// types
//------------------------------------------------------------------------------
// note that these do not follow the t_typedef naming convention...
// because they aspire to be 'integral types' like 'int' and 'short'...
typedef signed char int8;
typedef unsigned char uint8;
typedef signed short int16;
typedef unsigned short uint16;
typedef signed long int32;
typedef unsigned long uint32;
//------------------------------------------------------------------------------
// a datum is what fits in a register.
// this depends on the widths of the io and memory busses.
// this version assumes that the io bus width equals the memory bus width.
typedef uint8 t_datum;
typedef t_datum* t_datum_ref;
//------------------------------------------------------------------------------
// boolean
typedef uint8 t_bool;
//------------------------------------------------------------------------------
// bit index
#define k_max_bit_ix 7
typedef uint8 t_bit_ix;
//------------------------------------------------------------------------------
// bit mask
typedef uint8 t_bit_mask;
//------------------------------------------------------------------------------
// result codes
typedef uint8 t_result;
typedef enum e_result
{
k_success=0,
k_error,
k_in_progress,
k_finished,
k_ignored,
k_aborted,
k_timeout,
k_usbreset,
k_resume
//k_busy,
//k_ready,
//k_granted,
//k_denied
};
//------------------------------------------------------------------------------
// useful typedef's for endian swapping
typedef union u_uw16
{
uint16 u16;
struct
{
uint8 hi; // msw msb
uint8 lo; // lsw lsb
} u8;
} t_uw16;
typedef union u_udw32
{
uint32 u32;
struct
{
uint8 hi; // msw msb
uint8 lh; // msw lsb
uint8 hl; // lsw msb
uint8 lo; // lsw lsb
} u8;
} t_udw32;
//------------------------------------------------------------------------------
typedef unsigned char const code* t_code_ref;
typedef unsigned char volatile data* t_data_ref;
typedef unsigned char volatile idata* t_idata_ref;
typedef unsigned char volatile xdata* t_xdata_ref;
typedef unsigned char volatile* t_memory_ref;
//------------------------------------------------------------------------------
// a code fragment
typedef void (code *t_code_fragment)(void) reentrant;
//------------------------------------------------------------------------------
// an interrupt handler code fragment
typedef t_result (code *t_isr_fragment)(uint8) reentrant;
//------------------------------------------------------------------------------
// dependencies
//------------------------------------------------------------------------------
// standard c runtime library headers
#include <stdio.h>
#include <stddef.h>
#include <stdarg.h>
#include <intrins.h>
#include <string.h>
#include <setjmp.h>
//------------------------------------------------------------------------------
// compiler specific headers
#ifdef __C51__ // keil
#include <absacc.h>
#else
#define CBYTE ((unsigned char volatile code *) 0)
#define DBYTE ((unsigned char volatile data *) 0)
#define PBYTE ((unsigned char volatile pdata *) 0)
#define XBYTE ((unsigned char volatile xdata *) 0)
#endif
#define IBYTE ((unsigned char volatile idata *) 0)
// for the kernel and the protocol engine
#ifdef __kernel__
#include "trace.h" // trace fifo stuff
#include "cpu.h" // cpu registers
#include "isa.h" // isa bus
#include "mcu.h" // mcu registers
#include "osc.h" // oscillator
#include "sie.h" // serial interface engine
#include "mmu.h" // memory management unit
#include "mmp.h" // memory management policy
#include "gpfifo.h" // general purpose fifo
#include "txfifo.h" // transmit fifo
#include "endpoint.h" // endpoint
#include "hub.h" // usb hub
#include "knlcfg.h" // user/project specific kernel configuration options
#include "kernel.h" // MinimOS kernel configuration
#include "message.h" // MinimOS kernel internal messaging
#include "thread.h" // MinimOS threading model
#include "isr.h" // MinimOS kernel level interrupt service routines
#include "control.h" // MinimOS USB control pipe protocol engine
#include "device.h" // USB Device manager MinimOS client
#include "gpio.h" // general purpose io pins
#include "dmac.h" // dma controller
#ifdef k_mcu_97102
#include "sgdmac.h" // sgdma controller, 102/FDC
#endif
#include "debug.h" // misc debug
#endif
// for the udp interface manager
#ifdef __manager__
#include "..\inc\trace.h"
#include "..\inc\cpu.h"
#include "..\inc\isa.h"
#include "..\inc\mcu.h"
#include "..\inc\osc.h"
#include "..\inc\sie.h"
#include "..\inc\mmu.h"
#include "..\inc\mmp.h"
#include "..\inc\gpfifo.h"
#include "..\inc\txfifo.h"
#include "..\inc\endpoint.h"
#include "..\inc\hub.h"
#include "..\inc\knlcfg.h"
#include "..\inc\kernel.h"
#include "..\inc\message.h"
#include "..\inc\thread.h"
#include "..\inc\isr.h"
#include "..\inc\control.h"
#include "..\inc\device.h"
#include "..\inc\gpio.h"
#include "..\inc\dmac.h"
#ifdef k_mcu_97102
#include "..\inc\sgdmac.h"
#endif
#include "..\inc\debug.h"
#endif
//------------------------------------------------------------------------------
#define c_ibp DBYTE[0x0010]
#define _stack_dump() { TRACE2(4, stk, 0, "--> SP:%02X -- C_IBP:%02X <--", SP, c_ibp); }
#define _stack_check() { if (c_ibp && (SP >= c_ibp)) { _stack_dump(); mcu_halt(); }}
//------------------------------------------------------------------------------
// types
typedef uint16 t_dev_attribute_mask;
// attributes
#define kbm_bus_powered 512
#define kbm_hub_enabled 256
#define kbm_soft_attach_gpio7 128
#define kbm_soft_attach_gpio6 64
#define kbm_soft_attach_gpio5 32
#define kbm_soft_attach_gpio4 16
#define kbm_soft_attach_gpio3 8
#define kbm_soft_attach_gpio2 4
#define kbm_soft_attach_gpio1 2
#define kbm_soft_attach_gpio0 1
#define kbm_none 0
// application should declare this in device.c
extern code t_dev_attribute_mask k_dev_attributes;
//------------------------------------------------------------------------------
// nowhere else really good to put thuse since application doesn't include mcu.h...
#ifndef __kernel__
// application can call these
void mcu_begin_critical_section(void) reentrant;
void mcu_end_critical_section(void) reentrant;
#endif
//---eof------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -