Ejemplo n.º 1
0
void a_main()
{
    // Debug trigger
    enable_LED(PORTL0);
    disable_LED(PORTL0);

    // Initialize components
    uart_init();
    uart1_init();
    init_ADC();
    mode_PORTA_INPUT(JOYSTICK_PIN_HORZ);
    mode_PORTA_INPUT(JOYSTICK_PIN_VERT);
    DDRA = 0xFF;

    disable_LED(PORTL0);
    disable_LED(PORTL2);
    disable_LED(PORTL5);
    disable_LED(PORTL6);

    // Initialize tasks
    Task_Create(Task_ReadJoystick, 1, 0);
    Task_Create(Task_WriteBluetooth, 2, 0);

    Task_Create(Idle, 10, 0);

    // Kill the initialization task
    Task_Terminate();
}
Ejemplo n.º 2
0
void a_main(int parameter)
{
	/*
	//Place these as necessary to display output if not already doing so inside the RTOS
	//initialize pins
	DDRB |= (1<<PB1);	//pin 52
	DDRB |= (1<<PB2);	//pin 51	
	DDRB |= (1<<PB3);	//pin 50
	
	
	PORTB |= (1<<PB1);	//pin 52 on
	PORTB |= (1<<PB2);	//pin 51 on
	PORTB |= (1<<PB3);	//pin 50 on


	PORTB &= ~(1<<PB1);	//pin 52 off
	PORTB &= ~(1<<PB2);	//pin 51 off
	PORTB &= ~(1<<PB3);	//pin 50 off

	*/
	mut = Mutex_Init();
	evt = Event_Init();

	Task_Create(Task_P1, 1, 0);
	Task_Create(Task_P2, 2, 0);
	pid = Task_Create(Task_P3, 3, 0);
}
Ejemplo n.º 3
0
void a_main(){
    mut1 = Mutex_Init();
    mut2 = Mutex_Init();

    Task_Create(Task_P1, 1, 0);
    Task_Create(Task_P2, 2, 0);
    Task_Create(Task_P3, 3, 0);
}
Ejemplo n.º 4
0
void a_main(){
	DDRA |= (1<<PA0);
	DDRA |= (1<<PA1);
	DDRA |= (1<<PA2);
	DDRA |= (1<<PA3);
	PORTA &= ~(1<<PA0);
	PORTA &= ~(1<<PA1);
	PORTA &= ~(1<<PA2);
	PORTA &= ~(1<<PA3);
	e=Event_Init();
	Task_Create(Ping,1,0);
	Task_Create(Pong,1,0);
	Task_Terminate();
}
Ejemplo n.º 5
0
void a_main(){
    DDRB    = 0xF0;
    PORTB   = 0x00;

    mut = Mutex_Init();
    evt = Event_Init();

    _delay_ms(4000);

    Task_Create(Task_P1, 1, 0);
    Task_Create(Task_P2, 2, 0);
    Task_Create(Task_P3, 3, 0);
    Task_Create(Task_P4, 10, 0);
}
Ejemplo n.º 6
0
/* ======================================
   Name: 	main
   Description: 
   ====================================== */
