├── GBCamcorder ├── .cproject ├── .project ├── GBCamcorder.pdsprj ├── README.md ├── Release │ └── GBCamcorder.bin ├── bitmaps │ ├── icon_camnok.bmp │ ├── icon_camok.bmp │ ├── icon_rec.bmp │ ├── icon_sdnok.bmp │ ├── icon_sdok.bmp │ └── logo.bmp ├── case │ ├── shell1.SLDPRT │ └── shell1.STL ├── converter │ ├── Makefile.win │ ├── avi.c │ ├── avi.h │ ├── converter.dev │ ├── converter.exe │ ├── converter_private.h │ ├── converter_private.rc │ ├── converter_private.res │ └── main.c ├── schematic.pdf └── src │ ├── LPC13xx.h │ ├── about.c │ ├── capture.c │ ├── capture.h │ ├── colors.c │ ├── colors.h │ ├── core_cm3.c │ ├── core_cm3.h │ ├── cr_startup_lpc13xx.c │ ├── crp.c │ ├── diskio.h │ ├── ff.c │ ├── ff.h │ ├── ffconf.h │ ├── font.h │ ├── gbcam.c │ ├── gbcam.h │ ├── icons.c │ ├── icons.h │ ├── integer.h │ ├── io.c │ ├── io.h │ ├── lcd.c │ ├── lcd.h │ ├── main.c │ ├── main.h │ ├── menu.c │ ├── mmc.c │ ├── sdcard.c │ ├── sdcard.h │ ├── sram.c │ ├── system_LPC13xx.c │ ├── system_LPC13xx.h │ ├── tool.c │ ├── tool.h │ ├── view.c │ └── views.h └── GBLiveCam ├── Firmware ├── .mxproject ├── Drivers │ ├── CMSIS │ │ ├── Device │ │ │ └── ST │ │ │ │ └── STM32F7xx │ │ │ │ └── Include │ │ │ │ ├── stm32f730xx.h │ │ │ │ ├── stm32f7xx.h │ │ │ │ └── system_stm32f7xx.h │ │ └── Include │ │ │ ├── cmsis_armcc.h │ │ │ ├── cmsis_armclang.h │ │ │ ├── cmsis_compiler.h │ │ │ ├── cmsis_gcc.h │ │ │ ├── cmsis_iccarm.h │ │ │ ├── cmsis_version.h │ │ │ ├── core_armv8mbl.h │ │ │ ├── core_armv8mml.h │ │ │ ├── core_cm0.h │ │ │ ├── core_cm0plus.h │ │ │ ├── core_cm1.h │ │ │ ├── core_cm23.h │ │ │ ├── core_cm3.h │ │ │ ├── core_cm33.h │ │ │ ├── core_cm4.h │ │ │ ├── core_cm7.h │ │ │ ├── core_sc000.h │ │ │ ├── core_sc300.h │ │ │ ├── mpu_armv7.h │ │ │ ├── mpu_armv8.h │ │ │ └── tz_context.h │ └── STM32F7xx_HAL_Driver │ │ ├── Inc │ │ ├── Legacy │ │ │ └── stm32_hal_legacy.h │ │ ├── stm32f7xx_hal.h │ │ ├── stm32f7xx_hal_cortex.h │ │ ├── stm32f7xx_hal_def.h │ │ ├── stm32f7xx_hal_dma.h │ │ ├── stm32f7xx_hal_dma_ex.h │ │ ├── stm32f7xx_hal_exti.h │ │ ├── stm32f7xx_hal_flash.h │ │ ├── stm32f7xx_hal_flash_ex.h │ │ ├── stm32f7xx_hal_gpio.h │ │ ├── stm32f7xx_hal_gpio_ex.h │ │ ├── stm32f7xx_hal_i2c.h │ │ ├── stm32f7xx_hal_i2c_ex.h │ │ ├── stm32f7xx_hal_pcd.h │ │ ├── stm32f7xx_hal_pcd_ex.h │ │ ├── stm32f7xx_hal_pwr.h │ │ ├── stm32f7xx_hal_pwr_ex.h │ │ ├── stm32f7xx_hal_rcc.h │ │ ├── stm32f7xx_hal_rcc_ex.h │ │ ├── stm32f7xx_hal_tim.h │ │ ├── stm32f7xx_hal_tim_ex.h │ │ ├── stm32f7xx_ll_adc.h │ │ ├── stm32f7xx_ll_bus.h │ │ ├── stm32f7xx_ll_cortex.h │ │ ├── stm32f7xx_ll_dma.h │ │ ├── stm32f7xx_ll_exti.h │ │ ├── stm32f7xx_ll_gpio.h │ │ ├── stm32f7xx_ll_pwr.h │ │ ├── stm32f7xx_ll_rcc.h │ │ ├── stm32f7xx_ll_system.h │ │ ├── stm32f7xx_ll_usb.h │ │ └── stm32f7xx_ll_utils.h │ │ └── Src │ │ ├── stm32f7xx_hal.c │ │ ├── stm32f7xx_hal_cortex.c │ │ ├── stm32f7xx_hal_dma.c │ │ ├── stm32f7xx_hal_dma_ex.c │ │ ├── stm32f7xx_hal_exti.c │ │ ├── stm32f7xx_hal_flash.c │ │ ├── stm32f7xx_hal_flash_ex.c │ │ ├── stm32f7xx_hal_gpio.c │ │ ├── stm32f7xx_hal_i2c.c │ │ ├── stm32f7xx_hal_i2c_ex.c │ │ ├── stm32f7xx_hal_pcd.c │ │ ├── stm32f7xx_hal_pcd_ex.c │ │ ├── stm32f7xx_hal_pwr.c │ │ ├── stm32f7xx_hal_pwr_ex.c │ │ ├── stm32f7xx_hal_rcc.c │ │ ├── stm32f7xx_hal_rcc_ex.c │ │ ├── stm32f7xx_hal_tim.c │ │ ├── stm32f7xx_hal_tim_ex.c │ │ ├── stm32f7xx_ll_adc.c │ │ ├── stm32f7xx_ll_dma.c │ │ ├── stm32f7xx_ll_exti.c │ │ ├── stm32f7xx_ll_gpio.c │ │ ├── stm32f7xx_ll_rcc.c │ │ ├── stm32f7xx_ll_usb.c │ │ └── stm32f7xx_ll_utils.c ├── GBLiveCam.ioc ├── Inc │ ├── gbcam.h │ ├── init.h │ ├── main.h │ ├── osd.h │ ├── palettes.h │ ├── stm32f7xx_hal_conf.h │ ├── stm32f7xx_it.h │ ├── usb_device.h │ ├── usbd_audio_if.h │ ├── usbd_conf.h │ ├── usbd_desc.h │ └── uvc_req.h ├── Middlewares │ └── ST │ │ └── STM32_USB_Device_Library │ │ ├── Class │ │ └── UVC │ │ │ ├── Inc │ │ │ ├── usbd_uvc.h │ │ │ ├── uvc.h │ │ │ └── uvc_desc.h │ │ │ └── Src │ │ │ ├── usbd_uvc.c │ │ │ └── uvc_desc.c │ │ └── Core │ │ ├── Inc │ │ ├── usbd_core.h │ │ ├── usbd_ctlreq.h │ │ ├── usbd_def.h │ │ └── usbd_ioreq.h │ │ └── Src │ │ ├── usbd_core.c │ │ ├── usbd_ctlreq.c │ │ └── usbd_ioreq.c ├── Release │ ├── GBLiveCam_revB.bin │ ├── GBLiveCam_revC.bin │ ├── makefile │ └── program.bat ├── STM32F730R8TX_FLASH.ld ├── STM32F730R8TX_RAM.ld ├── Src │ ├── gbcam.c │ ├── init.c │ ├── main.c │ ├── osd.c │ ├── palettes.c │ ├── stm32f7xx_hal_msp.c │ ├── stm32f7xx_it.c │ ├── syscalls.c │ ├── sysmem.c │ ├── system_stm32f7xx.c │ ├── usb_device.c │ ├── usbd_audio_if.c │ ├── usbd_conf.c │ ├── usbd_desc.c │ └── uvc_req.c ├── Startup │ └── startup_stm32f730r8tx.s └── osd_font.bmp ├── PCB ├── GBLiveCam_B - CADCAM.ZIP ├── GBLiveCam_B_BOM.csv ├── GBLiveCam_B_schematics.PDF ├── GBLiveCam_panel_bot - CADCAM.ZIP └── GBLiveCam_panel_top - CADCAM.ZIP ├── README.md ├── photo.jpg └── video.gif /GBCamcorder/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | GBCamcorder 4 | 5 | 6 | lpc_chip_13xx 7 | 8 | 9 | 10 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 11 | clean,full,incremental, 12 | 13 | 14 | 15 | 16 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 17 | full,incremental, 18 | 19 | 20 | 21 | 22 | 23 | org.eclipse.cdt.core.cnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /GBCamcorder/GBCamcorder.pdsprj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBCamcorder/GBCamcorder.pdsprj -------------------------------------------------------------------------------- /GBCamcorder/README.md: -------------------------------------------------------------------------------- 1 | # GBCamcorder 2 | Lo-Fi portable video recorder using a GameBoy Camera cartridge. 3 | 4 | More details at http://furrtek.free.fr/?a=gbcc 5 | 6 | This initially was a 10-days rush project for the RGC 2015 (French retrogaming meeting). 7 | It involved PCB and 3D-printable enclosure design, firmware writing in C, and assembly by hand. 8 | 9 | It started to work 3 days late because of hair-pulling SD card and audio issues, which were caused by a misbehaving DC-DC converter. 10 | 11 | # Features 12 | * ~14fps 128*112px 4 colors video and 8192Hz audio recording on µSD(HC) card. 13 | * Auto-exposure with out-of-range alerts. 14 | * Dump the cartridge's saved pictures to the µSD card. 15 | * Real time LCD viewfinder. 16 | * No need to destroy cartridges. 17 | * Playback of recorded files. 18 | * USB rechargeable LiPo battery. 19 | 20 | # The idea 21 | The 1998 Nintendo GameBoy Camera was an official accessory for the GameBoy which could shoot and save up to 30, 128*112px pictures in 4 shades of grey. 22 | 23 | Numerous projects use the GameBoy Camera's CMOS sensor, but according to Google none use the complete cartridge. 24 | The main idea is to preserve the cartridge and interface to it directly, taking the GameBoy's place, and record shots fast enough to create videos. 25 | 26 | # File format 27 | For now, audio and video are recorded raw and interleaved in the files. They need to be converted to common video formats on a computer with a special tool. Photos and SRAM dumps are also in raw format but could be saved as .bmp files with a bit more work. 28 | 29 | The file starts with 4 bytes: "GBCC". The next 4 bytes are the video frame count, the next 4 are the audio frame count, the next 4 are reserved for now, and then the interleaved data starts (offset 16). 30 | 31 | Raw video and audio frames are stored with a 2 bytes header: 32 | 33 | Vx (0x56 xx) indicates the start of image data, and how many times the previous image has to be replicated (skips). One image is exactly 3584 bytes, in GB format. 34 | 35 | Ax (0x41 xx) indicates the start of one or multiple (xx) audio frames. Each are 512 unsigned bytes and should be played back at 8192Hz. 36 | -------------------------------------------------------------------------------- /GBCamcorder/Release/GBCamcorder.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBCamcorder/Release/GBCamcorder.bin -------------------------------------------------------------------------------- /GBCamcorder/bitmaps/icon_camnok.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBCamcorder/bitmaps/icon_camnok.bmp -------------------------------------------------------------------------------- /GBCamcorder/bitmaps/icon_camok.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBCamcorder/bitmaps/icon_camok.bmp -------------------------------------------------------------------------------- /GBCamcorder/bitmaps/icon_rec.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBCamcorder/bitmaps/icon_rec.bmp -------------------------------------------------------------------------------- /GBCamcorder/bitmaps/icon_sdnok.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBCamcorder/bitmaps/icon_sdnok.bmp -------------------------------------------------------------------------------- /GBCamcorder/bitmaps/icon_sdok.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBCamcorder/bitmaps/icon_sdok.bmp -------------------------------------------------------------------------------- /GBCamcorder/bitmaps/logo.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBCamcorder/bitmaps/logo.bmp -------------------------------------------------------------------------------- /GBCamcorder/case/shell1.SLDPRT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBCamcorder/case/shell1.SLDPRT -------------------------------------------------------------------------------- /GBCamcorder/case/shell1.STL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBCamcorder/case/shell1.STL -------------------------------------------------------------------------------- /GBCamcorder/converter/Makefile.win: -------------------------------------------------------------------------------- 1 | # Project: Converter 2 | # Makefile created by Dev-C++ 5.11 3 | 4 | CPP = g++.exe 5 | CC = gcc.exe 6 | WINDRES = windres.exe 7 | RES = converter_private.res 8 | OBJ = main.o avi.o $(RES) 9 | LINKOBJ = main.o avi.o $(RES) 10 | LIBS = -L"D:/Dev-Cpp/MinGW64/lib" -L"D:/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib" -static-libgcc 11 | INCS = -I"D:/Dev-Cpp/MinGW64/include" -I"D:/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"D:/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include" 12 | CXXINCS = -I"D:/Dev-Cpp/MinGW64/include" -I"D:/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"D:/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include" -I"D:/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++" 13 | BIN = converter.exe 14 | CXXFLAGS = $(CXXINCS) -Wall -Wextra -std=c++11 15 | CFLAGS = $(INCS) -Wall -Wextra -std=c++11 16 | RM = rm.exe -f 17 | 18 | .PHONY: all all-before all-after clean clean-custom 19 | 20 | all: all-before $(BIN) all-after 21 | 22 | clean: clean-custom 23 | ${RM} $(OBJ) $(BIN) 24 | 25 | $(BIN): $(OBJ) 26 | $(CC) $(LINKOBJ) -o $(BIN) $(LIBS) 27 | 28 | main.o: main.c 29 | $(CC) -c main.c -o main.o $(CFLAGS) 30 | 31 | avi.o: avi.c 32 | $(CC) -c avi.c -o avi.o $(CFLAGS) 33 | 34 | converter_private.res: converter_private.rc 35 | $(WINDRES) -i converter_private.rc --input-format=rc -o converter_private.res -O coff 36 | 37 | -------------------------------------------------------------------------------- /GBCamcorder/converter/avi.c: -------------------------------------------------------------------------------- 1 | // Converter for GameBoy Camcorder video files 2 | // 2018 furrtek 3 | // CC Attribution-NonCommercial-ShareAlike 4.0 4 | // https://github.com/furrtek/GBCamcorder 5 | 6 | #include 7 | #include 8 | #include 9 | #include "avi.h" 10 | 11 | AVIMAINHEADER avi_main_header = { 12 | { 'a', 'v', 'i', 'h' }, 13 | 14 * 4, 14 | 1000000/16, 15 | (128*112/2)*16 + 8192, 16 | 0, 17 | 0, // To check 18 | 0, // dwTotalFrames 19 | 0, 20 | 2, 21 | 0, 22 | 128, 23 | 112, 24 | { 0, 0, 0, 0 } 25 | }; 26 | 27 | AVISTREAMHEADER avi_video_header = { 28 | { 'v', 'i', 'd', 's' }, 29 | { 'D', 'I', 'B', ' ' }, 30 | 0, 31 | 0, 32 | 0, 33 | 0, 34 | 1, 35 | 16, 36 | 0, 37 | 0, // dwLength 38 | 32768, 39 | 10000, 40 | 0, 41 | { 0, 0, 128, 112 } 42 | }; 43 | 44 | AVISTREAMHEADER avi_audio_header = { 45 | { 'a', 'u', 'd', 's' }, 46 | { 'P', 'C', 'M', ' ' }, 47 | 0, 48 | 1, 49 | 0, 50 | 0, 51 | 1, 52 | 8192, 53 | 0, 54 | 0, // dwLength 55 | 32768, 56 | 10000, 57 | 0, 58 | { 0, 0, 0, 0 } 59 | }; 60 | 61 | BITMAPINFOHEADER bitmap_info_header = { 62 | 40, 63 | 128, 64 | 112, 65 | 1, 66 | 24, 67 | 0, 68 | 128*112*3, 69 | 0, 70 | 0, 71 | 0, 72 | 0 73 | }; 74 | 75 | void resizechunk(chunk_t * chunk, unsigned long size) { 76 | chunk_t * ptr = chunk; 77 | 78 | while (ptr != NULL) { 79 | ptr->size += size; 80 | ptr = ptr->parent; 81 | } 82 | } 83 | 84 | chunk_t startchunk(FILE * file, chunk_t * parent, char * type, char * fourcc) { 85 | long int start = ftell(file); 86 | fwrite(type, 1, 4, file); 87 | fseek(file, 4, SEEK_CUR); 88 | if (fourcc != NULL) { 89 | fwrite(fourcc, 1, 4, file); 90 | resizechunk(parent, 12); 91 | chunk_t r = { start, 4, parent }; 92 | return r; 93 | } else { 94 | resizechunk(parent, 8); 95 | chunk_t r = { start, 0, parent }; 96 | return r; 97 | } 98 | } 99 | 100 | void endchunk(FILE * file, chunk_t * chunk) { 101 | long int ref = ftell(file); 102 | fseek(file, chunk->start + 4, SEEK_SET); 103 | fwrite(&chunk->size, 1, 4, file); 104 | fseek(file, ref, SEEK_SET); 105 | } 106 | 107 | void fillchunk(FILE * file, chunk_t * chunk, void * data, unsigned long size) { 108 | resizechunk(chunk, size); 109 | fwrite(data, 1, size, file); 110 | } 111 | 112 | -------------------------------------------------------------------------------- /GBCamcorder/converter/avi.h: -------------------------------------------------------------------------------- 1 | // Converter for GameBoy Camcorder video files 2 | // 2018 furrtek 3 | // CC Attribution-NonCommercial-ShareAlike 4.0 4 | // https://github.com/furrtek/GBCamcorder 5 | 6 | typedef struct { 7 | unsigned short left; 8 | unsigned short top; 9 | unsigned short right; 10 | unsigned short bottom; 11 | } RECT; 12 | 13 | typedef struct { 14 | unsigned char fcc[4]; 15 | unsigned long cb; 16 | unsigned long dwMicroSecPerFrame; 17 | unsigned long dwMaxBytesPerSec; 18 | unsigned long dwPaddingGranularity; 19 | unsigned long dwFlags; 20 | unsigned long dwTotalFrames; 21 | unsigned long dwInitialFrames; 22 | unsigned long dwStreams; 23 | unsigned long dwSuggestedBufferSize; 24 | unsigned long dwWidth; 25 | unsigned long dwHeight; 26 | unsigned long dwReserved[4]; 27 | } AVIMAINHEADER; 28 | 29 | typedef struct { 30 | unsigned char fccType[4]; 31 | unsigned char fccHandler[4]; 32 | unsigned long dwFlags; 33 | unsigned short wPriority; 34 | unsigned short wLanguage; 35 | unsigned long dwInitialFrames; 36 | unsigned long dwScale; 37 | unsigned long dwRate; 38 | unsigned long dwStart; 39 | unsigned long dwLength; 40 | unsigned long dwSuggestedBufferSize; 41 | unsigned long dwQuality; 42 | unsigned long dwSampleSize; 43 | RECT rcFrame; 44 | } AVISTREAMHEADER; 45 | 46 | typedef struct { 47 | unsigned long biSize; 48 | unsigned long biWidth; 49 | unsigned long biHeight; 50 | unsigned short biPlanes; 51 | unsigned short biBitCount; 52 | unsigned long biCompression; 53 | unsigned long biSizeImage; 54 | unsigned long biXPelsPerMeter; 55 | unsigned long biYPelsPerMeter; 56 | unsigned long biClrUsed; 57 | unsigned long biClrImportant; 58 | } BITMAPINFOHEADER; 59 | 60 | typedef struct { 61 | unsigned long start; 62 | unsigned long size; 63 | void * parent; 64 | } chunk_t; 65 | 66 | AVIMAINHEADER avi_main_header; 67 | AVISTREAMHEADER avi_video_header; 68 | AVISTREAMHEADER avi_audio_header; 69 | BITMAPINFOHEADER bitmap_info_header; 70 | 71 | void resizechunk(chunk_t * chunk, unsigned long size); 72 | chunk_t startchunk(FILE * file, chunk_t * parent, char * type, char * fourcc); 73 | void endchunk(FILE * file, chunk_t * chunk); 74 | void fillchunk(FILE * file, chunk_t * chunk, void * data, unsigned long size); 75 | 76 | -------------------------------------------------------------------------------- /GBCamcorder/converter/converter.dev: -------------------------------------------------------------------------------- 1 | [Project] 2 | FileName=converter.dev 3 | Name=GBCC 4 | Type=1 5 | Ver=2 6 | ObjFiles= 7 | Includes= 8 | Libs= 9 | PrivateResource= 10 | ResourceIncludes= 11 | MakeIncludes= 12 | Compiler= 13 | CppCompiler= 14 | Linker= 15 | IsCpp=0 16 | Icon= 17 | ExeOutput= 18 | ObjectOutput= 19 | LogOutput= 20 | LogOutputEnabled=0 21 | OverrideOutput=0 22 | OverrideOutputName= 23 | HostApplication= 24 | UseCustomMakefile=0 25 | CustomMakefile= 26 | CommandLine= 27 | Folders= 28 | IncludeVersionInfo=0 29 | SupportXPThemes=0 30 | CompilerSet=0 31 | CompilerSettings=0000000000000000000000000 32 | 33 | [VersionInfo] 34 | Major=1 35 | Minor=0 36 | Release=0 37 | Build=0 38 | LanguageID=1033 39 | CharsetID=1252 40 | CompanyName= 41 | FileVersion= 42 | FileDescription=Developed using the Dev-C++ IDE 43 | InternalName= 44 | LegalCopyright= 45 | LegalTrademarks= 46 | OriginalFilename= 47 | ProductName= 48 | ProductVersion= 49 | AutoIncBuildNr=0 50 | SyncProduct=1 51 | 52 | -------------------------------------------------------------------------------- /GBCamcorder/converter/converter.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBCamcorder/converter/converter.exe -------------------------------------------------------------------------------- /GBCamcorder/converter/converter_private.h: -------------------------------------------------------------------------------- 1 | /* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */ 2 | /* DO NOT EDIT ! */ 3 | 4 | #ifndef CONVERTER_PRIVATE_H 5 | #define CONVERTER_PRIVATE_H 6 | 7 | /* VERSION DEFINITIONS */ 8 | #define VER_STRING "0.1.0.0" 9 | #define VER_MAJOR 0 10 | #define VER_MINOR 1 11 | #define VER_RELEASE 0 12 | #define VER_BUILD 0 13 | #define COMPANY_NAME "Furrtek.org" 14 | #define FILE_VERSION "0.1.0.0" 15 | #define FILE_DESCRIPTION "GBCamcorder video converter" 16 | #define INTERNAL_NAME "" 17 | #define LEGAL_COPYRIGHT "" 18 | #define LEGAL_TRADEMARKS "" 19 | #define ORIGINAL_FILENAME "" 20 | #define PRODUCT_NAME "" 21 | #define PRODUCT_VERSION "0.1.0.0" 22 | 23 | #endif /*CONVERTER_PRIVATE_H*/ 24 | -------------------------------------------------------------------------------- /GBCamcorder/converter/converter_private.rc: -------------------------------------------------------------------------------- 1 | /* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */ 2 | /* DO NOT EDIT! */ 3 | 4 | #include // include for version info constants 5 | 6 | 7 | // 8 | // TO CHANGE VERSION INFORMATION, EDIT PROJECT OPTIONS... 9 | // 10 | 1 VERSIONINFO 11 | FILEVERSION 0,1,0,0 12 | PRODUCTVERSION 0,1,0,0 13 | FILETYPE VFT_APP 14 | { 15 | BLOCK "StringFileInfo" 16 | { 17 | BLOCK "040904E4" 18 | { 19 | VALUE "CompanyName", "Furrtek.org" 20 | VALUE "FileVersion", "0.1.0.0" 21 | VALUE "FileDescription", "GBCamcorder video converter" 22 | VALUE "InternalName", "" 23 | VALUE "LegalCopyright", "" 24 | VALUE "LegalTrademarks", "" 25 | VALUE "OriginalFilename", "" 26 | VALUE "ProductName", "" 27 | VALUE "ProductVersion", "0.1.0.0" 28 | } 29 | } 30 | BLOCK "VarFileInfo" 31 | { 32 | VALUE "Translation", 0x0409, 1252 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /GBCamcorder/converter/converter_private.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBCamcorder/converter/converter_private.res -------------------------------------------------------------------------------- /GBCamcorder/converter/main.c: -------------------------------------------------------------------------------- 1 | // Converter for GameBoy Camcorder video files 2 | // 2018 furrtek 3 | // CC Attribution-NonCommercial-ShareAlike 4.0 4 | // https://github.com/furrtek/GBCamcorder 5 | 6 | #include 7 | #include 8 | #include 9 | #include "avi.h" 10 | 11 | typedef struct { 12 | unsigned char pixels[128*112]; 13 | unsigned short repeat; 14 | } frame_t; 15 | 16 | frame_t * frames; 17 | 18 | unsigned char dib_frame[128*112*3]; 19 | 20 | typedef struct { 21 | unsigned char R, G, B; 22 | } RGB; 23 | 24 | const RGB rgb_lut[4] = { 25 | { 0x00, 0x00, 0x00 }, 26 | { 0x55, 0x55, 0x55 }, 27 | { 0xAA, 0xAA, 0xAA }, 28 | { 0xFF, 0xFF, 0xFF } 29 | }; 30 | 31 | int main(int argc, char *argv[]) { 32 | FILE * file_in; 33 | FILE * file_out; 34 | //FILE * file_audio_out; 35 | long file_size, pos, dib_index; 36 | unsigned short frame_number = 0, skipped, x, y, xp, yto, plane_pos; 37 | unsigned char * buffer_in, * frame_ptr; 38 | unsigned char pixel; 39 | 40 | if (argc != 2) { 41 | puts("Usage: converter file.bin"); 42 | return 1; 43 | } 44 | 45 | file_in = fopen(argv[1], "rb"); 46 | 47 | fseek(file_in, 0, SEEK_END); 48 | file_size = ftell(file_in); 49 | buffer_in = malloc(file_size); 50 | 51 | if (buffer_in == NULL) { 52 | puts("Memory allocation 1 failed"); 53 | return 1; 54 | } 55 | 56 | // Testing 57 | frames = malloc(sizeof(frame_t) * 200); 58 | if (frames == NULL) { 59 | puts("Memory allocation 2 failed"); 60 | return 1; 61 | } 62 | 63 | rewind(file_in); 64 | fread(buffer_in, 1, file_size, file_in); 65 | fclose(file_in); 66 | 67 | if (strncmp((char*)buffer_in, "GBCC", 4)) { 68 | puts("Wrong file type"); 69 | return 1; 70 | } 71 | 72 | puts("File loaded OK"); 73 | 74 | //file_audio_out = fopen("OUT.SND", "wb+"); 75 | 76 | pos = 16; 77 | do { 78 | if (buffer_in[pos] == 'V') { 79 | // Frame 80 | skipped = buffer_in[pos+1]; 81 | // if (skipped > 5) puts("Skip error"); 82 | if (frame_number) { 83 | frames[frame_number-1].repeat = skipped; 84 | } 85 | // Decode new frame 86 | frame_ptr = &buffer_in[pos+2]; 87 | for (y = 0; y < 112; y++) { 88 | yto = (y & 7) + ((y & 0x78) << 4); 89 | for (x = 0; x < 128; x++) { 90 | plane_pos = ((x & 0x78) + yto) << 1; 91 | xp = 7 - (x & 7); 92 | pixel = ((frame_ptr[plane_pos] >> xp) & 1) | (((frame_ptr[plane_pos + 1] >> xp) << 1) & 2); 93 | 94 | frames[frame_number].pixels[((111 - y) << 7) + x] = pixel; 95 | } 96 | } 97 | frame_number++; 98 | pos += (3584 + 2); 99 | } else if (buffer_in[pos] == 'A') { 100 | // Audio 101 | skipped = buffer_in[pos+1]; 102 | pos += 2; 103 | 104 | while (skipped) { 105 | //fwrite(&buffer_in[pos], 1, 512, file_audio_out); 106 | pos += 512; 107 | skipped--; 108 | } 109 | 110 | } else { 111 | pos++; 112 | } 113 | } while (pos < file_size); 114 | 115 | //fclose(file_audio_out); 116 | free(buffer_in); 117 | 118 | 119 | file_out = fopen("out.avi", "wb+"); 120 | 121 | chunk_t chunk_avi = startchunk(file_out, NULL, "RIFF", "AVI "); 122 | 123 | chunk_t chunk_hdrl = startchunk(file_out, &chunk_avi, "LIST", "hdrl"); 124 | fillchunk(file_out, &chunk_hdrl, &avi_main_header, sizeof(avi_main_header)); 125 | 126 | chunk_t chunk_strl = startchunk(file_out, &chunk_hdrl, "LIST", "strl"); 127 | 128 | chunk_t chunk_strh = startchunk(file_out, &chunk_strl, "strh", NULL); 129 | fillchunk(file_out, &chunk_strh, &avi_video_header, sizeof(avi_video_header)); 130 | endchunk(file_out, &chunk_strh); 131 | chunk_t chunk_strf = startchunk(file_out, &chunk_strl, "strf", NULL); 132 | fillchunk(file_out, &chunk_strf, &bitmap_info_header, sizeof(bitmap_info_header)); 133 | endchunk(file_out, &chunk_strf); 134 | 135 | endchunk(file_out, &chunk_strl); 136 | endchunk(file_out, &chunk_hdrl); 137 | 138 | chunk_t chunk_movi = startchunk(file_out, &chunk_avi, "LIST", "movi"); 139 | 140 | for (x = 0; x < frame_number - 1; x++) { 141 | for (dib_index = 0; dib_index < (128*112); dib_index++) { 142 | pixel = frames[x].pixels[dib_index]; 143 | dib_frame[dib_index*3] = rgb_lut[pixel].R; 144 | dib_frame[dib_index*3+1] = rgb_lut[pixel].G; 145 | dib_frame[dib_index*3+2] = rgb_lut[pixel].B; 146 | } 147 | for (y = 0; y < frames[x].repeat + 1; y++) { 148 | chunk_t chunk_db = startchunk(file_out, &chunk_movi, "00db", NULL); 149 | fillchunk(file_out, &chunk_db, &dib_frame, sizeof(dib_frame)); 150 | endchunk(file_out, &chunk_db); 151 | } 152 | } 153 | 154 | endchunk(file_out, &chunk_movi); 155 | 156 | endchunk(file_out, &chunk_avi); 157 | 158 | fclose(file_out); 159 | 160 | free(frames); 161 | 162 | return 0; 163 | } 164 | 165 | -------------------------------------------------------------------------------- /GBCamcorder/src/about.c: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | Name : GBCamcorder 4 | Author : furrtek 5 | Version : 0.3 6 | Copyright : CC Attribution-NonCommercial-ShareAlike 4.0 7 | Description : GameBoy Camcorder firmware 8 | =============================================================================== 9 | */ 10 | 11 | #include "main.h" 12 | #include "views.h" 13 | #include "colors.h" 14 | #include "io.h" 15 | #include "lcd.h" 16 | 17 | const struct { 18 | uint16_t x; 19 | uint16_t y; 20 | char * s; 21 | uint16_t c; 22 | } credits[6] = { 23 | { 32, 64, "Hardware", COLOR_GREEN }, 24 | { 32, 64+16, "Firmware", COLOR_GREEN }, 25 | { 96, 64+16+16+8, "Furrtek", COLOR_WHITE }, 26 | { 32, 64+96, "Thanks:", COLOR_GREEN }, 27 | { 64, 64+96+16+8, "AntonioND", COLOR_WHITE }, 28 | { 64+96, 64+96+16+8+16, "cLx", COLOR_WHITE } 29 | }; 30 | 31 | void about_view() { 32 | lcd_clear(); 33 | 34 | for (uint32_t c = 0; c < 6; c++) 35 | lcd_print(credits[c].x, credits[c].y, credits[c].s, credits[c].c, 1); 36 | 37 | lcd_print(56, 304, "Press any button", COLOR_WHITE, 0); 38 | 39 | fade_in(); 40 | 41 | loop_func = about_loop; 42 | } 43 | 44 | void about_loop() { 45 | systick_wait(2); // 20ms 46 | 47 | read_inputs(); 48 | 49 | if (inputs_active) 50 | fade_out(menu_view); 51 | } 52 | -------------------------------------------------------------------------------- /GBCamcorder/src/capture.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | Name : GBCamcorder 4 | Author : furrtek 5 | Version : 0.3 6 | Copyright : CC Attribution-NonCommercial-ShareAlike 4.0 7 | Description : GameBoy Camcorder firmware 8 | =============================================================================== 9 | */ 10 | 11 | #ifndef CAPTURE_H_ 12 | #define CAPTURE_H_ 13 | 14 | #include "colors.h" 15 | 16 | // Capture modes 17 | #define MODE_VIDEO 0 18 | #define MODE_PHOTO 1 19 | 20 | // Capture states 21 | volatile enum state_t { 22 | STATE_IDLE = 0, 23 | STATE_START, 24 | STATE_REC, 25 | STATE_PLAY, 26 | STATE_STOP 27 | } state; 28 | 29 | #define FRAME_SIZE 3584 // 128 * 112 * 2bpp / 8 bits 30 | 31 | #define EXPO_INRANGE 0 32 | #define EXPO_DARK 1 33 | #define EXPO_BRIGHT 2 34 | 35 | #define MAX_EXPOSURE 1000 // ((acqtime/953.6)-32446)/16 36 | #define MIN_EXPOSURE 10 37 | 38 | void set_palette(); 39 | 40 | uint8_t mode; // Capture mode 41 | uint8_t picture_buffer[FRAME_SIZE]; 42 | uint16_t exposure; 43 | extern const uint8_t matrix_layout[16]; 44 | extern uint8_t qlevels[4]; 45 | uint8_t seconds, minutes, hours; // Recording duration counter 46 | uint8_t gain; 47 | uint16_t luma_acc; 48 | uint16_t histogram[4]; 49 | uint32_t video_frame_count; 50 | uint32_t audio_frame_count; 51 | 52 | const palette_t * lut_2bpp; 53 | uint8_t palette_number, prev_palette_number; 54 | uint16_t prev_gain_bar, prev_exp_bar; 55 | uint8_t prev_expo_status; 56 | 57 | // Audio stuff 58 | volatile uint8_t audio_fifo[MAX_AUDIO_BUFFERS][512]; 59 | volatile uint8_t audio_fifo_ready; 60 | volatile uint8_t audio_fifo_get; 61 | volatile uint8_t audio_fifo_put; 62 | volatile uint16_t audio_fifo_ptr; 63 | volatile uint8_t audio_max; 64 | 65 | // Timing/inputs 66 | uint8_t rec_timer; // Used for 1s timing 67 | volatile uint8_t skipped; 68 | volatile uint8_t frame_tick; 69 | 70 | #endif /* CAPTURE_H_ */ 71 | -------------------------------------------------------------------------------- /GBCamcorder/src/colors.c: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | Name : GBCamcorder 4 | Author : furrtek 5 | Version : 0.3 6 | Copyright : CC Attribution-NonCommercial-ShareAlike 4.0 7 | Description : GameBoy Camcorder firmware 8 | =============================================================================== 9 | */ 10 | 11 | #include "colors.h" 12 | #include "lcd.h" 13 | 14 | const palette_t palette_grey = { 15 | "Grey ", 16 | { 17 | COLOR565(0x00, 0x00, 0x00), 18 | COLOR565(0x55, 0x55, 0x55), 19 | COLOR565(0xAA, 0xAA, 0xAA), 20 | COLOR565(0xFF, 0xFF, 0xFF) 21 | } 22 | }; 23 | const palette_t palette_dmg = { 24 | "DMG ", 25 | { 26 | COLOR565(0x00, 0x2B, 0x16), 27 | COLOR565(0x0A, 0x64, 0x33), 28 | COLOR565(0x56, 0xAA, 0x2B), 29 | COLOR565(0xB1, 0xC1, 0x00) 30 | } 31 | }; 32 | const palette_t palette_cgb = { 33 | "CGB ", 34 | { 35 | COLOR565(0x00, 0x00, 0x00), 36 | COLOR565(0x00, 0x63, 0xC5), 37 | COLOR565(0x7B, 0xFF, 0x31), 38 | COLOR565(0xFF, 0xFF, 0xFF) 39 | } 40 | }; 41 | const palette_t palette_sepia = { 42 | "Sepia", 43 | { 44 | COLOR565(100, 64, 34), 45 | COLOR565(154, 105, 43), 46 | COLOR565(206, 146, 55), 47 | COLOR565(255, 190, 65) 48 | } 49 | }; 50 | const palette_t palette_candy = { 51 | "Candy", 52 | { 53 | COLOR565(64, 0, 128), 54 | COLOR565(188, 0, 155), 55 | COLOR565(255, 80, 120), 56 | COLOR565(255, 150, 70) 57 | } 58 | }; 59 | const palette_t palette_aqua = { 60 | "Aqua ", 61 | { 62 | COLOR565(22, 52, 162), 63 | COLOR565(40, 128, 201), 64 | COLOR565(69, 209, 255), 65 | COLOR565(169, 255, 245) 66 | } 67 | }; 68 | const palette_t palette_cute = { 69 | "Cute ", 70 | { 71 | COLOR565(240, 68, 121), 72 | COLOR565(245, 115, 140), 73 | COLOR565(250, 175, 155), 74 | COLOR565(255, 246, 200) 75 | } 76 | }; 77 | 78 | const palette_t * palettes_list[MAX_PALETTES] = { 79 | &palette_grey, 80 | &palette_dmg, 81 | &palette_cgb, 82 | &palette_sepia, 83 | &palette_candy, 84 | &palette_aqua, 85 | &palette_cute 86 | }; 87 | 88 | const uint16_t bar_colors[8] = { 89 | COLOR565(0xFF, 0x1F, 0x1F), 90 | COLOR565(0xFF, 0x7F, 0x1F), 91 | COLOR565(0x7F, 0xFF, 0x1F), 92 | COLOR565(0x1F, 0xFF, 0x1F), 93 | COLOR565(0x1F, 0xFF, 0x1F), 94 | COLOR565(0xFF, 0xFF, 0x1F), 95 | COLOR565(0xFF, 0x3F, 0x1F), 96 | COLOR565(0xFF, 0x1F, 0x1F) 97 | }; 98 | -------------------------------------------------------------------------------- /GBCamcorder/src/colors.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | Name : GBCamcorder 4 | Author : furrtek 5 | Version : 0.3 6 | Copyright : CC Attribution-NonCommercial-ShareAlike 4.0 7 | Description : GameBoy Camcorder firmware 8 | =============================================================================== 9 | */ 10 | 11 | #ifndef COLORS_H_ 12 | #define COLORS_H_ 13 | 14 | #include "main.h" 15 | 16 | #define COLOR_RED 0b1111100000000000 17 | #define COLOR_GREEN 0b0000011111100000 18 | #define COLOR_BLUE 0b0000000000011111 19 | #define COLOR_YELLOW 0b1111111111100000 20 | #define COLOR_ORANGE 0b1111101111100000 21 | #define COLOR_CYAN 0b0000011111111111 22 | #define COLOR_WHITE 0b1111111111111111 23 | #define COLOR_GREY 0b0111101111101111 24 | #define COLOR_BLACK 0b0000000000000000 25 | 26 | #define MAX_PALETTES 7 27 | 28 | typedef struct { 29 | char * name; 30 | uint16_t colors[4]; 31 | } palette_t; 32 | 33 | const palette_t * palettes_list[MAX_PALETTES]; 34 | 35 | const uint16_t bar_colors[8]; 36 | 37 | #endif /* COLORS_H_ */ 38 | -------------------------------------------------------------------------------- /GBCamcorder/src/crp.c: -------------------------------------------------------------------------------- 1 | //***************************************************************************** 2 | // crp.c 3 | // 4 | // Source file to create CRP word expected by LPCXpresso IDE linker 5 | //***************************************************************************** 6 | // 7 | // Copyright(C) NXP Semiconductors, 2013 8 | // All rights reserved. 9 | // 10 | // Software that is described herein is for illustrative purposes only 11 | // which provides customers with programming information regarding the 12 | // LPC products. This software is supplied "AS IS" without any warranties of 13 | // any kind, and NXP Semiconductors and its licensor disclaim any and 14 | // all warranties, express or implied, including all implied warranties of 15 | // merchantability, fitness for a particular purpose and non-infringement of 16 | // intellectual property rights. NXP Semiconductors assumes no responsibility 17 | // or liability for the use of the software, conveys no license or rights under any 18 | // patent, copyright, mask work right, or any other intellectual property rights in 19 | // or to any products. NXP Semiconductors reserves the right to make changes 20 | // in the software without notification. NXP Semiconductors also makes no 21 | // representation or warranty that such application will be suitable for the 22 | // specified use without further testing or modification. 23 | // 24 | // Permission to use, copy, modify, and distribute this software and its 25 | // documentation is hereby granted, under NXP Semiconductors' and its 26 | // licensor's relevant copyrights in the software, without fee, provided that it 27 | // is used in conjunction with NXP Semiconductors microcontrollers. This 28 | // copyright, permission, and disclaimer notice must appear in all copies of 29 | // this code. 30 | //***************************************************************************** 31 | 32 | #if defined (__CODE_RED) 33 | #include 34 | // Variable to store CRP value in. Will be placed automatically 35 | // by the linker when "Enable Code Read Protect" selected. 36 | // See crp.h header for more information 37 | __CRP const unsigned int CRP_WORD = CRP_NO_CRP ; 38 | #endif 39 | -------------------------------------------------------------------------------- /GBCamcorder/src/diskio.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------- 2 | / Low level disk interface modlue include file R0.05 (C)ChaN, 2007 3 | /-----------------------------------------------------------------------*/ 4 | 5 | #ifndef _DISKIO 6 | 7 | #define _READONLY 0 /* 1: Read-only mode */ 8 | #define _USE_IOCTL 1 9 | 10 | #include "integer.h" 11 | 12 | 13 | /* Status of Disk Functions */ 14 | typedef BYTE DSTATUS; 15 | 16 | /* Results of Disk Functions */ 17 | typedef enum { 18 | RES_OK = 0, /* 0: Successful */ 19 | RES_ERROR, /* 1: R/W Error */ 20 | RES_WRPRT, /* 2: Write Protected */ 21 | RES_NOTRDY, /* 3: Not Ready */ 22 | RES_PARERR /* 4: Invalid Parameter */ 23 | } DRESULT; 24 | 25 | 26 | /*---------------------------------------*/ 27 | /* Prototypes for disk control functions */ 28 | 29 | DSTATUS disk_initialize (BYTE); 30 | DSTATUS disk_status (BYTE); 31 | DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE); 32 | #if _READONLY == 0 33 | DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE); 34 | #endif 35 | DRESULT disk_ioctl (BYTE, BYTE, void*); 36 | void disk_timerproc (void); 37 | 38 | 39 | 40 | 41 | /* Disk Status Bits (DSTATUS) */ 42 | 43 | #define STA_NOINIT 0x01 /* Drive not initialized */ 44 | #define STA_NODISK 0x02 /* No medium in the drive */ 45 | #define STA_PROTECT 0x04 /* Write protected */ 46 | 47 | 48 | 49 | /* Command code for disk_ioctrl() */ 50 | 51 | /* Generic command */ 52 | #define CTRL_SYNC 0 /* Mandatory for write functions */ 53 | #define GET_SECTOR_COUNT 1 /* Mandatory for only f_mkfs() */ 54 | #define GET_SECTOR_SIZE 2 55 | #define GET_BLOCK_SIZE 3 /* Mandatory for only f_mkfs() */ 56 | #define CTRL_POWER 4 57 | #define CTRL_LOCK 5 58 | #define CTRL_EJECT 6 59 | /* MMC/SDC command */ 60 | #define MMC_GET_TYPE 10 61 | #define MMC_GET_CSD 11 62 | #define MMC_GET_CID 12 63 | #define MMC_GET_OCR 13 64 | #define MMC_GET_SDSTAT 14 65 | /* ATA/CF command */ 66 | #define ATA_GET_REV 20 67 | #define ATA_GET_MODEL 21 68 | #define ATA_GET_SN 22 69 | 70 | 71 | 72 | /* Card type flags (CardType) */ 73 | #define CT_MMC 0x01 /* MMC ver 3 */ 74 | #define CT_SD1 0x02 /* SD ver 1 */ 75 | #define CT_SD2 0x04 /* SD ver 2 */ 76 | #define CT_SDC (CT_SD1|CT_SD2) /* SD */ 77 | #define CT_BLOCK 0x08 /* Block addressing */ 78 | 79 | 80 | #define _DISKIO 81 | #endif 82 | -------------------------------------------------------------------------------- /GBCamcorder/src/font.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | Name : GBCamcorder 4 | Author : furrtek 5 | Version : 0.3 6 | Copyright : CC Attribution-NonCommercial-ShareAlike 4.0 7 | Description : GameBoy Camcorder firmware 8 | =============================================================================== 9 | */ 10 | 11 | #ifndef FONT_H_ 12 | #define FONT_H_ 13 | 14 | #include "LPC13xx.h" 15 | 16 | const uint8_t font[3*32*8] = { 17 | 0,0,0,0,0,0,0,0, 18 | 24,60,60,60,24,0,24,24, 19 | 0,6,10,18,34,18,10,6, 20 | 0,6,14,30,62,30,14,6, 21 | 0,127,127,62,28,8,0,0, 22 | 71,37,23,8,116,82,113,0, 23 | 0,0,0,0,0,0,0,0, 24 | 6,6,4,2,0,0,0,0, 25 | 96,16,8,8,8,16,96,0, 26 | 3,4,8,8,8,4,3,0, 27 | 0,0,34,20,8,20,34,0, 28 | 0,4,4,31,4,4,0,0, 29 | 0,0,0,0,6,6,4,2, 30 | 0,0,0,0,126,0,0,0, 31 | 0,0,0,0,0,6,6,0, 32 | 0,64,32,16,8,4,2,1, 33 | 0,28,50,99,99,38,28,0, 34 | 0,24,28,24,24,24,126,0, 35 | 0,62,99,112,30,7,127,0, 36 | 0,126,48,28,96,99,62,0, 37 | 0,56,60,54,51,127,48,0, 38 | 0,63,3,63,96,99,62,0, 39 | 0,62,3,63,99,99,62,0, 40 | 0,127,99,48,24,12,12,0, 41 | 0,62,99,62,99,99,62,0, 42 | 0,62,99,99,126,96,62,0, 43 | 0,24,24,0,0,24,24,0, 44 | 0,24,24,0,24,24,16,8, 45 | 0,48,12,3,12,48,0,0, 46 | 0,0,127,0,0,127,0,0, 47 | 0,3,12,48,12,3,0,0, 48 | 0,126,231,115,24,0,24,24, 49 | 62,65,93,117,29,65,62,0, 50 | 8,20,20,34,62,65,65,0, 51 | 31,33,33,63,65,65,63,0, 52 | 60,66,1,1,1,66,60,0, 53 | 31,33,65,65,65,33,31,0, 54 | 127,1,1,63,1,1,127,0, 55 | 127,1,1,63,1,1,1,0, 56 | 60,66,1,121,65,66,60,0, 57 | 65,65,65,127,65,65,65,0, 58 | 62,8,8,8,8,8,62,0, 59 | 126,16,16,16,17,17,14,0, 60 | 33,17,9,13,19,33,65,0, 61 | 1,1,1,1,1,1,127,0, 62 | 65,99,85,73,65,65,65,0, 63 | 65,67,69,73,81,97,65,0, 64 | 28,34,65,65,65,34,28,0, 65 | 63,65,65,63,1,1,1,0, 66 | 28,34,65,65,81,34,92,0, 67 | 63,65,65,63,17,33,65,0, 68 | 30,33,1,62,64,65,62,0, 69 | 127,8,8,8,8,8,8,0, 70 | 65,65,65,65,65,66,124,0, 71 | 65,65,34,34,20,20,8,0, 72 | 65,73,85,85,99,99,65,0, 73 | 99,34,20,8,20,34,99,0, 74 | 65,34,20,8,8,8,8,0, 75 | 127,32,16,8,4,2,127,0, 76 | 224,32,32,32,32,32,224,0, 77 | 4,4,8,8,16,16,32,0, 78 | 7,4,4,4,4,4,7,0, 79 | 0,0,0,0,0,0,0,0, 80 | 0,0,0,0,0,0,0,0, 81 | 0,0,0,0,0,0,0,0, 82 | 0,0,28,32,60,34,124,0, 83 | 2,2,2,62,66,66,62,0, 84 | 0,0,60,66,2,66,60,0, 85 | 64,64,64,124,66,66,124,0, 86 | 0,0,60,66,126,2,124,0, 87 | 48,72,8,126,8,8,8,0, 88 | 0,0,124,66,66,124,64,62, 89 | 2,2,2,30,34,34,34,0, 90 | 0,8,0,8,8,8,8,0, 91 | 0,16,0,16,16,16,16,12, 92 | 2,2,98,26,6,26,98,0, 93 | 8,8,8,8,8,8,8,0, 94 | 0,0,55,73,73,73,73,0, 95 | 0,0,60,68,68,68,68,0, 96 | 0,0,60,66,66,66,60,0, 97 | 0,0,62,66,66,62,2,2, 98 | 0,0,124,66,66,124,64,64, 99 | 0,0,114,10,6,2,2,0, 100 | 0,0,60,2,60,64,62,0, 101 | 0,8,62,8,8,8,48,0, 102 | 0,0,34,34,34,34,60,0, 103 | 0,0,34,34,34,20,8,0, 104 | 0,0,65,73,73,85,34,0, 105 | 0,0,35,20,8,20,98,0, 106 | 0,0,34,34,34,60,32,30, 107 | 0,0,126,32,24,4,126,0, 108 | 0,0,0,0,0,0,0,0, 109 | 0,0,0,0,0,0,0,0, 110 | 0,0,0,0,0,0,0,0, 111 | 0,0,0,0,0,0,0,0, 112 | 0,0,0,0,0,0,0,0 113 | }; 114 | 115 | 116 | #endif /* FONT_H_ */ 117 | -------------------------------------------------------------------------------- /GBCamcorder/src/gbcam.c: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | Name : GBCamcorder 4 | Author : furrtek 5 | Version : 0.3 6 | Copyright : CC Attribution-NonCommercial-ShareAlike 4.0 7 | Description : GameBoy Camcorder firmware 8 | =============================================================================== 9 | */ 10 | 11 | #include "LPC13xx.h" 12 | #include "main.h" 13 | #include "gbcam.h" 14 | #include "io.h" 15 | 16 | // Dithering layout taken from real GB Cam (see routine at ROMA:4427) 17 | // Table of matrix offsets * 3, order is top-bottom, left-right 18 | // 0 1 2 3 19 | // --------------- 20 | // 0 | A M D P 21 | // 1 | I E L H 22 | // 2 | C O B N 23 | // 3 | K G J F 24 | const uint8_t matrix_layout[16] = { 0, 30, 24, 6, 25 | 15, 45, 39, 21, 26 | 12, 42, 36, 18, 27 | 3, 33, 27, 9 }; 28 | 29 | // Contrast values for computing dithering matrix 30 | uint8_t qlevels[4]; 31 | 32 | uint8_t gbcam_wait_busy() { 33 | uint32_t timeout = 200000; 34 | 35 | cart_put(0x4000, 0x10); // ASIC registers 36 | while (!(cart_get_ram(0xA000) & 1)) { 37 | if (timeout) 38 | timeout--; 39 | else 40 | return 1; 41 | } 42 | return 0; 43 | } 44 | 45 | uint8_t gbcam_wait_idle() { 46 | uint32_t timeout = 200000; 47 | 48 | cart_put(0x4000, 0x10); // ASIC registers 49 | while (cart_get_ram(0xA000) & 1) { 50 | if (timeout) 51 | timeout--; 52 | else 53 | return 1; 54 | } 55 | return 0; 56 | } 57 | 58 | void cart_set_address(const uint16_t address) { 59 | LPC_GPIO1->DATA &= ~((1<<2) | (1<<3)); // ALEs both low 60 | LPC_GPIO2->DATA |= ((1<<8) | (1<<9) | (1<<10)); // Make sure cart isn't asked anything 61 | LPC_GPIO2->DIR |= 0xFF; // GB bus: Output 62 | 63 | // Set address low 64 | LPC_GPIO2->DATA = (LPC_GPIO2->DATA & 0xF00) | (address & 0x00FF); 65 | 66 | LPC_GPIO1->DATA |= (1<<2); // Clock ALEL 67 | __asm("nop"); 68 | __asm("nop"); 69 | __asm("nop"); 70 | __asm("nop"); 71 | __asm("nop"); 72 | __asm("nop"); 73 | LPC_GPIO1->DATA &= ~(1<<2); 74 | 75 | // Set address high 76 | LPC_GPIO2->DATA = (LPC_GPIO2->DATA & 0xF00) | (address >> 8); 77 | 78 | LPC_GPIO1->DATA |= (1<<3); // Clock ALEH 79 | __asm("nop"); 80 | __asm("nop"); 81 | __asm("nop"); 82 | __asm("nop"); 83 | __asm("nop"); 84 | __asm("nop"); 85 | LPC_GPIO1->DATA &= ~(1<<3); 86 | } 87 | 88 | uint8_t cart_get_ram(const uint16_t address) { 89 | uint8_t v; 90 | 91 | cart_set_address(address); 92 | 93 | LPC_GPIO2->DIR &= ~(0xFF); // GB bus: Input 94 | 95 | LPC_GPIO2->DATA &= ~(1<<9); // CS low 96 | delay_us(1); 97 | LPC_GPIO2->DATA &= ~(1<<10); // RD low 98 | 99 | __asm("nop"); // TODO: Long enough ? 100 | __asm("nop"); 101 | __asm("nop"); 102 | __asm("nop"); 103 | __asm("nop"); 104 | __asm("nop"); 105 | __asm("nop"); 106 | __asm("nop"); 107 | __asm("nop"); 108 | __asm("nop"); 109 | 110 | v = LPC_GPIO2->DATA & 0xFF; // Read data bus 111 | 112 | LPC_GPIO2->DATA |= (1<<10); // RD high 113 | //delay_us(1); 114 | LPC_GPIO2->DATA |= (1<<9); // CS high 115 | 116 | return v; 117 | } 118 | 119 | uint8_t cart_get_rom(const uint16_t address) { 120 | uint8_t v; 121 | 122 | cart_set_address(address); 123 | 124 | LPC_GPIO2->DIR &= ~(0xFF); // GB bus: Input 125 | LPC_GPIO2->DATA |= (1<<9); // CS high 126 | LPC_GPIO2->DATA &= ~(1<<10); // RD low 127 | 128 | delay_us(20); // TODO: ROM shouldn't be so slow :( 129 | 130 | v = LPC_GPIO2->DATA & 0xFF; // Read data bus 131 | LPC_GPIO2->DATA |= (1<<10); // RD high 132 | 133 | return v; 134 | } 135 | 136 | void cart_put(const uint16_t address, const uint8_t value) { 137 | cart_set_address(address); 138 | delay_us(1); // TODO: Make shorter ? 139 | 140 | LPC_GPIO2->DIR |= 0xFF; // GB bus: Output 141 | 142 | LPC_GPIO2->DATA = (LPC_GPIO2->DATA & 0xF00) | value; 143 | delay_us(1); // TODO: Make shorter ? 144 | 145 | if (address >= 0xA000) { 146 | LPC_GPIO2->DATA &= ~(1<<9); // CS low 147 | delay_us(1); // TODO: Make shorter ? 148 | } 149 | 150 | LPC_GPIO2->DATA &= ~(1<<8); // WR low (TODO: PHI must be high right now ?) 151 | delay_us(3); // TODO: Make shorter ? 152 | LPC_GPIO2->DATA |= (1<<8); // WR high 153 | 154 | if (address >= 0xA000) { 155 | delay_us(1); // TODO: Make shorter ? 156 | LPC_GPIO2->DATA |= (1<<9); // CS high 157 | } 158 | } 159 | 160 | // Returns 0 if GB Cam is detected 161 | uint8_t gbcam_detect(void) { 162 | const char rom_name[14] = "GAMEBOYCAMERA"; 163 | uint32_t c; 164 | 165 | cart_put(0x0000, 0x0A); // Initialize MBC, allow writing to RAM 166 | delay_us(5000); 167 | 168 | // Check for ID string in ROM bank 0 169 | for (c = 0; c < 13; c++) { 170 | if (cart_get_rom(c + 0x0134) != rom_name[c]) 171 | return 1; 172 | } 173 | 174 | // Check if A000 bit 0 is = 0 (idle) 175 | return gbcam_wait_idle(); 176 | } 177 | 178 | void gbcam_reset(void) { 179 | LPC_GPIO1->DATA &= ~(1<<11); // GBCRST low 180 | delay_us(20000); 181 | LPC_GPIO1->DATA |= (1<<11); // GBCRST high 182 | delay_us(10000); 183 | } 184 | 185 | // This is a hardcoded 16 entry LUT @ ROMA:7C20 in the GB Cam ROM 186 | // Slope should be 0~31 here 187 | void gbcam_setcontrast(const uint8_t slope, const uint8_t offset) { 188 | uint16_t c, v; 189 | 190 | for (c = 0; c < 4; c++) { 191 | v = offset + (146 - (slope >> 1)) + (c * slope); 192 | qlevels[c] = (v < 256) ? v : 255; 193 | } 194 | } 195 | 196 | // Compute GB Cam dithering matrix values (see GB Cam ROM) 197 | void gbcam_setmatrix() { 198 | uint16_t c, acc, inc; 199 | uint8_t pixel; 200 | 201 | // Each entry in the 4x4 matrix is 3 bytes indicating the threshold levels for each shade of grey 202 | // Pixel voltage < byte A -> black 203 | // byte A < Pv < byte B -> dark grey 204 | // byte B < Pv < byte C -> light grey 205 | // byte C < Pv -> white 206 | // Those are used to generate the voltages for the 3 comparators in the GB Cam ASIC 207 | // The GB Cam ROM generates the whole matrix from 4 bytes: qlevels array (and threshold levels also), 208 | // which are "spread out" by interpolation on the 16 pixels. 209 | // Bytes A for each pixel are qlevels[0] -> qlevels[1] 210 | // Bytes B for each pixel are qlevels[1] -> qlevels[2] 211 | // Bytes C for each pixel are qlevels[2] -> qlevels[3] 212 | for (c = 0; c < 3; c++) { 213 | acc = qlevels[c]; 214 | inc = qlevels[c + 1] - acc; 215 | acc <<= 4; 216 | for (pixel = 0; pixel < 16; pixel++) { 217 | gbcam_matrix[c + matrix_layout[pixel]] = acc >> 4; 218 | acc += inc; 219 | } 220 | } 221 | 222 | cart_put(0x4000, 0x10); // ASIC registers 223 | delay_us(100); 224 | gbcam_wait_idle(); 225 | 226 | for (c = 0; c < 48; c++) 227 | cart_put(c + 0xA006, gbcam_matrix[c]); 228 | } 229 | 230 | void gbcam_setexposure(const uint16_t exposure) { 231 | cart_put(0x4000, 0x10); // ASIC registers 232 | delay_us(100); 233 | gbcam_wait_idle(); 234 | 235 | cart_put(0xA002, exposure >> 8); 236 | cart_put(0xA003, exposure & 0xFF); 237 | } 238 | -------------------------------------------------------------------------------- /GBCamcorder/src/gbcam.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | Name : GBCamcorder 4 | Author : furrtek 5 | Version : 0.3 6 | Copyright : CC Attribution-NonCommercial-ShareAlike 4.0 7 | Description : GameBoy Camcorder firmware 8 | =============================================================================== 9 | */ 10 | 11 | #ifndef GBCAM_H_ 12 | #define GBCAM_H_ 13 | 14 | uint8_t gbcam_wait_busy(); 15 | uint8_t gbcam_wait_idle(); 16 | void cart_set_address(const uint16_t address); 17 | uint8_t cart_get_rom(const uint16_t address); 18 | uint8_t cart_get_ram(const uint16_t address); 19 | void cart_put(const uint16_t address, const uint8_t value); 20 | uint8_t gbcam_detect(void); 21 | void gbcam_reset(void); 22 | void gbcam_setcontrast(const uint8_t slope, const uint8_t offset); 23 | void gbcam_setmatrix(); 24 | void gbcam_setexposure(const uint16_t exposure); 25 | 26 | #endif /* GBCAM_H_ */ 27 | -------------------------------------------------------------------------------- /GBCamcorder/src/icons.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | Name : GBCamcorder 4 | Author : furrtek 5 | Version : 0.3 6 | Copyright : CC Attribution-NonCommercial-ShareAlike 4.0 7 | Description : GameBoy Camcorder firmware 8 | =============================================================================== 9 | */ 10 | 11 | // Use bmptile2array for conversion 12 | 13 | #ifndef ICONS_H_ 14 | #define ICONS_H_ 15 | 16 | #include "LPC13xx.h" 17 | 18 | extern const uint8_t logo[]; 19 | extern const uint8_t logo_fe[]; 20 | //extern const uint8_t icon_rec[]; 21 | extern const uint8_t icon_sdok[]; 22 | extern const uint8_t icon_sdnok[]; 23 | extern const uint8_t icon_camok[]; 24 | extern const uint8_t icon_camnok[]; 25 | 26 | #endif /* ICONS_H_ */ 27 | -------------------------------------------------------------------------------- /GBCamcorder/src/integer.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------*/ 2 | /* Integer type definitions for FatFs module */ 3 | /*-------------------------------------------*/ 4 | 5 | #ifndef _FF_INTEGER 6 | #define _FF_INTEGER 7 | 8 | #include "LPC13xx.h" 9 | 10 | #ifdef _WIN32 /* Development platform */ 11 | 12 | #include 13 | #include 14 | 15 | #else /* Embedded platform */ 16 | 17 | typedef unsigned char BOOL; 18 | 19 | #define TRUE 1 20 | #define FALSE 0 21 | 22 | /* This type MUST be 8-bit */ 23 | typedef uint8_t BYTE; 24 | 25 | /* These types MUST be 16-bit */ 26 | typedef int16_t SHORT; 27 | typedef uint16_t WORD; 28 | typedef uint16_t WCHAR; 29 | 30 | /* These types MUST be 16-bit or 32-bit */ 31 | typedef int16_t INT; 32 | typedef uint16_t UINT; 33 | 34 | /* These types MUST be 32-bit */ 35 | typedef int32_t LONG; 36 | typedef uint32_t DWORD; 37 | 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /GBCamcorder/src/io.c: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | Name : GBCamcorder 4 | Author : furrtek 5 | Version : 0.2 6 | Copyright : CC Attribution-NonCommercial-ShareAlike 4.0 7 | Description : GameBoy Camcorder firmware 8 | =============================================================================== 9 | */ 10 | 11 | #include "LPC13xx.h" 12 | #include "main.h" 13 | #include "io.h" 14 | 15 | // Microsecond wait using TMR16B0 (1us tick) 16 | void delay_us(uint16_t delay) { 17 | LPC_TMR16B0->TC = 0; 18 | while (LPC_TMR16B0->TC < delay); 19 | } 20 | 21 | void read_inputs() { 22 | // 00054321: PB5 (11) and PB1~4 (0~3) 23 | inputs_prev = inputs_current; 24 | inputs_current = (((LPC_GPIO2->DATA >> 7) & 0x10) | (LPC_GPIO3->DATA & 0x0F)) ^ 0x1F; 25 | inputs_active = (inputs_current ^ inputs_prev) & inputs_current; 26 | } 27 | 28 | void init_io(void) { 29 | LPC_IOCON->RESET_PIO0_0 = 0x10; // Func: Reset, Pull-up 30 | LPC_IOCON->PIO0_2 = 0; // Func: PIO 31 | LPC_IOCON->PIO0_3 = 0x01; // Func: USB_VBUS 32 | LPC_IOCON->PIO0_4 = 0; // Func: PIO 33 | LPC_IOCON->PIO0_5 = 0; // Func: PIO 34 | LPC_IOCON->PIO0_6 = 0x01; // Func: USB_CONNECT 35 | LPC_IOCON->PIO0_7 = 0; // Func: PIO 36 | LPC_IOCON->PIO0_8 = 0x01; // Func: MISO0 37 | LPC_IOCON->PIO0_9 = 0x01; // Func: MOSI0 38 | LPC_IOCON->JTAG_TCK_PIO0_10 = 2; // Func: SCK0 39 | LPC_IOCON->JTAG_TDI_PIO0_11 = 2; // Func: AD0 (Mic input) 40 | 41 | LPC_IOCON->JTAG_TMS_PIO1_0 = 0x81; // Func: PIO (Unused) 42 | LPC_IOCON->JTAG_TDO_PIO1_1 = 0x83; // Func: CT32B1_MAT0 (Backlight PWM) 43 | LPC_IOCON->JTAG_nTRST_PIO1_2 = 0x81; // Func: PIO 44 | LPC_IOCON->ARM_SWDIO_PIO1_3 = 0x81; // Func: PIO 45 | LPC_IOCON->PIO1_4 = 0x80; // Func: PIO (Unused) 46 | LPC_IOCON->PIO1_5 = 0; // Func: PIO 47 | LPC_IOCON->PIO1_6 = 0; // Func: PIO (PWM audio out disabled) 48 | LPC_IOCON->PIO1_7 = 0x01; // Func: TXD (Unused) 49 | LPC_IOCON->PIO1_8 = 0; // Func: PIO 50 | LPC_IOCON->PIO1_9 = 0x01; // Func: CT16B1_MAT0 (GB Phi) 51 | LPC_IOCON->PIO1_10 = 0; // Func: PIO (Unused) 52 | LPC_IOCON->PIO1_11 = 0x80; // Func: PIO 53 | 54 | LPC_IOCON->PIO2_0 = 0; // Func: PIO 55 | LPC_IOCON->PIO2_1 = 0; // Func: PIO 56 | LPC_IOCON->PIO2_2 = 0; // Func: PIO 57 | LPC_IOCON->PIO2_3 = 0; // Func: PIO 58 | LPC_IOCON->PIO2_4 = 0; // Func: PIO 59 | LPC_IOCON->PIO2_5 = 0; // Func: PIO 60 | LPC_IOCON->PIO2_6 = 0; // Func: PIO 61 | LPC_IOCON->PIO2_7 = 0; // Func: PIO 62 | LPC_IOCON->PIO2_8 = 0; // Func: PIO 63 | LPC_IOCON->PIO2_9 = 0; // Func: PIO 64 | LPC_IOCON->PIO2_10 = 0; // Func: PIO 65 | LPC_IOCON->PIO2_11 = 0x10; // Func: PIO, Pull-up 66 | 67 | LPC_IOCON->PIO3_0 = 0x10; // Func: PIO, Pull-up 68 | LPC_IOCON->PIO3_1 = 0x10; // Func: PIO, Pull-up 69 | LPC_IOCON->PIO3_2 = 0x10; // Func: PIO, Pull-up 70 | LPC_IOCON->PIO3_3 = 0x10; // Func: PIO, Pull-up 71 | 72 | LPC_IOCON->SCKLOC = 0; // Route SSP SCK0 on PIO0_10 pin 73 | 74 | LPC_GPIO0->DIR = 0b011011110100; 75 | LPC_GPIO1->DIR = 0b101101101110; 76 | LPC_GPIO2->DIR = 0b011100000000; 77 | LPC_GPIO3->DIR = 0b0000; 78 | 79 | LPC_GPIO0->DATA = 0b001001110100; // CSes and resets inactive 80 | LPC_GPIO1->DATA = 0b100100100000; // LEDs off 81 | LPC_GPIO2->DATA = 0b011100000000; 82 | LPC_GPIO3->DATA = 0b0000; 83 | } 84 | -------------------------------------------------------------------------------- /GBCamcorder/src/io.h: -------------------------------------------------------------------------------- 1 | /* 2 | * io.h 3 | * 4 | * Created on: 12 oct. 2015 5 | * Author: furrtek 6 | */ 7 | 8 | #ifndef IO_H_ 9 | #define IO_H_ 10 | 11 | void delay_us(uint16_t delay); 12 | void read_inputs(); 13 | void init_io(); 14 | 15 | uint8_t inputs_prev, inputs_current, inputs_active; 16 | 17 | #endif /* IO_H_ */ 18 | -------------------------------------------------------------------------------- /GBCamcorder/src/lcd.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | Name : GBCamcorder 4 | Author : furrtek 5 | Version : 0.3 6 | Copyright : CC Attribution-NonCommercial-ShareAlike 4.0 7 | Description : GameBoy Camcorder firmware 8 | =============================================================================== 9 | */ 10 | 11 | #ifndef LCD_H_ 12 | #define LCD_H_ 13 | 14 | #define COLOR565(r, g, b) (((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3)) 15 | 16 | void lcd_init(); 17 | void lcd_fill(const uint32_t x, const uint32_t y, const uint32_t w, const uint32_t h, const uint16_t color); 18 | void lcd_clear(); 19 | void lcd_locate(const uint32_t x, const uint32_t y, const uint32_t w, const uint32_t h); 20 | void lcd_print(uint32_t x, const uint32_t y, char * str, const uint16_t color, const uint32_t large); 21 | void lcd_print_time(const uint32_t x, const uint32_t y); 22 | void lcd_preview(const uint32_t x, const uint32_t y); 23 | void lcd_hline(const uint32_t x, const uint32_t y, const uint32_t l, const uint32_t color); 24 | void lcd_vline(const uint32_t x, const uint32_t y, const uint32_t l, const uint32_t color); 25 | void lcd_paint(uint32_t x, uint32_t y, const uint8_t * icon, const uint32_t large); 26 | void fade_in(); 27 | void fade_out(void (*func)(void)); 28 | 29 | #endif /* LCD_H_ */ 30 | -------------------------------------------------------------------------------- /GBCamcorder/src/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | Name : GBCamcorder 4 | 5 | Author : furrtek 6 | Version : 0.3 7 | Copyright : CC Attribution-NonCommercial-ShareAlike 4.0 8 | Description : GameBoy Camcorder firmware 9 | =============================================================================== 10 | */ 11 | 12 | #ifndef MAIN_H_ 13 | #define MAIN_H_ 14 | 15 | #include "LPC13xx.h" 16 | #include "ff.h" 17 | 18 | #define FW_STRING "FW 08072018" 19 | 20 | #define MAX_AUDIO_BUFFERS 5 21 | 22 | #define MENU_BEEP beep(400, 2, 40); 23 | #define VALIDATE_BEEP beep(800, 2, 40); 24 | 25 | // Button bit masks 26 | #define BTN_UP 1 27 | #define BTN_DOWN 8 28 | #define BTN_LEFT 2 29 | #define BTN_RIGHT 4 30 | #define BTN_A 16 31 | 32 | // For FATFS 33 | FATFS FatFs; 34 | FIL file; 35 | FILINFO file_info; 36 | DIR dir; 37 | FRESULT fr; 38 | 39 | // File stuff 40 | char file_buffer[4]; 41 | struct { 42 | char file_name[13]; 43 | uint32_t duration; 44 | } file_list[8]; 45 | 46 | void hex_insert(uint32_t pos, uint8_t d); 47 | void beep(const uint32_t frequency, const uint32_t duration, const uint32_t volume); 48 | void print_error(uint8_t x, uint8_t y, uint8_t fr); 49 | void systick_wait(const uint32_t duration); 50 | 51 | void (*loop_func)(void); // Loop function pointer for each view 52 | void (*slot_func)(void); // SD card or GB cam state change function pointer for each view 53 | 54 | uint8_t gbcam_matrix[48]; // Dithering/ADC matrix 55 | uint8_t bank; // For SRAM dump 56 | uint16_t bank_offset; 57 | 58 | // UI stuff 59 | char str_buffer[32]; // For lcd_print with dynamic data 60 | uint16_t backlight; // For fade in/out 61 | int8_t cursor, cursor_prev, cursor_max; // For menus 62 | uint8_t refresh_req; 63 | uint32_t picture_number, prev_picture_number; 64 | 65 | // Timing/inputs 66 | volatile uint32_t systick; // Used for 10ms timing 67 | uint16_t check_timer; // For SD and GB Cam detection 68 | uint8_t sd_ok, sd_ok_prev, gbcam_ok, gbcam_ok_prev; // Detection flags 69 | 70 | #endif /* MAIN_H_ */ 71 | -------------------------------------------------------------------------------- /GBCamcorder/src/menu.c: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | Name : GBCamcorder 4 | Author : furrtek 5 | Version : 0.2 6 | Copyright : CC Attribution-NonCommercial-ShareAlike 4.0 7 | Description : GameBoy Camcorder firmware 8 | =============================================================================== 9 | */ 10 | #include "main.h" 11 | #include "views.h" 12 | #include "capture.h" 13 | #include "tool.h" 14 | #include "colors.h" 15 | #include "io.h" 16 | #include "icons.h" 17 | #include "lcd.h" 18 | 19 | #define MENU_MAX 5 20 | 21 | typedef struct { 22 | uint16_t y; 23 | char * string; 24 | uint16_t color; 25 | void (*func)(void); 26 | } menu_item_t; 27 | 28 | void func_photo(void) { 29 | mode = MODE_PHOTO; 30 | fade_out(capture_view); 31 | } 32 | void func_video(void) { 33 | mode = MODE_VIDEO; 34 | fade_out(capture_view); 35 | } 36 | void func_view(void) { 37 | fade_out(view_view); 38 | } 39 | void func_sram(void) { 40 | fade_out(sram_view); 41 | } 42 | void func_tool(void) { 43 | fade_out(tool_view); 44 | } 45 | void func_about(void) { 46 | fade_out(about_view); 47 | } 48 | 49 | static const menu_item_t menu_items[6] = { 50 | { 96+0*24, "Photo", COLOR_RED, func_photo }, 51 | { 96+1*24, "Video", COLOR_ORANGE, func_video }, 52 | { 96+2*24, "View", COLOR_GREEN, func_view }, 53 | { 96+3*24, "Dump", COLOR_YELLOW, func_sram }, 54 | { 96+4*24, "Game tool", COLOR_CYAN, func_tool }, 55 | { 96+5*24, "About", COLOR_BLUE, func_about } 56 | }; 57 | 58 | uint8_t menu_item_enabled[6] = { 0, 0, 0, 0, 0, 1 }; 59 | 60 | void menu_move_cursor(const int8_t direction) { 61 | do { 62 | cursor += direction; 63 | 64 | if (cursor > MENU_MAX) 65 | cursor = 0; 66 | else if (cursor < 0) 67 | cursor = MENU_MAX; 68 | 69 | } while (!menu_item_enabled[cursor]); 70 | 71 | MENU_BEEP 72 | } 73 | 74 | void menu_draw() { 75 | const menu_item_t * menu_item; 76 | uint16_t color; 77 | 78 | if (!menu_item_enabled[cursor]) 79 | menu_move_cursor(1); 80 | 81 | for (uint32_t c = 0; c <= MENU_MAX; c++) { 82 | menu_item = &menu_items[c]; 83 | if (menu_item_enabled[c]) 84 | color = menu_item->color; 85 | else 86 | color = COLOR_GREY; 87 | lcd_print(48, menu_item->y, menu_item->string, color, 1); 88 | } 89 | } 90 | 91 | void menu_slot_func(void) { 92 | if (sd_ok) { 93 | menu_item_enabled[2] = 1; 94 | menu_item_enabled[4] = 1; 95 | if (gbcam_ok) { 96 | menu_item_enabled[0] = 1; 97 | menu_item_enabled[1] = 1; 98 | menu_item_enabled[3] = 1; 99 | } 100 | } 101 | 102 | refresh_req = 1; 103 | } 104 | 105 | void menu_view() { 106 | lcd_clear(); 107 | 108 | menu_draw(); 109 | 110 | lcd_paint(75, 268, logo_fe, 0); 111 | lcd_print(76, 304, FW_STRING, COLOR_GREY, 0); 112 | 113 | cursor = 0; 114 | cursor_prev = 1; // Force cursor update 115 | 116 | fade_in(); 117 | 118 | loop_func = menu_loop; 119 | slot_func = menu_slot_func; 120 | } 121 | 122 | void menu_loop() { 123 | systick_wait(2); // 20ms (50Hz update rate) 124 | 125 | read_inputs(); 126 | 127 | if (refresh_req) 128 | menu_draw(); 129 | 130 | if (inputs_active & BTN_DOWN) { 131 | menu_move_cursor(1); 132 | } else if (inputs_active & BTN_UP) { 133 | menu_move_cursor(-1); 134 | } else if (inputs_active & BTN_A) { 135 | VALIDATE_BEEP 136 | menu_items[cursor].func(); 137 | return; 138 | } 139 | 140 | // Refresh cursor if needed 141 | if (cursor != cursor_prev) { 142 | lcd_fill(32, 96 + (cursor_prev * 24), 16, 16, COLOR_BLACK); 143 | lcd_print(32, 96 + (cursor * 24), "#", COLOR_WHITE, 1); 144 | cursor_prev = cursor; 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /GBCamcorder/src/sdcard.c: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | Name : GBCamcorder 4 | Author : furrtek 5 | Version : 0.3 6 | Copyright : CC Attribution-NonCommercial-ShareAlike 4.0 7 | Description : GameBoy Camcorder firmware 8 | =============================================================================== 9 | */ 10 | 11 | #include "main.h" 12 | #include "sdcard.h" 13 | #include "capture.h" 14 | 15 | const char file_header[4] = { 'G', 'B', 'C', 'C' }; 16 | 17 | const uint8_t bmp_header[54] = { 18 | 'B', 'M', // Magic 19 | 0x76, 0x1C, 0x00, 0x00, // Size of file 20 | 0x00, 0x00, 0x00, 0x00, // Reserved 21 | 0x76, 0x00, 0x00, 0x00, // Offset to image data 22 | 23 | 0x28, 0x00, 0x00, 0x00, // Header size 24 | 0x80, 0x00, 0x00, 0x00, // Image width 25 | 0x70, 0x00, 0x00, 0x00, // Image height 26 | 0x01, 0x00, // Planes 27 | 0x04, 0x00, // Bits per pixel 28 | 0x00, 0x00, 0x00, 0x00, // Compression 29 | 0x00, 0x1C, 0x00, 0x00, // Image data size 30 | 0x00, 0x00, 0x00, 0x00, // X resolution 31 | 0x00, 0x00, 0x00, 0x00, // Y resolution 32 | 0x00, 0x00, 0x00, 0x00, // Colors count 33 | 0x00, 0x00, 0x00, 0x00 // Important colors 34 | }; 35 | 36 | void spi_init() { 37 | uint8_t i, dummy; 38 | 39 | LPC_SYSCON->PRESETCTRL |= 0x01; // SSP0 out of reset state 40 | LPC_SYSCON->SSPCLKDIV = 20; // 72/2/20/4 = 450kHz 41 | LPC_SSP->CPSR = 0x2; // Prescaler 42 | LPC_SSP->CR0 = 0x0407; // SPI 8 bit, /4 43 | LPC_SSP->CR1 = 0x2; // SSP0 on 44 | 45 | for (i = 0; i < 8; i++) 46 | dummy = LPC_SSP->DR; // Clear RXFIFO 47 | 48 | (void)dummy; 49 | } 50 | 51 | void set_filename(const char * filename) { 52 | memcpy(file_list[0].file_name, filename, 13); 53 | } 54 | 55 | uint8_t save_bmp() { 56 | uint32_t c; 57 | uint16_t br, color; 58 | uint8_t data_l, data_h, pixel; 59 | uint8_t xt, yt, yt_flip, xp, pixel_pair = 0; 60 | uint16_t addr, yto; 61 | 62 | // Write header 63 | f_write(&file, &bmp_header, 54, &br); 64 | 65 | // Write palettes 66 | for (c = 0; c < 4; c++) { 67 | color = lut_2bpp->colors[c]; 68 | f_putc((color << 3) & 0xF8, &file); // B 69 | f_putc((color >> 3) & 0xFC, &file); // G 70 | f_putc((color >> 8) & 0xF8, &file); // R 71 | f_putc(0, &file); 72 | } 73 | for (c = 0; c < (12 * 4); c++) 74 | f_putc(0, &file); 75 | 76 | // Write image data 77 | for (yt = 0; yt < 112; yt++) { 78 | 79 | yt_flip = 111 - yt; 80 | yto = (yt_flip & 7) + ((yt_flip & 0x78) * 16); 81 | 82 | for (xt = 0; xt < 128; xt++) { 83 | // (xt & 0x78): 0XXXX000 tile # x 84 | // + (yt & 7): 00000YYY pixel y in tile 85 | // + (yt & 0x78) * 16: 0YYYY000 0000 tile # y 86 | // * 2: 2 bytes per pixel 87 | 88 | addr = ((xt & 0x78) + yto) * 2; 89 | 90 | data_l = picture_buffer[addr]; 91 | data_h = picture_buffer[addr + 1]; 92 | 93 | xp = 7 - (xt & 7); // Invert x 94 | 95 | // Planar to linear 96 | // xp = 0 xp = 1 ... 97 | // 76543210 76543210 76543210 76543210 98 | // 6543210- 76543210 7654321- -7654321 99 | // ------0- -------0 ------1- -------1 100 | pixel = (((data_h >> xp) << 1) & 2) | ((data_l >> xp) & 1); 101 | 102 | if ((xt & 1) == 1) { 103 | pixel_pair |= pixel; 104 | if (f_putc(pixel_pair, &file) == -1) // Write image marker 105 | LPC_GPIO1->DATA &= ~(1<<8); // DEBUG: Yellow LED shouldn't turn on 106 | } else { 107 | pixel_pair = pixel << 4; 108 | } 109 | } 110 | } 111 | 112 | f_close(&file); 113 | 114 | return 0; 115 | } 116 | 117 | // File format: 118 | // "GBCC" 119 | // Vx + 3584 bytes image in GB format (x = frames skipped since last one) 120 | // Ax + x*512 bytes of 8192Hz 8-bit unsigned audio (x = number of audio frames to follow) 121 | uint8_t new_file() { 122 | char * file_name = file_list[0].file_name; 123 | 124 | // Find filename and create file 125 | fr = f_open(&file, file_name, FA_WRITE | FA_CREATE_NEW); 126 | while (fr == FR_EXIST) { 127 | if (file_name[7] < '9') { 128 | file_name[7]++; 129 | } else { 130 | file_name[7] = '0'; 131 | if (file_name[6] < '9') { 132 | file_name[6]++; 133 | } else { 134 | file_name[6] = '0'; 135 | if (file_name[5] < '9') { 136 | file_name[5]++; 137 | } else { 138 | // TODO: No file available for creation (all 999 already exist) 139 | return 1; 140 | } 141 | } 142 | } 143 | fr = f_open(&file, file_name, FA_WRITE | FA_CREATE_NEW); 144 | } 145 | 146 | if (fr != FR_OK) 147 | return fr; 148 | 149 | return 0; 150 | } 151 | -------------------------------------------------------------------------------- /GBCamcorder/src/sdcard.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | Name : GBCamcorder 4 | Author : furrtek 5 | Version : 0.3 6 | Copyright : CC Attribution-NonCommercial-ShareAlike 4.0 7 | Description : GameBoy Camcorder firmware 8 | =============================================================================== 9 | */ 10 | 11 | #include 12 | #include "LPC13xx.h" 13 | #include "diskio.h" 14 | 15 | #ifndef SDCARD_H_ 16 | #define SDCARD_H_ 17 | 18 | extern const uint8_t bmp_header[54]; 19 | extern const char file_header[4]; 20 | 21 | void FCLK_LCD(); 22 | void FCLK_FAST(); 23 | void FCLK_SLOW(); 24 | void xmit_spi(BYTE dat); 25 | 26 | void spi_init(void); 27 | void set_filename(const char * filename); 28 | uint8_t save_bmp(); 29 | uint8_t new_file(); 30 | 31 | #endif /* SDCARD_H_ */ 32 | -------------------------------------------------------------------------------- /GBCamcorder/src/sram.c: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | Name : GBCamcorder 4 | Author : furrtek 5 | Version : 0.3 6 | Copyright : CC Attribution-NonCommercial-ShareAlike 4.0 7 | Description : GameBoy Camcorder firmware 8 | =============================================================================== 9 | */ 10 | 11 | #include "main.h" 12 | #include "colors.h" 13 | #include "views.h" 14 | #include "capture.h" 15 | #include "lcd.h" 16 | #include "io.h" 17 | #include "sdcard.h" 18 | #include "gbcam.h" 19 | 20 | void sram_view() { 21 | lcd_clear(); 22 | 23 | lcd_print(64, 64, "< /30>", COLOR_GREY, 1); 24 | 25 | lcd_print(32, 220, "Save", COLOR_RED, 1); 26 | lcd_print(32, 220+24, "Erase", COLOR_GREEN, 1); 27 | lcd_print(32, 220+24+24, "Palette", COLOR_YELLOW, 1); 28 | lcd_print(32, 220+24+24+24, "Exit", COLOR_BLUE, 1); 29 | 30 | set_filename("SDUMP000.BMP"); 31 | 32 | // 2bpp gradient values 33 | prev_palette_number = 1; // Force palette update 34 | palette_number = 0; 35 | set_palette(); 36 | 37 | prev_picture_number = 1; // Force update 38 | picture_number = 0; 39 | 40 | bank = 1; 41 | bank_offset = 0xA000; 42 | cursor_prev = 1; 43 | cursor = 0; 44 | 45 | fade_in(); 46 | 47 | loop_func = sram_loop; 48 | } 49 | 50 | void sram_loop() { 51 | uint32_t c; 52 | 53 | systick_wait(2); // 20ms 54 | 55 | read_inputs(); 56 | 57 | if (inputs_active & BTN_DOWN) { 58 | if (cursor == 3) 59 | cursor = 0; 60 | else 61 | cursor++; 62 | } else if (inputs_active & BTN_UP) { 63 | if (cursor == 0) 64 | cursor = 3; 65 | else 66 | cursor--; 67 | } 68 | 69 | if (inputs_active & BTN_A) { 70 | // Save 71 | if (cursor == 0) { 72 | VALIDATE_BEEP 73 | FCLK_FAST(); 74 | fr = new_file(); 75 | if (!fr) { 76 | lcd_print(56, 300, file_list[0].file_name, COLOR_WHITE, 0); 77 | 78 | LPC_GPIO1->DATA &= ~(1<<8); // Yellow LED on 79 | 80 | FCLK_FAST(); 81 | save_bmp(); 82 | 83 | LPC_GPIO1->DATA |= (1<<8); // Yellow LED off 84 | } else 85 | print_error(0, 0, fr); 86 | } else if (cursor == 1) { 87 | // Erase 88 | VALIDATE_BEEP 89 | cart_put(0x4000, bank); // SRAM bank 90 | delay_us(2); 91 | cart_put(0x0000, 0x0A); // Enable SRAM writes 92 | 93 | for (c = 0; c < 0x1000; c++) 94 | cart_put(bank_offset + c, 0xFF); 95 | 96 | prev_picture_number = picture_number + 1; // Force refresh 97 | } else if (cursor == 3) { 98 | // Exit 99 | VALIDATE_BEEP 100 | fade_out(menu_view); 101 | return; 102 | } 103 | } 104 | 105 | if (cursor == 2) { 106 | // Palette 107 | if (inputs_active & BTN_LEFT) { 108 | if (palette_number) 109 | palette_number--; 110 | set_palette(); 111 | } else if (inputs_active & BTN_RIGHT) { 112 | if (palette_number < MAX_PALETTES - 1) 113 | palette_number++; 114 | set_palette(); 115 | } 116 | } else { 117 | if (inputs_active & BTN_LEFT) { 118 | if (picture_number) 119 | picture_number--; 120 | } else if (inputs_active & BTN_RIGHT) { 121 | if (picture_number < 29) 122 | picture_number++; 123 | } 124 | } 125 | 126 | if (picture_number != prev_picture_number) { 127 | MENU_BEEP 128 | lcd_fill(16, 64, 32, 16, COLOR_BLACK); // Erase previous picture number 129 | 130 | c = picture_number + 1; 131 | str_buffer[0] = '0' + (c / 10); // Draw new picture number 132 | str_buffer[1] = '0' + (c % 10); 133 | str_buffer[2] = 0; 134 | lcd_print(80, 64, str_buffer, COLOR_WHITE, 1); 135 | 136 | // Read SRAM 137 | bank = (picture_number >> 1) + 1; // SRAM bank 138 | cart_put(0x4000, bank); 139 | delay_us(2); 140 | 141 | bank_offset = (picture_number & 1) ? 0xB000 : 0xA000; // There are 2 pictures per bank 142 | 143 | for (c = 0; c < FRAME_SIZE; c++) 144 | picture_buffer[c] = cart_get_ram(bank_offset + c) ^ 0xFF; 145 | 146 | lcd_preview(56, 96); 147 | 148 | prev_picture_number = picture_number; 149 | } 150 | 151 | if (cursor != cursor_prev) { 152 | MENU_BEEP 153 | lcd_fill(16, 220 + (cursor_prev * 24), 16, 16, COLOR_BLACK); 154 | lcd_print(16, 220 + (cursor * 24), "#", COLOR_WHITE, 1); 155 | cursor_prev = cursor; 156 | } 157 | 158 | if (palette_number != prev_palette_number) { 159 | MENU_BEEP 160 | lcd_print(32+128, 220+24+24, palettes_list[palette_number]->name, COLOR_YELLOW, 1); 161 | prev_palette_number = palette_number; 162 | lcd_preview(56, 96); 163 | } 164 | 165 | } 166 | -------------------------------------------------------------------------------- /GBCamcorder/src/system_LPC13xx.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file system_LPC13xx.h 3 | * @brief CMSIS Cortex-M3 Device Peripheral Access Layer Header File 4 | * for the NXP LPC13xx Device Series 5 | * @version V1.01 6 | * @date 19. October 2009 7 | * 8 | * @note 9 | * Copyright (C) 2009 ARM Limited. All rights reserved. 10 | * 11 | * @par 12 | * ARM Limited (ARM) is supplying this software for use with Cortex-M 13 | * processor based microcontrollers. This file can be freely distributed 14 | * within development tools that are supporting such ARM based processors. 15 | * 16 | * @par 17 | * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED 18 | * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. 20 | * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR 21 | * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. 22 | * 23 | ******************************************************************************/ 24 | 25 | 26 | #ifndef __SYSTEM_LPC13xx_H 27 | #define __SYSTEM_LPC13xx_H 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | #include 34 | 35 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 36 | 37 | 38 | /** 39 | * Initialize the system 40 | * 41 | * @param none 42 | * @return none 43 | * 44 | * @brief Setup the microcontroller system. 45 | * Initialize the System and update the SystemCoreClock variable. 46 | */ 47 | extern void SystemInit (void); 48 | 49 | /** 50 | * Update SystemCoreClock variable 51 | * 52 | * @param none 53 | * @return none 54 | * 55 | * @brief Updates the SystemCoreClock with current core Clock 56 | * retrieved from cpu registers. 57 | */ 58 | extern void SystemCoreClockUpdate (void); 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif /* __SYSTEM_LPC13x_H */ 65 | -------------------------------------------------------------------------------- /GBCamcorder/src/tool.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | Name : GBCamcorder 4 | 5 | Author : furrtek 6 | Version : 0.3 7 | Copyright : CC Attribution-NonCommercial-ShareAlike 4.0 8 | Description : GameBoy Camcorder firmware 9 | =============================================================================== 10 | */ 11 | 12 | #ifndef TOOL_H_ 13 | #define TOOL_H_ 14 | 15 | uint32_t sram_banks; 16 | uint32_t rom_banks; 17 | uint32_t mapper_type; 18 | 19 | void about_loop(); 20 | void about_view(); 21 | void capture_loop(void); 22 | void capture_view(void); 23 | void menu_loop(); 24 | void menu_view(); 25 | void view_loop(void); 26 | void view_view(void); 27 | void sram_loop(void); 28 | void sram_view(void); 29 | 30 | #endif /* TOOL_H_ */ 31 | -------------------------------------------------------------------------------- /GBCamcorder/src/view.c: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | Name : GBCamcorder 4 | Author : furrtek 5 | Version : 0.3 6 | Copyright : CC Attribution-NonCommercial-ShareAlike 4.0 7 | Description : GameBoy Camcorder firmware 8 | =============================================================================== 9 | */ 10 | #include 11 | #include "main.h" 12 | #include "colors.h" 13 | #include "views.h" 14 | #include "capture.h" 15 | #include "icons.h" 16 | #include "lcd.h" 17 | #include "io.h" 18 | #include "sdcard.h" 19 | #include "gbcam.h" 20 | 21 | // List 8 files, returns 1 if no more files found 22 | uint8_t list_files(uint16_t page) { 23 | uint8_t c, s; 24 | uint16_t br, ff; 25 | uint32_t duration; 26 | 27 | c = 0; 28 | ff = page * 8; 29 | FCLK_FAST(); 30 | fr = f_opendir(&dir, "/"); 31 | 32 | if (fr == FR_OK) { 33 | for (;;) { 34 | FCLK_FAST(); 35 | fr = f_readdir(&dir, &file_info); 36 | if (file_info.fname[0] == 0) 37 | break; 38 | //if (fr != FR_OK || file_info.fname[0] == 0) 39 | // break; 40 | //if (!ff) { 41 | if (!(file_info.fattrib & AM_DIR)) { 42 | lcd_print(32, 216 + (c << 3), file_info.fname, COLOR_WHITE, 0); 43 | 44 | FCLK_FAST(); 45 | fr = f_open(&file, file_info.fname, FA_READ); 46 | if (fr == FR_OK) { 47 | // Check file header 48 | fr = f_read(&file, file_buffer, 4, &br); 49 | // fr == FR_OK 50 | for (s = 0; s < 4; s++) 51 | if (file_buffer[c] != file_header[c]) break; 52 | if (s == 4) { 53 | f_read(&file, &file_list[c].duration, 4, &br); 54 | if (file_list[c].duration == 1) { 55 | file_list[c].duration = 0; // Picture marker 56 | } else { 57 | file_list[c].duration *= 625; // Frame duration (1/16s) to seconds 58 | file_list[c].duration /= 10000; 59 | } 60 | memcpy(&file_list[c].file_name, file_info.fname, 13); 61 | //c++; 62 | } 63 | c++; 64 | f_close(&file); 65 | if (c == 8) 66 | break; 67 | } 68 | } 69 | //} else { 70 | // ff--; 71 | //} 72 | } 73 | f_closedir(&dir); 74 | 75 | if (!c) 76 | return 1; 77 | 78 | // Fill if needed 79 | for (; c < 8; c++) 80 | file_list[c].file_name[0] = 0; 81 | } else 82 | return 1; 83 | 84 | cursor_max = 0; 85 | 86 | // Clear shown file list 87 | lcd_fill(32, 216, 208, 64, COLOR_BLACK); 88 | 89 | // Display file list 90 | for (c = 0; c < 8; c++) { 91 | if (!file_list[c].file_name[0]) 92 | break; 93 | lcd_print(32, 216 + (c * 8), file_list[c].file_name, COLOR_WHITE, 0); 94 | duration = file_list[c].duration; 95 | if (!duration) { 96 | lcd_print(144, 216 + (c * 8), "PICTURE", COLOR_WHITE, 0); 97 | } else { 98 | str_buffer[7] = 0x30 + (duration % 10); 99 | str_buffer[6] = 0x30 + (duration / 10); 100 | duration /= 60; 101 | str_buffer[5] = ':'; 102 | str_buffer[4] = 0x30 + (duration % 10); 103 | str_buffer[3] = 0x30 + (duration / 10); 104 | duration /= 60; 105 | str_buffer[2] = ':'; 106 | str_buffer[1] = 0x30 + (duration % 10); 107 | str_buffer[0] = 0x30 + (duration / 10); 108 | str_buffer[8] = 0; 109 | lcd_print(144, 216 + (c * 8), str_buffer, COLOR_WHITE, 0); 110 | } 111 | cursor_max++; 112 | } 113 | 114 | if (cursor_max) // Should always be the case here 115 | cursor_max--; 116 | 117 | cursor = 0; 118 | 119 | return 0; 120 | } 121 | 122 | void view_view() { 123 | lcd_clear(); 124 | 125 | // TMR32B0 is used directly here for playback timing (no ADC trigger) 126 | LPC_TMR32B0->MCR = 3; // Reset AND interrupt on match 0 127 | NVIC->ISER[1] |= (1<<11); // Enable timer interrupt 128 | 129 | lcd_print(32, 208, "FILE NAME DURATION", COLOR_GREEN, 0); 130 | lcd_print(28, 296, "Press RIGHT+A to delete", COLOR_GREY, 0); 131 | lcd_print(48, 304, "Press LEFT to exit", COLOR_GREY, 0); 132 | 133 | picture_number = 0; // Used as page number for the file list 134 | 135 | list_files(picture_number); 136 | 137 | state = STATE_IDLE; 138 | cursor_prev = 1; 139 | cursor = 0; 140 | 141 | fade_in(); 142 | 143 | loop_func = view_loop; 144 | } 145 | 146 | void view_loop() { 147 | uint16_t br; 148 | 149 | systick_wait(2); // 20ms 150 | 151 | read_inputs(); 152 | 153 | if (inputs_active & BTN_DOWN) { 154 | if (cursor < cursor_max) { 155 | cursor++; 156 | } else { 157 | // Try next page 158 | if (!list_files(picture_number + 1)) 159 | picture_number++; 160 | } 161 | } else if (inputs_active & BTN_UP) { 162 | if (cursor > 0) { 163 | cursor--; 164 | } else { 165 | if (picture_number) { 166 | // Try previous page 167 | if (!list_files(picture_number - 1)) 168 | picture_number--; 169 | } 170 | } 171 | } 172 | if (inputs_active & BTN_A) { 173 | if (inputs_current & BTN_RIGHT) { 174 | // Delete file 175 | fr = f_unlink(file_list[cursor].file_name); 176 | if (fr == FR_OK) 177 | list_files(picture_number); // Refresh on success 178 | } else { 179 | if (state == STATE_IDLE) 180 | state = STATE_START; 181 | if (state == STATE_PLAY) 182 | state = STATE_STOP; 183 | VALIDATE_BEEP 184 | } 185 | } 186 | if ((inputs_active & BTN_LEFT) && (state == STATE_IDLE)) { 187 | NVIC->ICER[1] |= (1<<11); // Disable timer interrupt 188 | VALIDATE_BEEP 189 | fade_out(menu_view); 190 | return; 191 | } 192 | 193 | if (cursor != cursor_prev) { 194 | // Show first frame of file 195 | fr = f_open(&file, file_list[cursor].file_name, FA_READ); 196 | if (fr == FR_OK) { 197 | f_lseek(&file, 16); 198 | fr = f_read(&file, file_buffer, 2, &br); // Read block ID 199 | if (file_buffer[0] == 'V') { 200 | f_read(&file, picture_buffer, FRAME_SIZE, &br); 201 | lcd_preview(56, 64); 202 | } 203 | f_close(&file); 204 | } 205 | 206 | lcd_fill(24, 216 + (cursor_prev * 8), 8, 8, COLOR_BLACK); 207 | lcd_print(24, 216 + (cursor * 8), "#", COLOR_WHITE, 0); 208 | cursor_prev = cursor; 209 | MENU_BEEP 210 | } 211 | 212 | if (state == STATE_START) { 213 | // Play start request 214 | fr = f_open(&file, file_list[cursor].file_name, FA_READ); 215 | if (fr == FR_OK) { 216 | f_lseek(&file, 16); 217 | audio_fifo_ptr = 0; // Used here for timing 218 | frame_tick = 0; 219 | skipped = 0; 220 | rec_timer = 0; 221 | seconds = 0; 222 | minutes = 0; 223 | hours = 0; 224 | state = STATE_PLAY; 225 | LPC_TMR32B0->TCR = 1; 226 | } 227 | } 228 | 229 | if (state == STATE_PLAY) { 230 | // Playing 231 | if (frame_tick) { 232 | frame_tick = 0; 233 | 234 | if (skipped) { 235 | skipped--; 236 | } else { 237 | f_read(&file, file_buffer, 2, &br); // Read block ID 238 | if (!br) 239 | state = STATE_STOP; // End of file 240 | skipped = file_buffer[1]; 241 | 242 | if (file_buffer[0] == 'V') { 243 | f_read(&file, picture_buffer, FRAME_SIZE, &br); 244 | lcd_preview(56, 64); 245 | } else if (file_buffer[0] == 'A') { 246 | f_lseek(&file, f_tell(&file) + (skipped * 512)); // Skip audio 247 | } else { 248 | state = STATE_STOP; // Bad block ID 249 | } 250 | } 251 | } 252 | 253 | // Update playing time every second 254 | if (rec_timer >= 100) { 255 | rec_timer -= 100; 256 | if (seconds < 59) { 257 | seconds++; 258 | } else { 259 | seconds = 0; 260 | if (minutes < 59) { 261 | minutes++; 262 | } else { 263 | minutes = 0; 264 | if (hours < 99) 265 | hours++; 266 | } 267 | } 268 | 269 | lcd_print_time(88, 180); 270 | } 271 | } 272 | 273 | if (state == STATE_STOP) { 274 | LPC_TMR32B0->TCR = 0; 275 | f_close(&file); 276 | state = STATE_IDLE; 277 | } 278 | } 279 | -------------------------------------------------------------------------------- /GBCamcorder/src/views.h: -------------------------------------------------------------------------------- 1 | /* 2 | =============================================================================== 3 | Name : GBCamcorder 4 | Author : furrtek 5 | Version : 0.3 6 | Copyright : CC Attribution-NonCommercial-ShareAlike 4.0 7 | Description : GameBoy Camcorder firmware 8 | =============================================================================== 9 | */ 10 | 11 | void about_loop(); 12 | void about_view(); 13 | void capture_loop(void); 14 | void capture_view(void); 15 | void menu_loop(); 16 | void menu_view(); 17 | void view_loop(void); 18 | void view_view(void); 19 | void sram_loop(void); 20 | void sram_view(void); 21 | void tool_view(void); 22 | void tool_loop(void); 23 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Drivers/CMSIS/Device/ST/STM32F7xx/Include/stm32f730xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBLiveCam/Firmware/Drivers/CMSIS/Device/ST/STM32F7xx/Include/stm32f730xx.h -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Drivers/CMSIS/Device/ST/STM32F7xx/Include/stm32f7xx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBLiveCam/Firmware/Drivers/CMSIS/Device/ST/STM32F7xx/Include/stm32f7xx.h -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Drivers/CMSIS/Device/ST/STM32F7xx/Include/system_stm32f7xx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32f7xx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex-M7 Device System Source File for STM32F7xx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© COPYRIGHT(c) 2016 STMicroelectronics

