software and system v1

This commit is contained in:
2026-02-02 00:49:50 +01:00
parent 9c5082cd9e
commit a23dbf0828
21 changed files with 4400 additions and 137 deletions

View File

@@ -0,0 +1,120 @@
# SPI Wrapper Component
## OSAL Layer - ESP-IDF v5.4 Abstraction
**Component ID:** C-OSAL-SPI
**Version:** 1.0
**Date:** 2025-02-01
**Location:** `osal/spi_wrapper/`
**ESP-IDF Service:** `driver/spi_master.h`, `driver/spi_slave.h`
---
## 1. Component Overview
The SPI Wrapper provides a platform-independent interface for SPI bus operations, abstracting ESP-IDF v5.4 SPI master and slave drivers. This component enables storage drivers and other components to access SPI devices (SD cards, flash chips) without direct ESP-IDF dependencies.
**Primary Purpose:** Abstract SPI bus operations for application components.
---
## 2. Responsibilities
### 2.1 In-Scope
- SPI bus initialization and configuration
- SPI device registration and management
- SPI transaction operations (master mode)
- SPI bus error handling and recovery
- SPI bus resource management
- SPI timeout handling
- SPI bus status monitoring
### 2.2 Out-of-Scope
- SPI slave mode (not required for sensor hub)
- SPI protocol-level error recovery (handled by ESP-IDF)
- Device-specific SPI protocols (handled by storage drivers)
---
## 3. Provided Interfaces
### 3.1 Bus Management Interface
```c
/**
* @brief Initialize SPI bus
* @param bus_num SPI bus number (SPI1_HOST, SPI2_HOST, SPI3_HOST)
* @param config Bus configuration (clock speed, pins, mode)
* @return OSAL_OK on success
*/
osal_result_t osal_spi_bus_init(spi_bus_num_t bus_num, const osal_spi_bus_config_t* config);
/**
* @brief Deinitialize SPI bus
* @param bus_num SPI bus number
* @return OSAL_OK on success
*/
osal_result_t osal_spi_bus_deinit(spi_bus_num_t bus_num);
```
### 3.2 Device Management Interface
```c
/**
* @brief Register SPI device on bus
* @param bus_num SPI bus number
* @param device_config Device configuration (CS pin, mode, clock speed)
* @param device_handle Output device handle
* @return OSAL_OK on success
*/
osal_result_t osal_spi_device_register(spi_bus_num_t bus_num,
const osal_spi_device_config_t* device_config,
osal_spi_device_handle_t* device_handle);
/**
* @brief Unregister SPI device
* @param device_handle Device handle
* @return OSAL_OK on success
*/
osal_result_t osal_spi_device_unregister(osal_spi_device_handle_t device_handle);
```
### 3.3 Transaction Interface
```c
/**
* @brief Perform SPI transaction
* @param device_handle Device handle
* @param tx_data Transmit data buffer (NULL if read-only)
* @param rx_data Receive data buffer (NULL if write-only)
* @param length Transaction length in bytes
* @param timeout_ms Timeout in milliseconds
* @return OSAL_OK on success
*/
osal_result_t osal_spi_transaction(osal_spi_device_handle_t device_handle,
const uint8_t* tx_data, uint8_t* rx_data,
size_t length, uint32_t timeout_ms);
```
---
## 4. ESP-IDF v5.4 Integration
- Uses `spi_bus_handle_t` and `spi_device_handle_t`
- Supports SPI1_HOST, SPI2_HOST, SPI3_HOST
- Clock speed: Up to 80MHz (ESP32-S3 limit)
- SPI modes: 0, 1, 2, 3 supported
---
## 5. Traceability
- **SR-HW-005:** Hardware interface abstraction
- **SWR-IF-002:** SPI protocol support
- **SWR-DESIGN-003:** OSAL layer access
---
**Document Status:** Complete
**Next Review:** Before implementation