You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/11/27 11:19:28 UTC

[incubator-nuttx] 21/48: boards/arm/stm32/stm3210e-eval/src/stm32_lcd.c: Appease nxstyle

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 5631b7f4644663e234a3c7c3a051db13ec8ccb40
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Thu Nov 26 12:15:36 2020 +0900

    boards/arm/stm32/stm3210e-eval/src/stm32_lcd.c: Appease nxstyle
---
 boards/arm/stm32/stm3210e-eval/src/stm32_lcd.c | 216 ++++++++++++++-----------
 1 file changed, 124 insertions(+), 92 deletions(-)

diff --git a/boards/arm/stm32/stm3210e-eval/src/stm32_lcd.c b/boards/arm/stm32/stm3210e-eval/src/stm32_lcd.c
index c5d550a..2b82a43 100644
--- a/boards/arm/stm32/stm3210e-eval/src/stm32_lcd.c
+++ b/boards/arm/stm32/stm3210e-eval/src/stm32_lcd.c
@@ -43,15 +43,17 @@
  * 2. Orise Tech SPFD5408B
  * 3. RenesasSP R61580
  *
- * The driver dynamically selects the LCD based on the reported LCD ID value.  However,
- * code size can be reduced by suppressing support for individual LCDs using:
+ * The driver dynamically selects the LCD based on the reported LCD ID value.
+ * However, code size can be reduced by suppressing support for individual
+ * LCDs using:
  *
  *   CONFIG_STM3210E_AM240320_DISABLE
  *   CONFIG_STM3210E_SPFD5408B_DISABLE
  *   CONFIG_STM3210E_R61580_DISABLE
  *
- * Omitting the above (or setting them to "n") enables support for the LCD.  Setting
- * any of the above to "y" will disable support for the corresponding LCD.
+ * Omitting the above (or setting them to "n") enables support for the LCD.
+ * Setting any of the above to "y" will disable support for the
+ * corresponding LCD.
  */
 
 /****************************************************************************
@@ -83,7 +85,8 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
-/* Configuration **********************************************************************/
+/* Configuration ************************************************************/
+
 /* Check contrast selection */
 
 #if !defined(CONFIG_LCD_MAXCONTRAST)
@@ -159,7 +162,8 @@
 
 #define SPFD5408B_RDSHIFT 5
 
-/* Display/Color Properties ***********************************************************/
+/* Display/Color Properties *************************************************/
+
 /* Display Resolution */
 
 #ifdef CONFIG_LCD_LANDSCAPE
@@ -175,7 +179,8 @@
 #define STM3210E_BPP          16
 #define STM3210E_COLORFMT     FB_FMT_RGB16_565
 
-/* STM3210E-EVAL LCD Hardware Definitions *********************************************/
+/* STM3210E-EVAL LCD Hardware Definitions ***********************************/
+
 /* LCD /CS is CE4,  Bank 4 of NOR/SRAM Bank 1~4 */
 
 #define STM3210E_LCDBASE      ((uint32_t)(0x60000000 | 0x0c000000))
@@ -340,6 +345,7 @@ struct stm3210e_dev_s
 /****************************************************************************
  * Private Function Protototypes
  ****************************************************************************/
+
 /* Low Level LCD access */
 
 static void stm3210e_writereg(uint8_t regaddr, uint16_t regval);
@@ -356,17 +362,20 @@ static void stm3210e_setcursor(uint16_t col, uint16_t row);
 
 /* LCD Data Transfer Methods */
 
-static int stm3210e_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer,
-             size_t npixels);
-static int stm3210e_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
-             size_t npixels);
+static int stm3210e_putrun(fb_coord_t row, fb_coord_t col,
+                           FAR const uint8_t *buffer,
+                           size_t npixels);
+static int stm3210e_getrun(fb_coord_t row, fb_coord_t col,
+                           FAR uint8_t *buffer,
+                           size_t npixels);
 
 /* LCD Configuration */
 
 static int stm3210e_getvideoinfo(FAR struct lcd_dev_s *dev,
              FAR struct fb_videoinfo_s *vinfo);
