You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
5.4 KiB

5 years ago
  1. /* --COPYRIGHT--,BSD
  2. * Copyright (c) 2013, Texas Instruments Incorporated
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. *
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. *
  12. * * Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. *
  16. * * Neither the name of Texas Instruments Incorporated nor the names of
  17. * its contributors may be used to endorse or promote products derived
  18. * from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  22. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  23. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  24. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  25. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  26. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  27. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  28. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  29. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  30. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. * --/COPYRIGHT--*/
  32. //*****************************************************************************
  33. //
  34. // Close the Doxygen group.
  35. //! @}
  36. //
  37. //*****************************************************************************
  38. //*****************************************************************************
  39. //
  40. // IMPORTANT NOTE: The following driver file has been modified to store
  41. // the LCD DisplayBuffer on FLASH memory. This is due to the limited amount
  42. // of RAM memory on the MSP430G2553 device.
  43. //
  44. //*****************************************************************************
  45. //*****************************************************************************
  46. //
  47. // HAL_MSP-EXP430G2_Sharp96x96.c
  48. //
  49. //*****************************************************************************
  50. //
  51. //! \addtogroup display_api
  52. //! @{
  53. //
  54. //*****************************************************************************
  55. #include <msp430g2553.h>
  56. #include <stdint.h>
  57. #include "grlib.h"
  58. #include "HAL_MSP-EXP430G2_Sharp96x96.h"
  59. //*****************************************************************************
  60. //
  61. //! Initializes the display driver.
  62. //!
  63. //! This function initializes the Sharp96x96 display. This function
  64. //! configures the GPIO pins used to control the LCD display when the basic
  65. //! GPIO interface is in use. On exit, the LCD has been reset and is ready to
  66. //! receive command and data writes.
  67. //!
  68. //! \return None.
  69. //
  70. //*****************************************************************************
  71. void LCDInit(void)
  72. {
  73. // Configure:
  74. // LCD_MOSI_PIN for SPI_MOSI mode
  75. LCD_MOSI_PORT_SEL1 |= LCD_MOSI_PIN;
  76. LCD_MOSI_PORT_SEL2 |= LCD_MOSI_PIN;
  77. // Configure:
  78. // LCD_SCLK_PIN for SPI_CLK mode
  79. LCD_SCLK_PORT_SEL1 |= LCD_SCLK_PIN;
  80. LCD_SCLK_PORT_SEL2 |= LCD_SCLK_PIN;
  81. // Configure LCD_POWER_PIN as output to supply the LCD and LCD_DISP_PIN
  82. // as output for DISP
  83. LCD_POWER_DISP_DIR |= LCD_POWER_PIN + LCD_DISP_PIN;
  84. // Provide power to LCD and turn on DISP pins
  85. LCD_POWER_DISP_PORT |= LCD_POWER_PIN + LCD_DISP_PIN;
  86. // Configure LCD_SCS_PIN as output and clear pin
  87. LCD_SCS_DIR |= LCD_SCLK_PIN;
  88. ClearCS();
  89. // Configure USCIB0 for SPI mode:
  90. // SPI master,
  91. // 3-pin SPI,
  92. // 8-bit data,
  93. // Data is captured on the first UCLK edge and changed on the following edge
  94. // SMCLK sources USCI clock
  95. UCB0CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC;
  96. UCB0CTL1 |= UCSSEL_3;
  97. UCB0BR0 |= 0x08;
  98. UCB0BR1 = 0;
  99. // Initialize USCI state machine
  100. UCB0CTL1 &= ~UCSWRST;
  101. }
  102. //*****************************************************************************
  103. //
  104. //! Initialize DisplayBuffer.
  105. //!
  106. //! \param pvDisplayData is a pointer to the driver-specific data for this
  107. //! display driver.
  108. //!
  109. //! \param ucValue is the foreground color of the buffered data.
  110. //!
  111. //! This function initializes the display buffer and discards any cached data.
  112. //!
  113. //! \return None.
  114. //
  115. //*****************************************************************************
  116. void InitializeDisplayBuffer(void *pvDisplayData, uint8_t ucValue)
  117. {
  118. uint16_t i=0,j=0;
  119. uint8_t *pucData = pvDisplayData;
  120. uint16_t ucSegment = 0;
  121. UnlockFlashMemory();
  122. for(i =0; i< LCD_VERTICAL_MAX; i++){
  123. for(j =0; j< (LCD_HORIZONTAL_MAX>>3); j++){
  124. if(ucSegment==0 && ClrBlack != ucValue){
  125. SetFlashAccessRight(ERASE);
  126. //Dummy write to erase Flash segment
  127. *pucData=0;
  128. SetFlashAccessRight(WRT);
  129. }
  130. while(FCTL3&BUSY);
  131. *pucData++ = ucValue;
  132. ucSegment++;
  133. if(ucSegment == 512)
  134. ucSegment = 0;
  135. }
  136. }
  137. FinishMemoryWrite();
  138. }
  139. //*****************************************************************************
  140. //
  141. // Close the Doxygen group.
  142. //! @}
  143. //
  144. //*****************************************************************************