Пример #1
0
extern "C" void user_main() {
    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_SET);

    osKernelInitialize();
    osKernelStart();

    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_RESET);

    key_event_init();
    keymat_init();
    keymat_callback = key_event_handler;
    keymat_start();

    HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_SET);

    while (1) {
        osEvent ose = osMailGet(key_events, osWaitForever);
        if (ose.status == osEventMail) {
            KeyEvent* e = (KeyEvent*)ose.value.p;

            // NOTE: MIDI handling is hardcoded for now
            buf[0] = (e->state ? 0x90 : 0x80); // use ch0
            buf[1] = e->keycode;
            buf[2] = 100; // use hard-coded velocity

            osMailFree(key_events, e);

            send_n(3); // blocking call
        }
    }
}
Пример #2
0
/*
 *	Main function: initializes all system values and components, then starts
 *	operation of the two threads.
 *
 *	@author HP Truong, Jacob Barnett
 *
 *	@param void
 *	@return void
 */
int main (void) {
	CC2500_LowLevel_Init();
	CC2500_Reset();

	osKernelInitialize ();                    // initialize CMSIS-RTOS
	
	// initialize peripherals here
	/* LCD initiatization */
	LCD_Init();
  
	/* LCD Layer initiatization */
	LCD_LayerInit();

	/* Enable the LTDC controler */
	LTDC_Cmd(ENABLE);

	/* Set LCD foreground layer as the current layer */
	LCD_SetLayer(LCD_FOREGROUND_LAYER);

	LCD_SetFont(&Font16x24);
	LCD_Clear(LCD_COLOR_WHITE);

	receive_and_plot_thread = osThreadCreate(osThread(receive_and_plot), NULL);
	print_lcd_debug_thread = osThreadCreate(osThread(print_lcd_debug), NULL);

	osKernelStart ();                         // start thread execution 
}
Пример #3
0
int main(void){
	//Set procesor speed
	setToMaxSpeed();
	//Initialize kernel
	osKernelInitialize();
	//Hardware initialize
	led_init();
	//Initialize encoder
	timer_3_encoder_init();
	//Initialize PWM
	short myPrescaler=47;//set Tick time to 1us (Fclk/(Prescaler+1))
	int myAutorreload=1000;//set cycle time to 1ms
	TIMER2_CH2_PWM_Init(myPrescaler,myAutorreload);
	//Initialize serial
	os_serial_init();
	os_usart2_init(9600);
	//Initialize adc
	adc_poll_init();
	//Start Thread switching
	osKernelStart();
	//User Application
	float adc_reading;
	os_usart2_puts("Hello, World\n");
	while(1){
		adc_reading = adc_poll_read()*(100.0/4095);
		encoder_position=TIM_GetCounter(TIM3);
		
		os_serial_printf(os_usart2_puts,">>%d\n",turns_counter);
		TIMER2_CH2_PWM_SetDutyCycle((unsigned int) adc_reading,myAutorreload);
		osDelay(200);
	}
}
Пример #4
0
/*
 * Application entry point.
 */
int main(void) {

  /* HAL initialization, this also initializes the configured device drivers
     and performs the board-specific initializations.*/
  halInit();

  /* The kernel is initialized but not started yet, this means that
     main() is executing with absolute priority but interrupts are
     already enabled.*/
  osKernelInitialize();

  /* Activates the serial driver 2 using the driver default configuration.
    PA2(TX) and PA3(RX) are routed to USART2.*/
  sdStart(&SD2, NULL);
  palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7));
  palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7));

  /* Creates the example thread, it does not start immediately.*/
  osThreadCreate(osThread(Thread1), NULL);

  /* Kernel started, the main() thread has priority osPriorityNormal
     by default.*/
  osKernelStart();

  /* In the ChibiOS/RT CMSIS RTOS implementation the main() is an
     usable thread, here we just sleep in a loop printing a message.*/
  while (true) {
    sdWrite(&SD2, (uint8_t *)"Hello World!\r\n", 14);
    osDelay(500);
  }
}
Пример #5
0
/**
  * Main function
  */