-static int stm3210e_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno,
-             FAR struct lcd_planeinfo_s *pinfo);
+static int stm3210e_getplaneinfo(FAR struct lcd_dev_s *dev,
+                                 unsigned int planeno,
+                                 FAR struct lcd_planeinfo_s *pinfo);
 
 /* LCD RGB Mapping */
 
@@ -385,7 +394,8 @@ static int stm3210e_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno
 static int stm3210e_getpower(struct lcd_dev_s *dev);
 static int stm3210e_setpower(struct lcd_dev_s *dev, int power);
 static int stm3210e_getcontrast(struct lcd_dev_s *dev);
-static int stm3210e_setcontrast(struct lcd_dev_s *dev, unsigned int contrast);
+static int stm3210e_setcontrast(struct lcd_dev_s *dev,
+                                unsigned int contrast);
 
 /* LCD Power Management */
 
@@ -436,10 +446,10 @@ static const struct fb_videoinfo_s g_videoinfo =
 
 static const struct lcd_planeinfo_s g_planeinfo =
 {
-  .putrun = stm3210e_putrun,       /* Put a run into LCD memory */
-  .getrun = stm3210e_getrun,       /* Get a run from LCD memory */
-  .buffer = (uint8_t*)g_runbuffer, /* Run scratch buffer */
-  .bpp    = STM3210E_BPP,          /* Bits-per-pixel */
+  .putrun = stm3210e_putrun,        /* Put a run into LCD memory */
+  .getrun = stm3210e_getrun,        /* Get a run from LCD memory */
+  .buffer = (uint8_t *)g_runbuffer, /* Run scratch buffer */
+  .bpp    = STM3210E_BPP,           /* Bits-per-pixel */
 };
 
 /* This is the standard, NuttX LCD driver object */
@@ -454,6 +464,7 @@ static struct stm3210e_dev_s g_lcddev =
     .getplaneinfo = stm3210e_getplaneinfo,
 
     /* LCD RGB Mapping -- Not supported */
+
     /* Cursor Controls -- Not supported */
 
     /* LCD Specific Controls */
@@ -473,7 +484,6 @@ static struct pm_callback_s g_lcdcb =
 };
 #endif
 
-
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
@@ -542,9 +552,9 @@ static inline void stm3210e_writegram(uint16_t rgbval)
  * Name:  stm3210e_readsetup / stm3210e_readnosetup
  *
  * Description:
- *   Prime the operation by reading one pixel from the GRAM memory if necessary for
- *   this LCD type.  When reading 16-bit gram data, there may be some shifts in the
- *   returned data:
+ *   Prime the operation by reading one pixel from the GRAM memory if
+ *   necessary for this LCD type.  When reading 16-bit gram data, there may
+ *   be some shifts in the returned data:
  *
  *   - SPFD5408B:  There appears to be a 5-bit shift in the returned data.
  *   - R61580:     There is a 16-bit (1 pixel) shift in the returned data.
@@ -575,8 +585,8 @@ static void stm3210e_readnosetup(FAR uint16_t *accum)
  * Name:  stm3210e_readshift / stm3210e_readnoshift
  *
  * Description:
- *   Read one correctly aligned pixel from the GRAM memory.  Possibly shifting the
- *   data and possibly swapping red and green components.
+ *   Read one correctly aligned pixel from the GRAM memory.  Possibly
+ *   shifting the data and possibly swapping red and green components.
  *
  *   - SPFD5408B:  There appears to be a 5-bit shift in the returned data.
  *                 Red and green appear to be swapped on read-back as well
@@ -586,8 +596,8 @@ static void stm3210e_readnosetup(FAR uint16_t *accum)
  *
  ****************************************************************************/
 
