Пример #1
0
/**************************************************************************************************
 * @fn          main
 *
 * @brief       Start of application.
 *
 * @param       none
 *
 * @return      none
 **************************************************************************************************
 */
int main(void)
{
  /* Initialize hardware */
   HAL_BOARD_INIT();

  // Initialize board I/O
  InitBoard( OB_COLD );

  /* Initialze the HAL driver */
  HalDriverInit();

  /* Initialize NV system */
  osal_snv_init();
  
  /* Initialize LL */

  /* Initialize the operating system */
  osal_init_system();

  /* Enable interrupts */
  HAL_ENABLE_INTERRUPTS();

  // Final board initialization
  InitBoard( OB_READY );

  #if defined ( POWER_SAVING )
    osal_pwrmgr_device( PWRMGR_BATTERY );
  #endif
    
  /* Start OSAL */
  osal_start_system(); // No Return from here

  return 0;
}
Пример #2
0
/**
 * @brief       Start of application.
 */
int main(void)
{
  /* Initialize hardware */
   HAL_BOARD_INIT();

  // Initialize board I/O
  InitBoard( OB_COLD );

  /* Initialze the HAL driver */
  HalDriverInit();

  /* Initialize NV system */
  osal_snv_init();

  /* Initialize LL */

  /* Initialize the operating system */
  osal_init_system();

  /* Enable interrupts */
  HAL_ENABLE_INTERRUPTS();

  // Final board initialization
  InitBoard( OB_READY );

  osal_pwrmgr_device( PWRMGR_ALWAYS_ON );
  
  HCI_EXT_ClkDivOnHaltCmd(HCI_EXT_DISABLE_CLK_DIVIDE_ON_HALT);

    
  /* Start OSAL */
  osal_start_system(); // No Return from here

  return 0;
}
/**************************************************************************************************
 * @fn          main
 *
 * @brief       Start of application.
 *
 * @param       none
 *
 * @return      none
 **************************************************************************************************
 */
int main(void)
{
  /* Initialize hardware */
  HAL_BOARD_INIT();

  // Initialize board I/O
  InitBoard( OB_COLD );

  /* Initialze the HAL driver */
  HalDriverInit();

  /* Initialize NV system */
  osal_snv_init();
  
  /* Initialize LL */

  /* Initialize the operating system */
  osal_init_system();

  /* Enable interrupts */
  HAL_ENABLE_INTERRUPTS();

  // Final board initialization
  InitBoard( OB_READY );

  #if defined ( POWER_SAVING )
    osal_pwrmgr_device( PWRMGR_BATTERY );
  #endif

#if 0
  P0DIR |= 0x32;
  P0_1 = 0;
  P0_4 = 0;
  P0_5 = 0;
#endif    

#if 0
  P1DIR |= 0x08;
  P1_3 = 0;
  
  P2DIR |= 0x01;
  P2_0 = 1;
#endif
  

//  E009_Init();
//  E009_ActivatePwrKey();
  
  //HalLedSet(HAL_LED1_G,HAL_LED_MODE_ON);
  /* Start OSAL */
  osal_start_system(); // No Return from here

  return 0;
}
Пример #4
0
//JFang, 任何8051单片机c程序, 都是由 main 函数开始的,
// 我们拿到一份代码,首先需要找到main函数
int main(void)
{
 /* Initialize hardware */
  HAL_BOARD_INIT();      //JFang,初始化时钟稳定时钟等等

  // Initialize board I/O
  //JFang, 冷启动,关闭了led灯与中断, 一边接下来的各种初始化不受干扰
  InitBoard( OB_COLD ); 

  /* Initialze the HAL driver */
  HalDriverInit();   //JFang, 各种驱动的初始化、如按键、lcd、adc、usb、uart等

  /* Initialize NV system */
  //JFang, snv 内部用于保存配对数据或你的用户自定义数据的一段flash,4kB空间
  osal_snv_init(); 

  /* Initialize LL */

  /* Initialize the operating system */
  //JFang, oasl 操作系统初始化, 包含内存分配、消息队列、定时器、电源管理和任务等
  osal_init_system(); 

  /* Enable interrupts */
  HAL_ENABLE_INTERRUPTS();//JFang, 开启全局中断

  // Final board initialization
  InitBoard( OB_READY );  //JFang,设置标志标示系统初始化完毕 

  #if defined ( POWER_SAVING )
  //JFang, 如果你使能了低功耗, 就启动低功耗模式,
    osal_pwrmgr_device( PWRMGR_BATTERY );
  #endif
/*
低功耗部分
1.如何总是在PM1
  osal_pwrmgr_device( PWRMGR_ALWAYS_ON );
2.如何进入PM2
  osal_pwrmgr_device( PWRMGR_BATTERY );在空闲的时候就会进入到PM2模式
3.如何进入PM3
  存在连接就断开连接,存在广播就停掉广播,并确认自己创建的所有定时任务都已关闭,
  则系统应该就会进入PM3模式,只能进行外部中断唤醒
*/

  /* Start OSAL */
  osal_start_system(); // No Return from here
/* osal 操作系统启动,实际上是一个大循环,只是检查相对应的标志位,
就指定相对应的任务,看到这里,同学们应该往哪里看呢?其实,这已经是尽头了?那么我们的应用程序是在哪里写的呢
其实是在上面的 上面的函数 osal_init_system 里就初始化了,现在回过头去看看
osal_init_system 这个函数内部就知道了
*/    
  return 0;
}
Пример #5
0
static int ibmlana_open(struct IBMLANA_NETDEV *dev)
{
	int result;
	ibmlana_priv *priv = (ibmlana_priv *) dev->priv;

	/* register resources - only necessary for IRQ */

	result =
	    request_irq(priv->realirq, irq_handler,
			SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
	if (result != 0) {
		printk("%s: failed to register irq %d\n", dev->name,
		       dev->irq);
		return result;
	}
	dev->irq = priv->realirq;

	/* set up the card and SONIC */

	InitBoard(dev);

	/* initialize operational flags */

#if (LINUX_VERSION_CODE >= 0x02032a)
	netif_start_queue(dev);
#else
	dev->interrupt = 0;
	dev->tbusy = 0;
	dev->start = 1;
	MOD_INC_USE_COUNT;
#endif

	return 0;
}
Пример #6
0
int main(void)
{
    // Get the actual board ID
    VUE32_ID id = GetBoardID();

    // Initialize the board (communication, timers, etc).
    InitBoard();

    // Specific VUE32 initialization
    InitVUE32(id);

    //Most of the functions in the while(1) loop are timed by Timer1
    while (1)
    {
        EVERY_X_MS(125)
           LED1 ^= 1;  //Toggle LED 4Hz
        END_OF_EVERY

        // Process network stack
        NETV_MESSAGE oMsgRecep;
	if(netv_transceiver((unsigned char)id, &oMsgRecep))
            OnMsgVUE32(&oMsgRecep);

        // Process state machine
        CallVUE32Impl(id);
    }

    return 0;
}
Пример #7
0
static void ibmlana_set_multicast_list(struct net_device *dev)
{
	/* first stop the SONIC... */
	StopSONIC(dev);
	/* ...then reinit it with the new flags */
	InitBoard(dev);
}
Пример #8
0
void CFT_ReadDlg::Init()
{
	theApp.m_pSharedMemory->Read_FTS_Flag = ENABLE;
	FTVarINIT();
	m_nTime = 0;
	InitBoard();
	UpdateData(FALSE);
}
Пример #9
0
/**
 * InitGame - 游戏初始化
 */
VOID CNoGo::InitGame()
{
	memset(StepNum, 0, sizeof(StepNum));
	player = BLACK;
	count = 0;
	CleanStack(stepStack);//清空着法栈
	InitBoard();//初始化棋盘
}
Пример #10
0
void InitBoards(
  struct TBoardList *ptBoardList)
/****************************************************************************/
/* Initialises _all_ statemachines on all boards.                           */
/****************************************************************************/
{
  while (ptBoardList != NULL)
  {
    if (ptBoardList->ptThis != NULL)
      InitBoard(ptBoardList->ptThis);
    ptBoardList = ptBoardList->ptNext;
  }
}
Пример #11
0
/**************************************************************************************************
 * @fn          main
 *
 * @brief       Start of application.
 *
 * @param       none
 *
 * @return      none
 **************************************************************************************************
 */
int main(void)
{
  /* Initialize hardware */
  HAL_BOARD_INIT();

  // Initialize board I/O
  InitBoard( OB_COLD );

  /* Initialze the HAL driver */
  HalDriverInit();

  /* Initialize NV system */
  osal_snv_init();

  /* Initialize the operating system */
  osal_init_system();

  /* Enable interrupts */
  HAL_ENABLE_INTERRUPTS();

  // Final board initialization
  InitBoard( OB_READY );
  
#if defined ( POWER_SAVING )
  osal_pwrmgr_device( PWRMGR_BATTERY );
#endif

#if (ALLOW_SELF_TEST == ENABLE)  
  #if !defined(FEATURE_OAD)
    /* Run power on self-test */
    sensorTag_test();
  #endif
#endif
  
  /* Start OSAL */
  osal_start_system(); // No Return from here
  
  return 0;
}
Пример #12
0
 /*******************************************
 * @fun     : main
 * @brief   : Start of application.
 *
 * @param   : none 
 *
 * @return  : none
 ******************************************/
int main(void)
{
  HAL_BOARD_INIT();         //硬件初始化
  
  InitBoard( OB_COLD );     //板级IO初始化
  
  HalDriverInit();          //HAL驱动初始化

  osal_snv_init();          //NV系统初始化

  osal_init_system();       //OSAL初始化

  HAL_ENABLE_INTERRUPTS();  //使能总中断

  InitBoard( OB_READY );    //板级初始化

  #if defined ( POWER_SAVING )
    osal_pwrmgr_device( PWRMGR_BATTERY );   //低功耗管理
  #endif

  osal_start_system(); // No Return from here   启动OSAL

  return 0;
}
Пример #13
0
/******************************************************************************
*  HandleWarp - handle player warping                                         *
******************************************************************************/
void
HandleWarp(MyProgram *data)
{
   if (data->score.warp > 0)
   {
      UpdateStatus( "Engaging warp drive", data );
      InitBoard( data );
      UpdateDisplay( data );
      PlacePlayerIcon( MAX_GRID_ROW/2, MAX_GRID_COL/2, ICON_SHIPU, data );
      AdjustValue( ICON_WARP, DECR_WARP, data );
   }
   else
   {
      UpdateStatus( "You don't have any warp cores!", data );
   }
}
Пример #14
0
int main(void)
{
    InitBoard();

    //Set ErrorStateFlag
    ErrorStateFlag = FALSE;
    
    m_state = InitPeripheral;
    //LED2 ^= 1;

    //Most of the functions in the while(1) loop are timed by Timer1
    while (1)
    {
        // Process state machine        
        ImplBMS();

        ClearWDT();
        //CallBMSImpl();        
        
        
        /*NETV_MESSAGE oMsgRecep;

        EVERY_X_MS(1000)
            
            oMsgRecep.msg_cmd = 0;
            oMsgRecep.msg_comm_iface =0xFF;
            oMsgRecep.msg_data_length = 0;
            oMsgRecep.msg_dest = 0xFF;
            oMsgRecep.msg_remote = 1;
            oMsgRecep.msg_source = GetMyAddr();
            oMsgRecep.msg_type = 0x80;
            oMsgRecep.msg_priority = 1;
            netv_send_message(&oMsgRecep );
            LED1 ^= 1;
        END_OF_EVERY


        if(netv_transceiver((unsigned char)GetBoardID(), &oMsgRecep))
        {
            //LED2 ^= 1;
            OnMsgBMS(&oMsgRecep);
        }*/
    }

    return 0;
}
Пример #15
0
/* Runs a breadth-first, queue-based algorithim to find minimum number of moves until the entire board has been 'covered'. 
*/
void RunTour(){
	Path path; 
	Queue<Path >queue;
	Grid<int> board= InitBoard();
	int iterations=NOT_VISITED;
	path.numMoves=NOT_VISITED;
	path.currX=STARTX;
	path.currY=STARTY;
	queue.enqueue(path);
	while (!queue.isEmpty()) {  
		path = queue.dequeue(); 
		if (path.numMoves>iterations){
			iterations=path.numMoves;
			PrintBoard (board, path);
		}
		EnqueueMoves(path, queue, board);
	}
}
Пример #16
0
/*****************************************************************************
  Function:
	bool IPSInitScratchMemory(uint8_t pSMem, uint32_t cbSMem)

  Description:
        Creates a heap to be used to get some scratch memory for use with sockets
        In particular it will set up memory for sockets, ipStacks and Page manager headers.
        You MUST use IPGetScratchMemorySize(cEstSockets) to get the size needed for this

  Parameters:
	pSMem:      A pointer to the memory to use
        cbSMem:     How many bytes the memory is; must use IPGetScratchMemorySize(cEstSockets)

  Returns:
        None

  ***************************************************************************/
bool IPSInit(uint8_t * pScratchMem, uint32_t cbScratchMem, uint32_t cEstSockets)
{
    uint32_t cbSocketHeap = IPSGetSocketHeapSize(cEstSockets);

    // somewhere in the C only stack we need to init the board
    // this may be the wrong place to do it.
#if !defined(MPIDE)
    static bool fCallBoardInit = true;
    if(fCallBoardInit)
    {
        InitBoard();
        fCallBoardInit = false;
    }
#endif

    if(pScratchMem != NULL)
    {
        if(g_hSocketHeap != NULL || cbSocketHeap > cbScratchMem)
        {
            return(false);
        }

        g_hSocketHeap = RRHPInit(pScratchMem, cbSocketHeap);

        if(g_hSocketHeap == NULL)
        {
            IPSClearSocketHeap();
            return(false);
        }
    }

    // we do not want to define a default socket memory
    else
    {
        IPSClearSocketHeap();
    }

    LLInitAdaptorList();
    UDPInitSockets();
    TCPInitSockets();

    return(true);
}
Пример #17
0
static int ibmlana_open(struct net_device *dev)
{
	int result;
	ibmlana_priv *priv = (ibmlana_priv *) dev->priv;

	/* register resources - only necessary for IRQ */

	result = request_irq(priv->realirq, irq_handler, SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
	if (result != 0) {
		printk(KERN_ERR "%s: failed to register irq %d\n", dev->name, dev->irq);
		return result;
	}
	dev->irq = priv->realirq;

	/* set up the card and SONIC */
	InitBoard(dev);

	/* initialize operational flags */
	netif_start_queue(dev);
	return 0;
}
Пример #18
0
int main(int argc, char *argv[])
{
  BOARD main_board;
  InitBoard(&main_board);
  ReadFEN(STARTPOS, &main_board);
  
  CONTROL engine_control;
  engine_control.stop = 1;
  
  ENGINE_STATE engine = {&main_board, &engine_control};
  
  if (AllocTable(&hash_table, 0.8*TABLESIZE) == 0) {
    printf("Not enough memory\n");
    return 1;
  }
  ClearHashTable(&hash_table);
  
  if (AllocPawnTable(&pawn_table, 0.2*TABLESIZE) == 0) {
    printf("Not enough memory\n");
    return 1;
  }
  ClearPawnTable(&pawn_table);
  
  setvbuf(stdin, 0, _IONBF, 0);
  setvbuf(stdout, 0, _IONBF, 0);
  fflush(NULL);
  char input[BUFFER];

  while (fgets(input, BUFFER, stdin)) {
    if (!Command(input, &engine)) {
      break;
    }  
    memset(input, 0, BUFFER);
  }
  
  DeleteTable(&hash_table);
  DeletePawnTable(&pawn_table);
  return 0;
}
Пример #19
0
//a simple constructor that takes a x and y size of a board and creates a 1d array,
//later on the 1d array is accessed using indexes calculated as if it were a 2d array.
//A winning arrangement is also calculated.
Board::Board(int X, int Y)
{

    sizeX = X;
    sizeY = Y;
    maxVal = (sizeX * sizeY);

    board = new int[maxVal];
    winningArrangement = new int[maxVal];

    //initialise the board
    InitBoard();
    emptyVal = maxVal - 1;
    Cursor.x = 0;
    Cursor.y = 0;

    //shuffle the board
    Shuffle();

    //create the empty square!
    InitEmptySquare();

}
Пример #20
0
void EthernetInit(void)
{
	// Initialize hardware
	InitBoard();

    // Initialize stack-related hardware components that may be 
    // required by the UART configuration routines
    TickInit();

    // Initialize Stack and application related NV variables into AppConfig.
    InitAppConfig();

	// Seed the LFSRRand() function.
	LFSRSeedRand(GenerateRandomDWORD());

	// Initialize the MAC library.
    MACInit();

	// Initialize the ARP library.
    ARPInit();

	// Initialize UDP.
    UDPInit();

	// Open up a socket for our UDP server.
	localServerSocket = UDPOpenEx(NULL, UDP_OPEN_SERVER, UDP_SERVER_PORT, UDP_SERVER_PORT);
	if (localServerSocket == INVALID_UDP_SOCKET) {
		FATAL_ERROR();
	}

	// Open up a socket for our UDP client.
	remoteServerSocket = UDPOpenEx(NULL, UDP_OPEN_IP_ADDRESS, UDP_CLIENT_PORT, UDP_CLIENT_PORT);
	if (remoteServerSocket == INVALID_UDP_SOCKET) {
		FATAL_ERROR();
	}
}
Пример #21
0
static int ibmlana_tx(struct sk_buff *skb, struct IBMLANA_NETDEV *dev)
{
	ibmlana_priv *priv = (ibmlana_priv *) dev->priv;
	int retval = 0, tmplen, addr;
	unsigned long flags;
	tda_t tda;
	int baddr;

	/* if we get called with a NULL descriptor, the Ethernet layer thinks 
	   our card is stuck an we should reset it.  We'll do this completely: */

	if (skb == NULL) {
		printk("%s: Resetting SONIC\n", dev->name);
		StopSONIC(dev);
		InitBoard(dev);
		return 0;	/* don't try to free the block here ;-) */
	}

	/* find out if there are free slots for a frame to transmit. If not,
	   the upper layer is in deep desperation and we simply ignore the frame. */

	if (priv->txusedcnt >= TXBUFCNT) {
		retval = -EIO;
		priv->stat.tx_dropped++;
		goto tx_done;
	}

	/* copy the frame data into the next free transmit buffer - fillup missing */

	tmplen = skb->len;
	if (tmplen < 60)
		tmplen = 60;
	baddr = priv->txbufstart + (priv->nexttxdescr * PKTSIZE);
	IBMLANA_TOIO(dev->mem_start + baddr, skb->data, skb->len);

	/* copy filler into RAM - in case we're filling up... 
	   we're filling a bit more than necessary, but that doesn't harm
	   since the buffer is far larger... 
	   Sorry Linus for the filler string but I couldn't resist ;-) */

	if (tmplen > skb->len) {
		char *fill = "NetBSD is a nice OS too! ";
		unsigned int destoffs = skb->len, l = strlen(fill);

		while (destoffs < tmplen) {
			IBMLANA_TOIO(dev->mem_start + baddr + destoffs,
				     fill, l);
			destoffs += l;
		}
	}

	/* set up the new frame descriptor */

	addr = priv->tdastart + (priv->nexttxdescr * sizeof(tda_t));
	IBMLANA_FROMIO(&tda, dev->mem_start + addr, sizeof(tda_t));
	tda.length = tda.fraglength = tmplen;
	IBMLANA_TOIO(dev->mem_start + addr, &tda, sizeof(tda_t));

	/* if there were no active descriptors, trigger the SONIC */

	save_flags(flags);
	cli();

	priv->txusedcnt++;
	priv->txused[priv->nexttxdescr] = 1;

	/* are all transmission slots used up ? */

	if (priv->txusedcnt >= TXBUFCNT)
#if (LINUX_VERSION_CODE >= 0x02032a)
		netif_stop_queue(dev);
#else
		dev->tbusy = 1;
#endif

	if (priv->txusedcnt == 1)
		StartTx(dev, priv->nexttxdescr);
	priv->nexttxdescr = (priv->nexttxdescr + 1) % TXBUFCNT;

	restore_flags(flags);

      tx_done:

	/* When did that change exactly ? */

#if (LINUX_VERSION_CODE >= 0x20200)
	dev_kfree_skb(skb);
#else
	dev_kfree_skb(skb, FREE_WRITE);
#endif
	return retval;
}
Пример #22
0
int
main(void) {
    /*Enable interrupts*/
    INTCON2bits.GIE = 1; //disabled by the bootloader, so we must absolutely enable this!!!
    asm("CLRWDT"); //clear watchdog timer

    for (torque = 0; torque < 65533; torque++) {
        Nop();
    }

    InitBoard(&ADCBuff, &uartBuffer, &spiBuffer, EventChecker);

    if (can_motor_init()) {
        while (1);
    }
    CB_Init(&uartBuffer, uartBuf, 32);
    CB_Init(&spiBuffer, (uint8_t *) spiBuf, 128);

    LED1 = 1;
    LED2 = 0;
    LED3 = 1;
    LED4 = 1;

#ifdef POSITION
    /* This is used for testing */
    //    	SetPosition(incPos);
#endif

#ifdef VELOCITY
    SetVelocity(0);
#endif
    while (1) {
        if (events & EVENT_UPDATE_SPEED) {
            PMSM_Update_Position();
            events &= ~EVENT_UPDATE_SPEED;
        }

        if (events & EVENT_CAN) {
            can_process();
//            LED2 = !LED2;

            if (txreq_bitarray & 0b00000001 && !C1TR01CONbits.TXREQ0) {
                C1TR01CONbits.TXREQ0 = 1;
                txreq_bitarray = txreq_bitarray & 0b11111110;
            }
            if (txreq_bitarray & 0b00000010 && !C1TR01CONbits.TXREQ1) {
                C1TR01CONbits.TXREQ1 = 1;
                txreq_bitarray = txreq_bitarray & 0b11111101;
            }
            if (txreq_bitarray & 0b00000100 && !C1TR23CONbits.TXREQ2) {
                C1TR23CONbits.TXREQ2 = 1;
                txreq_bitarray = txreq_bitarray & 0b11111011;
            }
            if (txreq_bitarray & 0b00001000 && !C1TR23CONbits.TXREQ3) {
                C1TR23CONbits.TXREQ3 = 1;
                txreq_bitarray = txreq_bitarray & 0b11110111;
            }
            if (txreq_bitarray & 0b00010000 && !C1TR45CONbits.TXREQ4) {
                C1TR45CONbits.TXREQ4 = 1;
                txreq_bitarray = txreq_bitarray & 0b11101111;
            }
            if (txreq_bitarray & 0b00100000 && !C1TR45CONbits.TXREQ5) {
                C1TR45CONbits.TXREQ5 = 1;
                txreq_bitarray = txreq_bitarray & 0b11011111;
            }
            if (txreq_bitarray & 0b01000000 && !C1TR67CONbits.TXREQ6) {
                C1TR67CONbits.TXREQ6 = 1;
                txreq_bitarray = txreq_bitarray & 0b10111111;
            }

            SetPosition(((float) CO(position_control_Commanded_Position)) * 109. / 1000.);
            CO(state_Current_Position) = CO(position_control_Commanded_Position);

            can_time_dispatch();
            events &= ~EVENT_CAN;
        }

        if (events & EVENT_UART_DATA_READY) {
            events &= ~EVENT_UART_DATA_READY;
        }

        if (events & EVENT_SPI_RX) {
            static uint8_t message[32];
            uint16_t size;
            uint8_t out[56];
            message[0] = 0xFF;
            message[1] = 0xFF;
            message[2] = 0xFF;
            message[3] = 0xFF;
            message[4] = 0xFF;
            message[5] = 0xFF;
            message[6] = 0xFF;
            message[7] = 0xFF;

            CB_ReadByte(&spiBuffer, &message[0]);
            CB_ReadByte(&spiBuffer, &message[1]);
            CB_ReadByte(&spiBuffer, &message[2]);
            CB_ReadByte(&spiBuffer, &message[3]);
            CB_ReadByte(&spiBuffer, &message[4]);
            CB_ReadByte(&spiBuffer, &message[5]);
            CB_ReadByte(&spiBuffer, &message[6]);
            CB_ReadByte(&spiBuffer, &message[7]);

            CB_Init(&spiBuffer, &spiBuf, 64);

            events &= ~EVENT_SPI_RX;
        }

        if (events & EVENT_REPORT_FAULT) {
            events &= ~EVENT_REPORT_FAULT;
        }
    }
}
Пример #23
0
int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);

 	// TODO: ここにコードを挿入してください。

	InitSystem();

	InitBoard();

	/* 学習用パラメータ */
	//sprintf_s(DIR_PATH, "学習データ\\%s", STAGE);
	//sprintf_s(TAIKYOKU_NAME, "学習データ\\eval_%s.dat", STAGE);
	//sprintf_s(TABLE_NAME, "学習データ\\%s\\eval_table_%s.dat", STAGE, STAGE);
	//sprintf_s(MSEOUT_PATH, "学習データ\\%s\\mse.out", STAGE);
	//sprintf_s(TRACE_PATH, "学習データ\\%s\\trace.out", STAGE);

	/* 
		FFO Endgame Suite(http://radagast.se/othello/ffotest.html) のベンチマーク結果
		普通にプレイする分には、ここをいじらないでください。
		ここのコメントアウトを適宜外せば、ベンチマークできます。
	*/

	AI_result = TRUE;  //ベンチマーク時は、このコメントアウトを外す
	ghash = NULL;
	/* 上:勝敗探索 下:石差探索 */
	//m_FlagSearchWin = TRUE;
	//m_FlagPerfectSearch = TRUE; //ベンチマーク時は、このコメントアウトを外す

	//環境:CPU AMD Phenom(tm)�U X6 1045T 2.70GHz (6コアCPU)

	//FFO#40(black to move) (WinLoss:(a2:WIN) 0.03sec Exact:(a2:+38) 1.32sec)
	/* 以下3行をコメントアウト */
	//black = 9158069842325798912;
	//white = 11047339776155165;
	//CpuColor = BLACK;

	//FFO#41(black to move) (WinLoss:(h4:DRAW) 3.46sec Exact:(h4:+0) 3.28sec)
	//black = 616174399789064;
	//white = 39493460025648416;
	//NowTurn = BLACK;

	//FFO#42(black to move) (WinLoss:(g2:WIN) 2.26sec Exact:(g2:+6) 3.88sec)
	//white = 9091853944868375556;
	//black = 22586176447709200;
	//NowTurn = BLACK;
	
	//FFO#43(white to move) (WinLoss:(c7:LOSS) 0.501sec Exact:(c7:-12) 8.06sec)
	//black = 38808086923902976;
	//white = 13546258740034592;
	//NowTurn = WHITE;

	//FFO#44(white to move) (WinLoss:(d2:LOSS) 0.729sec  Exact:(d2:-14) 2.09ec)
	//black = 2494790880993312;
	//white = 1010251075753548824;
	//NowTurn = WHITE;

	//FFO#45(black to move) (WinLoss:(b2:WIN) 2.37sec Exact:(b2:+6) 38.21sec)
	/*black = 282828816915486;
	white = 9287318235258944;
	NowTurn = BLACK;*/

	//FFO#46(black to move) (WinLoss:(b7:LOSS) 8.09sec Exact:(b3:-8) 15.63sec)
	//black = 4052165999611379712;
	//white = 36117299622447104;
	//NowTurn = BLACK;

	//FFO#47(white to move) (WinLoss:(g2:WIN) 2.87sec: Exact:(g2:+4) 4.70sec)
	//black = 277938752194568;
	//white = 3536224466208;
	//NowTurn = WHITE;

	//FFO#48(white to move) (WinLoss:(f6:WIN) 0.98sec: Exact:(f6:+28) 42.42sec)
	/*black = 38519958422848574;
	white = 4725679339520;
	NowTurn = WHITE;*/

	//FFO#49(black to move) (WinLoss:(e1:WIN) 4.52sec: Exact:(e1:+16) 95.10sec)
	//black = 5765976742297600;
	//white = 4253833575484;
	//NowTurn = BLACK;

	//FFO#50(black to move) (WinLoss:(d8:WIN) 2.861sec: Exact:(d8:+10) 141.83sec)
	//black = 4504145659822080;
	//white = 4336117619740130304;
	//NowTurn = BLACK;

	//FFO#51(white to move) (WinLoss:(e2:WIN) 2.92sec: Exact:(e2:+6) 137.96sec)
	//black = 349834415978528;
	//white = 8664011788383158280;
	//NowTurn = WHITE;

	//FFO#52(white to move) (WinLoss:(a3:DRAW) 140.0sec: Exact:(a3:+0) 110.58sec)
	//black = 9096176176681728056;
	//white = 35409824317440;
	//NowTurn = WHITE;



	//FFO#59(black to move) (WinLoss:(g8:WIN) 0.32sec: Exact:(g8:+64) 0.34sec)
	/*black = 17320879491911778304;
	white = 295223649004691488;
	NowTurn = BLACK;*/


				/* これ以降は一晩経っても終わらんので登録していない */
/*-----------------------------------------------------------------------------------*/


	//FFO#53(black to move) (WinLoss:(WIN) 8.79sec: Exact:(g2:+4) 22.5sec)
	//black = 2515768979493888;
	//white = 8949795312300457984;
	//NowTurn = BLACK;

	//FFO#54(black to move) (WinLoss:(WIN) 8.79sec: Exact:(g2:+4) 22.5sec)
	//black = 277938752194568;
	//white = 3536224466208;
	//NowTurn = BLACK;

	//FFO#55(white to move) (WinLoss:(WIN) 8.79sec: Exact:(g2:+4) 22.5sec)
	/*black = 4635799596172290;
	white = 289361502099486840;
	NowTurn = WHITE;
*/
	//FFO#56(white to move) (WinLoss:(WIN) 8.79sec: Exact:(g2:+4) 22.5sec)
	/*black = 4925086697193472;
	white = 9007372734053408;
	NowTurn = WHITE;*/

	//FFO#57(black to move) (WinLoss:(WIN) 8.79sec: Exact:(g2:+4) 22.5sec)
	//black = 9060166336512000;
	//white = 8943248156475301888;
	//NowTurn = BLACK;

	//FFO#58(black to move) (WinLoss:(WIN) 8.79sec: Exact:(g2:+4) 22.5sec)
	//black = 4636039783186432;
	//white = 3383245044333600;
	//NowTurn = BLACK;

	MSG msg;
	HACCEL hAccelTable;

	// グローバル文字列を初期化しています。
	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
	LoadString(hInstance, IDC_REVERSI, szWindowClass, MAX_LOADSTRING);
	MyRegisterClass(hInstance);

	// アプリケーションの初期化を実行します:
	if (!InitInstance (hInstance, nCmdShow))
	{
		return FALSE;
	}
	
	hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_REVERSI));

	// メイン メッセージ ループ:
	while (GetMessage(&msg, NULL, 0, 0))
	{
		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

	return (int) msg.wParam;
}
Пример #24
0
void CProfileGraph::Init()
{
	InitBoard();
	UpdateData(FALSE);
	SetTimer(1, DISP_TIMER, NULL);
}
Пример #25
0
Board::Board()
{
	InitBoard();
}
Пример #26
0
uint16 SensorTag_ProcessEvent(uint8 task_id, uint16 events)
{
	VOID	task_id;	// OSAL required parameter that isn't used in this function


	///////////////////////////////////////////////////////////////////////
	// system event handle                                               //
	///////////////////////////////////////////////////////////////////////
	if (events & SYS_EVENT_MSG) {
		uint8	*msg;

		if ((msg = osal_msg_receive(sensorTag_TaskID)) != NULL) {
			sensorTag_ProcessOSALMsg((osal_event_hdr_t *) msg);

			// release the OSAL message
			osal_msg_deallocate(msg);
		}

		// return unprocessed events
		return (events ^ SYS_EVENT_MSG);
	}


	///////////////////////////////////////////////////////////////////////
	// start device event                                                //
	///////////////////////////////////////////////////////////////////////
	if (events & EVT_START_DEVICE) {
		// start the device
		GAPRole_StartDevice(&sensorTag_PeripheralCBs);

		// start bond manager
#if !defined(GAPBONDMGR_NO_SUPPORT)
		GAPBondMgr_Register(&sensorTag_BondMgrCBs);
#endif
		// start peripheral device
		oled_init();
		adxl345_softrst();
//		adxl345_self_calibration();

		steps	     = 0;
		BATCD_PXIFG  = ~(BATCD_BV);
		BATCD_IEN   |=  BATCD_IENBIT;

		osal_start_reload_timer(sensorTag_TaskID, EVT_RTC, PERIOD_RTC);
		pwmgr_state_change(PWMGR_S0, 0);

		fmsg(("\033[40;32m\n[power on]\033[0m\n"));
		return (events ^ EVT_START_DEVICE);
	}


	///////////////////////////////////////////////////////////////////////
	// key long press handle                                             //
	///////////////////////////////////////////////////////////////////////
	if (events & EVT_MODE) {
		if (key1_press) {
			oled_clr_screen();
			if ((opmode & 0xF0) == MODE_NORMAL) {
				opmode        = MODE_WORKOUT | MODE_TIME;
				workout.steps = normal.steps;
				workout.time  = osal_getClock();
				fmsg(("\033[40;32m[workout mode]\033[0m\n"));
			} else {
				opmode        = MODE_NORMAL | MODE_TIME;
				fmsg(("\033[40;32m[normal mode]\033[0m\n"));
			}

			pwmgr_state_change(pwmgr, TIME_OLED_OFF);
		}
		return (events ^ EVT_MODE);
	}

	if (events & EVT_SLEEP) {
		if (key1_press) {
			oled_clr_screen();
			opmode = MODE_SLEEP;
			fmsg(("\033[40;32m[sleep mode]\033[0m\n"));

			pwmgr_state_change(pwmgr, TIME_OLED_OFF);
		}
		return (events ^ EVT_SLEEP);
	}

	if (events & EVT_SYSRST) {
		if (key1_press) {
			fmsg(("\033[40;32m[system reset]\033[0m\n"));
			HAL_SYSTEM_RESET();
//			adxl345_self_calibration();
		}
		return (events ^ EVT_SYSRST);
	}


	///////////////////////////////////////////////////////////////////////
	// display handle                                                    //
	///////////////////////////////////////////////////////////////////////
	if (events & EVT_DISP) {
		if (pwmgr == PWMGR_S1) {
			sensorTag_HandleDisp(opmode, acc);
		} else {
			// display battery only
			sensorTag_BattDisp(batt_get_level());
		}
		if (pwmgr != PWMGR_S6)  {
			osal_start_timerEx(sensorTag_TaskID, EVT_DISP, PERIOD_DISP);
		}
		return (events ^ EVT_DISP);
	}


	///////////////////////////////////////////////////////////////////////
	// g-sensor handle                                                   //
	///////////////////////////////////////////////////////////////////////
	if (events & EVT_GSNINT1) {
		adxl345_exit_sleep();
		pwmgr_state_change(PWMGR_S3, TIME_GSEN_OFF);
		return (events ^ EVT_GSNINT1);
	}

	if (events & EVT_GSNINT2) {
		unsigned char	sampling;
		unsigned char	i;

		sampling = adxl345_chk_fifo();
		for (i=0; i<sampling; i++) {
			adxl345_read(acc);
#if (DEBUG_MESSAGE & MSG_STEPS)
			{
				unsigned long	tmp = algo_step(acc);
				if (normal.steps != tmp) {
					stepmsg(("\033[1;33mstep=%0lu\n\033[0m", tmp));
				}
				normal.steps = tmp;
			}
#else
			normal.steps = algo_step(acc);
#endif
		}

		normal.distance  = calc_distance(normal.steps, pi.stride);
		workout.distance = calc_distance((normal.steps - workout.steps), pi.stride);
		normal.calorie   = calc_calorie(normal.distance, pi.weight);
		workout.calorie  = calc_calorie(workout.distance, pi.weight);
		return (events ^ EVT_GSNINT2);
	}

	if (events & EVT_GSENSOR) {
		adxl345_exit_sleep();
		return (events ^ EVT_GSENSOR);
	}


	///////////////////////////////////////////////////////////////////////
	// RTC handle                                                        //
	///////////////////////////////////////////////////////////////////////
	if (events & EVT_RTC) {
		// performed once per second


		// record data
		if ((pwmgr != PWMGR_S5) && (pwmgr != PWMGR_S6)) {
#if defined(HAL_IMAGE_A) || defined(HAL_IMAGE_B)
			if ((osal_getClock() - mark.time) >= (12UL*60UL)) {
#else
			if ((osal_getClock() - mark.time) >= (12UL)) {
#endif
				if (!hash_is_full()) {
					unsigned short	tmp = normal.steps - mark.steps;

					switch (opmode & 0xF0) {
					case MODE_WORKOUT: tmp |= 0x8000; break;
					case MODE_SLEEP:   tmp |= 0x4000; break;
					}
					hash_put(&tmp);
				}
				mark.time  = osal_getClock();
#if defined(HAL_IMAGE_A) || defined(HAL_IMAGE_B)
				if ((mark.time % (24UL*60UL*60UL)) <= (13UL*60UL)) {
#else
				if ((mark.time % (24UL*60UL*60UL)) <= (13UL)) {
#endif
					dmsg(("reset steps...\n"));
					normal.steps  = 0;
					workout.steps = 0;
					STEPS         = 0;
				}
				mark.steps = normal.steps;
			}
		}

		// power management
		switch (pwmgr) {
		case PWMGR_S0:
			pmsg(("\033[40;35mS0 (power on)\033[0m\n"));
			if (pwmgr_saving_timer()) {
				adxl345_enter_sleep();

				osal_pwrmgr_device(PWRMGR_BATTERY);
				pwmgr_state_change(PWMGR_S4, 0);
			}
			break;

		case PWMGR_S1:
			pmsg(("\033[40;35mS1 (rtc+gsen+ble+oled)\033[0m\n"));
			if (pwmgr_saving_timer()) {
				oled_enter_sleep();
				osal_stop_timerEx(sensorTag_TaskID, EVT_MODE);
				osal_stop_timerEx(sensorTag_TaskID, EVT_SLEEP);
				osal_stop_timerEx(sensorTag_TaskID, EVT_SYSRST);

				pwmgr_state_change(PWMGR_S3, TIME_GSEN_OFF);
			}
			break;

		case PWMGR_S2:
			pmsg(("\033[40;35mS2 (rtc+gsen+ble)\033[0m\n"));
			if (gapProfileState == GAPROLE_WAITING) {
				// enable key interrupt mode
				InitBoard(OB_READY);
				pwmgr_state_change(PWMGR_S3, TIME_GSEN_OFF);
			}
			break;

		case PWMGR_S3:
			pmsg(("\033[40;35mS3 (rtc+gsen)\033[0m\n"));
			if (steps == normal.steps) {
				if (pwmgr_saving_timer()) {
					adxl345_enter_sleep();
					pwmgr_state_change(PWMGR_S4, 0);
				}
			} else {
				steps = normal.steps;
				pwmgr_state_change(pwmgr, TIME_GSEN_OFF);
			}
			break;

		case PWMGR_S4:
			pmsg(("\033[40;35mS4 (rtc)\033[0m\n"));
			dmsg(("$"));
			break;

		default:
		case PWMGR_S5:
			pmsg(("\033[40;35mS5 (shutdown)\033[0m\n"));
			adxl345_shutdown();
			osal_stop_timerEx(sensorTag_TaskID, EVT_RTC);
			break;

		case PWMGR_S6:
			pmsg(("\033[40;35mS6 (rtc+oled)\033[0m\n"));
			if (pwmgr_saving_timer()) {
				oled_enter_sleep();

				// enable key interrupt mode
				InitBoard(OB_READY);
				pwmgr_state_change(PWMGR_S5, 0);
			}
			break;
		}

		// battery measure
		if ((!batt_measure()) && (pwmgr != PWMGR_S6)) {
			pwmgr_state_change(PWMGR_S5, 0);
		}
		return (events ^ EVT_RTC);
	}


	///////////////////////////////////////////////////////////////////////
	// battery charge detect handle                                      //
	///////////////////////////////////////////////////////////////////////
	if (events & EVT_CHARGING) {
		if (pwmgr != PWMGR_S1) {
			if (!BATCD_SBIT) {
				dmsg(("[charging]\n"));
				oled_exit_sleep();
				if ((pwmgr == PWMGR_S5) || (pwmgr == PWMGR_S6)) {
					osal_start_reload_timer(sensorTag_TaskID, EVT_RTC, PERIOD_RTC);
					pwmgr_state_change(PWMGR_S4, 0);
				}
			} else {
				dmsg(("[no charge]\n"));
				oled_enter_sleep();
			}
		}
		return (events ^ EVT_CHARGING);
	}


	///////////////////////////////////////////////////////////////////////
	// discard unknown events                                            //
	///////////////////////////////////////////////////////////////////////

	return 0;
}
Пример #27
0
Файл: main.c Проект: iamfil/wine
LRESULT WINAPI MainProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    HDC hdc;
    PAINTSTRUCT ps;
    HMENU hMenu;
    static BOARD board;

    switch( msg ) {
    case WM_CREATE:
        board.hInst = ((LPCREATESTRUCT) lParam)->hInstance;
        board.hWnd = hWnd;
        InitBoard( &board );
        CreateBoard( &board );
        return 0;

    case WM_PAINT:
      {
        HDC hMemDC;

        WINE_TRACE("WM_PAINT\n");
        hdc = BeginPaint( hWnd, &ps );
        hMemDC = CreateCompatibleDC( hdc );

        DrawBoard( hdc, hMemDC, &ps, &board );

        DeleteDC( hMemDC );
        EndPaint( hWnd, &ps );

        return 0;
      }

    case WM_MOVE:
        WINE_TRACE("WM_MOVE\n");
        board.pos.x = (short)LOWORD(lParam);
        board.pos.y = (short)HIWORD(lParam);
        return 0;

    case WM_DESTROY:
        SaveBoard( &board );
        DestroyBoard( &board );
        PostQuitMessage( 0 );
        return 0;

    case WM_TIMER:
        if( board.status == PLAYING ) {
            board.time++;
	    RedrawWindow( hWnd, &board.timer_rect, 0,
			  RDW_INVALIDATE | RDW_UPDATENOW );
        }
        return 0;

    case WM_LBUTTONDOWN:
        WINE_TRACE("WM_LBUTTONDOWN\n");
        if( wParam & MK_RBUTTON )
            msg = WM_MBUTTONDOWN;
        TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg );
        SetCapture( hWnd );
        return 0;

    case WM_LBUTTONUP:
        WINE_TRACE("WM_LBUTTONUP\n");
        if( wParam & MK_RBUTTON )
            msg = WM_MBUTTONUP;
        TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg );
        ReleaseCapture();
        return 0;

    case WM_RBUTTONDOWN:
        WINE_TRACE("WM_RBUTTONDOWN\n");
        if( wParam & MK_LBUTTON ) {
            board.press.x = 0;
            board.press.y = 0;
            msg = WM_MBUTTONDOWN;
        }
        TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg );
        return 0;

    case WM_RBUTTONUP:
        WINE_TRACE("WM_RBUTTONUP\n");
        if( wParam & MK_LBUTTON )
            msg = WM_MBUTTONUP;
        TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg );
        return 0;

    case WM_MBUTTONDOWN:
        WINE_TRACE("WM_MBUTTONDOWN\n");
        TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg );
        return 0;

    case WM_MBUTTONUP:
        WINE_TRACE("WM_MBUTTONUP\n");
        TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg );
        return 0;

    case WM_MOUSEMOVE:
    {
        if( wParam & MK_MBUTTON ) {
            msg = WM_MBUTTONDOWN;
        }
        else if( wParam & MK_LBUTTON ) {
            msg = WM_LBUTTONDOWN;
        }
        else {
            return 0;
        }

        TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam),  msg );

        return 0;
    }

    case WM_COMMAND:
        switch(LOWORD(wParam)) {
        case IDM_NEW:
            CreateBoard( &board );
            return 0;

        case IDM_MARKQ:
            hMenu = GetMenu( hWnd );
            board.IsMarkQ = !board.IsMarkQ;
            if( board.IsMarkQ )
                CheckMenuItem( hMenu, IDM_MARKQ, MF_CHECKED );
            else
                CheckMenuItem( hMenu, IDM_MARKQ, MF_UNCHECKED );
            return 0;

        case IDM_BEGINNER:
            SetDifficulty( &board, BEGINNER );
            CreateBoard( &board );
            return 0;

        case IDM_ADVANCED:
            SetDifficulty( &board, ADVANCED );
            CreateBoard( &board );
            return 0;

        case IDM_EXPERT:
            SetDifficulty( &board, EXPERT );
            CreateBoard( &board );
            return 0;

        case IDM_CUSTOM:
            SetDifficulty( &board, CUSTOM );
            CreateBoard( &board );
            return 0;

        case IDM_EXIT:
            SendMessage( hWnd, WM_CLOSE, 0, 0);
            return 0;

        case IDM_TIMES:
            DialogBoxParam( board.hInst, "DLG_TIMES", hWnd,
                    TimesDlgProc, (LPARAM) &board);
            return 0;

        case IDM_ABOUT:
        {
            WCHAR appname[256], other[256];
            LoadStringW( board.hInst, IDS_APPNAME, appname, sizeof(appname)/sizeof(WCHAR) );
            LoadStringW( board.hInst, IDS_ABOUT, other, sizeof(other)/sizeof(WCHAR) );
            ShellAboutW( hWnd, appname, other,
                         LoadImageA( board.hInst, "WINEMINE", IMAGE_ICON, 48, 48, LR_SHARED ));
            return 0;
        }
        default:
            WINE_TRACE("Unknown WM_COMMAND command message received\n");
            break;
        }
    }
    return( DefWindowProc( hWnd, msg, wParam, lParam ));
}
Пример #28
0
void CWalk00TestDlg::Init()
{
	unsigned char i;
	theApp.m_pSharedMemory->INT_Flag = FALSE;

	theApp.m_pSharedMemory->TestModeFlag = TRUE;

	theApp.m_pSharedMemory->Arm_Motion = TRUE;//FALSE;
	theApp.m_pSharedMemory->MotionFlagALL = 0;
	theApp.m_pSharedMemory->ZMP_DSP_CTRL_Flag = FALSE;

	theApp.m_pSharedMemory->ZMPSysIDFlag = FALSE;
	theApp.m_pSharedMemory->Walk_Ready_Flag = FALSE;
	theApp.m_pSharedMemory->Home_Flag = FALSE;
	theApp.m_pSharedMemory->Walk01Test_Flag = FALSE;

	theApp.m_pSharedMemory->DSP_Pose_Set_Flag = 0;

	theApp.m_pSharedMemory->DSP_Pose_Reset_Flag = FALSE;
	theApp.m_pSharedMemory->DSP_Pose_CTRL_On_Flag = FALSE;
	theApp.m_pSharedMemory->DSP_Pose_CTRL_Off_Flag = FALSE;

	theApp.m_pSharedMemory->SSP_Pose_Set_Flag = 0;

	theApp.m_pSharedMemory->SSP_Pose_Reset_Flag = FALSE;
	theApp.m_pSharedMemory->SSP_Pose_CTRL_On_Flag = FALSE;
	theApp.m_pSharedMemory->SSP_Pose_CTRL_Off_Flag = FALSE;

	theApp.m_pSharedMemory->SSP_OL_L_Pose_Flag = FALSE;
	theApp.m_pSharedMemory->SSP_OL_R_Pose_Flag = FALSE;
	
	theApp.m_pSharedMemory->SSP_Tick_Roll_Save_Flag = FALSE;
	theApp.m_pSharedMemory->SSP_Tick_Pitch_Save_Flag = FALSE;
	
	theApp.m_pSharedMemory->SSP_OL_Save_Flag = FALSE;

	m_DSP_Pose_Set.EnableWindow(TRUE);
	m_DSP_Pose_Reset.EnableWindow(FALSE);
	m_DSP_On.EnableWindow(FALSE);
	m_DSP_Off.EnableWindow(FALSE);

	m_SSP_On.EnableWindow(TRUE);
	m_SSP_Off.EnableWindow(FALSE);
	m_SSP_CTRL_On.EnableWindow(FALSE);
	m_SSP_CTRL_Off.EnableWindow(FALSE);

	m_ButtonOL_L_SSP.EnableWindow(TRUE);
	m_ButtonOL_R_SSP.EnableWindow(TRUE);

	m_DSP_During	= 160;
	m_SideAmplitude = 70;
	m_SwayAmplitude = 180;

	theApp.m_pSharedMemory->DSP_During = m_DSP_During;
	theApp.m_pSharedMemory->DSP_SideAmplitude = (float)(-1. * m_SideAmplitude);
	theApp.m_pSharedMemory->DSP_SwayAmplitude = (float)m_SwayAmplitude;

	m_Board_RFootX=0.;
	m_Board_LFootX=0.;

	m_HandFreq = (float)0.;
	m_HandAmp = (float)0.;
		
	m_Board_RFootY=-L0;
	m_Board_LFootY= L0;
	
	m_Board_RFootZ=-(L1+L2);
	m_Board_LFootZ=-(L1+L2);

	theApp.m_pSharedMemory->SSPCTRLOn = FALSE;
	theApp.m_pSharedMemory->SSPCTRLOff = FALSE;

	m_EDIT_OveralGLP = 0;//1.;
	m_EDIT_OveralGLR = 0;//1.;
	m_EDIT_OveralGRP = 0;//1.;
	m_EDIT_OveralGRR = 0;//1.;

	InitBoard();
	SetTimer(1, DISP_TIMER, NULL);
	////// Joint Lock Enable
	for(i=0;i<TOTAL_JMC_NUM;i++)
	{
		theApp.EnableHIP(i);
		Sleep(50);
		
		theApp.SendRunCMD(i);
		Sleep(50);
		
	}
	
	UpdateData(FALSE);

	theApp.m_pSharedMemory->INT_Flag = TRUE;

	theApp.m_pSharedMemory->PROFTime[11] = 0;
	theApp.m_pSharedMemory->DataSaveFlag = TRUE;
}
Пример #29
0
PRIVATE bool etherboardp()
{
  int i;

  /* initialise ethernet board */
  InitBoard();

  StartIndex = (UBYTE)8+TxPktNo;
  StopIndex  = (UBYTE)0x20+TxPktNo;
  TxTimeout  = 0;
  StartPtr   = &((UBYTE*)ethermem)[StartIndex<<8];  
  StopPtr    = &((UBYTE*)ethermem)[StopIndex<<8];
  TxAvail    = true;
  
  ResetMe = false;
  Overrun = false;
  Underrun = false;
  Overflow = false;

  /* make sure the board is stopped */
  /* probably do not need           */
  
  outp(eb+CR,0x21);
  outp(eb+IMR,0);

 /* initialise the board just as it says in the docs */

  outp(eb+CR,0x21);             /* Stage 1 - Stop The Board             */
  outp(eb+DCR,0x48);            /* Stage 2 - Set Data Config Register   */
  outp(eb+RBCR0,0);             /* Stage 3 - Clear Remote Byte Counts   */
  outp(eb+RBCR1,0);             /* Stage 3 - Clear Remote Byte Counts   */

  outp(eb+RCR,etherrcr);        /* Stage 4 - Set the receive confi reg  */
  outp(eb+TCR,4);               /* Stage 5 - put nic in loopback mode 2 */
  outp(eb+BNRY,StartIndex);     /* Stage 6 - init boundary ptr          */
  outp(eb+PSTART,StartIndex);   /* Stage 6 - init page start ptr        */
  outp(eb+PSTOP,StopIndex);     /* Stage 6 - init page stop ptr         */
  outp(eb+ISR,0xFF);            /* Stage 7 - clear interrupt status     */
  outp(eb+IMR,0);               /* Stage 8 - no interrupts              */
  outp(eb+CR,0x61);             /* Stage 9 - set to page 1              */

  for (i = 0; i < 6; i++)
  {
    outp(eb+PAR0+i,etheraddr[i]); /* Stage 9 - set ether net address    */      
    outp(eb+MAR0+i,ethermult[i]); /* Stage 9 - set multicast address    */
  }

  outp(eb+MAR6,ethermult[6]);   /* Stage 9 - set multicast address    */
  outp(eb+MAR7,ethermult[7]);   /* Stage 9 - set multicast address    */

  outp(eb+CURR,StartIndex+1);   /* Stage 9 initialise current pointer */
  
  NextPkt = StartIndex+1;       /* Stage 9 initialise next packet     */

  StopIndex--;                  /* make life easier for later         */

  outp(eb+CR,0x22);             /* Stage 10 - start the nic           */
  outp(eb+TCR,0);               /* Stage 11 - out of loopback mode    */   

  return true;
 
}
VOID GameThread(VOID *hpTempPipe)
{
   HPIPE   hpGamePipe;
   BOOL    fQuit=FALSE;
   PPIB    dummy;
   PTIB    ptibThrdInfo;
   ULONG   ulID;
   USHORT  usMsg, usData, GameBoard[DIVISIONS][DIVISIONS], usTotalMoves=0;

   /* save pipe handle in own memory */
   hpGamePipe = *(HPIPE *)hpTempPipe;

   /* get thread ID for use in displaying messages */
   if((BOOL)DosGetInfoBlocks(&ptibThrdInfo, &dummy))
   {
      ulID = 0;
   }

   else
   {
      ulID = ptibThrdInfo->tib_ptib2->tib2_ultid;
   }

   InitBoard(GameBoard);

   /* initialize random number generator */
   srand((unsigned) ulID);

   if(!(BOOL)DosConnectNPipe(hpGamePipe))
   {
      while (!fAppExit &&
             !fQuit &&
             !(BOOL)(Pipe_IO(CLIENT, hpGamePipe, &usMsg, &usData, ulID)) &&
             !fAppExit)
      {
         switch (usMsg)
         {
            case CLIENT_MOVE:
               /* enter move from message */
               *((USHORT *)GameBoard + usData) = CLIENT_NUM;
               usTotalMoves++;

               /* test for win if total moves >= DIVISIONS*2-1 */
               if (usTotalMoves >= DIVISIONS*2-1 &&
                   ((BOOL)(usData=WinTest(GameBoard)) ||
                    usTotalMoves == DIVISIONS*DIVISIONS))
               {
                  /* notify of win or draw, and break (switch) on return */
                  if (!usData)
                  {
                     usData = DIVISIONS*DIVISIONS;
                     usMsg = WIN_DRAW;
                  }

                  else
                  {
                     usMsg = WIN_CLIENT;
                  }

                  if ((BOOL)Pipe_IO(SERVER, hpGamePipe, &usMsg, &usData, ulID))
                  {
                     WinPostMsg(hwndMain, WM_MSG, MPFROMLONG(IDMSG_PIPE_WRITE_FAILED), MPVOID);
                     fQuit = TRUE;
                     break;
                  }

                  /* call InitBoard on win */
                  InitBoard(GameBoard);
                  usTotalMoves = 0;

                  break;  /* switch */
               }

               /* NO BREAK */

            case YOU_FIRST:
               /* get move if there are moves left */
               usData = GetMove(GameBoard, usTotalMoves);
               usTotalMoves++;

               /* test for win if total moves >= DIVISIONS*2-1 */
               if (usTotalMoves >= DIVISIONS*2-1 &&
                   ((BOOL)(usMsg=WinTest(GameBoard)) ||
                    usTotalMoves == DIVISIONS*DIVISIONS))
               {
                  /* write game_won message with winning move */
                  if (!usMsg)
                  {
                     usMsg = WIN_DRAW;
                  }

                  else
                  {
                     usMsg = WIN_SERVER;
                  }

                  if ((BOOL)Pipe_IO(SERVER, hpGamePipe, &usMsg, &usData, ulID))
                  {
                     WinPostMsg(hwndMain, WM_MSG, MPFROMLONG(IDMSG_PIPE_WRITE_FAILED), MPVOID);
                     fQuit = TRUE;
                     break;
                  }

                  /* call InitBoard on win */
                  InitBoard(GameBoard);
                  usTotalMoves = 0;
               }

               /* else */
               else
               {
                  /* write move to client */
                  usMsg = SERVER_MOVE;
                  if ((BOOL)Pipe_IO(SERVER, hpGamePipe, &usMsg, &usData, ulID))
                  {
                     WinPostMsg(hwndMain, WM_MSG, MPFROMLONG(IDMSG_PIPE_WRITE_FAILED), MPVOID);
                     fQuit = TRUE;
                  }
               }
               break;

            case ERROR_MSG:
               /* post the error to message queue */
               WinPostMsg(hwndMain, WM_MSG, MPFROMSHORT(usData), MPVOID);

            case CLIENT_QUIT:
               /* quit while */
               fQuit = TRUE;
         }
      }

      DosDisConnectNPipe(hpGamePipe);
   }

   DosClose(hpGamePipe);
}