File tree 2 files changed +19
-2
lines changed
targets/TARGET_Cypress/TARGET_PSOC6
2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -39,9 +39,9 @@ void apply_config(gpio_t *obj)
39
39
}
40
40
41
41
if (obj -> drive_mode == PullUp ) {
42
- gpio_write (obj , 1 );
42
+ gpio_set_pull (obj , 1 );
43
43
} else if (obj -> drive_mode == PullDown ) {
44
- gpio_write (obj , 0 );
44
+ gpio_set_pull (obj , 0 );
45
45
}
46
46
}
47
47
@@ -80,6 +80,7 @@ void gpio_dir(gpio_t *obj, PinDirection direction)
80
80
} else if (direction == PIN_OUTPUT ) {
81
81
// mbed reads from input buffer instead of DR even for output pins so always leave input buffer enabled
82
82
obj -> direction = CYHAL_GPIO_DIR_BIDIRECTIONAL ;
83
+ gpio_write (obj , obj -> output_val );
83
84
if (obj -> drive_mode == CYHAL_GPIO_DRIVE_NONE || obj -> drive_mode == CYHAL_GPIO_DRIVE_ANALOG ) {
84
85
obj -> drive_mode = CYHAL_GPIO_DRIVE_STRONG ;
85
86
}
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ typedef struct {
35
35
cyhal_gpio_t pin ;
36
36
cyhal_gpio_direction_t direction ;
37
37
cyhal_gpio_drive_mode_t drive_mode ;
38
+ int output_val ;
38
39
} gpio_t ;
39
40
40
41
struct gpio_irq_s {
@@ -57,6 +58,21 @@ struct port_s {
57
58
* @param value The value to be set
58
59
*/
59
60
static inline void gpio_write (gpio_t * obj , int value )
61
+ {
62
+ if (obj -> direction != CYHAL_GPIO_DIR_INPUT ) {
63
+ MBED_ASSERT (obj -> pin != CYHAL_NC_PIN_VALUE );
64
+ cyhal_gpio_write (obj -> pin , value != 0 );
65
+ } else {
66
+ obj -> output_val = value ;
67
+ }
68
+ }
69
+
70
+ /** Set the pull value
71
+ *
72
+ * @param obj The GPIO object
73
+ * @param value The pull value to be set
74
+ */
75
+ static inline void gpio_set_pull (gpio_t * obj , int value )
60
76
{
61
77
MBED_ASSERT (obj -> pin != CYHAL_NC_PIN_VALUE );
62
78
cyhal_gpio_write (obj -> pin , value != 0 );
You can’t perform that action at this time.
0 commit comments