usb_cables: add load check function

this needed to add information about the pin type.
also pins are now considered as connected if any direction or
level works.
thus there are no errors anymore when testing cables.
power with ground pins are not tested anymore because optional
loads are causing false positives (regarding if pins are
connected).
This commit is contained in:
King Kévin 2019-12-09 13:52:17 +01:00
parent 76d8a23281
commit f93644d127
2 changed files with 239 additions and 159 deletions

File diff suppressed because it is too large Load Diff

View File

@ -18,12 +18,22 @@
* @date 2019
*/
enum usb_pin_type_t {
USB_PIN_TYPE_UNKNOWN,
USB_PIN_TYPE_GROUND,
USB_PIN_TYPE_POWER,
USB_PIN_TYPE_SHIELD,
USB_PIN_TYPE_DIFFERENTIAL,
USB_PIN_TYPE_IDENTIFICATION,
USB_PIN_TYPE_OTHER,
};
/* USB pin definition */
struct usb_pin_t {
const char* name; /*< pin name */
uint32_t port; /*< on which MCU port is this pin connected */
uint16_t pin; /*< on which MCU pin is this pin connected */
bool gnd; /*< if this is a ground pin */
enum usb_pin_type_t type; /*< pin type */
};
/** USB connector definition */
@ -79,13 +89,17 @@ void usb_cables_check_inter(const struct usb_connector_t** connectors, uint8_t c
* @note it assumes all grounds are connected (e.g. only one cable is connected)
*/
void usb_cables_check_ground(const struct usb_connector_t** connectors, uint8_t connectors_nb, bool* connected);
/** check if there is a load on the connector
* @param[in] connector connector to check
* @return if there is a load on the connector
*/
bool usb_cables_check_load(const struct usb_connector_t* connector);
/** check USB cable connections
* @param[in] usb_cable USB cable to check
* @param[out] defined number of pin pairs that are connected according to definition
* @param[out] undefined number of pin pairs that are connected but not according to definition
* @param[out] disconnected number of pin pairs that are not connected but should according to definition
* @param[out] error number of pin pairs that are have an issue (can't be put high and low, or are unidirectional)
* @return if the connections of the cable correspond to the definition
* @note each pair is checked in both directions
*/
bool usb_cables_check_cable(const struct usb_cable_t* usb_cable, uint8_t* defined, uint8_t* undefined, uint8_t* disconnected, uint8_t* error);
bool usb_cables_check_cable(const struct usb_cable_t* usb_cable, uint8_t* defined, uint8_t* undefined, uint8_t* disconnected);