Digital Power Starter Kit 3 Firmware
dsPIC33C Buck Converter Voltage Mode Control Example
drv_lcd_interface.c
1 //======================================================================================================================
2 // Copyright(c) 2018 Microchip Technology Inc. and its subsidiaries.
3 // Subject to your compliance with these terms, you may use Microchip software and any derivatives exclusively with
4 // Microchip products. It is your responsibility to comply with third party license terms applicable to your use of
5 // third-party software (including open source software) that may accompany Microchip software.
6 // THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO
7 // THIS SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR
8 // PURPOSE.
9 // IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE,
10 // COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED
11 // OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY
12 // ON ALL CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, THAT YOU HAVE
13 // PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
14 //======================================================================================================================
15 
16 //======================================================================================================================
17 // @file drv_lcd_interface.c
18 // @brief driver for the spi-interface to access the LCD controller
19 //======================================================================================================================
20 
21 #include <stdint.h>
22 #include "common/delay.h"
23 #include "config/hal.h"
24 
25 
26 // PRIVATE FUNCTION CALL PROTOTYPES
27 void drv_LcdInterface_SpiSend(uint8_t data);
28 
29 
35 #define LCD_CS_nSELECTED LCD_CS_SetHigh
36 #define LCD_CS_SELECTED LCD_CS_SetLow
37 
38 #define LCD_RS_COMMAND LCD_RS_SetLow
39 #define LCD_RS_DATA LCD_RS_SetHigh
40  // end of group lib-driver-layer-lcd-interface-properties-private
42 
43 
53 {
58  LCD_RS_SetLow();
59 
65 }
66 
67 
77 {
79  __delay_ms(25);
81 }
82 
83 
92 void drv_LcdInterface_SendCmd(uint8_t cmd)
93 {
97 }
98 
99 
108 extern void drv_LcdInterface_SendChar(const char c)
109 {
110  LCD_CS_SELECTED();
111  LCD_RS_DATA();
113 }
114 
115 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
116 // PRIVATE FUNCTIONS
117 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
118 
119 
128 void drv_LcdInterface_SpiSend(uint8_t data)
129 {
130  uint8_t mask;
131 
132  for(mask = 0x80; mask != 0; mask >>= 1)
133  {
134  LCD_SCL_SetLow();
135  Nop();
136  __delay_us(1);
137  if(data & mask)
138  LCD_SDI_SetHigh();
139  else
140  LCD_SDI_SetLow();
141  LCD_SCL_SetHigh();
142  Nop();
143  __delay_us(1);
144  }
146  __delay_us(50);
147 }
148 
149 
150 
151 // end of file
LCD_RS_SetLow
#define LCD_RS_SetLow()
Definition: dpsk3_hwdescr.h:1628
drv_LcdInterface_SpiSend
void drv_LcdInterface_SpiSend(uint8_t data)
Sends data through the SPI interface to the LCD controller.
Definition: drv_lcd_interface.c:128
drv_LcdInterface_Initialize
void drv_LcdInterface_Initialize(void)
Initializes the LCD interface driver.
Definition: drv_lcd_interface.c:52
LCD_CS_nSELECTED
#define LCD_CS_nSELECTED
Initial interface pin state conditions.
Definition: drv_lcd_interface.c:35
LCD_RST_SetDigitalOutput
#define LCD_RST_SetDigitalOutput()
Definition: dpsk3_hwdescr.h:1625
LCD_RST_SetLow
#define LCD_RST_SetLow()
Definition: dpsk3_hwdescr.h:1621
LCD_SCL_SetHigh
#define LCD_SCL_SetHigh()
LC Display Interface Declarations.
Definition: dpsk3_hwdescr.h:1599
LCD_RS_DATA
#define LCD_RS_DATA
Definition: drv_lcd_interface.c:39
LCD_CS_SetDigitalOutput
#define LCD_CS_SetDigitalOutput()
Definition: dpsk3_hwdescr.h:1618
LCD_SCL_SetDigitalOutput
#define LCD_SCL_SetDigitalOutput()
Definition: dpsk3_hwdescr.h:1604
LCD_CS_SELECTED
#define LCD_CS_SELECTED
Definition: drv_lcd_interface.c:36
drv_LcdInterface_SendCmd
void drv_LcdInterface_SendCmd(uint8_t cmd)
Sends a command to the LCD controller.
Definition: drv_lcd_interface.c:92
LCD_SDI_SetHigh
#define LCD_SDI_SetHigh()
Definition: dpsk3_hwdescr.h:1606
LCD_RST_SetHigh
#define LCD_RST_SetHigh()
Definition: dpsk3_hwdescr.h:1620
LCD_RS_SetDigitalOutput
#define LCD_RS_SetDigitalOutput()
Definition: dpsk3_hwdescr.h:1632
LCD_RS_COMMAND
#define LCD_RS_COMMAND
Definition: drv_lcd_interface.c:38
LCD_SCL_SetLow
#define LCD_SCL_SetLow()
Definition: dpsk3_hwdescr.h:1600
drv_LcdInterface_Reset
void drv_LcdInterface_Reset(void)
Resets the LCD controller.
Definition: drv_lcd_interface.c:76
LCD_SDI_SetDigitalOutput
#define LCD_SDI_SetDigitalOutput()
Definition: dpsk3_hwdescr.h:1611
LCD_SDI_SetLow
#define LCD_SDI_SetLow()
Definition: dpsk3_hwdescr.h:1607