/*
 * Clear the bit string.
 *	Clear the width bits from the position of specified bit.
 */
EXPORT void BitsClr( void *base, W offset, W width )
{
	UB	*bp;
	INT	n;

	n = offset / 8;
	bp = (UB*)base + n;

	n = (W)((UW)offset & 7U);
	if ( n > 0 ) {
		for ( ; n < 8; ++n ) {
			if ( --width < 0 ) {
				return;
			}
			BitClr(bp, (UW)n);
		}
		bp++;
	}

	n = width / 8;
	if ( n > 0 ) {
		MEMSET(bp, 0U, (size_t)n);
	}
	bp += n;
	width -= n * 8;

	for ( n = 0; n < width; ++n ) {
		BitClr(bp, (UW)n);
	}
}
Exemple #2
0
void InicializaDisplays(void)
{
	//configuração dos pinos de controle
	BitClr(TRISA,2);
	BitClr(TRISA,5);
	BitClr(TRISE,0);
	BitClr(TRISE,2);
	ADCON1 = 0x0E; //apenas AN0 é analogico, a referencia é baseada na fonte
	TRISD = 0x00;	//Porta de dados

}
Exemple #3
0
void InicializaPWM(void)
{
    BitClr(TRISC,2);//configura os pinos correspondentes como sa�das
    BitClr(TRISC,3);

    T2CON |= 0b00000011; //configura o prescale do timer 2 para 1:16
    BitSet(T2CON,2); //Liga o timer 2
    
    
    CCP1CON |= 0b00001100;    //configura CCP1 como um PWM
    CCP2CON |= 0b00001100;    //configura CCP2 como um PWM
}
Exemple #4
0
//--------------------------------------------------------------------------------//
void LCD_NYB(unsigned char nyb,unsigned char type){
    //SEND DATA LINE THE INFO 
    LCD_PORT->BSRRH |= 0x0F;
    LCD_PORT->BSRRL |= (nyb & 0x0F);

    if(type == CMD){
        BitClr(LCD_RS);             //COMMAND MODE
    } else {
        BitSet(LCD_RS);             //CHARACTER/DATA MODE
    }

    BitSet(LCD_E);         //ENABLE LCD DATA LINE
    DelayMS(1);                 //SMALL DELAY
    BitClr(LCD_E);         //DISABLE LCD DATA LINE
}
void RFM70_CE(uint8_t state)
{
    if(state==0)
        BitClr(PORTD,(1<<PD4));
    else
        BitSet(PORTD,(1<<PD4));
}
void InicializaTeclado(void)
{
    TRISB = 0xF0;    //quatro entradas e quatro saidas
    BitClr(INTCON2,7); //liga pull up
    ADCON1 = 0b00001110; //apenas AN0 � analogico, a referencia � baseada na fonte
    SPPCFG = 0x00;
}
void RFM70_MOSI(uint8_t state)
{
    if(state==0)
        BitClr(PORTB,(1<<PB3));
    else
        BitSet(PORTB,(1<<PB3));
}
void RFM70_SCK(uint8_t state)
{
    if(state==0)
        BitClr(PORTB,(1<<PB5));
    else
        BitSet(PORTB,(1<<PB5));
}
void SW_timer_handler()
{
    char buffer[20];
    uint8_t timnum;
    for(timnum=0;timnum<SWTIMERNUM;timnum++)
    {
        if(BitTst(SWtimerFlags,BitMsk(timnum)))
        {
            switch (timnum)
            {
                case 0 :
                    LED_action(LED1,TOGGLE);
                    break;
                case 1 :
                    therm_read_temperature(buffer);
                    debug_send(buffer);
                    break;
                case 2 :
                    LED_action(LED2,TOGGLE);
                    break;
                case 3 :
                   LED_action(LED3,TOGGLE);
                    break;
            }

            BitClr(SWtimerFlags,BitMsk(timnum));
        }
    }
    go_to_sleep();
}
Exemple #10
0
void InicializaSerial(void)
{
	TXSTA = 0b00101100;	//configura a transmissão de dados da serial
	RCSTA = 0b10010000;	//configura a recepção de dados da serial
	BAUDCON = 0b00001000;	//configura sistema de velocidade da serial
	SPBRGH = 0b00000000;	//configura para 56k
	SPBRG = 0b00100010;	//configura para 56k
	BitSet(TRISC,6);	//pino de recepção de dados
	BitClr(TRISC,7);	//pino de envio de dados
}
Exemple #11
0
void DebounceTeclas(void)
{
	unsigned char i,j;
	static unsigned char tempo;
	static unsigned int valorNovo = 0x0000;
	static unsigned int valorAntigo = 0x0000;

	for(i = 0; i < 4; i++)
	{
		//desliga todas as colunas
		PORTB |= 0x0F;
		BitClr(PORTB,i);	//liga a coluna correspondente
		//gasta tempo atoa, necess�rio para garantir que o pino atingiu o nivel alto
		for(j=0;j<100;j++);

		//realiza o teste para cada bit e atualiza a vari�vel
		for(j = 0; j < 4; j++)
		{
			if (!BitTst(PORTB,j+4))
			{
				BitSet(valorNovo,(i*4)+j);
			}
			else
			{
				BitClr(valorNovo,(i*4)+j);
			}
		}
	}
	if (valorAntigo == valorNovo)
	{
		tempo --;
	}
	else
	{
		tempo = 10;
		valorAntigo = valorNovo;
	}
	if (tempo == 0)
	{
		valor = valorAntigo;
	}
}
Exemple #12
0
static void mefreemenuid (short id) {
	
	register hdlmenubarlist hlist = menubarlist;
	
	#ifdef WIN95VERSION
		id /= 100;
	#endif

	if ((hlist != nil) && (id > 0))
		BitClr ((**hlist).menubitmap, id - (**hlist).basemenuid);
	} /*mefreemenuid*/
