Skip to content
Snippets Groups Projects
Commit 1e00c2b4 authored by malo's avatar malo
Browse files

msp430: spi: fixed setting of spi speed


Signed-off-by: default avatarmalo <malo@25cmsquare.io>
parent 5b5810ab
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......@@ -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 */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment