Example #1
0
void Observer::Initialize()
{
	if (mOurSide == '?'){
		PRINT_ERROR("my side unknown, can not initialize");
		return;
	}

	/* if true, multiply all coords by -1 inside initialize */
	bool rotate = (mOurSide == 'l') ? false : true;

	InitializeFlags(rotate);
	InitializePlayers();
}
void cScsiPassThrough::InitializePassThroughDirect(const StorageUtility::Scsi::sCommandCharacteristics& CommandCharacteristics, const StorageUtility::Scsi::uCdb& CdbRegister, std::shared_ptr<IBuffer> DataBuffer, U32 TimeoutValueInSeconds)
{
    //! TODO: Set up for Sense Data

    m_ScsiPassThrough.interface_id       = static_cast<U32>(eSgScsi::SgInterfaceId);
    m_ScsiPassThrough.mx_sb_len          = static_cast<U8>(eSgScsi::MaxSenseDataLength);
    m_ScsiPassThrough.dxfer_len          = CommandCharacteristics.DataTransferLengthInBytes;
    m_ScsiPassThrough.timeout            = TimeoutValueInSeconds;

    switch (CommandCharacteristics.FieldFormatting)
    {
    case StorageUtility::Scsi::eFieldFormatting::COMMAND_6:
    {
        m_ScsiPassThrough.cmd_len = 6;
    } break;

    case StorageUtility::Scsi::eFieldFormatting::COMMAND_10:
    {
        m_ScsiPassThrough.cmd_len = 10;
     } break;

    case StorageUtility::Scsi::eFieldFormatting::COMMAND_12:
    {
        m_ScsiPassThrough.cmd_len = 12;
    } break;

    case StorageUtility::Scsi::eFieldFormatting::COMMAND_16:
    case StorageUtility::Scsi::eFieldFormatting::ATAPASSTHROUGH_16:
    {
        m_ScsiPassThrough.cmd_len = 16;
    } break;

    default:
    {
        // Do nothing
    } break;
    }

    if (nullptr != DataBuffer)
    {
        m_ScsiPassThrough.dxferp = DataBuffer->ToDataBuffer();
    }

    m_ScsiPassThrough.cmdp = new U8[static_cast<U32>(eSgScsi::SgCommandDescBlockLengh)];
    memset(m_ScsiPassThrough.cmdp, 0, static_cast<U32>(eSgScsi::SgCommandDescBlockLengh) * sizeof(*m_ScsiPassThrough.cmdp)); // Set value of elements of Cdb to 0

    InitializeFlags(CommandCharacteristics);
    InitializeCdbRegister(CdbRegister);
}
    void cAtaPassThrough::InitializePassThroughDirect( const StorageUtility::Ata::sCommandCharacteristic& CommandCharacteristics, const StorageUtility::Ata::uTaskFileRegister& PreviousTaskFile, const StorageUtility::Ata::uTaskFileRegister& CurrentTaskFile, std::shared_ptr<cBufferInterface> DataBuffer, U32 TimeoutValueInSeconds )
    {
        m_AtaPassThrough.Length = sizeof( ATA_PASS_THROUGH_DIRECT );
        m_AtaPassThrough.DataTransferLength = CommandCharacteristics.DataTransferLengthInBytes;
        m_AtaPassThrough.TimeOutValue = TimeoutValueInSeconds;
        if (nullptr != DataBuffer)
        {
            m_AtaPassThrough.DataBuffer = DataBuffer->ToDataBuffer();
        }
        m_AtaPassThrough.ReservedAsUchar = 0;
        m_AtaPassThrough.ReservedAsUlong = 0;

        InitializeFlags( CommandCharacteristics );
        InitializeTaskFileInputRegisters( PreviousTaskFile, CurrentTaskFile );
    }