int main (void) {

	osKernelInitialize();                     /* initialize CMSIS-RTOS          */

	HAL_Init();                               /* Initialize the HAL Library     */

	SystemClock_Config();                     /* Configure the System Clock     */

	/* User codes goes here*/
	// initializeLED_IO();                       /* Initialize LED GPIO Buttons    */
	// start_Thread_LED();                       /* Create LED thread              */

	init_acc_kstate(0.01f, 0.1f, 0.0f, 0.1f, 0.0f);
	init_temp_kstate(0.005f, 0.05f, 0.0f, 5.0f, 0.0f);

	MAIL_CONTROLLER_init_mailboxes();
	ConfigureADC();
	accelerometer_init();
	LED_init_io();
	KP_init();

	TIM3_init();
	TIM4_init();

	MAIL_CONTROLLER_start_thread();
	LED_start_thread();
	temperature_start_thread();
	accelerometer_start_thread();
	KEYPAD_start_thread();
	/* User codes ends here*/

	osKernelStart();                          /* start thread execution         */

}
Пример #6
0
int main()
{
    printf("main() started\n");

#if 0

    runTests(0);
    while (1);

#else

    osThreadDef_t testRunnerThread = {&runTests, osPriorityNormal, 1, 0};
    if (osKernelInitialize() != osOK
        || osKernelStart() != osOK
        || osThreadCreate(&testRunnerThread, 0) == NULL)
    {
        showError();
    }

    while (1)
    {
        osDelay(10000);
    }

#endif
}
void osInitKernel(void)
{
//Check CMSIS-RTOS API version
#if (osCMSIS >= 0x10001)
   //Initialize the kernel
   osKernelInitialize();
#endif
}
Пример #8
0
int main()
{		
	osKernelInitialize();
				
	get_temperature_id = osThreadCreate(osThread(GetTemperature),NULL);  
	rx_id = osThreadCreate(osThread(RX_Thread),NULL);  
	tx_id	= osThreadCreate(osThread(TX_Thread),NULL);
	
	osKernelStart();	
}
Пример #9
0
/*
 * main: initialize and start the system
 */
int main (void) {
  uint8_t buf, reg;
  osKernelInitialize ();                    // initialize CMSIS-RTOS
  
  // initialize peripherals here
  Blinky_GPIO_Init();
  wireless_init();

  Rx_thread = osThreadCreate(osThread(RxPacket), NULL);
	osKernelStart();
}
Пример #10
0
int main (void) {
  osKernelInitialize();                     /* initialize CMSIS-RTOS */
  HAL_Init();                               /* Initialize the HAL Library */
  SystemClock_Config();                     /* Configure the System Clock */
  //start_Thread_SPI();
  start_Thread_Temperature();               /* Create a thread for sampling CPU temperature */
  start_Thread_Acc();                       /* Create a thread for sampling accelerometer data */
	start_Thread_LED();
  osKernelStart();                          /* start thread execution */
	
}
Пример #11
0
int main (void) {

  SystemCoreClockUpdate();
  osKernelInitialize();                 // Initialize CMSIS-RTOS
  osThreadNew(app_main, NULL, NULL);    // Create application main thread
  if (osKernelGetState() == osKernelReady) {
    osKernelStart();                    // Start thread execution
  }

  for (;;) {};
}
Пример #12
0
int main(void){
	led_init();
	osKernelInitialize();
	init_myThread();
	osKernelStart();//after this main beocmes a thread and the os starts running
	while(1){
		mainThreadCounter++;
		GPIO_WriteBit(GPIOB,GPIO_Pin_8,!GPIO_ReadOutputDataBit(GPIOB,GPIO_Pin_8));
		osDelay(250);
	}
}
Пример #13
0
/* 
* main: initialize and start the system */ 
int main (void) 
{ 
osKernelInitialize (); // Initialize CMSIS-RTOS 
// initialize peripherals here 
LED_Initialize (); // Initialize LEDs 
// create 'thread' functions that start executing, 
// example: tid_name = osThreadCreate (osThread(name), NULL); 
Init_BlinkyThread (); // Start Blinky thread 
osKernelStart (); // Start thread execution 
while (1); 
}
Пример #14
0
int main (void) {

  Status = osKernelInitialize();

  ThreadA_Id = osThreadNew(ThreadA, NULL, &ThreadAttr);
  ThreadB_Id = osThreadNew(ThreadB, NULL, &ThreadAttr);
  ThreadC_Id = osThreadNew(ThreadC, NULL, NULL);
  ThreadD_Id = osThreadNew(ThreadD, NULL, &ThreadAttr);

  Status = osKernelStart();

  for (;;);
}
Пример #15
0
/*
 * main: initialize and start the system
 */
