|
| 1 | +/* *INDENT-OFF* */ |
| 2 | +// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD |
| 3 | +// |
| 4 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +// you may not use this file except in compliance with the License. |
| 6 | +// You may obtain a copy of the License at |
| 7 | + |
| 8 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +// |
| 10 | +// Unless required by applicable law or agreed to in writing, software |
| 11 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +// See the License for the specific language governing permissions and |
| 14 | +// limitations under the License. |
| 15 | +#ifndef __I2S_LCD_DRIVER_H__ |
| 16 | +#define __I2S_LCD_DRIVER_H__ |
| 17 | + |
| 18 | +#include "driver/i2s.h" |
| 19 | + |
| 20 | +#ifdef __cplusplus |
| 21 | +extern "C" |
| 22 | +{ |
| 23 | +#endif |
| 24 | + |
| 25 | +#define LCD_CMD_LEV (0) |
| 26 | +#define LCD_DATA_LEV (1) |
| 27 | + |
| 28 | +typedef void *i2s_lcd_handle_t; /** Handle of i2s lcd driver */ |
| 29 | + |
| 30 | +/** |
| 31 | + * @brief Configuration of i2s lcd mode |
| 32 | + * |
| 33 | + */ |
| 34 | +typedef struct { |
| 35 | + int8_t data_width; /*!< Parallel data width, 16bit or 8bit available */ |
| 36 | + int8_t pin_data_num[16]; /*!< Parallel data output IO*/ |
| 37 | + int8_t pin_num_cs; /*!< CS io num */ |
| 38 | + int8_t pin_num_wr; /*!< Write clk io*/ |
| 39 | + int8_t pin_num_rs; /*!< RS io num */ |
| 40 | + int clk_freq; /*!< I2s clock frequency */ |
| 41 | + i2s_port_t i2s_port; /*!< I2S port number */ |
| 42 | + bool swap_data; /*!< Swap the 2 bytes of RGB565 color */ |
| 43 | + uint32_t buffer_size; /*!< DMA buffer size */ |
| 44 | +} i2s_lcd_config_t; |
| 45 | + |
| 46 | +/** |
| 47 | + * @brief Initilize i2s lcd driver. |
| 48 | + * |
| 49 | + * @param config configuration of i2s |
| 50 | + * |
| 51 | + * @return A handle to the created i2s lcd driver, or NULL in case of error. |
| 52 | + */ |
| 53 | +i2s_lcd_handle_t i2s_lcd_driver_init(const i2s_lcd_config_t *config); |
| 54 | + |
| 55 | +/** |
| 56 | + * @brief Deinit i2s lcd driver. |
| 57 | + * |
| 58 | + * @param handle i2s lcd driver handle to deinitilize |
| 59 | + * |
| 60 | + * @return |
| 61 | + * - ESP_OK on success |
| 62 | + * - ESP_ERR_INVALID_ARG handle is invalid |
| 63 | + */ |
| 64 | +esp_err_t i2s_lcd_driver_deinit(i2s_lcd_handle_t handle); |
| 65 | + |
| 66 | +/** |
| 67 | + * @brief Write a data to LCD |
| 68 | + * |
| 69 | + * @param handle i2s lcd driver handle |
| 70 | + * @param data Data to write |
| 71 | + * |
| 72 | + * @return |
| 73 | + * - ESP_OK on success |
| 74 | + * - ESP_ERR_INVALID_ARG handle is invalid |
| 75 | + */ |
| 76 | +esp_err_t i2s_lcd_write_data(i2s_lcd_handle_t handle, uint16_t data); |
| 77 | + |
| 78 | +/** |
| 79 | + * @brief Write a command to LCD |
| 80 | + * |
| 81 | + * @param handle Handle of i2s lcd driver |
| 82 | + * @param cmd command to write |
| 83 | + * |
| 84 | + * @return |
| 85 | + * - ESP_OK on success |
| 86 | + * - ESP_ERR_INVALID_ARG handle is invalid |
| 87 | + */ |
| 88 | +esp_err_t i2s_lcd_write_cmd(i2s_lcd_handle_t handle, uint16_t cmd); |
| 89 | + |
| 90 | +/** |
| 91 | + * @brief Write block data to LCD |
| 92 | + * |
| 93 | + * @param handle Handle of i2s lcd driver |
| 94 | + * @param data Pointer of data |
| 95 | + * @param length length of data |
| 96 | + * |
| 97 | + * @return |
| 98 | + * - ESP_OK on success |
| 99 | + * - ESP_ERR_INVALID_ARG handle is invalid |
| 100 | + */ |
| 101 | +esp_err_t i2s_lcd_write(i2s_lcd_handle_t handle, const uint8_t *data, uint32_t length); |
| 102 | + |
| 103 | +/** |
| 104 | + * @brief acquire a lock |
| 105 | + * |
| 106 | + * @param handle Handle of i2s lcd driver |
| 107 | + * |
| 108 | + * @return Always return ESP_OK |
| 109 | + */ |
| 110 | +esp_err_t i2s_lcd_acquire(i2s_lcd_handle_t handle); |
| 111 | + |
| 112 | +/** |
| 113 | + * @brief release a lock |
| 114 | + * |
| 115 | + * @param handle Handle of i2s lcd driver |
| 116 | + * |
| 117 | + * @return Always return ESP_OK |
| 118 | + */ |
| 119 | +esp_err_t i2s_lcd_release(i2s_lcd_handle_t handle); |
| 120 | + |
| 121 | + |
| 122 | +#ifdef __cplusplus |
| 123 | +} |
| 124 | +#endif |
| 125 | + |
| 126 | +#endif |
0 commit comments