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 048e1aab9cafea868c2beabaf711f91307b954ea Author: YAMAMOTO Takashi <yamam...@midokura.com> AuthorDate: Tue Nov 24 08:57:01 2020 +0900 boards/arm/stm32/stm32f429i-disco/src/stm32_ili93414ws.c: Appease nxstyle --- .../stm32/stm32f429i-disco/src/stm32_ili93414ws.c | 83 ++++++++++++---------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/boards/arm/stm32/stm32f429i-disco/src/stm32_ili93414ws.c b/boards/arm/stm32/stm32f429i-disco/src/stm32_ili93414ws.c index 82f183f..030fc5e 100644 --- a/boards/arm/stm32/stm32f429i-disco/src/stm32_ili93414ws.c +++ b/boards/arm/stm32/stm32f429i-disco/src/stm32_ili93414ws.c @@ -109,8 +109,7 @@ # define ILI93414WS_BAUD_DIVISOR 256 #endif -/* - * Permitted clock delay for a pixel transmission from the LCD gram. +/* Permitted clock delay for a pixel transmission from the LCD gram. * Calculated by cpu clock / (spi clock / baud divisor) */ @@ -126,9 +125,10 @@ #define ILI93414WS_SPI_SR (ILI93414WS_SPI_BASE + STM32_SPI_SR_OFFSET) #define ILI93414WS_SPI_DR (ILI93414WS_SPI_BASE + STM32_SPI_DR_OFFSET) -/* Activates the usage of the spi interface structure if several active devices - * connected on the SPI5 bus, e.g. LCD Display, MEMS. This will perform locking - * of the spi bus by SPI_LOCK at each selection of the SPI5 device. +/* Activates the usage of the spi interface structure if several active + * devices connected on the SPI5 bus, e.g. LCD Display, MEMS. This will + * perform locking of the spi bus by SPI_LOCK at each selection of the SPI5 + * device. */ #ifdef CONFIG_STM32_SPI5 @@ -474,20 +474,19 @@ static int stm32_ili93414ws_sendblock(FAR struct ili93414ws_lcd_s *lcd, { /* 8-bit spi mode */ - const uint8_t *src = (const uint8_t*)wd; - uint8_t word; + const uint8_t *src = (const uint8_t *)wd; + uint8_t word; while (nwords-- > 0) { word = *src++; stm32_ili93414ws_sndword((uint16_t)word); } - } - /* Wait until transmit is not busy after the last word is transmitted, marked - * by the BSY flag in the cr1 register. This is necessary if entering in halt - * mode or disable the spi periphery. + /* Wait until transmit is not busy after the last word is transmitted, + * marked by the BSY flag in the cr1 register. This is necessary if + * entering in halt mode or disable the spi periphery. */ while ((getreg16(ILI93414WS_SPI_SR) & SPI_SR_BSY) != 0); @@ -526,9 +525,9 @@ static uint16_t stm32_ili93414ws_recvword(void) * immediately after enabling it. If the pixel data stream is interrupted * during receiving, a synchronized transfer can not ensure. Especially on * higher frequency it can happen that the interrupted driver isn't fast - * enough to stop transmitting by disabling the spi device. So pixels lost but - * not recognized by the driver. This results in a big lock because the driver - * wants to receive missing pixel data. + * enough to stop transmitting by disabling the spi device. So pixels lost + * but not recognized by the driver. This results in a big lock because + * the driver wants to receive missing pixel data. * The critical section here ensures that the spi device is disabled fast * enough during a pixel is transmitted. */ @@ -541,9 +540,10 @@ static uint16_t stm32_ili93414ws_recvword(void) /* Enable spi device followed by disable the spi device. * - * Ensure that the spi is disabled within 8 or 16 spi clock cycles depending - * on the configured spi bit mode. This is necessary to prevent that the next - * data word is transmitted by the slave before the RX buffer is cleared. + * Ensure that the spi is disabled within 8 or 16 spi clock cycles + * depending on the configured spi bit mode. This is necessary to prevent + * that the next data word is transmitted by the slave before the RX + * buffer is cleared. * Otherwise the RX buffer will be overwritten. * * Physically the spi clock is disabled after the current 8/16 clock cycles @@ -562,12 +562,13 @@ static uint16_t stm32_ili93414ws_recvword(void) leave_critical_section(flags); - /* Waits until the RX buffer is filled with the received data word signalized - * by the spi hardware through the RXNE flag. + /* Waits until the RX buffer is filled with the received data word + * signalized by the spi hardware through the RXNE flag. * A busy loop is preferred against interrupt driven receiving method here - * because this happened fairly often. Also we have to ensure to avoid a big - * lock if the lcd driver doesn't send data anymore. - * A latency of CPU clock / SPI clock * 16 SPI clocks should be enough here. + * because this happened fairly often. Also we have to ensure to avoid a + * big lock if the lcd driver doesn't send data anymore. + * A latency of CPU clock / SPI clock * 16 SPI clocks should be enough + * here. */ for (n = 0; n < ILI93414WS_RECV_CLK * 16; n++) @@ -634,9 +635,11 @@ static int stm32_ili93414ws_recvblock(FAR struct ili93414ws_lcd_s *lcd, /* Discard the first 8 bit dummy */ /* 00000000 RRRRRR00 */ + w1 = stm32_ili93414ws_recvword(); /* GGGGGG00 BBBBBB00 */ + w2 = stm32_ili93414ws_recvword(); *dest++ = (((w1 << 8) & 0xf800) | @@ -696,7 +699,10 @@ static int stm32_ili93414ws_recvblock(FAR struct ili93414ws_lcd_s *lcd, while (nwords--) { - uint8_t r, g, b; + uint8_t r; + uint8_t g; + uint8_t b; + r = (uint8_t)(stm32_ili93414ws_recvword() >> 3); g = (uint8_t)(stm32_ili93414ws_recvword() >> 2); b = (uint8_t)(stm32_ili93414ws_recvword() >> 3); @@ -708,7 +714,7 @@ static int stm32_ili93414ws_recvblock(FAR struct ili93414ws_lcd_s *lcd, { /* 8-bit mode */ - uint8_t *dest = (uint8_t*)wd; + uint8_t *dest = (uint8_t *)wd; while (nwords--) { @@ -792,19 +798,18 @@ static void stm32_ili93414ws_spiconfig(FAR struct ili9341_lcd_s *lcd) FAR struct ili93414ws_lcd_s *priv = (FAR struct ili93414ws_lcd_s *)lcd; irqstate_t flags; - uint16_t clrbitscr1 = SPI_CR1_CPHA|SPI_CR1_CPOL|SPI_CR1_BR_MASK| - SPI_CR1_CRCEN|SPI_CR1_LSBFIRST|SPI_CR1_RXONLY| + uint16_t clrbitscr1 = SPI_CR1_CPHA | SPI_CR1_CPOL | SPI_CR1_BR_MASK | + SPI_CR1_CRCEN | SPI_CR1_LSBFIRST | SPI_CR1_RXONLY | SPI_CR1_DFF; - uint16_t setbitscr1 = SPI_CR1_BIDIOE|SPI_CR1_BIDIMODE|SPI_CR1_MSTR| - SPI_CR1_SSI|SPI_CR1_SSM|ILI93414WS_SPI_BR; + uint16_t setbitscr1 = SPI_CR1_BIDIOE | SPI_CR1_BIDIMODE | SPI_CR1_MSTR | + SPI_CR1_SSI | SPI_CR1_SSM | ILI93414WS_SPI_BR; - uint16_t clrbitscr2 = SPI_CR2_TXEIE|SPI_CR2_RXNEIE|SPI_CR2_ERRIE| - SPI_CR2_FRF|SPI_CR2_SSOE; + uint16_t clrbitscr2 = SPI_CR2_TXEIE | SPI_CR2_RXNEIE | SPI_CR2_ERRIE | + SPI_CR2_FRF | SPI_CR2_SSOE; uint16_t setbitscr2 = 0; - flags = enter_critical_section(); /* Disable spi */ @@ -817,8 +822,8 @@ static void stm32_ili93414ws_spiconfig(FAR struct ili9341_lcd_s *lcd) #ifdef ILI93414WS_SPI /* Backup cr1 and cr2 register to be sure they will be usable - * by default spi interface. Disable spi device here is necessary at the time - * restoring the register during deselection. + * by default spi interface. Disable spi device here is necessary at the + * time restoring the register during deselection. */ priv->cr2 = getreg16(ILI93414WS_SPI_CR2); @@ -887,7 +892,8 @@ static inline void stm32_ili93414ws_cmddata( * ****************************************************************************/ -static int stm32_ili93414ws_backlight(FAR struct ili9341_lcd_s *lcd, int level) +static int stm32_ili93414ws_backlight(FAR struct ili9341_lcd_s *lcd, + int level) { return OK; } @@ -1104,7 +1110,7 @@ static int stm32_ili93414ws_recvparam(FAR struct ili9341_lcd_s *lcd, #endif lcdinfo("param=%04x\n", param); - return stm32_ili93414ws_recvblock(priv, (uint16_t*)param, 1); + return stm32_ili93414ws_recvblock(priv, (uint16_t *)param, 1); } /**************************************************************************** @@ -1147,8 +1153,8 @@ static int stm32_ili93414ws_recvgram(FAR struct ili9341_lcd_s *lcd, * * Returned Value: * On success, this function returns a reference to the LCD control object - * for the specified ILI9341 LCD Single chip driver connected as 4 wire serial - * (spi). NULL is returned on any failure. + * for the specified ILI9341 LCD Single chip driver connected as 4 wire + * serial (spi). NULL is returned on any failure. * ****************************************************************************/ @@ -1194,7 +1200,7 @@ FAR struct ili9341_lcd_s *stm32_ili93414ws_initialize(void) /* Enable spi bus */ - regval= getreg32(STM32_RCC_APB2ENR); + regval = getreg32(STM32_RCC_APB2ENR); regval |= RCC_APB2ENR_SPI5EN; putreg32(regval, STM32_RCC_APB2ENR); @@ -1217,7 +1223,6 @@ FAR struct ili9341_lcd_s *stm32_ili93414ws_initialize(void) priv->dev.recvgram = stm32_ili93414ws_recvgram; priv->dev.backlight = stm32_ili93414ws_backlight; - /* Configure to bidirectional transfer mode */ lcdinfo("Configure spi device %d to bidirectional transfer mode\n",