31#include "../../../SensorBuildOpt.h"
32#if !SENSORLIB_EXCLUDE_PMIC_AXP517
42 v |= (uint8_t)(((uint8_t)cfg.
spec & 0x03) << 1);
53uint16_t AXP517Pd::buildHeader(uint8_t msgType, uint8_t objCnt)
59 h |= (uint16_t)(msgType & 0x1F);
60 h |= (uint16_t)(((uint8_t)_cfg.
dr & 0x1) << 5);
61 h |= (uint16_t)(((uint8_t)_cfg.
spec & 0x03) << 6);
62 h |= (uint16_t)(((uint8_t)_cfg.
pr & 0x1) << 8);
63 h |= (uint16_t)((_msgId & 0x7) << 9);
64 h |= (uint16_t)((objCnt & 0x7) << 12);
70 uint16_t hdr = buildHeader((uint8_t)msgType, 0);
74 if (ok) _msgId = (uint8_t)((_msgId + 1) & 0x7);
95 uint8_t objCnt = (uint8_t)(payloadLen / 4);
96 uint16_t hdr = buildHeader(msgType, objCnt);
99 hdr, payload, payloadLen);
100 if (ok) _msgId = (uint8_t)((_msgId + 1) & 0x7);
116 if (!(alert & (1u << 9))) {
bool sendControl(ControlMsg msgType)
Send a USB-PD control message.
@ Source
Source/DFP supplies VBUS.
bool sendRaw(uint8_t msgType, const uint8_t *payload, uint8_t payloadLen)
Send a raw USB-PD data message.
bool tryReceive(AXP517Tcpc::RxFifoMsg &out)
Try to read one pending RX FIFO message.
bool handleFaultOnce(uint8_t &faultStatus)
Read and clear one TCPC fault status sample.
bool setReceiveDetectSop(bool enable)
Enable or disable SOP receive detection.
bool configureHeaderInfo(const HeaderInfoCfg &cfg)
Configure local message-header defaults.
@ DFP
Downstream Facing Port.
ControlMsg
Supported USB-PD control message type values.
@ GetSourceCap
Get Source Capabilities control message.
bool sendHardReset()
Send a Hard Reset ordered set.
bool sendGetSourceCap()
Send a Get_Source_Cap control message.
bool writeMessageHeaderInfo(uint8_t v)
Write the TCPCI MESSAGE_HEADER_INFO register.
bool clearAlert(uint16_t maskRw1c)
Clear PD_ALERTL/H bits using write-one-to-clear semantics.
bool txSend(TransmitType type, RetryCount retry, uint16_t headerLE, const uint8_t *payload, uint8_t payloadLen)
Send a USB-PD packet through the TCPC TX FIFO.
bool clearFaultStatus(uint8_t maskRw1c)
Clear TCPC FAULT_STATUS bits using write-one-to-clear semantics.
bool readFaultStatus(uint8_t &out)
Read the TCPC FAULT_STATUS register.
bool writeReceiveDetect(uint8_t v)
Write the TCPCI RECEIVE_DETECT register.
bool readAlert(uint16_t &out)
Read PD_ALERTL/H.
bool rxReadMessage(RxFifoMsg &out)
Read and decode one TCPC RX FIFO message.
@ HARD_RESET
Hard Reset ordered set.