Ejemplo n.º 1
0
int main(void)
{

  /* USER CODE BEGIN 1 */
  osKernelInitialize();
  /* USER CODE END 1 */

  /* MCU Configuration----------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* Configure the system clock */
  SystemClock_Config();

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_TIM2_Init();
  MX_USART2_UART_Init();
  MX_TIM4_Init();
  MX_TIM3_Init();
  MX_ADC1_Init();

  /* USER CODE BEGIN 2 */
//#ifdef  USE_FULL_ASSERT
#ifndef MAC_COORDINATOR
  // Board - Serial identification
  sprintf(Buf, "\x0cNUCLEO-F446 Debug Terminal\r\nVisible Light Communication "
      "Project\r\n---\r\nDEV_CONFIG=%d\r\n\r\n", DEV_CONFIG);
  HAL_UART_Transmit(&huart2, (uint8_t *) Buf, strlen(Buf), 0xffff);
#endif
//#endif
  // Initialize Optical Driver
  DRV_Init();
  // Initialize PHY layer
  PHY_Init();
  // Initialize MAC APP layer
  MAC_AppInit();
  
  // Create threads
#ifdef MAC_COORDINATOR
  tid_blinkLED = osThreadCreate (osThread(blinkLED), NULL);
#endif
  //tid_sendSerial = osThreadCreate (osThread(sendSerial), NULL);
  //tid_checkButton = osThreadCreate (osThread(checkButton), NULL);
  // Start thread execution
  osKernelStart();

  // Run codes
  DRV_RX_Start();
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1) {
    osDelay(1000);
#ifdef MAC_COORDINATOR
    osSignalSet(tid_blinkLED, 0x0001);
#endif
  }
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

  /* USER CODE END 3 */

}
Ejemplo n.º 2
0
void PL_Init(void) {
#if PL_CONFIG_HAS_LED
    LED_Init();
#endif
#if PL_CONFIG_HAS_EVENTS
    EVNT_Init();
#endif
#if PL_CONFIG_HAS_TIMER
    TMR_Init();
#endif
#if PL_CONFIG_HAS_TRIGGER
    TRG_Init();
#endif
#if PL_CONFIG_HAS_BUZZER
    BUZ_Init();
#endif
#if PL_CONFIG_HAS_RTOS
    RTOS_Init();
#endif
#if PL_CONFIG_HAS_SHELL
    SHELL_Init();
#endif
#if PL_CONFIG_HAS_SHELL_QUEUE
    SQUEUE_Init();
#endif
#if PL_CONFIG_HAS_MOTOR
    MOT_Init();
#endif
#if PL_CONFIG_HAS_LINE_SENSOR
    REF_Init();
#endif
#if PL_CONFIG_HAS_MOTOR_TACHO
    TACHO_Init();
#endif
#if PL_CONFIG_HAS_MCP4728
    MCP4728_Init();
#endif
#if PL_CONFIG_HAS_ULTRASONIC
    US_Init();
#endif
#if PL_CONFIG_HAS_PID
    PID_Init();
#endif
#if PL_CONFIG_HAS_DRIVE
    DRV_Init();
#endif
#if PL_CONFIG_HAS_TURN
    TURN_Init();
#endif
#if PL_CONFIG_HAS_LINE_FOLLOW
    LF_Init();
#endif
#if PL_CONFIG_HAS_RADIO
    RNETA_Init();
#endif
#if PL_CONFIG_HAS_REMOTE
    REMOTE_Init();
#endif
#if PL_CONFIG_HAS_IDENTIFY
    ID_Init();
#endif
#if PL_CONFIG_HAS_LINE_MAZE
    MAZE_Init();
#endif
}
Ejemplo n.º 3
0
/*
 *  ======== WCD_Init ========
 *  Purpose:
 *      Module initialization is done by SERVICES Init.
 */
bool WCD_Init(void)
{
	bool fInit = true;
	bool fDRV, fDEV, fCOD, fSERVICES, fCHNL, fMSG, fIO;
	bool fMGR, fPROC, fNODE, fDISP, fNTFY, fSTRM, fRMM;
#ifdef DEBUG
	/* runtime check of Device IOCtl array. */
	u32 i;
	int cmdtable = ARRAY_SIZE(WCD_cmdTable);

	for (i = 1; i < cmdtable; i++)
		DBC_Assert(WCD_cmdTable[i - 1].dwIndex == i);

#endif
	if (WCD_cRefs == 0) {
		/* initialize all SERVICES modules */
		fSERVICES = SERVICES_Init();
		/* initialize debugging module */
		DBC_Assert(!WCD_debugMask.flags);
		GT_create(&WCD_debugMask, "CD");    /* CD for class driver */
		/* initialize class driver and other modules */
		fDRV = DRV_Init();
		fMGR = MGR_Init();
		fPROC = PROC_Init();
		fNODE = NODE_Init();
		fDISP = DISP_Init();
		fNTFY = NTFY_Init();
		fSTRM = STRM_Init();
		fRMM = RMM_init();
		fCHNL = CHNL_Init();
		fMSG = MSG_Init();
		fIO = IO_Init();
		fDEV = DEV_Init();
		fCOD = COD_Init();
		fInit = fSERVICES && fDRV && fDEV && fCHNL && fCOD &&
			fMSG && fIO;
		fInit = fInit && fMGR && fPROC && fRMM;
		if (!fInit) {
			if (fSERVICES)
				SERVICES_Exit();

			if (fDRV)
				DRV_Exit();

			if (fMGR)
				MGR_Exit();

			if (fSTRM)
				STRM_Exit();

			if (fPROC)
				PROC_Exit();

			if (fNODE)
				NODE_Exit();

			if (fDISP)
				DISP_Exit();

			if (fNTFY)
				NTFY_Exit();

			if (fCHNL)
				CHNL_Exit();

			if (fMSG)
				MSG_Exit();

			if (fIO)
				IO_Exit();

			if (fDEV)
				DEV_Exit();

			if (fCOD)
				COD_Exit();

			if (fRMM)
				RMM_exit();

		}
	}
	if (fInit)
		WCD_cRefs++;

	GT_1trace(WCD_debugMask, GT_5CLASS,
		 "Entered WCD_Init, ref count: 0x%x\n",	WCD_cRefs);
	return fInit;
}