Beispiel #1
0
// Once the wanted protocol, modus and RF channel are set, 
// only one bit (RXEN) is shifted in to switch between RX and TX. 
void RF_24G_SetRx() 
{ 
    setOutput();
    BIT_CLEAR(RF_24G_CE_PORT, RF_24G_CE_BIT); 
    BIT_SET(RF_24G_CS_PORT, RF_24G_CS_BIT); 
    CSDELAY(); 
    BIT_SET(RF_24G_DATA_OUT_PORT, RF_24G_DATA_BIT); 
    BIT_SET(RF_24G_CLK1_PORT, RF_24G_CLK1_BIT); 
    CLKDELAY(); 
    BIT_CLEAR(RF_24G_CLK1_PORT, RF_24G_CLK1_BIT); 
    CLKDELAY(); 
    BIT_CLEAR(RF_24G_CS_PORT, RF_24G_CS_BIT); 
    //OUTPUT_FLOAT(RF_24G_DATA); 
    BIT_CLEAR(RF_24G_CLK1_PORT, RF_24G_CLK1_BIT); 
    BIT_SET(RF_24G_CE_PORT, RF_24G_CE_BIT); 
    setInput();
} 
Beispiel #2
0
void putByte( uint8_t b ) 
{  
    //MSB first 
    int8_t i; 
    for(i=0 ; i < 8 ; i++) { 
        BIT_CLEAR(RF_24G_CLK1_PORT, RF_24G_CLK1_BIT); 
        if( BIT_TEST(b,BIT7) ) { 
            BIT_SET(RF_24G_DATA_OUT_PORT, RF_24G_DATA_BIT); 
        }else{ 
            BIT_CLEAR(RF_24G_DATA_OUT_PORT, RF_24G_DATA_BIT); 
        } 
        b<<=1;
        CLKDELAY(); 
        BIT_SET(RF_24G_CLK1_PORT, RF_24G_CLK1_BIT);  // Clock out on rising edge 
        CLKDELAY(); 
    } 
} 
Beispiel #3
0
static void
inherit_f2(struct f2 *inheritor_f2, struct f2 *from_f2)
{
#define inherit(memb) if((!(inheritor_f2->memb) || !(*inheritor_f2->memb))&&from_f2->memb)inheritor_f2->memb=from_f2->memb

  if (BIT_ISSET(inheritor_f2->flags, F2_FLAGS_FROM_CACHE))
    {
      *inheritor_f2 = *from_f2;
      return;
    }

#if 0
  if (!strcmp((const char *)inheritor_f2->form, "*"))
    inherit(cf);
#endif

  inherit(base);
  inherit(cont);
  inherit(norm);

  /* Fix the CF and GW fields: in L2 we can't make any kind
     of a match without these either matching CF/NORM or
     GW/SENSE, so this coercion is safe */
  if (!inheritor_f2->cf || (!BIT_ISSET(inheritor_f2->flags, F2_FLAGS_NOT_IN_SIGS)
			    && strcmp((char*)inheritor_f2->cf,(char*)from_f2->cf)))
    {
      inheritor_f2->cf = from_f2->cf;
      BIT_CLEAR(inheritor_f2->flags, F2_FLAGS_NORM_IS_CF);
    }
  if (!inheritor_f2->gw || (!BIT_ISSET(inheritor_f2->flags, F2_FLAGS_NOT_IN_SIGS)
			    && strcmp((char*)inheritor_f2->gw,(char*)from_f2->gw)))
    inheritor_f2->gw = from_f2->gw;
  if (!inheritor_f2->sense || (!BIT_ISSET(inheritor_f2->flags, F2_FLAGS_NOT_IN_SIGS)
			       && strcmp((char*)inheritor_f2->sense,(char*)from_f2->sense)))
    inheritor_f2->sense = from_f2->sense;

  if (!inheritor_f2->pos)
    inheritor_f2->pos = from_f2->pos;
  else
    {
      if (!BIT_ISSET(inheritor_f2->flags, F2_FLAGS_NOT_IN_SIGS))
	{
	  if (strcmp((char*)inheritor_f2->pos,(char*)from_f2->pos))
	    {
	      /* silently correct x[y]N where it is really x[y]'N */
	      inheritor_f2->epos = inheritor_f2->pos;
	      inheritor_f2->pos = from_f2->pos;
	    }
	}
    }

  inherit(epos);

  inherit(stem);
  inherit(morph);
  inherit(morph2);
#undef inherit
}
Beispiel #4
0
/*
 * get the values of malloc environ variables
 */