Exemple #13
0
void LCD_Init(void){
    //Setai pini pt LCD
    LCD_PORT->MODER = 0x5055;     //Setaea pinilo pentu output PD0:PD3(DB4:DB7),PD6(E),PD7(RS)
    LCD_PORT->OTYPER = 0x00;      //Setae de tip PUSH-PULL pentu toti
    LCD_PORT->OSPEEDR = 0xA0AA;   //50 MHz Fecventa potului pentu LCD
    LCD_PORT->PUPDR = 0x00;       //PULL-UP/PULL-DOWN Dezactivate

    BitClr(LCD_E);                //clear enable - pin PD6
    BitClr(LCD_RS);               //going to write command - pin PD7

    DelayMS(30);                //delay for LCD to initialise.
    LCD_NYB(0x30,0);              //Required for initialisation
    DelayMS(5);                 //required delay
    LCD_NYB(0x30,0);              //Required for initialisation
    DelayMS(1);                 //required delay
    LCD_DATA(0x02,0);           //set to 4 bit interface, 1 line and 5*7 font
    LCD_DATA(0x28,0);           //set to 4 bit interface, 2 line and 5*10 font
    LCD_DATA(0x0c,0);           //set to 4 bit interface, 2 line and 5*7 font
    LCD_DATA(0x01,0);           //clear display
    LCD_DATA(0x06,0);           //move cursor right after write

}
Exemple #14
0
//--------------------------------------------------------------------------------//
void LCD_DATA(unsigned char data,unsigned char type){
    
    WaitLCDBusy();                  //TEST LCD FOR BUSY 

    if(type == CMD){
        BitClr(LCD_RS);             //COMMAND MODE
    } else {
        BitSet(LCD_RS);             //CHARACTER/DATA MODE
    }

    LCD_NYB(data>>4,type);               //WRITE THE UPPER NIBBLE
    LCD_NYB(data,type);                  //WRITE THE LOWER NIBBLE
}
Exemple #15
0
int bitmanip(int word)
{
printf("fresh %d\n",word);
      word = BitSet(word, 2);
printf("set 2 %d\n",word);
      word = BitSet(word, 7);
printf("set 7 %d\n",word);
      word = BitClr(word, 3);
printf("clr 3 %d\n",word);
      word = BitFlp(word, 9);
printf("flip 9 %d\n",word);
      return word;
}
void SetObjectGrouped (ObjectRecHdl thisObjectHdl, Boolean bGroupedFlag)
{
	short	objectFlags;

	objectFlags = (**thisObjectHdl).objectFlags;
	if (bGroupedFlag)
		BitSet (&objectFlags, kGroupedMask);
	else
		BitClr (&objectFlags, kGroupedMask);
	(**thisObjectHdl).objectFlags = objectFlags;	

	return;
}
void SetObjectMarked (ObjectRecHdl ObjectHdl, Boolean MarkedFlag)
{
	short	objectFlags;

	objectFlags = (**ObjectHdl).objectFlags;
	if (MarkedFlag)
		BitSet (&objectFlags, kMarkedMask);
	else
		BitClr (&objectFlags, kMarkedMask);
	(**ObjectHdl).objectFlags = objectFlags;	

	return;
}
void SetObjectUndone (ObjectRecHdl ObjectHdl, Boolean bUndoFlag)
{
	short	objectFlags;
	
	objectFlags = (**ObjectHdl).objectFlags;
	if (bUndoFlag)
		BitSet (&objectFlags, kUndoMask);
	else
		BitClr (&objectFlags, kUndoMask);
	(**ObjectHdl).objectFlags = objectFlags;	

	return;
}
void SetOSymbolVisible (ObjectRecHdl ObjectHdl, Boolean SymVisFlag)
{
	short	objectFlags;

	objectFlags = (**ObjectHdl).objectFlags;
	if (SymVisFlag)
		BitSet (&objectFlags, kSymbolVisMask);
	else
		BitClr (&objectFlags, kSymbolVisMask);
	(**ObjectHdl).objectFlags = objectFlags;	

	return;
}