How iwatake2222/digitalcamera_stm32 works
Project Type & Purpose
• This is an embedded system project for a digital camera built around an STM32F4 microcontroller.
• Its purpose is to capture still photos and record movies (both JPEG and Motion JPEG), provide a live view, and facilitate media playback using peripherals (camera module OV7670, LCD with ILI9341 controller, and an SD card for storage).
Analyzing the File Structure
• Top-Level Components:
– Directories such as Drivers (CMSIS and STM32 HAL drivers), Src (application source code and drivers), and Inc (header files). These indicate a layered design with hardware abstraction.
– The Middlewares folder contains external libraries for FreeRTOS (real-time operating system scheduler), FatFS (file system for SD card), and LibJPEG (for JPEG compression/decompression).
– The presence of a startup folder and configuration files (for CubeMX, linker file, etc.) confirms that the project is built on standard STM32 embedded design principles.
• Observations:
– There is clear separation between hardware drivers (e.g., for LCD, OV7670, UART) and application logic (mode manager, live view control, playback).
– Tools and documentation directories indicate that there are conversion tools (e.g., jpeg2RGB565.py) and design documents to aid the development.
Insights from the README
• It highlights the use of specific STM32 peripherals: DCMI for the camera, FSMC or similar interface for LCD, SPI for SD card, and interfaces for rotary encoders and buttons.
• The software is built using FreeRTOS to manage tasks, FatFS to handle file operations on the SD card, and LibJPEG for image processing.
• Main Components (each represented as a distinct block or component):
– Microcontroller (STM32F407 on the Discovery board), representing the core processing unit.
– Hardware Interfaces:
• Camera Module (OV7670) on the DCMI interface.
• Module (ILI9341) connected via FSMC/LCD driver.
• SD Card via SPI (plus FatFS integration).
• I2C bus for camera configuration.
• UART for terminal debugging.
• Rotary Encoders and Buttons (control inputs).
– Software Layers:
• Hardware Abstraction Layer (drivers under “Drivers” and “Inc” folders using STM32 HAL and CMSIS libraries).
• Middleware Layer:
• FreeRTOS – for task scheduling (look at Middlewares/Third_Party/FreeRTOS).
• FatFS – for file system management on SD card (in the FatFs folder).
• LibJPEG – for image handling (located in Middlewares/Third_Party/LibJPEG).
• Application Layer:
• Application logic in the “Src/app” folder (debugMonitor, liveviewCtrl, modeMgr, playbackCtrl).
• Additional services in “Src/service” (file and input services).
• Low-Level Initialization and Startup routines (startup folder and main.c, system_stm32f4xx.c).
• Relationships and Data Flow:
– Show that the hardware abstraction layer directly interfaces with the physical interfaces (DCMI for camera, FSMC for LCD, SPI for SD card).
• Architectural Patterns/Design Principles:
– Layered architecture: Separation of hardware-level drivers, middleware services, and application logic.
– Use of a Real-Time Operating System (FreeRTOS) for multitasking.
– Modular design approach allowing independent updating of drivers (e.g., for LCD or camera) without impacting higher-level services.
• Incorporate Relevant Technologies:
– STM32F407 (ARM Cortex-M4) as the MCU.
– STM32CubeMX and HAL libraries for peripheral configuration.
– External libraries: FreeRTOS, FatFS, LibJPEG.
– Tools: Python and batch scripts in “00_tools” for data conversion.
Final Assembly
• On one side, attach the interfaces: DCMI (with connection to OV7670), FSMC for LCD connection, SPI for SD card.
• On another side, layer the drivers (CMSIS, HAL), followed by middleware (FreeRTOS, FatFS, LibJPEG), and then the application logic (live view, mode management, and playback).
• Don’t forget to include peripheral debugging tools (USART2) and configuration inputs (buttons/rotary encoders).