LOCAL	void	get_environ(void)
{
  char		*env;
  
  /* get the malloc_debug value */
  env = (char *)getenv(DEBUG_ENVIRON);
  if (env != NULL)
    _malloc_debug = hex_to_int(env);
  
  /* get the malloc debug logfile name into a holding variable */
  env = (char *)getenv(LOGFILE_ENVIRON);
  if (env != NULL) {
    (void)strcpy(log_path, env);
    malloc_logpath = log_path;
  }
  
  /* watch for a specific address and die when we get it */
  env = (char *)getenv(ADDRESS_ENVIRON);
  if (env != NULL) {
    char	*addp;
    
    addp = index(env, ':');
    if (addp != NULL) {
      *addp = NULLC;
      address_count = atoi(addp + 1);
    }
    else
      address_count = 1;
    
    malloc_address = (char *)hex_to_int(env);
  }
  
  /* check the heap every X times */
  env = (char *)getenv(INTERVAL_ENVIRON);
  if (env != NULL)
    check_interval = atoi(env);
  
  /*
   * start checking the heap after X iterations OR
   * start at a file:line combination
   */
  env = (char *)getenv(START_ENVIRON);
  if (env != NULL) {
    char	*startp;
    
    BIT_CLEAR(_malloc_debug, DEBUG_CHECK_HEAP);
    
    startp = index(env, ':');
    if (startp != NULL) {
      *startp = NULLC;
      (void)strcpy(start_file, env);
      start_line = atoi(startp + 1);
      start_count = 0;
    }
    else
      start_count = atoi(env);
  }
}
Beispiel #5
0
static int32_t
af_inet_bind_to_port_lt_ceiling(int fd, struct sockaddr *sockaddr,
                                socklen_t sockaddr_len, uint32_t ceiling)
{
#if GF_DISABLE_PRIVPORT_TRACKING
    _assign_port(sockaddr, 0);
    return bind(fd, sockaddr, sockaddr_len);
#else
    int32_t ret = -1;
    uint16_t port = ceiling - 1;
    unsigned char ports[GF_PORT_ARRAY_SIZE] = {
        0,
    };
    int i = 0;

loop:
    ret = gf_process_reserved_ports(ports, ceiling);

    while (port) {
        if (port == GF_CLIENT_PORT_CEILING) {
            ret = -1;
            break;
        }

        /* ignore the reserved ports */
        if (BIT_VALUE(ports, port)) {
            port--;
            continue;
        }

        _assign_port(sockaddr, port);

        ret = bind(fd, sockaddr, sockaddr_len);

        if (ret == 0)
            break;

        if (ret == -1 && errno == EACCES)
            break;

        port--;
    }

    /* In case if all the secure ports are exhausted, we are no more
     * binding to secure ports, hence instead of getting a random
     * port, lets define the range to restrict it from getting from
     * ports reserved for bricks i.e from range of 49152 - 65535
     * which further may lead to port clash */
    if (!port) {
        ceiling = port = GF_CLNT_INSECURE_PORT_CEILING;
        for (i = 0; i <= ceiling; i++)
            BIT_CLEAR(ports, i);
        goto loop;
    }

    return ret;
#endif /* GF_DISABLE_PRIVPORT_TRACKING */
}
Beispiel #6
0
void RF_24G_Config() 
{ 
    BIT_CLEAR(RF_24G_CE_PORT, RF_24G_CE_BIT); 
    BIT_CLEAR(RF_24G_CS_PORT, RF_24G_CS_BIT); 
    BIT_CLEAR(RF_24G_CLK1_PORT, RF_24G_CLK1_BIT); 
    BIT_CLEAR(RF_24G_DATA_OUT_PORT, RF_24G_DATA_BIT); 
    PWUPDELAY(); 
    BIT_SET(RF_24G_CS_PORT, RF_24G_CS_BIT); 
    CSDELAY(); 

    //MSB byte first 
    putByte(DATA2_W); 
    putByte(DATA1_W); 
    putByte(ADDR2_4); 
    putByte(ADDR2_3); 
    putByte(ADDR2_2); 
    putByte(ADDR2_1); 
    putByte(ADDR2_0); 
    putByte(ADDR1_4); 
    putByte(ADDR1_3); 
    putByte(ADDR1_2); 
    putByte(ADDR1_1); 
    putByte(ADDR1_0); 
    putByte(ADDR_W_2_BYTE | CRC_L_16_BIT | CRC_EN_ENABLE); 
    //putByte(ADDR_W_2_BYTE | CRC_L_8_BIT | CRC_EN_ENABLE); 
    putByte(RX2_EN_DISABLE | CM_SHOCKBURST | RFDR_SB_1_MBPS | XO_F_16MHZ | RF_PWR_0DB); 
    //putByte(RF_CH | RXEN_RX); 
    putByte(RF_CH | RXEN_TX); 

    //OUTPUT_FLOAT(RF_24G_DATA); 
    BIT_CLEAR(RF_24G_CE_PORT, RF_24G_CE_BIT); 
    BIT_CLEAR(RF_24G_CS_PORT, RF_24G_CS_BIT); 
    BIT_CLEAR(RF_24G_CLK1_PORT, RF_24G_CLK1_BIT); 
} 
Beispiel #7
0
/******************************************************************
 ** LedsUpdate
 *
 *  DESCRIPTION:
 *		Updates the LEDs with data from global state register
 *
 *  Create: 5/9/2006	9:28:49 PM - Trampas Stern
 *******************************************************************/
