📄 general_definitions.h
字号:
/*
** Copyright (C) 2006 Tamir Michael
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _GENERAL_DEFINITIONS
#define _GENERAL_DEFINITIONS
// basic data types
typedef unsigned char int8u ;
typedef char int8s ;
typedef unsigned int int16u ;
typedef int int16s ;
typedef unsigned long int32u ;
typedef long int32s ;
typedef float float32 ;
typedef double float64 ;
// definitions for interrupt priority
#define IC_IE(x) (((x) == 0) ? 0x0000 : 0x0040)
#define IC_ILVL(x) (((x) << 2) & 0x003C)
#define IC_GLVL(x) ((x) & 0x0003)
// WAR STORY
// the size of the trace buffer - very powerful feature for embedded debugging
// the user posts action codes into the buffer, where they stored along with the lower two bytes of the
// tick count, allowing after-crash analysis/problem analysis at run time.
#define TRACE_BUFFER_SIZE 128
#define TRACE_BUFFER_END_MARKER 127 // this marker is needed in order to be able to observe where the trace buffer ends (the trace buffer is circular)
// handy for debugging
#define FLIP_PORT_BIT(x,b) P##x = ( ((P##x & 1<<b) == 1<<b ) ? (P##x & 0xFF^(1<<b)) : (P##x | 1<<b) ) ; // port x.b is used to indicate an administration switch. handy for debugging purposes.
// data structures
#define MAX_QUEUE_ELEMENTS 20 // must be >= MAX_TASKS, otherwise software errors can be expected due to queues that contain task ids over-following
// WAR STORY (was not implemented because it adds one instruction to the wraparound check in queue.c,
// but it is handy anyway)
// this canstant is a power of 2 so that checking the top index can be done within 1 instruction:
// if the queue contains 32 items, indices 0..31 shall be used. in order to put the tail pointer of the queue at the
// first index is it goes beyond the last element (when the circular queue is not full), instead of doing a
// comparision every operation to check the index location, is it faster to 'AND' the index
// with the mask 0x1F - this will have no effect on indices <=31, but once the index >31, (31=0x1F=11111b ----(+1)----> 32=0x20=100000b)
// the "1" bit will be set to 0, so that the index returns to 0. this can only be done with array sizes that are a
// power of 2 (because the mask that is used must be all '1's - a buffer size of 256 needs the mask 0x0FF, 0x1FF for
// 512 bytes etc.
// generate a random number
int32s g_generate_random_id() ;
// module interface starts here
// failure routines
void software_error(const char*, ...) ;
void software_warning(const char *, ...) ;
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -