Explicit pinmap - fix style

pull/11892/head
Przemyslaw Stekiel 2019-09-18 14:47:53 +02:00
parent 17c1b9a860
commit d75cc97d80
18 changed files with 230 additions and 223 deletions

View File

@ -132,8 +132,8 @@ static void uart_test_common(int baudrate, int data_bits, SerialParity parity, i
const serial_fc_pinmap_t pinmap = get_uart_fc_pinmap(rts, cts);
serial_set_flow_control_direct(&serial, FlowControlRTSCTS, &pinmap);
#else
//skip this test case if explicit pinmap is not supported
return;
//skip this test case if explicit pinmap is not supported
return;
#endif
} else {
serial_set_flow_control(&serial, FlowControlRTSCTS, rts, cts);

View File

@ -440,7 +440,7 @@ protected:
/* SPI peripheral name */
SPIName _peripheral_name;
/* Pointer to spi init function */
void (*_init_func)(SPI*);
void (*_init_func)(SPI *);
private:
void _do_construct();

View File

@ -67,7 +67,7 @@ typedef struct analogin_s analogin_t;
* @param obj The analogin object to initialize
* @param pinmap pointer to structure which holds static pinmap
*/
void analogin_init_direct(analogin_t* obj, const PinMap *pinmap);
void analogin_init_direct(analogin_t *obj, const PinMap *pinmap);
/** Initialize the analogin peripheral
*

View File

@ -69,7 +69,7 @@ typedef struct dac_s dac_t;
* @param obj The analogout object to initialize
* @param pinmap pointer to structure which holds static pinmap
*/
void analogout_init_direct(dac_t* obj, const PinMap *pinmap);
void analogout_init_direct(dac_t *obj, const PinMap *pinmap);
/** Initialize the analogout peripheral
*

View File

@ -186,8 +186,8 @@ MSTD_CONSTEXPR_FN_14 spi_pinmap_t get_spi_pinmap(const PinName mosi, const PinNa
}
if ((!mosi_map || !miso_map || !sclk_map || !ssel_map) ||
(mosi_map->peripheral != miso_map->peripheral || mosi_map->peripheral != sclk_map->peripheral) ||
(ssel_map->pin != NC && mosi_map->peripheral != ssel_map->peripheral)) {
(mosi_map->peripheral != miso_map->peripheral || mosi_map->peripheral != sclk_map->peripheral) ||
(ssel_map->pin != NC && mosi_map->peripheral != ssel_map->peripheral)) {
return {NC, NC, NC, NC, NC, NC, NC, NC, NC};
}

View File

@ -73,7 +73,7 @@ typedef struct pwmout_s pwmout_t;
* @param obj The pwmout object to initialize
* @param pinmap pointer to structure which holds static pinmap
*/
void pwmout_init_direct(pwmout_t* obj, const PinMap *pinmap);
void pwmout_init_direct(pwmout_t *obj, const PinMap *pinmap);
/** Initialize the pwm out peripheral and configure the pin
*

View File

@ -61,8 +61,7 @@
#define alignas(N) __attribute__((aligned(N)))
#endif
namespace std
{
namespace std {
// [cstddef.syn]
using nullptr_t = decltype(nullptr);
@ -70,8 +69,7 @@ using nullptr_t = decltype(nullptr);
#endif // __CC_ARM
namespace mstd
{
namespace mstd {
using std::size_t;
using std::ptrdiff_t;
using std::nullptr_t;

View File

@ -332,8 +332,8 @@ static FileHandle *default_console()
#if MBED_CONF_TARGET_CONSOLE_UART && DEVICE_SERIAL
# if MBED_CONF_PLATFORM_STDIO_BUFFERED_SERIAL
static const serial_pinmap_t console_pinmap = get_uart_pinmap(STDIO_UART_TX, STDIO_UART_RX);
static UARTSerial console(console_pinmap, MBED_CONF_PLATFORM_STDIO_BAUD_RATE);
static const serial_pinmap_t console_pinmap = get_uart_pinmap(STDIO_UART_TX, STDIO_UART_RX);
static UARTSerial console(console_pinmap, MBED_CONF_PLATFORM_STDIO_BAUD_RATE);
# if CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTS
static const serial_fc_pinmap_t fc_pinmap = get_uart_fc_pinmap(STDIO_UART_RTS, NC);
console.serial_set_flow_control(SerialBase::RTS, fc_pinmap);

View File

@ -128,7 +128,7 @@ MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_GPIO[] = {
{PTE27, GPIO_X, 1},
{PTE28, GPIO_X, 1},
{NC , NC , 0}
{NC, NC, 0}
};
/************RTC***************/
@ -139,16 +139,16 @@ MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_RTC[] = {
/************ADC***************/
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_ADC[] = {
{PTA17, ADC1_SE17, 0},
{PTB0 , ADC0_SE8 , 0},
{PTB1 , ADC0_SE9 , 0},
{PTB2 , ADC0_SE12, 0},
{PTB3 , ADC0_SE13, 0},
{PTB6 , ADC1_SE12, 0},
{PTB7 , ADC1_SE13, 0},
{PTB0, ADC0_SE8, 0},
{PTB1, ADC0_SE9, 0},
{PTB2, ADC0_SE12, 0},
{PTB3, ADC0_SE13, 0},
{PTB6, ADC1_SE12, 0},
{PTB7, ADC1_SE13, 0},
{PTB10, ADC1_SE14, 0},
{PTB11, ADC1_SE15, 0},
{PTC0 , ADC0_SE14, 0},
{PTC1 , ADC0_SE15, 0},
{PTC0, ADC0_SE14, 0},
{PTC1, ADC0_SE15, 0},
{PTC2, ADC0_SE4b, 0},
{PTC8, ADC1_SE4b, 0},
{PTC9, ADC1_SE5b, 0},
@ -163,197 +163,197 @@ MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_ADC[] = {
{PTE3, ADC1_SE7a, 0},
//{PTE24, ADC0_SE17, 0}, //I2C pull up
//{PTE25, ADC0_SE18, 0}, //I2C pull up
{NC , NC , 0}
{NC, NC, 0}
};
/************DAC***************/
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_DAC[] = {
{DAC0_OUT, DAC_0, 0},
{NC , NC , 0}
{NC, NC, 0}
};
/************I2C***************/
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_I2C_SDA[] = {
{PTE25, I2C_0, 5},
{PTB1 , I2C_0, 2},
{PTB3 , I2C_0, 2},
{PTB1, I2C_0, 2},
{PTB3, I2C_0, 2},
{PTC11, I2C_1, 2},
{PTA13, I2C_2, 5},
{PTD3 , I2C_0, 7},
{PTE0 , I2C_1, 6},
{NC , NC , 0}
{PTD3, I2C_0, 7},
{PTE0, I2C_1, 6},
{NC, NC, 0}
};
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_I2C_SCL[] = {
{PTE24, I2C_0, 5},
{PTB0 , I2C_0, 2},
{PTB2 , I2C_0, 2},
{PTB0, I2C_0, 2},
{PTB2, I2C_0, 2},
{PTC10, I2C_1, 2},
{PTA12, I2C_2, 5},
{PTA14, I2C_2, 5},
{PTD2 , I2C_0, 7},
{PTE1 , I2C_1, 6},
{NC , NC , 0}
{PTD2, I2C_0, 7},
{PTE1, I2C_1, 6},
{NC, NC, 0}
};
/************UART***************/
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_UART_TX[] = {
{PTB17, UART_0, 3},
{PTC17, UART_3, 3},
{PTD7 , UART_0, 3},
{PTD3 , UART_2, 3},
{PTC4 , UART_1, 3},
{PTD7, UART_0, 3},
{PTD3, UART_2, 3},
{PTC4, UART_1, 3},
{PTC15, UART_4, 3},
{PTB11, UART_3, 3},
{PTA14, UART_0, 3},
{PTE24, UART_4, 3},
{PTE4 , UART_3, 3},
{PTE4, UART_3, 3},
{PTE0, UART_1, 3},
{NC , NC , 0}
{NC, NC, 0}
};
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_UART_RX[] = {
{PTB16, UART_0, 3},
{PTE1 , UART_1, 3},
{PTE5 , UART_3, 3},
{PTE1, UART_1, 3},
{PTE5, UART_3, 3},
{PTE25, UART_4, 3},
{PTA15, UART_0, 3},
{PTC16, UART_3, 3},
{PTB10, UART_3, 3},
{PTC3 , UART_1, 3},
{PTC3, UART_1, 3},
{PTC14, UART_4, 3},
{PTD2 , UART_2, 3},
{PTD6 , UART_0, 3},
{NC , NC , 0}
{PTD2, UART_2, 3},
{PTD6, UART_0, 3},
{NC, NC, 0}
};
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_UART_CTS[] = {
{PTB13, UART_3, 2},
{PTE2 , UART_1, 3},
{PTE6 , UART_3, 3},
{PTE2, UART_1, 3},
{PTE6, UART_3, 3},
{PTE26, UART_4, 3},
{PTA0 , UART_0, 2},
{PTA0, UART_0, 2},
{PTA16, UART_0, 3},
{PTB3 , UART_0, 3},
{PTB9 , UART_3, 3},
{PTC2 , UART_1, 3},
{PTB3, UART_0, 3},
{PTB9, UART_3, 3},
{PTC2, UART_1, 3},
{PTC13, UART_4, 3},
{PTC19, UART_3, 3},
{PTD1 , UART_2, 3},
{PTD5 , UART_0, 3},
{NC , NC , 0}
{PTD1, UART_2, 3},
{PTD5, UART_0, 3},
{NC, NC, 0}
};
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_UART_RTS[] = {
{PTB12, UART_3, 2},
{PTE3 , UART_1, 3},
{PTE7 , UART_3, 3},
{PTE3, UART_1, 3},
{PTE7, UART_3, 3},
{PTE27, UART_4, 3},
{PTA17, UART_0, 3},
{PTB8 , UART_3, 3},
{PTC1 , UART_1, 3},
{PTB8, UART_3, 3},
{PTC1, UART_1, 3},
{PTC12, UART_4, 3},
{PTC18, UART_3, 3},
{PTD0 , UART_2, 3},
{PTD4 , UART_0, 3},
{PTA3 , UART_0, 2},
{PTB2 , UART_0, 3},
{NC , NC , 0}
{PTD0, UART_2, 3},
{PTD4, UART_0, 3},
{PTA3, UART_0, 2},
{PTB2, UART_0, 3},
{NC, NC, 0}
};
/************SPI***************/
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_SPI_SCLK[] = {
{PTD1 , SPI_0, 2},
{PTE2 , SPI_1, 2},
{PTD1, SPI_0, 2},
{PTE2, SPI_1, 2},
{PTA15, SPI_0, 2},
{PTB11, SPI_1, 2},
{PTB21, SPI_2, 2},
{PTC5 , SPI_0, 2},
{PTD5 , SPI_1, 7},
{NC , NC , 0}
{PTC5, SPI_0, 2},
{PTD5, SPI_1, 7},
{NC, NC, 0}
};
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_SPI_MOSI[] = {
{PTD2 , SPI_0, 2},
{PTE1 , SPI_1, 2},
{PTE3 , SPI_1, 7},
{PTD2, SPI_0, 2},
{PTE1, SPI_1, 2},
{PTE3, SPI_1, 7},
{PTA16, SPI_0, 2},
{PTB16, SPI_1, 2},
{PTB22, SPI_2, 2},
{PTC6 , SPI_0, 2},
{PTD6 , SPI_1, 7},
{NC , NC , 0}
{PTC6, SPI_0, 2},
{PTD6, SPI_1, 7},
{NC, NC, 0}
};
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_SPI_MISO[] = {
{PTD3 , SPI_0, 2},
{PTE1 , SPI_1, 7},
{PTE3 , SPI_1, 2},
{PTD3, SPI_0, 2},
{PTE1, SPI_1, 7},
{PTE3, SPI_1, 2},
{PTA17, SPI_0, 2},
{PTB17, SPI_1, 2},
{PTB23, SPI_2, 2},
{PTC7 , SPI_0, 2},
{PTD7 , SPI_1, 7},
{NC , NC , 0}
{PTC7, SPI_0, 2},
{PTD7, SPI_1, 7},
{NC, NC, 0}
};
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_SPI_SSEL[] = {
{PTD0 , SPI_0, 2},
{PTE4 , SPI_1, 2},
{PTD0, SPI_0, 2},
{PTE4, SPI_1, 2},
{PTA14, SPI_0, 2},
{PTB10, SPI_1, 2},
{PTB20, SPI_2, 2},
{PTC4 , SPI_0, 2},
{PTD4 , SPI_1, 7},
{NC , NC , 0}
{PTC4, SPI_0, 2},
{PTD4, SPI_1, 7},
{NC, NC, 0}
};
/************PWM***************/
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_PWM[] = {
{PTA0 , PWM_6 , 3},
{PTA1 , PWM_7 , 3},
{PTA2 , PWM_8 , 3},
{PTA3 , PWM_1 , 3},
{PTA4 , PWM_2 , 3},
{PTA5 , PWM_3 , 3},
{PTA6 , PWM_4 , 3},
{PTA7 , PWM_5 , 3},
{PTA8 , PWM_9 , 3},
{PTA9 , PWM_10, 3},
{PTA0, PWM_6, 3},
{PTA1, PWM_7, 3},
{PTA2, PWM_8, 3},
{PTA3, PWM_1, 3},
{PTA4, PWM_2, 3},
{PTA5, PWM_3, 3},
{PTA6, PWM_4, 3},
{PTA7, PWM_5, 3},
{PTA8, PWM_9, 3},
{PTA9, PWM_10, 3},
{PTA10, PWM_17, 3},
{PTA11, PWM_18, 3},
{PTA12, PWM_9 , 3},
{PTA12, PWM_9, 3},
{PTA13, PWM_10, 3},
{PTB0 , PWM_9 , 3},
{PTB1 , PWM_10, 3},
{PTB0, PWM_9, 3},
{PTB1, PWM_10, 3},
{PTB18, PWM_17, 3},
{PTB19, PWM_18, 3},
{PTC1 , PWM_1 , 4},
{PTC2 , PWM_2 , 4},
{PTC3 , PWM_3 , 4},
{PTC4 , PWM_4 , 4},
{PTC5 , PWM_3 , 7},
{PTC8 , PWM_29, 3},
{PTC9 , PWM_30, 3},
{PTC1, PWM_1, 4},
{PTC2, PWM_2, 4},
{PTC3, PWM_3, 4},
{PTC4, PWM_4, 4},
{PTC5, PWM_3, 7},
{PTC8, PWM_29, 3},
{PTC9, PWM_30, 3},
{PTC10, PWM_31, 3},
{PTC11, PWM_32, 3},
{PTD0 , PWM_25, 4},
{PTD1 , PWM_26, 4},
{PTD2 , PWM_27, 4},
{PTD3 , PWM_28, 4},
{PTD4 , PWM_5 , 4},
{PTD5 , PWM_6 , 4},
{PTD6 , PWM_7 , 4},
{PTD4 , PWM_5 , 4},
{PTD7 , PWM_8 , 4},
{PTD0, PWM_25, 4},
{PTD1, PWM_26, 4},
{PTD2, PWM_27, 4},
{PTD3, PWM_28, 4},
{PTD4, PWM_5, 4},
{PTD5, PWM_6, 4},
{PTD6, PWM_7, 4},
{PTD4, PWM_5, 4},
{PTD7, PWM_8, 4},
{PTE5 , PWM_25, 6},
{PTE6 , PWM_26, 6},
{PTE5, PWM_25, 6},
{PTE6, PWM_26, 6},
{NC , NC , 0}
{NC, NC, 0}
};
#define PINMAP_ANALOGIN PinMap_ADC

View File

@ -33,16 +33,16 @@ typedef enum {
#define GPIO_PORT_SHIFT 12
typedef enum {
PTA0 = (0 << GPIO_PORT_SHIFT | 0 ),
PTA1 = (0 << GPIO_PORT_SHIFT | 1 ),
PTA2 = (0 << GPIO_PORT_SHIFT | 2 ),
PTA3 = (0 << GPIO_PORT_SHIFT | 3 ),
PTA4 = (0 << GPIO_PORT_SHIFT | 4 ),
PTA5 = (0 << GPIO_PORT_SHIFT | 5 ),
PTA6 = (0 << GPIO_PORT_SHIFT | 6 ),
PTA7 = (0 << GPIO_PORT_SHIFT | 7 ),
PTA8 = (0 << GPIO_PORT_SHIFT | 8 ),
PTA9 = (0 << GPIO_PORT_SHIFT | 9 ),
PTA0 = (0 << GPIO_PORT_SHIFT | 0),
PTA1 = (0 << GPIO_PORT_SHIFT | 1),
PTA2 = (0 << GPIO_PORT_SHIFT | 2),
PTA3 = (0 << GPIO_PORT_SHIFT | 3),
PTA4 = (0 << GPIO_PORT_SHIFT | 4),
PTA5 = (0 << GPIO_PORT_SHIFT | 5),
PTA6 = (0 << GPIO_PORT_SHIFT | 6),
PTA7 = (0 << GPIO_PORT_SHIFT | 7),
PTA8 = (0 << GPIO_PORT_SHIFT | 8),
PTA9 = (0 << GPIO_PORT_SHIFT | 9),
PTA10 = (0 << GPIO_PORT_SHIFT | 10),
PTA11 = (0 << GPIO_PORT_SHIFT | 11),
PTA12 = (0 << GPIO_PORT_SHIFT | 12),
@ -65,16 +65,16 @@ typedef enum {
PTA29 = (0 << GPIO_PORT_SHIFT | 29),
PTA30 = (0 << GPIO_PORT_SHIFT | 30),
PTA31 = (0 << GPIO_PORT_SHIFT | 31),
PTB0 = (1 << GPIO_PORT_SHIFT | 0 ),
PTB1 = (1 << GPIO_PORT_SHIFT | 1 ),
PTB2 = (1 << GPIO_PORT_SHIFT | 2 ),
PTB3 = (1 << GPIO_PORT_SHIFT | 3 ),
PTB4 = (1 << GPIO_PORT_SHIFT | 4 ),
PTB5 = (1 << GPIO_PORT_SHIFT | 5 ),
PTB6 = (1 << GPIO_PORT_SHIFT | 6 ),
PTB7 = (1 << GPIO_PORT_SHIFT | 7 ),
PTB8 = (1 << GPIO_PORT_SHIFT | 8 ),
PTB9 = (1 << GPIO_PORT_SHIFT | 9 ),
PTB0 = (1 << GPIO_PORT_SHIFT | 0),
PTB1 = (1 << GPIO_PORT_SHIFT | 1),
PTB2 = (1 << GPIO_PORT_SHIFT | 2),
PTB3 = (1 << GPIO_PORT_SHIFT | 3),
PTB4 = (1 << GPIO_PORT_SHIFT | 4),
PTB5 = (1 << GPIO_PORT_SHIFT | 5),
PTB6 = (1 << GPIO_PORT_SHIFT | 6),
PTB7 = (1 << GPIO_PORT_SHIFT | 7),
PTB8 = (1 << GPIO_PORT_SHIFT | 8),
PTB9 = (1 << GPIO_PORT_SHIFT | 9),
PTB10 = (1 << GPIO_PORT_SHIFT | 10),
PTB11 = (1 << GPIO_PORT_SHIFT | 11),
PTB12 = (1 << GPIO_PORT_SHIFT | 12),
@ -97,16 +97,16 @@ typedef enum {
PTB29 = (1 << GPIO_PORT_SHIFT | 29),
PTB30 = (1 << GPIO_PORT_SHIFT | 30),
PTB31 = (1 << GPIO_PORT_SHIFT | 31),
PTC0 = (2 << GPIO_PORT_SHIFT | 0 ),
PTC1 = (2 << GPIO_PORT_SHIFT | 1 ),
PTC2 = (2 << GPIO_PORT_SHIFT | 2 ),
PTC3 = (2 << GPIO_PORT_SHIFT | 3 ),
PTC4 = (2 << GPIO_PORT_SHIFT | 4 ),
PTC5 = (2 << GPIO_PORT_SHIFT | 5 ),
PTC6 = (2 << GPIO_PORT_SHIFT | 6 ),
PTC7 = (2 << GPIO_PORT_SHIFT | 7 ),
PTC8 = (2 << GPIO_PORT_SHIFT | 8 ),
PTC9 = (2 << GPIO_PORT_SHIFT | 9 ),
PTC0 = (2 << GPIO_PORT_SHIFT | 0),
PTC1 = (2 << GPIO_PORT_SHIFT | 1),
PTC2 = (2 << GPIO_PORT_SHIFT | 2),
PTC3 = (2 << GPIO_PORT_SHIFT | 3),
PTC4 = (2 << GPIO_PORT_SHIFT | 4),
PTC5 = (2 << GPIO_PORT_SHIFT | 5),
PTC6 = (2 << GPIO_PORT_SHIFT | 6),
PTC7 = (2 << GPIO_PORT_SHIFT | 7),
PTC8 = (2 << GPIO_PORT_SHIFT | 8),
PTC9 = (2 << GPIO_PORT_SHIFT | 9),
PTC10 = (2 << GPIO_PORT_SHIFT | 10),
PTC11 = (2 << GPIO_PORT_SHIFT | 11),
PTC12 = (2 << GPIO_PORT_SHIFT | 12),
@ -129,16 +129,16 @@ typedef enum {
PTC29 = (2 << GPIO_PORT_SHIFT | 29),
PTC30 = (2 << GPIO_PORT_SHIFT | 30),
PTC31 = (2 << GPIO_PORT_SHIFT | 31),
PTD0 = (3 << GPIO_PORT_SHIFT | 0 ),
PTD1 = (3 << GPIO_PORT_SHIFT | 1 ),
PTD2 = (3 << GPIO_PORT_SHIFT | 2 ),
PTD3 = (3 << GPIO_PORT_SHIFT | 3 ),
PTD4 = (3 << GPIO_PORT_SHIFT | 4 ),
PTD5 = (3 << GPIO_PORT_SHIFT | 5 ),
PTD6 = (3 << GPIO_PORT_SHIFT | 6 ),
PTD7 = (3 << GPIO_PORT_SHIFT | 7 ),
PTD8 = (3 << GPIO_PORT_SHIFT | 8 ),
PTD9 = (3 << GPIO_PORT_SHIFT | 9 ),
PTD0 = (3 << GPIO_PORT_SHIFT | 0),
PTD1 = (3 << GPIO_PORT_SHIFT | 1),
PTD2 = (3 << GPIO_PORT_SHIFT | 2),
PTD3 = (3 << GPIO_PORT_SHIFT | 3),
PTD4 = (3 << GPIO_PORT_SHIFT | 4),
PTD5 = (3 << GPIO_PORT_SHIFT | 5),
PTD6 = (3 << GPIO_PORT_SHIFT | 6),
PTD7 = (3 << GPIO_PORT_SHIFT | 7),
PTD8 = (3 << GPIO_PORT_SHIFT | 8),
PTD9 = (3 << GPIO_PORT_SHIFT | 9),
PTD10 = (3 << GPIO_PORT_SHIFT | 10),
PTD11 = (3 << GPIO_PORT_SHIFT | 11),
PTD12 = (3 << GPIO_PORT_SHIFT | 12),
@ -161,16 +161,16 @@ typedef enum {
PTD29 = (3 << GPIO_PORT_SHIFT | 29),
PTD30 = (3 << GPIO_PORT_SHIFT | 30),
PTD31 = (3 << GPIO_PORT_SHIFT | 31),
PTE0 = (4 << GPIO_PORT_SHIFT | 0 ),
PTE1 = (4 << GPIO_PORT_SHIFT | 1 ),
PTE2 = (4 << GPIO_PORT_SHIFT | 2 ),
PTE3 = (4 << GPIO_PORT_SHIFT | 3 ),
PTE4 = (4 << GPIO_PORT_SHIFT | 4 ),
PTE5 = (4 << GPIO_PORT_SHIFT | 5 ),
PTE6 = (4 << GPIO_PORT_SHIFT | 6 ),
PTE7 = (4 << GPIO_PORT_SHIFT | 7 ),
PTE8 = (4 << GPIO_PORT_SHIFT | 8 ),
PTE9 = (4 << GPIO_PORT_SHIFT | 9 ),
PTE0 = (4 << GPIO_PORT_SHIFT | 0),
PTE1 = (4 << GPIO_PORT_SHIFT | 1),
PTE2 = (4 << GPIO_PORT_SHIFT | 2),
PTE3 = (4 << GPIO_PORT_SHIFT | 3),
PTE4 = (4 << GPIO_PORT_SHIFT | 4),
PTE5 = (4 << GPIO_PORT_SHIFT | 5),
PTE6 = (4 << GPIO_PORT_SHIFT | 6),
PTE7 = (4 << GPIO_PORT_SHIFT | 7),
PTE8 = (4 << GPIO_PORT_SHIFT | 8),
PTE9 = (4 << GPIO_PORT_SHIFT | 9),
PTE10 = (4 << GPIO_PORT_SHIFT | 10),
PTE11 = (4 << GPIO_PORT_SHIFT | 11),
PTE12 = (4 << GPIO_PORT_SHIFT | 12),

View File

@ -27,7 +27,7 @@ static float pwm_clock_mhz;
/* Array of FTM peripheral base address. */
static FTM_Type *const ftm_addrs[] = FTM_BASE_PTRS;
void pwmout_init_direct(pwmout_t* obj, const PinMap *pinmap)
void pwmout_init_direct(pwmout_t *obj, const PinMap *pinmap)
{
PWMName pwm = (PWMName)pinmap->peripheral;
MBED_ASSERT(pwm != (PWMName)NC);
@ -74,7 +74,7 @@ void pwmout_init_direct(pwmout_t* obj, const PinMap *pinmap)
pin_mode(pinmap->pin, PullNone);
}
void pwmout_init(pwmout_t* obj, PinName pin)
void pwmout_init(pwmout_t *obj, PinName pin)
{
int peripheral = (int)pinmap_peripheral(pin, PinMap_PWM);
int function = (int)pinmap_find_function(pin, PinMap_PWM);
@ -84,12 +84,12 @@ void pwmout_init(pwmout_t* obj, PinName pin)
pwmout_init_direct(obj, &explicit_pinmap);
}
void pwmout_free(pwmout_t* obj)
void pwmout_free(pwmout_t *obj)
{
FTM_Deinit(ftm_addrs[obj->pwm_name >> TPM_SHIFT]);
}
void pwmout_write(pwmout_t* obj, float value)
void pwmout_write(pwmout_t *obj, float value)
{
if (value < 0.0f) {
value = 0.0f;
@ -107,30 +107,31 @@ void pwmout_write(pwmout_t* obj, float value)
FTM_SetSoftwareTrigger(base, true);
}
float pwmout_read(pwmout_t* obj)
float pwmout_read(pwmout_t *obj)
{
FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT];
uint16_t count = (base->CONTROLS[obj->pwm_name & 0xF].CnV) & FTM_CnV_VAL_MASK;
uint16_t mod = base->MOD & FTM_MOD_MOD_MASK;
if (mod == 0)
if (mod == 0) {
return 0.0;
}
float v = (float)(count) / (float)(mod);
return (v > 1.0f) ? (1.0f) : (v);
}
void pwmout_period(pwmout_t* obj, float seconds)
void pwmout_period(pwmout_t *obj, float seconds)
{
pwmout_period_us(obj, seconds * 1000000.0f);
}
void pwmout_period_ms(pwmout_t* obj, int ms)
void pwmout_period_ms(pwmout_t *obj, int ms)
{
pwmout_period_us(obj, ms * 1000);
}
// Set the PWM period, keeping the duty cycle the same.
void pwmout_period_us(pwmout_t* obj, int us)
void pwmout_period_us(pwmout_t *obj, int us)
{
FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT];
float dc = pwmout_read(obj);
@ -157,17 +158,17 @@ void pwmout_period_us(pwmout_t* obj, int us)
pwmout_write(obj, dc);
}
void pwmout_pulsewidth(pwmout_t* obj, float seconds)
void pwmout_pulsewidth(pwmout_t *obj, float seconds)
{
pwmout_pulsewidth_us(obj, seconds * 1000000.0f);
}
void pwmout_pulsewidth_ms(pwmout_t* obj, int ms)
void pwmout_pulsewidth_ms(pwmout_t *obj, int ms)
{
pwmout_pulsewidth_us(obj, ms * 1000);
}
void pwmout_pulsewidth_us(pwmout_t* obj, int us)
void pwmout_pulsewidth_us(pwmout_t *obj, int us)
{
FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT];
uint32_t value = (uint32_t)(pwm_clock_mhz * (float)us);

View File

@ -119,8 +119,7 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b
uint8_t temp;
/* Set bit count and parity mode. */
temp = base->C1 & ~(UART_C1_PE_MASK | UART_C1_PT_MASK | UART_C1_M_MASK);
if (parity != ParityNone)
{
if (parity != ParityNone) {
/* Enable Parity */
temp |= (UART_C1_PE_MASK | UART_C1_M_MASK);
if (parity == ParityOdd) {
@ -147,18 +146,19 @@ static inline void uart_irq(uint32_t transmit_empty, uint32_t receive_full, uint
UART_Type *base = uart_addrs[index];
/* If RX overrun. */
if (UART_S1_OR_MASK & base->S1)
{
if (UART_S1_OR_MASK & base->S1) {
/* Read base->D, otherwise the RX does not work. */
(void)base->D;
}
if (serial_irq_ids[index] != 0) {
if (transmit_empty && (UART_GetEnabledInterrupts(uart_addrs[index]) & kUART_TxDataRegEmptyInterruptEnable))
if (transmit_empty && (UART_GetEnabledInterrupts(uart_addrs[index]) & kUART_TxDataRegEmptyInterruptEnable)) {
irq_handler(serial_irq_ids[index], TxIrq);
}
if (receive_full && (UART_GetEnabledInterrupts(uart_addrs[index]) & kUART_RxDataRegFullInterruptEnable))
if (receive_full && (UART_GetEnabledInterrupts(uart_addrs[index]) & kUART_RxDataRegFullInterruptEnable)) {
irq_handler(serial_irq_ids[index], RxIrq);
}
}
}
@ -269,8 +269,9 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
default:
break;
}
if (all_disabled)
if (all_disabled) {
NVIC_DisableIRQ(uart_irqs[obj->serial.index]);
}
}
}
@ -292,16 +293,18 @@ void serial_putc(serial_t *obj, int c)
int serial_readable(serial_t *obj)
{
uint32_t status_flags = UART_GetStatusFlags(uart_addrs[obj->serial.index]);
if (status_flags & kUART_RxOverrunFlag)
if (status_flags & kUART_RxOverrunFlag) {
UART_ClearStatusFlags(uart_addrs[obj->serial.index], kUART_RxOverrunFlag);
}
return (status_flags & kUART_RxDataRegFullFlag);
}
int serial_writable(serial_t *obj)
{
uint32_t status_flags = UART_GetStatusFlags(uart_addrs[obj->serial.index]);
if (status_flags & kUART_RxOverrunFlag)
if (status_flags & kUART_RxOverrunFlag) {
UART_ClearStatusFlags(uart_addrs[obj->serial.index], kUART_RxOverrunFlag);
}
return (status_flags & kUART_TxDataRegEmptyFlag);
}
@ -351,7 +354,7 @@ const PinMap *serial_rts_pinmap()
*/
void serial_set_flow_control_direct(serial_t *obj, FlowControl type, const serial_fc_pinmap_t *pinmap)
{
switch(type) {
switch (type) {
case FlowControlRTS:
pin_function(pinmap->rx_flow_pin, pinmap->rx_flow_function);
pin_mode(pinmap->rx_flow_pin, PullNone);
@ -404,7 +407,7 @@ static void serial_send_asynch(serial_t *obj)
sendXfer.dataSize = obj->tx_buff.length;
if (obj->serial.uartDmaRx.dmaUsageState == DMA_USAGE_ALLOCATED ||
obj->serial.uartDmaRx.dmaUsageState == DMA_USAGE_TEMPORARY_ALLOCATED) {
obj->serial.uartDmaRx.dmaUsageState == DMA_USAGE_TEMPORARY_ALLOCATED) {
UART_SendEDMA(uart_addrs[obj->serial.index], &obj->serial.uart_dma_handle, &sendXfer);
} else {
UART_TransferSendNonBlocking(uart_addrs[obj->serial.index], &obj->serial.uart_transfer_handle, &sendXfer);
@ -420,7 +423,7 @@ static void serial_receive_asynch(serial_t *obj)
receiveXfer.dataSize = obj->rx_buff.length;
if (obj->serial.uartDmaRx.dmaUsageState == DMA_USAGE_ALLOCATED ||
obj->serial.uartDmaRx.dmaUsageState == DMA_USAGE_TEMPORARY_ALLOCATED) {
obj->serial.uartDmaRx.dmaUsageState == DMA_USAGE_TEMPORARY_ALLOCATED) {
UART_ReceiveEDMA(uart_addrs[obj->serial.index], &obj->serial.uart_dma_handle, &receiveXfer);
} else {
UART_TransferReceiveNonBlocking(uart_addrs[obj->serial.index], &obj->serial.uart_transfer_handle, &receiveXfer, NULL);
@ -464,7 +467,7 @@ static bool serial_allocate_dma(serial_t *obj, uint32_t handler)
EDMA_CreateHandle(&(obj->serial.uartDmaTx.handle), DMA0, obj->serial.uartDmaTx.dmaChannel);
UART_TransferCreateHandleEDMA(uart_addrs[obj->serial.index], &obj->serial.uart_dma_handle, (uart_edma_transfer_callback_t)handler,
NULL, &obj->serial.uartDmaTx.handle, &obj->serial.uartDmaRx.handle);
NULL, &obj->serial.uartDmaTx.handle, &obj->serial.uartDmaRx.handle);
return true;
}
@ -512,7 +515,8 @@ void serial_enable_event(serial_t *obj, int event, uint8_t enable)
}
}
static void serial_tx_buffer_set(serial_t *obj, void *tx, int tx_length, uint8_t width) {
static void serial_tx_buffer_set(serial_t *obj, void *tx, int tx_length, uint8_t width)
{
(void)width;
// Exit if a transmit is already on-going
@ -528,9 +532,11 @@ static void serial_tx_buffer_set(serial_t *obj, void *tx, int tx_length, uint8_t
int serial_tx_asynch(serial_t *obj, const void *tx, size_t tx_length, uint8_t tx_width, uint32_t handler, uint32_t event, DMAUsage hint)
{
// Check that a buffer has indeed been set up
MBED_ASSERT(tx != (void*)0);
MBED_ASSERT(tx != (void *)0);
if (tx_length == 0) return 0;
if (tx_length == 0) {
return 0;
}
if (serial_tx_active(obj)) {
return 0;
@ -582,7 +588,9 @@ void serial_rx_buffer_set(serial_t *obj, void *rx, int rx_length, uint8_t width)
// We only support byte buffers for now
MBED_ASSERT(width == 8);
if (serial_rx_active(obj)) return;
if (serial_rx_active(obj)) {
return;
}
obj->rx_buff.buffer = rx;
obj->rx_buff.length = rx_length;
@ -595,15 +603,17 @@ void serial_rx_buffer_set(serial_t *obj, void *rx, int rx_length, uint8_t width)
void serial_rx_asynch(serial_t *obj, void *rx, size_t rx_length, uint8_t rx_width, uint32_t handler, uint32_t event, uint8_t char_match, DMAUsage hint)
{
// Check that a buffer has indeed been set up
MBED_ASSERT(rx != (void*)0);
if (rx_length == 0) return;
MBED_ASSERT(rx != (void *)0);
if (rx_length == 0) {
return;
}
if (serial_rx_active(obj)) {
return;
}
// Set up buffer
serial_rx_buffer_set(obj,(void*) rx, rx_length, rx_width);
serial_rx_buffer_set(obj, (void *) rx, rx_length, rx_width);
// Set up events
serial_enable_event(obj, SERIAL_EVENT_RX_ALL, false);
@ -711,7 +721,7 @@ int serial_irq_handler_asynch(serial_t *obj)
}
}
#if 0
if (obj->char_match != SERIAL_RESERVED_CHAR_MATCH){
if (obj->char_match != SERIAL_RESERVED_CHAR_MATCH) {
/* Check for character match event */
if (buf[obj->rx_buff.length - 1] == obj->char_match) {
status |= SERIAL_EVENT_RX_CHARACTER_MATCH;

View File

@ -31,10 +31,10 @@ static ADC_Type *const adc_addrs[] = ADC_BASE_PTRS;
#if EXPLICIT_PINMAP_READY
#define ANALOGIN_INIT_DIRECT analogin_init_direct
void analogin_init_direct(analogin_t* obj, const PinMap *pinmap)
void analogin_init_direct(analogin_t *obj, const PinMap *pinmap)
#else
#define ANALOGIN_INIT_DIRECT _analogin_init_direct
static void _analogin_init_direct(analogin_t* obj, const PinMap *pinmap)
static void _analogin_init_direct(analogin_t *obj, const PinMap *pinmap)
#endif
{
obj->adc = (ADCName)pinmap->peripheral;
@ -47,8 +47,9 @@ static void _analogin_init_direct(analogin_t* obj, const PinMap *pinmap)
bus_clock = CLOCK_GetFreq(kCLOCK_BusClk);
uint32_t clkdiv;
for (clkdiv = 0; clkdiv < 4; clkdiv++) {
if ((bus_clock >> clkdiv) <= MAX_FADC)
if ((bus_clock >> clkdiv) <= MAX_FADC) {
break;
}
}
if (clkdiv == 4) {
clkdiv = 0x3; //Set max div
@ -65,7 +66,7 @@ static void _analogin_init_direct(analogin_t* obj, const PinMap *pinmap)
pin_mode(pinmap->pin, PullNone);
}
void analogin_init(analogin_t* obj, PinName pin)
void analogin_init(analogin_t *obj, PinName pin)
{
int peripheral = (int)pinmap_peripheral(pin, PinMap_ADC);
int function = (int)pinmap_find_function(pin, PinMap_ADC);
@ -88,7 +89,7 @@ uint16_t analogin_read_u16(analogin_t *obj)
#endif
ADC16_SetChannelMuxMode(adc_addrs[instance],
obj->adc & (1 << ADC_B_CHANNEL_SHIFT) ? kADC16_ChannelMuxB : kADC16_ChannelMuxA);
obj->adc & (1 << ADC_B_CHANNEL_SHIFT) ? kADC16_ChannelMuxB : kADC16_ChannelMuxA);
/*
* When in software trigger mode, each conversion would be launched once calling the "ADC16_ChannelConfigure()"
@ -96,8 +97,7 @@ uint16_t analogin_read_u16(analogin_t *obj)
*/
ADC16_SetChannelConfig(adc_addrs[instance], 0, &adc16_channel_config);
while (0U == (kADC16_ChannelConversionDoneFlag &
ADC16_GetChannelStatusFlags(adc_addrs[instance], 0)))
{
ADC16_GetChannelStatusFlags(adc_addrs[instance], 0))) {
}
return ADC16_GetChannelConversionValue(adc_addrs[instance], 0);
}

View File

@ -30,10 +30,10 @@ static DAC_Type *const dac_bases[] = DAC_BASE_PTRS;
#if EXPLICIT_PINMAP_READY
#define ANALOGOUT_INIT_DIRECT analogout_init_direct
void analogout_init_direct(dac_t* obj, const PinMap *pinmap)
void analogout_init_direct(dac_t *obj, const PinMap *pinmap)
#else
#define ANALOGOUT_INIT_DIRECT _analogout_init_direct
static void _analogout_init_direct(dac_t* obj, const PinMap *pinmap)
static void _analogout_init_direct(dac_t *obj, const PinMap *pinmap)
#endif
{
dac_config_t dac_config;
@ -50,7 +50,7 @@ static void _analogout_init_direct(dac_t* obj, const PinMap *pinmap)
DAC_Enable(dac_bases[obj->dac], true);
}
void analogout_init(dac_t* obj, PinName pin)
void analogout_init(dac_t *obj, PinName pin)
{
int peripheral = (int)pinmap_peripheral(pin, PinMap_ADC);

View File

@ -98,8 +98,7 @@ int i2c_start(i2c_t *obj)
}
#if defined(FSL_FEATURE_I2C_HAS_DOUBLE_BUFFERING) && FSL_FEATURE_I2C_HAS_DOUBLE_BUFFERING
while (!(base->S2 & I2C_S2_EMPTY_MASK))
{
while (!(base->S2 & I2C_S2_EMPTY_MASK)) {
}
#endif /* FSL_FEATURE_I2C_HAS_DOUBLE_BUFFERING */
@ -217,8 +216,7 @@ int i2c_byte_read(i2c_t *obj, int last)
data = base->D;
/* Wait until data transfer complete. */
while (!(base->S & kI2C_IntPendingFlag))
{
while (!(base->S & kI2C_IntPendingFlag)) {
}
/* Clear the IICIF flag. */

View File

@ -38,10 +38,10 @@
#if EXPLICIT_PINMAP_READY
#define ANALOGIN_INIT_DIRECT analogin_init_direct
void analogin_init_direct(analogin_t* obj, const PinMap *pinmap)
void analogin_init_direct(analogin_t *obj, const PinMap *pinmap)
#else
#define ANALOGIN_INIT_DIRECT _analogin_init_direct
static void _analogin_init_direct(analogin_t* obj, const PinMap *pinmap)
static void _analogin_init_direct(analogin_t *obj, const PinMap *pinmap)
#endif
{
uint32_t function = (uint32_t)pinmap->function;
@ -105,7 +105,7 @@ static void _analogin_init_direct(analogin_t* obj, const PinMap *pinmap)
}
}
void analogin_init(analogin_t* obj, PinName pin)
void analogin_init(analogin_t *obj, PinName pin)
{
int peripheral;
int function;

View File

@ -37,10 +37,10 @@
#if EXPLICIT_PINMAP_READY
#define ANALOGOUT_INIT_DIRECT analogout_init_direct
void analogout_init_direct(dac_t* obj, const PinMap *pinmap)
void analogout_init_direct(dac_t *obj, const PinMap *pinmap)
#else
#define ANALOGOUT_INIT_DIRECT _analogout_init_direct
static void _analogout_init_direct(dac_t* obj, const PinMap *pinmap)
static void _analogout_init_direct(dac_t *obj, const PinMap *pinmap)
#endif
{
DAC_ChannelConfTypeDef sConfig = {0};

View File

@ -78,10 +78,10 @@ uint32_t TIM_ChannelConvert_HAL2LL(uint32_t channel, pwmout_t *obj)
#if EXPLICIT_PINMAP_READY
#define PWM_INIT_DIRECT pwmout_init_direct
void pwmout_init_direct(pwmout_t* obj, const PinMap *pinmap)
void pwmout_init_direct(pwmout_t *obj, const PinMap *pinmap)
#else
#define PWM_INIT_DIRECT _pwmout_init_direct
static void _pwmout_init_direct(pwmout_t* obj, const PinMap *pinmap)
static void _pwmout_init_direct(pwmout_t *obj, const PinMap *pinmap)
#endif
{
// Get the peripheral name from the pin and assign it to the object
@ -207,7 +207,7 @@ static void _pwmout_init_direct(pwmout_t* obj, const PinMap *pinmap)
pwmout_period_us(obj, 20000); // 20 ms per default
}
void pwmout_init(pwmout_t* obj, PinName pin)
void pwmout_init(pwmout_t *obj, PinName pin)
{
int peripheral = (int)pinmap_peripheral(pin, PinMap_PWM);
int function = (int)pinmap_find_function(pin, PinMap_PWM);