Skip to content

Commit 6d11627

Browse files
committed
- Cleaned up some formatting issues; - Fixed a build error in spi_master_block_write; - Some clean up in serai_api.
1 parent 6f9a547 commit 6d11627

File tree

5 files changed

+30
-93
lines changed

5 files changed

+30
-93
lines changed

targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/cmsis.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@
4343
#define __C
4444
#include "adi_processor.h"
4545
#include "cmsis_nvic.h"
46+
#undef __C
4647
#endif

targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/lp_ticker_api.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static int set_rtc_alarm_interrupt(ADI_RTC_HANDLE const hDevice, uint32_t nAlarm
120120
* Local RTC 1 ISR callback function.
121121
*
122122
*/
123-
static void rtc1_Callback (void *pCBParam, uint32_t nEvent, void *EventArg)
123+
static void rtc1_Callback(void *pCBParam, uint32_t nEvent, void *EventArg)
124124
{
125125
/* process RTC interrupts (cleared by driver) */
126126
if (ADI_RTC_ALARM_INT & nEvent) {
@@ -129,16 +129,6 @@ static void rtc1_Callback (void *pCBParam, uint32_t nEvent, void *EventArg)
129129
}
130130

131131

132-
/** Get low power ticker's data
133-
*
134-
* @return The low power ticker data
135-
*/
136-
/*
137-
const ticker_data_t* get_lp_ticker_data()
138-
{
139-
}*/
140-
141-
142132
/* HAL lp ticker */
143133

144134
/** Initialize the low power ticker

targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/objects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct i2c_s {
8585

8686
#define BUILD_SPI_MI_DYNAMIC
8787
struct spi_s {
88-
uint32_t instance;
88+
uint32_t instance;
8989
uint32_t error;
9090
ADI_SPI_HANDLE *pSPI_Handle;
9191
#if defined(BUILD_SPI_MI_DYNAMIC)

targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/serial_api.c

Lines changed: 11 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -135,24 +135,26 @@ void serial_baud(serial_t *obj, int baudrate)
135135

136136
void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits)
137137
{
138-
int convertedparity = ADI_UART_NO_PARITY;
139-
int convertedstopbits = ADI_UART_ONE_STOPBIT;
138+
ADI_UART_PARITY convertedparity = ADI_UART_NO_PARITY;
139+
ADI_UART_STOPBITS convertedstopbits = ADI_UART_ONE_STOPBIT;
140140

141-
if (stop_bits)
141+
if (stop_bits) {
142142
convertedstopbits = ADI_UART_ONE_AND_HALF_TWO_STOPBITS;
143+
}
143144

144-
if (parity == ParityOdd)
145+
if (parity == ParityOdd) {
145146
convertedparity = ADI_UART_ODD_PARITY;
146-
else if (parity == ParityEven)
147+
} else if (parity == ParityEven) {
147148
convertedparity = ADI_UART_EVEN_PARITY;
148-
else if (parity == ParityForced1)
149+
} else if (parity == ParityForced1) {
149150
convertedparity = ADI_UART_ODD_PARITY_STICKY;
150-
else if (parity == ParityForced0)
151+
} else if (parity == ParityForced0) {
151152
convertedparity = ADI_UART_EVEN_PARITY_STICKY;
153+
}
152154

153-
adi_uart_SetConfiguration(hDevice[obj->index], convertedparity, convertedstopbits, (data_bits - 5));
155+
adi_uart_SetConfiguration(hDevice[obj->index], convertedparity, convertedstopbits,
156+
(ADI_UART_WORDLEN)(data_bits - 5));
154157
}
155-
#ifndef ADI_UART_TRANSFER_MODE
156158

157159
void serial_init(serial_t *obj, PinName tx, PinName rx)
158160
{
@@ -212,71 +214,6 @@ void serial_putc(serial_t *obj, int c)
212214
return;
213215
}
214216

215-
#else
216-
217-
void serial_init(serial_t *obj, PinName tx, PinName rx)
218-
{
219-
uint32_t uart_tx = pinmap_peripheral(tx, PinMap_UART_TX);
220-
uint32_t uart_rx = pinmap_peripheral(rx, PinMap_UART_RX);
221-
222-
obj->index = pinmap_merge(uart_tx, uart_rx);
223-
MBED_ASSERT((int)obj->index != NC);
224-
225-
adi_uart_Open(obj->index, ADI_UART_DIR_BIDIRECTION, UartDeviceMem[obj->index], ADI_UART_MEMORY_SIZE, &hDevice[obj->index]);
226-
227-
serial_baud(obj, 9600);
228-
serial_format(obj, 8, ParityNone, 1);
229-
230-
pinmap_pinout(tx, PinMap_UART_TX);
231-
pinmap_pinout(rx, PinMap_UART_RX);
232-
233-
if (tx != NC) {
234-
pin_mode(tx, PullUp);
235-
}
236-
237-
if (rx != NC) {
238-
pin_mode(rx, PullUp);
239-
}
240-
241-
if (obj->index == STDIO_UART) {
242-
stdio_uart_inited = 1;
243-
memcpy(&stdio_uart, obj, sizeof(serial_t));
244-
}
245-
246-
// set maximum FIFO depth
247-
adi_uart_SetRxFifoTriggerLevel(hDevice[obj->index], ADI_UART_RX_FIFO_TRIG_LEVEL_14BYTE);
248-
249-
// enable FIFO
250-
adi_uart_EnableFifo(hDevice[obj->index], true);
251-
}
252-
253-
int serial_getc(serial_t *obj)
254-
{
255-
int c;
256-
uint32_t hwErr;
257-
258-
adi_uart_Read(hDevice[obj->index], (void *) &c, 1, false, &hwErr);
259-
return (c);
260-
}
261-
262-
void serial_putc(serial_t *obj, int c)
263-
{
264-
uint32_t hwErr;
265-
266-
adi_uart_Write(hDevice[obj->index], &c, 1, false, &hwErr);
267-
return;
268-
}
269-
270-
int serial_readable(serial_t *obj)
271-
{
272-
return 0;
273-
}
274-
275-
int serial_writable(serial_t *obj)
276-
{
277-
return 0;
278-
}
279-
#endif
280217
void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
281218
{
282219
MBED_ASSERT(obj);

targets/TARGET_Analog_Devices/TARGET_ADUCM4X50/TARGET_ADUCM4050/api/spi_api.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,24 @@ void spi_free(spi_t *obj)
213213
* 2 | 1 0
214214
* 3 | 1 1
215215
* @endcode
216+
217+
bool phase;
218+
true : trailing-edge
219+
false : leading-edge
220+
221+
bool polarity;
222+
true : CPOL=1 (idle high) polarity
223+
false : CPOL=0 (idle-low) polarity
216224
*/
217225
void spi_format(spi_t *obj, int bits, int mode, int slave)
218226
{
219227
ADI_SPI_HANDLE SPI_Handle;
220228
ADI_SPI_RESULT SPI_Return = ADI_SPI_SUCCESS;
221-
bool_t master;
229+
bool master;
222230

223231
master = !((bool_t)slave);
224232
SPI_Handle = *obj->pSPI_Handle;
233+
225234
SPI_Return = adi_spi_SetMasterMode(SPI_Handle, master);
226235
if (SPI_Return) {
227236
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
309318
ADI_SPI_HANDLE SPI_Handle;
310319
ADI_SPI_RESULT SPI_Return = ADI_SPI_SUCCESS;
311320

312-
transceive.pReceiver = rx_buffer;
313-
transceive.ReceiverBytes = rx_length; /* link transceive data size to the remaining count */
314-
transceive.nRxIncrement = 1; /* auto increment buffer */
315-
transceive.pTransmitter = tx_buffer; /* initialize data attributes */
316-
transceive.TransmitterBytes = tx_length; /* link transceive data size to the remaining count */
317-
transceive.nTxIncrement = 1; /* auto increment buffer */
321+
transceive.pReceiver = (uint8_t*)rx_buffer;
322+
transceive.ReceiverBytes = rx_length; /* link transceive data size to the remaining count */
323+
transceive.nRxIncrement = 1; /* auto increment buffer */
324+
transceive.pTransmitter = (uint8_t*)tx_buffer; /* initialize data attributes */
325+
transceive.TransmitterBytes = tx_length; /* link transceive data size to the remaining count */
326+
transceive.nTxIncrement = 1; /* auto increment buffer */
318327

319328
transceive.bDMA = false;
320329
transceive.bRD_CTL = false;

0 commit comments

Comments
 (0)