cc2538: lpm: Add registration mechanism for peripherals

Some peripherals have their clocks automatically gated in PM1+ modes, so they
cannot operate. This new mechanism gives peripherals a way to prohibit PM1+
modes so that they can properly complete their current operations before
entering PM1+.

This mechanism is implemented with peripheral functions registered to the LPM
module. These functions return whether the associated peripheral permits or not
PM1+ modes. They are called by the LPM module each time PM1+ might be possible.
If any of the peripherals wants to block PM1+, then the system is only dropped
to PM0.

Partly from: George Oikonomou
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
cc2538: usb: Use the new LPM peripheral registration

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
cc2538: uart: Fix crippled output occurring upon lpm_enter()

lpm_enter() must not enter PM1+ if the UART TX FIFO is not empty. Otherwise, the
UART clock gets disabled, and its TX is broken.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
Fix rpl-udp build failure on native target, reported on contiki mailing list

http://sourceforge.net/mailarchive/forum.php?thread_name=a2b9cb98ac4a191867afc953113fabaa%40amnesiak.org&forum_name=contiki-developers
cc2538: gpio: Fix usage of parameters in macros

The parameters in the GPIO macros were used without being parenthesized. This
could generate wrong values for register assignments in the case of expressions
passed as arguments to these macros.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
cc2538: gpio: Add pin read / write and interrupt clear macros

Introduce new useful GPIO macros to:
 - read the levels of some port pins,
 - write the levels of some port pins (pass bit-field value to be set),
 - clear the interrupt flags for some port pins.

These macros are cleaner and less error prone than raw register access code
copied all over the place.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
cc2538: gpio: Use accessor macros

Use the GPIO accessor macros instead of copying raw register access code all
over the place. This is cleaner and less error prone.

This fixes the setting of the USB pull-up resistor that worked only by chance on
the CC2538DK because it is controlled by the pin 0 of the used GPIO port.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
Merge pull request #408 from ADVANSEE/cc2538-uart

cc2538: lpm: Add registration mechanism for peripherals and use it
Merge pull request #425 from ADVANSEE/cc2538-gpio

cc2538: gpio: Bug fix and various improvements
Merge pull request #322 from ismb-pert/fix-rpd-udp

Fix build failure on rpl-udp reported on contiki mailing list