INT LedsUpdate(void)
{
	//write data to U18
	DATA_WRITE(LEDS_U18);
	//latch data
	BIT_SET(PORTG,2);
	BIT_SET(PORTG,2); //write twice as delay
	BIT_CLEAR(PORTG,2);

	//write data to U40
	DATA_WRITE(LEDS_U40);
	//latch data
	BIT_SET(PORTC,7);
	BIT_SET(PORTC,7); //write twice as delay
	BIT_CLEAR(PORTC,7);

	return NO_ERROR;
}
Beispiel #8
0
/****************************************************************************
* DESCRIPTION: Enable or disable the transmitter
* RETURN:      none
* ALGORITHM:   none
* NOTES:       none
*****************************************************************************/
void RS485_Transmitter_Enable(
    bool enable)
{
    if (enable) {
        BIT_SET(PORTD, PD2);
    } else {
        BIT_CLEAR(PORTD, PD2);
    }
}
Beispiel #9
0
/* enable the transmit-enable line on the RS-485 transceiver */
void rs485_rts_enable(
    bool enable)
{
    if (enable) {
        BIT_SET(PORTD, PD4);
    } else {
        BIT_CLEAR(PORTD, PD4);
    }
}
Beispiel #10
0
/*
 * dump the current flags set in the debug variable VAL
 */
