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).
pull/1501/head
Mikko Polojarvi 2015-12-04 17:58:11 +02:00 committed by Steven Cooreman
parent 3fc661944a
commit 86376495a6
1 changed files with 3 additions and 12 deletions

View File

@ -39,11 +39,6 @@
#define PORT_NUM_PINS 16
uint8_t port_get_index(port_t *obj)
{
return 0;
}
PinName port_pin(PortName port, int pin_n)
{
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)
/* Set default pin mode for pins given by mask */
switch (dir) {
case PIN_INPUT:
port_mode(obj, PullDefault);
port_mode(obj, Input);
break;
case PIN_OUTPUT:
port_mode(obj, PullNone);
port_mode(obj, PushPull);
break;
}
}
void port_write(port_t *obj, int value)
{
if (value) {
GPIO_PortOutSet(obj->port, obj->mask);
} else {
GPIO_PortOutClear(obj->port, obj->mask);
}
GPIO_PortOutSetVal(obj->port, value, obj->mask);
}
int port_read(port_t *obj)