JD2022-TU1/main/extern/rfphio/rfphio_lib/include/multi.h

57 lines
1.4 KiB
C

/*---------------------------------------------------------------------------*
Project: HIO2 demos - multi
File: multi.h
(C)2005 HUDSON SOFT
$Header: /home/cvsroot/SDK/build/demos/hio2demo/include/multi.h,v 1.2 2006/03/09 12:28:37 yasuh-to Exp $
$NoKeywords: $
*---------------------------------------------------------------------------*/
#ifndef __MULTI_H__
#define __MULTI_H__
#ifdef __cplusplus
extern "C" {
#endif
// マクロ
#ifdef WIN32
#define SWAP16(w) ((((w) >> 8) & 0x00FF) | (((w) << 8) & 0xFF00))
#else
#define SWAP16(w) (w)
#endif
// データ転送パケット
typedef struct
{
u8 mon; // month since January [0, 11]
u8 mday; // day of the month [1, 31]
u8 hour; // hours since midnight [0, 23]
u8 min; // minutes after the hour [0, 59]
u8 sec; // seconds after the minute [0, 61]
u8 align;
u16 msec; // milliseconds after the second [0,999]
char string[24]; // mesage
} MULTI_PACKET;
// EXI-USBメモリマッピング
#define MULTI_BUFFER_SIZE sizeof(MULTI_PACKET)
#define MULTI_PC2NNGC_ADDR 0x1000
#define MULTI_NNGC2PC_ADDR (MULTI_PC2NNGC_ADDR + MULTI_BUFFER_SIZE)
// inline function - MULTI_PACKET to string
static inline
void MultiPacketToString(char *string, MULTI_PACKET* packet)
{
(void)sprintf(string,"%02d/%02d %02d:%02d:%02d %03d, %s",
packet->mon, packet->mday,
packet->hour, packet->min, packet->sec, SWAP16(packet->msec),
packet->string);
}
#ifdef __cplusplus
}
#endif
#endif // __MULTI_H__