/*
 *  ======== clockTask ========
 *  Wrapper function for TSK objects calling
 *  Clock::tick()
 */
void clockTask(UArg arg)
{   
    Clock *clock = (Clock *)arg;
    int count = 0;
   
    if (clock->getId() == 3) {
        for(;;) {             // task id = 3
            Semaphore_pend(sem0, BIOS_WAIT_FOREVER);
            clock->tick();
            if(count == 50) {
                Task_sleep(25);
                count = 0;
            } 
            count++;
            Semaphore_post(sem1);
        }
    }
    else {
        for(;;) {             // task id = 4
            Semaphore_pend(sem1, BIOS_WAIT_FOREVER);
            if(count == 50) {
                Task_sleep(25);
                count = 0;
            }   
            clock->tick();
            count++;
            Semaphore_post(sem0);
        }
    }
}
void sim800_send_sms(char * tx_buffer, int tx_size){
	char rxBuffer[SIM800_RXBUFFER_SIZE];

	 if(sim800_initialised  && !sim800_locked){
		sim800_locked = 1;

		UART_write(uart, sim800_at_smgf, sizeof(sim800_at_smgf));
		Task_sleep(500);

		UART_write(uart, sim800_at_smgs, strlen(sim800_at_smgs));
		Task_sleep(1000);

		UART_write(uart, tx_buffer, tx_size);
		Task_sleep(5000);

		memset(&rxBuffer, 0, sizeof(rxBuffer));
		UART_write(uart, sim800_ctrl_z, sizeof(sim800_ctrl_z));
		UART_read(uart, rxBuffer, sizeof(rxBuffer));
		serial_printf(cli_stdout, "sms:%s", rxBuffer);

		sim800_locked = 0;
	 }else{
		serial_printf(cli_stdout, "sim800 not initialised",0);
	}

}
void sim800_buffermessage_http(char * tx_buffer, int tx_size){
	if(!sim800_initialised){
		serial_printf(cli_stdout, "sim800 not initialised",0);
	}else{
		char rxBuffer[SIM800_RXBUFFER_SIZE];
		memset(&rxBuffer, 0, sizeof(rxBuffer));

		UART_write(uart, sim800_at_httpdata, sizeof(sim800_at_httpdata));
		Task_sleep(600);
		UART_write(uart, tx_buffer, tx_size);
		UART_read(uart, rxBuffer, sizeof(rxBuffer));
		serial_printf(cli_stdout, "%s", rxBuffer);


		Task_sleep(11000);
		UART_write(uart, sim800_at_httpaction, strlen(sim800_at_httpaction));

		Task_sleep(300);
		UART_write(uart, sim800_at_httpread, strlen(sim800_at_httpread));

		Task_sleep(300);
		UART_write(uart, sim800_at_httpterm, strlen(sim800_at_httpterm));
		UART_read(uart, rxBuffer, sizeof(rxBuffer));

	}
}
//must be called from within a task - this function will block!
//returns 1 if modem responds with OK
int sim800_begin(){
	char rxBuffer[SIM800_RXBUFFER_SIZE];
	memset(&rxBuffer, 0, sizeof(rxBuffer));

	if(sim800_open()){
		UART_write(uart, sim800_at_echo_off, sizeof(sim800_at_echo_off));
		UART_read(uart, rxBuffer, sizeof(rxBuffer));
		Task_sleep(500);

		memset(&rxBuffer, 0, sizeof(rxBuffer));
		UART_write(uart, sim800_at_echo_off, sizeof(sim800_at_echo_off));
		UART_read(uart, rxBuffer, sizeof(rxBuffer));

		serial_printf(cli_stdout, "%s", rxBuffer);
		Task_sleep(500);

		if(!strcmp("\r\nOK\r\n", rxBuffer)){
			sim800_initialised = 1;
			return 1; //modem can now communicate with us
		}else{
			return 0;
		}
	}else{
		return 0;
	}
}
Ejemplo n.º 5
0
Int32 Utils_tskDelete(Utils_TskHndl * pHndl)
{
    UInt32 sleepTime = 8;                                  /* in OS ticks */

    Utils_tskSendCmd(pHndl, UTILS_TSK_CMD_EXIT);

    /* wait for command to be received and task to be exited */

    Task_sleep(1);

    while (Task_Mode_TERMINATED != Task_getMode(pHndl->tsk))
    {

        Task_sleep(sleepTime);

        sleepTime >>= 1;

        if (sleepTime == 0)
        {
            char name[64];

            strcpy(name, "INVALID_TSK");
            Utils_prfGetTaskName(pHndl->tsk, name);
            Vps_printf("Task Delete Error!!!!!!, task %s not deleted\n", name);
            UTILS_assert(0);
        }
    }

    Utils_prfLoadUnRegister(pHndl->tsk);

    Task_delete(&pHndl->tsk);
    Utils_mbxDelete(&pHndl->mbx);

    return FVID2_SOK;
}
Ejemplo n.º 6
0
void display_on_matrix(uint32_t number)
{
	char str[10];
	sprintf(str, "%d", number);
	int i = 0;
	for(i=0; str[i]!='\0';i++)
	{
		turnOffAllLeds();
		Task_sleep(300);
		displayChar(str[i]);
		Task_sleep(300);
	}
}
Ejemplo n.º 7
0
Void radioTask(UArg arg0, UArg arg1){

	GPIO_write(MSP_OCT1_432P401RLP_5V_EN, 1);
	GPIO_write(MSP_OCT1_432P401RLP_HX1_EN, 1);

	while(true){
		GPIO_write(MSP_OCT1_432P401RLP_HX1_TX, 1);
		Task_sleep(1000);
		GPIO_write(MSP_OCT1_432P401RLP_HX1_TX, 0);

		Task_sleep(3000);
	}
}
Ejemplo n.º 8
0
void blink_led(uint8_t x, uint8_t y, uint8_t z){
	// Turn on
	//Input for Latches Port1-8
	GPIOPinWrite(GPIO_PORTG_BASE,GPIO_PIN_0,x);
	GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_1 |GPIO_PIN_2 |GPIO_PIN_3 |GPIO_PIN_4 |GPIO_PIN_5 |GPIO_PIN_6 |GPIO_PIN_7,x);
	Task_sleep(SLEEP_TIME);
	// CS latches Port11-18
	GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_0 |GPIO_PIN_1 |GPIO_PIN_2 |GPIO_PIN_3 |GPIO_PIN_4 |GPIO_PIN_5 |GPIO_PIN_6 |GPIO_PIN_7,y);
	Task_sleep(SLEEP_TIME);
	GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_0 |GPIO_PIN_1 |GPIO_PIN_2 |GPIO_PIN_3 |GPIO_PIN_4 |GPIO_PIN_5 |GPIO_PIN_6 |GPIO_PIN_7,0);
	Task_sleep(SLEEP_TIME);
	//Anode Port21-28
	GPIOPinWrite(GPIO_PORTK_BASE,GPIO_PIN_0 |GPIO_PIN_1 |GPIO_PIN_2 |GPIO_PIN_3 |GPIO_PIN_4 |GPIO_PIN_5 |GPIO_PIN_6 |GPIO_PIN_7,z);
	Task_sleep(SLEEP_TIME);
	//Turn off
	//Zero all latches
	GPIOPinWrite(GPIO_PORTG_BASE,GPIO_PIN_0,0);
	GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_1 |GPIO_PIN_2 |GPIO_PIN_3 |GPIO_PIN_4 |GPIO_PIN_5 |GPIO_PIN_6 |GPIO_PIN_7,0);
	Task_sleep(SLEEP_TIME);
	//Select all latches
	GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_0 |GPIO_PIN_1 |GPIO_PIN_2 |GPIO_PIN_3 |GPIO_PIN_4 |GPIO_PIN_5 |GPIO_PIN_6 |GPIO_PIN_7,0xFF);
	Task_sleep(SLEEP_TIME);
	GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_0 |GPIO_PIN_1 |GPIO_PIN_2 |GPIO_PIN_3 |GPIO_PIN_4 |GPIO_PIN_5 |GPIO_PIN_6 |GPIO_PIN_7,0);
	Task_sleep(SLEEP_TIME);
	GPIOPinWrite(GPIO_PORTK_BASE,GPIO_PIN_0 |GPIO_PIN_1 |GPIO_PIN_2 |GPIO_PIN_3 |GPIO_PIN_4 |GPIO_PIN_5 |GPIO_PIN_6 |GPIO_PIN_7,0);
	Task_sleep(SLEEP_TIME);


}
Ejemplo n.º 9
0
int
_clip_setlock(ClipMachine * ClipMachineMemory, long hash, int fd, off_t pos, int flags)
{
   int ok = 0;

   struct flock fl;

   fl.l_type = (flags & CLIP_LOCK_WRITE) ? F_WRLCK : F_RDLCK;
   fl.l_whence = SEEK_SET;
   fl.l_start = pos;
   fl.l_len = (flags & CLIP_LOCK_FLOCK) ? pos - 1 : 1;

   while (1)
   {
      if (fl.l_type == F_WRLCK)
	 ok = _clip_wrlock(ClipMachineMemory->tasklocks, hash, fd, &fl, !(flags & CLIP_LOCK_HILEVEL));
      else
	 ok = _clip_rdlock(ClipMachineMemory->tasklocks, hash, fd, &fl, !(flags & CLIP_LOCK_HILEVEL));

      if (ok || !(flags & CLIP_LOCK_WAIT))
	 break;
#ifdef USE_TASKS
      Task_sleep(1);
#else
      usleep(1);
#endif
   }
   return !ok;
}
Ejemplo n.º 10
0
Void appTaskFxn(UArg arg0, UArg arg1)
{
	char* args[8];
	//arg[0] is 2 chars for dev type
	args[0] = Memory_alloc(NULL, 2 * sizeof(char), 0, NULL);
	//arg[1] is 3 chars for channel num
	args[1] = Memory_alloc(NULL, 3 * sizeof(char), 0, NULL);

	//init the RPC queue
	rpcInitMq();

	//init the application thread to register the callbacks
	appInit();

	consolePrint(
	        "Enter device type c: Coordinator, r: Router, e: End Device:\n");
	consoleGetLine(args[0], 8);

	consolePrint("Enter channel 11-26:\n");
	consoleGetLine(args[1], 8);

	while (1)
	{
		appProcess(args);
		Task_sleep(10);
	}

	Memory_free(NULL, args[0], 2 * sizeof(char));
	Memory_free(NULL, args[1], 3 * sizeof(char));
}
Ejemplo n.º 11
0
Void Dsp_AppTask (UArg arg1, UArg arg2)
{
  OMX_ERRORTYPE eError = OMX_ErrorNone;
  //TIMM_OSAL_ERRORTYPE osalError = TIMM_OSAL_ERR_NONE;

  /*--------------------------------------------------------------------------*/
  /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  /* Initiailize the system. The initialization can include driver, syslink */
  /* cache.  */
  /*--------------------------------------------------------------------------*/
  Log_print0 (Diags_USER1,"DSP: In Dsp_AppTask");
  platform_init ();
  Log_print0 (Diags_USER1,"DSP: Platform Initialized");

  while (TRUE)
  {
    Task_sleep (DSP_APP_TASK_SLEEP_DURATION);
  }

  /*--------------------------------------------------------------------------*/
  /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  /* UnInitiailize the system.  */
  /*--------------------------------------------------------------------------*/
  platform_deinit ();
  Log_print0 (Diags_USER1,"DSP: Platform De-Initialized");

  Log_print0 (Diags_USER1,"DSP: Exiting the system");
  System_exit (0);

//EXIT:
  if (eError != OMX_ErrorNone)
  {
    Log_print1 (Diags_USER1,"Error in executing app. Failed code:%d", eError);
  }
}                               /* Dsp_AppTask */
void sim800_init_http(SIM800_MIME mime_type){
	if(!sim800_initialised){
		serial_printf(cli_stdout, "sim800 not initialised",0);
	}else{
		char rxBuffer[SIM800_RXBUFFER_SIZE];
		int i;

		const char *init_http_cmdseq[] = {
			sim800_at_sapbr_apn,
			sim800_at_sapbr,
			sim800_at_httpinit,
			sim800_at_httppara_url,
			sim800_at_httppara_cid,
			""
		};

		//set selected mime type
		if(mime_type == MIME_OCTET_STREAM){
			init_http_cmdseq[5] = sim800_at_httppara_content_stream;
		}else{
			init_http_cmdseq[5] = sim800_at_httppara_content_text;
		}


		for(i=0; i<6; i++){
			memset(&rxBuffer, 0, sizeof(rxBuffer));
			UART_write(uart, init_http_cmdseq[i], strlen(init_http_cmdseq[i]));
			UART_read(uart, rxBuffer, sizeof(rxBuffer));
			Task_sleep(200);
		}


	}
}
Ejemplo n.º 13
0
int usleep(useconds_t usec)
{
	// tall TI-RTOS sleep task
	Task_sleep(usec / Clock_tickPeriod);

	return 0;
}
Ejemplo n.º 14
0
Void Ducati_AppTask (UArg arg1, UArg arg2)
{
	FCSettings_init();
	Diags_setMask(FCSETTINGS_MODNAME"+12345678LEXAIZFS");
	CESettings_init();
	Diags_setMask(CESETTINGS_MODNAME"+12345678LEXAIZFS");
//	Diags_setMask("ti.sdo.rcm.RcmServer-12");
//	Diags_setMask("ti.sysbios.utils.Load-4");

    init_IVAHDFrwk();
    HDVICP_Reset(NULL, NULL);
    platform_init();

    /* how do we know when to unload.. */
    while (1) {
        Task_sleep(0x7fffffff);
    }

    /*The test cases will run in this task's context in the init call.
    Once init returns, testcases have exited so do deinit*/
    platform_deinit();

    exit_IVAHDFrwk();

    System_exit(0);
}
Ejemplo n.º 15
0
/*
 *  ======== heartBeatFxn ========
 *  Toggle the Board_LED0. The Task_sleep is determined by arg0 which
 *  is configured for the heartBeat Task instance.
 */
