SPI lcd configuration

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • SPI lcd configuration

      Hi.
      I am using STemwin + ILI9341 SPI LCD.
      in FMC configuration we should use some codes like:

      Source Code

      1. /*
      2. * LcdWriteReg
      3. */
      4. static void LcdWriteReg(U16 Data) {
      5. *(uint16_t *)0x60000000 = Data;
      6. }
      7. /*
      8. * LcdWriteData
      9. */
      10. static void LcdWriteData(U16 Data) {
      11. *(uint16_t *)0x60020000 = Data;
      12. }
      13. /*
      14. * LcdWriteDataMultiple
      15. */
      16. static void LcdWriteDataMultiple(U16 * pData, int NumItems) {
      17. while (NumItems--) {
      18. *(uint16_t *)0x60020000 = *pData;
      19. pData++;
      20. }
      21. }
      22. /*
      23. * LcdReadDataMultiple
      24. */
      25. static void LcdReadDataMultiple(U16 * pData, int NumItems) {
      26. while (NumItems--) {
      27. *pData = *(uint16_t *)0x60020000;
      28. pData++;
      29. }
      30. }
      Display All
      in LCDConf_Flexcolor.c file.

      now... the question is how to edit this lines for SPI lcds?
      thanks.
    • solved by:

      Source Code

      1. /*
      2. * LcdWriteReg
      3. */
      4. static void LcdWriteReg(U8 Data) {
      5. HAL_GPIO_WritePin(DC_GPIO_Port, DC_Pin, GPIO_PIN_RESET); //A0 = 0
      6. HAL_SPI_Transmit(&hspi1, &Data, 1, 5);
      7. }
      8. /*
      9. * LcdWriteData
      10. */
      11. static void LcdWriteData(U8 Data) {
      12. HAL_GPIO_WritePin(DC_GPIO_Port, DC_Pin, GPIO_PIN_SET); //A0 = 1
      13. HAL_SPI_Transmit(&hspi1, &Data, 1, 5);
      14. }
      15. /*
      16. * LcdWriteDataMultiple
      17. */
      18. static void LcdWriteDataMultiple(U8 * pData, int NumItems) {
      19. HAL_GPIO_WritePin(DC_GPIO_Port, DC_Pin, GPIO_PIN_SET); //A0 = 1
      20. //while (NumItems--) {
      21. HAL_SPI_Transmit(&hspi1, &*pData, NumItems, 5);
      22. //pData++;
      23. //}
      24. }
      25. /*
      26. * LcdReadDataMultiple
      27. */
      28. static void LcdReadDataMultiple(U8 * pData, int NumItems) {
      29. HAL_GPIO_WritePin(DC_GPIO_Port, DC_Pin, GPIO_PIN_SET); //A0 = 1
      30. //while (NumItems--) {
      31. HAL_SPI_Receive(&hspi1, &*pData, NumItems, 5);
      32. //pData++;
      33. //}
      34. }
      Display All

      and using this "pfwrite"s:

      Source Code

      1. PortAPI.pfWrite8_A0 = LcdWriteReg;
      2. PortAPI.pfWrite8_A1 = LcdWriteData;
      3. PortAPI.pfWriteM8_A1 = LcdWriteDataMultiple;
      4. PortAPI.pfReadM8_A1 = LcdReadDataMultiple;
      5. GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66709, GUIDRV_FLEXCOLOR_M16C0B8);