1 mapi_getsetregister(), Library inputs and outputs, Mapi_getsetregister() – Maxim Integrated 78M6612 M-API Library User Manual
Page 18

78M6612 M-API Library User Guide
UG_6612_036
18
Rev. 1.00
4.2 Library Inputs and Outputs
4.2.1 MAPI_GetSetRegister()
Purpose
Get or Set the value of a specific register location. An error will be returned if the
address is out of range or within the restricted location. Care must be taken when
calling this API to Set the value into a register. There are three types of registers:
MPU, CE and I/O Hardware Control. The range of address indicates the type of
registers as follows:
0x0000 – 0x03FF: MPU Address
0x0400 – 0x07FF: CE Address
0x2001 – 0x2001: Hardware I/O Control registers. Only address 2001 is accessible.
When calling this function, make sure the Reg.Address is OR’ed with the specific
type of register (CE or MPU or I/O RAM) defined such as:
enum REG_TYPE {
MPU_ADDRESS = 0x0000,
CE_ADDRESS = 0x1000,
RI_ADDRESS = 0x2000};
For example:
{ //example code to get different types of registers
Struct Reg_t xdata Regt;
//CE Address
//shift 2 to accommodate 4-byte increment. Get CE add 100E
Regt.Address = (unsigned long) (CE_ADDRESS | ( 0x01 << 2));
MAPI_GetSetRegister (READ, &Regt);
//Change CE contents at address 0x100E
Regt.Value = 0x6050; //Change SAG counts
MAPI_GetSetRegister (WRITE, &Regt);
//MPU Address
//Get MPU address 0x07 – Read-only
Regt.Address = (unsigned long) (MPU_ADDRESS | (0x07));
MAPI_GetSetRegister (READ, &Regt);
//RI address
Regt_Address = (unsigned long) ((RI_ADDRESS) | (0x01));
MAPI_GetSetRegisters (READ, &Regt);
....
}
Synopsis
enum MAPI_RC MAPI_GetSetRegister( bool Operation,
struct Reg_t *Reg)
Where Reg_t is defined as:
Struct Reg_t
{
Unsigned Integer
Address;
Unsigned Long
Value;
Unsigned Char
TypeSize;
Unsigned Integer
ScaleFactor;
};