hal: astyle update

pull/7008/head
Martin Kojtal 2018-06-20 11:24:18 +01:00
parent d10e821272
commit 483427a285
20 changed files with 144 additions and 123 deletions

View File

@ -34,27 +34,33 @@ static inline void _gpio_init_out(gpio_t* gpio, PinName pin, PinMode mode, int v
} }
} }
void gpio_init_in(gpio_t* gpio, PinName pin) { void gpio_init_in(gpio_t *gpio, PinName pin)
{
gpio_init_in_ex(gpio, pin, PullDefault); gpio_init_in_ex(gpio, pin, PullDefault);
} }
void gpio_init_in_ex(gpio_t* gpio, PinName pin, PinMode mode) { void gpio_init_in_ex(gpio_t *gpio, PinName pin, PinMode mode)
{
_gpio_init_in(gpio, pin, mode); _gpio_init_in(gpio, pin, mode);
} }
void gpio_init_out(gpio_t* gpio, PinName pin) { void gpio_init_out(gpio_t *gpio, PinName pin)
{
gpio_init_out_ex(gpio, pin, 0); gpio_init_out_ex(gpio, pin, 0);
} }
void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value) { void gpio_init_out_ex(gpio_t *gpio, PinName pin, int value)
{
_gpio_init_out(gpio, pin, PullNone, value); _gpio_init_out(gpio, pin, PullNone, value);
} }
void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value) { void gpio_init_inout(gpio_t *gpio, PinName pin, PinDirection direction, PinMode mode, int value)
{
if (direction == PIN_INPUT) { if (direction == PIN_INPUT) {
_gpio_init_in(gpio, pin, mode); _gpio_init_in(gpio, pin, mode);
if (pin != NC) if (pin != NC) {
gpio_write(gpio, value); // we prepare the value in case it is switched later gpio_write(gpio, value); // we prepare the value in case it is switched later
}
} else { } else {
_gpio_init_out(gpio, pin, mode, value); _gpio_init_out(gpio, pin, mode, value);
} }

View File

@ -70,8 +70,7 @@ uint32_t mbed_itm_send(uint32_t port, uint32_t data)
{ {
/* Check if ITM and port is enabled */ /* Check if ITM and port is enabled */
if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */
((ITM->TER & (1UL << port) ) != 0UL) ) /* ITM Port enabled */ ((ITM->TER & (1UL << port)) != 0UL)) { /* ITM Port enabled */
{
/* write data to port */ /* write data to port */
ITM->PORT[port].u32 = data; ITM->PORT[port].u32 = data;

View File

@ -16,9 +16,11 @@
#include "hal/pinmap.h" #include "hal/pinmap.h"
#include "platform/mbed_error.h" #include "platform/mbed_error.h"
void pinmap_pinout(PinName pin, const PinMap *map) { void pinmap_pinout(PinName pin, const PinMap *map)
if (pin == NC) {
if (pin == NC) {
return; return;
}
while (map->pin != NC) { while (map->pin != NC) {
if (map->pin == pin) { if (map->pin == pin) {
@ -32,58 +34,72 @@ void pinmap_pinout(PinName pin, const PinMap *map) {
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "could not pinout", pin); MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "could not pinout", pin);
} }
uint32_t pinmap_merge(uint32_t a, uint32_t b) { uint32_t pinmap_merge(uint32_t a, uint32_t b)
{
// both are the same (inc both NC) // both are the same (inc both NC)
if (a == b) if (a == b) {
return a; return a;
}
// one (or both) is not connected // one (or both) is not connected
if (a == (uint32_t)NC) if (a == (uint32_t)NC) {
return b; return b;
if (b == (uint32_t)NC) }
if (b == (uint32_t)NC) {
return a; return a;
}
// mis-match error case // mis-match error case
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap mis-match", a); MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap mis-match", a);
return (uint32_t)NC; return (uint32_t)NC;
} }
uint32_t pinmap_find_peripheral(PinName pin, const PinMap* map) { uint32_t pinmap_find_peripheral(PinName pin, const PinMap *map)
{
while (map->pin != NC) { while (map->pin != NC) {
if (map->pin == pin) if (map->pin == pin) {
return map->peripheral; return map->peripheral;
}
map++; map++;
} }
return (uint32_t)NC; return (uint32_t)NC;
} }
uint32_t pinmap_peripheral(PinName pin, const PinMap* map) { uint32_t pinmap_peripheral(PinName pin, const PinMap *map)
{
uint32_t peripheral = (uint32_t)NC; uint32_t peripheral = (uint32_t)NC;
if (pin == (PinName)NC) if (pin == (PinName)NC) {
return (uint32_t)NC; return (uint32_t)NC;
}
peripheral = pinmap_find_peripheral(pin, map); peripheral = pinmap_find_peripheral(pin, map);
if ((uint32_t)NC == peripheral) // no mapping available if ((uint32_t)NC == peripheral) { // no mapping available
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap not found for peripheral", peripheral); MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap not found for peripheral", peripheral);
}
return peripheral; return peripheral;
} }
uint32_t pinmap_find_function(PinName pin, const PinMap* map) { uint32_t pinmap_find_function(PinName pin, const PinMap *map)
{
while (map->pin != NC) { while (map->pin != NC) {
if (map->pin == pin) if (map->pin == pin) {
return map->function; return map->function;
}
map++; map++;
} }
return (uint32_t)NC; return (uint32_t)NC;
} }
uint32_t pinmap_function(PinName pin, const PinMap* map) { uint32_t pinmap_function(PinName pin, const PinMap *map)
{
uint32_t function = (uint32_t)NC; uint32_t function = (uint32_t)NC;
if (pin == (PinName)NC) if (pin == (PinName)NC) {
return (uint32_t)NC; return (uint32_t)NC;
}
function = pinmap_find_function(pin, map); function = pinmap_find_function(pin, map);
if ((uint32_t)NC == function) // no mapping available if ((uint32_t)NC == function) { // no mapping available
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap not found for function", function); MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap not found for function", function);
}
return function; return function;
} }