mbed w/ spi bug fig

Dependents:   display-puck

Fork of mbed-src by mbed official

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Sun May 25 08:00:07 2014 +0100
Parent:
210:45934c3d812a
Child:
212:34d62c0b2af6
Commit message:
Synchronized with git revision 6d53312090cb63310e39d12eaa59a3b638350b4a

Full URL: https://github.com/mbedmicro/mbed/commit/6d53312090cb63310e39d12eaa59a3b638350b4a/

[NUCLEO_L053R8] Add object pin init for SPI + typo for I2C

Changed in this revision

targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/i2c_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/spi_api.c Show annotated file Show diff for this revision Revisions of this file
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/i2c_api.c	Fri May 23 14:00:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/i2c_api.c	Sun May 25 08:00:07 2014 +0100
@@ -165,8 +165,8 @@
 
     /* update CR2 register */
     i2c->CR2 = (i2c->CR2 & (uint32_t)~((uint32_t)(I2C_CR2_SADD | I2C_CR2_NBYTES | I2C_CR2_RELOAD | I2C_CR2_AUTOEND | I2C_CR2_RD_WRN | I2C_CR2_START | I2C_CR2_STOP)))
-             | (uint32_t)(((uint32_t)address & I2C_CR2_SADD) | (((uint32_t)length << 16 ) & I2C_CR2_NBYTES) | (uint32_t)I2C_SOFTEND_MODE | (uint32_t)I2C_GENERATE_START_READ);
-            
+               | (uint32_t)(((uint32_t)address & I2C_CR2_SADD) | (((uint32_t)length << 16) & I2C_CR2_NBYTES) | (uint32_t)I2C_SOFTEND_MODE | (uint32_t)I2C_GENERATE_START_READ);
+
     // Read all bytes
     for (count = 0; count < length; count++) {
         value = i2c_byte_read(obj, 0);
@@ -181,7 +181,8 @@
             return 0;
         }
     }
-    __HAL_I2C_CLEAR_FLAG(&I2cHandle,I2C_FLAG_TC);
+
+    __HAL_I2C_CLEAR_FLAG(&I2cHandle, I2C_FLAG_TC);
 
     // If not repeated start, send stop.
     if (stop) {
@@ -211,10 +212,8 @@
 
     /* update CR2 register */
     i2c->CR2 = (i2c->CR2 & (uint32_t)~((uint32_t)(I2C_CR2_SADD | I2C_CR2_NBYTES | I2C_CR2_RELOAD | I2C_CR2_AUTOEND | I2C_CR2_RD_WRN | I2C_CR2_START | I2C_CR2_STOP)))
-             | (uint32_t)(((uint32_t)address & I2C_CR2_SADD) | (((uint32_t)length << 16 ) & I2C_CR2_NBYTES) | (uint32_t)I2C_SOFTEND_MODE | (uint32_t)I2C_GENERATE_START_WRITE);
-   
+               | (uint32_t)(((uint32_t)address & I2C_CR2_SADD) | (((uint32_t)length << 16) & I2C_CR2_NBYTES) | (uint32_t)I2C_SOFTEND_MODE | (uint32_t)I2C_GENERATE_START_WRITE);
 
-    
     for (count = 0; count < length; count++) {
         i2c_byte_write(obj, data[count]);
     }
@@ -225,9 +224,10 @@
         timeout--;
         if (timeout == 0) {
             return 0;
-    }
+        }
     }
-    __HAL_I2C_CLEAR_FLAG(&I2cHandle,I2C_FLAG_TC);
+
+    __HAL_I2C_CLEAR_FLAG(&I2cHandle, I2C_FLAG_TC);
 
     // If not repeated start, send stop.
     if (stop) {
@@ -275,7 +275,7 @@
     }
 
     i2c->TXDR = (uint8_t)data;
-    
+
     return 1;
 }
 
@@ -355,7 +355,7 @@
 
 int i2c_slave_read(i2c_t *obj, char *data, int length) {
     char size = 0;
-  
+
     if (length == 0) return 0;
 
     while (size < length) data[size++] = (char)i2c_byte_read(obj, 0);
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/spi_api.c	Fri May 23 14:00:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/spi_api.c	Sun May 25 08:00:07 2014 +0100
@@ -129,6 +129,11 @@
     obj->cpha = SPI_PHASE_1EDGE;
     obj->br_presc = SPI_BAUDRATEPRESCALER_256;
 
+    obj->pin_miso = miso;
+    obj->pin_mosi = mosi;
+    obj->pin_sclk = sclk;
+    obj->pin_ssel = ssel;
+
     if (ssel == NC) { // SW NSS Master mode
         obj->mode = SPI_MODE_MASTER;
         obj->nss = SPI_NSS_SOFT;