/**************************************************************************************************
 * @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;
}
/**************************************************************************************************
 * @fn          main
 *
 * @brief       Start of application.
 *
 * @param       none
 *
 * @return      none
 **************************************************************************************************
 */
int main(void)
{
  /* Initialize hardware */
  HAL_BOARD_INIT();

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

  /* Initialize MAC */
  MAC_Init();

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

  /* Enable interrupts */
  HAL_ENABLE_INTERRUPTS();

  /* Setup OSAL Timer */
  HalTimerConfig ( OSAL_TIMER,                         // 16bit timer3
                   HAL_TIMER_MODE_CTC,                 // Clear Timer on Compare
                   HAL_TIMER_CHANNEL_SINGLE,           // Channel 1 - default
                   HAL_TIMER_CH_MODE_OUTPUT_COMPARE,   // Output Compare mode
                   FALSE,                              // Use interrupt
                   MSA_Main_TimerCallBack);            // Channel Mode

  /* Setup Keyboard callback */
  HalKeyConfig(MSA_KEY_INT_ENABLED, MSA_Main_KeyCallback);

  /* Initialize UART */
  UartCnfg.baudRate = HAL_UART_BR_9600;
  UartCnfg.callBackFunc = HalUARTCBack;
  UartCnfg.flowControl = FALSE;
  UartCnfg.flowControlThreshold = 0;  /* max Buffer Size in Byte*/
  UartCnfg.idleTimeout = 200;

  /*
   * halUARTOpen provvederà tramite la funzione halUartAllocBuffers ad allocare e inizializzare
   * le strutture dati RxUART e TxUART.
   */

  UartCnfg.rx = RxUART;
  UartCnfg.tx = TxUART;
  UartCnfg.rx.maxBufSize = UART_MAX_BUFFER_SIZE;
  UartCnfg.tx.maxBufSize = UART_MAX_BUFFER_SIZE;
  UartCnfg.intEnable = TRUE ;  /* enable or disable the interrupts */
  UartCnfg.configured = TRUE;

  uint8 status = HalUARTOpen(HAL_UART_PORT, &UartCnfg); /* passo l'indirizzo di memoria della struttura dati
  	  	  	  	  	  	  	  	  	  	  UartCnfg, Passaggio per riferimento!!!*/




  /* 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;
}
Example #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;
}
Example #5
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;
}
Example #6
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;
}
Example #7
0
/**************************************************************************************************
 * @fn          main
 *
 * @brief       Start of application.
 *
 * @param       none
 *
 * @return      none
 **************************************************************************************************
 */
int main(void)
{
  /* Initialize hardware */
  HAL_BOARD_INIT();

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

  /* Initialize MAC */
  MAC_Init();

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

#ifdef HAL_BOARD_CC2538
  /* Master enable interrupts */
  IntMasterEnable();

  /* Setup SysTick to generate interrupt every 1 ms */
  SysTickSetup();
#endif /* HAL_BOARD_CC2538 */

  /* Enable interrupts */
  HAL_ENABLE_INTERRUPTS();

  /* Setup Keyboard callback */
  HalKeyConfig(MSA_KEY_INT_ENABLED, MSA_Main_KeyCallback);

  /* Blink LED on startup */
  HalLedBlink (HAL_LED_4, 0, 40, 200);

  /* Start OSAL */
  OSAL_START_SYSTEM();

  return 0;
}