Пример #1
0
int ProcessingRestrictions::checkTransaction (byte termCap,
        byte transType,
        byte dom_trans,
        byte inter_truns,
        byte auc,
        bool IsCountryCodeMatch)
{
    if (check_bit(termCap, transType))
    {
        if (IsCountryCodeMatch)
        {
            // Issuer Country Code == Term Country Code
            if (!check_bit(auc, dom_trans)) // Is Not Vaild for Domestic Transactions
            {
                // Condition is not satisfied
                return EMV_CONDITIONS_NOT_SATISFIED;
            }
        }
        else
        {
            // Issuer Country Code != Term Country Code
            if (!check_bit(auc, inter_truns)) // Is Not Vaild for International Transactions
            {
                // Condition is not satisfied
                return EMV_CONDITIONS_NOT_SATISFIED;
            }
        }
    }
    return SUCCESS;
}
Пример #2
0
int main(){

    uint8_t rd_buf[1];

    char str[6];

    // Initialize UART
    UART_Init(MY_UBRR);

    init_twi();	

    sei();
        
    init_LSM6DS3();
    
    rd_buf[0] = check_bit(CTRL9_XL,SOFT_EN);
    sprintf(str,"%02X\r\n",rd_buf[0]);
    UART_Transmit_String(str);

    set_bits(CTRL9_XL, SOFT_EN);
    rd_buf[0] = check_bit(CTRL9_XL,SOFT_EN);
    sprintf(str,"%02X\r\n",rd_buf[0]);
    UART_Transmit_String(str);

    clear_bits(CTRL9_XL, SOFT_EN);
    rd_buf[0] = check_bit(CTRL9_XL,SOFT_EN);
    sprintf(str,"%02X\r\n",rd_buf[0]);
    UART_Transmit_String(str);
    
    return 0;
}
Пример #3
0
int main(void)
{
	int timer = 0;
	int x;
	int y;

	char str1[16];
	char str2[16];
	
	clear_bit(DDRD,5);
	clear_bit(DDRD,4);
	
	set_bit(DDRB,7);
	
	set_bit(PORTD,5);
	set_bit(PORTD,4);
	set_bit(PORTB,7);

	LCDInit();
	ADCInit();

	sei();

	LCDClear();

    while(1)
    {

		timer ++;

		if (timer >= 1000) {

			timer = 0;

			if(!check_bit(PIND,5))
			{

			}

			if(!check_bit(PIND,4))
			{

			}			

		}

	}

}
Пример #4
0
int main(void)
{
    // The following line sets bit 5 HIGH in register DDRD
    set_bit(DDRD,5); // Pin PD5 is now configured as an OUTPUT
    set_bit(DDRD,6); // Pin PD6 is now configured as an OUTPUT

    // The following line sets bit 0 LOW in register DDRF
    clear_bit(DDRF,0); // Pin PF0 is now configured as an INPUT
    set_bit(PORTF,0); // Turn on internal pullups for PF0

    while(1)
    {
        // PINF is the register you have to read to check if a particular
        // pin on port F (PFx) is HIGH or LOW
        if(check_bit(PINF,0))
        {
            // If PF0 is HIGH, toggle pin PD5's output status
            toggle_bit(PORTD,5);
        }
        else
        {
            // If PF0 is LOW, toggle pin PD6's output status
            toggle_bit(PORTD,6);
        }

        _delay_ms(1000); // Delay 1 second before checking PF0 again

    }

    return 0;
}
Пример #5
0
inline Value SimpleBitVector::inline_aset(INDEX i, Value new_value)
{
    if (i >= _capacity)
        return bad_index(i);
    inline_setbit(i, check_bit(new_value));
    return new_value;
}
static
void
release_mutex_no(unsigned no)
{
  Guard g(&g_mutex_no_mutex);
  assert(check_bit(&g_mutex_no_mask, no));
  clear_bit(&g_mutex_no_mask, no);
}
Пример #7
0
// Reverse and flip the bits from i = 0 to i = end
void reverse_and_flip_bits(int A[], int end) {
    for (int i = 0; i < (end / 2); i++) {
        int temp = check_bit(A, i);
        if (check_bit(A, end - i - 1)) {
            set_bit(A, i);
        } else {
            clear_bit(A, i);
        }
        if (temp) {
            set_bit(A, end - i - 1);
        } else {
            clear_bit(A, end - i - 1);
        }
    }
    for (int i = 0; i < end; i++) {
        flip_bit(A, i);
    }
}
void
ndb_mutex_destoyed(NdbMutex* p)
{
  unsigned no = p->m_mutex_state->m_no;

  /**
   * In order to be able to reuse mutex_no,
   *   we need to clear this no from all mutexes that has it in before map...
   *   this is all mutexes in after map
   */
  for (unsigned i = 0; i<p->m_mutex_state->m_locked_after_list.m_used; i++)
  {
    NdbMutex * m = get_element(&p->m_mutex_state->m_locked_after_list, i);
    assert(check_bit(&p->m_mutex_state->m_locked_after_mask, m->m_mutex_state->m_no));

    /**
     * And we need to lock it while doing this
     */
    NdbMutex_Lock(m);
    assert(check_bit(&m->m_mutex_state->m_locked_before_mask, no));
    clear_bit(&m->m_mutex_state->m_locked_before_mask, no);
    remove_mutex_from_array(&m->m_mutex_state->m_locked_before_list, p);
    NdbMutex_Unlock(m);
  }

  /**
   * And we need to remove ourselfs from after list of mutexes in out before list
   */
  for (unsigned i = 0; i<p->m_mutex_state->m_locked_before_list.m_used; i++)
  {
    NdbMutex * m = get_element(&p->m_mutex_state->m_locked_before_list, i);
    NdbMutex_Lock(m);
    assert(check_bit(&m->m_mutex_state->m_locked_after_mask, no));
    clear_bit(&m->m_mutex_state->m_locked_after_mask, no);
    remove_mutex_from_array(&m->m_mutex_state->m_locked_after_list, p);
    NdbMutex_Unlock(m);
  }

  release(&p->m_mutex_state->m_locked_before_mask);
  release(&p->m_mutex_state->m_locked_before_list);
  release(&p->m_mutex_state->m_locked_after_mask);
  release(&p->m_mutex_state->m_locked_after_list);
  release_mutex_no(no);
}
Пример #9
0
AbstractVector * SimpleBitVector::adjust_vector(INDEX new_capacity,
        Value initial_element,
        Value initial_contents)
{
    if (initial_contents != NIL)
    {
        SimpleBitVector * bv = new_simple_bit_vector(new_capacity);
        if (listp(initial_contents))
        {
            Value list = initial_contents;
            for (INDEX i = 0; i < new_capacity; i++)
            {
                bv->inline_setbit(i, check_bit(car(list)));
                list = xcdr(list);
            }
        }
        else if (vectorp(initial_contents))
        {
            AbstractVector * v = the_vector(initial_contents);
            for (INDEX i = 0; i < new_capacity; i++)
                bv->inline_setbit(i, check_bit(v->aref(i)));
        }
        else
            signal_type_error(initial_contents, S_sequence);
        return bv;
    }
    if (_capacity != new_capacity)
    {
        SimpleBitVector * bv = new_simple_bit_vector(new_capacity);
        INDEX limit = (_capacity < new_capacity) ? _capacity : new_capacity;
        for (INDEX i = 0; i < limit; i++)
            bv->inline_setbit(i, inline_getbit(i));
        if (_capacity < new_capacity)
        {
            BIT bit = check_bit(initial_element);
            for (INDEX i = _capacity; i < new_capacity; i++)
                bv->inline_setbit(i, bit);
        }
        return bv;
    }
    // no change
    return this;
}
Пример #10
0
	void fighter::ai()
	{
		if(check_bit(attributes, DEAD) || check_bit(attributes, FRIENDLY))
			return;

		calc_lightmap();
		int targetx, targety;
		if(lightmap->data[curr_level->guy->y][curr_level->guy->x] == 1)
		{
			targetx = curr_level->guy->x;
			targety = curr_level->guy->y;
		}
		else
		{
			return;
//			targetx = x;
//			targety = y;
		}

		if(a_star(targetx, targety))
		{

			if(is_monster(moves[0]->x, moves[0]->y))
			{
				int monst = is_monster(moves[0]->x, moves[0]->y) - 1;
				attack_something(curr_level->monsters[monst]);
			}
			if(curr_level->guy->x == moves[0]->x && curr_level->guy->y == moves[0]->y)
				attack_something(curr_level->guy);

			if(good_move(moves[0]->x, moves[0]->y))
			{
				x = moves[0]->x;
				y = moves[0]->y;
			}

			while(moves.size() > 0)
				moves.erase(moves.begin());
		}

		return;
	}