static	void	dump_debug(const unsigned long val)
{
  attr_t	*attr_p;
  char		*str;
  unsigned long	work = val;
  int		col_c = 0, len;
  
  for (attr_p = attributes; attr_p->at_string != NULL; attr_p++) {
    /* the below test for work == 0 is necessary to handle the 'none' token */
    if ((work == 0 && attr_p->at_value == 0)
	|| (attr_p->at_value != 0 && BIT_IS_SET(work, attr_p->at_value))) {
      BIT_CLEAR(work, attr_p->at_value);
      
      if (col_c == 0) {
	(void)fprintf(stderr, "   ");
	col_c += 3;
      }
      
      if (very_verbose_b) {
	(void)fprintf(stderr, "%s -- %s (%#lx)\n",
		      attr_p->at_string, attr_p->at_desc, attr_p->at_value);
	col_c = 0;
      }
      else {
	str = attr_p->at_string;
	len = strlen(str);
	if (col_c + len + 2 > LINE_WIDTH) {
	  (void)fprintf(stderr, "\n");
	  (void)fprintf(stderr, "   ");
	  col_c = 3;
	}
	(void)fprintf(stderr, "%s", str);
	col_c += len;
	
	/* if we've got more to go then print the , */
	if (work != 0) {
	  (void)fprintf(stderr, ", ");
	  col_c += 2;
	}
      }
      
      if (work == 0) {
	break;
      }
    }
  }
  
  if (col_c != 0) {
    (void)fprintf(stderr, "\n");
  }
  
  if (work != 0) {
    (void)fprintf(stderr, "%s: warning, unknown debug flag(s): %#lx\n",
		  argv_program, work);
  }
}
Beispiel #11
0
/*************************************************************************
* Description: Initialization for Timer
* Returns: none
* Notes: none
*************************************************************************/
static void timer2_init(
    void)
{
    /* Normal Operation */
    TCCR2A = 0;
    /* Timer2: prescale selections:
       CSn2 CSn1 CSn0 Description
       ---- ---- ---- -----------
       0    0    0  No Clock Source
       0    0    1  No prescaling
       0    1    0  CLKt2s/8
       0    1    1  CLKt2s/32
       1    0    0  CLKt2s/64
       1    0    1  CLKt2s/128
       1    1    0  CLKt2s/256
       1    1    1  CLKt2s/1024
     */
#if (TIMER2_PRESCALER==1)
    TCCR2B = _BV(CS20);
#elif (TIMER2_PRESCALER==8)
    TCCR2B = _BV(CS21);
#elif (TIMER2_PRESCALER==32)
    TCCR2B = _BV(CS21) | _BV(CS20);
#elif (TIMER2_PRESCALER==64)
    TCCR2B = _BV(CS22);
#elif (TIMER2_PRESCALER==128)
    TCCR2B = _BV(CS22) | _BV(CS20);
#elif (TIMER2_PRESCALER==256)
    TCCR2B = _BV(CS22) | _BV(CS21);
#elif (TIMER2_PRESCALER==1024)
    TCCR2B = _BV(CS22) | _BV(CS21) | _BV(CS20);
#else
#error Timer2 Prescale: Invalid Value
#endif
    /* Clear any TOV Flag set when the timer overflowed */
    BIT_CLEAR(TIFR2, TOV2);
    /* Initial value */
    TCNT2 = TIMER2_COUNT;
    /* Enable the overflow interrupt */
    BIT_SET(TIMSK2, TOIE2);
    /* Clear the Power Reduction Timer/Counter0 */
    BIT_CLEAR(PRR, PRTIM2);
}
Beispiel #12
0
void
systemConfig( uint32_t flags )
{
	BIT_CLEAR( MMCHS_SYSCONFIG, MMCHS_SYSCONFIG_AUTOIDLE_BIT |
			MMCHS_SYSCONFIG_SOFTRESET_BIT |
			MMCHS_SYSCONFIG_ENAWAKEUP_BIT |
			MMCHS_SYSCONFIG_SIDLE_BITS |
			MMCHS_SYSCONFIG_CLCKACT_BITS );

	BIT_SET( MMCHS_SYSCONFIG, flags );
}
Beispiel #13
0
void
setBusWidth( uint32_t busWidth )
{
	// NOTE: MMCHS_CON is configured only here in this function, wont be set during sending a command

	if ( BUS_WIDTH_8BIT == busWidth )
	{
		BIT_SET( MMCHS_CON, MMCHS_CON_DW8_BIT );
	}
	else if ( BUS_WIDTH_4BIT == busWidth )
	{
		BIT_CLEAR( MMCHS_CON, MMCHS_CON_DW8_BIT );
		BIT_SET( MMCHS_HCTL, MMCHS_HCTL_DTW_BIT );
	}
	else if ( BUS_WIDTH_1BIT == busWidth )
	{
		BIT_CLEAR( MMCHS_CON, MMCHS_CON_DW8_BIT );
		BIT_CLEAR( MMCHS_HCTL, MMCHS_HCTL_DTW_BIT );
	}
}
Beispiel #14
0
void getBuffer() 
{ 
    int8_t i; 
    for( i=0; i<BUF_MAX ; i++) { 
        RF_24G_Buffer[i] = getByte(); 
    } 
    BIT_CLEAR(RF_24G_CLK1_PORT, RF_24G_CLK1_BIT); 
    //wait for DR1 to go low
    while(hasData());
    BIT_SET(RF_24G_CE_PORT, RF_24G_CE_BIT); 
} 
Beispiel #15
0
/*************************************************************************
* Description: Turn off an LED
* Returns: none
* Notes: none
*************************************************************************/
void led_off(
    uint8_t index)
{
    switch (index) {
        case LED_1:
            BIT_CLEAR(PORTD, PD7);
            break;
        case LED_2:
            BIT_CLEAR(PORTD, PD6);
            break;
        case LED_3:
            BIT_CLEAR(PORTC, PC7);
            break;
        case LED_4:
            BIT_CLEAR(PORTC, PC6);
            break;
        default:
            break;
    }
}
/****************************************************************************
Call this function to set up the TWI slave to its initial standby state.
Remember to enable interrupts from the main application after initializing the TWI.
Pass both the slave address and the requrements for triggering on a general call in the
same byte. Use e.g. this notation when calling this function:
TWI_Slave_Initialise( (TWI_slaveAddress<<TWI_ADR_BITS) | (TRUE<<TWI_GEN_BIT) );
The TWI module is configured to NACK on any requests. Use a TWI_Start_Transceiver function to 
start the TWI.
****************************************************************************/
void TWI_Slave_Initialise( unsigned char TWI_ownAddress )
{
  TWAR = TWI_ownAddress;                            // Set own TWI slave address. Accept TWI General Calls.
  TWCR = (1<<TWEN)|                                 // Enable TWI-interface and release TWI pins.
         (0<<TWIE)|(0<<TWINT)|                      // Disable TWI Interupt.
         (0<<TWEA)|(0<<TWSTA)|(0<<TWSTO)|           // Do not ACK on any requests, yet.
         (0<<TWWC);                                 //
  TWI_busy = 0;

  BIT_CLEAR( PRR, PRTWI );
}    
int main ()
{
	DDRB = 0x03;
	PORTB = 0x02;
	while (1) {
		if (BIT_GET(PINB, BIT(7))) {
			BIT_SET(PORTB, BIT(0));
		}
		BIT_CLEAR(PORTB, BIT(0));
	}
	return 1;
}
Beispiel #18
0
/*************************************************************************
* Description: Turn off an LED
* Returns: none
* Notes: none
*************************************************************************/
void led_off(
    uint8_t index)
{
    switch (index) {
        case 0:
            BIT_CLEAR(PORTD, PD7);
            break;
        case 1:
            BIT_CLEAR(PORTD, PD6);
            break;
        case 2:
#if (BDK_VERSION==4)
            BIT_CLEAR(PORTB, PB0);
#else
            BIT_CLEAR(PORTC, PC7);
#endif
            break;
        case 3:
#if (BDK_VERSION==4)
            BIT_CLEAR(PORTB, PB4);
#else
            BIT_CLEAR(PORTC, PC6);
#endif
            break;
        default:
            break;
    }
    if (index < MAX_LEDS) {
        timer_interval_no_expire(&Off_Delay_Timer[index]);
    }
}
Beispiel #19
0
void calibration()
{
    robot.calibrated = FALSE;


    BIT_SET(DDRA,BIT(robot.portA.CAL));

    BIT_SET(PORTA,BIT(robot.portA.CAL));
    //vMax+
    setDirection(ARRIERE,AVANT);

//	wait();
    cal.vMaxPosD = speedMoteurDroit;
    cal.vMaxPosG = speedMoteurGauche;

    //vZero+
    BIT_CLEAR(PORTA,BIT(robot.portA.CAL));


//	wait();
    cal.vZeroPosD = speedMoteurDroit;
    cal.vZeroPosG= speedMoteurGauche;


    BIT_SET(PORTA,BIT(robot.portA.CAL));
    //vMax-
    setDirection(AVANT,ARRIERE);

    //      wait();
    cal.vMaxNegD = speedMoteurDroit;
    cal.vMaxNegG = speedMoteurGauche;

    BIT_CLEAR(PORTA,BIT(robot.portA.CAL));
    //vZero-
//	wait();
    cal.vZeroNegD = speedMoteurDroit;
    cal.vZeroNegG = speedMoteurGauche;
    robot.calibrated = TRUE;

}
// Initialize the Analog to Digital Conversion port
void AnalogInInit()
{
    BIT_CLEAR(PRR, PRADC);

    BITS_SET(ADCSRA, BIT(ADEN)  |   // ADC Enable
                     BIT(ADIE)  |   // ADC Interupt Enable
                     BIT(ADSC)  |   // ADC Start Conversion (need to trigger the first reading)
                     BIT(ADPS2) |   // Clk Div 128
                     BIT(ADPS1) |
                     BIT(ADPS0));

    BITS_SET(DIDR0, 0x06);          // Disable the digital I/O on used analog pins
}
Beispiel #21
0
void shift_write_word ( uint8_t *output, uint8_t size )
{
    uint8_t i;

    for ( i=1; i<=size; i++)
    {
        shift_write_bit(output[(size-i)/8] & (1<<(size-i)%8));
    }

    BIT_SET( LATCH_PORT, LATCH_BIT );
    _delay_us(DELAY);
    BIT_CLEAR( LATCH_PORT, LATCH_BIT );
    _delay_us(DELAY);
}
Beispiel #22
0
/*************************************************************************
* Description: returns the current millisecond count
* Returns: none
* Notes: This method only disables the timer overflow interrupt.
*************************************************************************/
uint32_t timer_milliseconds(
    void)
{
    uint32_t timer_value;       /* return value */

    /* Disable the overflow interrupt.
       Prevents value corruption that would happen if interrupted */
    BIT_CLEAR(TIMSK2, TOIE2);
    timer_value = Millisecond_Counter;
    /* Enable the overflow interrupt */
    BIT_SET(TIMSK2, TOIE2);

    return timer_value;
}
Beispiel #23
0
/******************************************************************
 ** LedsSet
 *
 *  DESCRIPTION:
 *		Sets the state of the leds
 *
 *  Create: 5/9/2006	9:37:35 PM - Trampas Stern
 *******************************************************************/
