Skip to content

Commit 8637649

Browse files
mpolojarstevew817
authored andcommitted
SiLabs: port_api: Allow individual values on output pins and fix init
Previously, all pins in an mbed Port were set to the same value. Use GPIO_PortOutSetVal to directly write the desired value to the pins. During port initialization the pin mode for input pins was set incorrectly. Now, input pins are directly set to Input (gpioModeInput) and output pins to PushPull (gpioModePushPull).
1 parent 3fc6619 commit 8637649

File tree

1 file changed

+3
-12
lines changed
  • libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32

1 file changed

+3
-12
lines changed

libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/port_api.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@
3939

4040
#define PORT_NUM_PINS 16
4141

42-
uint8_t port_get_index(port_t *obj)
43-
{
44-
return 0;
45-
}
46-
4742
PinName port_pin(PortName port, int pin_n)
4843
{
4944
return (PinName) (pin_n | port << 4); // Encode pin and port number in one uint32
@@ -80,21 +75,17 @@ void port_dir(port_t *obj, PinDirection dir)
8075
/* Set default pin mode for pins given by mask */
8176
switch (dir) {
8277
case PIN_INPUT:
83-
port_mode(obj, PullDefault);
78+
port_mode(obj, Input);
8479
break;
8580
case PIN_OUTPUT:
86-
port_mode(obj, PullNone);
81+
port_mode(obj, PushPull);
8782
break;
8883
}
8984
}
9085

9186
void port_write(port_t *obj, int value)
9287
{
93-
if (value) {
94-
GPIO_PortOutSet(obj->port, obj->mask);
95-
} else {
96-
GPIO_PortOutClear(obj->port, obj->mask);
97-
}
88+
GPIO_PortOutSetVal(obj->port, value, obj->mask);
9889
}
9990

10091
int port_read(port_t *obj)

0 commit comments

Comments
 (0)