How drbild/cp2130 works
Main Components Identification
a. Core API Layer
• Entry point for users
• High-level Pythonic interface
b. Feature Modules Layer
• SPI Communication
• GPIO Management
• Clock Configuration
• Event Counter
• ROM Operations
• USB Configuration
c. Low-Level Implementation Layer
• Chip Commands
• Register Operations
• USB Backend Implementations
[User Application]
• ↓
[Core API Layer]
• ↓
[Feature Modules]
• ↓
[Low-Level Implementation]
• ↓
[Hardware Interface]
Component Details
a. Core API Layer (cp2130.core):
• Connections to all feature modules
• Main CP2130 class as the primary interface
• SPI Module (spi.py)
• GPIO Module (gpio.py)
• Clock Module (clock.py)
• Event Counter Module (event_counter.py)
• Pin Configuration (pin_config.py)
• USB Configuration (usb_config.py)
c. Data Layer (data/):
• As a shared resource
• To both Core API and Feature Modules
• Enums and constants
d. Chip Layer:
• Command handling (chip/commands.py)
• Register management (chip/registers.py)
• Field definitions (chip/fields.py)
e. USB Backend Layer:
• Multiple implementations (PyUSB and libusb1)
• Use interface symbol for USBDevice interface
• To hardware layer
Important Relationships
a. Data Flow:
• User → Core API → Feature Modules → Chip Layer → USB Backend → Hardware
b. Dependencies:
• How data package is used across layers
• USB backend abstraction
• Chip command flow
Additional Elements
• Notes about critical features (e.g., cs_hold limitation)
• Version compatibility (Python 2.7 and 3.3+)