@@ -29,6 +29,16 @@ extern "C" {
2929
3030/**
3131 * \defgroup hal_gpio GPIO HAL functions
32+ *
33+ * # Defined behavior
34+ * * ::gpio_init and other init functions can be called with NC or a valid PinName for the target.
35+ * * ::gpio_is_connected can be used to test whether a gpio_t object was initialized with NC.
36+ *
37+ * # Undefined behavior
38+ * * Calling any ::gpio_mode, ::gpio_dir, ::gpio_write or ::gpio_read on a gpio_t object that was initialized
39+ * with NC.
40+ * * Calling ::gpio_set with NC.
41+ *
3242 * @{
3343 */
3444
@@ -38,43 +48,45 @@ extern "C" {
3848 * @return The GPIO port mask for this pin
3949 **/
4050uint32_t gpio_set (PinName pin );
41- /* Checks if gpio object is connected (pin was not initialized with NC)
42- * @param pin The pin to be set as GPIO
43- * @return 0 if port is initialized with NC
51+
52+ /** Checks if gpio object is connected (pin was not initialized with NC)
53+ * @param obj The GPIO object
54+ * @return 0 if object was initialized with NC
55+ * @return 1 if object was initialized with a valid PinName
4456 **/
4557int gpio_is_connected (const gpio_t * obj );
4658
4759/** Initialize the GPIO pin
4860 *
4961 * @param obj The GPIO object to initialize
50- * @param pin The GPIO pin to initialize
62+ * @param pin The GPIO pin to initialize (may be NC)
5163 */
5264void gpio_init (gpio_t * obj , PinName pin );
5365
5466/** Set the input pin mode
5567 *
56- * @param obj The GPIO object
68+ * @param obj The GPIO object (must be connected)
5769 * @param mode The pin mode to be set
5870 */
5971void gpio_mode (gpio_t * obj , PinMode mode );
6072
6173/** Set the pin direction
6274 *
63- * @param obj The GPIO object
75+ * @param obj The GPIO object (must be connected)
6476 * @param direction The pin direction to be set
6577 */
6678void gpio_dir (gpio_t * obj , PinDirection direction );
6779
6880/** Set the output value
6981 *
70- * @param obj The GPIO object
82+ * @param obj The GPIO object (must be connected)
7183 * @param value The value to be set
7284 */
7385void gpio_write (gpio_t * obj , int value );
7486
7587/** Read the input value
7688 *
77- * @param obj The GPIO object
89+ * @param obj The GPIO object (must be connected)
7890 * @return An integer value 1 or 0
7991 */
8092int gpio_read (gpio_t * obj );
@@ -85,38 +97,38 @@ int gpio_read(gpio_t *obj);
8597/** Init the input pin and set mode to PullDefault
8698 *
8799 * @param gpio The GPIO object
88- * @param pin The pin name
100+ * @param pin The pin name (may be NC)
89101 */
90102void gpio_init_in (gpio_t * gpio , PinName pin );
91103
92104/** Init the input pin and set the mode
93105 *
94106 * @param gpio The GPIO object
95- * @param pin The pin name
107+ * @param pin The pin name (may be NC)
96108 * @param mode The pin mode to be set
97109 */
98110void gpio_init_in_ex (gpio_t * gpio , PinName pin , PinMode mode );
99111
100112/** Init the output pin as an output, with predefined output value 0
101113 *
102114 * @param gpio The GPIO object
103- * @param pin The pin name
115+ * @param pin The pin name (may be NC)
104116 * @return An integer value 1 or 0
105117 */
106118void gpio_init_out (gpio_t * gpio , PinName pin );
107119
108120/** Init the pin as an output and set the output value
109121 *
110122 * @param gpio The GPIO object
111- * @param pin The pin name
123+ * @param pin The pin name (may be NC)
112124 * @param value The value to be set
113125 */
114126void gpio_init_out_ex (gpio_t * gpio , PinName pin , int value );
115127
116128/** Init the pin to be in/out
117129 *
118130 * @param gpio The GPIO object
119- * @param pin The pin name
131+ * @param pin The pin name (may be NC)
120132 * @param direction The pin direction to be set
121133 * @param mode The pin mode to be set
122134 * @param value The value to be set for an output pin
0 commit comments