Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msp430 spi speed fix + USIC/USCI cleanup #5127

Merged
merged 2 commits into from
Mar 24, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
msp430: spi: fixed setting of spi speed
Signed-off-by: malo <malo@25cmsquare.io>
  • Loading branch information
malosek committed Mar 24, 2016
commit 1e00c2b4b7de0c86cd426aec48e7fd356a662b81
24 changes: 18 additions & 6 deletions cpu/msp430fxyz/periph/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,26 @@ int spi_init_master(spi_t dev, spi_conf_t conf, spi_speed_t speed)
switch (speed) {
case SPI_SPEED_100KHZ:
br /= 100000;
break;
case SPI_SPEED_400KHZ:
br /= 400000;
break;
case SPI_SPEED_1MHZ:
br /= 1000000;
break;
case SPI_SPEED_5MHZ:
br /= 5000000;
if (br < 2) { /* make sure the is not smaller then 2 */
br = 2;
}
break;
default:
/* other clock speeds are not supported */
return -1;
}

/* make sure the is not smaller then 2 */
if (br < 2) {
br = 2;
}

SPI_DEV->BR0 = (uint8_t)br;
SPI_DEV->BR1 = (uint8_t)(br >> 8);
SPI_DEV->MCTL = 0;
Expand Down Expand Up @@ -136,20 +142,26 @@ int spi_init_master(spi_t dev, spi_conf_t conf, spi_speed_t speed)
switch (speed) {
case SPI_SPEED_100KHZ:
br /= 100000;
break;
case SPI_SPEED_400KHZ:
br /= 400000;
break;
case SPI_SPEED_1MHZ:
br /= 1000000;
break;
case SPI_SPEED_5MHZ:
br /= 5000000;
if (br < 2) { /* make sure the is not smaller then 2 */
br = 2;
}
break;
default:
/* other clock speeds are not supported */
return -1;
}

/* make sure the is not smaller then 2 */
if (br < 2) {
br = 2;
}

SPI_DEV->BR0 = (uint8_t)br;
SPI_DEV->BR1 = (uint8_t)(br >> 8);
/* release from software reset */
Expand Down