Quick Start

This guide will get you up and running with the TLE92466ED driver in just a few steps.

Prerequisites

Minimal Example

Here’s a complete working example:

```cpp #include “tle92466ed.hpp”

// 1. Implement the SPI interface class MySpi : public tle92466ed::SpiInterface { public: auto spiTransfer(std::span txData, std::span rxData) noexcept -> std::expected<void, tle92466ed::CommError> override { // Your SPI transfer implementation // Assert CS, transfer 32-bit frames, deassert CS return {}; }

1
2
3
void delayMicroseconds(uint32_t us) noexcept override {
    // Your delay implementation
} };

// 2. Create instances MySpi spi; tle92466ed::Driver driver(spi);

// 3. Initialize if (auto result = driver.Init(); !result) { // Handle error return; }

// 4. Enter mission mode driver.EnterMissionMode();

// 5. Configure channel 0 for 1.5A current control driver.SetChannelMode(tle92466ed::Channel::CH0, tle92466ed::ChannelMode::ICC); driver.SetCurrentSetpoint(tle92466ed::Channel::CH0, 1500); // 1500 mA

// 6. Enable channel driver.EnableChannel(tle92466ed::Channel::CH0, true); ```cpp

Step-by-Step Explanation

Step 1: Include the Header

cpp #include "tle92466ed.hpp" cpp

This includes the main driver class and all necessary types.

Step 2: Implement the SPI Interface

You need to implement the SpiInterface for your platform. See Platform Integration for detailed examples.

```cpp class MySpi : public tle92466ed::SpiInterface { public: auto spiTransfer(std::span txData, std::span rxData) noexcept -> std::expected<void, tle92466ed::CommError> override { // Implement 32-bit SPI frame transfer with CRC return {}; }

1
2
3
void delayMicroseconds(uint32_t us) noexcept override {
    // Implement microsecond delay
} }; ```cpp

Step 3: Create Driver Instance

cpp MySpi spi; tle92466ed::Driver driver(spi); cpp

The constructor takes a reference to your SPI interface implementation.

Step 4: Initialize

cpp if (auto result = driver.Init(); !result) { // Handle error - result.error() contains DriverError return; } cpp

Step 5: Enter Mission Mode

cpp driver.EnterMissionMode(); text

Mission mode enables channel control. Configuration changes require Config Mode.

Step 6: Configure Channel

cpp driver.SetChannelMode(tle92466ed::Channel::CH0, tle92466ed::ChannelMode::ICC); driver.SetCurrentSetpoint(tle92466ed::Channel::CH0, 1500); // 1500 mA cpp

Step 7: Enable Channel

cpp driver.EnableChannel(tle92466ed::Channel::CH0, true); cpp

Complete Example with Error Handling

```cpp #include “tle92466ed.hpp”

class MySpi : public tle92466ed::SpiInterface { // ... SPI implementation };

void app_main() { MySpi spi; tle92466ed::Driver driver(spi);

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Initialize
if (auto result = driver.Init(); !result) {
    printf("Initialization failed: %d\n", static_cast<int>(result.error()));
    return;
}

// Enter mission mode
if (auto result = driver.EnterMissionMode(); !result) {
    printf("Failed to enter mission mode\n");
    return;
}

// Configure channel 0
if (auto result = driver.SetChannelMode(tle92466ed::Channel::CH0, 
                                        tle92466ed::ChannelMode::ICC); !result) {
    printf("Failed to set channel mode\n");
    return;
}

if (auto result = driver.SetCurrentSetpoint(tle92466ed::Channel::CH0, 1500); !result) {
    printf("Failed to set current\n");
    return;
}

// Enable channel
driver.EnableChannel(tle92466ed::Channel::CH0, true);

// Read diagnostics
if (auto diag = driver.GetChannelDiagnostics(tle92466ed::Channel::CH0); diag) {
    printf("Channel 0 current: %u mA\n", diag->average_current);
} } ```cpp

Expected Output

When running this example, you should see:

cpp Channel 0 current: 1500 mA cpp

Troubleshooting

If you encounter issues:

  • Compilation errors: Check that you’ve implemented the spiTransfer() method in your SPI interface
  • Initialization fails: Verify SPI connections and hardware setup
  • Channel not working: Check channel configuration and enable state
  • See: Troubleshooting for common issues

Next Steps


Navigation ⬅️ Installation | Next: Hardware Setup ➡️ | Back to Index