10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | ****************************************************************************** 34 | */ 35 | 36 | /** @addtogroup CMSIS 37 | * @{ 38 | */ 39 | 40 | /** @addtogroup stm32f7xx_system 41 | * @{ 42 | */ 43 | 44 | /** 45 | * @brief Define to prevent recursive inclusion 46 | */ 47 | #ifndef __SYSTEM_STM32F7XX_H 48 | #define __SYSTEM_STM32F7XX_H 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | /** @addtogroup STM32F7xx_System_Includes 55 | * @{ 56 | */ 57 | 58 | /** 59 | * @} 60 | */ 61 | 62 | 63 | /** @addtogroup STM32F7xx_System_Exported_Variables 64 | * @{ 65 | */ 66 | /* The SystemCoreClock variable is updated in three ways: 67 | 1) by calling CMSIS function SystemCoreClockUpdate() 68 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 69 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 70 | Note: If you use this function to configure the system clock; then there 71 | is no need to call the 2 first functions listed above, since SystemCoreClock 72 | variable is updated automatically. 73 | */ 74 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ 75 | 76 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 77 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ 78 | 79 | 80 | /** 81 | * @} 82 | */ 83 | 84 | /** @addtogroup STM32F7xx_System_Exported_Constants 85 | * @{ 86 | */ 87 | 88 | /** 89 | * @} 90 | */ 91 | 92 | /** @addtogroup STM32F7xx_System_Exported_Macros 93 | * @{ 94 | */ 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /** @addtogroup STM32F7xx_System_Exported_Functions 101 | * @{ 102 | */ 103 | 104 | extern void SystemInit(void); 105 | extern void SystemCoreClockUpdate(void); 106 | /** 107 | * @} 108 | */ 109 | 110 | #ifdef __cplusplus 111 | } 112 | #endif 113 | 114 | #endif /*__SYSTEM_STM32F7XX_H */ 115 | 116 | /** 117 | * @} 118 | */ 119 | 120 | /** 121 | * @} 122 | */ 123 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 124 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Drivers/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.2 5 | * @date 19. April 2017 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2017 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Drivers/CMSIS/Include/tz_context.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file tz_context.h 3 | * @brief Context Management for Armv8-M TrustZone 4 | * @version V1.0.1 5 | * @date 10. January 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef TZ_CONTEXT_H 32 | #define TZ_CONTEXT_H 33 | 34 | #include 35 | 36 | #ifndef TZ_MODULEID_T 37 | #define TZ_MODULEID_T 38 | /// \details Data type that identifies secure software modules called by a process. 39 | typedef uint32_t TZ_ModuleId_t; 40 | #endif 41 | 42 | /// \details TZ Memory ID identifies an allocated memory slot. 43 | typedef uint32_t TZ_MemoryId_t; 44 | 45 | /// Initialize secure context memory system 46 | /// \return execution status (1: success, 0: error) 47 | uint32_t TZ_InitContextSystem_S (void); 48 | 49 | /// Allocate context memory for calling secure software modules in TrustZone 50 | /// \param[in] module identifies software modules called from non-secure mode 51 | /// \return value != 0 id TrustZone memory slot identifier 52 | /// \return value 0 no memory available or internal error 53 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); 54 | 55 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S 56 | /// \param[in] id TrustZone memory slot identifier 57 | /// \return execution status (1: success, 0: error) 58 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); 59 | 60 | /// Load secure context (called on RTOS thread context switch) 61 | /// \param[in] id TrustZone memory slot identifier 62 | /// \return execution status (1: success, 0: error) 63 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); 64 | 65 | /// Store secure context (called on RTOS thread context switch) 66 | /// \param[in] id TrustZone memory slot identifier 67 | /// \return execution status (1: success, 0: error) 68 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); 69 | 70 | #endif // TZ_CONTEXT_H 71 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_dma_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f7xx_hal_dma_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of DMA HAL extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32F7xx_HAL_DMA_EX_H 22 | #define __STM32F7xx_HAL_DMA_EX_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f7xx_hal_def.h" 30 | 31 | /** @addtogroup STM32F7xx_HAL_Driver 32 | * @{ 33 | */ 34 | 35 | /** @addtogroup DMAEx 36 | * @{ 37 | */ 38 | 39 | /* Exported types ------------------------------------------------------------*/ 40 | /** @defgroup DMAEx_Exported_Types DMAEx Exported Types 41 | * @brief DMAEx Exported types 42 | * @{ 43 | */ 44 | 45 | /** 46 | * @brief HAL DMA Memory definition 47 | */ 48 | typedef enum 49 | { 50 | MEMORY0 = 0x00U, /*!< Memory 0 */ 51 | MEMORY1 = 0x01U, /*!< Memory 1 */ 52 | 53 | }HAL_DMA_MemoryTypeDef; 54 | 55 | /** 56 | * @} 57 | */ 58 | 59 | /* Exported constants --------------------------------------------------------*/ 60 | 61 | /** @defgroup DMA_Exported_Constants DMA Exported Constants 62 | * @brief DMA Exported constants 63 | * @{ 64 | */ 65 | 66 | /** @defgroup DMAEx_Channel_selection DMA Channel selection 67 | * @brief DMAEx channel selection 68 | * @{ 69 | */ 70 | #define DMA_CHANNEL_0 0x00000000U /*!< DMA Channel 0 */ 71 | #define DMA_CHANNEL_1 0x02000000U /*!< DMA Channel 1 */ 72 | #define DMA_CHANNEL_2 0x04000000U /*!< DMA Channel 2 */ 73 | #define DMA_CHANNEL_3 0x06000000U /*!< DMA Channel 3 */ 74 | #define DMA_CHANNEL_4 0x08000000U /*!< DMA Channel 4 */ 75 | #define DMA_CHANNEL_5 0x0A000000U /*!< DMA Channel 5 */ 76 | #define DMA_CHANNEL_6 0x0C000000U /*!< DMA Channel 6 */ 77 | #define DMA_CHANNEL_7 0x0E000000U /*!< DMA Channel 7 */ 78 | #if defined (STM32F722xx) || defined (STM32F723xx) || defined (STM32F732xx) || defined (STM32F733xx) ||\ 79 | defined (STM32F765xx) || defined (STM32F767xx) || defined (STM32F769xx) || defined (STM32F777xx) ||\ 80 | defined (STM32F779xx) || defined (STM32F730xx) 81 | #define DMA_CHANNEL_8 0x10000000U /*!< DMA Channel 8 */ 82 | #define DMA_CHANNEL_9 0x12000000U /*!< DMA Channel 9 */ 83 | #define DMA_CHANNEL_10 0x14000000U /*!< DMA Channel 10*/ 84 | #define DMA_CHANNEL_11 0x16000000U /*!< DMA Channel 11*/ 85 | #define DMA_CHANNEL_12 0x18000000U /*!< DMA Channel 12*/ 86 | #define DMA_CHANNEL_13 0x1A000000U /*!< DMA Channel 13*/ 87 | #define DMA_CHANNEL_14 0x1C000000U /*!< DMA Channel 14*/ 88 | #define DMA_CHANNEL_15 0x1E000000U /*!< DMA Channel 15*/ 89 | #endif /* STM32F722xx || STM32F723xx || STM32F732xx || STM32F733xx || STM32F765xx || STM32F767xx || 90 | STM32F769xx || STM32F777xx || STM32F779xx || STM32F730xx */ 91 | 92 | /** 93 | * @} 94 | */ 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /* Exported functions --------------------------------------------------------*/ 101 | /** @defgroup DMAEx_Exported_Functions DMAEx Exported Functions 102 | * @brief DMAEx Exported functions 103 | * @{ 104 | */ 105 | 106 | /** @defgroup DMAEx_Exported_Functions_Group1 Extended features functions 107 | * @brief Extended features functions 108 | * @{ 109 | */ 110 | 111 | /* IO operation functions *******************************************************/ 112 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 113 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength); 114 | HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory); 115 | 116 | /** 117 | * @} 118 | */ 119 | /** 120 | * @} 121 | */ 122 | 123 | /* Private macros ------------------------------------------------------------*/ 124 | /** @defgroup DMAEx_Private_Macros DMA Private Macros 125 | * @brief DMAEx private macros 126 | * @{ 127 | */ 128 | #if defined (STM32F722xx) || defined (STM32F723xx) || defined (STM32F732xx) || defined (STM32F733xx) ||\ 129 | defined (STM32F765xx) || defined (STM32F767xx) || defined (STM32F769xx) || defined (STM32F777xx) ||\ 130 | defined (STM32F779xx) || defined (STM32F730xx) 131 | #define IS_DMA_CHANNEL(CHANNEL) (((CHANNEL) == DMA_CHANNEL_0) || \ 132 | ((CHANNEL) == DMA_CHANNEL_1) || \ 133 | ((CHANNEL) == DMA_CHANNEL_2) || \ 134 | ((CHANNEL) == DMA_CHANNEL_3) || \ 135 | ((CHANNEL) == DMA_CHANNEL_4) || \ 136 | ((CHANNEL) == DMA_CHANNEL_5) || \ 137 | ((CHANNEL) == DMA_CHANNEL_6) || \ 138 | ((CHANNEL) == DMA_CHANNEL_7) || \ 139 | ((CHANNEL) == DMA_CHANNEL_8) || \ 140 | ((CHANNEL) == DMA_CHANNEL_9) || \ 141 | ((CHANNEL) == DMA_CHANNEL_10) || \ 142 | ((CHANNEL) == DMA_CHANNEL_11) || \ 143 | ((CHANNEL) == DMA_CHANNEL_12) || \ 144 | ((CHANNEL) == DMA_CHANNEL_13) || \ 145 | ((CHANNEL) == DMA_CHANNEL_14) || \ 146 | ((CHANNEL) == DMA_CHANNEL_15)) 147 | #else 148 | #define IS_DMA_CHANNEL(CHANNEL) (((CHANNEL) == DMA_CHANNEL_0) || \ 149 | ((CHANNEL) == DMA_CHANNEL_1) || \ 150 | ((CHANNEL) == DMA_CHANNEL_2) || \ 151 | ((CHANNEL) == DMA_CHANNEL_3) || \ 152 | ((CHANNEL) == DMA_CHANNEL_4) || \ 153 | ((CHANNEL) == DMA_CHANNEL_5) || \ 154 | ((CHANNEL) == DMA_CHANNEL_6) || \ 155 | ((CHANNEL) == DMA_CHANNEL_7)) 156 | #endif /* STM32F722xx || STM32F723xx || STM32F732xx || STM32F733xx || STM32F765xx || STM32F767xx || 157 | STM32F769xx || STM32F777xx || STM32F779xx || STM32F730xx*/ 158 | /** 159 | * @} 160 | */ 161 | 162 | /* Private functions ---------------------------------------------------------*/ 163 | /** @defgroup DMAEx_Private_Functions DMAEx Private Functions 164 | * @brief DMAEx Private functions 165 | * @{ 166 | */ 167 | /** 168 | * @} 169 | */ 170 | 171 | /** 172 | * @} 173 | */ 174 | 175 | /** 176 | * @} 177 | */ 178 | 179 | #ifdef __cplusplus 180 | } 181 | #endif 182 | 183 | #endif /* __STM32F7xx_HAL_DMA_H */ 184 | 185 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 186 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_pcd_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f7xx_hal_pcd_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of PCD HAL Extension module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef STM32F7xx_HAL_PCD_EX_H 22 | #define STM32F7xx_HAL_PCD_EX_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "stm32f7xx_hal_def.h" 30 | 31 | #if defined (USB_OTG_FS) || defined (USB_OTG_HS) 32 | /** @addtogroup STM32F7xx_HAL_Driver 33 | * @{ 34 | */ 35 | 36 | /** @addtogroup PCDEx 37 | * @{ 38 | */ 39 | /* Exported types ------------------------------------------------------------*/ 40 | /* Exported constants --------------------------------------------------------*/ 41 | /* Exported macros -----------------------------------------------------------*/ 42 | /* Exported functions --------------------------------------------------------*/ 43 | /** @addtogroup PCDEx_Exported_Functions PCDEx Exported Functions 44 | * @{ 45 | */ 46 | /** @addtogroup PCDEx_Exported_Functions_Group1 Peripheral Control functions 47 | * @{ 48 | */ 49 | 50 | #if defined (USB_OTG_FS) || defined (USB_OTG_HS) 51 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size); 52 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size); 53 | #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */ 54 | 55 | 56 | HAL_StatusTypeDef HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef *hpcd); 57 | HAL_StatusTypeDef HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef *hpcd); 58 | 59 | void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg); 60 | void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg); 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | /** 67 | * @} 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** 75 | * @} 76 | */ 77 | #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */ 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | 83 | 84 | #endif /* STM32F7xx_HAL_PCD_EX_H */ 85 | 86 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 87 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pcd_ex.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f7xx_hal_pcd_ex.c 4 | * @author MCD Application Team 5 | * @brief PCD Extended HAL module driver. 6 | * This file provides firmware functions to manage the following 7 | * functionalities of the USB Peripheral Controller: 8 | * + Extended features functions 9 | * 10 | ****************************************************************************** 11 | * @attention 12 | * 13 | *

