Example #1
0
void adc_showTemp()
{
	t_print("Temp is ");
	t_print(getTemp());
	t_putc(248);
	t_print("C\n");
}
Example #2
0
void handleSatelites(char * gpgsv)
{
	char *argv[9];
	uint8_t argc = parseNMEA(gpgsv, argv, 9);

	if(argc < 8)
		return;

//	t_print(argv[2]);  //Satellites  in view
//	t_print(" ");
//	t_print(argv[3]);	//PRN number
//	t_print(" ");
	t_print(argv[4]);	//elivation
//	t_print(" ");
//	t_print(argv[5]);	//azimuth
//	t_print(" ");
//	t_print(argv[6]);	//SNR
	t_print("\n");
	if( t_atoi(argv[4]) > 1)
	{
		gpsOK = 1;
		GPIO_SetBits(GPIOC, GPIO_Pin_8);
	}
	else
	{
		gpsOK = 0;
		GPIO_ResetBits(GPIOC, GPIO_Pin_8);
	}
}
Example #3
0
void handleTime(char * gpgga)
{
	char *argv[7];
	uint8_t argc = parseNMEA(gpgga, argv, 7);

	if(argc < 5)
		return;

	argv[0][4] = 0;
	gpsMinute = t_atoi(&argv[0][2]);

	argv[0][2] = 0;
	gpsHour = t_atoi(argv[0]);

	static uint8_t flag = 0;
	if(flag)
		GPIO_ResetBits(GPIOC, GPIO_Pin_9);
	else
		GPIO_SetBits(GPIOC, GPIO_Pin_9);

	flag = !flag;

	d_print(gpsHour);
	t_print(":");
	d_print(gpsMinute);
	t_print("\n");
}
Example #4
0
int main(int argc, char* argv[])
{
    std::thread t_read(data_reading);
    std::thread t_print(data_printing);
    t_print.join();
    t_read.join();
}
Example #5
0
void rtc_setTime(char * argv[], int argc)
{


	if(argc > 4)
	{
		t_print("Setting time\n");

		mHour = t_atoi(argv[0]);
		mMinute = t_atoi(argv[1]);

		s_DateStructVar.Day = t_atoi(argv[2]);
		s_DateStructVar.Month = t_atoi(argv[3]);
		s_DateStructVar.Year = t_atoi(argv[4]);

		uint32_t CounterValue = ((mHour * 3600)+ (mMinute * 60));

		RTC_WaitForLastTask();
		RTC_SetCounter(CounterValue);
		RTC_WaitForLastTask();

		BKP_WriteBackupRegister(BKP_DR2,s_DateStructVar.Day);
		BKP_WriteBackupRegister(BKP_DR3,s_DateStructVar.Month);
		BKP_WriteBackupRegister(BKP_DR4,s_DateStructVar.Year);
	}
	else if(argc > 1)
	{
		mHour = t_atoi(argv[0]);
		mMinute = t_atoi(argv[1]);

		uint32_t CounterValue = ((mHour * 3600)+ (mMinute * 60));

		RTC_WaitForLastTask();
		RTC_SetCounter(CounterValue);
		RTC_WaitForLastTask();
	}

	t_print("Time: ");

	d_print(mHour);
	t_print(":");
	d_print(mMinute);
	t_print(":");
	d_print(mSecond);
	t_print(" ");
	d_print(s_DateStructVar.Day);
	t_print("-");
	d_print(s_DateStructVar.Month);
	t_print("-");
	d_print(s_DateStructVar.Year);
	t_print("\n");
}
Example #6
0
int
main(int argc, char *argv[])
{
  char *name = "as.txt";
  Text text = t_load_file(name);
  Piece p = text.head;
  Piece p_2 = p_load_file("bs.txt", p, NULL);
  int in_i = file_size(p->file);; /* 4 into second */

  t_print(text);
  
  Location location = p_location_of(text, in_i);
  Location d_loc = {
    .piece = p_2,
    .offset = 9 
  };
  e_delete(d_loc); 
  t_print(text);

  t_cleanup(text);
  return 0;
}
Example #7
0
void initRTC()
{

	mSecondsAlarm.AlarmCount = 0;
	mSecondsAlarm.AlarmInterval = 0;
	mSecondsAlarm.CurrentValue = 0;
	mSecondsAlarm.cb_func = 0;

	mMinutesAlarm.AlarmCount = 0;
	mMinutesAlarm.AlarmInterval = 0;
	mMinutesAlarm.CurrentValue = 0;
	mMinutesAlarm.cb_func = 0;

	mHoursAlarm.AlarmCount = 0;
	mHoursAlarm.AlarmInterval = 0;
	mHoursAlarm.CurrentValue = 0;
	mHoursAlarm.cb_func = 0;

	 /* Enable PWR and BKP clocks */
	  RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);

	  /* Allow access to BKP Domain */
	  PWR_BackupAccessCmd(ENABLE);



	if (BKP_ReadBackupRegister(BKP_DR1) != 0xA5A5)
	{
		/* Backup data register value is not correct or not yet programmed (when
		       the first time the program is executed) */

		t_print("Configuring RTC....\n");

		RTC_Configuration();

		BKP_WriteBackupRegister(BKP_DR1, 0xA5A5);
	}
	else
	{
		t_print("RTC has time....\n");

		s_DateStructVar.Day = BKP_ReadBackupRegister(BKP_DR2);
		s_DateStructVar.Month = BKP_ReadBackupRegister(BKP_DR3);
		s_DateStructVar.Year = BKP_ReadBackupRegister(BKP_DR4);

		CheckForDaysElapsed();
	}

	/* Wait for RTC registers synchronization */
	RTC_WaitForSynchro();

	/* Enable the RTC Second */
	RTC_ITConfig(RTC_IT_SEC, ENABLE);
	/* Wait until last write operation on RTC registers has finished */
	RTC_WaitForLastTask();

	/* Enable the RTC Interrupt */
	NVIC_InitTypeDef NVIC_InitStructure;
	NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQn;
	NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
	NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
	NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
	NVIC_Init(&NVIC_InitStructure);
}
Example #8
0
static int
twhich( char *pattern, int displayall )
{
    struct node		*node;
    struct transcript	*tran;
    extern struct transcript	*tran_head;
    extern struct list	*exclude_list;
    int			cmp = 0, match = 0;

    /* check exclude list */
    if ( exclude_list->l_count > 0 ) {
        for ( node = list_pop_head( exclude_list ); node != NULL;
                node = list_pop_head( exclude_list )) {
            if ( wildcard( node->n_path, pattern, case_sensitive )) {
                printf( "# Exclude\n" );
                printf( "# exclude pattern: %s\n", node->n_path );
                if ( !displayall ) {
                    goto done;
                }
            }
            free( node );
        }
    }

    for ( tran = tran_head; tran->t_next != NULL; tran = tran->t_next ) {

        /* Skip NULL/empty transcripts */
        if ( tran->t_eof ) {
            continue;
        }

        while (( cmp = pathcasecmp( tran->t_pinfo.pi_name,
                                    pattern, case_sensitive )) < 0 ) {
            transcript_parse( tran );
            if ( tran->t_eof ) {
                break;
            }
        }
        if ( tran->t_eof ) {
            continue;
        }

        if ( cmp > 0 ) {
            continue;
        }

        if ( cmp == 0 ) {
            match++;
            switch( tran->t_type ) {
            case T_POSITIVE:
                printf( "# Positive\n" );
                break;

            case T_NEGATIVE:
                printf( "# Negative\n" );
                break;

            case T_SPECIAL:
                printf( "# Special\n" );
                break;

            default:
                fprintf( stderr, "unknown transcript type\n" );
                exit( 2 );
            }
            printf( "# %s:\n", tran->t_kfile );

            if ( tran->t_pinfo.pi_minus ) {
                printf( "%s:\n", tran->t_shortname );
                t_print( NULL, tran, PR_STATUS_MINUS );
            } else {
                t_print( NULL, tran, PR_TRAN_ONLY );
            }

            if ( !displayall ) {
                goto done;
            }
        }
    }

done:
    if ( match ) {
        return( 0 );
    } else {
        return( 1 );
    }
}