Void heartBeatFxn(UArg arg0, UArg arg1)
{
    while (1) {
        Task_sleep((unsigned int)arg0);
        GPIO_toggle(Board_LED0);
    }
}
Ejemplo n.º 16
0
Void Task_PWM(UArg arg0, UArg arg1)
{
    PWM_Handle pwm[3];
    PWM_Params params;
    uint16_t   period=1500;
    uint16_t   duty[3]={0, };

    PWM_Params_init(&params);
    params.period = period; //ms
    //params.polarity = PWM_POL_ACTIVE_LOW;
    params.polarity = PWM_POL_ACTIVE_HIGH;
    //params.dutyMode = PWM_DUTY_COUNTS; 
    params.dutyMode = PWM_DUTY_SCALAR;
    //params.dutyMode = PWM_DUTY_TIME:;
    pwm[0] = PWM_open(Board_PWM0, &params);
    pwm[1] = PWM_open(EK_TM4C1294XL_Mk_PF1_M0PWM1, &params);    
    pwm[2] = PWM_open(EK_TM4C1294XL_Mk_PF2_M0PWM2, &params);   
    
    System_printf("\nTask_PWM");
    for (;;) {
        PWM_setDuty(pwm[0], duty[0]);
        PWM_setDuty(pwm[1], duty[1]);
        PWM_setDuty(pwm[2], duty[2]);
        
        duty[0]+=0xf;
        duty[1]=duty[0]+0xff;
        duty[2]=duty[1]+0xff;
        
        Task_sleep(1); //One Tick is 1ms
    }    
}
Ejemplo n.º 17
0
void sdEscreve(char *conteudo, int tamanho) {
	SDSPI_Handle sdspiHandle;
	SDSPI_Params sdspiParams;
	FILE *src;
	const char outputfile[] = "fat:"STR(SD_DRIVE_NUM)":input.txt";

	/* Mount and register the SD Card */
	SDSPI_Params_init(&sdspiParams);
	sdspiHandle = SDSPI_open(Board_SDSPI0, SD_DRIVE_NUM, &sdspiParams);
	if (sdspiHandle == NULL) {
		printf("Erro ao iniciar o SD card!\n");
		return;
	}
//	else {
//		printf("Drive %u montado!\n", SD_DRIVE_NUM);
//	}
	/* Tenta abrir o arquivo */
	src = fopen(outputfile, "ab");
	if (!src) {
		printf("Nao foi possivel criar o arquivo!\n");
		Task_sleep(1);
		SDSPI_close(sdspiHandle);
		return;
	} else {
		printf("Arquivo criado!\n\n");
		/*  escreve do arquivo */
		fputs(conteudo, src);
		//fflush(src);
		fclose(src);
	}
	SDSPI_close(sdspiHandle);
}
Ejemplo n.º 18
0
bool sdApaga(char *nome) {

	SDSPI_Handle sdspiHandle;
	SDSPI_Params sdspiParams;

	char arquivo[20] = "fat:"STR(SD_DRIVE_NUM)":";

	strcat(arquivo, nome);
	strcat(arquivo, ".txt");

	/* Mount and register the SD Card */
	SDSPI_Params_init(&sdspiParams);
	sdspiHandle = SDSPI_open(Board_SDSPI0, SD_DRIVE_NUM, &sdspiParams);
	if (sdspiHandle == NULL) {
		printf("Erro ao iniciar o SD card!\n");
		return false;
	}
	if (remove(arquivo) != 0) {
		printf("Nao foi possivel apagar o arquivo!\n");
		Task_sleep(10);
		SDSPI_close(sdspiHandle);
		return false;
	} else {
		printf("\t\tArquivo apagado!\n");
	}
	SDSPI_close(sdspiHandle);
	return true;
}
Ejemplo n.º 19
0
/*
 *  ======== heartBeatFxn ========
 *  Toggle the Board_LED0. The Task_sleep is determined by arg0 which
 *  is configured for the heartBeat Task instance.
 */
