- if (++lcd_brightness > LCD_BACKLIGHT_MAX)
- lcd_brightness = 0;
- lcd_setBacklight(lcd_brightness);
- }
- }
-}
-
-
-static void NORETURN soft_reset(Bitmap * bm)
-{
- int i;
-
- gfx_bitmapClear(bm);
- for (i = 5; i; --i)
- {
- text_xprintf(bm, 2, 0, TEXT_FILL | TEXT_CENTER, "%d", i);
- lcd_hx8347_blitBitmap(bm);
- timer_delay(1000);
- }
- text_xprintf(bm, 2, 0, TEXT_FILL | TEXT_CENTER, "REBOOT");
- lcd_hx8347_blitBitmap(bm);
- timer_delay(1000);
-
- /* Perform a software reset request */
- HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | NVIC_APINT_SYSRESETREQ;
- UNREACHABLE();
-}
-
-static void read_adc(Bitmap *bm)
-{
- gfx_bitmapClear(bm);
- text_xprintf(bm, 0, 0, TEXT_FILL | TEXT_CENTER, "ADC Value");
- while (1)
- {
- uint16_t value = ADC_RANGECONV(adc_read(1), 0, 3300);
- uint16_t temp = hw_convertToDegree (adc_read(ADC_TEMPERATURE_CH));
-
- text_xprintf(&lcd_bitmap, 2, 0, TEXT_FILL | TEXT_CENTER,
- "Voltage on VR1: %d.%dV", value / 1000, value % 1000);
- text_xprintf(&lcd_bitmap, 3, 0, TEXT_FILL | TEXT_CENTER,
- "CPU temperature: %d.%dC", temp / 10, temp % 10);
- lcd_hx8347_blitBitmap(bm);
- timer_delay(400);
- if (kbd_peek() & KEY_MASK)
- break;
- }
-}
-#define FILE_NAME "outfile.wav"
-#define ACQ_FILE_NAME FILE_NAME
-
-
-uint8_t tmp[4096];
-
-// SD fat filesystem context
-FATFS fs;
-FatFile log_file;
-FatFile acq_file;
-
-
-
-static int wav_check(KFile *fd)
-{
-
- WavHdr header;
-
- if (kfile_read(fd, &header, sizeof(header)) != sizeof(header))
- {
- kputs("Error reading wave file header\n");
- return EOF;
- }
-
- if (strncmp(header.chunk_id, "RIFF", 4))
- {
- kputs("RIFF tag not found\n");
- goto error;
- }
-
- if (strncmp(header.format, "WAVE", 4))
- {
- kputs("WAVE tag not found\n");
- goto error;
- }
-
- if (le16_to_cpu(header.audio_format) != 1)
- {
- kprintf("Audio format not valid, found [%d]\n", le16_to_cpu(header.audio_format));
- goto error;
- }
-
- if (le16_to_cpu(header.num_channels) != 2)
- {
- kprintf("Channels number not valid, found [%d]\n", le16_to_cpu(header.num_channels));
- goto error;
- }
-
-
- if (le32_to_cpu(header.sample_rate) != 44100)
- {
- kprintf("Sample rate not valid, found [%ld]\n", le32_to_cpu(header.sample_rate));
- goto error;
- }