File tree Expand file tree Collapse file tree 2 files changed +18
-7
lines changed
targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,13 @@ extern "C" {
28
28
**/
29
29
uint32_t gpio_set (PinName pin );
30
30
31
+ /* Checks if gpio object is connected (pin was not initialized with NC)
32
+ * @param pin The pin to be set as GPIO
33
+ * @return Non zero value if port is connected to pin
34
+ * 0 if port is initialized with NC
35
+ **/
36
+ int gpio_is_connected (const gpio_t * obj );
37
+
31
38
/* GPIO object */
32
39
void gpio_init (gpio_t * obj , PinName pin );
33
40
Original file line number Diff line number Diff line change @@ -25,27 +25,31 @@ extern "C" {
25
25
#endif
26
26
27
27
typedef struct {
28
- PinName pinName ;
28
+ PinName pin ;
29
29
} gpio_t ;
30
30
31
31
static inline void gpio_write (gpio_t * obj , int value ) {
32
- MBED_ASSERT (obj -> pinName != (PinName )NC );
33
- uint32_t port = obj -> pinName >> GPIO_PORT_SHIFT ;
34
- uint32_t pin = obj -> pinName & 0xFF ;
32
+ MBED_ASSERT (obj -> pin != (PinName )NC );
33
+ uint32_t port = obj -> pin >> GPIO_PORT_SHIFT ;
34
+ uint32_t pin = obj -> pin & 0xFF ;
35
35
uint32_t gpio_addrs [] = GPIO_BASE_ADDRS ;
36
36
37
37
GPIO_HAL_WritePinOutput (gpio_addrs [port ], pin , value );
38
38
}
39
39
40
40
static inline int gpio_read (gpio_t * obj ) {
41
- MBED_ASSERT (obj -> pinName != (PinName )NC );
42
- uint32_t port = obj -> pinName >> GPIO_PORT_SHIFT ;
43
- uint32_t pin = obj -> pinName & 0xFF ;
41
+ MBED_ASSERT (obj -> pin != (PinName )NC );
42
+ uint32_t port = obj -> pin >> GPIO_PORT_SHIFT ;
43
+ uint32_t pin = obj -> pin & 0xFF ;
44
44
uint32_t gpio_addrs [] = GPIO_BASE_ADDRS ;
45
45
46
46
return (int )GPIO_HAL_ReadPinInput (gpio_addrs [port ], pin );
47
47
}
48
48
49
+ static inline int gpio_is_connected (const gpio_t * obj ) {
50
+ return obj -> pin != (PinName )NC ;
51
+ }
52
+
49
53
#ifdef __cplusplus
50
54
}
51
55
#endif
You can’t perform that action at this time.
0 commit comments