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.2 2006/03/09 12:28:37 yasuh-to 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 // macros
20 #ifdef WIN32
21 #define	SWAP16(w)	((((w) >> 8) & 0x00FF) | (((w) << 8) & 0xFF00))
22 #else
23 #define	SWAP16(w)	(w)
24 #endif
25 
26 // data transfer packet
27 typedef struct
28 {
29 	u8	mon;		// month since January [0, 11]
30 	u8	mday;		// day of the month [1, 31]
31 	u8	hour;		// hours since midnight [0, 23]
32 	u8	min;		// minutes after the hour [0, 59]
33 	u8	sec;		// seconds after the minute [0, 61]
34 	u8	align;
35 	u16	msec;		// milliseconds after the second [0,999]
36 	char	string[24];	// message
37 } MULTI_PACKET;
38 
39 // EXI-USB memory mapping
40 #define MULTI_BUFFER_SIZE	sizeof(MULTI_PACKET)
41 #define MULTI_PC2NNGC_ADDR	0x1000
42 #define	MULTI_NNGC2PC_ADDR	(MULTI_PC2NNGC_ADDR + MULTI_BUFFER_SIZE)
43 
44 // inline function - MULTI_PACKET to string
45 static inline
MultiPacketToString(char * string,MULTI_PACKET * packet)46 void	MultiPacketToString(char *string, MULTI_PACKET* packet)
47 {
48 	(void)sprintf(string,"%02d/%02d %02d:%02d:%02d %03d, %s",
49 				  packet->mon, packet->mday,
50 				  packet->hour, packet->min, packet->sec, SWAP16(packet->msec),
51 				  packet->string);
52 }
53 
54 #ifdef __cplusplus
55 }
56 #endif
57 #endif	// __MULTI_H__
58