© Copyright (c) 2017 STMicroelectronics. 14 | * All rights reserved.

15 | * 16 | * This software component is licensed by ST under BSD 3-Clause license, 17 | * the "License"; You may not use this file except in compliance with the 18 | * License. You may obtain a copy of the License at: 19 | * opensource.org/licenses/BSD-3-Clause 20 | * 21 | ****************************************************************************** 22 | */ 23 | 24 | /* Includes ------------------------------------------------------------------*/ 25 | #include "stm32f7xx_hal.h" 26 | 27 | /** @addtogroup STM32F7xx_HAL_Driver 28 | * @{ 29 | */ 30 | 31 | /** @defgroup PCDEx PCDEx 32 | * @brief PCD Extended HAL module driver 33 | * @{ 34 | */ 35 | 36 | #ifdef HAL_PCD_MODULE_ENABLED 37 | 38 | #if defined (USB_OTG_FS) || defined (USB_OTG_HS) 39 | /* Private types -------------------------------------------------------------*/ 40 | /* Private variables ---------------------------------------------------------*/ 41 | /* Private constants ---------------------------------------------------------*/ 42 | /* Private macros ------------------------------------------------------------*/ 43 | /* Private functions ---------------------------------------------------------*/ 44 | /* Exported functions --------------------------------------------------------*/ 45 | 46 | /** @defgroup PCDEx_Exported_Functions PCDEx Exported Functions 47 | * @{ 48 | */ 49 | 50 | /** @defgroup PCDEx_Exported_Functions_Group1 Peripheral Control functions 51 | * @brief PCDEx control functions 52 | * 53 | @verbatim 54 | =============================================================================== 55 | ##### Extended features functions ##### 56 | =============================================================================== 57 | [..] This section provides functions allowing to: 58 | (+) Update FIFO configuration 59 | 60 | @endverbatim 61 | * @{ 62 | */ 63 | #if defined (USB_OTG_FS) || defined (USB_OTG_HS) 64 | /** 65 | * @brief Set Tx FIFO 66 | * @param hpcd PCD handle 67 | * @param fifo The number of Tx fifo 68 | * @param size Fifo size 69 | * @retval HAL status 70 | */ 71 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size) 72 | { 73 | uint8_t i; 74 | uint32_t Tx_Offset; 75 | 76 | /* TXn min size = 16 words. (n : Transmit FIFO index) 77 | When a TxFIFO is not used, the Configuration should be as follows: 78 | case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes) 79 | --> Txm can use the space allocated for Txn. 80 | case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes) 81 | --> Txn should be configured with the minimum space of 16 words 82 | The FIFO is used optimally when used TxFIFOs are allocated in the top 83 | of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones. 84 | When DMA is used 3n * FIFO locations should be reserved for internal DMA registers */ 85 | 86 | Tx_Offset = hpcd->Instance->GRXFSIZ; 87 | 88 | if (fifo == 0U) 89 | { 90 | hpcd->Instance->DIEPTXF0_HNPTXFSIZ = ((uint32_t)size << 16) | Tx_Offset; 91 | } 92 | else 93 | { 94 | Tx_Offset += (hpcd->Instance->DIEPTXF0_HNPTXFSIZ) >> 16; 95 | for (i = 0U; i < (fifo - 1U); i++) 96 | { 97 | Tx_Offset += (hpcd->Instance->DIEPTXF[i] >> 16); 98 | } 99 | 100 | /* Multiply Tx_Size by 2 to get higher performance */ 101 | hpcd->Instance->DIEPTXF[fifo - 1U] = ((uint32_t)size << 16) | Tx_Offset; 102 | } 103 | 104 | return HAL_OK; 105 | } 106 | 107 | /** 108 | * @brief Set Rx FIFO 109 | * @param hpcd PCD handle 110 | * @param size Size of Rx fifo 111 | * @retval HAL status 112 | */ 113 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size) 114 | { 115 | hpcd->Instance->GRXFSIZ = size; 116 | 117 | return HAL_OK; 118 | } 119 | 120 | /** 121 | * @brief Activate LPM feature. 122 | * @param hpcd PCD handle 123 | * @retval HAL status 124 | */ 125 | HAL_StatusTypeDef HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef *hpcd) 126 | { 127 | USB_OTG_GlobalTypeDef *USBx = hpcd->Instance; 128 | 129 | hpcd->lpm_active = 1U; 130 | hpcd->LPM_State = LPM_L0; 131 | USBx->GINTMSK |= USB_OTG_GINTMSK_LPMINTM; 132 | USBx->GLPMCFG |= (USB_OTG_GLPMCFG_LPMEN | USB_OTG_GLPMCFG_LPMACK | USB_OTG_GLPMCFG_ENBESL); 133 | 134 | return HAL_OK; 135 | } 136 | 137 | /** 138 | * @brief Deactivate LPM feature. 139 | * @param hpcd PCD handle 140 | * @retval HAL status 141 | */ 142 | HAL_StatusTypeDef HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef *hpcd) 143 | { 144 | USB_OTG_GlobalTypeDef *USBx = hpcd->Instance; 145 | 146 | hpcd->lpm_active = 0U; 147 | USBx->GINTMSK &= ~USB_OTG_GINTMSK_LPMINTM; 148 | USBx->GLPMCFG &= ~(USB_OTG_GLPMCFG_LPMEN | USB_OTG_GLPMCFG_LPMACK | USB_OTG_GLPMCFG_ENBESL); 149 | 150 | return HAL_OK; 151 | } 152 | 153 | #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */ 154 | 155 | /** 156 | * @brief Send LPM message to user layer callback. 157 | * @param hpcd PCD handle 158 | * @param msg LPM message 159 | * @retval HAL status 160 | */ 161 | __weak void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg) 162 | { 163 | /* Prevent unused argument(s) compilation warning */ 164 | UNUSED(hpcd); 165 | UNUSED(msg); 166 | 167 | /* NOTE : This function should not be modified, when the callback is needed, 168 | the HAL_PCDEx_LPM_Callback could be implemented in the user file 169 | */ 170 | } 171 | 172 | /** 173 | * @brief Send BatteryCharging message to user layer callback. 174 | * @param hpcd PCD handle 175 | * @param msg LPM message 176 | * @retval HAL status 177 | */ 178 | __weak void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg) 179 | { 180 | /* Prevent unused argument(s) compilation warning */ 181 | UNUSED(hpcd); 182 | UNUSED(msg); 183 | 184 | /* NOTE : This function should not be modified, when the callback is needed, 185 | the HAL_PCDEx_BCD_Callback could be implemented in the user file 186 | */ 187 | } 188 | 189 | /** 190 | * @} 191 | */ 192 | 193 | /** 194 | * @} 195 | */ 196 | #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */ 197 | #endif /* HAL_PCD_MODULE_ENABLED */ 198 | 199 | /** 200 | * @} 201 | */ 202 | 203 | /** 204 | * @} 205 | */ 206 | 207 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 208 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_exti.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32f7xx_ll_exti.c 4 | * @author MCD Application Team 5 | * @brief EXTI LL module driver. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2017 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under BSD 3-Clause license, 13 | * the "License"; You may not use this file except in compliance with the 14 | * License. You may obtain a copy of the License at: 15 | * opensource.org/licenses/BSD-3-Clause 16 | * 17 | ****************************************************************************** 18 | */ 19 | #if defined(USE_FULL_LL_DRIVER) 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "stm32f7xx_ll_exti.h" 23 | #ifdef USE_FULL_ASSERT 24 | #include "stm32_assert.h" 25 | #else 26 | #define assert_param(expr) ((void)0U) 27 | #endif 28 | 29 | /** @addtogroup STM32F7xx_LL_Driver 30 | * @{ 31 | */ 32 | 33 | #if defined (EXTI) 34 | 35 | /** @defgroup EXTI_LL EXTI 36 | * @{ 37 | */ 38 | 39 | /* Private types -------------------------------------------------------------*/ 40 | /* Private variables ---------------------------------------------------------*/ 41 | /* Private constants ---------------------------------------------------------*/ 42 | /* Private macros ------------------------------------------------------------*/ 43 | /** @addtogroup EXTI_LL_Private_Macros 44 | * @{ 45 | */ 46 | 47 | #define IS_LL_EXTI_LINE_0_31(__VALUE__) (((__VALUE__) & ~LL_EXTI_LINE_ALL_0_31) == 0x00000000U) 48 | 49 | #define IS_LL_EXTI_MODE(__VALUE__) (((__VALUE__) == LL_EXTI_MODE_IT) \ 50 | || ((__VALUE__) == LL_EXTI_MODE_EVENT) \ 51 | || ((__VALUE__) == LL_EXTI_MODE_IT_EVENT)) 52 | 53 | 54 | #define IS_LL_EXTI_TRIGGER(__VALUE__) (((__VALUE__) == LL_EXTI_TRIGGER_NONE) \ 55 | || ((__VALUE__) == LL_EXTI_TRIGGER_RISING) \ 56 | || ((__VALUE__) == LL_EXTI_TRIGGER_FALLING) \ 57 | || ((__VALUE__) == LL_EXTI_TRIGGER_RISING_FALLING)) 58 | 59 | /** 60 | * @} 61 | */ 62 | 63 | /* Private function prototypes -----------------------------------------------*/ 64 | 65 | /* Exported functions --------------------------------------------------------*/ 66 | /** @addtogroup EXTI_LL_Exported_Functions 67 | * @{ 68 | */ 69 | 70 | /** @addtogroup EXTI_LL_EF_Init 71 | * @{ 72 | */ 73 | 74 | /** 75 | * @brief De-initialize the EXTI registers to their default reset values. 76 | * @retval An ErrorStatus enumeration value: 77 | * - SUCCESS: EXTI registers are de-initialized 78 | * - ERROR: not applicable 79 | */ 80 | uint32_t LL_EXTI_DeInit(void) 81 | { 82 | /* Interrupt mask register set to default reset values */ 83 | LL_EXTI_WriteReg(IMR, 0x00000000U); 84 | /* Event mask register set to default reset values */ 85 | LL_EXTI_WriteReg(EMR, 0x00000000U); 86 | /* Rising Trigger selection register set to default reset values */ 87 | LL_EXTI_WriteReg(RTSR, 0x00000000U); 88 | /* Falling Trigger selection register set to default reset values */ 89 | LL_EXTI_WriteReg(FTSR, 0x00000000U); 90 | /* Software interrupt event register set to default reset values */ 91 | LL_EXTI_WriteReg(SWIER, 0x00000000U); 92 | /* Pending register set to default reset values */ 93 | LL_EXTI_WriteReg(PR, 0x01FFFFFFU); 94 | 95 | return SUCCESS; 96 | } 97 | 98 | /** 99 | * @brief Initialize the EXTI registers according to the specified parameters in EXTI_InitStruct. 100 | * @param EXTI_InitStruct pointer to a @ref LL_EXTI_InitTypeDef structure. 101 | * @retval An ErrorStatus enumeration value: 102 | * - SUCCESS: EXTI registers are initialized 103 | * - ERROR: not applicable 104 | */ 105 | uint32_t LL_EXTI_Init(LL_EXTI_InitTypeDef *EXTI_InitStruct) 106 | { 107 | ErrorStatus status = SUCCESS; 108 | /* Check the parameters */ 109 | assert_param(IS_LL_EXTI_LINE_0_31(EXTI_InitStruct->Line_0_31)); 110 | assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->LineCommand)); 111 | assert_param(IS_LL_EXTI_MODE(EXTI_InitStruct->Mode)); 112 | 113 | /* ENABLE LineCommand */ 114 | if (EXTI_InitStruct->LineCommand != DISABLE) 115 | { 116 | assert_param(IS_LL_EXTI_TRIGGER(EXTI_InitStruct->Trigger)); 117 | 118 | /* Configure EXTI Lines in range from 0 to 31 */ 119 | if (EXTI_InitStruct->Line_0_31 != LL_EXTI_LINE_NONE) 120 | { 121 | switch (EXTI_InitStruct->Mode) 122 | { 123 | case LL_EXTI_MODE_IT: 124 | /* First Disable Event on provided Lines */ 125 | LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31); 126 | /* Then Enable IT on provided Lines */ 127 | LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31); 128 | break; 129 | case LL_EXTI_MODE_EVENT: 130 | /* First Disable IT on provided Lines */ 131 | LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31); 132 | /* Then Enable Event on provided Lines */ 133 | LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31); 134 | break; 135 | case LL_EXTI_MODE_IT_EVENT: 136 | /* Directly Enable IT & Event on provided Lines */ 137 | LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31); 138 | LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31); 139 | break; 140 | default: 141 | status = ERROR; 142 | break; 143 | } 144 | if (EXTI_InitStruct->Trigger != LL_EXTI_TRIGGER_NONE) 145 | { 146 | switch (EXTI_InitStruct->Trigger) 147 | { 148 | case LL_EXTI_TRIGGER_RISING: 149 | /* First Disable Falling Trigger on provided Lines */ 150 | LL_EXTI_DisableFallingTrig_0_31(EXTI_InitStruct->Line_0_31); 151 | /* Then Enable Rising Trigger on provided Lines */ 152 | LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31); 153 | break; 154 | case LL_EXTI_TRIGGER_FALLING: 155 | /* First Disable Rising Trigger on provided Lines */ 156 | LL_EXTI_DisableRisingTrig_0_31(EXTI_InitStruct->Line_0_31); 157 | /* Then Enable Falling Trigger on provided Lines */ 158 | LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31); 159 | break; 160 | case LL_EXTI_TRIGGER_RISING_FALLING: 161 | LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31); 162 | LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31); 163 | break; 164 | default: 165 | status = ERROR; 166 | break; 167 | } 168 | } 169 | } 170 | } 171 | /* DISABLE LineCommand */ 172 | else 173 | { 174 | /* De-configure EXTI Lines in range from 0 to 31 */ 175 | LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31); 176 | LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31); 177 | } 178 | return status; 179 | } 180 | 181 | /** 182 | * @brief Set each @ref LL_EXTI_InitTypeDef field to default value. 183 | * @param EXTI_InitStruct Pointer to a @ref LL_EXTI_InitTypeDef structure. 184 | * @retval None 185 | */ 186 | void LL_EXTI_StructInit(LL_EXTI_InitTypeDef *EXTI_InitStruct) 187 | { 188 | EXTI_InitStruct->Line_0_31 = LL_EXTI_LINE_NONE; 189 | EXTI_InitStruct->LineCommand = DISABLE; 190 | EXTI_InitStruct->Mode = LL_EXTI_MODE_IT; 191 | EXTI_InitStruct->Trigger = LL_EXTI_TRIGGER_FALLING; 192 | } 193 | 194 | /** 195 | * @} 196 | */ 197 | 198 | /** 199 | * @} 200 | */ 201 | 202 | /** 203 | * @} 204 | */ 205 | 206 | #endif /* defined (EXTI) */ 207 | 208 | /** 209 | * @} 210 | */ 211 | 212 | #endif /* USE_FULL_LL_DRIVER */ 213 | 214 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 215 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/GBLiveCam.ioc: -------------------------------------------------------------------------------- 1 | #MicroXplorer Configuration settings - do not modify 2 | File.Version=6 3 | KeepUserPlacement=false 4 | Mcu.Family=STM32F7 5 | Mcu.IP0=CORTEX_M7 6 | Mcu.IP1=NVIC 7 | Mcu.IP2=RCC 8 | Mcu.IP3=SYS 9 | Mcu.IP4=USB_DEVICE 10 | Mcu.IP5=USB_OTG_FS 11 | Mcu.IPNb=6 12 | Mcu.Name=STM32F730R8Tx 13 | Mcu.Package=LQFP64 14 | Mcu.Pin0=PH0-OSC_IN 15 | Mcu.Pin1=PH1-OSC_OUT 16 | Mcu.Pin2=PA11 17 | Mcu.Pin3=PA12 18 | Mcu.Pin4=VP_SYS_VS_Systick 19 | Mcu.Pin5=VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS 20 | Mcu.PinsNb=6 21 | Mcu.ThirdPartyNb=0 22 | Mcu.UserConstants= 23 | Mcu.UserName=STM32F730R8Tx 24 | MxCube.Version=5.2.0 25 | MxDb.Version=DB.5.0.20 26 | NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 27 | NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false 28 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 29 | NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false 30 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false 31 | NVIC.OTG_FS_IRQn=true\:0\:0\:false\:false\:true\:false\:true 32 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false 33 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 34 | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false 35 | NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true 36 | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false 37 | PA11.Mode=Device_Only 38 | PA11.Signal=USB_OTG_FS_DM 39 | PA12.Mode=Device_Only 40 | PA12.Signal=USB_OTG_FS_DP 41 | PCC.Checker=false 42 | PCC.Line=STM32F7x0 Value line 43 | PCC.MCU=STM32F730R8Tx 44 | PCC.PartNumber=STM32F730R8Tx 45 | PCC.Seq0=0 46 | PCC.Series=STM32F7 47 | PCC.Temperature=25 48 | PCC.Vdd=3.3 49 | PH0-OSC_IN.Mode=HSE-External-Oscillator 50 | PH0-OSC_IN.Signal=RCC_OSC_IN 51 | PH1-OSC_OUT.Mode=HSE-External-Oscillator 52 | PH1-OSC_OUT.Signal=RCC_OSC_OUT 53 | PinOutPanel.RotationAngle=0 54 | ProjectManager.AskForMigrate=true 55 | ProjectManager.BackupPrevious=false 56 | ProjectManager.CompilerOptimize=6 57 | ProjectManager.ComputerToolchain=false 58 | ProjectManager.CoupleFile=false 59 | ProjectManager.CustomerFirmwarePackage= 60 | ProjectManager.DefaultFWLocation=true 61 | ProjectManager.DeletePrevious=true 62 | ProjectManager.DeviceId=STM32F730R8Tx 63 | ProjectManager.FirmwarePackage=STM32Cube FW_F7 V1.15.0 64 | ProjectManager.FreePins=false 65 | ProjectManager.HalAssertFull=false 66 | ProjectManager.HeapSize=0x400 67 | ProjectManager.KeepUserCode=true 68 | ProjectManager.LastFirmware=true 69 | ProjectManager.LibraryCopy=1 70 | ProjectManager.MainLocation=Src 71 | ProjectManager.NoMain=false 72 | ProjectManager.PreviousToolchain=STM32CubeIDE 73 | ProjectManager.ProjectBuild=false 74 | ProjectManager.ProjectFileName=UVC_test.ioc 75 | ProjectManager.ProjectName=UVC_test 76 | ProjectManager.StackSize=0x400 77 | ProjectManager.TargetToolchain=STM32CubeIDE 78 | ProjectManager.ToolChainLocation= 79 | ProjectManager.UnderRoot=true 80 | ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-true 81 | RCC.FamilyName=M 82 | RCC.HSE_VALUE=8000000 83 | RCC.HSI_VALUE=16000000 84 | RCC.I2SFreq_Value=192000000 85 | RCC.IPParameters=FamilyName,HSE_VALUE,HSI_VALUE,I2SFreq_Value,LSE_VALUE,LSI_VALUE,PLLCLKFreq_Value,PLLI2SQCLKFreq_Value,PLLI2SRCLKFreq_Value,PLLI2SRoutputFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLQoutputFreq_Value,PLLSAIPCLKFreq_Value,PLLSAIQCLKFreq_Value,PLLSAIoutputFreq_Value,RNGFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SDMMCFreq_Value,USBFreq_Value,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAIOutputFreq_Value 86 | RCC.LSE_VALUE=32768 87 | RCC.LSI_VALUE=32000 88 | RCC.PLLCLKFreq_Value=96000000 89 | RCC.PLLI2SQCLKFreq_Value=192000000 90 | RCC.PLLI2SRCLKFreq_Value=192000000 91 | RCC.PLLI2SRoutputFreq_Value=192000000 92 | RCC.PLLM=4 93 | RCC.PLLN=96 94 | RCC.PLLQ=4 95 | RCC.PLLQCLKFreq_Value=48000000 96 | RCC.PLLQoutputFreq_Value=48000000 97 | RCC.PLLSAIPCLKFreq_Value=192000000 98 | RCC.PLLSAIQCLKFreq_Value=192000000 99 | RCC.PLLSAIoutputFreq_Value=192000000 100 | RCC.RNGFreq_Value=48000000 101 | RCC.SAI1Freq_Value=192000000 102 | RCC.SAI2Freq_Value=192000000 103 | RCC.SDMMCFreq_Value=16000000 104 | RCC.USBFreq_Value=48000000 105 | RCC.VCOI2SOutputFreq_Value=384000000 106 | RCC.VCOInputFreq_Value=2000000 107 | RCC.VCOOutputFreq_Value=192000000 108 | RCC.VCOSAIOutputFreq_Value=384000000 109 | USB_DEVICE.CLASS_NAME_FS=AUDIO 110 | USB_DEVICE.IPParameters=VirtualMode-AUDIO_FS,VirtualModeFS,CLASS_NAME_FS 111 | USB_DEVICE.VirtualMode-AUDIO_FS=Audio 112 | USB_DEVICE.VirtualModeFS=Audio_FS 113 | USB_OTG_FS.IPParameters=VirtualMode 114 | USB_OTG_FS.VirtualMode=Device_Only 115 | VP_SYS_VS_Systick.Mode=SysTick 116 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick 117 | VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Mode=AUDIO_FS 118 | VP_USB_DEVICE_VS_USB_DEVICE_AUDIO_FS.Signal=USB_DEVICE_VS_USB_DEVICE_AUDIO_FS 119 | board=custom 120 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Inc/gbcam.h: -------------------------------------------------------------------------------- 1 | #ifndef __GBCAM_H 2 | #define __GBCAM_H 3 | 4 | #define GB_FRAME_SIZE 3584 // 128 * 112 * 2bpp / 8 bits 5 | #define GBC_TIMEOUT 50000 // CPU speed dependent ! 6 | 7 | #define GBCCS_LOW GPIOA->BSRR = (LL_GPIO_PIN_5 << 16); 8 | #define GBCCS_HIGH GPIOA->BSRR = LL_GPIO_PIN_5; 9 | #define GBCRD_LOW GPIOA->BSRR = (LL_GPIO_PIN_6 << 16); 10 | #define GBCRD_HIGH GPIOA->BSRR = LL_GPIO_PIN_6; 11 | #if PCBREV == 'B' 12 | #define GBCWR_LOW GPIOA->BSRR = (LL_GPIO_PIN_7 << 16); 13 | #define GBCWR_HIGH GPIOA->BSRR = LL_GPIO_PIN_7; 14 | #else 15 | #define GBCWR_LOW GPIOA->BSRR = (LL_GPIO_PIN_8 << 16); 16 | #define GBCWR_HIGH GPIOA->BSRR = LL_GPIO_PIN_8; 17 | #endif 18 | #define GBCRST_LOW GPIOC->BSRR = (LL_GPIO_PIN_3 << 16); 19 | #define GBCRST_HIGH GPIOC->BSRR = LL_GPIO_PIN_3; 20 | #define GBBUS_OUTPUT GPIOC->MODER = (GPIOC->MODER & 0x0000FFFF) | 0x55550000; // 0b0101010101010101<<16 21 | #define GBBUS_INPUT GPIOC->MODER = (GPIOC->MODER & 0x0000FFFF); 22 | #define GBBUS_SET(v) GPIOC->ODR = ((GPIOC->ODR & 0x00FF) | ((v) << 8)); 23 | #define GBBUS_READ ((GPIOC->IDR & 0xFF00) >> 8); 24 | 25 | #if PCBREV == 'B' 26 | #define ALEL_LOW GPIOA->BSRR = (LL_GPIO_PIN_8 << 16); 27 | #define ALEL_HIGH GPIOA->BSRR = LL_GPIO_PIN_8; 28 | #define ALEH_LOW GPIOC->BSRR = (LL_GPIO_PIN_0 << 16); 29 | #define ALEH_HIGH GPIOC->BSRR = LL_GPIO_PIN_0; 30 | #endif 31 | 32 | void cart_set_address(const uint16_t address); 33 | uint8_t cart_get_ram(const uint16_t address); 34 | uint8_t cart_get_rom(const uint16_t address); 35 | void cart_put(const uint16_t address, const uint8_t value); 36 | void gbcam_reset(); 37 | void gbcam_init(); 38 | uint32_t gbcam_detect(); 39 | uint8_t gbcam_wait_busy(); 40 | uint8_t gbcam_wait_idle(); 41 | void gbcam_setmatrix(const uint8_t slope, const uint8_t offset); 42 | void gbcam_setgain(const uint32_t gain); 43 | void gbcam_setexposure(const uint16_t exposure); 44 | 45 | #endif /* __GBCAM_H */ 46 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Inc/init.h: -------------------------------------------------------------------------------- 1 | #ifndef __INIT_H 2 | #define __INIT_H 3 | 4 | void MX_ADC1_Init(void); 5 | void SystemClock_Config(void); 6 | void MX_GPIO_Init(void); 7 | 8 | #endif /* __INIT_H */ 9 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Inc/main.h: -------------------------------------------------------------------------------- 1 | #ifndef __MAIN_H 2 | #define __MAIN_H 3 | 4 | #include "stm32f7xx_hal.h" 5 | #include "stm32f7xx_ll_adc.h" 6 | #include "stm32f7xx_ll_rcc.h" 7 | #include "stm32f7xx_ll_bus.h" 8 | #include "stm32f7xx_ll_system.h" 9 | #include "stm32f7xx_ll_exti.h" 10 | #include "stm32f7xx_ll_cortex.h" 11 | #include "stm32f7xx_ll_utils.h" 12 | #include "stm32f7xx_ll_pwr.h" 13 | #include "stm32f7xx_ll_dma.h" 14 | #include "stm32f7xx.h" 15 | #include "stm32f7xx_ll_gpio.h" 16 | 17 | #define PCBREV 'C' 18 | 19 | #if PCBREV == 'B' 20 | #define VERSION_STR "1.0B" 21 | #else 22 | #define VERSION_STR "1.0C" 23 | #endif 24 | 25 | #define ERROR_THRESHOLD 3 26 | 27 | #define SPECIAL_VALUE_VERSION 123 28 | #define SPECIAL_VALUE_DEBUG 999 29 | #define SPECIAL_VALUE_DFU 1337 30 | 31 | #define ADDR_SYSMEM (uint32_t)0x00100000 // RM0431 page 56 32 | 33 | void Error_Handler(void); 34 | void delay_us(uint32_t delay); 35 | 36 | volatile enum { 37 | STATUS_STOPPED, 38 | STATUS_READY, 39 | STATUS_RUNNING 40 | } cam_status; 41 | 42 | volatile struct { 43 | uint32_t exposure; 44 | uint8_t auto_exposure; 45 | uint16_t hue; 46 | uint16_t brightness; 47 | uint16_t contrast; 48 | uint16_t gain; 49 | uint16_t debug; 50 | } settings; 51 | 52 | extern volatile uint8_t new_frame_trigger; 53 | extern volatile uint8_t flag_update_matrix; 54 | extern volatile uint8_t flag_update_exposure; 55 | extern TIM_HandleTypeDef s_PhiTimer; 56 | extern uint32_t OSD_timer; 57 | extern uint32_t error_acc; 58 | extern int16_t final_exposure; 59 | 60 | extern volatile uint8_t debug_val; 61 | 62 | #endif /* __MAIN_H */ 63 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Inc/osd.h: -------------------------------------------------------------------------------- 1 | #ifndef OSD_H_ 2 | #define OSD_H_ 3 | 4 | void OSD_write_value(const uint8_t px, const uint8_t py, uint8_t* buffer, const char letter, uint32_t value, const uint32_t digits); 5 | void OSD_write(const uint8_t px, const uint8_t py, uint8_t* buffer, char* txt); 6 | void OSD_write_nocam(uint8_t* buffer); 7 | uint8_t OSD_write_special(uint8_t* buffer); 8 | 9 | #endif /* OSD_H_ */ 10 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Inc/palettes.h: -------------------------------------------------------------------------------- 1 | #ifndef __PALETTES_H 2 | #define __PALETTES_H 3 | 4 | typedef struct { 5 | uint8_t Y, U, V; 6 | } YUV_t; 7 | 8 | typedef struct { 9 | YUV_t color[4]; 10 | char name[11]; 11 | } palette_t; 12 | 13 | extern const palette_t palettes[8]; 14 | 15 | #endif /* __PALETTES_H */ 16 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Inc/stm32f7xx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f7xx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2019 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32F7xx_IT_H 23 | #define __STM32F7xx_IT_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Private includes ----------------------------------------------------------*/ 30 | /* USER CODE BEGIN Includes */ 31 | 32 | /* USER CODE END Includes */ 33 | 34 | /* Exported types ------------------------------------------------------------*/ 35 | /* USER CODE BEGIN ET */ 36 | 37 | /* USER CODE END ET */ 38 | 39 | /* Exported constants --------------------------------------------------------*/ 40 | /* USER CODE BEGIN EC */ 41 | 42 | /* USER CODE END EC */ 43 | 44 | /* Exported macro ------------------------------------------------------------*/ 45 | /* USER CODE BEGIN EM */ 46 | 47 | /* USER CODE END EM */ 48 | 49 | /* Exported functions prototypes ---------------------------------------------*/ 50 | void NMI_Handler(void); 51 | void HardFault_Handler(void); 52 | void MemManage_Handler(void); 53 | void BusFault_Handler(void); 54 | void UsageFault_Handler(void); 55 | void SVC_Handler(void); 56 | void DebugMon_Handler(void); 57 | void PendSV_Handler(void); 58 | void SysTick_Handler(void); 59 | void OTG_FS_IRQHandler(void); 60 | /* USER CODE BEGIN EFP */ 61 | 62 | /* USER CODE END EFP */ 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | 68 | #endif /* __STM32F7xx_IT_H */ 69 | 70 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 71 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Inc/usb_device.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usb_device.h 5 | * @version : v1.0_Cube 6 | * @brief : Header for usb_device.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© Copyright (c) 2019 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under Ultimate Liberty license 14 | * SLA0044, the "License"; You may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at: 16 | * www.st.com/SLA0044 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __USB_DEVICE__H__ 24 | #define __USB_DEVICE__H__ 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Includes ------------------------------------------------------------------*/ 31 | #include "stm32f7xx.h" 32 | #include "stm32f7xx_hal.h" 33 | #include "usbd_def.h" 34 | 35 | /* USER CODE BEGIN INCLUDE */ 36 | 37 | /* USER CODE END INCLUDE */ 38 | 39 | /** @addtogroup USBD_OTG_DRIVER 40 | * @{ 41 | */ 42 | 43 | /** @defgroup USBD_DEVICE USBD_DEVICE 44 | * @brief Device file for Usb otg low level driver. 45 | * @{ 46 | */ 47 | 48 | /** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables 49 | * @brief Public variables. 50 | * @{ 51 | */ 52 | 53 | /* Private variables ---------------------------------------------------------*/ 54 | /* USER CODE BEGIN PV */ 55 | 56 | /* USER CODE END PV */ 57 | 58 | /* Private function prototypes -----------------------------------------------*/ 59 | /* USER CODE BEGIN PFP */ 60 | 61 | /* USER CODE END PFP */ 62 | 63 | /* 64 | * -- Insert your variables declaration here -- 65 | */ 66 | /* USER CODE BEGIN VARIABLES */ 67 | 68 | /* USER CODE END VARIABLES */ 69 | /** 70 | * @} 71 | */ 72 | 73 | /** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype 74 | * @brief Declaration of public functions for Usb device. 75 | * @{ 76 | */ 77 | 78 | /** USB Device initialization function. */ 79 | void MX_USB_DEVICE_Init(void); 80 | 81 | /* 82 | * -- Insert functions declaration here -- 83 | */ 84 | /* USER CODE BEGIN FD */ 85 | 86 | /* USER CODE END FD */ 87 | /** 88 | * @} 89 | */ 90 | 91 | /** 92 | * @} 93 | */ 94 | 95 | /** 96 | * @} 97 | */ 98 | 99 | #ifdef __cplusplus 100 | } 101 | #endif 102 | 103 | #endif /* __USB_DEVICE__H__ */ 104 | 105 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 106 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Inc/usbd_audio_if.h: -------------------------------------------------------------------------------- 1 | #ifndef __USBD_AUDIO_IF_H__ 2 | #define __USBD_AUDIO_IF_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "usbd_uvc.h" 9 | 10 | //extern USBD_VIDEO_ItfTypeDef USBD_VIDEO_fops_FS; 11 | 12 | void TransferComplete_CallBack_FS(void); 13 | void HalfTransfer_CallBack_FS(void); 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | 19 | #endif /* __USBD_AUDIO_IF_H__ */ 20 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Inc/usbd_conf.h: -------------------------------------------------------------------------------- 1 | #ifndef __USBD_CONF__H__ 2 | #define __USBD_CONF__H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | #include "main.h" 12 | #include "stm32f7xx.h" 13 | #include "stm32f7xx_hal.h" 14 | 15 | /* AudioConf, AudioStream IN */ 16 | #define USBD_MAX_NUM_INTERFACES 1 17 | /*---------- -----------*/ 18 | #define USBD_MAX_NUM_CONFIGURATION 1U 19 | /*---------- -----------*/ 20 | #define USBD_MAX_STR_DESC_SIZ 512U 21 | /*---------- -----------*/ 22 | #define USBD_SUPPORT_USER_STRING 0U 23 | /*---------- -----------*/ 24 | #define USBD_DEBUG_LEVEL 1U 25 | /*---------- -----------*/ 26 | #define USBD_LPM_ENABLED 0U 27 | /*---------- -----------*/ 28 | #define USBD_SELF_POWERED 1U 29 | /*---------- -----------*/ 30 | #define USBD_AUDIO_FREQ 22100U 31 | 32 | /****************************************/ 33 | /* #define for FS and HS identification */ 34 | #define DEVICE_FS 0 35 | #define DEVICE_HS 1 36 | 37 | /* Memory management macros */ 38 | 39 | /** Alias for memory allocation. */ 40 | #define USBD_malloc malloc 41 | 42 | /** Alias for memory release. */ 43 | #define USBD_free free 44 | 45 | /** Alias for memory set. */ 46 | #define USBD_memset memset 47 | 48 | /** Alias for memory copy. */ 49 | #define USBD_memcpy memcpy 50 | 51 | /** Alias for delay. */ 52 | #define USBD_Delay HAL_Delay 53 | 54 | /* DEBUG macros */ 55 | 56 | #if (USBD_DEBUG_LEVEL > 0) 57 | #define USBD_UsrLog(...) printf(__VA_ARGS__);\ 58 | printf("\n"); 59 | #else 60 | #define USBD_UsrLog(...) 61 | #endif 62 | 63 | #if (USBD_DEBUG_LEVEL > 1) 64 | 65 | #define USBD_ErrLog(...) printf("ERROR: ") ;\ 66 | printf(__VA_ARGS__);\ 67 | printf("\n"); 68 | #else 69 | #define USBD_ErrLog(...) 70 | #endif 71 | 72 | #if (USBD_DEBUG_LEVEL > 2) 73 | #define USBD_DbgLog(...) printf("DEBUG : ") ;\ 74 | printf(__VA_ARGS__);\ 75 | printf("\n"); 76 | #else 77 | #define USBD_DbgLog(...) 78 | #endif 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | 84 | #endif /* __USBD_CONF__H__ */ 85 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Inc/usbd_desc.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : usbd_desc.c 5 | * @version : v1.0_Cube 6 | * @brief : Header for usbd_conf.c file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© Copyright (c) 2019 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under Ultimate Liberty license 14 | * SLA0044, the "License"; You may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at: 16 | * www.st.com/SLA0044 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __USBD_DESC__C__ 23 | #define __USBD_DESC__C__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "usbd_def.h" 31 | 32 | /* USER CODE BEGIN INCLUDE */ 33 | 34 | /* USER CODE END INCLUDE */ 35 | 36 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY 37 | * @{ 38 | */ 39 | 40 | /** @defgroup USBD_DESC USBD_DESC 41 | * @brief Usb device descriptors module. 42 | * @{ 43 | */ 44 | 45 | /** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants 46 | * @brief Constants. 47 | * @{ 48 | */ 49 | #define DEVICE_ID1 (UID_BASE) 50 | #define DEVICE_ID2 (UID_BASE + 0x4) 51 | #define DEVICE_ID3 (UID_BASE + 0x8) 52 | 53 | #define USB_SIZ_STRING_SERIAL 0x1A 54 | 55 | /* USER CODE BEGIN EXPORTED_CONSTANTS */ 56 | 57 | /* USER CODE END EXPORTED_CONSTANTS */ 58 | 59 | /** 60 | * @} 61 | */ 62 | 63 | /** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines 64 | * @brief Defines. 65 | * @{ 66 | */ 67 | 68 | /* USER CODE BEGIN EXPORTED_DEFINES */ 69 | 70 | /* USER CODE END EXPORTED_DEFINES */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions 77 | * @brief Types. 78 | * @{ 79 | */ 80 | 81 | /* USER CODE BEGIN EXPORTED_TYPES */ 82 | 83 | /* USER CODE END EXPORTED_TYPES */ 84 | 85 | /** 86 | * @} 87 | */ 88 | 89 | /** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros 90 | * @brief Aliases. 91 | * @{ 92 | */ 93 | 94 | /* USER CODE BEGIN EXPORTED_MACRO */ 95 | 96 | /* USER CODE END EXPORTED_MACRO */ 97 | 98 | /** 99 | * @} 100 | */ 101 | 102 | /** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables 103 | * @brief Public variables. 104 | * @{ 105 | */ 106 | 107 | /** Descriptor for the Usb device. */ 108 | extern USBD_DescriptorsTypeDef FS_Desc; 109 | 110 | /* USER CODE BEGIN EXPORTED_VARIABLES */ 111 | 112 | /* USER CODE END EXPORTED_VARIABLES */ 113 | 114 | /** 115 | * @} 116 | */ 117 | 118 | /** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype 119 | * @brief Public functions declaration. 120 | * @{ 121 | */ 122 | 123 | /* USER CODE BEGIN EXPORTED_FUNCTIONS */ 124 | 125 | /* USER CODE END EXPORTED_FUNCTIONS */ 126 | 127 | /** 128 | * @} 129 | */ 130 | 131 | /** 132 | * @} 133 | */ 134 | 135 | /** 136 | * @} 137 | */ 138 | 139 | #ifdef __cplusplus 140 | } 141 | #endif 142 | 143 | #endif /* __USBD_DESC__C__ */ 144 | 145 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 146 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Inc/uvc_req.h: -------------------------------------------------------------------------------- 1 | #ifndef __UVC_REQ_H 2 | #define __UVC_REQ_H 3 | 4 | #include "uvc.h" 5 | #include "usbd_def.h" 6 | 7 | typedef struct { 8 | uint8_t data[USB_MAX_EP0_SIZE]; 9 | uint8_t len; 10 | uint8_t unit; // Interface 11 | uint8_t cs; // Control 12 | } UVCClassData_t; 13 | 14 | void UVC_REQ_CT(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 15 | void UVC_REQ_PU(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 16 | void UVC_REQ_STREAM(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 17 | 18 | #endif /* __UVC_REQ_H */ 19 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Middlewares/ST/STM32_USB_Device_Library/Class/UVC/Inc/usbd_uvc.h: -------------------------------------------------------------------------------- 1 | #ifndef __USB_AUDIO_H 2 | #define __USB_AUDIO_H 3 | 4 | #include "usbd_ioreq.h" 5 | 6 | #define WBVAL(x) (x & 0xFF),((x >> 8) & 0xFF) 7 | #define DBVAL(x) (x & 0xFF),((x >> 8) & 0xFF),((x >> 16) & 0xFF),((x >> 24) & 0xFF) 8 | 9 | #define WIDTH (unsigned int)256 10 | #define HEIGHT (unsigned int)224 11 | #define CAM_FPS 8 12 | #define VIDEO_PACKET_SIZE (unsigned int)((672)+2) //672 862! 13 | #define MIN_BIT_RATE (unsigned long)(WIDTH*HEIGHT*16*CAM_FPS)//16 bit 14 | #define MAX_BIT_RATE (unsigned long)(WIDTH*HEIGHT*16*CAM_FPS) 15 | //#define MAX_FRAME_SIZE (unsigned long)(WIDTH*HEIGHT*2)//yuy2 16 | #define MAX_FRAME_SIZE (unsigned long)(WIDTH*HEIGHT*3/2)//nv12 17 | #define INTERVAL (unsigned long)(10000000/CAM_FPS) 18 | #define PACKETS_IN_FRAME (unsigned int)(MAX_FRAME_SIZE/(VIDEO_PACKET_SIZE-2)) 19 | 20 | #define USB_VIDEO_DESC_SIZ (unsigned long)(\ 21 | USB_CONFIGUARTION_DESC_SIZE +\ 22 | UVC_INTERFACE_ASSOCIATION_DESC_SIZE +\ 23 | USB_INTERFACE_DESC_SIZE + \ 24 | UVC_VC_INTERFACE_HEADER_DESC_SIZE(1) + \ 25 | UVC_CAMERA_TERMINAL_DESC_SIZE(2) + \ 26 | UVC_OUTPUT_TERMINAL_DESC_SIZE(0) + \ 27 | UVC_PROCESSING_UNIT_DESC_SIZE(2) + \ 28 | USB_INTERFACE_DESC_SIZE + \ 29 | UVC_VS_INTERFACE_INPUT_HEADER_DESC_SIZE(1,1) + \ 30 | VS_FORMAT_UNCOMPRESSED_DESC_SIZE + \ 31 | VS_FRAME_UNCOMPRESSED_DESC_SIZE + \ 32 | VS_COLOR_MATCHING_DESC_SIZE +\ 33 | USB_INTERFACE_DESC_SIZE + \ 34 | USB_ENDPOINT_DESC_SIZE) 35 | 36 | #define VC_TERMINAL_SIZ (unsigned int)(UVC_VC_INTERFACE_HEADER_DESC_SIZE(1) + UVC_CAMERA_TERMINAL_DESC_SIZE(2) + UVC_OUTPUT_TERMINAL_DESC_SIZE(0) + UVC_PROCESSING_UNIT_DESC_SIZE(2)) 37 | #define VC_HEADER_SIZ (unsigned int)(UVC_VS_INTERFACE_INPUT_HEADER_DESC_SIZE(1,1) + VS_FORMAT_UNCOMPRESSED_DESC_SIZE + VS_FRAME_UNCOMPRESSED_DESC_SIZE + VS_COLOR_MATCHING_DESC_SIZE) 38 | 39 | 40 | #define USB_DEVICE_DESC_SIZE (sizeof(USB_DEVICE_DESCRIPTOR)) 41 | #define USB_CONFIGUARTION_DESC_SIZE (char)9 42 | #define USB_INTERFACE_DESC_SIZE (char)9 43 | #define USB_ENDPOINT_DESC_SIZE (char)7 44 | #define UVC_INTERFACE_ASSOCIATION_DESC_SIZE (char)8 45 | #define UVC_VC_ENDPOINT_DESC_SIZE (char)5 46 | 47 | #define UVC_VC_INTERFACE_HEADER_DESC_SIZE(n) (char)(12+n) 48 | #define UVC_CAMERA_TERMINAL_DESC_SIZE(n) (char)(15+n) 49 | #define UVC_OUTPUT_TERMINAL_DESC_SIZE(n) (char)(9+n) 50 | #define UVC_PROCESSING_UNIT_DESC_SIZE(n) (char)(10+n) 51 | #define UVC_VS_INTERFACE_INPUT_HEADER_DESC_SIZE(a,b) (char)(13+a*b) 52 | 53 | 54 | #define VS_FORMAT_UNCOMPRESSED_DESC_SIZE (char)(27) 55 | #define VS_FRAME_UNCOMPRESSED_DESC_SIZE (char)(30) 56 | #define VS_COLOR_MATCHING_DESC_SIZE (char)(6) 57 | 58 | #define USB_UVC_VCIF_NUM 0 59 | #define USB_UVC_VSIF_NUM (char)1 60 | 61 | #define VIDEO_TOTAL_IF_NUM 2 62 | 63 | //UVC 1.0 uses only 26 first bytes 64 | typedef struct { 65 | uint8_t bmHint[2]; // 2 66 | uint8_t bFormatIndex[1]; // 3 67 | uint8_t bFrameIndex[1]; // 4 68 | uint8_t dwFrameInterval[4]; // 8 69 | uint8_t wKeyFrameRate[2]; // 10 70 | uint8_t wPFrameRate[2]; // 12 71 | uint8_t wCompQuality[2]; // 14 72 | uint8_t wCompWindowSize[2]; // 16 73 | uint8_t wDelay[2]; // 18 74 | uint8_t dwMaxVideoFrameSize[4]; // 22 75 | uint8_t dwMaxPayloadTransferSize[4]; // 26 76 | uint8_t dwClockFrequency[4]; 77 | uint8_t bmFramingInfo[1]; 78 | uint8_t bPreferedVersion[1]; 79 | uint8_t bMinVersion[1]; 80 | uint8_t bMaxVersion[1]; 81 | } VideoControl; 82 | 83 | /* bmRequestType.Dir */ 84 | #define REQUEST_HOST_TO_DEVICE 0 85 | #define REQUEST_DEVICE_TO_HOST 1 86 | 87 | /* bmRequestType.Type */ 88 | #define REQUEST_STANDARD 0 89 | #define REQUEST_CLASS 1 90 | #define REQUEST_VENDOR 2 91 | #define REQUEST_RESERVED 3 92 | 93 | /* bmRequestType.Recipient */ 94 | #define REQUEST_TO_DEVICE 0 95 | #define REQUEST_TO_INTERFACE 1 96 | #define REQUEST_TO_ENDPOINT 2 97 | #define REQUEST_TO_OTHER 3 98 | 99 | #define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE 6 100 | #define USB_OTHER_SPEED_CONFIG_DESCRIPTOR_TYPE 7 101 | #define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 8 102 | #define USB_OTG_DESCRIPTOR_TYPE 9 103 | #define USB_DEBUG_DESCRIPTOR_TYPE 10 104 | #define USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE 11 105 | 106 | /* USB Device Classes */ 107 | #define USB_DEVICE_CLASS_RESERVED 0x00 108 | #define USB_DEVICE_CLASS_AUDIO 0x01 109 | #define USB_DEVICE_CLASS_COMMUNICATIONS 0x02 110 | #define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03 111 | #define USB_DEVICE_CLASS_MONITOR 0x04 112 | #define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05 113 | #define USB_DEVICE_CLASS_POWER 0x06 114 | #define USB_DEVICE_CLASS_PRINTER 0x07 115 | #define USB_DEVICE_CLASS_STORAGE 0x08 116 | #define USB_DEVICE_CLASS_HUB 0x09 117 | #define USB_DEVICE_CLASS_MISCELLANEOUS 0xEF 118 | #define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF 119 | 120 | /* bmAttributes in Configuration Descriptor */ 121 | #define USB_CONFIG_POWERED_MASK 0xC0 122 | #define USB_CONFIG_BUS_POWERED 0x80 123 | 124 | /* bMaxPower in Configuration Descriptor */ 125 | #define USB_CONFIG_POWER_MA(mA) ((mA)/2) 126 | 127 | /* bEndpointAddress in Endpoint Descriptor */ 128 | #define USB_ENDPOINT_DIRECTION_MASK 0x80 129 | #define USB_ENDPOINT_OUT(addr) ((addr) | 0x00) 130 | #define USB_ENDPOINT_IN(addr) ((addr) | 0x80) 131 | 132 | /* bmAttributes in Endpoint Descriptor */ 133 | #define USB_ENDPOINT_TYPE_MASK 0x03 134 | #define USB_ENDPOINT_TYPE_CONTROL 0x00 135 | #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01 136 | #define USB_ENDPOINT_TYPE_BULK 0x02 137 | #define USB_ENDPOINT_TYPE_INTERRUPT 0x03 138 | #define USB_ENDPOINT_SYNC_MASK 0x0C 139 | #define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION 0x00 140 | #define USB_ENDPOINT_SYNC_ASYNCHRONOUS 0x04 141 | #define USB_ENDPOINT_SYNC_ADAPTIVE 0x08 142 | #define USB_ENDPOINT_SYNC_SYNCHRONOUS 0x0C 143 | #define USB_ENDPOINT_USAGE_MASK 0x30 144 | #define USB_ENDPOINT_USAGE_DATA 0x00 145 | #define USB_ENDPOINT_USAGE_FEEDBACK 0x10 146 | #define USB_ENDPOINT_USAGE_IMPLICIT_FEEDBACK 0x20 147 | #define USB_ENDPOINT_USAGE_RESERVED 0x30 148 | 149 | typedef struct { 150 | uint8_t (*VideoInit)(void); 151 | uint8_t (*VideoDeInit)(void); 152 | uint8_t (*VideoCmd)(uint8_t* pbuf, uint32_t size, uint8_t cmd); 153 | uint8_t (*VideoGetState)(void); 154 | } VIDEO_FOPS_TypeDef; 155 | 156 | extern USBD_ClassTypeDef USBD_VIDEO; 157 | 158 | #endif /* __USB_AUDIO_H */ 159 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Middlewares/ST/STM32_USB_Device_Library/Class/UVC/Inc/uvc_desc.h: -------------------------------------------------------------------------------- 1 | #ifndef __UVC_DESC_H 2 | #define __UVC_DESC_H 3 | 4 | #include "uvc.h" 5 | #include "usbd_uvc.h" 6 | 7 | extern VideoControl videoCommitControl; 8 | extern VideoControl videoProbeControl; 9 | 10 | extern const uint8_t USBD_VIDEO_CfgDesc[USB_VIDEO_DESC_SIZ]; 11 | extern const uint8_t USBD_VIDEO_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC]; 12 | 13 | #endif /* __UVC_DESC_H */ 14 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_core.h 4 | * @author MCD Application Team 5 | * @brief Header file for usbd_core.c file 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2015 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * http://www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __USBD_CORE_H 22 | #define __USBD_CORE_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbd_conf.h" 30 | #include "usbd_def.h" 31 | #include "usbd_ioreq.h" 32 | #include "usbd_ctlreq.h" 33 | 34 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 35 | * @{ 36 | */ 37 | 38 | /** @defgroup USBD_CORE 39 | * @brief This file is the Header file for usbd_core.c file 40 | * @{ 41 | */ 42 | 43 | 44 | /** @defgroup USBD_CORE_Exported_Defines 45 | * @{ 46 | */ 47 | #ifndef USBD_DEBUG_LEVEL 48 | #define USBD_DEBUG_LEVEL 0U 49 | #endif /* USBD_DEBUG_LEVEL */ 50 | /** 51 | * @} 52 | */ 53 | 54 | 55 | /** @defgroup USBD_CORE_Exported_TypesDefinitions 56 | * @{ 57 | */ 58 | 59 | 60 | /** 61 | * @} 62 | */ 63 | 64 | 65 | 66 | /** @defgroup USBD_CORE_Exported_Macros 67 | * @{ 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** @defgroup USBD_CORE_Exported_Variables 75 | * @{ 76 | */ 77 | #define USBD_SOF USBD_LL_SOF 78 | /** 79 | * @} 80 | */ 81 | 82 | /** @defgroup USBD_CORE_Exported_FunctionsPrototype 83 | * @{ 84 | */ 85 | USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev, USBD_DescriptorsTypeDef *pdesc, uint8_t id); 86 | USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev); 87 | USBD_StatusTypeDef USBD_Start (USBD_HandleTypeDef *pdev); 88 | USBD_StatusTypeDef USBD_Stop (USBD_HandleTypeDef *pdev); 89 | USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass); 90 | 91 | USBD_StatusTypeDef USBD_RunTestMode (USBD_HandleTypeDef *pdev); 92 | USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx); 93 | USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx); 94 | 95 | USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup); 96 | USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev , uint8_t epnum, uint8_t *pdata); 97 | USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev , uint8_t epnum, uint8_t *pdata); 98 | 99 | USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev); 100 | USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev, USBD_SpeedTypeDef speed); 101 | USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev); 102 | USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev); 103 | 104 | USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev); 105 | USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum); 106 | USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum); 107 | 108 | USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev); 109 | USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev); 110 | 111 | /* USBD Low Level Driver */ 112 | USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev); 113 | USBD_StatusTypeDef USBD_LL_DeInit (USBD_HandleTypeDef *pdev); 114 | USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev); 115 | USBD_StatusTypeDef USBD_LL_Stop (USBD_HandleTypeDef *pdev); 116 | USBD_StatusTypeDef USBD_LL_OpenEP (USBD_HandleTypeDef *pdev, 117 | uint8_t ep_addr, 118 | uint8_t ep_type, 119 | uint16_t ep_mps); 120 | 121 | USBD_StatusTypeDef USBD_LL_CloseEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 122 | USBD_StatusTypeDef USBD_LL_FlushEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 123 | USBD_StatusTypeDef USBD_LL_StallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 124 | USBD_StatusTypeDef USBD_LL_ClearStallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 125 | uint8_t USBD_LL_IsStallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 126 | USBD_StatusTypeDef USBD_LL_SetUSBAddress (USBD_HandleTypeDef *pdev, uint8_t dev_addr); 127 | USBD_StatusTypeDef USBD_LL_Transmit (USBD_HandleTypeDef *pdev, 128 | uint8_t ep_addr, 129 | uint8_t *pbuf, 130 | uint16_t size); 131 | 132 | USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, 133 | uint8_t ep_addr, 134 | uint8_t *pbuf, 135 | uint16_t size); 136 | 137 | uint32_t USBD_LL_GetRxDataSize (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 138 | void USBD_LL_Delay (uint32_t Delay); 139 | 140 | /** 141 | * @} 142 | */ 143 | 144 | #ifdef __cplusplus 145 | } 146 | #endif 147 | 148 | #endif /* __USBD_CORE_H */ 149 | 150 | /** 151 | * @} 152 | */ 153 | 154 | /** 155 | * @} 156 | */ 157 | 158 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_req.h 4 | * @author MCD Application Team 5 | * @brief Header file for the usbd_req.c file 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2015 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * http://www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __USB_REQUEST_H 22 | #define __USB_REQUEST_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbd_def.h" 30 | 31 | 32 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 33 | * @{ 34 | */ 35 | 36 | /** @defgroup USBD_REQ 37 | * @brief header file for the usbd_req.c file 38 | * @{ 39 | */ 40 | 41 | /** @defgroup USBD_REQ_Exported_Defines 42 | * @{ 43 | */ 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @defgroup USBD_REQ_Exported_Types 50 | * @{ 51 | */ 52 | /** 53 | * @} 54 | */ 55 | 56 | 57 | 58 | /** @defgroup USBD_REQ_Exported_Macros 59 | * @{ 60 | */ 61 | /** 62 | * @} 63 | */ 64 | 65 | /** @defgroup USBD_REQ_Exported_Variables 66 | * @{ 67 | */ 68 | /** 69 | * @} 70 | */ 71 | 72 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype 73 | * @{ 74 | */ 75 | 76 | USBD_StatusTypeDef USBD_StdDevReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 77 | USBD_StatusTypeDef USBD_StdItfReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 78 | USBD_StatusTypeDef USBD_StdEPReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 79 | 80 | 81 | void USBD_CtlError (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); 82 | 83 | void USBD_ParseSetupRequest (USBD_SetupReqTypedef *req, uint8_t *pdata); 84 | 85 | void USBD_GetString (uint8_t *desc, uint8_t *unicode, uint16_t *len); 86 | /** 87 | * @} 88 | */ 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif /* __USB_REQUEST_H */ 95 | 96 | /** 97 | * @} 98 | */ 99 | 100 | /** 101 | * @} 102 | */ 103 | 104 | 105 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 106 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_ioreq.h 4 | * @author MCD Application Team 5 | * @brief Header file for the usbd_ioreq.c file 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2015 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * http://www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __USBD_IOREQ_H 22 | #define __USBD_IOREQ_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "usbd_def.h" 30 | #include "usbd_core.h" 31 | 32 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 33 | * @{ 34 | */ 35 | 36 | /** @defgroup USBD_IOREQ 37 | * @brief header file for the usbd_ioreq.c file 38 | * @{ 39 | */ 40 | 41 | /** @defgroup USBD_IOREQ_Exported_Defines 42 | * @{ 43 | */ 44 | /** 45 | * @} 46 | */ 47 | 48 | 49 | /** @defgroup USBD_IOREQ_Exported_Types 50 | * @{ 51 | */ 52 | 53 | 54 | /** 55 | * @} 56 | */ 57 | 58 | 59 | 60 | /** @defgroup USBD_IOREQ_Exported_Macros 61 | * @{ 62 | */ 63 | 64 | /** 65 | * @} 66 | */ 67 | 68 | /** @defgroup USBD_IOREQ_Exported_Variables 69 | * @{ 70 | */ 71 | 72 | /** 73 | * @} 74 | */ 75 | 76 | /** @defgroup USBD_IOREQ_Exported_FunctionsPrototype 77 | * @{ 78 | */ 79 | 80 | USBD_StatusTypeDef USBD_CtlSendData (USBD_HandleTypeDef *pdev, 81 | uint8_t *pbuf, 82 | uint16_t len); 83 | 84 | USBD_StatusTypeDef USBD_CtlContinueSendData (USBD_HandleTypeDef *pdev, 85 | uint8_t *pbuf, 86 | uint16_t len); 87 | 88 | USBD_StatusTypeDef USBD_CtlPrepareRx (USBD_HandleTypeDef *pdev, 89 | uint8_t *pbuf, 90 | uint16_t len); 91 | 92 | USBD_StatusTypeDef USBD_CtlContinueRx (USBD_HandleTypeDef *pdev, 93 | uint8_t *pbuf, 94 | uint16_t len); 95 | 96 | USBD_StatusTypeDef USBD_CtlSendStatus (USBD_HandleTypeDef *pdev); 97 | 98 | USBD_StatusTypeDef USBD_CtlReceiveStatus (USBD_HandleTypeDef *pdev); 99 | 100 | uint32_t USBD_GetRxCount (USBD_HandleTypeDef *pdev, uint8_t ep_addr); 101 | 102 | /** 103 | * @} 104 | */ 105 | 106 | #ifdef __cplusplus 107 | } 108 | #endif 109 | 110 | #endif /* __USBD_IOREQ_H */ 111 | 112 | /** 113 | * @} 114 | */ 115 | 116 | /** 117 | * @} 118 | */ 119 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 120 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file usbd_ioreq.c 4 | * @author MCD Application Team 5 | * @brief This file provides the IO requests APIs for control endpoints. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2015 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * http://www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "usbd_ioreq.h" 22 | 23 | /** @addtogroup STM32_USB_DEVICE_LIBRARY 24 | * @{ 25 | */ 26 | 27 | 28 | /** @defgroup USBD_IOREQ 29 | * @brief control I/O requests module 30 | * @{ 31 | */ 32 | 33 | /** @defgroup USBD_IOREQ_Private_TypesDefinitions 34 | * @{ 35 | */ 36 | /** 37 | * @} 38 | */ 39 | 40 | 41 | /** @defgroup USBD_IOREQ_Private_Defines 42 | * @{ 43 | */ 44 | 45 | /** 46 | * @} 47 | */ 48 | 49 | 50 | /** @defgroup USBD_IOREQ_Private_Macros 51 | * @{ 52 | */ 53 | /** 54 | * @} 55 | */ 56 | 57 | 58 | /** @defgroup USBD_IOREQ_Private_Variables 59 | * @{ 60 | */ 61 | 62 | /** 63 | * @} 64 | */ 65 | 66 | 67 | /** @defgroup USBD_IOREQ_Private_FunctionPrototypes 68 | * @{ 69 | */ 70 | /** 71 | * @} 72 | */ 73 | 74 | 75 | /** @defgroup USBD_IOREQ_Private_Functions 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @brief USBD_CtlSendData 81 | * send data on the ctl pipe 82 | * @param pdev: device instance 83 | * @param buff: pointer to data buffer 84 | * @param len: length of data to be sent 85 | * @retval status 86 | */ 87 | USBD_StatusTypeDef USBD_CtlSendData (USBD_HandleTypeDef *pdev, uint8_t *pbuf, 88 | uint16_t len) 89 | { 90 | /* Set EP0 State */ 91 | pdev->ep0_state = USBD_EP0_DATA_IN; 92 | pdev->ep_in[0].total_length = len; 93 | pdev->ep_in[0].rem_length = len; 94 | 95 | /* Start the transfer */ 96 | USBD_LL_Transmit (pdev, 0x00U, pbuf, len); 97 | 98 | return USBD_OK; 99 | } 100 | 101 | /** 102 | * @brief USBD_CtlContinueSendData 103 | * continue sending data on the ctl pipe 104 | * @param pdev: device instance 105 | * @param buff: pointer to data buffer 106 | * @param len: length of data to be sent 107 | * @retval status 108 | */ 109 | USBD_StatusTypeDef USBD_CtlContinueSendData (USBD_HandleTypeDef *pdev, 110 | uint8_t *pbuf, uint16_t len) 111 | { 112 | /* Start the next transfer */ 113 | USBD_LL_Transmit (pdev, 0x00U, pbuf, len); 114 | 115 | return USBD_OK; 116 | } 117 | 118 | /** 119 | * @brief USBD_CtlPrepareRx 120 | * receive data on the ctl pipe 121 | * @param pdev: device instance 122 | * @param buff: pointer to data buffer 123 | * @param len: length of data to be received 124 | * @retval status 125 | */ 126 | USBD_StatusTypeDef USBD_CtlPrepareRx (USBD_HandleTypeDef *pdev, uint8_t *pbuf, 127 | uint16_t len) 128 | { 129 | /* Set EP0 State */ 130 | pdev->ep0_state = USBD_EP0_DATA_OUT; 131 | pdev->ep_out[0].total_length = len; 132 | pdev->ep_out[0].rem_length = len; 133 | 134 | /* Start the transfer */ 135 | USBD_LL_PrepareReceive (pdev, 0U, pbuf, len); 136 | 137 | return USBD_OK; 138 | } 139 | 140 | /** 141 | * @brief USBD_CtlContinueRx 142 | * continue receive data on the ctl pipe 143 | * @param pdev: device instance 144 | * @param buff: pointer to data buffer 145 | * @param len: length of data to be received 146 | * @retval status 147 | */ 148 | USBD_StatusTypeDef USBD_CtlContinueRx (USBD_HandleTypeDef *pdev, uint8_t *pbuf, 149 | uint16_t len) 150 | { 151 | USBD_LL_PrepareReceive(pdev, 0U, pbuf, len); 152 | 153 | return USBD_OK; 154 | } 155 | 156 | /** 157 | * @brief USBD_CtlSendStatus 158 | * send zero lzngth packet on the ctl pipe 159 | * @param pdev: device instance 160 | * @retval status 161 | */ 162 | USBD_StatusTypeDef USBD_CtlSendStatus (USBD_HandleTypeDef *pdev) 163 | { 164 | /* Set EP0 State */ 165 | pdev->ep0_state = USBD_EP0_STATUS_IN; 166 | 167 | /* Start the transfer */ 168 | USBD_LL_Transmit(pdev, 0x00U, NULL, 0U); 169 | 170 | return USBD_OK; 171 | } 172 | 173 | /** 174 | * @brief USBD_CtlReceiveStatus 175 | * receive zero lzngth packet on the ctl pipe 176 | * @param pdev: device instance 177 | * @retval status 178 | */ 179 | USBD_StatusTypeDef USBD_CtlReceiveStatus (USBD_HandleTypeDef *pdev) 180 | { 181 | /* Set EP0 State */ 182 | pdev->ep0_state = USBD_EP0_STATUS_OUT; 183 | 184 | /* Start the transfer */ 185 | USBD_LL_PrepareReceive (pdev, 0U, NULL, 0U); 186 | 187 | return USBD_OK; 188 | } 189 | 190 | /** 191 | * @brief USBD_GetRxCount 192 | * returns the received data length 193 | * @param pdev: device instance 194 | * @param ep_addr: endpoint address 195 | * @retval Rx Data blength 196 | */ 197 | uint32_t USBD_GetRxCount (USBD_HandleTypeDef *pdev, uint8_t ep_addr) 198 | { 199 | return USBD_LL_GetRxDataSize(pdev, ep_addr); 200 | } 201 | 202 | /** 203 | * @} 204 | */ 205 | 206 | 207 | /** 208 | * @} 209 | */ 210 | 211 | 212 | /** 213 | * @} 214 | */ 215 | 216 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 217 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Release/GBLiveCam_revB.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBLiveCam/Firmware/Release/GBLiveCam_revB.bin -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Release/GBLiveCam_revC.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBLiveCam/Firmware/Release/GBLiveCam_revC.bin -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Release/makefile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | # Toolchain: GNU Tools for STM32 (9-2020-q2-update) 4 | ################################################################################ 5 | 6 | -include ../makefile.init 7 | 8 | RM := rm -rf 9 | 10 | # All of the sources participating in the build are defined here 11 | -include sources.mk 12 | -include Startup/subdir.mk 13 | -include Src/subdir.mk 14 | -include Middlewares/ST/STM32_USB_Device_Library/Core/Src/subdir.mk 15 | -include Middlewares/ST/STM32_USB_Device_Library/Class/UVC/Src/subdir.mk 16 | -include Drivers/STM32F7xx_HAL_Driver/Src/subdir.mk 17 | -include subdir.mk 18 | -include objects.mk 19 | 20 | ifneq ($(MAKECMDGOALS),clean) 21 | ifneq ($(strip $(S_DEPS)),) 22 | -include $(S_DEPS) 23 | endif 24 | ifneq ($(strip $(S_UPPER_DEPS)),) 25 | -include $(S_UPPER_DEPS) 26 | endif 27 | ifneq ($(strip $(C_DEPS)),) 28 | -include $(C_DEPS) 29 | endif 30 | endif 31 | 32 | -include ../makefile.defs 33 | 34 | OPTIONAL_TOOL_DEPS := \ 35 | $(wildcard ../makefile.defs) \ 36 | $(wildcard ../makefile.init) \ 37 | $(wildcard ../makefile.targets) \ 38 | 39 | 40 | BUILD_ARTIFACT_NAME := GBLiveCam 41 | BUILD_ARTIFACT_EXTENSION := elf 42 | BUILD_ARTIFACT_PREFIX := 43 | BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME).$(BUILD_ARTIFACT_EXTENSION) 44 | 45 | # Add inputs and outputs from these tool invocations to the build variables 46 | EXECUTABLES += \ 47 | GBLiveCam.elf \ 48 | 49 | SIZE_OUTPUT += \ 50 | default.size.stdout \ 51 | 52 | OBJDUMP_LIST += \ 53 | GBLiveCam.list \ 54 | 55 | OBJCOPY_BIN += \ 56 | GBLiveCam.bin \ 57 | 58 | 59 | # All Target 60 | all: main-build 61 | 62 | # Main-build Target 63 | main-build: GBLiveCam.elf secondary-outputs 64 | 65 | # Tool invocations 66 | GBLiveCam.elf: $(OBJS) $(USER_OBJS) C:\Users\furrtek\Documents\Electro\Gameboy\GBLiveCam\Firmware\STM32F730R8TX_FLASH.ld makefile objects.list $(OPTIONAL_TOOL_DEPS) 67 | arm-none-eabi-gcc -o "GBLiveCam.elf" @"objects.list" $(USER_OBJS) $(LIBS) -mcpu=cortex-m7 -T"C:\Users\furrtek\Documents\Electro\Gameboy\GBLiveCam\Firmware\STM32F730R8TX_FLASH.ld" --specs=nosys.specs -Wl,-Map="GBLiveCam.map" -Wl,--gc-sections -static --specs=nano.specs -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -Wl,--end-group 68 | @echo 'Finished building target: $@' 69 | @echo ' ' 70 | 71 | default.size.stdout: $(EXECUTABLES) makefile objects.list $(OPTIONAL_TOOL_DEPS) 72 | arm-none-eabi-size $(EXECUTABLES) 73 | @echo 'Finished building: $@' 74 | @echo ' ' 75 | 76 | GBLiveCam.list: $(EXECUTABLES) makefile objects.list $(OPTIONAL_TOOL_DEPS) 77 | arm-none-eabi-objdump -h -S $(EXECUTABLES) > "GBLiveCam.list" 78 | @echo 'Finished building: $@' 79 | @echo ' ' 80 | 81 | GBLiveCam.bin: $(EXECUTABLES) makefile objects.list $(OPTIONAL_TOOL_DEPS) 82 | arm-none-eabi-objcopy -O binary $(EXECUTABLES) "GBLiveCam.bin" 83 | @echo 'Finished building: $@' 84 | @echo ' ' 85 | 86 | # Other Targets 87 | clean: 88 | -$(RM) * 89 | -@echo ' ' 90 | 91 | secondary-outputs: $(SIZE_OUTPUT) $(OBJDUMP_LIST) $(OBJCOPY_BIN) 92 | 93 | fail-specified-linker-script-missing: 94 | @echo 'Error: Cannot find the specified linker script. Check the linker settings in the build configuration.' 95 | @exit 2 96 | 97 | warn-no-linker-script-specified: 98 | @echo 'Warning: No linker script specified. Check the linker settings in the build configuration.' 99 | 100 | .PHONY: all clean dependents fail-specified-linker-script-missing warn-no-linker-script-specified 101 | .SECONDARY: 102 | 103 | -include ../makefile.targets 104 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Release/program.bat: -------------------------------------------------------------------------------- 1 | ..\dfu-util-0.9-win64\dfu-util --device 0483:df11 -a 0 -s 0x08000000:leave --download GBLiveCam_revC.bin 2 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/STM32F730R8TX_FLASH.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | ** File : LinkerScript.ld 5 | ** 6 | ** Author : Auto-generated by STM32CubeIDE 7 | ** 8 | ** Abstract : Linker script for STM32F730R8Tx Device from STM32F7 series 9 | ** 64Kbytes FLASH 10 | ** 256Kbytes RAM 11 | ** 12 | ** Set heap size, stack size and stack location according 13 | ** to application requirements. 14 | ** 15 | ** Set memory bank area and size if external memory is used. 16 | ** 17 | ** Target : STMicroelectronics STM32 18 | ** 19 | ** Distribution: The file is distributed as is without any warranty 20 | ** of any kind. 21 | ** 22 | ***************************************************************************** 23 | ** @attention 24 | ** 25 | **