int main (void) {
  osKernelInitialize ();    	// initialize CMSIS-RTOS
  
  //console.log("Hellow World");

	
	 Init_Thread();
  // initialize peripherals here

  // create 'thread' functions that start executing,
  // example: tid_name = osThreadCreate (osThread(name), NULL);

  osKernelStart ();                         // start thread execution 
}
Пример #16
0
/**
* @brief  Main Function
* @param  
* @retval int 0
*/
int main (void) {

  osKernelInitialize ();                    // initialize CMSIS-RTOS
  wireless_init();  //Initialize wireless
  LCD_Init();  //Initialize LCD
  LCD_LayerInit(); //Initialize Layer  
  /* Enable the LTDC controler */
  LTDC_Cmd(ENABLE);
  /* Set LCD foreground layer as the current layer */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);
	DisplayLCD_thread = osThreadCreate(osThread(DisplayLCD), NULL);
  Rx_thread = osThreadCreate(osThread(RxPacket), NULL);
	osKernelStart();
}
Пример #17
0
int main(void)
{
  DAVE_Init();   /* initialize Dave internals */
  osKernelInitialize ();

  //IO004_EnableOutputDriver(&IO004_Handle0, IO004_OPENDRAIN);
  /* Create Task to call Lua_task */

  MainThreadId = osThreadCreate(osThread(LUA001_Task), NULL);

  osKernelStart();
  osDelay(osWaitForever);
  for (;;);
  return 0;
}
/*----------------------------------------------------------------------------
 *        Main: Initialize and start RTX Kernel
 *---------------------------------------------------------------------------*/
int main (void) 
{
	osKernelInitialize ();                    
	LED_Initialize();
	Turnstile =	osSemaphoreCreate(osSemaphore(Turnstile), 0); // 0 tokens
	Turnstile2 = osSemaphoreCreate(osSemaphore(Turnstile2), 1); // 1 token
	Mutex =	osSemaphoreCreate(osSemaphore(Mutex), 1);	
	tsk2_0 = osThreadCreate(osThread(threadBaseCode),(void *) 1U);
	tsk2_1 = osThreadCreate(osThread(threadBaseCode),(void *) 2U); 
	tsk2_2 = osThreadCreate(osThread(threadBaseCode),(void *) 3U);
	tsk2_3 = osThreadCreate(osThread(threadBaseCode),(void *) 4U);
	tsk2_4 = osThreadCreate(osThread(threadBaseCode),(void *) 5U);

	osKernelStart ();                         
}
Пример #19
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* This project template calls firstly two functions in order to configure MPU feature 
     and to enable the CPU Cache, respectively MPU_Config() and CPU_CACHE_Enable().
     These functions are provided as template implementation that User may integrate 
     in his application, to enhance the performance in case of use of AXI interface 
     with several masters. */ 
  
  /* Configure the MPU attributes as Write Through */
  MPU_Config();

  /* Enable the CPU Cache */
  CPU_CACHE_Enable();

#ifdef RTE_CMSIS_RTOS                   // when using CMSIS RTOS
  osKernelInitialize();                 // initialize CMSIS-RTOS
#endif

  /* STM32F7xx HAL library initialization:
       - Configure the Flash ART accelerator on ITCM interface
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Low Level Initialization
     */
  HAL_Init();

  /* Configure the System clock to have a frequency of 216 MHz */
  SystemClock_Config();


  /* Add your application code here
     */
	BSP_SDRAM_Init();
	Touch_Initialize();
	
#ifdef RTE_CMSIS_RTOS                   // when using CMSIS RTOS
	Init_Thread1();
	Init_Thread2();

  osKernelStart();                      // start thread execution 
