Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to design and implement simple interface ?

Status
Not open for further replies.

jani12

Member level 4
Joined
Oct 30, 2014
Messages
78
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
913
// Some_Filename.c - This file already exists
/* This function fetches two bytes from Non-Volatile Memory(NVM) and returns to the calling library.
signed short GetDeltaMin ( void ) */
{
signed short param;
NVM_Read ( ( unsigned char * ) &param );
return (signed short) param;
}

// New File - Activate_Deactive_I.c

void Enable_Disable ( Boolean State)
{
/* user will pass 1 or 0 to this function. */
/* If State =1, there is no change to GetDeltaMin ( ). It'll still pass two byte value from NVRAM to calling library. */
/* If State = 0, GetDeltaMin ( ) needs to pass 0 to calling library instead of two byte value from
from NVRAM. */
/* Please write this function and modify GetDeltaMin ( ). */
}

// New File - Activate_Deactivate.h

extern void Enable_Disable ( Boolean State); /* This header file must be included in file from where Enable_Disable ( ) will be called. */
/* I don't think Activate_Deactive_I.c needs to include this header file ? */
 

jani12

Member level 4
Joined
Oct 30, 2014
Messages
78
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
913
// Some_Filename.c - This file already exists
/* This function fetches two bytes from Non-Volatile Memory(NVM) and returns to the calling library.
signed short GetDeltaMin ( void ) */
{
signed short param;
NVM_Read ( ( unsigned char * ) &param );
return (signed short) param;
}

// New File - Activate_Deactive_I.c

void Enable_Disable ( Boolean State)
{
/* user will pass 1 or 0 to this function. */
/* If State =1, there is no change to GetDeltaMin ( ). It'll still pass two byte value from NVRAM to calling library. */
/* If State = 0, GetDeltaMin ( ) needs to pass 0 to calling library instead of two byte value from
from NVRAM. */
/* Please write this function and modify GetDeltaMin ( ). */
}

// New File - Activate_Deactivate.h

extern void Enable_Disable ( Boolean State); /* This header file must be included in file from where Enable_Disable ( ) will be called. */
/* I don't think Activate_Deactive_I.c needs to include this header file ? */





When Enable_Disable( ) is called, I can assign value of state to a global variable. Then, in GetDeltaMin( ), I can use the value of global variable to decide whether to return value from NVM or 0 to the calling library.

I'm asking for a better solution than a global variable.

- - - Updated - - -

When Enable_Disable( ) is called, I can assign value of state to a global variable. Then, in GetDeltaMin( ), I can use the value of global variable to decide whether to return value from NVM or 0 to the calling library.

I'm asking for a better solution than a global variable.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top