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); const serial_fc_pinmap_t pinmap = get_uart_fc_pinmap(rts, cts);
serial_set_flow_control_direct(&serial, FlowControlRTSCTS, &pinmap); serial_set_flow_control_direct(&serial, FlowControlRTSCTS, &pinmap);
#else #else
//skip this test case if explicit pinmap is not supported //skip this test case if explicit pinmap is not supported
return; return;
#endif #endif
} else { } else {
serial_set_flow_control(&serial, FlowControlRTSCTS, rts, cts); serial_set_flow_control(&serial, FlowControlRTSCTS, rts, cts);

View File

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

View File

@ -67,7 +67,7 @@ typedef struct analogin_s analogin_t;
* @param obj The analogin object to initialize * @param obj The analogin object to initialize
* @param pinmap pointer to structure which holds static pinmap * @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 /** Initialize the analogin peripheral
* *

View File

@ -69,7 +69,7 @@ typedef struct dac_s dac_t;
* @param obj The analogout object to initialize * @param obj The analogout object to initialize
* @param pinmap pointer to structure which holds static pinmap * @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 /** 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) || if ((!mosi_map || !miso_map || !sclk_map || !ssel_map) ||
(mosi_map->peripheral != miso_map->peripheral || mosi_map->peripheral != sclk_map->peripheral) || (mosi_map->peripheral != miso_map->peripheral || mosi_map->peripheral != sclk_map->peripheral) ||
(ssel_map->pin != NC && mosi_map->peripheral != ssel_map->peripheral)) { (ssel_map->pin != NC && mosi_map->peripheral != ssel_map->peripheral)) {
return {NC, NC, NC, NC, NC, NC, NC, NC, NC}; 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 obj The pwmout object to initialize
* @param pinmap pointer to structure which holds static pinmap * @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 /** Initialize the pwm out peripheral and configure the pin
* *

View File

@ -61,8 +61,7 @@
#define alignas(N) __attribute__((aligned(N))) #define alignas(N) __attribute__((aligned(N)))
#endif #endif
namespace std namespace std {
{
// [cstddef.syn] // [cstddef.syn]
using nullptr_t = decltype(nullptr); using nullptr_t = decltype(nullptr);
@ -70,8 +69,7 @@ using nullptr_t = decltype(nullptr);
#endif // __CC_ARM #endif // __CC_ARM
namespace mstd namespace mstd {
{
using std::size_t; using std::size_t;
using std::ptrdiff_t; using std::ptrdiff_t;
using std::nullptr_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_TARGET_CONSOLE_UART && DEVICE_SERIAL
# if MBED_CONF_PLATFORM_STDIO_BUFFERED_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 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 UARTSerial console(console_pinmap, MBED_CONF_PLATFORM_STDIO_BAUD_RATE);
# if CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTS # if CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTS
static const serial_fc_pinmap_t fc_pinmap = get_uart_fc_pinmap(STDIO_UART_RTS, NC); 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); 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}, {PTE27, GPIO_X, 1},
{PTE28, GPIO_X, 1}, {PTE28, GPIO_X, 1},
{NC , NC , 0} {NC, NC, 0}
}; };
/************RTC***************/ /************RTC***************/
@ -139,16 +139,16 @@ MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_RTC[] = {
/************ADC***************/ /************ADC***************/
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_ADC[] = { MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_ADC[] = {
{PTA17, ADC1_SE17, 0}, {PTA17, ADC1_SE17, 0},
{PTB0 , ADC0_SE8 , 0}, {PTB0, ADC0_SE8, 0},
{PTB1 , ADC0_SE9 , 0}, {PTB1, ADC0_SE9, 0},
{PTB2 , ADC0_SE12, 0}, {PTB2, ADC0_SE12, 0},
{PTB3 , ADC0_SE13, 0}, {PTB3, ADC0_SE13, 0},
{PTB6 , ADC1_SE12, 0}, {PTB6, ADC1_SE12, 0},
{PTB7 , ADC1_SE13, 0}, {PTB7, ADC1_SE13, 0},
{PTB10, ADC1_SE14, 0}, {PTB10, ADC1_SE14, 0},
{PTB11, ADC1_SE15, 0}, {PTB11, ADC1_SE15, 0},
{PTC0 , ADC0_SE14, 0}, {PTC0, ADC0_SE14, 0},
{PTC1 , ADC0_SE15, 0}, {PTC1, ADC0_SE15, 0},
{PTC2, ADC0_SE4b, 0}, {PTC2, ADC0_SE4b, 0},
{PTC8, ADC1_SE4b, 0}, {PTC8, ADC1_SE4b, 0},
{PTC9, ADC1_SE5b, 0}, {PTC9, ADC1_SE5b, 0},
@ -163,197 +163,197 @@ MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_ADC[] = {
{PTE3, ADC1_SE7a, 0}, {PTE3, ADC1_SE7a, 0},
//{PTE24, ADC0_SE17, 0}, //I2C pull up //{PTE24, ADC0_SE17, 0}, //I2C pull up
//{PTE25, ADC0_SE18, 0}, //I2C pull up //{PTE25, ADC0_SE18, 0}, //I2C pull up
{NC , NC , 0} {NC, NC, 0}
}; };
/************DAC***************/ /************DAC***************/
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_DAC[] = { MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_DAC[] = {
{DAC0_OUT, DAC_0, 0}, {DAC0_OUT, DAC_0, 0},
{NC , NC , 0} {NC, NC, 0}
}; };
/************I2C***************/ /************I2C***************/
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_I2C_SDA[] = { MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_I2C_SDA[] = {
{PTE25, I2C_0, 5}, {PTE25, I2C_0, 5},
{PTB1 , I2C_0, 2}, {PTB1, I2C_0, 2},
{PTB3 , I2C_0, 2}, {PTB3, I2C_0, 2},
{PTC11, I2C_1, 2}, {PTC11, I2C_1, 2},
{PTA13, I2C_2, 5}, {PTA13, I2C_2, 5},
{PTD3 , I2C_0, 7}, {PTD3, I2C_0, 7},
{PTE0 , I2C_1, 6}, {PTE0, I2C_1, 6},
{NC , NC , 0} {NC, NC, 0}
}; };
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_I2C_SCL[] = { MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_I2C_SCL[] = {
{PTE24, I2C_0, 5}, {PTE24, I2C_0, 5},
{PTB0 , I2C_0, 2}, {PTB0, I2C_0, 2},
{PTB2 , I2C_0, 2}, {PTB2, I2C_0, 2},
{PTC10, I2C_1, 2}, {PTC10, I2C_1, 2},
{PTA12, I2C_2, 5}, {PTA12, I2C_2, 5},
{PTA14, I2C_2, 5}, {PTA14, I2C_2, 5},
{PTD2 , I2C_0, 7}, {PTD2, I2C_0, 7},
{PTE1 , I2C_1, 6}, {PTE1, I2C_1, 6},
{NC , NC , 0} {NC, NC, 0}
}; };
/************UART***************/ /************UART***************/
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_UART_TX[] = { MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_UART_TX[] = {
{PTB17, UART_0, 3}, {PTB17, UART_0, 3},
{PTC17, UART_3, 3}, {PTC17, UART_3, 3},
{PTD7 , UART_0, 3}, {PTD7, UART_0, 3},
{PTD3 , UART_2, 3}, {PTD3, UART_2, 3},
{PTC4 , UART_1, 3}, {PTC4, UART_1, 3},
{PTC15, UART_4, 3}, {PTC15, UART_4, 3},
{PTB11, UART_3, 3}, {PTB11, UART_3, 3},
{PTA14, UART_0, 3}, {PTA14, UART_0, 3},
{PTE24, UART_4, 3}, {PTE24, UART_4, 3},
{PTE4 , UART_3, 3}, {PTE4, UART_3, 3},
{PTE0, UART_1, 3}, {PTE0, UART_1, 3},
{NC , NC , 0} {NC, NC, 0}
}; };
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_UART_RX[] = { MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_UART_RX[] = {
{PTB16, UART_0, 3}, {PTB16, UART_0, 3},
{PTE1 , UART_1, 3}, {PTE1, UART_1, 3},
{PTE5 , UART_3, 3}, {PTE5, UART_3, 3},
{PTE25, UART_4, 3}, {PTE25, UART_4, 3},
{PTA15, UART_0, 3}, {PTA15, UART_0, 3},
{PTC16, UART_3, 3}, {PTC16, UART_3, 3},
{PTB10, UART_3, 3}, {PTB10, UART_3, 3},
{PTC3 , UART_1, 3}, {PTC3, UART_1, 3},
{PTC14, UART_4, 3}, {PTC14, UART_4, 3},
{PTD2 , UART_2, 3}, {PTD2, UART_2, 3},
{PTD6 , UART_0, 3}, {PTD6, UART_0, 3},
{NC , NC , 0} {NC, NC, 0}
}; };
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_UART_CTS[] = { MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_UART_CTS[] = {
{PTB13, UART_3, 2}, {PTB13, UART_3, 2},
{PTE2 , UART_1, 3}, {PTE2, UART_1, 3},
{PTE6 , UART_3, 3}, {PTE6, UART_3, 3},
{PTE26, UART_4, 3}, {PTE26, UART_4, 3},
{PTA0 , UART_0, 2}, {PTA0, UART_0, 2},
{PTA16, UART_0, 3}, {PTA16, UART_0, 3},
{PTB3 , UART_0, 3}, {PTB3, UART_0, 3},
{PTB9 , UART_3, 3}, {PTB9, UART_3, 3},
{PTC2 , UART_1, 3}, {PTC2, UART_1, 3},
{PTC13, UART_4, 3}, {PTC13, UART_4, 3},
{PTC19, UART_3, 3}, {PTC19, UART_3, 3},
{PTD1 , UART_2, 3}, {PTD1, UART_2, 3},
{PTD5 , UART_0, 3}, {PTD5, UART_0, 3},
{NC , NC , 0} {NC, NC, 0}
}; };
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_UART_RTS[] = { MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_UART_RTS[] = {
{PTB12, UART_3, 2}, {PTB12, UART_3, 2},
{PTE3 , UART_1, 3}, {PTE3, UART_1, 3},
{PTE7 , UART_3, 3}, {PTE7, UART_3, 3},
{PTE27, UART_4, 3}, {PTE27, UART_4, 3},
{PTA17, UART_0, 3}, {PTA17, UART_0, 3},
{PTB8 , UART_3, 3}, {PTB8, UART_3, 3},
{PTC1 , UART_1, 3}, {PTC1, UART_1, 3},
{PTC12, UART_4, 3}, {PTC12, UART_4, 3},
{PTC18, UART_3, 3}, {PTC18, UART_3, 3},
{PTD0 , UART_2, 3}, {PTD0, UART_2, 3},
{PTD4 , UART_0, 3}, {PTD4, UART_0, 3},
{PTA3 , UART_0, 2}, {PTA3, UART_0, 2},
{PTB2 , UART_0, 3}, {PTB2, UART_0, 3},
{NC , NC , 0} {NC, NC, 0}
}; };
/************SPI***************/ /************SPI***************/
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_SPI_SCLK[] = { MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_SPI_SCLK[] = {
{PTD1 , SPI_0, 2}, {PTD1, SPI_0, 2},
{PTE2 , SPI_1, 2}, {PTE2, SPI_1, 2},
{PTA15, SPI_0, 2}, {PTA15, SPI_0, 2},
{PTB11, SPI_1, 2}, {PTB11, SPI_1, 2},
{PTB21, SPI_2, 2}, {PTB21, SPI_2, 2},
{PTC5 , SPI_0, 2}, {PTC5, SPI_0, 2},
{PTD5 , SPI_1, 7}, {PTD5, SPI_1, 7},
{NC , NC , 0} {NC, NC, 0}
}; };
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_SPI_MOSI[] = { MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_SPI_MOSI[] = {
{PTD2 , SPI_0, 2}, {PTD2, SPI_0, 2},
{PTE1 , SPI_1, 2}, {PTE1, SPI_1, 2},
{PTE3 , SPI_1, 7}, {PTE3, SPI_1, 7},
{PTA16, SPI_0, 2}, {PTA16, SPI_0, 2},
{PTB16, SPI_1, 2}, {PTB16, SPI_1, 2},
{PTB22, SPI_2, 2}, {PTB22, SPI_2, 2},
{PTC6 , SPI_0, 2}, {PTC6, SPI_0, 2},
{PTD6 , SPI_1, 7}, {PTD6, SPI_1, 7},
{NC , NC , 0} {NC, NC, 0}
}; };
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_SPI_MISO[] = { MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_SPI_MISO[] = {
{PTD3 , SPI_0, 2}, {PTD3, SPI_0, 2},
{PTE1 , SPI_1, 7}, {PTE1, SPI_1, 7},
{PTE3 , SPI_1, 2}, {PTE3, SPI_1, 2},
{PTA17, SPI_0, 2}, {PTA17, SPI_0, 2},
{PTB17, SPI_1, 2}, {PTB17, SPI_1, 2},
{PTB23, SPI_2, 2}, {PTB23, SPI_2, 2},
{PTC7 , SPI_0, 2}, {PTC7, SPI_0, 2},
{PTD7 , SPI_1, 7}, {PTD7, SPI_1, 7},
{NC , NC , 0} {NC, NC, 0}
}; };
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_SPI_SSEL[] = { MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_SPI_SSEL[] = {
{PTD0 , SPI_0, 2}, {PTD0, SPI_0, 2},
{PTE4 , SPI_1, 2}, {PTE4, SPI_1, 2},
{PTA14, SPI_0, 2}, {PTA14, SPI_0, 2},
{PTB10, SPI_1, 2}, {PTB10, SPI_1, 2},
{PTB20, SPI_2, 2}, {PTB20, SPI_2, 2},
{PTC4 , SPI_0, 2}, {PTC4, SPI_0, 2},
{PTD4 , SPI_1, 7}, {PTD4, SPI_1, 7},
{NC , NC , 0} {NC, NC, 0}
}; };
/************PWM***************/ /************PWM***************/
MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_PWM[] = { MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_PWM[] = {
{PTA0 , PWM_6 , 3}, {PTA0, PWM_6, 3},
{PTA1 , PWM_7 , 3}, {PTA1, PWM_7, 3},
{PTA2 , PWM_8 , 3}, {PTA2, PWM_8, 3},
{PTA3 , PWM_1 , 3}, {PTA3, PWM_1, 3},
{PTA4 , PWM_2 , 3}, {PTA4, PWM_2, 3},
{PTA5 , PWM_3 , 3}, {PTA5, PWM_3, 3},
{PTA6 , PWM_4 , 3}, {PTA6, PWM_4, 3},
{PTA7 , PWM_5 , 3}, {PTA7, PWM_5, 3},
{PTA8 , PWM_9 , 3}, {PTA8, PWM_9, 3},
{PTA9 , PWM_10, 3}, {PTA9, PWM_10, 3},
{PTA10, PWM_17, 3}, {PTA10, PWM_17, 3},
{PTA11, PWM_18, 3}, {PTA11, PWM_18, 3},
{PTA12, PWM_9 , 3}, {PTA12, PWM_9, 3},
{PTA13, PWM_10, 3}, {PTA13, PWM_10, 3},
{PTB0 , PWM_9 , 3}, {PTB0, PWM_9, 3},
{PTB1 , PWM_10, 3}, {PTB1, PWM_10, 3},
{PTB18, PWM_17, 3}, {PTB18, PWM_17, 3},
{PTB19, PWM_18, 3}, {PTB19, PWM_18, 3},
{PTC1 , PWM_1 , 4}, {PTC1, PWM_1, 4},
{PTC2 , PWM_2 , 4}, {PTC2, PWM_2, 4},
{PTC3 , PWM_3 , 4}, {PTC3, PWM_3, 4},
{PTC4 , PWM_4 , 4}, {PTC4, PWM_4, 4},
{PTC5 , PWM_3 , 7}, {PTC5, PWM_3, 7},
{PTC8 , PWM_29, 3}, {PTC8, PWM_29, 3},
{PTC9 , PWM_30, 3}, {PTC9, PWM_30, 3},
{PTC10, PWM_31, 3}, {PTC10, PWM_31, 3},
{PTC11, PWM_32, 3}, {PTC11, PWM_32, 3},
{PTD0 , PWM_25, 4}, {PTD0, PWM_25, 4},
{PTD1 , PWM_26, 4}, {PTD1, PWM_26, 4},
{PTD2 , PWM_27, 4}, {PTD2, PWM_27, 4},
{PTD3 , PWM_28, 4}, {PTD3, PWM_28, 4},
{PTD4 , PWM_5 , 4}, {PTD4, PWM_5, 4},
{PTD5 , PWM_6 , 4}, {PTD5, PWM_6, 4},
{PTD6 , PWM_7 , 4}, {PTD6, PWM_7, 4},
{PTD4 , PWM_5 , 4}, {PTD4, PWM_5, 4},
{PTD7 , PWM_8 , 4}, {PTD7, PWM_8, 4},
{PTE5 , PWM_25, 6}, {PTE5, PWM_25, 6},
{PTE6 , PWM_26, 6}, {PTE6, PWM_26, 6},
{NC , NC , 0} {NC, NC, 0}
}; };
#define PINMAP_ANALOGIN PinMap_ADC #define PINMAP_ANALOGIN PinMap_ADC

View File

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

View File

@ -27,7 +27,7 @@ static float pwm_clock_mhz;
/* Array of FTM peripheral base address. */ /* Array of FTM peripheral base address. */
static FTM_Type *const ftm_addrs[] = FTM_BASE_PTRS; 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; PWMName pwm = (PWMName)pinmap->peripheral;
MBED_ASSERT(pwm != (PWMName)NC); MBED_ASSERT(pwm != (PWMName)NC);
@ -74,7 +74,7 @@ void pwmout_init_direct(pwmout_t* obj, const PinMap *pinmap)
pin_mode(pinmap->pin, PullNone); 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 peripheral = (int)pinmap_peripheral(pin, PinMap_PWM);
int function = (int)pinmap_find_function(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); 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]); 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) { if (value < 0.0f) {
value = 0.0f; value = 0.0f;
@ -107,30 +107,31 @@ void pwmout_write(pwmout_t* obj, float value)
FTM_SetSoftwareTrigger(base, true); 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]; 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 count = (base->CONTROLS[obj->pwm_name & 0xF].CnV) & FTM_CnV_VAL_MASK;
uint16_t mod = base->MOD & FTM_MOD_MOD_MASK; uint16_t mod = base->MOD & FTM_MOD_MOD_MASK;
if (mod == 0) if (mod == 0) {
return 0.0; return 0.0;
}
float v = (float)(count) / (float)(mod); float v = (float)(count) / (float)(mod);
return (v > 1.0f) ? (1.0f) : (v); 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); 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); pwmout_period_us(obj, ms * 1000);
} }
// Set the PWM period, keeping the duty cycle the same. // 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]; FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT];
float dc = pwmout_read(obj); float dc = pwmout_read(obj);
@ -157,17 +158,17 @@ void pwmout_period_us(pwmout_t* obj, int us)
pwmout_write(obj, dc); 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); 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); 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]; FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT];
uint32_t value = (uint32_t)(pwm_clock_mhz * (float)us); 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; uint8_t temp;
/* Set bit count and parity mode. */ /* Set bit count and parity mode. */
temp = base->C1 & ~(UART_C1_PE_MASK | UART_C1_PT_MASK | UART_C1_M_MASK); temp = base->C1 & ~(UART_C1_PE_MASK | UART_C1_PT_MASK | UART_C1_M_MASK);
if (parity != ParityNone) if (parity != ParityNone) {
{
/* Enable Parity */ /* Enable Parity */
temp |= (UART_C1_PE_MASK | UART_C1_M_MASK); temp |= (UART_C1_PE_MASK | UART_C1_M_MASK);
if (parity == ParityOdd) { 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]; UART_Type *base = uart_addrs[index];
/* If RX overrun. */ /* 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. */ /* Read base->D, otherwise the RX does not work. */
(void)base->D; (void)base->D;
} }
if (serial_irq_ids[index] != 0) { 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); 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); irq_handler(serial_irq_ids[index], RxIrq);
}
} }
} }
@ -269,8 +269,9 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
default: default:
break; break;
} }
if (all_disabled) if (all_disabled) {
NVIC_DisableIRQ(uart_irqs[obj->serial.index]); 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) int serial_readable(serial_t *obj)
{ {
uint32_t status_flags = UART_GetStatusFlags(uart_addrs[obj->serial.index]); 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); UART_ClearStatusFlags(uart_addrs[obj->serial.index], kUART_RxOverrunFlag);
}
return (status_flags & kUART_RxDataRegFullFlag); return (status_flags & kUART_RxDataRegFullFlag);
} }
int serial_writable(serial_t *obj) int serial_writable(serial_t *obj)
{ {
uint32_t status_flags = UART_GetStatusFlags(uart_addrs[obj->serial.index]); 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); UART_ClearStatusFlags(uart_addrs[obj->serial.index], kUART_RxOverrunFlag);
}
return (status_flags & kUART_TxDataRegEmptyFlag); 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) void serial_set_flow_control_direct(serial_t *obj, FlowControl type, const serial_fc_pinmap_t *pinmap)
{ {
switch(type) { switch (type) {
case FlowControlRTS: case FlowControlRTS:
pin_function(pinmap->rx_flow_pin, pinmap->rx_flow_function); pin_function(pinmap->rx_flow_pin, pinmap->rx_flow_function);
pin_mode(pinmap->rx_flow_pin, PullNone); 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; sendXfer.dataSize = obj->tx_buff.length;
if (obj->serial.uartDmaRx.dmaUsageState == DMA_USAGE_ALLOCATED || 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); UART_SendEDMA(uart_addrs[obj->serial.index], &obj->serial.uart_dma_handle, &sendXfer);
} else { } else {
UART_TransferSendNonBlocking(uart_addrs[obj->serial.index], &obj->serial.uart_transfer_handle, &sendXfer); 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; receiveXfer.dataSize = obj->rx_buff.length;
if (obj->serial.uartDmaRx.dmaUsageState == DMA_USAGE_ALLOCATED || 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); UART_ReceiveEDMA(uart_addrs[obj->serial.index], &obj->serial.uart_dma_handle, &receiveXfer);
} else { } else {
UART_TransferReceiveNonBlocking(uart_addrs[obj->serial.index], &obj->serial.uart_transfer_handle, &receiveXfer, NULL); 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); 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, 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; 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; (void)width;
// Exit if a transmit is already on-going // 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) 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 // 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)) { if (serial_tx_active(obj)) {
return 0; 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 // We only support byte buffers for now
MBED_ASSERT(width == 8); MBED_ASSERT(width == 8);
if (serial_rx_active(obj)) return; if (serial_rx_active(obj)) {
return;
}
obj->rx_buff.buffer = rx; obj->rx_buff.buffer = rx;
obj->rx_buff.length = rx_length; 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) 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 // Check that a buffer has indeed been set up
MBED_ASSERT(rx != (void*)0); MBED_ASSERT(rx != (void *)0);
if (rx_length == 0) return; if (rx_length == 0) {
return;
}
if (serial_rx_active(obj)) { if (serial_rx_active(obj)) {
return; return;
} }
// Set up buffer // 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 // Set up events
serial_enable_event(obj, SERIAL_EVENT_RX_ALL, false); serial_enable_event(obj, SERIAL_EVENT_RX_ALL, false);
@ -711,7 +721,7 @@ int serial_irq_handler_asynch(serial_t *obj)
} }
} }
#if 0 #if 0
if (obj->char_match != SERIAL_RESERVED_CHAR_MATCH){ if (obj->char_match != SERIAL_RESERVED_CHAR_MATCH) {
/* Check for character match event */ /* Check for character match event */
if (buf[obj->rx_buff.length - 1] == obj->char_match) { if (buf[obj->rx_buff.length - 1] == obj->char_match) {
status |= SERIAL_EVENT_RX_CHARACTER_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 #if EXPLICIT_PINMAP_READY
#define ANALOGIN_INIT_DIRECT analogin_init_direct #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 #else
#define ANALOGIN_INIT_DIRECT _analogin_init_direct #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 #endif
{ {
obj->adc = (ADCName)pinmap->peripheral; 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); bus_clock = CLOCK_GetFreq(kCLOCK_BusClk);
uint32_t clkdiv; uint32_t clkdiv;
for (clkdiv = 0; clkdiv < 4; clkdiv++) { for (clkdiv = 0; clkdiv < 4; clkdiv++) {
if ((bus_clock >> clkdiv) <= MAX_FADC) if ((bus_clock >> clkdiv) <= MAX_FADC) {
break; break;
}
} }
if (clkdiv == 4) { if (clkdiv == 4) {
clkdiv = 0x3; //Set max div 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); 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 peripheral = (int)pinmap_peripheral(pin, PinMap_ADC);
int function = (int)pinmap_find_function(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 #endif
ADC16_SetChannelMuxMode(adc_addrs[instance], 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()" * 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); ADC16_SetChannelConfig(adc_addrs[instance], 0, &adc16_channel_config);
while (0U == (kADC16_ChannelConversionDoneFlag & while (0U == (kADC16_ChannelConversionDoneFlag &
ADC16_GetChannelStatusFlags(adc_addrs[instance], 0))) ADC16_GetChannelStatusFlags(adc_addrs[instance], 0))) {
{
} }
return ADC16_GetChannelConversionValue(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 #if EXPLICIT_PINMAP_READY
#define ANALOGOUT_INIT_DIRECT analogout_init_direct #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 #else
#define ANALOGOUT_INIT_DIRECT _analogout_init_direct #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 #endif
{ {
dac_config_t dac_config; 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); 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); 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 #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 */ #endif /* FSL_FEATURE_I2C_HAS_DOUBLE_BUFFERING */
@ -217,8 +216,7 @@ int i2c_byte_read(i2c_t *obj, int last)
data = base->D; data = base->D;
/* Wait until data transfer complete. */ /* Wait until data transfer complete. */
while (!(base->S & kI2C_IntPendingFlag)) while (!(base->S & kI2C_IntPendingFlag)) {
{
} }
/* Clear the IICIF flag. */ /* Clear the IICIF flag. */

View File

@ -38,10 +38,10 @@
#if EXPLICIT_PINMAP_READY #if EXPLICIT_PINMAP_READY
#define ANALOGIN_INIT_DIRECT analogin_init_direct #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 #else
#define ANALOGIN_INIT_DIRECT _analogin_init_direct #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 #endif
{ {
uint32_t function = (uint32_t)pinmap->function; 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 peripheral;
int function; int function;

View File

@ -37,10 +37,10 @@
#if EXPLICIT_PINMAP_READY #if EXPLICIT_PINMAP_READY
#define ANALOGOUT_INIT_DIRECT analogout_init_direct #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 #else
#define ANALOGOUT_INIT_DIRECT _analogout_init_direct #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 #endif
{ {
DAC_ChannelConfTypeDef sConfig = {0}; 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 #if EXPLICIT_PINMAP_READY
#define PWM_INIT_DIRECT pwmout_init_direct #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 #else
#define PWM_INIT_DIRECT _pwmout_init_direct #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 #endif
{ {
// Get the peripheral name from the pin and assign it to the object // 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 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 peripheral = (int)pinmap_peripheral(pin, PinMap_PWM);
int function = (int)pinmap_find_function(pin, PinMap_PWM); int function = (int)pinmap_find_function(pin, PinMap_PWM);