Пример #11
0
// This function determines whether or not the terminal is ATM.
// This check is performed based on the rule specified in
// EMV book 4 (Cardholder, Attendant and Acquirer Interface Requirements),
// Annex A, A1.
// Terminal types '14', '15', and '16' with cash disbursment capability
//(Additional terminal capabilities, byte 1, 'cash' bit = '1') are considered
// to be ATMs. All other terminal types are not considered to be ATMs.
bool ProcessingRestrictions::IsATM(DataObject *dob_TermType,
                                   DataObject *dob_TermCap)
{
    if (((dob_TermType->Data[0] == 0x14) ||
            (dob_TermType->Data[0] == 0x15) ||
            (dob_TermType->Data[0] == 0x16)) &&
            check_bit(dob_TermCap->Data [0], 0x80))
        return true;
    else
        return false;
}
Пример #12
0
void print_footprint(int foot_print)
{
    printf ("footprint: ");
    int j;
    for (j = 0; j < nitems; ++j){
        if (check_bit(j, foot_print)){
            printf ("%d ", weight[j]);
        }
    }
    printf ("\n");
}
int check_is_null(pnArray null_struct, int index)
{
    if(!null_struct || index < 0 || index > null_struct->len) {
        debug("parameter error: null parameter");
        return ERR ;
    }
    if(1==check_bit(null_struct->map,index,null_struct->len*8)) {
        return index ;
    }
    return ERR ;
}
Пример #14
0
int knapsack_bruteforce()
{
    int i, kinds = pow(2, nitems);
    int max_value = 0, foot_print = 0;
    
    for (i = 0; i < kinds; ++i){
        int j, weight_sum = 0, value_sum = 0;

        for (j = 0; j < nitems; ++j){
            weight_sum += weight[j] * check_bit(j, i);
            value_sum += value[j] * check_bit(j, i);            
        }

        if (weight_sum <= knapsacksize && value_sum > max_value){
            max_value = value_sum;
            foot_print = i;
        }
    }
    /// print_footprint(foot_print);
    return max_value;
}
static
void
add_lock_to_mutex_after_list(ndb_mutex_state * m1, NdbMutex* m2)
{
  assert(m1 != m2->m_mutex_state);
  unsigned no = m2->m_mutex_state->m_no;
  if (!check_bit(&m1->m_locked_after_mask, no))
  {
    set_bit(&m1->m_locked_after_mask, no);
    add_mutex_to_array(&m1->m_locked_after_list, m2);
  }
}
Пример #16
0
void SimpleBitVector::fill(Value value)
{
    const BIT bit = check_bit(value);
    INDEX size = _capacity >> BIT_VECTOR_SHIFT;
    if ((_capacity & BIT_VECTOR_MASK) != 0)
        ++size;
    if (bit == 0)
        for (INDEX i = size; i-- > 0;)
            _data[i] = 0;
    else
        for (INDEX i = size; i-- > 0;)
            _data[i] = 0xffffffff;
}
Пример #17
0
void* allocate() 
{ 

	unsigned short shortfull = 65535; // (2^16)

	// ersten nicht vollen short finden
	int i;
	int current_short = -1;
	int current_bit;
	
	for (i=0; i < (NUM_BLOCKS/16); i++)
	{
		if (allocated_map[i] < shortfull)
		{
			current_short = i;
			break; // for schleife verlassen
		}

	}

	// kein freies short gefunden --> Nullpointer returnen
	if (current_short == -1)
	{
		fprintf(stderr, "Warning: Arena full!\n");
		return (void*) 0; 
	}

	// sonst weiter mit freiem short!
	// freies bit finden & 1 setzen
	for (i=0; i<16; i++)
	{
		if(!check_bit(&allocated_map[current_short],i)) // erste 0 finden
		{
			current_bit = i;
			set_bit(&allocated_map[current_short],current_bit);
			break;
		}
	}

	// entsprechenden pointer in arena finden
	int offset = 16*current_short + current_bit;

	// pointer returnen
	printf("[info] allocated block: %d/%d [%ld]\n", current_short, current_bit, (long)(&arena[offset*BLOCKSIZE]));
	return &arena[offset*BLOCKSIZE];

}
Пример #18
0
int 
Array_Sort<elemType>::
find( const elemType &val )
{
     int low = 0;
     int high = Array<elemType>::_size-1;
     check_bit();
     while ( low <= high ) 
     {
          int mid = ( low + high )/2;

          if ( val == _ia[ mid ])
               return mid;

          if ( val < _ia[ mid ] )
               high = mid-1;
          else low = mid+1;
     }

     return -1;
}
void
ndb_mutex_locked(NdbMutex* p)
{
  ndb_mutex_state * m = p->m_mutex_state;
  ndb_mutex_thr_state * thr = get_thr();
  if (thr == 0)
  {
    /**
     * These are threads not started with NdbThread_Create(...)
     *   e.g mysql-server threads...ignore these for now
     */
    return;
  }

  for (unsigned i = 0; i < thr->m_mutexes_locked.m_used; i++)
  {
    /**
     * We want to lock m
     * Check that none of the mutex we curreny have locked
     *   have m in their *before* list
     */
    NdbMutex * h = get_element(&thr->m_mutexes_locked, i);
    if (check_bit(&h->m_mutex_state->m_locked_before_mask, m->m_no))
    {
      abort();
    }

    /**
     * Add h to m's list of before-locks
     */
    add_lock_to_mutex_before_list(m, h);

    /**
     * Add m to h's list of after locks
     */
    add_lock_to_mutex_after_list(h->m_mutex_state, p);
  }

  add_lock_to_thread(thr, p);
}
static
unsigned
alloc_mutex_no()
{
  Guard g(&g_mutex_no_mutex);
  unsigned no = 0;

  for (unsigned i = 0; i < g_mutex_no_mask.m_len; i++)
  {
    if (g_mutex_no_mask.m_mask[i] != 255)
    {
      no = (8 * i) + ff(g_mutex_no_mask.m_mask[i]);
      goto found;
    }
  }

  no = 8 * g_mutex_no_mask.m_len;
found:
  set_bit(&g_mutex_no_mask, no);
  assert(check_bit(&g_mutex_no_mask, no));
  return no;
}
Пример #21
0
/******************************************************************
 * calculation server
 * delivers positions in string format which can be sent easily
 * over a communication line to the calculation client.
 * if plalist = 0, only SUN .. CHIRON are delivered, no LILITH
 ******************************************************************/
