Пример #1
0
int main(void)
{
    //Start the HW
	initHardware();
  ciaaWriteOutput(3,0);

  //create the queue
  xQueue1 = xQueueCreate( QUEUE1_SIZE, sizeof(uint8_t) );

  if (xQueue1==NULL)
    ciaaWriteOutput(4,1); //if it is not create, turn on the red led



    //Create task to read the button
	xTaskCreate(taskReadButton, (const char *)"taskReadButton", configMINIMAL_STACK_SIZE*2, 0, tskIDLE_PRIORITY+1, 0);
    
    //Create task to blick the led
  xTaskCreate(taskBlickLed, (const char *)"taskReadButton", configMINIMAL_STACK_SIZE*2, 0, tskIDLE_PRIORITY+1, 0);


    //Start the Scheduler
	vTaskStartScheduler();

	while (1) {
	}
}
Пример #2
0
static void taskBlickLed(void * a)
{
    
   
    while (1) {
        
        if (xSemaphoreTake(xSemaphore,1000))
        {
          //ciaaWriteOutput(3,1);  
          //Check if the time is zero, if not blink
          //xSemaphoreGive(xSemaphore);
          ciaaWriteOutput(5,1);  //Led green ON
          ciaaWriteOutput(4,0);  //Led red ON

        }
        else
        {
          ciaaWriteOutput(5,0);  //Led green ON
          ciaaWriteOutput(4,1);  //Led red ON


        }




        
        }
}
Пример #3
0
static void taskBlickLed(void * a)
{
    
   uint32_t buttonTime2=0;  //buffer to receive the data
    while (1) {
        xQueueReceive(xQueue1,&buttonTime2,0);
          
        //ciaaWriteOutput(3,1);  
        //Check if the time is zero, if not blink
        if (buttonTime2>0)
          {
           ciaaToggleOutput(3);  //Led 4 ON
           vTaskDelay(buttonTime2/ portTICK_RATE_MS);
            ciaaWriteOutput(5,1);
          }
        else
          {
           ciaaToggleOutput(3);  //Led 4 ON
           vTaskDelay(500/ portTICK_RATE_MS);
           ciaaWriteOutput(5,0);
          }    
        

 
        
        }
}
Пример #4
0
static void taskReadButton(void * a)
{
	
   button_t  button;
   
   //Init the struct
   button.number=0;
   button.state=RELEASE;
   button.time=0;
   
   uint32_t  buttonTime=0;

   while(1)
   {
        //Delay - Who often the task will be entered
        vTaskDelay(UPDATE_BUTTON_TIME/portTICK_RATE_MS); 
        
        //Check if it is press
        if (!ciaaReadInput(button.number))
        {
            button.time+=UPDATE_BUTTON_TIME; //if press add UPDATE_BUTTON_TIME
            if (button.time>2000000000)   //Set the limit
                button.time=2000000000;  
            if (button.time>TIME_NOT_REBOUND) 
              {
                button.state=PRESS;    
              } 
        }
        else
        {
            button.state=RELEASE;
            if (button.time>TIME_NOT_REBOUND)
              {
                //take the time of press in mseg
                buttonTime=button.time;
                xQueueSend( xQueue1, ( void * ) &buttonTime, 0);

              }
            button.time=0;
            
        }

        if(button.state==PRESS)
          {  
            ciaaWriteOutput(0,1);  //Led RED ON
          }
          else
          {
            ciaaWriteOutput(0,0);  //Led RED OFF
          }  
        


   }

}
Пример #5
0
static void taskReadButton(void * a)
{
	
   button_t  button;
   
   //Init the struct
   button.number=0;
   button.state=RELEASE;
   button.time=0;
   


   while(1)
   {
        //Delay
        vTaskDelay(TIME_NOT_REBOUND/portTICK_RATE_MS); 
        
        //check if it is press
        if (!ciaaReadInput(button.number))
        {
            button.time++;
            if (button.time>65000)
                button.time=65000;
            if (button.time>TICKS_BUTTON)
                button.state=PRESS; 

        }
        else
        {
            button.state=RELEASE;
            if (button.time>TICKS_BUTTON)
              {
                xSemaphoreGive(xSemaphore);
                //take the time of press in mseg
                buttonTime=(button.time-TICKS_BUTTON)*TIME_NOT_REBOUND;
              }
            button.time=0;
            
        }

        if(button.state==PRESS)
          {  
            ciaaWriteOutput(0,1);  //Led RED ON
          }
          else
          {
            ciaaWriteOutput(0,0);  //Led RED OFF
          }  
        


   }

}
Пример #6
0
int main(void)
{
    //Start the HW
  uint8_t numLedRGBred;
  uint8_t numLedRGBgreen;
  uint8_t numLedRGBblue;

	initHardware();
  ciaaWriteOutput(3,0); 
  // Create a semaphore
  vSemaphoreCreateBinary(xSemaphore);
  //xSemaphoreTake(xSemaphore,portMAX_DELAY);
    //Create task to read the button
	//xTaskCreate(taskReadButton, (const char *)"taskReadButton", configMINIMAL_STACK_SIZE*2, 0, tskIDLE_PRIORITY+1, 0);
    
  numLedRGBred=0; //LED RED
    //Create task to blick the led
  xTaskCreate(taskBlickLed, (const char *)"task", configMINIMAL_STACK_SIZE*2, &numLedRGBred, tskIDLE_PRIORITY+1, 0);

  numLedRGBgreen=1; //LED GREEN
    //Create task to blick the led
  xTaskCreate(taskBlickLed, (const char *)"taskReadButton", configMINIMAL_STACK_SIZE*2, &numLedRGBgreen, tskIDLE_PRIORITY+1, 0);

  numLedRGBblue=2; //LED BLUE
    //Create task to blick the led
  xTaskCreate(taskBlickLed, (const char *)"taskReadButton", configMINIMAL_STACK_SIZE*2, &numLedRGBblue, tskIDLE_PRIORITY+1, 0);

    //Start the Scheduler
	vTaskStartScheduler();

	while (1) {
	}
}
Пример #7
0
static void initHardware(void)
{
    SystemCoreClockUpdate();

    Board_Init();

    ciaaIOInit();

    ciaaWriteOutput(0, 0);
}
Пример #8
0
static void initHardware(void)
{
    //Set the system core
    SystemCoreClockUpdate();
    //Init the clock of HW - gpio
    Board_Init();
    //Init the EDU-CIAA HW
    ciaaIOInit();
    //Turn of the LED
    ciaaWriteOutput(0, 0);
}
Пример #9
0
static void taskBlickLed(void * a)
{
    
   uint8_t buf=NOT_READY;  //buffer to receive the data
    while (1) {
        
        if (xQueueReceive(xQueue1,&buf,portMAX_DELAY))
        {  
          //ciaaWriteOutput(3,1);  
          //Check if the time is zero, if not blink
          if (buttonTime>0)
          {
           ciaaWriteOutput(3,1);  //Led 4 ON
           vTaskDelay(buttonTime/ portTICK_RATE_MS);
           ciaaWriteOutput(3,0); 
          }    
        }

 
        
        }
}
Пример #10
0
int main(void)
{
	volatile int i;

	/* FIXME: SystemCoreClock no se usa con LPC43xx,
	 * pero CGU_GetPCLKFrequency() no sé por qué genera
	 * cuelgues erráticos o hace que SysTick no interrumpa :(
	 */

	SysTick_Config(SystemCoreClock/1000);
    ciaaIOInit();

    while(1)
    {
    	for(i=4; i<8; i++)
    	{
			ciaaWriteOutput(i, 1);
			pausems(100);
			ciaaWriteOutput(i, 0);
    	}
    }
}
Пример #11
0
int main(void)
{
    //Start the HW
	initHardware();
  ciaaWriteOutput(3,0); 
  // Create a semaphore
  vSemaphoreCreateBinary(xSemaphore);
  xSemaphoreTake(xSemaphore,0);
    //Create task to read the button
	xTaskCreate(taskReadButton, (const char *)"taskReadButton", configMINIMAL_STACK_SIZE*2, 0, tskIDLE_PRIORITY+1, 0);
    
    //Create task to blick the led
  xTaskCreate(taskBlickLed, (const char *)"taskReadButton", configMINIMAL_STACK_SIZE*2, 0, tskIDLE_PRIORITY+1, 0);

    //Start the Scheduler
	vTaskStartScheduler();

	while (1) {
	}
}
Пример #12
0
static void initHardware(void)
{
    SystemCoreClockUpdate();

    Board_Init();

    ciaaIOInit();
    ciaaUARTInit();

    ciaaWriteOutput(0, 0);


    //BOTON 1

    Chip_PININT_Init(LPC_GPIO_PIN_INT);
    //Set GPIO0[4] (SW1) -> GPIO0_IRQHandler
    Chip_SCU_GPIOIntPinSel(0,0,4);
    //falling edge IRQ 
    Chip_PININT_SetPinModeEdge(LPC_GPIO_PIN_INT,PININTCH0);
    Chip_PININT_EnableIntLow(LPC_GPIO_PIN_INT,PININTCH0);

    //habilitar la IRQ
    NVIC_EnableIRQ(PIN_INT0_IRQn);

    //BOTON 2

    //Set GPIO0[4] (SW1) -> GPIO0_IRQHandler
    Chip_SCU_GPIOIntPinSel(1,1,9);
    //falling edge IRQ 
    Chip_PININT_SetPinModeEdge(LPC_GPIO_PIN_INT,PININTCH1);
    Chip_PININT_EnableIntLow(LPC_GPIO_PIN_INT,PININTCH1);

    //habilitar la IRQ
    NVIC_EnableIRQ(PIN_INT1_IRQn);




}