-/* This version is used only for the SPFD5408B.  It shifts the data by 5-bits and swaps
- * red and green
+/* This version is used only for the SPFD5408B.  It shifts the data by
+ * 5-bits and swaps red and green
  */
 
 #ifndef CONFIG_STM3210E_SPFD5408B_DISABLE
@@ -601,7 +611,8 @@ static uint16_t stm3210e_readshift(FAR uint16_t *accum)
 
   uint16_t next = LCD->value;
 
-  /* Return previous bits 0-10 as bits 6-15 and next data bits 11-15 as bits 0-5
+  /* Return previous bits 0-10 as bits 6-15 and next data bits 11-15 as
+   * bits 0-5
    *
    *   xxxx xPPP PPPP PPPP
    *   NNNN Nxxx xxxx xxxx
@@ -609,7 +620,8 @@ static uint16_t stm3210e_readshift(FAR uint16_t *accum)
    * Assuming that SPFD5408B_RDSHIFT == 5
    */
 
-  uint16_t value  = *accum << SPFD5408B_RDSHIFT | next >> (16-SPFD5408B_RDSHIFT);
+  uint16_t value  = *accum << SPFD5408B_RDSHIFT |
+                    next >> (16 - SPFD5408B_RDSHIFT);
 
   /* Save the value for the next time we are called */
 
@@ -617,9 +629,9 @@ static uint16_t stm3210e_readshift(FAR uint16_t *accum)
 
   /* Tear the RGB655 apart. Swap read and green */
 
-  red   = (value << (11-5)) & 0xf800; /* Move bits 5-9 to 11-15 */
-  green = (value >> (10-5)) & 0x07e0; /* Move bits 10-15 to bits 5-10 */
-  blue  =  value            & 0x001f; /* Blue is in the right place */
+  red   = (value << (11 - 5)) & 0xf800; /* Move bits 5-9 to 11-15 */
+  green = (value >> (10 - 5)) & 0x07e0; /* Move bits 10-15 to bits 5-10 */
+  blue  =  value              & 0x001f; /* Blue is in the right place */
 
   /* And put the RGB565 back together */
 
@@ -627,7 +639,8 @@ static uint16_t stm3210e_readshift(FAR uint16_t *accum)
 
   /* This is weird... If blue is zero, then red+green values are off by 0x20.
    * Except that both 0x0000 and 0x0020 can map to 0x0000.  Need to revisit
-   * this!!!!!!!!!!!  I might be misinterpreting some of the data that I have.
+   * this!!!!!!!!!!!  I might be misinterpreting some of the data that I
+   * have.
    */
 
 #if 0 /* REVISIT */
@@ -641,8 +654,8 @@ static uint16_t stm3210e_readshift(FAR uint16_t *accum)
 }
 #endif
 
-/* This version is used for the R61580 and for the AM240320.  It neither shifts nor
- * swaps colors.
+/* This version is used for the R61580 and for the AM240320.  It neither
+ * shifts nor swaps colors.
  */
 
 #if !defined(CONFIG_STM3210E_R61580_DISABLE) || !defined(CONFIG_STM3210E_AM240320_DISABLE)
@@ -658,8 +671,8 @@ static uint16_t stm3210e_readnoshift(FAR uint16_t *accum)
  * Name:  stm3210e_setcursor
  *
  * Description:
- *   Set the cursor position.  In landscape mode, the "column" is actually the physical
- *   Y position and the "row" is the physical X position.
+ *   Set the cursor position.  In landscape mode, the "column" is actually
+ *   the physical Y position and the "row" is the physical X position.
  *
  ****************************************************************************/
 
@@ -681,9 +694,11 @@ static void stm3210e_setcursor(uint16_t col, uint16_t row)
  ****************************************************************************/
 
 #if 0 /* Sometimes useful */