int main(void)
{
  int   fd2fpDev0;
  int   ret;

  fd2fpDev0 = open( "/dev/test/fd2fp0", O_RDWR );
  printf("fd2fpDev0: fd %d\n", fd2fpDev0);

  task1 = Task_Create(FD2FP_Task1, NULL, 4096, TASK_PRIORITY, "FD2FP_TASK1", 0); 
  task2 = Task_Create(FD2FP_Task2, NULL, 4096, TASK_PRIORITY, "FD2FP_TASK2", 0); 
  task3 = Task_Create(FD2FP_Task3, NULL, 4096, TASK_PRIORITY, "FD2FP_TASK3", 0); 

  if( fd2fpDev0>=0 && fd2fpDev1>=0 && fd2fpDev2>=0 && fd2fpDev3>=0 )
  {
    ret = ioctl(fd2fpDev0, FD2FP_PASS_FD, &fd2fpDev1);
    ret = ioctl(fd2fpDev0, FD2FP_PASS_FD, &fd2fpDev2);
    ret = ioctl(fd2fpDev0, FD2FP_PASS_FD, &fd2fpDev3);

    ret = ioctl(fd2fpDev1, FD2FP_PASS_FD, &fd2fpDev0);
    ret = ioctl(fd2fpDev2, FD2FP_PASS_FD, &fd2fpDev0);
    ret = ioctl(fd2fpDev3, FD2FP_PASS_FD, &fd2fpDev0);

    ret = ioctl(fd2fpDev1, FD2FP_PASS_FD, &fd2fpDev1);
    ret = ioctl(fd2fpDev1, FD2FP_PASS_FD, &fd2fpDev2);
    ret = ioctl(fd2fpDev1, FD2FP_PASS_FD, &fd2fpDev3);
  }
  else
  {
    printf("Failed to open fd2fp dev.\n");
    return 1;
  }

  ret = close(fd2fpDev3);
  ret |= close(fd2fpDev2);
  ret |= close(fd2fpDev1);
  ret |= close(fd2fpDev0);
  printf( "ret = %08X\n", ret);

  printf("cancelling the task.\n");
  pthread_cancel(*task1);
  pthread_join(*task1, NULL);
  pthread_cancel(*task2);
  pthread_join(*task2, NULL);
  pthread_cancel(*task3);
  pthread_join(*task3, NULL);

  return 0;
}
void a_main()
{
    Task_Create(Task_P1, 1, 0);
    Task_Create(Task_P2, 2, 0);
    Task_Create(Idle, MINPRIORITY, 0);

    disable_LED(PORTL0);
    disable_LED(PORTL2);
    disable_LED(PORTL5);
    disable_LED(PORTL6);

    enable_LED(PORTL0);
    disable_LED(PORTL0);

    Task_Terminate();

}
Ejemplo n.º 8
0
void a_main() {
	DDRB = 0xF0;
	PORTB = 0x00;

	blink_increment = Event_Init();

	//1. Start Task_2
	Task_Create(Task_2, 0, 0);
}
Ejemplo n.º 9
0
int
main(int argc, char *argv[])
{
    motor_t rightMotor = {
        &PORTB, &DDRB, PORTB7, // PWM
        &PORTC, &DDRC, PORTC1, // Direction
        &OCR0A                 // Top value
    };
    
    motor_t leftMotor = {
        &PORTD, &DDRD, PORTD0, // PWM
        &PORTB, &DDRB, PORTB0, // Direction
        &OCR0B                 // Top value
    };
    
    //uint8_t sonarDistance = 0;
    
    cli();
    NO_CLK_PRESCALE();
    //uart_init();
    radio_init(HOV1_ADDRESS, RECEIVE_MODE);
    sonar_init();
    motorInit(&rightMotor);
    motorInit(&leftMotor);
    pwmInit();
    sei();
    
	stop = Event_Init();

    sendPing();
    while(!receivedInit);

    Task_Create((void*)(&motor_task),0, PERIODIC, MOTOR);
    Task_Create((void*)(&fire_sonar),0, PERIODIC, FIRE);
    Task_Create((void*)(&listen_sonar),0,PERIODIC, LISTEN);
    Task_Create((void*)(&sendRadio),0,PERIODIC, RADIO);
	Task_Create((void*)(&stopSystem), 0,SYSTEM, STOP); 
   
    setMotorDirection(&rightMotor, FORWARD);
    setMotorDirection(&leftMotor, FORWARD);
    
    return 0;
}
Ejemplo n.º 10
0
int r_main(void) {
	init();
	servoInit();

	pinMode(ONBOARD_LED, OUTPUT);
//	pinMode(4, OUTPUT);
	pinMode(9, OUTPUT);
	//pinMode(13, OUTPUT);
	Serial.begin(57600);
	//sonarInit();

//	digitalWrite( LEFT_MOTOR_PIN_1, 0 );
//	digitalWrite( LEFT_MOTOR_PIN_2, 1 );
//
//	digitalWrite( RIGHT_MOTOR_PIN_1, 0 );
//	digitalWrite( RIGHT_MOTOR_PIN_2, 1 );
//
//	analogWrite( LEFT_MOTOR_PIN_E, (int) (40));
//	analogWrite( RIGHT_MOTOR_PIN_E, (int) (40));
//	digitalWrite(13, LOW);
//	digitalWrite(12, HIGH);
//	while(true){
//analogWrite(4, 127);
//	}

	//pinMode(9, OUTPUT);
//while (1) {
	//analogWrite(9, 127);
	//digitalWrite(9, HIGH);
	//_delay_ms(50);
//analogWrite(9, 0);
//digitalWrite(9, LOW);
//}
//	radioInitSetup();

	Task_Create(task1, ONBOARD_LED_HIGH, PERIODIC, ONBOARD_LED_HIGH);
	Task_Create(task2, ONBOARD_LED_LOW, PERIODIC, ONBOARD_LED_LOW);
//	Task_Create(sonarTask, SONAR_TASK, PERIODIC, SONAR_TASK);
//	Task_Create(actuateTask, ACTUATE_TASK, PERIODIC, ACTUATE_TASK);
//	Task_Create(controlTask, CONTROL_TASK, PERIODIC, CONTROL_TASK);

	return 0;
}
void a_main()
{
    mut1 = Mutex_Init();

    task1 = Task_Create(Task_P1, 1, 0);
    task2 = Task_Create(Task_P2, 2, 0);
    task3 = Task_Create(Task_P3, 3, 0);
    Task_Create(Idle, MINPRIORITY, 0);

    disable_LED(PORTL0);
    disable_LED(PORTL2);
    disable_LED(PORTL5);
    disable_LED(PORTL6);

    enable_LED(PORTL0);
    disable_LED(PORTL0);

    Task_Terminate();

}
void a_main()
{
    mut = Mutex_Init();
    evt = Event_Init();

    Task_Create(Task_P1, 1, 0);
    Task_Create(Task_P2, 2, 0);
    Task_Create(Task_P3, 3, 0);
    Task_Create(Idle, 10, 0);

    disable_LED(PORTL0);
    disable_LED(PORTL2);
    disable_LED(PORTL5);
    disable_LED(PORTL6);

    enable_LED(PORTL0);
    disable_LED(PORTL0);

    Task_Terminate();

}
Ejemplo n.º 13
0
void Task_2() {
	//2. Create Task_1 which will signal Task_2
	Task_Create(Task_1, 1, 0);

	//3. Wait for signal, this will yield to the lower priority task_1
	Event_Wait(blink_increment);

	//6. Run the blink
	int i;
	for(i = 0; i<blinks; i++) {
		PORTB = 0x10;
	    _delay_ms(500);
	    PORTB = 0x00;
	    _delay_ms(500);	
	}

	//7.Terminate Task_2, continue to Task_1
	Task_Terminate();
}
Ejemplo n.º 14
0
void Task_1() {
	//4. Signal to Task_2 waiting on blink_increment
	Event_Signal(blink_increment);

	//8. Run and increment the blinks
	int i;
	for(i = 0; i<blinks; i++) {
		PORTB = 0x20;
	    _delay_ms(500);
	    PORTB = 0x00;
	    _delay_ms(500);
	}
	blinks++;

	//9. Create Task_2
	Task_Create(Task_2, 0, 0);
	
	//10. Terminate the task, restarting the loop at Task_2
	Task_Terminate();
}
Ejemplo n.º 15
0
/************************************************************************
 	 function:	Core_Init()

 	 description: Initializes the OS and all kernel objects

 	 parameters: N/A

 	 return:	 OS_OK - System ok, all objects were initialized.


 ************************************************************************/
