Beispiel #1
0
int main (void)
{
	// Initialize everything
	initAll();

	xprintf("Startup!");


#ifdef GENERATE_ASCII_RANDOM_BITS

	uint32_t i,j;
	uint32_t n;
	for (i=0; i<NUMBER_OF_RANDOM_WORDS; i++)
	{
		n = TM_RNG_Get();
		//while (n) {
		for (j=0; j<32; j++)
		{
		    if (n & 1)
		        xprintf("1");
		    else
		        xprintf("0");

		    n >>= 1;
		}
	}

#endif

#ifdef GENERATE_BINARY_RANDOM_BITS
	uint32_t i=0;
	uint32_t n;
	for (i=0; i<NUMBER_OF_RANDOM_WORDS; i++)
	{
		//xprintf(".");
		n = TM_RNG_Get();
		xprintf("%c%c%c%c",(n&0xff),((n>>8)&0xff),((n>>16)&0xff),((n>>24)&0xff));
	}
#endif

#ifdef PERFORM_UNIT_TESTS
	perform_unit_tests();
#endif

#ifdef PERFORM_SPEED_TESTS
	speed_test();
#endif

	xputs("[Done]\n\n");

	while (1)
	{
	}

	return 0;
}
Beispiel #2
0
void TM_SNAKE_Random(int8_t* twobytesarray) {
	float temp;
	
	/* Generate first random number */
	temp = (float)TM_RNG_Get() / (float)0xFFFFFFFF * (SNAKE_PIXELS - 1);
	twobytesarray[0] = (int8_t)temp;
	
	/* Generate second random number */
	temp = (float)TM_RNG_Get() / (float)0xFFFFFFFF * (SNAKE_PIXELS - 1);
	twobytesarray[1] = (int8_t)temp;
}
Beispiel #3
0
int main(void) {
    char buffer[20];

    /* Initialize system */
    SystemInit();

    /* Initialize delay */
    TM_DELAY_Init();

    /* Initialize USART1, TX: PB6 */
    TM_USART_Init(USART1, TM_USART_PinsPack_2, 115200);

    /* Initialize random number generator */
    TM_RNG_Init();

    while (1) {
        /* Get number */
        sprintf(buffer, "Number: %u\n", TM_RNG_Get());
        /* Put to USART */
        TM_USART_Puts(USART1, buffer);
        Delayms(1000);
    }
}