Void heartBeatFxn(UArg arg0, UArg arg1)
{
    while (1) {
        Task_sleep((UInt)arg0);
        //PIN_setOutputValue(ledPinHandle, Board_LED0,
          //                 !PIN_getOutputValue(Board_LED0));
    }
}
Ejemplo n.º 20
0
/*
 *  ======== taskFxn ========
 */
Void taskFxn(UArg a0, UArg a1)
{
    System_printf("enter taskFxn()\n");
	
    Task_sleep(10);
	
    System_printf("exit taskFxn()\n");
}
Ejemplo n.º 21
0
void ReadLightFn () {
	while(1){
		//Get the up to date light value.
		ReadLightW(LightSema, &lightPtr);
		Task_sleep(2);
	}

}
Ejemplo n.º 22
0
Void appInMessageFxn(UArg arg0, UArg arg1)
{
	while (1)
	{
		appMsgProcess(NULL);
		Task_sleep(10);
	}
}
Ejemplo n.º 23
0
Void Task_GPIO(UArg arg0, UArg arg1)
{
    System_printf("\nTask_GPIO");
    for (;;) {
        GPIO_toggle(EK_TM4C1294XL_Mk_DO_PN4);   
        Task_sleep(200); //One Tick is 1ms
    }
}
Ejemplo n.º 24
0
Archivo: ssc.c Proyecto: ArakniD/dynawa
void SSC_Open(AT91S_SSC *ssc, unsigned int id) {
    // Enable SSC peripheral clock
    AT91C_BASE_PMC->PMC_PCER = 1 << id;

    // Reset, disable receiver & transmitter
    ssc->SSC_CR = AT91C_SSC_RXDIS | AT91C_SSC_TXDIS | AT91C_SSC_SWRST;
    Task_sleep(10);
    ssc->SSC_PTCR = AT91C_PDC_RXTDIS | AT91C_PDC_TXTDIS;
}
Ejemplo n.º 25
0
/* ========================================================================== */
TIMM_OSAL_ERRORTYPE TIMM_OSAL_SleepTask (TIMM_OSAL_U32 mSec)
{
    TIMM_OSAL_U32 ticks = 0;

	ticks = _TIMM_OSAL_GetTicks(mSec);
    Task_sleep(ticks);
    
    return TIMM_OSAL_ERR_NONE;
}
Void cycleLED(UArg arg0, UArg arg1)
{
    unsigned int    i = 0;
    uint8_t         writeBuffer[4];
    I2C_Handle      handle;
    I2C_Params      i2cparams;
    I2C_Transaction i2c;

    I2C_Params_init(&i2cparams);
    i2cparams.bitRate = I2C_400kHz;
    handle = I2C_open(Board_I2C_TPL0401, &i2cparams);
    if (handle == NULL) {
        System_abort("I2C was not opened");
    }

    i2c.slaveAddress = Board_TPL0401_ADDR;
    i2c.readCount = 0;
    i2c.readBuf = NULL;
    i2c.writeBuf = writeBuffer;

    /* Enable the PWM oscillator */
    writeBuffer[0] = 0x00;
    writeBuffer[1] = 0x81;
    i2c.writeCount = 2;
    if (!I2C_transfer(handle, &i2c)) {
        GPIO_write(Board_LED1, Board_LED_ON);
        System_abort("Bad I2C transfer!");
    }

    /* Bring the LEDs into PWM mode */
    writeBuffer[0] = 0x8C;
    writeBuffer[1] = 0xAA;
    writeBuffer[2] = 0xAA;
    i2c.writeCount = 3;
    if (!I2C_transfer(handle, &i2c)) {
        GPIO_write(Board_LED1, Board_LED_ON);
        System_abort("Bad I2C transfer!");
    }

    i2c.writeCount = 4;
    while (true) {
        /* Point to the new LED pattern */
        i2c.writeBuf = (uint8_t *) &(rgbcmd[i]);

        if (!I2C_transfer(handle, &i2c)) {
            GPIO_write(Board_LED1, Board_LED_ON);
            System_abort("Bad I2C transfer!");
        }

        /* Reached the end of the RGB patterns; reset index */
        if (rgbcmd[++i].LED == 0x00) {
            i = 0;
        }
        Task_sleep(100);
    }
}
/*
 *  ======== tsk0Fxn ========
 *  Statically created task
 */
Void tsk0Fxn(UArg arg0, UArg arg1)
{
    Int num = 0;

    /* To demonstrate the exchange function */
    while (TRUE) {
        Log_iwriteUC1(logger0, LoggerStreamer2_L_test, num++);
        Task_sleep(1);
    }
}
Ejemplo n.º 28
0
static gint
__idle_task_yield(gpointer data)
{
	Task_sleep(10);
	while (gtk_events_pending())
		gtk_main_iteration();
	while (gtk_events_pending())
		gtk_main_iteration();
	return 1;
}
Ejemplo n.º 29
0
/*
 *  ======== sleep ========
 */
unsigned sleep(unsigned seconds)
{
    unsigned long timeout;

    timeout = ((unsigned long)seconds * 1000000L) / Clock_tickPeriod;

    Task_sleep((UInt32)timeout);

    return (0);
}
/*
 *  ======== tsk1Fxn ========
 *  Statically created task
 */
Void tsk1Fxn(UArg arg0, UArg arg1)
{
    Int num = 0;

    /* To demonstrate the exchange function */
    while (TRUE) {
        Log_iprintUC1(logger1, "Num = %d", num++);
        Task_sleep(1);
    }
}