zongqiang.zhang | 0c6a088 | 2019-08-07 14:48:21 +0800 | [diff] [blame^] | 1 | /** |
| 2 | * \file STM32F10x.h |
| 3 | * \brief Device implementation for ST STM32F10x ARM Cortex-M3 MCUs |
| 4 | * Requires the use of ST's Standard Peripheral Library |
| 5 | * \author Andy Gock |
| 6 | * |
| 7 | * \todo Code is untested! |
| 8 | */ |
| 9 | |
| 10 | /* |
| 11 | Copyright (c) 2012, Andy Gock |
| 12 | |
| 13 | All rights reserved. |
| 14 | |
| 15 | Redistribution and use in source and binary forms, with or without |
| 16 | modification, are permitted provided that the following conditions are met: |
| 17 | * Redistributions of source code must retain the above copyright |
| 18 | notice, this list of conditions and the following disclaimer. |
| 19 | * Redistributions in binary form must reproduce the above copyright |
| 20 | notice, this list of conditions and the following disclaimer in the |
| 21 | documentation and/or other materials provided with the distribution. |
| 22 | * Neither the name of Andy Gock nor the |
| 23 | names of its contributors may be used to endorse or promote products |
| 24 | derived from this software without specific prior written permission. |
| 25 | |
| 26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 27 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 28 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 29 | DISCLAIMED. IN NO EVENT SHALL ANDY GOCK BE LIABLE FOR ANY |
| 30 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 31 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 32 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 33 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 35 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 36 | */ |
| 37 | #ifndef __glcd_spi_h__ |
| 38 | #define __glcd_spi_h__ |
| 39 | |
| 40 | #include "spi.h" |
| 41 | |
| 42 | /** SPI port number e.g SPI1, SPI2 (not to be confused with GPIOA, GPIOB, etc) */ |
| 43 | #define CONTROLLER_SPI_NUMBER |
| 44 | #define CONTROLLER_SPI_PORT |
| 45 | #define CONTROLLER_SPI_SCK_PIN |
| 46 | #define CONTROLLER_SPI_SCK_PINSRC |
| 47 | #define CONTROLLER_SPI_MISO_PIN |
| 48 | #define CONTROLLER_SPI_MISO_PINSRC |
| 49 | #define CONTROLLER_SPI_MOSI_PIN |
| 50 | #define CONTROLLER_SPI_MOSI_PINSRC |
| 51 | |
| 52 | #define CONTROLLER_SPI_SS_PORT |
| 53 | #define CONTROLLER_SPI_SS_PIN |
| 54 | #define CONTROLLER_SPI_DC_PORT GPIOC |
| 55 | #define CONTROLLER_SPI_DC_PIN GPIO_Pin_10 |
| 56 | #define CONTROLLER_SPI_RST_PORT GPIOC |
| 57 | #define CONTROLLER_SPI_RST_PIN GPIO_Pin_11 |
| 58 | |
| 59 | #define GLCD_SELECT() SPI_SELECT_CH2() |
| 60 | #define GLCD_DESELECT() SPI_DESELECT_CH2() |
| 61 | #define GLCD_DC_LOW() GPIO_ResetBits(CONTROLLER_SPI_DC_PORT,CONTROLLER_SPI_DC_PIN) |
| 62 | #define GLCD_DC_HIGH() GPIO_SetBits(CONTROLLER_SPI_DC_PORT,CONTROLLER_SPI_DC_PIN) |
| 63 | #define GLCD_A0_LOW() GPIO_ResetBits(CONTROLLER_SPI_DC_PORT,CONTROLLER_SPI_DC_PIN) |
| 64 | #define GLCD_A0_HIGH() GPIO_SetBits(CONTROLLER_SPI_DC_PORT,CONTROLLER_SPI_DC_PIN) |
| 65 | #define GLCD_RESET_LOW() GPIO_ResetBits(CONTROLLER_SPI_RST_PORT,CONTROLLER_SPI_RST_PIN) |
| 66 | #define GLCD_RESET_HIGH() GPIO_SetBits(CONTROLLER_SPI_RST_PORT,CONTROLLER_SPI_RST_PIN) |
| 67 | /*#ifdef HW_V01 |
| 68 | #define GLCD_BKL_ON() GPIO_SetBits(GPIOD, GPIO_Pin_2) |
| 69 | #define GLCD_BKL_OFF() GPIO_ResetBits(GPIOD, GPIO_Pin_2) |
| 70 | #endif |
| 71 | #ifdef HW_V02*/ |
| 72 | #define GLCD_BKL_ON() GPIO_SetBits(GPIOA, GPIO_Pin_15) |
| 73 | #define GLCD_BKL_OFF() GPIO_ResetBits(GPIOA, GPIO_Pin_15) |
| 74 | //#endif |
| 75 | |
| 76 | /** |
| 77 | * Initialise the LCD. This function is platform and controller specific. |
| 78 | */ |
| 79 | void glcd_HW_init(void); |
| 80 | |
| 81 | /** |
| 82 | * Write a byte to the connected SPI slave. |
| 83 | * \param c Byte to be written |
| 84 | * \return Returned value from SPI (often not used) |
| 85 | */ |
| 86 | void glcd_spi_write(uint8_t c); |
| 87 | |
| 88 | |
| 89 | /** |
| 90 | * Reset the LCD. |
| 91 | * \note Not all LCD controllers support reset. |
| 92 | */ |
| 93 | void glcd_reset(void); |
| 94 | |
| 95 | void glcd_bkl_on(void); |
| 96 | |
| 97 | void glcd_bkl_off(void); |
| 98 | |
| 99 | #endif |
| 100 | /* __glcd_spi_h__ */ |