1 /*---------------------------------------------------------------------------*
2   Project:  HIO2 demos - multi
3   File:     multi.h
4 
5   (C)2005 HUDSON SOFT
6 
7   $Header: /home/cvsroot/SDK/build/demos/hio2demo/include/multi.h,v 1.4 2007/11/26 13:54:06 iwai_yuma Exp $
8 
9   $NoKeywords: $
10  *---------------------------------------------------------------------------*/
11 
12 #ifndef __MULTI_H__
13 #define	__MULTI_H__
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 #pragma warning(disable: 4996)
20 
21 // Macros
22 #ifdef WIN32
23 #define	SWAP16(w)	((((w) >> 8) & 0x00FF) | (((w) << 8) & 0xFF00))
24 #else
25 #define	SWAP16(w)	(w)
26 #endif
27 
28 // Data transfer packet
29 typedef struct
30 {
31 	u8	mon;		// Months since January [0, 11]
32 	u8	mday;		// Day of the month [1, 31]
33 	u8	hour;		// Hours since midnight [0, 23]
34 	u8	min;		// Minutes after the hour [0, 59]
35 	u8	sec;		// Seconds after the minute [0, 61]
36 	u8	align;
37 	u16	msec;		// Milliseconds after the second [0,999]
38 	char	string[24];	// Message
39 } MULTI_PACKET;
40 
41 // EXI-USB memory mapping
42 #define MULTI_BUFFER_SIZE	sizeof(MULTI_PACKET)
43 #define MULTI_PC2NNGC_ADDR	0x1000
44 #define	MULTI_NNGC2PC_ADDR	(MULTI_PC2NNGC_ADDR + MULTI_BUFFER_SIZE)
45 
46 // Inline function - MULTI_PACKET to string
47 static inline
48 //void	MultiPacketToString( char *string, u32 bufSize, MULTI_PACKET* packet )
MultiPacketToString(char * string,MULTI_PACKET * packet)49 void	MultiPacketToString( char *string, MULTI_PACKET* packet )
50 {
51 //	(void)sprintf_s( string, bufSize, "%s, %02d/%02d %02d:%02d:%02d %03d",
52 //				    packet->string,
53 //				    packet->mon, packet->mday,
54 //				    packet->hour, packet->min, packet->sec, SWAP16(packet->msec)
55 //				    );
56 	(void)sprintf( string, "%s, %02d/%02d %02d:%02d:%02d %03d",
57 		           packet->string,
58 			       packet->mon, packet->mday,
59 			       packet->hour, packet->min, packet->sec, SWAP16(packet->msec)
60 			     );
61 }
62 
63 #ifdef __cplusplus
64 }
65 #endif
66 #endif	// __MULTI_H__
67