Skip to content

Commit 446dbe6

Browse files
committed
Clean-up style issues
Fix indentation issues, remove useless comments, correct if/else format
1 parent 1fb5b3f commit 446dbe6

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

targets/TARGET_STM/stm_spi_api.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -289,24 +289,24 @@ static const uint16_t baudrate_prescaler_table[] = {SPI_BAUDRATEPRESCALER_2,
289289

290290
void spi_frequency(spi_t *obj, int hz) {
291291
struct spi_s *spiobj = SPI_S(obj);
292-
int spi_hz = 0;
293-
uint8_t prescaler_rank = 0;
292+
int spi_hz = 0;
293+
uint8_t prescaler_rank = 0;
294294
SPI_HandleTypeDef *handle = &(spiobj->handle);
295295

296-
/* Get the clock of the peripheral */
297-
spi_hz = spi_get_clock_freq(obj);
296+
/* Get the clock of the peripheral */
297+
spi_hz = spi_get_clock_freq(obj);
298298

299-
/* Define pre-scaler in order to get highest available frequency below requested frequency */
300-
while ((spi_hz > hz) && (prescaler_rank < sizeof(baudrate_prescaler_table)/sizeof(baudrate_prescaler_table[0]))){
301-
spi_hz = spi_hz / 2;
302-
prescaler_rank++;
303-
}
299+
/* Define pre-scaler in order to get highest available frequency below requested frequency */
300+
while ((spi_hz > hz) && (prescaler_rank < sizeof(baudrate_prescaler_table)/sizeof(baudrate_prescaler_table[0]))){
301+
spi_hz = spi_hz / 2;
302+
prescaler_rank++;
303+
}
304304

305-
if (prescaler_rank <= sizeof(baudrate_prescaler_table)/sizeof(baudrate_prescaler_table[0])) {
306-
handle->Init.BaudRatePrescaler = baudrate_prescaler_table[prescaler_rank-1];
307-
} else {
308-
error("Couldn't setup requested SPI frequency");
309-
}
305+
if (prescaler_rank <= sizeof(baudrate_prescaler_table)/sizeof(baudrate_prescaler_table[0])) {
306+
handle->Init.BaudRatePrescaler = baudrate_prescaler_table[prescaler_rank-1];
307+
} else {
308+
error("Couldn't setup requested SPI frequency");
309+
}
310310

311311
init_spi(obj);
312312
}
@@ -388,7 +388,6 @@ void spi_slave_write(spi_t *obj, int value)
388388
struct spi_s *spiobj = SPI_S(obj);
389389
SPI_HandleTypeDef *handle = &(spiobj->handle);
390390
while (!ssp_writeable(obj));
391-
//spi->DR = (uint16_t)value;
392391
if (handle->Init.DataSize == SPI_DATASIZE_8BIT) {
393392
// Force 8-bit access to the data register
394393
uint8_t *p_spi_dr = 0;
@@ -427,8 +426,11 @@ static int spi_master_start_asynch_transfer(spi_t *obj, transfer_type_t transfer
427426

428427
obj->spi.transfer_type = transfer_type;
429428

430-
if (is16bit) words = length / 2;
431-
else words = length;
429+
if (is16bit) {
430+
words = length / 2;
431+
} else {
432+
words = length;
433+
}
432434

433435
// enable the interrupt
434436
IRQn_Type irq_n = spiobj->spiIRQ;
@@ -438,7 +440,6 @@ static int spi_master_start_asynch_transfer(spi_t *obj, transfer_type_t transfer
438440
NVIC_EnableIRQ(irq_n);
439441

440442
// enable the right hal transfer
441-
//static uint16_t sink;
442443
int rc = 0;
443444
switch(transfer_type) {
444445
case SPI_TRANSFER_TYPE_TXRX:

0 commit comments

Comments
 (0)