Esempio n. 1
0
int Io_Start( int index, bool lock )
{
  if ( index < 0 || index > IO_PIN_COUNT )
    return CONTROLLER_ERROR_ILLEGAL_INDEX;
  IoPin* p = &Io.pins[ index ];
  // If it's not locked at all and 
  //    either no lock is requested or no a lock is requested but no other are using the io and
  //    there are not a huge number of users
  if ( !p->lock && ( !lock || ( lock && p->users == 0 ) ) && ( p->users < IO_USERS_MAX - 2 ) )
  {
    if ( Io.users == 0 )
      Io_Init();
   
    // Lock it up.
    Io.users++;
    p->users++;
    if ( lock )
      p->lock = true;

    // Output Pair 1
    // Switch to PIO
    // AT91C_BASE_PIOA->PIO_PER = AT91C_PIO_PA26;
    // AT91C_BASE_PIOB->PIO_PER = AT91C_PIO_PB23;
    
    return CONTROLLER_OK;
  }
  else
    return CONTROLLER_ERROR_TOO_MANY_USERS;
}
Esempio n. 2
0
File: bsp.c Progetto: xinmulan/RGB
void Bsp_Init(void)
{
   RCC_Configuration();
		/*********************************************************************************************/
    //
    GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE);
    //初始化LED灯
		 led_init_com();
		 led_init_io();
	
    //初始化串口
	   UART1_NVIC_Configuration();
     UART1_Configuration();
     UART1_GPIO_Configuration();
	
		 UART2_NVIC_Configuration();
     UART2_Configuration();
     UART2_GPIO_Configuration();
		 //清除标志位,否则第一位会丢失
		 USART_ClearFlag(USART1,USART_FLAG_TC);
		 USART_ClearFlag(USART2,USART_FLAG_TC);
	
		 //初始化输入输出接口
	   Io_Init();
		 
		 //初始化E13_TLL模块
		 /***
		 E13_Io_Init();

		 
		 //配置E13_TLL模块
		 if (E13_Configuration()==1)            //E13模块配置失效,闪烁发送和接受LED灯,进入死循环 
		 {
			 while(1)
			 {
			 Delay_Ms(25);
			 led_on_com_r();
				 led_on_com_t();
			 Delay_Ms(25);
				 led_off_r();
				 led_off_t();

			 }
		 }
		 *///////////////
		 led_on_in_3();                  //点亮IN3作为电源指示灯
		 
		 //初始化flash
		 data_error =Read_Flash(0x0801fc00);
		 communication_over_time =Read_Flash(0x0801f800);
		 communication_miss =Read_Flash(0x0801f400);
		 power_up=Read_Flash(0x0801f000);
		 //Write_Flash(0x0801fc00,0);
		 //Write_Flash(0x0801f800,0);
}
Esempio n. 3
0
int Io_StartBits( longlong bits, bool lock )
{
  IoPin* p = &Io.pins[ 0 ];
  int i = 0;
  int failure = -1;
  ullong mask = 1LL;
  for ( i = 0; i < 64; i++ )
  {
    if ( bits & mask )
    {
      if ( !p->lock && ( !lock || ( lock && p->users == 0 ) ) && p->users < IO_USERS_MAX - 2 )
      {
        if ( Io.users == 0 )
          Io_Init();
        if ( lock )
          p->lock = true;
        p->users++;
        Io.users++;
      }
      else
      {
        failure = i;
        break;
      }
    }
    mask <<= 1;
    p++;
  }

  if ( failure != -1 )
  {
    IoPin* p = &Io.pins[ 0 ];
    mask = 1LL;
    for ( i = 0; i < failure; i++ )
    {
      if ( bits & mask )
      {
        if ( lock )
          p->lock = false;
        p->users--;
        Io.users--;
        if ( Io.users == 0 )
          Io_Deinit();
      }
      mask <<= 1;
      p++;
    }
    return CONTROLLER_ERROR_CANT_LOCK;
  }

  return CONTROLLER_OK;
}
Esempio n. 4
0
/**Function*************************************************************

  Synopsis    [Starts all the packages.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Abc_FrameInit( Abc_Frame_t * pAbc )
{
    Cmd_Init( pAbc );
    Cmd_CommandExecute( pAbc, "set checkread" ); 
    Io_Init( pAbc );
    Abc_Init( pAbc );
    Fpga_Init( pAbc );
    Map_Init( pAbc );
    Mio_Init( pAbc );
    Super_Init( pAbc );
    Libs_Init( pAbc );
    Load_Init( pAbc );
    Scl_Init( pAbc );
    Test_Init( pAbc );
#ifdef USE_ABC2
    Abc2_Init( pAbc );
#endif
#ifdef USE_ABC85
    Abc85_Init( pAbc );
#endif
    EXT_ABC_INIT(pAbc) // plugin for external functionality
}