void change_speed (void) {
  if ((AT91F_PIO_GetInput(AT91C_BASE_PIOA) & SW1_MASK) == 0) {
    if (LEDSpeed > SPEED) LEDSpeed -= SPEED;
  }
  if ((AT91F_PIO_GetInput(AT91C_BASE_PIOA) & SW2_MASK) == 0) {
    if (LEDSpeed < MCK)   LEDSpeed += SPEED;
  }
}
Exemple #2
0
//*--------------------------------------------------------------------------------------
//* Function Name       : change_speed
//* Object              : Adjust "LedSpeed" value depending on SW1 and SW2 are pressed or not
//* Input Parameters    : none
//* Output Parameters   : Update of LedSpeed value.
//*--------------------------------------------------------------------------------------
static void change_speed ( void )
{//* Begin
    if ( (AT91F_PIO_GetInput(AT91C_BASE_PIOA) & SW1_MASK) == 0 )
    {
        if ( LedSpeed > SPEED ) LedSpeed -=SPEED ;
    }
    if ( (AT91F_PIO_GetInput(AT91C_BASE_PIOA) & SW2_MASK) == 0 )
    {
        if ( LedSpeed < MCK ) LedSpeed +=SPEED ;
    }
}//* End
Exemple #3
0
void change_speed(void) {
  if ( (AT91F_PIO_GetInput(AT91C_BASE_PIOA) & SW1_MASK) == 0 ) {
    if ( LedSpeed > SPEED ) {
      LedSpeed -= SPEED ;
    }
  }
  if ( (AT91F_PIO_GetInput(AT91C_BASE_PIOA) & SW3_MASK) == 0 ) {
    if ( LedSpeed < MCK ) {
      LedSpeed += SPEED ;
    }
  }
}
Exemple #4
0
////////////////////////////////////////////////////////////////////////////////
// Odebranie 8 bit�w danych z kamery
////////////////////////////////////////////////////////////////////////////////
inline char CamRead(void) {
	register char data = 0;

	data = (AT91F_PIO_GetInput(AT91C_BASE_PIOA) & (CAM_D2 | CAM_D3 | CAM_D4
			| CAM_D5 | CAM_D6 | CAM_D7)) >> 14;
	if (AT91F_PIO_GetInput(AT91C_BASE_PIOA) & CAM_D0) {
		data += 1;
	}
	if (AT91F_PIO_GetInput(AT91C_BASE_PIOA) & CAM_D1) {
		data += 2;
	}

	return data;
}
unsigned char recvBeacon( ob_data* block ) {
    unsigned long crc;
    unsigned char ret=0, status;

	ob_switchRXMode();
	if((AT91F_PIO_GetInput(AT91C_BASE_PIOA)&IRQ_PIN)==0)
	{
		portENTER_CRITICAL();
			status=nRFAPI_GetStatus();
			if(status&MASK_RX_DR_FLAG ) {

				ret=nRFAPI_RX((unsigned char*)block, sizeof(ob_data) );

				if(ret>0) {
					// CRC Check
					crc = env_crc16(block->payload, sizeof(block->payload) );
					if(block->crc == swapshort(crc)) {
						increment(ob_int_mgmt.rx_beacons, 4);
					} else {
						increment(ob_int_mgmt.fail_rx_beacons, 4);
						ret=0;
					}
				}
				nRFAPI_FlushRX();
			}

			nRFAPI_ClearIRQ(status);
		portEXIT_CRITICAL ();
	}
	return ret;
}
Exemple #6
0
////////////////////////////////////////////////////////////////////////////////
// Odebranie ramki obrazu z kamery // po optymalizacji //
// podzielnik = 2 -> klatka 320 x 200
// podzielnik = 4 -> klatka 160 x 100
////////////////////////////////////////////////////////////////////////////////
void GetFrame(register char PodzielnikX, register char PodzielnikY,
		char transmit) {
	register unsigned int x = 0, y = 0, wsk = 0;
	register char x2 = 0, y2 = 0, CamClockEnable = 0;

	// 1-sza klatka do odrzutu
	CamClockEnable = 1;
	AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, DIODA2);
	while (AT91F_PIO_GetInput(AT91C_BASE_PIOA) & VSYNC) {
		AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, MCLK);
		AT91F_PIO_SetOutput(AT91C_BASE_PIOA, MCLK);
	}