-static void stm3210e_dumprun(FAR const char *msg, FAR uint16_t *run, size_t npixels)
+static void stm3210e_dumprun(FAR const char *msg, FAR uint16_t *run,
+                             size_t npixels)
 {
-  int i, j;
+  int i;
+  int j;
 
   syslog(LOG_DEBUG, "\n%s:\n", msg);
   for (i = 0; i < npixels; i += 16)
@@ -714,10 +729,11 @@ static void stm3210e_dumprun(FAR const char *msg, FAR uint16_t *run, size_t npix
  *
  ****************************************************************************/
 
-static int stm3210e_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer,
-                       size_t npixels)
+static int stm3210e_putrun(fb_coord_t row, fb_coord_t col,
+                           FAR const uint8_t *buffer,
+                           size_t npixels)
 {
-  FAR const uint16_t *src = (FAR const uint16_t*)buffer;
+  FAR const uint16_t *src = (FAR const uint16_t *)buffer;
   int i;
 
   /* Buffer must be provided and aligned to a 16-bit address boundary */
@@ -728,11 +744,11 @@ static int stm3210e_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *bu
   /* Write the run to GRAM. */
 
 #ifdef CONFIG_LCD_LANDSCAPE
-  /* Convert coordinates -- Which edge of the display is the "top?" Here the edge
-   * with the simplest conversion is used.
+  /* Convert coordinates -- Which edge of the display is the "top?" Here the
+   * edge with the simplest conversion is used.
    */
 
-  col = (STM3210E_XRES-1) - col;
+  col = (STM3210E_XRES - 1) - col;
 
   /* Set the cursor position */
 
@@ -743,7 +759,9 @@ static int stm3210e_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *bu
   stm3210e_gramselect();
   for (i = 0; i < npixels; i++)
     {
-      /* Write the next pixel to this position (auto-decrements to the next column) */
+      /* Write the next pixel to this position (auto-decrements to the next
+       * column)
+       */
 
       stm3210e_writegram(*src++);
     }
@@ -769,8 +787,8 @@ static int stm3210e_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *bu
    * Which edge of the display is the "top"?
    */
 
-  col = (STM3210E_XRES-1) - col;
-  row = (STM3210E_YRES-1) - row;
+  col = (STM3210E_XRES - 1) - col;
+  row = (STM3210E_YRES - 1) - row;
 
   /* Then write the GRAM data, manually incrementing Y (which is col) */
 
@@ -787,6 +805,7 @@ static int stm3210e_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *bu
       col--;
     }
 #endif
+
   return OK;
 }
 
@@ -804,10 +823,11 @@ static int stm3210e_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *bu
  *
  ****************************************************************************/
 
