Set_bit( ) function, Syntax, Example – Echelon Neuron C User Manual
Page 153: Set_eeprom_lock( ) function
Neuron C Reference Guide
133
when (timer_expires(three_sec_timer))
{
if (service_pin_state()) {
// Service pin still depressed
// go to unconfigured state
go_unconfigured();
}
}
Note this example is functional, but incomplete: the device would go
unconfigured if the service pin is still being pressed after three seconds, or when
it has been released and, by chance, is pressed again when the three seconds
expire. A more robust device would stop the timer when the service pin is being
released, to facilitate the press-and-hold scheme.
set_bit( )
Function
The set_bit( ) function sets a bit in a bit array pointed to by
array
. Bits are
numbered from left to right in each byte, so that the first bit in the array is the
most significant bit of the first byte in the array. Like all arrays in C, this first
element corresponds to index 0 (
bitnum
0). When managing a number of bits
that are all similar, a bit array can be more code-efficient than a series of
bitfields because the array can be accessed using an array index rather than
separate lines of code for each bitfield. See also clr_bit( ) and tst_bit( ).
Syntax
#include
void set_bit (void *
array
, unsigned
bitnum
);
Example
#include
unsigned short a[4];
void f(void)
{
memset(a, 0, 4);
// Clears all bits at once
set_bit(a, 4); // Sets a[0] to 0x08 (5th bit)
}
set_eeprom_lock( )
Function
The set_eeprom_lock( ) function allows the application to control the state of the
EEPROM lock. This feature is available only for:
• Neuron 3120xx Chips or FT 3120 Smart Transceivers with system
firmware Version 4 or later
• Neuron 3150 Chips and FT 3150 Smart Transceivers with system
firmware Version 6 or later
• Series 5000 chips