Пример #1
0
int main(void) {
	char buff[100];
	
	/* Init system clock for maximum system speed */
	TM_RCC_InitSystem();
	
	/* Init HAL layer */
	HAL_Init();
	
	/* Init leds */
	TM_DISCO_LedInit();
	
	/* Init LCD */
	TM_LCD_Init();

	/* Display fixes */
#if defined(STM32F7_DISCOVERY)
	TM_LCD_SetFont(&TM_Font_7x10);
#elif defined(STM32F429_DISCOVERY)
	TM_LCD_SetFont(&TM_Font_7x10);
	TM_LCD_SetOrientation(3);
#endif
	
	/* Format unique ID */
	sprintf(buff, "Unique ID: 0x%08X 0x%08X 0x%08X", TM_ID_GetUnique32(0), TM_ID_GetUnique32(1), TM_ID_GetUnique32(2));
	TM_LCD_SetXY(10, 10);
	TM_LCD_Puts(buff);
	
	/* Format device signature */
	sprintf(buff, "Device signature: 0x%04X", TM_ID_GetSignature());
	TM_LCD_SetXY(10, 30);
	TM_LCD_Puts(buff);
	
	/* Format revision */
	sprintf(buff, "Revision: 0x%04X", TM_ID_GetRevision());
	TM_LCD_SetXY(10, 50);
	TM_LCD_Puts(buff);
	
	/* Format package */
	sprintf(buff, "Package: 0x%04X", TM_ID_GetPackage());
	TM_LCD_SetXY(10, 70);
	TM_LCD_Puts(buff);
	
	/* Format flash size */
	sprintf(buff, "Flash size: %04d kBytes", TM_ID_GetFlashSize());
	TM_LCD_SetXY(10, 90);
	TM_LCD_Puts(buff);

	while (1) {

	}
}
Пример #2
0
uint8_t TM_FATFS_SearchCallback(char* path, uint8_t is_file, TM_FATFS_Search_t* FindStructure) {
	/* Print on LCD */
	TM_LCD_Puts(path);
	
	/* Delete file on card */
	if (f_unlink(path) == FR_OK) {
		TM_LCD_Puts("; Delete OK!");
	} else {
		TM_LCD_Puts("; Delete Error!");
	}
	
	/* Go to new line */
	TM_LCD_Putc('\n');
	
	/* Allow next search */
	return 1;
}
Пример #3
0
int main(void) {
	uint8_t i;
	
	/* Init system clock for maximum system speed */
	TM_RCC_InitSystem();
	
	/* Init HAL layer */
	HAL_Init();
	
	/* Init leds */
	TM_DISCO_LedInit();
	
	/* Init delay functions */
	TM_DELAY_Init();
	
	/* Init LCD */
	TM_LCD_Init();
	
	/* Fill LCD with color */
	TM_LCD_Fill(0xFFFF);
	
	/* Set custom orientation for LCD */
	TM_LCD_SetOrientation(1);
	
	/* Get orientation from LCD and save to Touch Screen structure */
	TS.Orientation = TM_LCD_GetOrientation();
	
	/* Init touch, use default drivers, depends on defines in library */
	/* Check library description for more information */
	TM_TOUCH_Init(NULL, &TS);
	
	while (1) {
		/* Read touch */
		TM_TOUCH_Read(&TS);
		
		/* Check if pressed */
		if (TS.NumPresses) {
			/* Go through all presses on LCD */
			for (i = 0; i < TS.NumPresses; i++) {
				/* Draw circle */
				TM_LCD_DrawFilledCircle(TS.X[i], TS.Y[i], 5, TOUCH_Colors[i]);
				
				/* Format string */
				sprintf(str, "X: %3d Y: %3d", TS.X[i], TS.Y[i]);
				
				/* Print on LCD */
				TM_LCD_SetXY(10, 10 + i * 20);
				TM_LCD_Puts(str);
			}
		}
		
		Delayms(5);
	}
}
Пример #4
0
int main(void) {
#ifdef CREATE_FILES
	uint8_t i = 10;
#endif
	
	/* Init system clock for maximum system speed */
	TM_RCC_InitSystem();
	
	/* Init HAL layer */
	HAL_Init();
	
	/* Init leds */
	TM_DISCO_LedInit();
	
	/* Init LCD */
	TM_LCD_Init();
	
	/* Set font */
	TM_LCD_SetFont(&TM_Font_7x10);
	
	/* Set start position */
	TM_LCD_SetXY(5, 5);
	
	/* Try to mount card */
	if ((fres = f_mount(&FS, "SD:", 1)) == FR_OK) {
#ifdef CREATE_FILES
		/* Create 10 fake files */
		while (i--) {
			/* Format path */
			sprintf(buffer, "SD:/file_%d.txt", i);
			
			/* open file */
			f_open(&fil, buffer, FA_OPEN_ALWAYS | FA_WRITE | FA_WRITE);
			
			/* Put some text */
			f_puts("Test file content!", &fil);
			
			/* Close file */
			f_close(&fil);
		}
#endif
		
		/* Make a search on files */
		if ((fres = TM_FATFS_Search("SD:", buffer, sizeof(buffer), &Files)) == FR_OK) {
			/* Search was OK */
			
			/* Format string */
			sprintf(buffer, "Search OK! Num of files: %d; Num of folders: %d\n", Files.FilesCount, Files.FoldersCount);
			
			/* Send on LCD */
			TM_LCD_Puts(buffer);
		} else {
			/* Error, probably buffer is too small for all sub folders */
			TM_LCD_Puts("Search error!\n");
		}
		
		/* Unmount SDCARD */
		f_mount(NULL, "SD:", 1);
	}
	
	/* Do nothing */
	while (1) {
		
	}
}
Пример #5
0
int main(void) {
	uint32_t i = 0, freq = 0;
	
	/* Init system clock for maximum system speed */
	TM_RCC_InitSystem();
	
	/* Init HAL layer */
	HAL_Init();	
	
	/* Init LCD */
	TM_LCD_Init();

#if defined(STM32F429_DISCOVERY)
	/* Rotate LCD to landscape mode */
	TM_LCD_SetOrientation(2);
#endif
	
	/* Print on LCD */
	TM_LCD_SetXY(10, 10);
	TM_LCD_Puts("FFT Library example");
	TM_LCD_SetXY(10, 30);
	TM_LCD_Puts("with software generated");
	TM_LCD_SetXY(10, 50);
	TM_LCD_Puts("SINE wave");
	
	/* Print "logo" */
	TM_LCD_SetFont(&TM_Font_7x10);
	TM_LCD_SetXY(30, TM_LCD_GetHeight() - 15);
	TM_LCD_Puts("stm32f4-discovery.net");
	
	/* Init FFT, FFT_SIZE define is used for FFT_SIZE, samples count is FFT_SIZE * 2, don't use malloc for memory allocation */
	TM_FFT_Init_F32(&FFT, FFT_SIZE, 0);
	
	/* We didn't used malloc for allocation, so we have to set pointers ourself */
	/* Input buffer must be 2 * FFT_SIZE in length because of real and imaginary part */
	/* Output buffer must be FFT_SIZE in length */
	TM_FFT_SetBuffers_F32(&FFT, Input, Output);
	
	while (1) {
		/* Let's fake sinus signal with 5, 15 and 30Hz frequencies */
		do {
			/* Calculate sinus value */
			sin_val = 0;
			sin_val += (float)0.5 * (float)sin((float)2 * (float)3.14159265359 * (float)1 * (float)freq * (float)i / (float)(FFT_SIZE / 2));
			sin_val += (float)0.3 * (float)sin((float)2 * (float)3.14159265359 * (float)2 * (float)freq * (float)i / (float)(FFT_SIZE / 2));
			sin_val += (float)0.1 * (float)sin((float)2 * (float)3.14159265359 * (float)3 * (float)freq * (float)i / (float)(FFT_SIZE / 2));
			
			i++;
		} while (!TM_FFT_AddToBuffer(&FFT, sin_val));
			
		/* Do FFT on signal, values at each bin and calculate max value and index where max value happened */
		TM_FFT_Process_F32(&FFT);

		/* Display data on LCD, only single sided spectrum of FFT */
		for (i = 0; i < (TM_FFT_GetFFTSize(&FFT) / 2); i++) {
			/* Draw FFT results */
			DrawBar(30 + 2 * i,
					TM_LCD_GetHeight() - 30,
					FFT_BAR_MAX_HEIGHT,
					TM_FFT_GetMaxValue(&FFT),
					TM_FFT_GetFromBuffer(&FFT, i),
					0x1234,
					0xFFFF
			);
		}
		
		/* Increase frequency */
		freq++;
		
		/* Check value */
		if (freq > 100) {
			freq = 0;
		}
		
		/* Little delay */
		Delayms(50);
	}
}