ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
fusb302b_registers.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4
5namespace esphome::fusb302b {
6
7// Register addresses
8static constexpr uint8_t FUSB_DEVICE_ID = 0x01;
9static constexpr uint8_t FUSB_SWITCHES0 = 0x02;
10static constexpr uint8_t FUSB_SWITCHES1 = 0x03;
11static constexpr uint8_t FUSB_MEASURE = 0x04;
12static constexpr uint8_t FUSB_CONTROL0 = 0x06;
13static constexpr uint8_t FUSB_CONTROL1 = 0x07;
14static constexpr uint8_t FUSB_CONTROL3 = 0x09;
15static constexpr uint8_t FUSB_MASK1 = 0x0A;
16static constexpr uint8_t FUSB_POWER = 0x0B;
17static constexpr uint8_t FUSB_RESET = 0x0C;
18static constexpr uint8_t FUSB_MASKA = 0x0E;
19static constexpr uint8_t FUSB_MASKB = 0x0F;
20static constexpr uint8_t FUSB_STATUS0A = 0x3C;
21static constexpr uint8_t FUSB_STATUS0 = 0x40;
22static constexpr uint8_t FUSB_STATUS1 = 0x41;
23static constexpr uint8_t FUSB_FIFOS = 0x43;
24
25// DEVICE_ID: version in bits 7:4, product variant (I2C address 0x22-0x25) in bits 3:2, silicon revision in bits 1:0
26static constexpr uint8_t FUSB_DEVICE_ID_VERSION_MASK = 0xF0;
27static constexpr uint8_t FUSB_DEVICE_ID_VERSION_A = 0x80;
28static constexpr uint8_t FUSB_DEVICE_ID_VERSION_B = 0x90;
29
30// SWITCHES0 bits
31static constexpr uint8_t FUSB_SWITCHES0_MEAS_CC2 = 1 << 3;
32static constexpr uint8_t FUSB_SWITCHES0_MEAS_CC1 = 1 << 2;
33static constexpr uint8_t FUSB_SWITCHES0_PDWN_2 = 1 << 1;
34static constexpr uint8_t FUSB_SWITCHES0_PDWN_1 = 1 << 0;
35
36// SWITCHES1 bits
37static constexpr uint8_t FUSB_SWITCHES1_SPECREV_REV2 = 0x01 << 5;
38static constexpr uint8_t FUSB_SWITCHES1_AUTO_CRC = 1 << 2;
39static constexpr uint8_t FUSB_SWITCHES1_TXCC2 = 1 << 1;
40static constexpr uint8_t FUSB_SWITCHES1_TXCC1 = 1 << 0;
41
42// MEASURE value used for CC detection
43static constexpr uint8_t FUSB_MEASURE_MDAC_CC = 49;
44
45// CONTROL0 bits
46static constexpr uint8_t FUSB_CONTROL0_TX_FLUSH = 1 << 6;
47
48// CONTROL1 bits
49static constexpr uint8_t FUSB_CONTROL1_RX_FLUSH = 1 << 2;
50
51// CONTROL3 bits
52static constexpr uint8_t FUSB_CONTROL3_N_RETRIES_SHIFT = 1;
53static constexpr uint8_t FUSB_CONTROL3_N_RETRIES_MASK = 0x3 << FUSB_CONTROL3_N_RETRIES_SHIFT;
54static constexpr uint8_t FUSB_CONTROL3_AUTO_RETRY = 1 << 0;
55
56// MASK1: mask the ACTIVITY, CRC_CHK and BC_LVL interrupts
57static constexpr uint8_t FUSB_MASK1_DEFAULT = 0x51;
58
59// POWER bits
60static constexpr uint8_t FUSB_POWER_ALL = 0x0F;
61
62// RESET bits
63static constexpr uint8_t FUSB_RESET_PD_RESET = 1 << 1;
64static constexpr uint8_t FUSB_RESET_SW_RES = 1 << 0;
65
66// INTERRUPTA bits
67static constexpr uint8_t FUSB_INTERRUPTA_I_RETRYFAIL = 1 << 4;
68static constexpr uint8_t FUSB_INTERRUPTA_I_SOFTRST = 1 << 1;
69static constexpr uint8_t FUSB_INTERRUPTA_I_HARDRST = 1 << 0;
70
71// INTERRUPT bits
72static constexpr uint8_t FUSB_INTERRUPT_I_VBUSOK = 1 << 7;
73
74// STATUS0 bits
75static constexpr uint8_t FUSB_STATUS0_VBUSOK = 1 << 7;
76static constexpr uint8_t FUSB_STATUS0_BC_LVL = 0x03;
77
78// STATUS1 bits
79static constexpr uint8_t FUSB_STATUS1_RX_EMPTY = 1 << 5;
80
81// RX FIFO token
82static constexpr uint8_t FUSB_FIFO_RX_TOKEN_BITS = 0xE0;
83static constexpr uint8_t FUSB_FIFO_RX_SOP = 0xE0;
84
85// TX FIFO tokens
86static constexpr uint8_t FUSB_TX_TOKEN_TXON = 0xA1;
87static constexpr uint8_t FUSB_TX_TOKEN_SYNC1 = 0x12;
88static constexpr uint8_t FUSB_TX_TOKEN_SYNC2 = 0x13;
89static constexpr uint8_t FUSB_TX_TOKEN_PACKSYM = 0x80;
90static constexpr uint8_t FUSB_TX_TOKEN_JAM_CRC = 0xFF;
91static constexpr uint8_t FUSB_TX_TOKEN_EOP = 0x14;
92static constexpr uint8_t FUSB_TX_TOKEN_TXOFF = 0xFE;
93
94} // namespace esphome::fusb302b