INT LedsSet(UINT8 Led, UINT8 State)
{
	if (Led<=7)
	{
		if (State)
	   	{
	   		BIT_CLEAR(LEDS_U18,Led);
		}else
		{
			BIT_SET(LEDS_U18,Led);
		}
	}else if (Led<=14)
	{
		Led=Led-8;
		if (State)
	   	{
	   		BIT_CLEAR(LEDS_U40,Led);
		}else
		{
			BIT_SET(LEDS_U40,Led);
		}
	}
	return LedsUpdate(); //update the LEDs
}
Beispiel #24
0
static void rs485_usart_init(
    void)
{
    /* enable Transmit and Receive */
    UCSR0B = _BV(TXEN0) | _BV(RXEN0);
    /* Set USART Control and Status Register n C */
    /* Asynchronous USART 8-bit data, No parity, 1 stop */
    /* Set USART Mode Select: UMSELn1 UMSELn0 = 00 for Asynchronous USART */
    /* Set Parity Mode:  UPMn1 UPMn0 = 00 for Parity Disabled */
    /* Set Stop Bit Select: USBSn = 0 for 1 stop bit */
    /* Set Character Size: UCSZn2 UCSZn1 UCSZn0 = 011 for 8-bit */
    /* Clock Polarity: UCPOLn = 0 when asynchronous mode is used. */
    UCSR0C = _BV(UCSZ01) | _BV(UCSZ00);
    /* Clear Power Reduction */
    BIT_CLEAR(PRR, PRUSART0);
}
Beispiel #25
0
uint8_t getByte() 
{  
    //MSB first 
    int8_t i, b = 0; 
    for(i=0 ; i < 8 ; i++) { 
        BIT_CLEAR(RF_24G_CLK1_PORT, RF_24G_CLK1_BIT); 
        CLKDELAY(); 
        BIT_SET(RF_24G_CLK1_PORT, RF_24G_CLK1_BIT); 
        CLKDELAY();           // Read before falling edge 
        if( BIT_TEST(RF_24G_DATA_IN_PORT, RF_24G_DATA_BIT) ) { 
            b|=1;
        } 
        if(i!=7)
            b<<=1;
    } 
    return b; 
} 
Beispiel #26
0
/*
 * a call to the alloc routines has been made, check the debug variables
 * returns [NO]ERROR.
 */