-static int stm3210e_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
-                       size_t npixels)
+static int stm3210e_getrun(fb_coord_t row, fb_coord_t col,
+                           FAR uint8_t *buffer,
+                           size_t npixels)
 {
-  FAR uint16_t *dest = (FAR uint16_t*)buffer;
+  FAR uint16_t *dest = (FAR uint16_t *)buffer;
   void (*readsetup)(FAR uint16_t *accum);
   uint16_t (*readgram)(FAR uint16_t *accum);
   uint16_t accum;
@@ -850,11 +870,11 @@ static int stm3210e_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
   /* Read the run from GRAM. */
 
 #ifdef CONFIG_LCD_LANDSCAPE
-  /* Convert coordinates -- Which edge of the display is the "top?" Here the edge
-   * with the simplest conversion is used.
+  /* Convert coordinates -- Which edge of the display is the "top?" Here the
+   * edge with the simplest conversion is used.
    */
 
-  col = (STM3210E_XRES-1) - col;
+  col = (STM3210E_XRES - 1) - col;
 
   /* Set the cursor position */
 
@@ -870,7 +890,9 @@ static int stm3210e_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
 
   for (i = 0; i < npixels; i++)
     {
-      /* Read the next pixel from this position (autoincrements to the next row) */
+      /* Read the next pixel from this position (autoincrements to the next
+       * row)
+       */
 
       *dest++ = readgram(&accum);
     }
@@ -897,8 +919,8 @@ static int stm3210e_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
    * Which edge of the display is the "top"?
    */
 
-  col = (STM3210E_XRES-1) - col;
-  row = (STM3210E_YRES-1) - row;
+  col = (STM3210E_XRES - 1) - col;
+  row = (STM3210E_YRES - 1) - row;
 
   /* Then write the GRAM data, manually incrementing Y (which is col) */
 
@@ -933,7 +955,8 @@ static int stm3210e_getvideoinfo(FAR struct lcd_dev_s *dev,
 {
   DEBUGASSERT(dev && vinfo);
   ginfo("fmt: %d xres: %d yres: %d nplanes: %d\n",
-         g_videoinfo.fmt, g_videoinfo.xres, g_videoinfo.yres, g_videoinfo.nplanes);
+         g_videoinfo.fmt, g_videoinfo.xres,
+         g_videoinfo.yres, g_videoinfo.nplanes);
   memcpy(vinfo, &g_videoinfo, sizeof(struct fb_videoinfo_s));
   return OK;
 }
@@ -946,8 +969,9 @@ static int stm3210e_getvideoinfo(FAR struct lcd_dev_s *dev,
  *
  ****************************************************************************/
 
-static int stm3210e_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno,
-                              FAR struct lcd_planeinfo_s *pinfo)
+static int stm3210e_getplaneinfo(FAR struct lcd_dev_s *dev,
+                                 unsigned int planeno,
+                                 FAR struct lcd_planeinfo_s *pinfo)
 {
   DEBUGASSERT(dev && pinfo && planeno == 0);
   ginfo("planeno: %d bpp: %d\n", planeno, g_planeinfo.bpp);
@@ -959,8 +983,9 @@ static int stm3210e_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno
  * Name:  stm3210e_getpower
  *
  * Description:
- *   Get the LCD panel power status (0: full off - CONFIG_LCD_MAXPOWER: full on). On
- *   backlit LCDs, this setting may correspond to the backlight setting.
+ *   Get the LCD panel power status (0: full off - CONFIG_LCD_MAXPOWER:
+ *   full on). On backlit LCDs, this setting may correspond to the backlight
+ *   setting.
  *
  ****************************************************************************/
 
@@ -974,8 +999,9 @@ static int stm3210e_getpower(struct lcd_dev_s *dev)
  * Name:  stm3210e_poweroff
  *
  * Description:
- *   Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On
- *   backlit LCDs, this setting may correspond to the backlight setting.
+ *   Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER:
+ *   full on). On backlit LCDs, this setting may correspond to the backlight
+ *   setting.
  *
  ****************************************************************************/
 
@@ -1011,8 +1037,9 @@ static int stm3210e_poweroff(void)
  * Name:  stm3210e_setpower
  *
  * Description:
- *   Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On
- *   backlit LCDs, this setting may correspond to the backlight setting.
+ *   Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER:
+ *   full on). On backlit LCDs, this setting may correspond to the backlight
+ *   setting.
  *
  ****************************************************************************/
 
@@ -1029,7 +1056,9 @@ static int stm3210e_setpower(struct lcd_dev_s *dev, int power)
       uint32_t frac;
       uint32_t duty;
 