Example #4
0
int main(void)
{
  void *tmp;
  #if ZOTTAOS_TIMER == EVENT_TIMER_INDEX
     #error Event timer device must be different from the internal timer used by ZottaOS
  #endif
  // Enable debug module clock
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_DBGMCU,ENABLE);
  /* Stop ZottaOS internal timer during debugger connection */
  #if ZOTTAOS_TIMER == OS_IO_TIM17
     DBGMCU_APB2PeriphConfig(DBGMCU_TIM17_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM16
     DBGMCU_APB2PeriphConfig(DBGMCU_TIM16_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM15
     DBGMCU_APB2PeriphConfig(DBGMCU_TIM15_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM14
     DBGMCU_APB1PeriphConfig(DBGMCU_TIM14_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM3
     DBGMCU_APB1PeriphConfig(DBGMCU_TIM3_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM2
     DBGMCU_APB1PeriphConfig(DBGMCU_TIM2_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM1
     DBGMCU_APB2PeriphConfig(DBGMCU_TIM1_STOP,ENABLE);
  #endif
/* Initialize Hardware */
  SystemInit();
  InitializeFlags(FLAG1_PIN | FLAG2_PIN);
  OSInitTimerEvent(2,47,0,EVENT_TIMER_INDEX);
  #if defined(ZOTTAOS_VERSION_HARD)
     tmp = OSCreateEventDescriptor();
     OSCreateSynchronousTask(ClearLed1Task,1000,tmp,NULL);
     OSCreateTask(SetLed1Task,0,5000,5000,tmp);
     tmp = OSCreateEventDescriptor();
     OSCreateSynchronousTask(ClearLed2Task,1000,tmp,NULL);
     OSCreateTask(SetLed2Task,0,10000,10000,tmp);
  #elif defined(ZOTTAOS_VERSION_SOFT)
     tmp = OSCreateEventDescriptor();
     OSCreateSynchronousTask(ClearLed1Task,0,1000,0,tmp,NULL);
     OSCreateTask(SetLed1Task,0,0,5000,5000,1,1,0,tmp);
     tmp = OSCreateEventDescriptor();
     OSCreateSynchronousTask(ClearLed2Task,0,1000,0,tmp,NULL);
     OSCreateTask(SetLed2Task,0,0,10000,10000,1,1,0,tmp);
  #endif
  /* Start the OS so that it starts scheduling the user tasks */
  return OSStartMultitasking(NULL,NULL);
} /* end of main */
Example #5
0
int main(void)
{
  TaskParametersDef *TaskParameters;
  // Enable debug module clock
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_DBGMCU, ENABLE);
  /* Stop timer during debugger connection */
  #if ZOTTAOS_TIMER == OS_IO_TIM17
     DBGMCU_APB2PeriphConfig(DBGMCU_TIM17_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM16
     DBGMCU_APB2PeriphConfig(DBGMCU_TIM16_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM15
     DBGMCU_APB2PeriphConfig(DBGMCU_TIM15_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM14
     DBGMCU_APB1PeriphConfig(DBGMCU_TIM14_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM3
     DBGMCU_APB1PeriphConfig(DBGMCU_TIM3_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM2
     DBGMCU_APB1PeriphConfig(DBGMCU_TIM2_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM1
     DBGMCU_APB2PeriphConfig(DBGMCU_TIM1_STOP,ENABLE);
  #endif
  /* Initialize Hardware */
  SystemInit();
  InitializeFlags(FLAG1_PIN | FLAG2_PIN | FLAG3_PIN);
  /* Create the 3 tasks. Notice that each particular task receives a private set of para-
  ** meters that it inherits from the main program and that it is the only task that can
  ** later access. */
  #if defined(ZOTTAOS_VERSION_HARD)
     /* Calculation of the total load:
     ** 1250  / 5000  -> 25%
     ** 2500  / 10000 -> 25%
     ** 12000 / 30000 -> 40%
     ** Total:           90% */
     TaskParameters = (TaskParametersDef *)OSMalloc(sizeof(TaskParametersDef));
     TaskParameters->GPIOx = FLAG_PORT;
     TaskParameters->GPIO_Pin = FLAG1_PIN;
     TaskParameters->Delay = 350;
     OSCreateTask(FixedDelayTask,0,500,500,TaskParameters);
     TaskParameters = (TaskParametersDef *)OSMalloc(sizeof(TaskParametersDef));
     TaskParameters->GPIOx = FLAG_PORT;
     TaskParameters->GPIO_Pin = FLAG2_PIN;
     TaskParameters->Delay = 700;
     OSCreateTask(FixedDelayTask,0,1000,1000,TaskParameters);
     TaskParameters = (TaskParametersDef *)OSMalloc(sizeof(TaskParametersDef));
     TaskParameters->GPIOx = FLAG_PORT;
     TaskParameters->GPIO_Pin = FLAG3_PIN;
     TaskParameters->Delay = 3000;
     OSCreateTask(VariableDelayTask,0,3000,3000,TaskParameters);
  #elif defined(ZOTTAOS_VERSION_SOFT)
     /* Calculation of the total load:
     ** Without ZottaOS-Soft capabilities:
     **    1250  / 5000  ->  25%
     **    2500  / 10000 ->  25%
     **    24000 / 30000 ->  80%
     **    Total:           130% (Task set is NOT schedulable)
     ** With ZottaOS-Soft capabilities:
     **    1250  / 5000  / 3 ->   8%
     **    2500  / 10000 / 3 ->   8%
     **    24000 / 30000 / 1 ->  80%
     **    Total:                96% (Task set is schedulable) */
     TaskParameters = (TaskParametersDef *)OSMalloc(sizeof(TaskParametersDef));
     TaskParameters->GPIOx = FLAG_PORT;
     TaskParameters->GPIO_Pin = FLAG1_PIN;
     TaskParameters->Delay = 300;
     OSCreateTask(FixedDelayTask,125,0,500,500,1,2,0,TaskParameters);
     TaskParameters = (TaskParametersDef *)OSMalloc(sizeof(TaskParametersDef));
     TaskParameters->GPIOx = FLAG_PORT;
     TaskParameters->GPIO_Pin = FLAG2_PIN;
     TaskParameters->Delay = 600;
     OSCreateTask(FixedDelayTask,250,0,1000,1000,1,3,0,TaskParameters);
     TaskParameters = (TaskParametersDef *)OSMalloc(sizeof(TaskParametersDef));
     TaskParameters->GPIOx = FLAG_PORT;
     TaskParameters->GPIO_Pin = FLAG3_PIN;
     TaskParameters->Delay = 5000;
     OSCreateTask(VariableDelayTask,2400,0,3000,3000,1,1,0,TaskParameters);
  #endif
  /* Start the OS so that it starts scheduling the user tasks */
  return OSStartMultitasking(NULL,NULL);
} /* end of main */
Example #6
0
int main(void)
{
  TaskParametersDef *TaskParameters;
  /* Stop timer during debugger connection */
  #if ZOTTAOS_TIMER == OS_IO_TIM17
     DBGMCU_Config(DBGMCU_TIM17_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM16
     DBGMCU_Config(DBGMCU_TIM16_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM15
     DBGMCU_Config(DBGMCU_TIM15_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM14
     DBGMCU_Config(DBGMCU_TIM14_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM13
     DBGMCU_Config(DBGMCU_TIM13_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM12
     DBGMCU_Config(DBGMCU_TIM12_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM11
     DBGMCU_Config(DBGMCU_TIM11_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM10
     DBGMCU_Config(DBGMCU_TIM10_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM9
     DBGMCU_Config(DBGMCU_TIM9_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM8
     DBGMCU_Config(DBGMCU_TIM8_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM5
     DBGMCU_Config(DBGMCU_TIM5_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM4
     DBGMCU_Config(DBGMCU_TIM4_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM3
     DBGMCU_Config(DBGMCU_TIM3_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM2
     DBGMCU_Config(DBGMCU_TIM2_STOP,ENABLE);
  #elif ZOTTAOS_TIMER == OS_IO_TIM1
     DBGMCU_Config(DBGMCU_TIM1_STOP,ENABLE);
  #endif
  /* Keep debugger connection during sleep mode */
  DBGMCU_Config(DBGMCU_SLEEP,ENABLE);
  /* Initialize Hardware */
  SystemInit();
  InitializeFlags(FLAG1_PIN | FLAG2_PIN | FLAG3_PIN);
  /* Create the 3 tasks. Notice that each particular task receives a private set of para-
  ** meters that it inherits from the main program and that it is the only task that can
  ** later access. */
  #if defined(ZOTTAOS_VERSION_HARD)
     TaskParameters = (TaskParametersDef *)OSMalloc(sizeof(TaskParametersDef));
     TaskParameters->GPIOx = FLAG_PORT;
     TaskParameters->GPIO_Pin = FLAG1_PIN;
     TaskParameters->Delay = 150;
     OSCreateTask(FixedDelayTask,0,700,699,TaskParameters);
     TaskParameters = (TaskParametersDef *)OSMalloc(sizeof(TaskParametersDef));
     TaskParameters->GPIOx = FLAG_PORT;
     TaskParameters->GPIO_Pin = FLAG2_PIN;
     TaskParameters->Delay = 150;
     OSCreateTask(FixedDelayTask,0,700,700,TaskParameters);
     TaskParameters = (TaskParametersDef *)OSMalloc(sizeof(TaskParametersDef));
     TaskParameters->GPIOx = FLAG_PORT;
     TaskParameters->GPIO_Pin = FLAG3_PIN;
     TaskParameters->Delay = 7000;
     OSCreateTask(VariableDelayTask,0,2100,2100,TaskParameters);
  #elif defined(ZOTTAOS_VERSION_SOFT)
     TaskParameters = (TaskParametersDef *)OSMalloc(sizeof(TaskParametersDef));
     TaskParameters->GPIOx = FLAG_PORT;
     TaskParameters->GPIO_Pin = FLAG1_PIN;
     TaskParameters->Delay = 600;
     OSCreateTask(FixedDelayTask,200,0,700,250,1,3,0,TaskParameters);
     TaskParameters = (TaskParametersDef *)OSMalloc(sizeof(TaskParametersDef));
     TaskParameters->GPIOx = FLAG_PORT;
     TaskParameters->GPIO_Pin = FLAG2_PIN;
     TaskParameters->Delay = 600;
     OSCreateTask(FixedDelayTask,200,0,700,700,1,3,0,TaskParameters);
     TaskParameters = (TaskParametersDef *)OSMalloc(sizeof(TaskParametersDef));
     TaskParameters->GPIOx = FLAG_PORT;
     TaskParameters->GPIO_Pin = FLAG3_PIN;
     TaskParameters->Delay = 7000;
     OSCreateTask(VariableDelayTask,1600,0,2100,2100,1,1,0,TaskParameters);
  #endif
  /* Start the OS so that it starts scheduling the user tasks */
  return OSStartMultitasking();
} /* end of main */