LOCAL	int	check_debug_vars(const char * file, const int line)
{
  static int	iterc = 0;
  
  if (in_alloc) {
    malloc_errno = MALLOC_IN_TWICE;
    _malloc_perror("check_debug_vars");
    /* malloc_perror may die already */
    _malloc_die();
    /*NOTREACHED*/
  }
  
  in_alloc = TRUE;
  
  if (! malloc_enabled)
    if (malloc_startup() != NOERROR)
      return ERROR;
  
  /* check start file/line specifications */
  if (! BIT_IS_SET(_malloc_debug, DEBUG_CHECK_HEAP)
      && start_file[0] != NULLC
      && file != NULL
      && strcmp(start_file, file) == 0
      && (line == 0 || line == start_line))
    BIT_SET(_malloc_debug, DEBUG_CHECK_HEAP);
  
  /* start checking heap after X times */
  if (start_count != -1 && --start_count == 0)
    BIT_SET(_malloc_debug, DEBUG_CHECK_HEAP);
  
  /* checking heap every X times */
  if (check_interval != -1) {
    if (++iterc >= check_interval) {
      BIT_SET(_malloc_debug, DEBUG_CHECK_HEAP);
      iterc = 0;
    }
    else
      BIT_CLEAR(_malloc_debug, DEBUG_CHECK_HEAP);
  }
  
  /* after all that, do we need to check the heap? */
  if (BIT_IS_SET(_malloc_debug, DEBUG_CHECK_HEAP))
    (void)_chunk_heap_check();
  
  return NOERROR;
}
Beispiel #27
0
//-----------------------------------------------------------------------------
// When a PONG is received, it is assumed that we sent a ping.  It can also be
// used as a keep-alive.
static void cmdPong(void *base)
{
 	node_t *node = (node_t *) base;

 	assert(node != NULL);
 	assert(node->handle >= 0);

 	assert(node->idle >= 0);
 	node->idle = 0;

 	if (BIT_TEST(node->flags, FLAG_NODE_BUSY)) {
		BIT_CLEAR(node->flags, FLAG_NODE_BUSY);

		// since the node is no longer marked as busy, then we need to alert the
		// queues so that they can begin sending messages to this node again.
		assert(0);
	}
}
Beispiel #28
0
void
sendInitStream( void )
{
	/* Enable the command completion status to be set */
	BIT_SET( MMCHS_IE, MMCHS_IE_CC_BIT );
	 /* Initiate the INIT command */
	BIT_SET( MMCHS_CON, MMCHS_CON_INIT_BIT );
	MMCHS_CMD = 0x0;

	// WAIT 1ms to allow card initializing internal state
	uint64_t sysMillis = getSysMillis();
	while ( 1 > getSysMillis() - sysMillis ) { }

	// end initialization sequence
	BIT_CLEAR( MMCHS_CON, MMCHS_CON_INIT_BIT );
	// clear all status
	clearAllInterruptsStatus();
}
Beispiel #29
0
uint32_t
setInternalClock( bool enable )
{
	if ( enable )
	{
		// await Internal clock stable
		BIT_SET( MMCHS_SYSCTL, MMCHS_SYSCTL_ICE_BIT );
		if ( awaitInternalClockStable( 0xFF ) )
		{
			return 1;
		}
	}
	else
	{
		BIT_CLEAR( MMCHS_SYSCTL, MMCHS_SYSCTL_ICE_BIT );
	}

	return 0;
}
Beispiel #30
0
static void udev_handle_keyboard(udev_input_t *udev,
      const struct input_event *event, struct input_device *dev)
{
   switch (event->type)
   {
      case EV_KEY:
         if (event->value)
            BIT_SET(udev->key_state, event->code);
         else
            BIT_CLEAR(udev->key_state, event->code);

#ifdef HAVE_XKBCOMMON
         handle_xkb(udev->xkb_state, udev->mod_map_idx, udev->mod_map_bit, event->code, event->value);
#endif
         break;

      default:
         break;
   }
}