Skip to content

Commit

Permalink
[SUASH ME] cpu/stm32f0: reacted to cppcheck warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
haukepetersen committed Sep 26, 2014
1 parent 0675659 commit ed3e265
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions cpu/stm32f0/periph/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@

int spi_init_master(spi_t dev, spi_conf_t conf, spi_speed_t speed)
{
SPI_TypeDef *spi = 0;
GPIO_TypeDef *port = 0;
SPI_TypeDef *spi;
GPIO_TypeDef *port;
int pin[3]; /* 3 pins: sck, miso, mosi */
int af;
int af = 0;

/* power on the SPI device */
spi_poweron(dev);
Expand Down Expand Up @@ -62,6 +62,8 @@ int spi_init_master(spi_t dev, spi_conf_t conf, spi_speed_t speed)
SPI_0_PORT_CLKEN();
break;
#endif
default:
return -1;
}

/* configure pins for their correct alternate function */
Expand Down Expand Up @@ -133,6 +135,8 @@ int spi_transfer_byte(spi_t dev, char out, char *in)
spi = SPI_1_DEV;
break;
#endif
default:
return 0;
}

/* wait for an eventually previous byte to be readily transferred */
Expand All @@ -154,20 +158,21 @@ int spi_transfer_byte(spi_t dev, char out, char *in)
int spi_transfer_bytes(spi_t dev, char *out, char *in, unsigned int length)
{
char res;
int count = 0;

for (int i = 0; i < length; i++) {
if (out) {
spi_transfer_byte(dev, out[i], &res);
count += spi_transfer_byte(dev, out[i], &res);
}
else {
spi_transfer_byte(dev, 0, &res);
count += spi_transfer_byte(dev, 0, &res);
}
if (in) {
in[i] = res;
}
}

return length;
return count;
}

int spi_transfer_reg(spi_t dev, uint8_t reg, char out, char *in)
Expand Down

0 comments on commit ed3e265

Please sign in to comment.