@@ -29,6 +29,16 @@ extern "C" {
29
29
30
30
/**
31
31
* \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
+ *
32
42
* @{
33
43
*/
34
44
@@ -38,43 +48,45 @@ extern "C" {
38
48
* @return The GPIO port mask for this pin
39
49
**/
40
50
uint32_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 non-zero if object was initialized with a valid PinName
44
56
**/
45
57
int gpio_is_connected (const gpio_t * obj );
46
58
47
59
/** Initialize the GPIO pin
48
60
*
49
61
* @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)
51
63
*/
52
64
void gpio_init (gpio_t * obj , PinName pin );
53
65
54
66
/** Set the input pin mode
55
67
*
56
- * @param obj The GPIO object
68
+ * @param obj The GPIO object (must be connected)
57
69
* @param mode The pin mode to be set
58
70
*/
59
71
void gpio_mode (gpio_t * obj , PinMode mode );
60
72
61
73
/** Set the pin direction
62
74
*
63
- * @param obj The GPIO object
75
+ * @param obj The GPIO object (must be connected)
64
76
* @param direction The pin direction to be set
65
77
*/
66
78
void gpio_dir (gpio_t * obj , PinDirection direction );
67
79
68
80
/** Set the output value
69
81
*
70
- * @param obj The GPIO object
82
+ * @param obj The GPIO object (must be connected)
71
83
* @param value The value to be set
72
84
*/
73
85
void gpio_write (gpio_t * obj , int value );
74
86
75
87
/** Read the input value
76
88
*
77
- * @param obj The GPIO object
89
+ * @param obj The GPIO object (must be connected)
78
90
* @return An integer value 1 or 0
79
91
*/
80
92
int gpio_read (gpio_t * obj );
@@ -85,38 +97,38 @@ int gpio_read(gpio_t *obj);
85
97
/** Init the input pin and set mode to PullDefault
86
98
*
87
99
* @param gpio The GPIO object
88
- * @param pin The pin name
100
+ * @param pin The pin name (may be NC)
89
101
*/
90
102
void gpio_init_in (gpio_t * gpio , PinName pin );
91
103
92
104
/** Init the input pin and set the mode
93
105
*
94
106
* @param gpio The GPIO object
95
- * @param pin The pin name
107
+ * @param pin The pin name (may be NC)
96
108
* @param mode The pin mode to be set
97
109
*/
98
110
void gpio_init_in_ex (gpio_t * gpio , PinName pin , PinMode mode );
99
111
100
112
/** Init the output pin as an output, with predefined output value 0
101
113
*
102
114
* @param gpio The GPIO object
103
- * @param pin The pin name
115
+ * @param pin The pin name (may be NC)
104
116
* @return An integer value 1 or 0
105
117
*/
106
118
void gpio_init_out (gpio_t * gpio , PinName pin );
107
119
108
120
/** Init the pin as an output and set the output value
109
121
*
110
122
* @param gpio The GPIO object
111
- * @param pin The pin name
123
+ * @param pin The pin name (may be NC)
112
124
* @param value The value to be set
113
125
*/
114
126
void gpio_init_out_ex (gpio_t * gpio , PinName pin , int value );
115
127
116
128
/** Init the pin to be in/out
117
129
*
118
130
* @param gpio The GPIO object
119
- * @param pin The pin name
131
+ * @param pin The pin name (may be NC)
120
132
* @param direction The pin direction to be set
121
133
* @param mode The pin mode to be set
122
134
* @param value The value to be set for an output pin
0 commit comments