int calcserv(int id,	/* request id, random number to prevent phase err */
	    double jd_ad,	/* time as relative Astrodienst julian date */
	    int	flag,	/* a set of CALC_BIT_ bitflags */
	    int  plalist,/* bit list of planets to be computed, 0 = all */
	    char *so)	/* output string, MUST BE LONG ENOUGH (800 bytes)*/
{
  int p, planet, so_len;
  double rlng, rrad, rlat, rspeed, rau[CALC_N];
  centisec lcs[CALC_N], lpcs[CALC_N], betcs[CALC_N]; 
  char s[AS_MAXCH];
  if (plalist == 0) plalist = (1 << 13) - 1;	/* sun .. chiron */;
  /*
   * flag determines whether deltat is added to t;
   * if CALC_BIT_EPHE is set, jd_ad is considered as ephemeris time,
   * otherwise as universal time.
   */
  if ((flag & CALC_BIT_EPHE) == 0) {
    jd_ad += deltat (jd_ad);
  }
  for (p = SUN; p < CALC_N; p++) {
    if (! check_bit(plalist, p)) continue;
    if (calc (p, jd_ad, flag, &rlng, &rrad, &rlat, &rspeed) == OK) {
      lcs [p] = swe_d2l (rlng * DEG);
      lpcs [p] = swe_d2l (rspeed * DEG);
      betcs [p] = swe_d2l (rlat * DEG);
      rau [p] = rrad;
    } else {
      sprintf(so,"error at planet %d", p);
      return ( ERR);
    }
  }
  /*
   * format comma separated list: id,teph,flag,plalist,ekl,nut
   * double is given with 8 digits precision after decimal point, 
   * all angles are given in centiseconds.
   * then for each requested planet: longitude (csec)
   * then for each requested planet, if wanted: speed (csec/day)
   * then for each requested planet, if wanted: latitude (csec)
   * then for each requested planet, if wanted: rgeo (units 0..999)
   * then for each requested planet, if wanted: rau  (A.U.)
   */
  sprintf (so, "%d,%.8f,%d,%d,%d,%d", id, jd_ad, flag, plalist, 
	       swe_d2l(ekl * DEG), swe_d2l (nut * DEG) );
  so_len = strlen (so);
  for (planet = SUN; planet < CALC_N; planet++) {
    if (! check_bit(plalist, planet)) continue;
    sprintf (s ,",%d", lcs[planet]);
    strcat (so + so_len, s);
    so_len += strlen (s);
  }
  if (flag & CALC_BIT_SPEED) {
    for (planet = SUN; planet < CALC_N; planet++)  {
      if (! check_bit(plalist, planet)) continue;
      sprintf (s ,",%d", lpcs[planet]);
      strcat (so + so_len, s);
      so_len += strlen (s);
    }
  }
  if (flag & CALC_BIT_BETA) {
    for (planet = SUN; planet < CALC_N; planet++)  {
      if (! check_bit(plalist, planet)) continue;
      sprintf (s ,",%d", betcs[planet]);
      strcat (so + so_len, s);
      so_len += strlen (s);
    }
  }
  if (flag & CALC_BIT_RGEO) {
    for (planet = SUN; planet < CALC_N; planet++)  {
      if (! check_bit(plalist, planet)) continue;
      sprintf (s ,",%d", rel_geo(planet,rau[planet]));
      strcat (so + so_len, s);
      so_len += strlen (s);
    }
  }
  if (flag & CALC_BIT_RAU) {
    for (planet = SUN; planet < CALC_N; planet++)  {
      if (! check_bit(plalist, planet)) continue;
      sprintf (s ,",%.8f", rau[planet]);
      strcat (so + so_len, s);
      so_len += strlen (s);
    }
  }
  return (OK);
}	/* end calcserv */
Пример #22
0
/*	//move, because it would be boring otherwise
	void fungus::move(int x_change, int y_change)
	{
		a=x;
		b=y;

		x += x_change;
		y += y_change;
	}
*/
	void fungus::ai()
	{
		if(check_bit(attributes, DEAD))// || check_bit(attributes, FRIENDLY))
			return;

		other_count++;

		if(other_count == 6)
		{
			other_count = 0;
			set_bit(attributes, ASLEEP);
			return;
		}

		if(hp < hp_old)
		{
			for(unsigned int i=0; i<curr_level->monsters.size(); i++)
				if(curr_level->monsters[i]->type == type && curr_level->monsters[i]->x >= x-1 && curr_level->monsters[i]->x <= x+1 && curr_level->monsters[i]->y >= y-1 && curr_level->monsters[i]->y <= y+1)
				{
					unset_bit(curr_level->monsters[i]->attributes, ASLEEP);
					curr_level->monsters[i]->energy = curr_level->guy->speed;
					curr_level->monsters[i]->other_count = 0;
				}
		}
		hp_old = hp;


//		int colors[6] =  { 46, 82, 118, 154, 190, 226 };  //green/yellow (plant)
		int colors[6] = { 201, 165, 129, 93, 57, 21 };  //purple/blue
//		int colors[6] = { 196, 202, 208, 214, 220, 226 };  //red/yellow (fire)
//		int colors[6] = { 52, 58, 64, 70, 76, 82};  //red/grean (sickly);
//		int colors[6] = { 196, 160, 124, 88, 52, 52 };  //dark red

		color = colors[other_count];

		int direction = range(1,9);
		int spawn_x = x, spawn_y = y;

		switch(direction)
		{
			case 1:
				spawn_y--;
				spawn_x--;
				break;
			case 2:
				spawn_y--;
				break;
			case 3:
				spawn_y--;
				spawn_x++;
				break;
			case 4:
				spawn_x--;
				break;
			case 5:
				spawn_x++;
				break;
			case 6:
				spawn_y++;
				spawn_x--;
				break;
			case 7:
				spawn_y++;
				break;
			case 8:
				spawn_y++;
				spawn_x++;
				break;
		}

		for(unsigned int i=0; i<curr_level->monsters.size(); i++)
			if(curr_level->monsters[i]->x == x && curr_level->monsters[i]->y == y && curr_level->monsters[i] != this)
				attack_something(curr_level->monsters[i]);

		if(curr_level->data->data[spawn_y][spawn_x] == FLOOR)
		{
	//		if(range(0,2) != 1)
	//			return;

			for(unsigned int i=0; i<curr_level->monsters.size(); i++)
				if(curr_level->monsters[i]->x == spawn_x && curr_level->monsters[i]->y == spawn_y && !check_bit(curr_level->monsters[i]->attributes, DEAD))
				{
					if(curr_level->monsters[i]->type != type)
						attack_something(curr_level->monsters[i]);

					return;
				}

			if(curr_level->guy->x == spawn_x && curr_level->guy->y == spawn_y)
			{
				attack_something(curr_level->guy);
				return;
			}

			curr_level->monsters.push_back(new fungus(type,spawn_x, spawn_y, curr_level));
		}

		
	}