os_error_t Core_Init(void)
{
	//Error variable:
	os_error_t xErr;

	//Initialize the tasks control blocks:
	Task_InitBlocks();

	//Queue Init

	//Mutex Init

	//Mailbox Init

	//Timers

	//Semaphores

	//Disable the OS:
	bOsEnable = OS_DIS;

	//reset the tick counter:
	dTickCounter = 0;

	//create Idle task:
	//Install tasks:
	xErr = Task_Create	((taskptr_t *) &Core_IdleTask,
						 (os_stack_t *)&axIdleTaskStack,
						 sizeof(axIdleTaskStack),
						 63,
						 (os_taskname_t *) "uLipeIdleTask");

	//check if all gone well:
	if(OS_OK != xErr)
	{
		return(OS_ERROR);
	}

	//return ok
	return(OS_OK);
}
Ejemplo n.º 16
0
int main(void)
{
    /* setup the test */
	uart_init();
	uart_write((uint8_t*)"\r\nSTART\r\n", 9);
    set_test(2);

    print_event = Event_Init();
      
   	Task_Create(generic_task, A, PERIODIC, A);
   	Task_Create(generic_task, B, PERIODIC, B);
   	Task_Create(generic_task, C, PERIODIC, C);
   	Task_Create(generic_task, D, PERIODIC, D);
	Task_Create(generic_task, E, PERIODIC, E);
	Task_Create(generic_task, F, PERIODIC, F);    

    Event_Wait(print_event);
    print_trace();
}
Ejemplo n.º 17
0
int main(void)
{
    /* setup the test */
	uart_init();
	uart_write((uint8_t*)"\r\nSTART\r\n", 9);
    set_test(3);

    print_event = Event_Init();

    Task_Create(generic_task, 1, RR, A);
    Task_Create(generic_task, 2, RR, B);
    Task_Create(generic_task, 3, RR, C);
    Task_Create(generic_task, 4, RR, D);
    Task_Create(generic_task, 5, RR, E);
    Task_Create(generic_task, 6, RR, F);

    Event_Wait(print_event);
    print_trace();
}
Ejemplo n.º 18
0
void a_main(){
	
	TESTING_INIT(TESTING_ALL);
	Task_Create(Task_P1, 1, 0);
	Task_Create(Task_P2, 1, 0);
}