|
static Version | setVersionInfo (Register &base) |
| Get PORT version information.
|
|
static void | secletPortVoltageRange (Register &base, VoltageRange range) |
| Get PORT version information.
|
|
static void | setPinConfig (Register &base, uint32 pin, const Config &config) |
| Sets the port PCR register.
|
|
static void | setMultiplePinsConfig (Register &base, uint32 mask, const Config &config) |
| Sets the port PCR register for multiple pins.
|
|
static void | setPinMux (Register &base, uint32 pin, Mux mux) |
| Configures the pin muxing.
|
|
static void | setPinDriveStrength (Register &base, uint32 pin, uint8 strength) |
| Configures the port pin drive strength.
|
|
static void | enablePinDoubleDriveStrength (Register &base, uint32 pin, bool enable) |
| Enables the port pin double drive strength.
|
|
static void | setPinPullValue (Register &base, uint32 pin, uint8 value) |
| Configures the port pin pull value.
|
|
static constexpr uint32 | VERID_FEATURE (uint32 value) |
| VERID - FEATURE.
|
|
static constexpr uint32 | VERID_MINOR (uint32 value) |
| VERID - MINOR.
|
|
static constexpr uint32 | VERID_MAJOR (uint32 value) |
| VERID - MAJOR.
|
|
static constexpr uint32 | GPCLR_GPWD (uint32 value) |
| GPCLR - GPWD.
|
|
static constexpr uint32 | GPCLR_GPWE0 (uint32 value) |
| GPCLR - GPWE0.
|
|
static constexpr uint32 | GPCLR_GPWE1 (uint32 value) |
| GPCLR - GPWE1.
|
|
static constexpr uint32 | GPCLR_GPWE2 (uint32 value) |
| GPCLR - GPWE2.
|
|
static constexpr uint32 | GPCLR_GPWE3 (uint32 value) |
| GPCLR - GPWE3.
|
|
static constexpr uint32 | GPCLR_GPWE4 (uint32 value) |
| GPCLR - GPWE4.
|
|
static constexpr uint32 | GPCLR_GPWE5 (uint32 value) |
| GPCLR - GPWE5.
|
|
static constexpr uint32 | GPCLR_GPWE6 (uint32 value) |
| GPCLR - GPWE6.
|
|
static constexpr uint32 | GPCLR_GPWE7 (uint32 value) |
| GPCLR - GPWE7.
|
|
static constexpr uint32 | GPCLR_GPWE8 (uint32 value) |
| GPCLR - GPWE8.
|
|
static constexpr uint32 | GPCLR_GPWE9 (uint32 value) |
| GPCLR - GPWE9.
|
|
static constexpr uint32 | GPCLR_GPWE10 (uint32 value) |
| GPCLR - GPWE10.
|
|
static constexpr uint32 | GPCLR_GPWE11 (uint32 value) |
| GPCLR - GPWE11.
|
|
static constexpr uint32 | GPCLR_GPWE12 (uint32 value) |
| GPCLR - GPWE12.
|
|
static constexpr uint32 | GPCLR_GPWE13 (uint32 value) |
| GPCLR - GPWE13.
|
|
static constexpr uint32 | GPCLR_GPWE14 (uint32 value) |
| GPCLR - GPWE14.
|
|
static constexpr uint32 | GPCLR_GPWE15 (uint32 value) |
| GPCLR - GPWE15.
|
|
static constexpr uint32 | GPCHR_GPWD (uint32 value) |
| GPCHR - GPWD.
|
|
static constexpr uint32 | GPCHR_GPWE16 (uint32 value) |
| GPCHR - GPWE16.
|
|
static constexpr uint32 | GPCHR_GPWE17 (uint32 value) |
| GPCHR - GPWE17.
|
|
static constexpr uint32 | GPCHR_GPWE18 (uint32 value) |
| GPCHR - GPWE18.
|
|
static constexpr uint32 | GPCHR_GPWE19 (uint32 value) |
| GPCHR - GPWE19.
|
|
static constexpr uint32 | GPCHR_GPWE20 (uint32 value) |
| GPCHR - GPWE20.
|
|
static constexpr uint32 | GPCHR_GPWE21 (uint32 value) |
| GPCHR - GPWE21.
|
|
static constexpr uint32 | GPCHR_GPWE22 (uint32 value) |
| GPCHR - GPWE22.
|
|
static constexpr uint32 | GPCHR_GPWE23 (uint32 value) |
| GPCHR - GPWE23.
|
|
static constexpr uint32 | GPCHR_GPWE24 (uint32 value) |
| GPCHR - GPWE24.
|
|
static constexpr uint32 | GPCHR_GPWE25 (uint32 value) |
| GPCHR - GPWE25.
|
|
static constexpr uint32 | GPCHR_GPWE26 (uint32 value) |
| GPCHR - GPWE26.
|
|
static constexpr uint32 | GPCHR_GPWE27 (uint32 value) |
| GPCHR - GPWE27.
|
|
static constexpr uint32 | GPCHR_GPWE28 (uint32 value) |
| GPCHR - GPWE28.
|
|
static constexpr uint32 | GPCHR_GPWE29 (uint32 value) |
| GPCHR - GPWE29.
|
|
static constexpr uint32 | GPCHR_GPWE30 (uint32 value) |
| GPCHR - GPWE30.
|
|
static constexpr uint32 | GPCHR_GPWE31 (uint32 value) |
| GPCHR - GPWE31.
|
|
static constexpr uint32 | CONFIG_RANGE (uint32 value) |
| CONFIG - RANGE.
|
|
static constexpr uint32 | CALIB0_NCAL (uint32 value) |
| CALIB0 - NCAL.
|
|
static constexpr uint32 | CALIB0_PCAL (uint32 value) |
| CALIB0 - PCAL.
|
|
static constexpr uint32 | CALIB1_NCAL (uint32 value) |
| CALIB1 - NCAL.
|
|
static constexpr uint32 | CALIB1_PCAL (uint32 value) |
| CALIB1 - PCAL.
|
|
static constexpr uint32 | PCR_PS (uint32 value) |
| PCR - PS.
|
|
static constexpr uint32 | PCR_PE (uint32 value) |
| PCR - PE.
|
|
static constexpr uint32 | PCR_PV (uint32 value) |
| PCR - PV.
|
|
static constexpr uint32 | PCR_SRE (uint32 value) |
| PCR - SRE.
|
|
static constexpr uint32 | PCR_PFE (uint32 value) |
| PCR - PFE.
|
|
static constexpr uint32 | PCR_ODE (uint32 value) |
| PCR - ODE.
|
|
static constexpr uint32 | PCR_DSE (uint32 value) |
| PCR - DSE.
|
|
static constexpr uint32 | PCR_DSE1 (uint32 value) |
| PCR - DSE1.
|
|
static constexpr uint32 | PCR_MUX (uint32 value) |
| PCR - MUX.
|
|
static constexpr uint32 | PCR_IBE (uint32 value) |
| PCR - IBE.
|
|
static constexpr uint32 | PCR_INV (uint32 value) |
| PCR - INV.
|
|
static constexpr uint32 | PCR_LK (uint32 value) |
| PCR - LK.
|
|
MCXA153 埠控制暫存器 (Port Control Register) 管理靜態工具類別
Port 類別提供 MCXA153 微控制器埠控制暫存器的完整操作介面。 此類別設計為靜態工具類別,無法實例化,所有功能均透過靜態函數提供, 用於配置和控制 GPIO 引腳的電氣特性、多工選擇、上下拉電阻、 驅動強度、濾波功能等詳細的引腳屬性設定。
主要功能模組包括:
引腳多工控制 (Pin Multiplexing):
- **MUX 選擇**:支援 14 種不同的引腳功能選擇 (Alternative 0-13)
- **功能切換**:GPIO、UART、SPI、I2C、PWM、ADC 等功能切換
- **動態重配置**:運行時動態改變引腳功能
- **晶片特定功能**:支援各種晶片特定的周邊功能映射
電氣特性配置:
- 上下拉電阻 (Pull-up/Pull-down):內建可選擇的上拉/下拉電阻
- 驅動強度 (Drive Strength):低驅動/高驅動強度選擇
- 雙倍驅動強度 (Double Drive Strength):加強驅動能力選項
- 開漏輸出 (Open Drain):支援開漏和推挽輸出模式
- 轉換速率 (Slew Rate):快速/慢速邊緣轉換控制
輸入信號處理:
- 輸入緩衝器 (Input Buffer):可控制的輸入緩衝器啟用
- 輸入反轉 (Input Inversion):硬體信號反轉功能
- 被動濾波器 (Passive Filter):輸入信號噪音濾波
- **電壓範圍設定**:1.71V-3.6V 或 2.70V-3.6V 電壓範圍支援
批次配置功能:
- 單引腳配置 (setPinConfig):配置單一引腳的所有屬性
- 多引腳配置 (setMultiplePinsConfig):批次配置多個引腳
- 全域控制暫存器 (GPCLR/GPCHR):原子性批次引腳設定
- **引腳遮罩操作**:支援位元遮罩的批次操作
版本和校準功能:
- 版本資訊查詢 (setVersionInfo):取得 PORT 模組版本資訊
- 驅動器校準 (CALIB0/CALIB1):NMOS/PMOS 輸出驅動器校準
- **特性規格**:查詢支援的功能規格編號
支援的埠實例:
- **PORT0-PORT3**:四個獨立的埠控制器實例
- **32 個引腳**:每個埠最多支援 32 個引腳配置
- **獨立控制**:每個引腳可獨立配置所有屬性
- **陣列存取**:提供 PORT 陣列便於批次操作
引腳配置結構:
PCR 暫存器位元欄位:
- PS (Pull Select):上拉/下拉選擇
- PE (Pull Enable):上下拉啟用控制
- PV (Pull Value):上下拉電阻值選擇
- SRE (Slew Rate Enable):轉換速率控制
- PFE (Passive Filter Enable):被動濾波器啟用
- ODE (Open Drain Enable):開漏輸出啟用
- DSE (Drive Strength Enable):驅動強度控制
- DSE1 (Double Drive Strength):雙倍驅動強度
- MUX (Multiplexer):引腳功能多工選擇
- IBE (Input Buffer Enable):輸入緩衝器啟用
- INV (Invert):輸入信號反轉
- LK (Lock):暫存器鎖定保護
全域控制功能:
- GPCLR (Global Pin Control Low):控制引腳 0-15 的批次設定
- GPCHR (Global Pin Control High):控制引腳 16-31 的批次設定
- GPWD (Global Pin Write Data):全域寫入資料
- GPWE (Global Pin Write Enable):全域寫入啟用遮罩
電壓範圍和校準:
- **CONFIG_RANGE**:埠電壓範圍配置 (1.71-3.6V / 2.70-3.6V)
- **CALIB0_NCAL/PCAL**:校準暫存器 0 的 NMOS/PMOS 校準
- **CALIB1_NCAL/PCAL**:校準暫存器 1 的 NMOS/PMOS 校準
引腳鎖定機制:
- 防止意外修改關鍵引腳配置
- 鎖定後需要系統重設才能解鎖
- 適用於安全關鍵應用的引腳保護
程式設計模式:
- **型別安全配置**:使用強型別枚舉避免配置錯誤
- **constexpr 最佳化**:編譯時位元操作,執行效率高
- **批次操作支援**:提高多引腳配置的執行效率
- **原子性操作**:全域控制暫存器確保配置一致性
使用範例:
pinConfig.pull = Pull::kDisable;
pinConfig.openDrain = OpenDrain::kDisable;
pinConfig.
mux = Mux::kGpio;
uint32 pinMask = (1 << 2) | (1 << 3) | (1 << 4);
static void setPinConfig(Register &base, uint32 pin, const Config &config)
Sets the port PCR register.
Definition Port.h:280
static void secletPortVoltageRange(Register &base, VoltageRange range)
Get PORT version information.
Definition Port.h:254
static void setPinDriveStrength(Register &base, uint32 pin, uint8 strength)
Configures the port pin drive strength.
Definition Port.h:355
static void setPinMux(Register &base, uint32 pin, Mux mux)
Configures the pin muxing.
Definition Port.h:341
static void enablePinDoubleDriveStrength(Register &base, uint32 pin, bool enable)
Enables the port pin double drive strength.
Definition Port.h:367
static void setMultiplePinsConfig(Register &base, uint32 mask, const Config &config)
Sets the port PCR register for multiple pins.
Definition Port.h:309
PORT Pin Configuration Structure.
Definition Config.h:66
Mux mux
Pin Multiplexer Configuration.
Definition Config.h:214
DriveStrength driveStrength
Drive Strength Control.
Definition Config.h:176
- 註
- 此類別繼承自 NonInstantiable,無法建立實例
-
使用前需確保相應的 PORT 時鐘已在 MRCC 中啟用
-
引腳功能改變可能需要相應周邊模組的重新初始化
-
鎖定的引腳配置只能透過系統重設來解鎖
-
電壓範圍設定影響整個埠的電氣特性,需謹慎配置
-
校準暫存器通常由系統自動設定,手動修改需要了解硬體特性
-
批次操作時需要注意引腳遮罩的正確性,避免影響未預期的引腳
- 作者
- ZxyKira
- 日期
- 2020
- 版本
- 1.0
- 參閱
- Register PORT 暫存器結構定義
-
Config 引腳配置結構
-
Mux 引腳多工選擇枚舉
-
Pull 上下拉電阻配置枚舉
-
DriveStrength 驅動強度枚舉
-
VoltageRange 電壓範圍枚舉
-
PORT0, PORT1, PORT2, PORT3 外部全域暫存器實例