Line 10... |
Line 10... |
* Plasma Real Time Operating System
|
* Plasma Real Time Operating System
|
*--------------------------------------------------------------------*/
|
*--------------------------------------------------------------------*/
|
#ifndef __RTOS_H__
|
#ifndef __RTOS_H__
|
#define __RTOS_H__
|
#define __RTOS_H__
|
|
|
//#define printf UartPrintf
|
#define printf UartPrintf
|
#define printf UartPrintfPoll
|
//#define printf UartPrintfPoll
|
#define scanf UartScanf
|
#define scanf UartScanf
|
|
#ifndef WIN32
|
|
#define malloc(S) OS_HeapMalloc(NULL, S)
|
|
#define free(S) OS_HeapFree(S)
|
|
#endif
|
|
|
// Typedefs
|
// Typedefs
|
typedef unsigned int uint32;
|
typedef unsigned int uint32;
|
typedef unsigned short uint16;
|
typedef unsigned short uint16;
|
typedef unsigned char uint8;
|
typedef unsigned char uint8;
|
|
|
// Memory Access
|
// Memory Access
|
#ifdef WIN32
|
#ifdef WIN32
|
uint32 MemoryRead(uint32 Address);
|
uint32 MemoryRead(uint32 Address);
|
void MemoryWrite(uint32 Address, uint32 Value);
|
void MemoryWrite(uint32 Address, uint32 Value);
|
|
#define atoi atoi2
|
#else
|
#else
|
#define MemoryRead(A) (*(volatile uint32*)(A))
|
#define MemoryRead(A) (*(volatile uint32*)(A))
|
#define MemoryWrite(A,V) *(volatile uint32*)(A)=(V)
|
#define MemoryWrite(A,V) *(volatile uint32*)(A)=(V)
|
#endif
|
#endif
|
|
|
/***************** LibC ******************/
|
/***************** LibC ******************/
|
|
#ifndef _LIBC
|
#ifndef NULL
|
#ifndef NULL
|
#define NULL (void*)0
|
#define NULL (void*)0
|
#endif
|
#endif
|
|
|
#define assert(A) if((A)==0){OS_Assert();UartPrintfCritical("\r\nAssert %s:%d\r\n", __FILE__, __LINE__);}
|
#define assert(A) if((A)==0){OS_Assert();UartPrintfCritical("\r\nAssert %s:%d\r\n", __FILE__, __LINE__);}
|
Line 43... |
Line 49... |
#define islower(c) ('a'<=(c)&&(c)<='z')
|
#define islower(c) ('a'<=(c)&&(c)<='z')
|
#define isupper(c) ('A'<=(c)&&(c)<='Z')
|
#define isupper(c) ('A'<=(c)&&(c)<='Z')
|
#define isalpha(c) (islower(c)||isupper(c))
|
#define isalpha(c) (islower(c)||isupper(c))
|
#define isalnum(c) (isalpha(c)||isdigit(c))
|
#define isalnum(c) (isalpha(c)||isdigit(c))
|
#define min(a,b) ((a)<(b)?(a):(b))
|
#define min(a,b) ((a)<(b)?(a):(b))
|
|
#define memcpy memcpy2 //don't use built in version
|
|
|
char *strcpy(char *dst, const char *src);
|
char *strcpy(char *dst, const char *src);
|
char *strncpy(char *dst, const char *src, int count);
|
char *strncpy(char *dst, const char *src, int count);
|
char *strcat(char *dst, const char *src);
|
char *strcat(char *dst, const char *src);
|
char *strncat(char *dst, const char *src, int count);
|
char *strncat(char *dst, const char *src, int count);
|
int strcmp(const char *string1, const char *string2);
|
int strcmp(const char *string1, const char *string2);
|
int strncmp(const char *string1, const char *string2, int count);
|
int strncmp(const char *string1, const char *string2, int count);
|
char *strstr(char *string, char *find);
|
char *strstr(const char *string, const char *find);
|
int strlen(const char *string);
|
int strlen(const char *string);
|
void *memcpy(void *dst, const void *src, unsigned long bytes);
|
void *memcpy(void *dst, const void *src, unsigned long bytes);
|
void *memmove(void *dst, const void *src, unsigned long bytes);
|
void *memmove(void *dst, const void *src, unsigned long bytes);
|
int memcmp(const void *cs, const void *ct, unsigned long bytes);
|
int memcmp(const void *cs, const void *ct, unsigned long bytes);
|
void *memset(void *dst, int c, unsigned long bytes);
|
void *memset(void *dst, int c, unsigned long bytes);
|
int abs(int n);
|
int abs(int n);
|
unsigned int rand(void);
|
int rand(void);
|
void srand(unsigned int seed);
|
void srand(unsigned int seed);
|
long strtol(const char *s, const char **end, int base);
|
long strtol(const char *s, const char **end, int base);
|
int atoi(const char *s);
|
int atoi(const char *s);
|
void itoa(char *dst, int num, int base, int width);
|
char *itoa(int num, char *dst, int base);
|
|
void dump(const unsigned char *data, int length);
|
#ifndef NO_ELLIPSIS
|
#ifndef NO_ELLIPSIS
|
int sprintf(char *s, const char *format, ...);
|
int sprintf(char *s, const char *format, ...);
|
int sscanf(char *s, const char *format, ...);
|
int sscanf(char *s, const char *format, ...);
|
#endif
|
#endif
|
|
#define _LIBC
|
|
#endif
|
|
|
|
|
/***************** Assembly **************/
|
/***************** Assembly **************/
|
#define OS_CriticalBegin() OS_AsmInterruptEnable(0)
|
#define OS_CriticalBegin() OS_AsmInterruptEnable(0)
|
#define OS_CriticalEnd(S) OS_AsmInterruptEnable(S)
|
#define OS_CriticalEnd(S) OS_AsmInterruptEnable(S)
|
typedef uint32 jmp_buf[20];
|
typedef uint32 jmp_buf[20];
|
Line 168... |
Line 179... |
void OS_Start(void);
|
void OS_Start(void);
|
void OS_Assert(void);
|
void OS_Assert(void);
|
void MainThread(void *Arg);
|
void MainThread(void *Arg);
|
|
|
/***************** UART ******************/
|
/***************** UART ******************/
|
|
typedef uint8* (*PacketGetFunc_t)(void);
|
void UartInit(void);
|
void UartInit(void);
|
void UartWrite(int C);
|
void UartWrite(int C);
|
uint8 UartRead(void);
|
uint8 UartRead(void);
|
void UartWriteData(uint8 *Data, int Length);
|
void UartWriteData(uint8 *Data, int Length);
|
void UartReadData(uint8 *Data, int Length);
|
void UartReadData(uint8 *Data, int Length);
|
Line 179... |
Line 191... |
void UartPrintf(const char *format, ...);
|
void UartPrintf(const char *format, ...);
|
void UartPrintfPoll(const char *format, ...);
|
void UartPrintfPoll(const char *format, ...);
|
void UartPrintfCritical(const char *format, ...);
|
void UartPrintfCritical(const char *format, ...);
|
void UartScanf(const char *format, ...);
|
void UartScanf(const char *format, ...);
|
#endif
|
#endif
|
|
void UartPacketConfig(PacketGetFunc_t PacketGetFunc,
|
|
int PacketSize,
|
|
OS_MQueue_t *mQueue);
|
|
void UartPacketSend(uint8 *Data, int Bytes);
|
int puts(const char *string);
|
int puts(const char *string);
|
int getch(void);
|
int getch(void);
|
int kbhit(void);
|
int kbhit(void);
|
void LogWrite(int a);
|
void LogWrite(int a);
|
void LogDump(void);
|
void LogDump(void);
|
|
void Led(int value);
|
|
|
|
|
/***************** Math ******************/
|
/***************** Math ******************/
|
//IEEE single precision floating point math
|
//IEEE single precision floating point math
|
#ifndef WIN32
|
#ifndef WIN32
|
#define FP_Neg __negsf2
|
#define FP_Neg __negsf2
|