//	printf("-- Poza petla --\n\r");
	AT91F_PIO_SetOutput(AT91C_BASE_PIOA, DIODA2);
	CamClockEnable = 1;
	wsk = 0;

	register int pclkJump;

	register int enter = 0;
	// 2-ga klatka dobra
	AT91C_BASE_PIOA->PIO_CODR = DIODA1;
	while (CamClockEnable) {
		for (pclkJump = 0; pclkJump < PodzielnikX; pclkJump++) {
			AT91C_BASE_PIOA->PIO_CODR = MCLK;
			AT91C_BASE_PIOA->PIO_SODR = MCLK;
			//      AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, MCLK );
			//      AT91F_PIO_SetOutput( AT91C_BASE_PIOA, MCLK );
		}

		// VSYNC = 1 (podczas aktywnej czesci klatki)
		if (AT91C_BASE_PIOA->PIO_PDSR & VSYNC) {
			//      AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, DIODA1 );
			// HSYNC = 1 (podczas aktywnej czesci linii)
			if (AT91C_BASE_PIOA->PIO_PDSR & HSYNC) {
				enter = 1;
				if (PodzielnikX < 8) {
					if (x < (640. / PodzielnikX) && y < (400. / PodzielnikY)) {
						//            printf(".");
						x++;
						mem[wsk] = (AT91C_BASE_PIOA->PIO_PDSR & (CAM_D2
								| CAM_D3 | CAM_D4 | CAM_D5 | CAM_D6 | CAM_D7))
								>> 14;
						if (AT91C_BASE_PIOA->PIO_PDSR & CAM_D0) {
							mem[wsk] += 1;
						}
						if (AT91C_BASE_PIOA->PIO_PDSR & CAM_D1) {
							mem[wsk] += 2;
						}
						wsk++;
					} else if (y >= 400 / PodzielnikY)
						CamClockEnable = 0;
					if (CamClockEnable == 1) {
						CamClockEnable = 2;
					}

				} else {
					if (x < 1280 && y < 800) {
void nRFCMD_ISR_ACK_Handler(void)
{
    portBASE_TYPE xTaskWokenACK = pdFALSE;

    if( (AT91C_BASE_PIOA->PIO_ISR & IRQ_PIN) && ((AT91F_PIO_GetInput(AT91C_BASE_PIOA)&IRQ_PIN)==0) )
        xTaskWokenACK = xSemaphoreGiveFromISR( xnRF_SemaphoreACK, &xTaskWokenACK );

    AT91C_BASE_AIC->AIC_EOICR = 0;

    if(xTaskWokenACK)
	portYIELD_FROM_ISR();
}
Exemple #8
0
void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
{
	if( uxLED < ( portBASE_TYPE ) NB_LED )
	{
		if( AT91F_PIO_GetInput( AT91C_BASE_PIOB ) & ulLED_MASK[ uxLED ] )
		{
			AT91F_PIO_ClearOutput( AT91C_BASE_PIOB, ulLED_MASK[ uxLED ]);
		}
		else
		{
			AT91F_PIO_SetOutput( AT91C_BASE_PIOB, ulLED_MASK[ uxLED ] );					
		}
	}
}
Exemple #9
0
void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
{
	if( uxLED < ( portBASE_TYPE ) NB_LED )
	{
		if( AT91F_PIO_GetInput( AT91C_BASE_PIOA ) & led_mask[ uxLED ] )
		{
			AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, led_mask[ uxLED ]);
		}
		else
		{
			AT91F_PIO_SetOutput( AT91C_BASE_PIOA, led_mask[ uxLED ] );					
		}
	}
}
unsigned int GPIO_device_get(unsigned int port)
{
    unsigned int gpioStates = AT91F_PIO_GetInput(AT91C_BASE_PIOA);
    int value = 0;
    switch (port) {
    case 0:
        value = ((gpioStates & GPIO_1) != 0);
        break;
    case 1:
        value = ((gpioStates & GPIO_2) != 0);
        break;
    case 2:
        value = ((gpioStates & GPIO_3) != 0);
        break;
    default:
        break;
    }
    return value;
}
//*----------------------------------------------------------------------------
//* Function Name       : timer0_c_irq_handler
//* Object              : C handler interrupt function called by the interrupts
//*                       assembling routine
//* Output Parameters   : increment count_timer0_interrupt
//*----------------------------------------------------------------------------
void timer0_c_irq_handler(void)
{
	AT91PS_TC TC_pt = AT91C_BASE_TC0;
    unsigned int dummy;
    //* Acknowledge interrupt status
    dummy = TC_pt->TC_SR;
    //* Suppress warning variable "dummy" was set but never used
    dummy = dummy;
    count_timer0_interrupt++;
    //* Read the output state
    if ( (AT91F_PIO_GetInput(AT91C_BASE_PIOA) & LED3 ) == LED3 )
    {
        AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, LED3 );
    }
    else
    {
        AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED3 );
    }
}
unsigned char nRFLL_ReadWrite(unsigned char byte) 
{
    int bit;
    
    for(bit=0;bit<8;bit++)
    {
	if(byte & 0x80)
	    AT91F_PIO_SetOutput(AT91C_BASE_PIOA,MOSI_PIN);
	else
	    AT91F_PIO_ClearOutput(AT91C_BASE_PIOA,MOSI_PIN);
		
	AT91F_PIO_SetOutput(AT91C_BASE_PIOA,SCK_PIN);

	byte<<=1;
	if(AT91F_PIO_GetInput(AT91C_BASE_PIOA)&MISO_PIN)
	    byte|=1;
		    
	AT91F_PIO_ClearOutput(AT91C_BASE_PIOA,SCK_PIN);
    }	
    AT91F_PIO_ClearOutput(AT91C_BASE_PIOA,MOSI_PIN);
	
    return byte;
}
Exemple #13
0
int  sdpin_write_protect(void)
{
  return ( AT91F_PIO_GetInput(AT91C_BASE_PIOA) & SD_SOCKET_WP ) == SD_SOCKET_WP;
}
Exemple #14
0
int  sdpin_no_card(void)
{
  return ( AT91F_PIO_GetInput(AT91C_BASE_PIOA) & SD_SOCKET_INS ) == SD_SOCKET_INS;
}
static unsigned int GetGPIOBits(void)
{
    return AT91F_PIO_GetInput(AT91C_BASE_PIOA);
}
Exemple #16
0
static void
vCmdTask (void *pvParameters)
{
	(void) pvParameters;
	unsigned int t = 0;
	portCHAR cByte;
	portBASE_TYPE len = 0;
	static char next_command[MAX_CMD_LINE_LENGTH];

	for (;;)
	{
		if (vUSBRecvByte (&cByte, 1, 100))
		{
			vDebugSendHook (cByte);
			switch (cByte)
			{
				case '\n':
				case '\r':
					if (len)
					{
						next_command[len] = 0;
						vCmdProcess (next_command);
						len = 0;
					}
					break;
				default:
					next_command[len++] = cByte;
			}
		}
		else if (AT91F_PIO_GetInput (EXT_BUTTON_PIO) & EXT_BUTTON_PIN)
		{
			if (t < 30)
				t++;
			else
			{
				for (t = 0; t < 10; t++)
				{
					vTaskDelay (500 / portTICK_RATE_MS);
					led_set_red (0);
					vTaskDelay (500 / portTICK_RATE_MS);
					led_set_red (1);
				}

				/* backup reader id */
				t = env.e.reader_id;
				vNetworkResetDefaultSettings ();
				/* restore reader id */
				env.e.reader_id = t;

				/* store the configuration */
				env_store ();

				/* wait a bit before the reset */
				debug_printf ("restoring original settings"
							  " after reset pin triggerd & reboot...\n");
				vTaskDelay (1000 / portTICK_RATE_MS);

				/*force watchdog reset */
				while (1);
			}
		}
		else
			t = 0;
	}
}