#endif
	Analyzer_Init();
	GUI_Init();
	osMutexWait(mid_Thread_Mutex,osWaitForever);
	Hello_MSG();
	osMutexRelease(mid_Thread_Mutex);
	osThreadTerminate(osThreadGetId());
}
void Reset_Handler(void)
{
  /*
   * Only Initialize Internal SRAM
   * USB RAM is used for USB purpose
   */
  unsigned int *src, *dst;

  /* Copy data section from flash to RAM */
  src = &__data_load_addr;
  dst = &__data_start;
  while (dst < &__data_end)
    *dst++ = *src++;

  /* Zero fill the bss section */
  dst = &__bss_start;
  while (dst < &__bss_end)
    *dst++ = 0;

  SystemInit();

#if defined (__cplusplus)
  //
  // Call C++ library initialisation
  //
  __libc_init_array();
#endif

#if defined(CFG_CMSIS_RTOS)
	osKernelInitialize();
	osThreadCreate(&os_thread_def_main, NULL);
	osKernelStart();
#else
#if defined (__REDLIB__)
  // Call the Redlib library, which in turn calls main()
  __main() ;
#else
  main();
#endif
#endif
  //
  // main() shouldn't return, but if it does, we'll just enter an infinite loop
  //
  while (1)
  {
  }
}
Пример #21
0
int main(void)
{
    osKernelInitialize();

    thread.name         = "app_task";
    thread.pthread      = (os_pthread)app_task;
    thread.tpriority    = osPriorityNormal;
    thread.stacksize    = APP_TASK_STACKSIZE;
    thread.ptcb         = &app_task_obj;
    thread.pstackspace  = app_task_buf;

    osThreadCreate (&thread, NULL);

    osKernelStart();

    return 0;
}
Пример #22
0
/*! \fn int main(void)
    \brief Start of main program
		\details Initializes the peripherals and starts the OS
*/
int main(void)
{
	osKernelInitialize ();                    // initialize CMSIS-RTOS
	
	// initialize peripherals
	UART_initialize();
  printf("\n\rRavenOS demo\n\r");
  LED_initialize(); 
	
	printf("Initializing threads\n\r");
  if (Init_thread0() != 0)
	{
		stop_cpu;
	}
  if (Init_thread1() != 0)
	{
		stop_cpu;
	}
  if (Init_thread2() != 0)
	{
		stop_cpu;
	}	
//  // thread3 is a low priority thread can be used as a more user obvious alternative to print tracing from UART, 
//  // which currently resides in the Idle thread (operated by the RTOS)
//  if (Init_thread3() != 0)
//	{
//		stop_cpu;
//	}
	
	printf("Initializing semaphores\n\r");
  if (Init_Semaphore0() != 0)
	{
		stop_cpu;
	}	
  if (Init_Semaphore1() != 0)
	{
		stop_cpu;
	}		
	printf("Start kernel\n\r");
	osKernelStart ();                         // start thread execution 
	
  // Should not be here
  stop_cpu;
}
Пример #23
0
/*----------------------------------------------------------------------------
 * main: initialize and start the system
 *----------------------------------------------------------------------------*/
int main (void) {
  uint32_t button_msk = (1U << Buttons_GetCount()) - 1;

  osKernelInitialize ();                                   // initialize CMSIS-RTOS

  // initialize peripherals
  SystemCoreClockConfigure();                              // configure System Clock
  SystemCoreClockUpdate();

  LED_Initialize();                                        // LED Initialization
  Buttons_Initialize();                                    // Buttons Initialization

  // create threads
  tid_blinkLED = osThreadCreate (osThread(blinkLED), NULL);

  osKernelStart ();                                        // start thread execution
	DAC_init();
	DAC_enable();
	
	
	for(Counter=0;Counter<182;Counter++)
	{
		DAC_value2[Counter]=DAC_value1[Counter]/2;
	}
	Counter=0;

  for (;;) { 
		if (Counter<=0)Direction=0;
		else if (Counter>179)Direction=1;
		if (Direction==0)Counter++;
		else Counter--;
		
		DAC_write(DAC_value2[Counter]);
		
		
		
//		DAC_write(4000);
//    osDelay(100);
//		while (Buttons_GetState() & (button_msk));             // Wait while holding USER button
//		DAC_write(0);
//    osSignalSet(tid_blinkLED, 0x0001);
  }
}
  int main(void)
  {
    /* Initiaise the HW */
    boardInit();

    /* Initialise the RTX kernel */
    osKernelInitialize();

    /* Create out threads */
    tid_mainthread = osThreadCreate(osThread(main_thread), NULL);
    tid_blinkythread = osThreadCreate(osThread(blinky_thread), NULL);

    /* Start the kernel and then go into an endless loop */
    osKernelStart();

    /* No return */
    while(1);

    return 1;
  }
Пример #25
0
/**
  * @brief  Main function. Executes all initialization and terminate its thread.
  * @param  None
  * @retval None
  */