© COPYRIGHT(c) 2019 STMicroelectronics

26 | ** 27 | ** Redistribution and use in source and binary forms, with or without modification, 28 | ** are permitted provided that the following conditions are met: 29 | ** 1. Redistributions of source code must retain the above copyright notice, 30 | ** this list of conditions and the following disclaimer. 31 | ** 2. Redistributions in binary form must reproduce the above copyright notice, 32 | ** this list of conditions and the following disclaimer in the documentation 33 | ** and/or other materials provided with the distribution. 34 | ** 3. Neither the name of STMicroelectronics nor the names of its contributors 35 | ** may be used to endorse or promote products derived from this software 36 | ** without specific prior written permission. 37 | ** 38 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 41 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 42 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 43 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 44 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 45 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 47 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 | ** 49 | ***************************************************************************** 50 | */ 51 | 52 | /* Entry Point */ 53 | ENTRY(Reset_Handler) 54 | 55 | /* Highest address of the user mode stack */ 56 | _estack = 0x2003ffff; /* end of "RAM" Ram type memory */ 57 | 58 | _Min_Heap_Size = 0x400; /* required amount of heap */ 59 | _Min_Stack_Size = 0x400; /* required amount of stack */ 60 | 61 | /* Memories definition */ 62 | MEMORY 63 | { 64 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 64K 65 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256K 66 | } 67 | 68 | /* Sections */ 69 | SECTIONS 70 | { 71 | /* The startup code into "FLASH" Rom type memory */ 72 | .isr_vector : 73 | { 74 | . = ALIGN(4); 75 | KEEP(*(.isr_vector)) /* Startup code */ 76 | . = ALIGN(4); 77 | } >FLASH 78 | 79 | /* The program code and other data into "FLASH" Rom type memory */ 80 | .text : 81 | { 82 | . = ALIGN(4); 83 | *(.text) /* .text sections (code) */ 84 | *(.text*) /* .text* sections (code) */ 85 | *(.glue_7) /* glue arm to thumb code */ 86 | *(.glue_7t) /* glue thumb to arm code */ 87 | *(.eh_frame) 88 | 89 | KEEP (*(.init)) 90 | KEEP (*(.fini)) 91 | 92 | . = ALIGN(4); 93 | _etext = .; /* define a global symbols at end of code */ 94 | } >FLASH 95 | 96 | /* Constant data into "FLASH" Rom type memory */ 97 | .rodata : 98 | { 99 | . = ALIGN(4); 100 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 101 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 102 | . = ALIGN(4); 103 | } >FLASH 104 | 105 | .ARM.extab : { 106 | . = ALIGN(4); 107 | *(.ARM.extab* .gnu.linkonce.armextab.*) 108 | . = ALIGN(4); 109 | } >FLASH 110 | 111 | .ARM : { 112 | . = ALIGN(4); 113 | __exidx_start = .; 114 | *(.ARM.exidx*) 115 | __exidx_end = .; 116 | . = ALIGN(4); 117 | } >FLASH 118 | 119 | .preinit_array : 120 | { 121 | . = ALIGN(4); 122 | PROVIDE_HIDDEN (__preinit_array_start = .); 123 | KEEP (*(.preinit_array*)) 124 | PROVIDE_HIDDEN (__preinit_array_end = .); 125 | . = ALIGN(4); 126 | } >FLASH 127 | 128 | .init_array : 129 | { 130 | . = ALIGN(4); 131 | PROVIDE_HIDDEN (__init_array_start = .); 132 | KEEP (*(SORT(.init_array.*))) 133 | KEEP (*(.init_array*)) 134 | PROVIDE_HIDDEN (__init_array_end = .); 135 | . = ALIGN(4); 136 | } >FLASH 137 | 138 | .fini_array : 139 | { 140 | . = ALIGN(4); 141 | PROVIDE_HIDDEN (__fini_array_start = .); 142 | KEEP (*(SORT(.fini_array.*))) 143 | KEEP (*(.fini_array*)) 144 | PROVIDE_HIDDEN (__fini_array_end = .); 145 | . = ALIGN(4); 146 | } >FLASH 147 | 148 | /* Used by the startup to initialize data */ 149 | _sidata = LOADADDR(.data); 150 | 151 | /* Initialized data sections into "RAM" Ram type memory */ 152 | .data : 153 | { 154 | . = ALIGN(4); 155 | _sdata = .; /* create a global symbol at data start */ 156 | *(.data) /* .data sections */ 157 | *(.data*) /* .data* sections */ 158 | 159 | . = ALIGN(4); 160 | _edata = .; /* define a global symbol at data end */ 161 | 162 | } >RAM AT> FLASH 163 | 164 | /* Uninitialized data section into "RAM" Ram type memory */ 165 | . = ALIGN(4); 166 | .bss : 167 | { 168 | /* This is used by the startup in order to initialize the .bss secion */ 169 | _sbss = .; /* define a global symbol at bss start */ 170 | __bss_start__ = _sbss; 171 | *(.bss) 172 | *(.bss*) 173 | *(COMMON) 174 | 175 | . = ALIGN(4); 176 | _ebss = .; /* define a global symbol at bss end */ 177 | __bss_end__ = _ebss; 178 | } >RAM 179 | 180 | /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ 181 | ._user_heap_stack : 182 | { 183 | . = ALIGN(8); 184 | PROVIDE ( end = . ); 185 | PROVIDE ( _end = . ); 186 | . = . + _Min_Heap_Size; 187 | . = . + _Min_Stack_Size; 188 | . = ALIGN(8); 189 | } >RAM 190 | 191 | /* Remove information from the compiler libraries */ 192 | /DISCARD/ : 193 | { 194 | libc.a ( * ) 195 | libm.a ( * ) 196 | libgcc.a ( * ) 197 | } 198 | 199 | .ARM.attributes 0 : { *(.ARM.attributes) } 200 | } 201 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/STM32F730R8TX_RAM.ld: -------------------------------------------------------------------------------- 1 | /* 2 | ****************************************************************************** 3 | ** 4 | ** File : LinkerScript.ld (debug in RAM dedicated) 5 | ** 6 | ** Author : Auto-generated by STM32CubeIDE 7 | ** 8 | ** Abstract : Linker script for STM32F730R8Tx Device from STM32F7 series 9 | ** 64Kbytes FLASH 10 | ** 256Kbytes RAM 11 | ** 12 | ** Set heap size, stack size and stack location according 13 | ** to application requirements. 14 | ** 15 | ** Set memory bank area and size if external memory is used. 16 | ** 17 | ** Target : STMicroelectronics STM32 18 | ** 19 | ** Distribution: The file is distributed as is without any warranty 20 | ** of any kind. 21 | ** 22 | ***************************************************************************** 23 | ** @attention 24 | ** 25 | **

© COPYRIGHT(c) 2019 STMicroelectronics

26 | ** 27 | ** Redistribution and use in source and binary forms, with or without modification, 28 | ** are permitted provided that the following conditions are met: 29 | ** 1. Redistributions of source code must retain the above copyright notice, 30 | ** this list of conditions and the following disclaimer. 31 | ** 2. Redistributions in binary form must reproduce the above copyright notice, 32 | ** this list of conditions and the following disclaimer in the documentation 33 | ** and/or other materials provided with the distribution. 34 | ** 3. Neither the name of STMicroelectronics nor the names of its contributors 35 | ** may be used to endorse or promote products derived from this software 36 | ** without specific prior written permission. 37 | ** 38 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 39 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 41 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 42 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 43 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 44 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 45 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 47 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 | ** 49 | ***************************************************************************** 50 | */ 51 | 52 | /* Entry Point */ 53 | ENTRY(Reset_Handler) 54 | 55 | /* Highest address of the user mode stack */ 56 | _estack = 0x2003ffff; /* end of "RAM" Ram type memory */ 57 | 58 | _Min_Heap_Size = 0x400; /* required amount of heap */ 59 | _Min_Stack_Size = 0x400; /* required amount of stack */ 60 | 61 | /* Memories definition */ 62 | MEMORY 63 | { 64 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 64K 65 | RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 256K 66 | } 67 | 68 | /* Sections */ 69 | SECTIONS 70 | { 71 | /* The startup code into "RAM" Ram type memory */ 72 | .isr_vector : 73 | { 74 | . = ALIGN(4); 75 | KEEP(*(.isr_vector)) /* Startup code */ 76 | . = ALIGN(4); 77 | } >RAM 78 | 79 | /* The program code and other data into "RAM" Ram type memory */ 80 | .text : 81 | { 82 | . = ALIGN(4); 83 | *(.text) /* .text sections (code) */ 84 | *(.text*) /* .text* sections (code) */ 85 | *(.glue_7) /* glue arm to thumb code */ 86 | *(.glue_7t) /* glue thumb to arm code */ 87 | *(.eh_frame) 88 | 89 | KEEP (*(.init)) 90 | KEEP (*(.fini)) 91 | 92 | . = ALIGN(4); 93 | _etext = .; /* define a global symbols at end of code */ 94 | } >RAM 95 | 96 | /* Constant data into "RAM" Ram type memory */ 97 | .rodata : 98 | { 99 | . = ALIGN(4); 100 | *(.rodata) /* .rodata sections (constants, strings, etc.) */ 101 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ 102 | . = ALIGN(4); 103 | } >RAM 104 | 105 | .ARM.extab : { 106 | . = ALIGN(4); 107 | *(.ARM.extab* .gnu.linkonce.armextab.*) 108 | . = ALIGN(4); 109 | } >RAM 110 | 111 | .ARM : { 112 | . = ALIGN(4); 113 | __exidx_start = .; 114 | *(.ARM.exidx*) 115 | __exidx_end = .; 116 | . = ALIGN(4); 117 | } >RAM 118 | 119 | .preinit_array : 120 | { 121 | . = ALIGN(4); 122 | PROVIDE_HIDDEN (__preinit_array_start = .); 123 | KEEP (*(.preinit_array*)) 124 | PROVIDE_HIDDEN (__preinit_array_end = .); 125 | . = ALIGN(4); 126 | } >RAM 127 | 128 | .init_array : 129 | { 130 | . = ALIGN(4); 131 | PROVIDE_HIDDEN (__init_array_start = .); 132 | KEEP (*(SORT(.init_array.*))) 133 | KEEP (*(.init_array*)) 134 | PROVIDE_HIDDEN (__init_array_end = .); 135 | . = ALIGN(4); 136 | } >RAM 137 | 138 | .fini_array : 139 | { 140 | . = ALIGN(4); 141 | PROVIDE_HIDDEN (__fini_array_start = .); 142 | KEEP (*(SORT(.fini_array.*))) 143 | KEEP (*(.fini_array*)) 144 | PROVIDE_HIDDEN (__fini_array_end = .); 145 | . = ALIGN(4); 146 | } >RAM 147 | 148 | /* Used by the startup to initialize data */ 149 | _sidata = LOADADDR(.data); 150 | 151 | /* Initialized data sections into "RAM" Ram type memory */ 152 | .data : 153 | { 154 | . = ALIGN(4); 155 | _sdata = .; /* create a global symbol at data start */ 156 | *(.data) /* .data sections */ 157 | *(.data*) /* .data* sections */ 158 | 159 | . = ALIGN(4); 160 | _edata = .; /* define a global symbol at data end */ 161 | 162 | } >RAM 163 | 164 | /* Uninitialized data section into "RAM" Ram type memory */ 165 | . = ALIGN(4); 166 | .bss : 167 | { 168 | /* This is used by the startup in order to initialize the .bss secion */ 169 | _sbss = .; /* define a global symbol at bss start */ 170 | __bss_start__ = _sbss; 171 | *(.bss) 172 | *(.bss*) 173 | *(COMMON) 174 | 175 | . = ALIGN(4); 176 | _ebss = .; /* define a global symbol at bss end */ 177 | __bss_end__ = _ebss; 178 | } >RAM 179 | 180 | /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ 181 | ._user_heap_stack : 182 | { 183 | . = ALIGN(8); 184 | PROVIDE ( end = . ); 185 | PROVIDE ( _end = . ); 186 | . = . + _Min_Heap_Size; 187 | . = . + _Min_Stack_Size; 188 | . = ALIGN(8); 189 | } >RAM 190 | 191 | /* Remove information from the compiler libraries */ 192 | /DISCARD/ : 193 | { 194 | libc.a ( * ) 195 | libm.a ( * ) 196 | libgcc.a ( * ) 197 | } 198 | 199 | .ARM.attributes 0 : { *(.ARM.attributes) } 200 | } 201 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Src/init.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "init.h" 3 | 4 | void MX_ADC1_Init(void) { 5 | LL_ADC_InitTypeDef ADC_InitStruct = {0}; 6 | LL_ADC_REG_InitTypeDef ADC_REG_InitStruct = {0}; 7 | LL_ADC_CommonInitTypeDef ADC_CommonInitStruct = {0}; 8 | 9 | LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; 10 | 11 | /* Peripheral clock enable */ 12 | LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC1); 13 | 14 | LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOA); 15 | /**ADC1 GPIO Configuration 16 | PA0-WKUP ------> ADC1_IN0*/ 17 | GPIO_InitStruct.Pin = LL_GPIO_PIN_0; 18 | GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; 19 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; 20 | LL_GPIO_Init(GPIOA, &GPIO_InitStruct); 21 | 22 | /** Common config*/ 23 | ADC_InitStruct.Resolution = LL_ADC_RESOLUTION_12B; 24 | ADC_InitStruct.DataAlignment = LL_ADC_DATA_ALIGN_RIGHT; 25 | ADC_InitStruct.SequencersScanMode = LL_ADC_SEQ_SCAN_DISABLE; 26 | LL_ADC_Init(ADC1, &ADC_InitStruct); 27 | ADC_REG_InitStruct.TriggerSource = LL_ADC_REG_TRIG_SOFTWARE; 28 | ADC_REG_InitStruct.SequencerLength = LL_ADC_REG_SEQ_SCAN_DISABLE; 29 | ADC_REG_InitStruct.SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE; 30 | ADC_REG_InitStruct.ContinuousMode = LL_ADC_REG_CONV_SINGLE; 31 | ADC_REG_InitStruct.DMATransfer = LL_ADC_REG_DMA_TRANSFER_NONE; 32 | LL_ADC_REG_Init(ADC1, &ADC_REG_InitStruct); 33 | LL_ADC_REG_SetFlagEndOfConversion(ADC1, LL_ADC_REG_FLAG_EOC_UNITARY_CONV); 34 | LL_ADC_DisableIT_EOCS(ADC1); 35 | ADC_CommonInitStruct.CommonClock = LL_ADC_CLOCK_SYNC_PCLK_DIV2; 36 | ADC_CommonInitStruct.Multimode = LL_ADC_MULTI_INDEPENDENT; 37 | LL_ADC_CommonInit(__LL_ADC_COMMON_INSTANCE(ADC1), &ADC_CommonInitStruct); 38 | /** Configure Regular Channel */ 39 | LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_1, LL_ADC_CHANNEL_0); 40 | LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_0, LL_ADC_SAMPLINGTIME_3CYCLES); 41 | } 42 | 43 | void SystemClock_Config(void) { 44 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; 45 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; 46 | RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; 47 | 48 | // Configure the main internal regulator output voltage 49 | __HAL_RCC_PWR_CLK_ENABLE(); 50 | __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3); 51 | 52 | // HSE: 8MHz crystal 53 | // Initializes the CPU, AHB and APB busses clocks 54 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; 55 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; 56 | //RCC_OscInitStruct.HSIState = RCC_HSI_ON; 57 | //RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; 58 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; 59 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; 60 | RCC_OscInitStruct.PLL.PLLM = 4; 61 | RCC_OscInitStruct.PLL.PLLN = 120; // 8/4*120=240MHz PLL output 62 | RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; // 240/2=120MHz SYSCLK 63 | RCC_OscInitStruct.PLL.PLLQ = 5; // 240/5=48MHz USB clock 64 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) 65 | Error_Handler(); 66 | 67 | // Initializes the CPU, AHB and APB busses clocks 68 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; 69 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; 70 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; 71 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; 72 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; 73 | 74 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK) 75 | Error_Handler(); 76 | PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_CLK48; 77 | PeriphClkInitStruct.Clk48ClockSelection = RCC_CLK48SOURCE_PLL; 78 | if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) 79 | Error_Handler(); 80 | } 81 | 82 | void MX_GPIO_Init(void) { 83 | LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; 84 | 85 | /* GPIO Ports Clock Enable */ 86 | LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOH); 87 | LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOA); 88 | LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOB); 89 | LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOC); 90 | 91 | LL_GPIO_SetOutputPin(GPIOA, LL_GPIO_PIN_5); // /GBCCS 92 | LL_GPIO_SetOutputPin(GPIOA, LL_GPIO_PIN_6); // /GBCRD 93 | LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_14); // LED1 94 | LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_15); // LED2 95 | LL_GPIO_SetOutputPin(GPIOC, LL_GPIO_PIN_3); // /GBCRST 96 | 97 | #if PCBREV == 'B' 98 | LL_GPIO_SetOutputPin(GPIOA, LL_GPIO_PIN_7); // /GBCWR 99 | LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_8); // ALEL 100 | LL_GPIO_ResetOutputPin(GPIOB, LL_GPIO_PIN_14); // GBCPHI 101 | LL_GPIO_ResetOutputPin(GPIOC, LL_GPIO_PIN_0); // ALEH 102 | #else 103 | LL_GPIO_SetOutputPin(GPIOA, LL_GPIO_PIN_8); // /GBCWR 104 | LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_7); // GBCPHI 105 | #endif 106 | 107 | // GB cart Phi 108 | GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; 109 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; // LL_GPIO_SPEED_FREQ_VERY_HIGH ? 110 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; 111 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; 112 | #if PCBREV == 'B' 113 | // PB14: TIM12_CH1 114 | GPIO_InitStruct.Pin = LL_GPIO_PIN_14; 115 | GPIO_InitStruct.Alternate = LL_GPIO_AF_9; // TIM12_CH1 116 | LL_GPIO_Init(GPIOB, &GPIO_InitStruct); 117 | #else 118 | // PA7: TIM14_CH1 119 | GPIO_InitStruct.Pin = LL_GPIO_PIN_7; 120 | GPIO_InitStruct.Alternate = LL_GPIO_AF_9; // TIM14_CH1 121 | LL_GPIO_Init(GPIOA, &GPIO_InitStruct); 122 | #endif 123 | 124 | // GB cart control 125 | #if PCBREV == 'B' 126 | GPIO_InitStruct.Pin = LL_GPIO_PIN_5 | LL_GPIO_PIN_6 | LL_GPIO_PIN_7 | LL_GPIO_PIN_8; 127 | #else 128 | GPIO_InitStruct.Pin = LL_GPIO_PIN_5 | LL_GPIO_PIN_6 | LL_GPIO_PIN_8; 129 | #endif 130 | GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; 131 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; // LL_GPIO_SPEED_FREQ_VERY_HIGH ? 132 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; 133 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; 134 | LL_GPIO_Init(GPIOA, &GPIO_InitStruct); 135 | #if PCBREV == 'B' 136 | GPIO_InitStruct.Pin = LL_GPIO_PIN_0 | LL_GPIO_PIN_3; 137 | #else 138 | GPIO_InitStruct.Pin = LL_GPIO_PIN_3; 139 | #endif 140 | LL_GPIO_Init(GPIOC, &GPIO_InitStruct); 141 | 142 | // LEDs 143 | GPIO_InitStruct.Pin = LL_GPIO_PIN_14 | LL_GPIO_PIN_15; 144 | GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; 145 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; 146 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; 147 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; 148 | LL_GPIO_Init(GPIOA, &GPIO_InitStruct); 149 | 150 | // Data / Multiplexed bus 151 | GPIO_InitStruct.Pin = LL_GPIO_PIN_8 | LL_GPIO_PIN_9 | LL_GPIO_PIN_10 | LL_GPIO_PIN_11 | 152 | LL_GPIO_PIN_12 | LL_GPIO_PIN_13 | LL_GPIO_PIN_14 | LL_GPIO_PIN_15; 153 | GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; 154 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; // LL_GPIO_SPEED_FREQ_VERY_HIGH ? 155 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; 156 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; 157 | LL_GPIO_Init(GPIOC, &GPIO_InitStruct); 158 | 159 | #if PCBREV != 'B' 160 | // Address bus 161 | GPIO_InitStruct.Pin = LL_GPIO_PIN_0 | LL_GPIO_PIN_1 | LL_GPIO_PIN_2 | LL_GPIO_PIN_3 | 162 | LL_GPIO_PIN_4 | LL_GPIO_PIN_5 | LL_GPIO_PIN_6 | LL_GPIO_PIN_7 | 163 | LL_GPIO_PIN_8 | LL_GPIO_PIN_9 | LL_GPIO_PIN_10 | LL_GPIO_PIN_11 | 164 | LL_GPIO_PIN_12 | LL_GPIO_PIN_13 | LL_GPIO_PIN_14 | LL_GPIO_PIN_15; 165 | GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; 166 | GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; // LL_GPIO_SPEED_FREQ_VERY_HIGH ? 167 | GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; 168 | GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; 169 | LL_GPIO_Init(GPIOB, &GPIO_InitStruct); 170 | #endif 171 | } 172 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Src/palettes.c: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "palettes.h" 3 | 4 | // Y = 0.257*R + 0.504*G + 0.098*B + 16 5 | // U = -0.148*R - 0.291*G + 0.439*B + 128 6 | // V = 0.439*R - 0.368*G - 0.071*B + 128 7 | #define RGBR(in) ((in >> 16) & 0xFF) 8 | #define RGBG(in) ((in >> 8) & 0xFF) 9 | #define RGBB(in) (in & 0xFF) 10 | #define RGB2YUV(v) (0.257*RGBR(v) + 0.504*RGBG(v) + 0.098*RGBB(v) + 16), \ 11 | (-0.148*RGBR(v) - 0.291*RGBG(v) + 0.439*RGBB(v) + 128), \ 12 | (0.439*RGBR(v) - 0.368*RGBG(v) - 0.071*RGBB(v) + 128) 13 | 14 | const palette_t palettes[8] = { 15 | {{ 16 | { RGB2YUV(0x000000) }, 17 | { RGB2YUV(0x555555) }, 18 | { RGB2YUV(0xAAAAAA) }, 19 | { RGB2YUV(0xFFFFFF) } 20 | }, "PURE GREY"}, 21 | {{ 22 | { RGB2YUV(0x394A6D) }, 23 | { RGB2YUV(0x3C9D9B) }, 24 | { RGB2YUV(0x52DE97) }, 25 | { RGB2YUV(0xC0FFB3) } 26 | }, "DMG GREEN"}, 27 | {{ 28 | { RGB2YUV(0x6A2C70) }, 29 | { RGB2YUV(0xB83B5E) }, 30 | { RGB2YUV(0xF08A5D) }, 31 | { RGB2YUV(0xF9ED69) } 32 | }, "CANDY"}, 33 | {{ 34 | { RGB2YUV(0x334257) }, 35 | { RGB2YUV(0x476072) }, 36 | { RGB2YUV(0x548CA8) }, 37 | { RGB2YUV(0xEEEEEE) } 38 | }, "GLACIER"}, 39 | {{ 40 | { RGB2YUV(0x85603F) }, 41 | { RGB2YUV(0x9E7540) }, 42 | { RGB2YUV(0xBD9354) }, 43 | { RGB2YUV(0xE3D18A) } 44 | }, "PAPER"}, 45 | {{ 46 | { RGB2YUV(0x000000) }, 47 | { RGB2YUV(0x3E432E) }, 48 | { RGB2YUV(0x616F39) }, 49 | { RGB2YUV(0xA7D129) } 50 | }, "PINE"}, 51 | {{ 52 | { RGB2YUV(0x3A0088) }, 53 | { RGB2YUV(0x930077) }, 54 | { RGB2YUV(0xE61C5D) }, 55 | { RGB2YUV(0xFFBD39) } 56 | }, "DUSK"}, 57 | {{ 58 | { RGB2YUV(0xFFFFFF) }, 59 | { RGB2YUV(0xAAAAAA) }, 60 | { RGB2YUV(0x555555) }, 61 | { RGB2YUV(0x000000) } 62 | }, "INVERTED"} 63 | }; 64 | 65 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Src/stm32f7xx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * File Name : stm32f7xx_hal_msp.c 5 | * Description : This file provides code for the MSP Initialization 6 | * and de-Initialization codes. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | *

© Copyright (c) 2019 STMicroelectronics. 11 | * All rights reserved.

12 | * 13 | * This software component is licensed by ST under Ultimate Liberty license 14 | * SLA0044, the "License"; You may not use this file except in compliance with 15 | * the License. You may obtain a copy of the License at: 16 | * www.st.com/SLA0044 17 | * 18 | ****************************************************************************** 19 | */ 20 | /* USER CODE END Header */ 21 | 22 | /* Includes ------------------------------------------------------------------*/ 23 | #include "main.h" 24 | /* USER CODE BEGIN Includes */ 25 | 26 | /* USER CODE END Includes */ 27 | 28 | /* Private typedef -----------------------------------------------------------*/ 29 | /* USER CODE BEGIN TD */ 30 | 31 | /* USER CODE END TD */ 32 | 33 | /* Private define ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN Define */ 35 | 36 | /* USER CODE END Define */ 37 | 38 | /* Private macro -------------------------------------------------------------*/ 39 | /* USER CODE BEGIN Macro */ 40 | 41 | /* USER CODE END Macro */ 42 | 43 | /* Private variables ---------------------------------------------------------*/ 44 | /* USER CODE BEGIN PV */ 45 | 46 | /* USER CODE END PV */ 47 | 48 | /* Private function prototypes -----------------------------------------------*/ 49 | /* USER CODE BEGIN PFP */ 50 | 51 | /* USER CODE END PFP */ 52 | 53 | /* External functions --------------------------------------------------------*/ 54 | /* USER CODE BEGIN ExternalFunctions */ 55 | 56 | /* USER CODE END ExternalFunctions */ 57 | 58 | /* USER CODE BEGIN 0 */ 59 | 60 | /* USER CODE END 0 */ 61 | /** 62 | * Initializes the Global MSP. 63 | */ 64 | void HAL_MspInit(void) 65 | { 66 | /* USER CODE BEGIN MspInit 0 */ 67 | 68 | /* USER CODE END MspInit 0 */ 69 | 70 | __HAL_RCC_PWR_CLK_ENABLE(); 71 | __HAL_RCC_SYSCFG_CLK_ENABLE(); 72 | 73 | /* System interrupt init*/ 74 | 75 | /* USER CODE BEGIN MspInit 1 */ 76 | 77 | /* USER CODE END MspInit 1 */ 78 | } 79 | 80 | /* USER CODE BEGIN 1 */ 81 | 82 | /* USER CODE END 1 */ 83 | 84 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 85 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Src/stm32f7xx_it.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32f7xx_it.c 5 | * @brief Interrupt Service Routines. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | *

© Copyright (c) 2019 STMicroelectronics. 10 | * All rights reserved.

11 | * 12 | * This software component is licensed by ST under Ultimate Liberty license 13 | * SLA0044, the "License"; You may not use this file except in compliance with 14 | * the License. You may obtain a copy of the License at: 15 | * www.st.com/SLA0044 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | #include "stm32f7xx_it.h" 24 | /* Private includes ----------------------------------------------------------*/ 25 | /* USER CODE BEGIN Includes */ 26 | /* USER CODE END Includes */ 27 | 28 | /* Private typedef -----------------------------------------------------------*/ 29 | /* USER CODE BEGIN TD */ 30 | 31 | /* USER CODE END TD */ 32 | 33 | /* Private define ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN PD */ 35 | 36 | /* USER CODE END PD */ 37 | 38 | /* Private macro -------------------------------------------------------------*/ 39 | /* USER CODE BEGIN PM */ 40 | 41 | /* USER CODE END PM */ 42 | 43 | /* Private variables ---------------------------------------------------------*/ 44 | /* USER CODE BEGIN PV */ 45 | 46 | /* USER CODE END PV */ 47 | 48 | /* Private function prototypes -----------------------------------------------*/ 49 | /* USER CODE BEGIN PFP */ 50 | 51 | /* USER CODE END PFP */ 52 | 53 | /* Private user code ---------------------------------------------------------*/ 54 | /* USER CODE BEGIN 0 */ 55 | 56 | /* USER CODE END 0 */ 57 | 58 | /* External variables --------------------------------------------------------*/ 59 | extern PCD_HandleTypeDef hpcd_USB_OTG_FS; 60 | 61 | /* USER CODE BEGIN EV */ 62 | 63 | /* USER CODE END EV */ 64 | 65 | /******************************************************************************/ 66 | /* Cortex-M7 Processor Interruption and Exception Handlers */ 67 | /******************************************************************************/ 68 | /** 69 | * @brief This function handles Non maskable interrupt. 70 | */ 71 | void NMI_Handler(void) 72 | { 73 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ 74 | 75 | /* USER CODE END NonMaskableInt_IRQn 0 */ 76 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ 77 | 78 | /* USER CODE END NonMaskableInt_IRQn 1 */ 79 | } 80 | 81 | /** 82 | * @brief This function handles Hard fault interrupt. 83 | */ 84 | void HardFault_Handler(void) 85 | { 86 | /* USER CODE BEGIN HardFault_IRQn 0 */ 87 | 88 | /* USER CODE END HardFault_IRQn 0 */ 89 | while (1) 90 | { 91 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */ 92 | /* USER CODE END W1_HardFault_IRQn 0 */ 93 | } 94 | } 95 | 96 | /** 97 | * @brief This function handles Memory management fault. 98 | */ 99 | void MemManage_Handler(void) 100 | { 101 | /* USER CODE BEGIN MemoryManagement_IRQn 0 */ 102 | 103 | /* USER CODE END MemoryManagement_IRQn 0 */ 104 | while (1) 105 | { 106 | /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ 107 | /* USER CODE END W1_MemoryManagement_IRQn 0 */ 108 | } 109 | } 110 | 111 | /** 112 | * @brief This function handles Pre-fetch fault, memory access fault. 113 | */ 114 | void BusFault_Handler(void) 115 | { 116 | /* USER CODE BEGIN BusFault_IRQn 0 */ 117 | 118 | /* USER CODE END BusFault_IRQn 0 */ 119 | while (1) 120 | { 121 | /* USER CODE BEGIN W1_BusFault_IRQn 0 */ 122 | /* USER CODE END W1_BusFault_IRQn 0 */ 123 | } 124 | } 125 | 126 | /** 127 | * @brief This function handles Undefined instruction or illegal state. 128 | */ 129 | void UsageFault_Handler(void) 130 | { 131 | /* USER CODE BEGIN UsageFault_IRQn 0 */ 132 | 133 | /* USER CODE END UsageFault_IRQn 0 */ 134 | while (1) 135 | { 136 | /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ 137 | /* USER CODE END W1_UsageFault_IRQn 0 */ 138 | } 139 | } 140 | 141 | /** 142 | * @brief This function handles System service call via SWI instruction. 143 | */ 144 | void SVC_Handler(void) 145 | { 146 | /* USER CODE BEGIN SVCall_IRQn 0 */ 147 | 148 | /* USER CODE END SVCall_IRQn 0 */ 149 | /* USER CODE BEGIN SVCall_IRQn 1 */ 150 | 151 | /* USER CODE END SVCall_IRQn 1 */ 152 | } 153 | 154 | /** 155 | * @brief This function handles Debug monitor. 156 | */ 157 | void DebugMon_Handler(void) 158 | { 159 | /* USER CODE BEGIN DebugMonitor_IRQn 0 */ 160 | 161 | /* USER CODE END DebugMonitor_IRQn 0 */ 162 | /* USER CODE BEGIN DebugMonitor_IRQn 1 */ 163 | 164 | /* USER CODE END DebugMonitor_IRQn 1 */ 165 | } 166 | 167 | /** 168 | * @brief This function handles Pendable request for system service. 169 | */ 170 | void PendSV_Handler(void) 171 | { 172 | /* USER CODE BEGIN PendSV_IRQn 0 */ 173 | 174 | /* USER CODE END PendSV_IRQn 0 */ 175 | /* USER CODE BEGIN PendSV_IRQn 1 */ 176 | 177 | /* USER CODE END PendSV_IRQn 1 */ 178 | } 179 | 180 | /** 181 | * @brief This function handles System tick timer. 182 | */ 183 | void SysTick_Handler(void) 184 | { 185 | /* USER CODE BEGIN SysTick_IRQn 0 */ 186 | 187 | /* USER CODE END SysTick_IRQn 0 */ 188 | HAL_IncTick(); 189 | /* USER CODE BEGIN SysTick_IRQn 1 */ 190 | 191 | /* USER CODE END SysTick_IRQn 1 */ 192 | } 193 | 194 | /******************************************************************************/ 195 | /* STM32F7xx Peripheral Interrupt Handlers */ 196 | /* Add here the Interrupt Handlers for the used peripherals. */ 197 | /* For the available peripheral interrupt handler names, */ 198 | /* please refer to the startup file (startup_stm32f7xx.s). */ 199 | /******************************************************************************/ 200 | 201 | /** 202 | * @brief This function handles USB On The Go FS global interrupt. 203 | */ 204 | void OTG_FS_IRQHandler(void) 205 | { 206 | /* USER CODE BEGIN OTG_FS_IRQn 0 */ 207 | 208 | /* USER CODE END OTG_FS_IRQn 0 */ 209 | HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); 210 | /* USER CODE BEGIN OTG_FS_IRQn 1 */ 211 | 212 | /* USER CODE END OTG_FS_IRQn 1 */ 213 | } 214 | 215 | /* USER CODE BEGIN 1 */ 216 | 217 | /* USER CODE END 1 */ 218 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 219 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Src/syscalls.c: -------------------------------------------------------------------------------- 1 | /** 2 | ***************************************************************************** 3 | ** 4 | ** File : syscalls.c 5 | ** 6 | ** Author : Auto-generated by STM32CubeIDE 7 | ** 8 | ** Abstract : STM32CubeIDE Minimal System calls file 9 | ** 10 | ** For more information about which c-functions 11 | ** need which of these lowlevel functions 12 | ** please consult the Newlib libc-manual 13 | ** 14 | ** Environment : STM32CubeIDE MCU 15 | ** 16 | ** Distribution: The file is distributed as is, without any warranty 17 | ** of any kind. 18 | ** 19 | ***************************************************************************** 20 | ** 21 | **

© COPYRIGHT(c) 2018 STMicroelectronics

22 | ** 23 | ** Redistribution and use in source and binary forms, with or without modification, 24 | ** are permitted provided that the following conditions are met: 25 | ** 1. Redistributions of source code must retain the above copyright notice, 26 | ** this list of conditions and the following disclaimer. 27 | ** 2. Redistributions in binary form must reproduce the above copyright notice, 28 | ** this list of conditions and the following disclaimer in the documentation 29 | ** and/or other materials provided with the distribution. 30 | ** 3. Neither the name of STMicroelectronics nor the names of its contributors 31 | ** may be used to endorse or promote products derived from this software 32 | ** without specific prior written permission. 33 | ** 34 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 35 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 36 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 38 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 39 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 40 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 41 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 42 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 43 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 44 | ** 45 | ** 46 | ***************************************************************************** 47 | */ 48 | 49 | /* Includes */ 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | 59 | 60 | /* Variables */ 61 | //#undef errno 62 | extern int errno; 63 | extern int __io_putchar(int ch) __attribute__((weak)); 64 | extern int __io_getchar(void) __attribute__((weak)); 65 | 66 | register char * stack_ptr asm("sp"); 67 | 68 | char *__env[1] = { 0 }; 69 | char **environ = __env; 70 | 71 | 72 | /* Functions */ 73 | void initialise_monitor_handles() 74 | { 75 | } 76 | 77 | int _getpid(void) 78 | { 79 | return 1; 80 | } 81 | 82 | int _kill(int pid, int sig) 83 | { 84 | errno = EINVAL; 85 | return -1; 86 | } 87 | 88 | void _exit (int status) 89 | { 90 | _kill(status, -1); 91 | while (1) {} /* Make sure we hang here */ 92 | } 93 | 94 | __attribute__((weak)) int _read(int file, char *ptr, int len) 95 | { 96 | int DataIdx; 97 | 98 | for (DataIdx = 0; DataIdx < len; DataIdx++) 99 | { 100 | *ptr++ = __io_getchar(); 101 | } 102 | 103 | return len; 104 | } 105 | 106 | __attribute__((weak)) int _write(int file, char *ptr, int len) 107 | { 108 | int DataIdx; 109 | 110 | for (DataIdx = 0; DataIdx < len; DataIdx++) 111 | { 112 | __io_putchar(*ptr++); 113 | } 114 | return len; 115 | } 116 | 117 | int _close(int file) 118 | { 119 | return -1; 120 | } 121 | 122 | 123 | int _fstat(int file, struct stat *st) 124 | { 125 | st->st_mode = S_IFCHR; 126 | return 0; 127 | } 128 | 129 | int _isatty(int file) 130 | { 131 | return 1; 132 | } 133 | 134 | int _lseek(int file, int ptr, int dir) 135 | { 136 | return 0; 137 | } 138 | 139 | int _open(char *path, int flags, ...) 140 | { 141 | /* Pretend like we always fail */ 142 | return -1; 143 | } 144 | 145 | int _wait(int *status) 146 | { 147 | errno = ECHILD; 148 | return -1; 149 | } 150 | 151 | int _unlink(char *name) 152 | { 153 | errno = ENOENT; 154 | return -1; 155 | } 156 | 157 | int _times(struct tms *buf) 158 | { 159 | return -1; 160 | } 161 | 162 | int _stat(char *file, struct stat *st) 163 | { 164 | st->st_mode = S_IFCHR; 165 | return 0; 166 | } 167 | 168 | int _link(char *old, char *new) 169 | { 170 | errno = EMLINK; 171 | return -1; 172 | } 173 | 174 | int _fork(void) 175 | { 176 | errno = EAGAIN; 177 | return -1; 178 | } 179 | 180 | int _execve(char *name, char **argv, char **env) 181 | { 182 | errno = ENOMEM; 183 | return -1; 184 | } 185 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Src/sysmem.c: -------------------------------------------------------------------------------- 1 | /** 2 | ***************************************************************************** 3 | ** 4 | ** File : sysmem.c 5 | ** 6 | ** Author : Auto-generated by STM32CubeIDE 7 | ** 8 | ** Abstract : STM32CubeIDE Minimal System Memory calls file 9 | ** 10 | ** For more information about which c-functions 11 | ** need which of these lowlevel functions 12 | ** please consult the Newlib libc-manual 13 | ** 14 | ** Environment : STM32CubeIDE MCU 15 | ** 16 | ** Distribution: The file is distributed as is, without any warranty 17 | ** of any kind. 18 | ** 19 | ***************************************************************************** 20 | ** 21 | **

© COPYRIGHT(c) 2018 STMicroelectronics

22 | ** 23 | ** Redistribution and use in source and binary forms, with or without modification, 24 | ** are permitted provided that the following conditions are met: 25 | ** 1. Redistributions of source code must retain the above copyright notice, 26 | ** this list of conditions and the following disclaimer. 27 | ** 2. Redistributions in binary form must reproduce the above copyright notice, 28 | ** this list of conditions and the following disclaimer in the documentation 29 | ** and/or other materials provided with the distribution. 30 | ** 3. Neither the name of STMicroelectronics nor the names of its contributors 31 | ** may be used to endorse or promote products derived from this software 32 | ** without specific prior written permission. 33 | ** 34 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 35 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 36 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 37 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 38 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 39 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 40 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 41 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 42 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 43 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 44 | ** 45 | ** 46 | ***************************************************************************** 47 | */ 48 | 49 | /* Includes */ 50 | #include 51 | #include 52 | 53 | /* Variables */ 54 | extern int errno; 55 | register char * stack_ptr asm("sp"); 56 | 57 | /* Functions */ 58 | 59 | /** 60 | _sbrk 61 | Increase program data space. Malloc and related functions depend on this 62 | **/ 63 | caddr_t _sbrk(int incr) 64 | { 65 | extern char end asm("end"); 66 | static char *heap_end; 67 | char *prev_heap_end; 68 | 69 | if (heap_end == 0) 70 | heap_end = &end; 71 | 72 | prev_heap_end = heap_end; 73 | if (heap_end + incr > stack_ptr) 74 | { 75 | errno = ENOMEM; 76 | return (caddr_t) -1; 77 | } 78 | 79 | heap_end += incr; 80 | 81 | return (caddr_t) prev_heap_end; 82 | } 83 | 84 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Src/usb_device.c: -------------------------------------------------------------------------------- 1 | #include "usb_device.h" 2 | #include "usbd_core.h" 3 | #include "usbd_desc.h" 4 | #include "usbd_uvc.h" 5 | #include "usbd_audio_if.h" 6 | 7 | USBD_HandleTypeDef hUsbDeviceFS; 8 | 9 | /** 10 | * Init USB device Library, add supported class and start the library 11 | * @retval None 12 | */ 13 | void MX_USB_DEVICE_Init(void) { 14 | /* Init Device Library, add supported class and start the library. */ 15 | if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK) { 16 | Error_Handler(); 17 | } 18 | if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_VIDEO) != USBD_OK) { 19 | Error_Handler(); 20 | } 21 | /*if (USBD_AUDIO_RegisterInterface(&hUsbDeviceFS, &USBD_VIDEO_fops_FS) != USBD_OK) { 22 | Error_Handler(); 23 | }*/ 24 | if (USBD_Start(&hUsbDeviceFS) != USBD_OK) { 25 | Error_Handler(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/Src/usbd_audio_if.c: -------------------------------------------------------------------------------- 1 | #include "usbd_audio_if.h" 2 | 3 | extern USBD_HandleTypeDef hUsbDeviceFS; 4 | 5 | static int8_t AUDIO_Init_FS(uint32_t AudioFreq, uint32_t Volume, uint32_t options); 6 | static int8_t AUDIO_DeInit_FS(uint32_t options); 7 | static int8_t AUDIO_AudioCmd_FS(uint8_t* pbuf, uint32_t size, uint8_t cmd); 8 | static int8_t AUDIO_VolumeCtl_FS(uint8_t vol); 9 | static int8_t AUDIO_MuteCtl_FS(uint8_t cmd); 10 | static int8_t AUDIO_PeriodicTC_FS(uint8_t cmd); 11 | static int8_t AUDIO_GetState_FS(void); 12 | 13 | /*USBD_AUDIO_ItfTypeDef USBD_AUDIO_fops_FS = 14 | { 15 | AUDIO_Init_FS, 16 | AUDIO_DeInit_FS, 17 | AUDIO_AudioCmd_FS, 18 | AUDIO_VolumeCtl_FS, 19 | AUDIO_MuteCtl_FS, 20 | AUDIO_PeriodicTC_FS, 21 | AUDIO_GetState_FS 22 | };*/ 23 | 24 | /* Private functions ---------------------------------------------------------*/ 25 | /** 26 | * @brief Initializes the AUDIO media low layer over USB FS IP 27 | * @param AudioFreq: Audio frequency used to play the audio stream. 28 | * @param Volume: Initial volume level (from 0 (Mute) to 100 (Max)) 29 | * @param options: Reserved for future use 30 | * @retval USBD_OK if all operations are OK else USBD_FAIL 31 | */ 32 | static int8_t AUDIO_Init_FS(uint32_t AudioFreq, uint32_t Volume, uint32_t options) 33 | { 34 | /* USER CODE BEGIN 0 */ 35 | return (USBD_OK); 36 | /* USER CODE END 0 */ 37 | } 38 | 39 | /** 40 | * @brief De-Initializes the AUDIO media low layer 41 | * @param options: Reserved for future use 42 | * @retval USBD_OK if all operations are OK else USBD_FAIL 43 | */ 44 | static int8_t AUDIO_DeInit_FS(uint32_t options) 45 | { 46 | /* USER CODE BEGIN 1 */ 47 | return (USBD_OK); 48 | /* USER CODE END 1 */ 49 | } 50 | 51 | /** 52 | * @brief Handles AUDIO command. 53 | * @param pbuf: Pointer to buffer of data to be sent 54 | * @param size: Number of data to be sent (in bytes) 55 | * @param cmd: Command opcode 56 | * @retval USBD_OK if all operations are OK else USBD_FAIL 57 | */ 58 | static int8_t AUDIO_AudioCmd_FS(uint8_t* pbuf, uint32_t size, uint8_t cmd) 59 | { 60 | /* USER CODE BEGIN 2 */ 61 | /* switch(cmd) 62 | { 63 | case AUDIO_CMD_START: 64 | break; 65 | 66 | case AUDIO_CMD_PLAY: 67 | break; 68 | }*/ 69 | return (USBD_OK); 70 | /* USER CODE END 2 */ 71 | } 72 | 73 | /** 74 | * @brief Controls AUDIO Volume. 75 | * @param vol: volume level (0..100) 76 | * @retval USBD_OK if all operations are OK else USBD_FAIL 77 | */ 78 | static int8_t AUDIO_VolumeCtl_FS(uint8_t vol) 79 | { 80 | /* USER CODE BEGIN 3 */ 81 | return (USBD_OK); 82 | /* USER CODE END 3 */ 83 | } 84 | 85 | /** 86 | * @brief Controls AUDIO Mute. 87 | * @param cmd: command opcode 88 | * @retval USBD_OK if all operations are OK else USBD_FAIL 89 | */ 90 | static int8_t AUDIO_MuteCtl_FS(uint8_t cmd) 91 | { 92 | /* USER CODE BEGIN 4 */ 93 | return (USBD_OK); 94 | /* USER CODE END 4 */ 95 | } 96 | 97 | /** 98 | * @brief AUDIO_PeriodicT_FS 99 | * @param cmd: Command opcode 100 | * @retval USBD_OK if all operations are OK else USBD_FAIL 101 | */ 102 | static int8_t AUDIO_PeriodicTC_FS(uint8_t cmd) 103 | { 104 | /* USER CODE BEGIN 5 */ 105 | return (USBD_OK); 106 | /* USER CODE END 5 */ 107 | } 108 | 109 | /** 110 | * @brief Gets AUDIO State. 111 | * @retval USBD_OK if all operations are OK else USBD_FAIL 112 | */ 113 | static int8_t AUDIO_GetState_FS(void) 114 | { 115 | /* USER CODE BEGIN 6 */ 116 | return (USBD_OK); 117 | /* USER CODE END 6 */ 118 | } 119 | 120 | /** 121 | * @brief Manages the DMA full transfer complete event. 122 | * @retval None 123 | */ 124 | void TransferComplete_CallBack_FS(void) 125 | { 126 | /* USER CODE BEGIN 7 */ 127 | //USBD_AUDIO_Sync(&hUsbDeviceFS, AUDIO_OFFSET_FULL); 128 | /* USER CODE END 7 */ 129 | } 130 | 131 | /** 132 | * @brief Manages the DMA Half transfer complete event. 133 | * @retval None 134 | */ 135 | void HalfTransfer_CallBack_FS(void) 136 | { 137 | /* USER CODE BEGIN 8 */ 138 | //USBD_AUDIO_Sync(&hUsbDeviceFS, AUDIO_OFFSET_HALF); 139 | /* USER CODE END 8 */ 140 | } 141 | 142 | /* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */ 143 | 144 | /* USER CODE END PRIVATE_FUNCTIONS_IMPLEMENTATION */ 145 | 146 | /** 147 | * @} 148 | */ 149 | 150 | /** 151 | * @} 152 | */ 153 | 154 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 155 | -------------------------------------------------------------------------------- /GBLiveCam/Firmware/osd_font.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBLiveCam/Firmware/osd_font.bmp -------------------------------------------------------------------------------- /GBLiveCam/PCB/GBLiveCam_B - CADCAM.ZIP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBLiveCam/PCB/GBLiveCam_B - CADCAM.ZIP -------------------------------------------------------------------------------- /GBLiveCam/PCB/GBLiveCam_B_BOM.csv: -------------------------------------------------------------------------------- 1 | Category,Quantity,References,Value,PCB Package,Stock Code,Notes 2 | Capacitors,3,"C1-C2,C4",47uF,TANT-C,TAJC476K016SNJ,47u 16V tantalum 3 | Capacitors,4,"C3,C5-C7",100nF,1206,,100n 10V MLCC 4 | Capacitors,1,C8,4.7uF,1206,C1206C473K5RAC7867,4.7u 5V MLCC 5 | Capacitors,1,C9,10nF,1206,C1206C103K5RAC,DNP 6 | Resistors,2,R1-R2,10k,1206,, 7 | Resistors,1,R3,150,1206,, 8 | Resistors,1,R5,2.2k,1206,,DNP 9 | Integrated Circuits,1,U1,1117,SOT223-3,LDL1117S33R,3.3V LDO 10 | Integrated Circuits,1,U2,STM32F730R8T6,QFP50P1200X1200X160-64,STM32F730R8T6, 11 | Integrated Circuits,1,U3,74LVC16373,SOP50P810X110-48,74LVC16373ADGG, 12 | Integrated Circuits,1,U4,MAX9813,SOT23-8,MAX9813LEKA+T,DNP 13 | Diodes,1,D1,WP937EGW,LED,WP937EGW,3mm red/green LED 14 | Miscellaneous,5,"AI,AO,G,H,P",PIN,TESTPAD,, 15 | Miscellaneous,1,B0,SJUMPER2,SOLDERJUMPER,,Bridge for programming 16 | Miscellaneous,1,GBCAM,GBCONN,GBCONN_MICRO_NH,,Replacement NDS GBA cart connector 17 | Miscellaneous,1,L,PIN,testpad,, 18 | Miscellaneous,1,MIC,CONN-SIL2,CONN-SIL2,,DNP 19 | Miscellaneous,1,RN1,RX8,RESCAV80P160X640X70-16,CN1J8TTE101J,Octo isolated resistor array 20 | Miscellaneous,1,USB,47590-0001,USBMICRO,, 21 | Miscellaneous,1,X1,RESONATOR,CSTNE,CSTNE8M00G550000R0,8MHz resonator 22 | -------------------------------------------------------------------------------- /GBLiveCam/PCB/GBLiveCam_B_schematics.PDF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBLiveCam/PCB/GBLiveCam_B_schematics.PDF -------------------------------------------------------------------------------- /GBLiveCam/PCB/GBLiveCam_panel_bot - CADCAM.ZIP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBLiveCam/PCB/GBLiveCam_panel_bot - CADCAM.ZIP -------------------------------------------------------------------------------- /GBLiveCam/PCB/GBLiveCam_panel_top - CADCAM.ZIP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBLiveCam/PCB/GBLiveCam_panel_top - CADCAM.ZIP -------------------------------------------------------------------------------- /GBLiveCam/README.md: -------------------------------------------------------------------------------- 1 | # GBLiveCam 2 | 3 | ![GBLiveCam in use](photo.jpg) 4 | 5 | GBLiveCam is an adapter which turns a Game Boy Camera (or Pocket Camera) cartridge into an USB webcam. 6 | No screwdrivers and destruction required: just plug and stream ! 7 | 8 | ![GIF video example](video.gif) 9 | 10 | Video resolution is 256 * 224 pixels (original 128 * 112 picture scaled x2) to cancel out the chroma sub-sampling of the NV12 (YUV420) format. Frame rate is fixed 8 fps. No audio. 11 | 12 | # How to build 13 | 14 | * Order at least the main PCB: `GBLiveCam_B - CADCAM.ZIP` (60 * 75mm, 2 layers, thickness 1.6mm). 15 | * Only order the top and bottom panel PCBs (64 * 23mm, 2 layers, thickness 1mm) if you want the aluminum enclosure. 16 | * Order a 64 * 23.5 * 75mm aluminum enclosure, and 8 M2*10mm hex head screws. 17 | * Solder all components, solder the GB cart slot and the USB connector last. The bicolor LED must be bent 90°. The USB connector must be 2mm away from the edge of the PCB. 18 | * Check the tantalum caps polarity, otherwise they'll politely let you know they were backwards by exploding. 19 | * Bridge the B0 pads with solder. 20 | * Connect to computer via USB, if nothing smokes or catches on fire, an "STM32 BOOTLOADER" USB device should be detected. 21 | * Flash the firmware `Firmware\Release\GBLiveCam.bin` with dfu-util: `dfu-util --device 0483:df11 -a 0 -s 0x08000000:leave --download GBLiveCam.bin`. The LED should light up red. 22 | * Disconnected USB, clear the B0 pads so they aren't shorted anymore. 23 | * Slide the main PCB in one of the aluminum enclosure's rails to see where the USB connector hole should be made. Remove the PCB and drill a 10~14mm hole, or mill a rectangular one. 24 | * Place and screw a plate PCB on one end of the enclosure, slide the main PCB in (the right way around), place and screw the other end's plate. 25 | 26 | # Firmware 27 | 28 | If using PCB revision B, change the `#define PCBREV 'C'` line in main.h to `#define PCBREV 'B'`. 29 | 30 | # How to use 31 | 32 | * Stick a `Game Boy Camera` or `Pocket Camera` cartridge in the cart slot. 33 | * Connect to computer via USB. 34 | * You should see a `GBLiveCam` device appear. 35 | * Use as a regular webcam ! 36 | 37 | Notes: 38 | * The LED indicates the video stream status (red: only powered, green: streaming). 39 | * The gain setting should be left between 2 and 5 most of the time. Play with brightness and contrast until you see something. The more light the better ! 40 | * The hue setting is used to select one of the eight available palettes. After a change, the palette name is displayed during ~2 seconds. 41 | * The `sharpness` setting is used to trigger special functions according to the set value: 42 | * A value of `123` will show the firmware's version and the serial number. 43 | * A value of `999` will show debug values. 44 | * A value of `1337` will show "DFU!", indicating that stopping the video stream now will put the GBLiveCam into DFU (USB firmware update) mode, as if you had bridged the B0 pads again. 45 | -------------------------------------------------------------------------------- /GBLiveCam/photo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBLiveCam/photo.jpg -------------------------------------------------------------------------------- /GBLiveCam/video.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/furrtek/GBCameraProjects/806c8688ee0b01170863277d4edf75b732a3651c/GBLiveCam/video.gif --------------------------------------------------------------------------------