32
©
Copyright 2004 Cirrus Logic, Inc.
DS651UM21
Version 2.1
CobraNet Hardware User’s Manual
HMI Reference Code
8.2
HMI Access Code
/*========================================================================
** hmi.c
** CobraNet Host Management Interface example code
** Simple edition
**------------------------------------------------------------------------
** $Header$
** Copyright (c) 2004, Peak Audio, a division of Cirrus Logic, Inc.
**========================================================================*/
#include "hmi.h"
/* variables model HMI state */
long PeekLimit;
long PeekPointer = -1;
long PokeLimit;
long PokePointer = -1;
/* access host port hardware */
#define HMI_BASE 0
unsigned char ReadRegister(
int hmiregister )
{
return *(unsigned char volatile *const) ( hmire HMI_BASE );
}
void WriteRegister(
int hmiregister,
unsigned char value )
{
*(unsigned char volatile *const) ( hmire HMI_BASE ) = value;
}
void SendMessage(
unsigned char message )
{
int msgack = ReadRegister( MSG_D );
/* issue (last byte of) message */
WriteRegister( MSG_D, message );
/* wait for acceptance of message */
while( !( ( msgack ^ ReadRegister( MSG_D ) ) & ( 1 << MSG_TOGGLE_BO ) ) );
}
void SetAddress(
long address )
{
/* translate address */
WriteRegister( MSG_A, ( address & 0xff0000 ) >> 16 );
WriteRegister( MSG_B, ( address & 0xff00 ) >> 8 );
WriteRegister( MSG_C, address & 0xff );
SendMessage( CVR_TRANSLATE_ADDRESS );
/* wait for completion of translate address */