-      /* If we are coming up from the power off state, then re-configure the timer */
+      /* If we are coming up from the power off state, then re-configure
+       * the timer
+       */
 
       if (g_lcddev.power == 0)
         {
@@ -1065,7 +1094,9 @@ static int stm3210e_setpower(struct lcd_dev_s *dev, int power)
 
 #ifndef CONFIG_STM3210E_AM240320_DISABLE
 #  if !defined (CONFIG_STM3210E_SPFD5408B_DISABLE) || !defined(CONFIG_STM3210E_R61580_DISABLE)
-      stm3210e_writereg(LCD_REG_7, g_lcddev.type == LCD_TYPE_AM240320 ? 0x0173 : 0x0112);
+      stm3210e_writereg(LCD_REG_7,
+                        g_lcddev.type == LCD_TYPE_AM240320 ?
+                                         0x0173 : 0x0112);
 #  else
       stm3210e_writereg(LCD_REG_7, 0x0173);
 #  endif
@@ -1211,7 +1242,7 @@ static void stm3210e_pm_notify(struct pm_callback_s *cb, int domain,
               stm3210e_writereg(LCD_REG_24, 0xc0); /* CP1, CP2, CP3 turn off */
               up_mdelay(10);                       /* wait 10 ms */
 
-              stm3210e_writereg(LCD_REG_24, 0x00); /* VR1 / VR2 off*/
+              stm3210e_writereg(LCD_REG_24, 0x00); /* VR1 / VR2 off */
               stm3210e_writereg(LCD_REG_28, 0x30); /* Step up circuit operating current stop */
               up_mdelay(10);
 
@@ -1231,7 +1262,6 @@ static void stm3210e_pm_notify(struct pm_callback_s *cb, int domain,
       default:
         {
           /* Should not get here */
-
         }
         break;
     }
@@ -1276,8 +1306,8 @@ static void stm3210e_pm_notify(struct pm_callback_s *cb, int domain,
 static int stm3210e_pm_prepare(struct pm_callback_s *cb, int domain,
                                enum pm_state_e pmstate)
 {
-  /* No preparation to change power modes is required by the LCD driver.  We always
-   * accept the state change by returning OK.
+  /* No preparation to change power modes is required by the LCD driver.
+   * We always accept the state change by returning OK.
    */
 
   return OK;
@@ -1296,8 +1326,8 @@ static inline void stm3210e_lcdinitialize(void)
 {
   uint16_t id;
 
-  /* Check if the LCD is Orise Tech SPFD5408B Controller (or the compatible RenesasSP
-   * R61580).
+  /* Check if the LCD is Orise Tech SPFD5408B Controller (or the compatible
+   * RenesasSP R61580).
    */
 
   id = stm3210e_readreg(LCD_REG_0);
@@ -1337,7 +1367,7 @@ static inline void stm3210e_lcdinitialize(void)
       stm3210e_writereg(LCD_REG_17,  0x0007);  /* DC1[2:0], DC0[2:0], VC[2:0] */
       up_mdelay(50);
 
-      stm3210e_writereg(LCD_REG_16,  0x12B0);  /* SAP, BT[3:0], AP, DSTB, SLP, STB */
+      stm3210e_writereg(LCD_REG_16,  0x12b0);  /* SAP, BT[3:0], AP, DSTB, SLP, STB */
       up_mdelay(50);
 
       stm3210e_writereg(LCD_REG_18,  0x01bd);  /* External reference voltage= Vci */
@@ -1350,7 +1380,7 @@ static inline void stm3210e_lcdinitialize(void)
       stm3210e_writereg(LCD_REG_32,  0x0000); /* GRAM horizontal Address */
       stm3210e_writereg(LCD_REG_33,  0x013f); /* GRAM Vertical Address */
 
-      /* Adjust the Gamma Curve (SPFD5408B)*/
+      /* Adjust the Gamma Curve (SPFD5408B) */
 
       stm3210e_writereg(LCD_REG_48,  0x0b0d);
       stm3210e_writereg(LCD_REG_49,  0x1923);
@@ -1577,7 +1607,7 @@ static inline void stm3210e_lcdinitialize(void)
 #else
       lcderr("ERROR: Unsupported LCD type\n");
 #endif
-  }
+    }
 }
 
 /****************************************************************************
@@ -1604,7 +1634,8 @@ static void stm3210e_backlight(void)
 
   /* Calculate the TIM1 prescaler value */
 
-  prescaler = (STM32_PCLK2_FREQUENCY / CONFIG_STM3210E_LCD_PWMFREQUENCY + 65534) / 65535;
+  prescaler = (STM32_PCLK2_FREQUENCY / CONFIG_STM3210E_LCD_PWMFREQUENCY +
+               65534) / 65535;
   if (prescaler < 1)
     {
       prescaler = 1;
@@ -1649,11 +1680,11 @@ static void stm3210e_backlight(void)
 
   /* Set the Autoreload value */
 
-  putreg16(reload-1, STM32_TIM1_ARR);
+  putreg16(reload - 1, STM32_TIM1_ARR);
 
   /* Set the Prescaler value */
 
-  putreg16(prescaler-1, STM32_TIM1_PSC);
+  putreg16(prescaler - 1, STM32_TIM1_PSC);
 
   /* Generate an update event to reload the Prescaler value immediately */
 
@@ -1696,15 +1727,15 @@ static void stm3210e_backlight(void)
 
   /* Select the output polarity level == LOW and enable */
 
-  ccer |= (ATIM_CCER_CC1E );
+  ccer |= (ATIM_CCER_CC1E);
 
   /* Reset the Output N Polarity level */
 
-  ccer &= ~(ATIM_CCER_CC1NP|ATIM_CCER_CC1NE);
+  ccer &= ~(ATIM_CCER_CC1NP | ATIM_CCER_CC1NE);
 
   /* Reset the Output Compare and Output Compare N IDLE State */
 
-  cr2 &= ~(ATIM_CR2_OIS1|ATIM_CR2_OIS1N);
+  cr2 &= ~(ATIM_CR2_OIS1 | ATIM_CR2_OIS1N);
 
   /* Write the timer configuration */
 
@@ -1754,9 +1785,9 @@ static void stm3210e_backlight(void)
  * Name:  board_lcd_initialize
  *
  * Description:
- *   Initialize the LCD video hardware.  The initial state of the LCD is fully
- *   initialized, display memory cleared, and the LCD ready to use, but with the power
- *   setting at 0 (full off).
+ *   Initialize the LCD video hardware.  The initial state of the LCD is
+ *   fully initialized, display memory cleared, and the LCD ready to use,
+ *   but with the power setting at 0 (full off).
  *
  ****************************************************************************/
 
@@ -1801,8 +1832,8 @@ int board_lcd_initialize(void)
  * Name:  board_lcd_getdev
  *
  * Description:
- *   Return a a reference to the LCD object for the specified LCD.  This allows support
- *   for multiple LCD devices.
+ *   Return a a reference to the LCD object for the specified LCD.  This
+ *   allows support for multiple LCD devices.
  *
  ****************************************************************************/
 
@@ -1830,10 +1861,11 @@ void board_lcd_uninitialize(void)
  * Name:  stm3210e_lcdclear
  *
  * Description:
- *   This is a non-standard LCD interface just for the STM3210E-EVAL board.  Because
- *   of the various rotations, clearing the display in the normal way by writing a
- *   sequences of runs that covers the entire display can be very slow.  Here the
- *   display is cleared by simply setting all GRAM memory to the specified color.
+ *   This is a non-standard LCD interface just for the STM3210E-EVAL board.
+ *   Because of the various rotations, clearing the display in the normal
+ *   way by writing a sequences of runs that covers the entire display can
+ *   be very slow.  Here the display is cleared by simply setting all GRAM
+ *   memory to the specified color.
  *
  ****************************************************************************/
 
@@ -1841,7 +1873,7 @@ void stm3210e_lcdclear(uint16_t color)
 {
   uint32_t i = 0;
 
-  stm3210e_setcursor(0, STM3210E_XRES-1);
+  stm3210e_setcursor(0, STM3210E_XRES - 1);
   stm3210e_gramselect();
   for (i = 0; i < STM3210E_XRES * STM3210E_YRES; i++)
     {