Пример #23
0
int main(void) {
    int t; // number of test cases
    scanf("%d", &t);

    char s[MAX_LENGTH]; // string S, maximum length of 10
    int bits[INT_SIZE]; // we need 10 bits, hence 1 int will do
    for (int i = 1; i <= t; i++) {
        scanf("%s", s);

        // printf("%lu\n", strlen(s));
        if (strlen(s) == 0) { // No pancakes, no flipping
            printf("Case #%d: 0\n", i);
            continue;
        }

        // Clear the bit array
        for (int x = 0; x < INT_SIZE; x++) {
            bits[x] = 0;
        }

        // Translate + to 1 and - to 0 in the bits array
        int len = strlen(s);
        for (int pos = 0; pos < len; pos++) {
            if (s[pos] == '+') {
                set_bit(bits, pos);
            } // else it's still 0
        }
        // Now set the remaining bits after len to 1 (happy)
        for (int pos = len; pos < (INT_SIZE * 4 * 8); pos++) {
            set_bit(bits, pos);
        }

        // for (int pos = 0; pos < (INT_SIZE * 4 * 8); pos++) {
        //     printf("%d", check_bit(bits, pos));
        // }

        int flipped_count = 0;
        while (1) {
            if (check_bit(bits, 0) == 1) { // start with a +, flip first
                int l = 0;
                while (check_bit(bits, l) == 1 && l < MAX_LENGTH) l++;

                if (l == MAX_LENGTH) { // all done, break loop
                    break;
                }

                reverse_and_flip_bits(bits, l);
                flipped_count++;
            }

            // should start with a - here, look for differences now
            int l = 0;
            while (check_bit(bits, l) == 0) l++;

            reverse_and_flip_bits(bits, l);
            flipped_count++;
        }

        printf("Case #%d: %d\n", i, flipped_count);
    }

    return 0;
}
Пример #24
0
uint32_t get_pinMode(uint32_t pin)
{
        uint64_t bit = check_bit(&pin_modes, pin);
        return ((bit == 0)? IN : OUTPUT);
}
Пример #25
0
uint32_t get_pinState(uint32_t pin)
{
        uint64_t bit = check_bit(&pin_states, pin);
        return ((bit == 0)? LOW : HIGH);
}
Пример #26
0
/* ------------------------------------------------------------------------- */
uint8_t nrf24_miso_digitalRead()
{
    return check_bit(RF_PIN,MISO);
}
Пример #27
0
int ProcessingRestrictions::CheckUsageControl()
{
    DataObject dob_auc; // Application Usage Control
    int res;

    if (InitStatus == EMV_DATA_ERROR)
        return initError;
    if (InitStatus == EMV_DATA_NOT_INITIALIZED)
    {
        if (initData() != SUCCESS)
            return initError;
    }

    res = EnvContext.getTagValue (0x9f07, &dob_auc, true);
    if (res == SUCCESS && dob_auc.len > 0)
    {
        // DO checking according to section 6.4.2, EMV book 3 -
        //  Application Usage Control)

        // Get Terminal Type and additional terminal capabilities
        DataObject dob_termType;
        DataObject dob_addTermCap;
        if ((res = EnvContext.getTagValue (0x9f35, &dob_termType, false))
                != SUCCESS)
            return EMV_MISSING_MANDATORY_DATA;

        if ((res = EnvContext.getTagValue (0x9f40, &dob_addTermCap, false))
                != SUCCESS)
            return EMV_MISSING_MANDATORY_DATA;

        // Check condition 1 (section 6.4.2, EMV book 3)
        if (IsATM(&dob_termType, &dob_addTermCap))
        {
            // Terminal type is ATM
            if (!check_bit(dob_auc.Data[0], 0x02))
            {
                //Appl Usage Control doesn't have 'Valid for ATMs' bit set
                updateDataObject (0x95, &dob_TVR, 2, 0x10);
            }
        }
        else
        {
            // Terminal is not an ATM
            // Check condition 2 (section 6.4.2, EMV book 3)
            if (!check_bit(dob_auc.Data[0], 0x01))
            {
                // Appl Usage Control doesn't have 'Valid for terminals
                // other than ATMs' bit set
                updateDataObject (0x95, &dob_TVR, 2, 0x10);
            }
        }

        // Get Issuer Country Code
        DataObject dob_issCntryCode;
        if ((res = EnvContext.getTagValue (0x5f28, &dob_issCntryCode, true))
                != SUCCESS)
        {
            // Issuer Country code is conditional if Application Usage Control is
            // present. Since it is not found, do not continue with additional
            // checking
            return SUCCESS;
            //return EMV_MISSING_MANDATORY_DATA;
        }

        // Get Transaction Info (tag '60000001' in TransactionTypes). This data type
        // must be initialized during TransactionType initialization
        DataObject dob_transInfo;
        if ((res = EnvContext.getTagValue (0x60000001, &dob_transInfo, true))
                != SUCCESS)
        {
            // Transaction Info is mandatory.
            //Since it is not found, exit the transaction
            return EMV_MISSING_MANDATORY_DATA;
        }

        byte cash = 0x20;
        byte goods = 0x04;
        byte services = 0x08;
        byte cashback = 0x02;

        byte dom_cash = 0x80;
        byte int_cash = 0x40;
        byte dom_goods = 0x20;
        byte int_goods = 0x10;
        byte dom_serv = 0x08;
        byte int_serv = 0x04;
        byte dom_csh_back = 0x80;
        byte int_csh_back = 0x40;

        bool IsCountryCodeMatch = CompareByteArr (dob_issCntryCode.Data,
                                  dob_issCntryCode.len,
                                  dob_TermCountryCode.Data,
                                  dob_TermCountryCode.len);

        if (checkTransaction (dob_transInfo.Data [0],
                              cash, dom_cash, int_cash,
                              dob_auc.Data[0], IsCountryCodeMatch) != SUCCESS)
            return updateDataObject (0x95, &dob_TVR, 2, 0x10);
        if (checkTransaction (dob_transInfo.Data [0],
                              goods, dom_goods, int_goods,
                              dob_auc.Data[0], IsCountryCodeMatch) != SUCCESS)
            return updateDataObject (0x95, &dob_TVR, 2, 0x10);
        if (checkTransaction (dob_transInfo.Data [0],
                              services, dom_serv, int_serv,
                              dob_auc.Data[0], IsCountryCodeMatch) != SUCCESS)
            return updateDataObject (0x95, &dob_TVR, 2, 0x10);
        // Check if cashback amount (Amount Other, tag '9F03') is present
        DataObject dob_cashBack;
        if ((res = EnvContext.getTagValue (0x9f03, &dob_cashBack, true))
                == SUCCESS)
        {
            if (checkTransaction (dob_transInfo.Data [0],
                                  cashback, dom_csh_back,
                                  int_csh_back, dob_auc.Data[1],
                                  IsCountryCodeMatch) != SUCCESS)
                return updateDataObject (0x95, &dob_TVR, 2, 0x10);
        }
    }
    return SUCCESS;

}
/* ------------------------------------------------------------------------- */
uint8_t nrf24_miso_digitalRead()
{
    return check_bit(PINC,0);
}