int main(void)
{	
  ///////////////////////////////////////////////////////////////////////////////////////////
  /* Configure the MPU attributes as Write Through */
  MPU_Config();
  /* Enable the CPU Cache */
  CPU_CACHE_Enable();
	// initialize CMSIS-RTOS
  osKernelInitialize();
	///////////////////////////////////////////////////////////////////////////////////////////
	// Hardware initialize
  if( HAL_Init() != HAL_OK)
		Error_Handler();
	if( ConfigureDMA(&g_DmaHandle, &g_AdcHandle) != HAL_OK)
		Error_Handler();
	if( ADC_INIT(&g_AdcHandle) != HAL_OK)
		Error_Handler();
	
	BSP_SDRAM_Init();
	Touch_Initialize();
	///////////////////////////////////////////////////////////////////////////////////////////
  /* Configure the System clock to have a frequency of 216 MHz */
  SystemClock_Config();
	// Thread initialization
	Init_TH_GUI();
	Init_TH_Touch();
	// RTOS Start Kernel
  osKernelStart();                      // start thread execution 
	// Get Main Thread ID
	Main_thID = osThreadGetId();
	///////////////////////////////////////////////////////////////////////////////////////////
	// Start data acquire
	HAL_ADC_Start_DMA(&g_AdcHandle, values, ADC_BUFFER_LENGTH);
	///////////////////////////////////////////////////////////////////////////////////////////
	// Terminate main thread
	osThreadTerminate(Main_thID);
	/* Infinite loop */
  while (1) {  }
}
Пример #26
0
int main() {
	GPIO_InitTypeDef GPIO_InitDef;
	
	SystemClock_Config();
	SystemCoreClockUpdate();
	
	HAL_Init();
	
	/* driver init */
	lsm303dlhc_init();
	l3gd20_init();
	
	osKernelInitialize();
	Init_Timers();
	
	
	handlerThread_id = osThreadCreate(osThread(handlerThread), NULL);
	gyroHandlerThread_id = osThreadCreate(osThread(gyroHandlerThread), NULL);
	visioThread_id = osThreadCreate(osThread(visioThread), NULL);
	
	accelBuffer_mutex_id = osMutexCreate(osMutex(accelBuffer_mutex));
	gyroBuffer_mutex_id = osMutexCreate(osMutex(gyroBuffer_mutex));
	
	// enable clock for GPIOE
	//__HAL_RCC_GPIOE_CLK_ENABLE();

	// init GPIO pin
	GPIO_InitDef.Pin = GPIO_PIN_9;
	GPIO_InitDef.Mode = GPIO_MODE_OUTPUT_PP;
	GPIO_InitDef.Speed = GPIO_SPEED_FREQ_LOW;
	
	HAL_GPIO_Init(GPIOE, &GPIO_InitDef);
	
	// set LD3
	HAL_GPIO_WritePin(GPIOE, GPIO_PIN_9, GPIO_PIN_SET);
	
	osKernelStart();
}
Пример #27
0
/*----------------------------------------------------------------------------
 * main: initialize and start the system
 *----------------------------------------------------------------------------*/
int main (void) {
  uint32_t button_msk = (1U << Buttons_GetCount()) - 1;

  osKernelInitialize ();                                   // initialize CMSIS-RTOS

  // initialize peripherals
  SystemCoreClockConfigure();                              // configure System Clock
  SystemCoreClockUpdate();

  LED_Initialize();                                        // LED Initialization
  Buttons_Initialize();                                    // Buttons Initialization

  // create threads
  tid_blinkLED = osThreadCreate (osThread(blinkLED), NULL);

  osKernelStart ();                                        // start thread execution

  for (;;) {                                               // main must not be terminated!
    osDelay(500);
    while (Buttons_GetState() & (button_msk));             // Wait while holding USER button
    osSignalSet(tid_blinkLED, 0x0001);
  }
}
Пример #28
0
int main (void) {
    uint8_t	ret = 0x23;
    u32IAP_ReadUID(uid);
    sn = uid[0] + uid[1] +uid[2] +uid[3];

    osKernelInitialize ();                    // initialize CMSIS-RTOS

    // initialize peripherals here

    UARTInit(9600); // Initial, then create thread call back.
    tidUART = osThreadCreate(osThread(UARTCallback), NULL);
    printf("UART initial, UID:%ull\r\n", sn);

    if(sn == (2871327760ll))
        printf("UID matched:%ull\r\n", sn);

    LEDInit(); // Initial, then create thread call back.
    tidLED = osThreadCreate (osThread(LEDCallback), NULL);
    printf("LED initial\r\n");

    NRF24L01_Init();
    printf("NRF24L01_Init()\r\n");
    ret = NRF24L01_Check();
    printf("NRF24L01_Check():%d\r\n", ret);

    //txbuf[0]= 0x11;
    //NRF24L01_TxPacket(txbuf);
    TIM32B1_Square(1, BIT1);

    //CLKOUT_ENABLE(CLK_SRC_MAIN, 100); //If it's too fast to watch on OSC, divided it to 100.
    //TIM32B0_init();

    osKernelStart();// start thread execution

    printf("End if main()\r\n");
    while(1);
}
Пример #29
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 */

}
Пример #30
0
__WEAK void software_init_hook (void) {
  osKernelInitialize();
}