3.24_433_RX版本:封装RF433模块,完成开机进入TX/RX模式并在开发板验证成功

This commit is contained in:
2026-03-24 16:59:20 +08:00
commit e439dd465e
1311 changed files with 692196 additions and 0 deletions

132
CLAUDE.md Normal file
View File

@ -0,0 +1,132 @@
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
This is an STM32F103C8 firmware project for the E32-433TBH-SC 433MHz wireless transceiver module with OLED display and menu system. The project provides a user interface for configuring and testing the E32 wireless module.
## Build System
This project uses Keil MDK-ARM (µVision) for building.
**Build Commands:**
- Open `MDK-ARM/project.uvprojx` in Keil µVision
- Build: F7 or Project → Build Target
- Flash: F8 or Flash → Download
**Target:** STM32F103C8 (Cortex-M3, 64KB Flash, 20KB RAM)
## Architecture
### Hardware Abstraction Layer (`Core/`)
- **e32_hal.c/h** - Hardware abstraction for the E32 wireless module
- `e32_hal_uart_tx()` - UART transmission
- `e32_hal_aux_wait()` - Wait for AUX pin (module busy indicator)
- `e32_hal_reset()` - Reset the E32 module
- `e32_hal_work_mode()` - Switch between transparent/WOR/config modes
- **e32_demo.c/h** - E32 module driver and protocol implementation
- Register structures for module configuration (address, channel, baud rate, power, FEC)
- Functions for reading module name, firmware version, configuration
- Transmission modes (transparent, specify target)
- **u8g2_hal.c/h** - Hardware interface for OLED display via I2C
- **key.c** - Button input handling (UP, DOWN, ENTER)
- **fifo.c** - Ring buffer implementation for UART/USB data
- **systick.c** - 1ms timer callbacks for timeouts and key scanning
### Menu System (`Middlewares/MultMenu/`)
A custom hierarchical menu framework with animation support:
- **menu.c/h** - Core menu framework
- `Menu_Init()` - Initialize menu structure
- `Menu_Task()` - Main menu loop (call from main while loop)
- Page/Item/Menu structures for hierarchical navigation
- **menuConfig.h** - Menu configuration and type definitions
- Screen resolution: 128x64 (OLED)
- Menu states: INIT, DRAWING, RUN, APP_RUN, etc.
- Item types: PARENTS, LOOP_FUNCTION, ONCE_FUNCTION, SWITCH, DATA
- **application.c/h** - Application-specific menu callbacks
- Configuration items: work_mode, rate_mode, channel, tx_power, tx_count
- Mode callbacks: tx_mode_callback, rx_mode_callback
- Utility callbacks: version_callback, reset_callback, background_color_callback
- **AirPlane.c/h, DinoGame.c** - Example games running on the menu system
### Display Library (`Middlewares/u8g2Lib/`)
U8g2 graphics library for OLED display:
- Configure display in `u8g2_hal.c`
- Font: `u8g2_font_profont12_mf` (12px height, defined in menuConfig.h)
### USB CDC (`USB_DEVICE/`)
Virtual serial port over USB for PC communication and AT commands.
## Key Configuration
### Pin Definitions (`Core/Inc/main.h`)
```
RESET -> PA3 (E32 module reset)
M0 -> PA7 (Mode select 0)
M1 -> PB0 (Mode select 1)
AUX -> PB1 (Busy indicator)
LED_TX -> PA15 (TX indicator)
LED_RX -> PB6 (RX indicator)
KEY_UP -> PB4
KEY_DOWN -> PB9
KEY_ENTER -> PB7
```
### E32 Work Modes
- Mode 0 (M0=0, M1=0): Transparent transmission
- Mode 1 (M0=1, M1=0): WOR master (wake on radio)
- Mode 2 (M0=0, M1=1): WOR slave (power saving)
- Mode 3 (M0=1, M1=1): Configuration/sleep mode
### E32 Register Structure
- Register 01H-02H: Module address (high/low byte)
- Register 03H: Air data rate, UART baud rate, parity
- Register 04H: RF channel
- Register 05H: TX power, FEC, WOR period, target mode
## Adding New Menu Items
1. Define the item variable in `menu.c`:
```c
xItem my_new_item;
```
2. Add page if needed:
```c
xPage my_new_page;
```
3. In `Menu_Init()`, add the item using `AddItem()`:
```c
AddItem("Item Name", ITEM_TYPE, &data, &my_new_item, &Home_Page, NULL, my_callback);
```
4. Implement the callback function in `application.c`:
```c
void my_callback(xpItem item) {
// Handle item selection
}
```
## STM32CubeIDE Integration
The project was generated with STM32CubeMX (`project.ioc`). To modify peripherals:
1. Open `project.ioc` in STM32CubeMX
2. Configure peripherals
3. Generate code
4. Copy generated files to `Core/` directory, preserving user code sections marked by `/* USER CODE BEGIN */` and `/* USER CODE END */`
## Important Notes
- The main loop calls `Menu_Task()` to handle menu rendering and input
- Key scanning happens via 1ms systick callback
- Use `usb_printf()` for debug output via USB CDC
- AUX pin must be HIGH before sending commands (use `e32_hal_aux_wait()`)
- E32 module reset takes ~30ms (V8.2 firmware) or ~1200ms (V8.1 firmware)