# ROM wifi funcs

todo:

- disasm the wifi binary

```mermaid
sequenceDiagram
    participant Device
    participant AP as Access Point
    participant MAC as MAC Layer
    participant PHY as PHY Layer

    Note over Device,PHY: Initialization Phase
    Device->>MAC: ROM_WIFI_InitMacClk
    Device->>MAC: ROM_WIFI_Init32kClk
    Device->>MAC: ROM_WIFI_InitLxDma
    Device->>MAC: ROM_WIFI_INIT_MACADDR_SET
    Device->>MAC: ROM_WIFI_InitNetworkType
    Device->>MAC: ROM_WIFI_InitEDCA
    Device->>PHY: ROM_WIFI_ENABLE_BB_RF

    Note over Device,PHY: Connection Phase
    Device->>AP: ROM_WIFI_Set_MLME_Sitesurvey
    AP->>Device: Beacon Frames
    Device->>MAC: ROM_WIFI_BCN_VALID
    Device->>MAC: ROM_WIFI_CHECK_BSSID
    Device->>MAC: ROM_WIFI_Set_MLME_JOIN
    Device->>MAC: ROM_WIFI_BSSID_SET

    Note over Device,PHY: Operation Phase
    Device->>MAC: ROM_WIFI_Set_AC_Param
    MAC->>Device: ROM_WIFI_CHECK_TXBUF
    Device->>MAC: ROM_WIFI_SET_MAX_AGG_NUM

    Note over Device,PHY: Security Setup
    Device->>MAC: ROM_WIFI_SEC_CFG
    Device->>MAC: ROM_WIFI_CAM_WRITE

    Note over Device,PHY: Maintenance
    Device->>MAC: ROM_WIFI_TSF_GetByPort
    Device->>MAC: ROM_WIFI_IMR_UPDATE
    Device->>MAC: ROM_WIFI_High_Queue_Empty_Check

```

1. init:

   - sysclock init (`ROM_WIFI_InitMacClk`, `ROM_WIFI_Init32kClk`)
   - DMA setup (`ROM_WIFI_InitLxDma`)
   - MAC address config (`ROM_WIFI_INIT_MACADDR_SET`)
   - Network type setup (`ROM_WIFI_InitNetworkType`)
   - EDCA params for QoS (`ROM_WIFI_InitEDCA`)
   - RF/Baseband enable (`ROM_WIFI_ENABLE_BB_RF`)

2. connect:

   - site survey to find networks (`ROM_WIFI_Set_MLME_Sitesurvey`)
   - beacon validation (`ROM_WIFI_BCN_VALID`)
   - BSSID checking (`ROM_WIFI_CHECK_BSSID`)
   - join request (`ROM_WIFI_Set_MLME_JOIN`)
   - BSSID setting (`ROM_WIFI_BSSID_SET`)

3. config:

   - AC (Access Category) param (`ROM_WIFI_Set_AC_Param`)
   - Buffer management? (`ROM_WIFI_CHECK_TXBUF`)
   - Aggregation configuration (`ROM_WIFI_SET_MAX_AGG_NUM`)

4. security:

   - Security configuration (`ROM_WIFI_SEC_CFG`)
   - CAM (Content Addressable Memory) (`ROM_WIFI_CAM_WRITE`)

5. maintain:
   - TSF (Timing Synchronization Function) (`ROM_WIFI_TSF_GetByPort`)
   - Interrupt mask updates (`ROM_WIFI_IMR_UPDATE`)
   - Queue monitoring (`ROM_WIFI_High_Queue_Empty_Check`)

- MU-EDCA (Multi-User EDCA) `ROM_WIFI_AX_MUEDCA_Para`
- BSS Coloring `ROM_WIFI_AX_BSS_COLOR_SET`
- OFDMA (Orthogonal Frequency Division Multiple Access)
