diff --git a/targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/cmsis.h b/targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/cmsis.h index 2d2850cc2e..b0439b1db0 100755 --- a/targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/cmsis.h +++ b/targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/cmsis.h @@ -43,4 +43,5 @@ #define __C #include "adi_processor.h" #include "cmsis_nvic.h" +#undef __C #endif diff --git a/targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/lp_ticker_api.c b/targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/lp_ticker_api.c index 5d46471c4a..addb198aa6 100755 --- a/targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/lp_ticker_api.c +++ b/targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/lp_ticker_api.c @@ -120,7 +120,7 @@ static int set_rtc_alarm_interrupt(ADI_RTC_HANDLE const hDevice, uint32_t nAlarm * Local RTC 1 ISR callback function. * */ -static void rtc1_Callback (void *pCBParam, uint32_t nEvent, void *EventArg) +static void rtc1_Callback(void *pCBParam, uint32_t nEvent, void *EventArg) { /* process RTC interrupts (cleared by driver) */ if (ADI_RTC_ALARM_INT & nEvent) { @@ -129,16 +129,6 @@ static void rtc1_Callback (void *pCBParam, uint32_t nEvent, void *EventArg) } -/** Get low power ticker's data - * - * @return The low power ticker data - */ -/* -const ticker_data_t* get_lp_ticker_data() -{ -}*/ - - /* HAL lp ticker */ /** Initialize the low power ticker diff --git a/targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/objects.h b/targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/objects.h index aeecf36d00..495faf8c67 100755 --- a/targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/objects.h +++ b/targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/objects.h @@ -85,7 +85,7 @@ struct i2c_s { #define BUILD_SPI_MI_DYNAMIC struct spi_s { - uint32_t instance; + uint32_t instance; uint32_t error; ADI_SPI_HANDLE *pSPI_Handle; #if defined(BUILD_SPI_MI_DYNAMIC) diff --git a/targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/serial_api.c b/targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/serial_api.c index c6af733fad..fabe28d035 100755 --- a/targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/serial_api.c +++ b/targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/serial_api.c @@ -135,24 +135,26 @@ void serial_baud(serial_t *obj, int baudrate) void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) { - int convertedparity = ADI_UART_NO_PARITY; - int convertedstopbits = ADI_UART_ONE_STOPBIT; + ADI_UART_PARITY convertedparity = ADI_UART_NO_PARITY; + ADI_UART_STOPBITS convertedstopbits = ADI_UART_ONE_STOPBIT; - if (stop_bits) + if (stop_bits) { convertedstopbits = ADI_UART_ONE_AND_HALF_TWO_STOPBITS; + } - if (parity == ParityOdd) + if (parity == ParityOdd) { convertedparity = ADI_UART_ODD_PARITY; - else if (parity == ParityEven) + } else if (parity == ParityEven) { convertedparity = ADI_UART_EVEN_PARITY; - else if (parity == ParityForced1) + } else if (parity == ParityForced1) { convertedparity = ADI_UART_ODD_PARITY_STICKY; - else if (parity == ParityForced0) + } else if (parity == ParityForced0) { convertedparity = ADI_UART_EVEN_PARITY_STICKY; + } - adi_uart_SetConfiguration(hDevice[obj->index], convertedparity, convertedstopbits, (data_bits - 5)); + adi_uart_SetConfiguration(hDevice[obj->index], convertedparity, convertedstopbits, + (ADI_UART_WORDLEN)(data_bits - 5)); } -#ifndef ADI_UART_TRANSFER_MODE void serial_init(serial_t *obj, PinName tx, PinName rx) { @@ -212,71 +214,6 @@ void serial_putc(serial_t *obj, int c) return; } -#else - -void serial_init(serial_t *obj, PinName tx, PinName rx) -{ - uint32_t uart_tx = pinmap_peripheral(tx, PinMap_UART_TX); - uint32_t uart_rx = pinmap_peripheral(rx, PinMap_UART_RX); - - obj->index = pinmap_merge(uart_tx, uart_rx); - MBED_ASSERT((int)obj->index != NC); - - adi_uart_Open(obj->index, ADI_UART_DIR_BIDIRECTION, UartDeviceMem[obj->index], ADI_UART_MEMORY_SIZE, &hDevice[obj->index]); - - serial_baud(obj, 9600); - serial_format(obj, 8, ParityNone, 1); - - pinmap_pinout(tx, PinMap_UART_TX); - pinmap_pinout(rx, PinMap_UART_RX); - - if (tx != NC) { - pin_mode(tx, PullUp); - } - - if (rx != NC) { - pin_mode(rx, PullUp); - } - - if (obj->index == STDIO_UART) { - stdio_uart_inited = 1; - memcpy(&stdio_uart, obj, sizeof(serial_t)); - } - - // set maximum FIFO depth - adi_uart_SetRxFifoTriggerLevel(hDevice[obj->index], ADI_UART_RX_FIFO_TRIG_LEVEL_14BYTE); - - // enable FIFO - adi_uart_EnableFifo(hDevice[obj->index], true); -} - -int serial_getc(serial_t *obj) -{ - int c; - uint32_t hwErr; - - adi_uart_Read(hDevice[obj->index], (void *) &c, 1, false, &hwErr); - return (c); -} - -void serial_putc(serial_t *obj, int c) -{ - uint32_t hwErr; - - adi_uart_Write(hDevice[obj->index], &c, 1, false, &hwErr); - return; -} - -int serial_readable(serial_t *obj) -{ - return 0; -} - -int serial_writable(serial_t *obj) -{ - return 0; -} -#endif void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable) { MBED_ASSERT(obj); diff --git a/targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/spi_api.c b/targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/spi_api.c index 76015a4b2d..a52406889b 100755 --- a/targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/spi_api.c +++ b/targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/spi_api.c @@ -213,15 +213,24 @@ void spi_free(spi_t *obj) * 2 | 1 0 * 3 | 1 1 * @endcode + + bool phase; + true : trailing-edge + false : leading-edge + + bool polarity; + true : CPOL=1 (idle high) polarity + false : CPOL=0 (idle-low) polarity */ void spi_format(spi_t *obj, int bits, int mode, int slave) { ADI_SPI_HANDLE SPI_Handle; ADI_SPI_RESULT SPI_Return = ADI_SPI_SUCCESS; - bool_t master; + bool master; master = !((bool_t)slave); SPI_Handle = *obj->pSPI_Handle; + SPI_Return = adi_spi_SetMasterMode(SPI_Handle, master); if (SPI_Return) { obj->error = SPI_EVENT_ERROR; @@ -309,12 +318,12 @@ int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length, cha ADI_SPI_HANDLE SPI_Handle; ADI_SPI_RESULT SPI_Return = ADI_SPI_SUCCESS; - transceive.pReceiver = rx_buffer; - transceive.ReceiverBytes = rx_length; /* link transceive data size to the remaining count */ - transceive.nRxIncrement = 1; /* auto increment buffer */ - transceive.pTransmitter = tx_buffer; /* initialize data attributes */ - transceive.TransmitterBytes = tx_length; /* link transceive data size to the remaining count */ - transceive.nTxIncrement = 1; /* auto increment buffer */ + transceive.pReceiver = (uint8_t*)rx_buffer; + transceive.ReceiverBytes = rx_length; /* link transceive data size to the remaining count */ + transceive.nRxIncrement = 1; /* auto increment buffer */ + transceive.pTransmitter = (uint8_t*)tx_buffer; /* initialize data attributes */ + transceive.TransmitterBytes = tx_length; /* link transceive data size to the remaining count */ + transceive.nTxIncrement = 1; /* auto increment buffer */ transceive.bDMA = false; transceive.bRD_CTL = false;