2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2018-02-17 18:59:07 +01:00
|
|
|
* drivers/lcd/ft80x.h
|
|
|
|
*
|
2021-03-04 07:10:42 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2021-03-04 07:10:42 +01:00
|
|
|
|
|
|
|
/* Definitions for the FTDI FT80x GUI
|
2018-02-17 18:59:07 +01:00
|
|
|
*
|
|
|
|
* References:
|
2021-03-04 08:02:21 +01:00
|
|
|
* - Document No.:
|
|
|
|
* FT_000792, "FT800 Embedded Video Engine", Datasheet Version 1.1,
|
|
|
|
* Clearance No.:
|
|
|
|
* FTDI# 334, Future Technology Devices International Ltd.
|
|
|
|
* - Document No.:
|
|
|
|
* FT_000986, "FT801 Embedded Video Engine Datasheet", Version 1.0,
|
|
|
|
* Clearance No.:
|
|
|
|
* FTDI#376, Future Technology Devices International Ltd.
|
2018-02-17 18:59:07 +01:00
|
|
|
* - Some definitions derive from FTDI sample code.
|
2021-03-04 07:10:42 +01:00
|
|
|
*/
|
2018-02-17 18:59:07 +01:00
|
|
|
|
|
|
|
#ifndef __DRIVERS_LCD_FT80X_H
|
|
|
|
#define __DRIVERS_LCD_FT80X_H
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2018-02-17 18:59:07 +01:00
|
|
|
* Included Files
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2018-02-17 18:59:07 +01:00
|
|
|
|
2018-02-17 23:36:11 +01:00
|
|
|
#include <nuttx/config.h>
|
2019-01-27 16:28:59 +01:00
|
|
|
#include <nuttx/signal.h>
|
2018-02-17 23:36:11 +01:00
|
|
|
#include <nuttx/wqueue.h>
|
2022-09-06 08:18:45 +02:00
|
|
|
#include <nuttx/mutex.h>
|
2018-02-17 23:36:11 +01:00
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/****************************************************************************
|
2018-02-17 18:59:07 +01:00
|
|
|
* Public Types
|
2021-03-04 08:02:21 +01:00
|
|
|
****************************************************************************/
|
2018-02-17 18:59:07 +01:00
|
|
|
|
|
|
|
/* Host write command
|
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
* For a SPI write command write transaction, the host writes a zero bit
|
|
|
|
* followed by a one bit, followed by the 5-bit command, followed by two
|
|
|
|
* bytes of zero. All data is streamed with a single chip select.
|
2018-02-17 18:59:07 +01:00
|
|
|
*
|
|
|
|
* I2C data format is equivalent (with obvious differences in bus protocol)
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct ft80x_hostwrite_s
|
|
|
|
{
|
|
|
|
uint8_t cmd; /* Bits 6-7: 01, Bits 0-5: command */
|
|
|
|
uint8_t pad1; /* Zero */
|
|
|
|
uint8_t pad2; /* Zero */
|
|
|
|
};
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/* For SPI memory read transaction, the host sends two zero bits, followed
|
|
|
|
* by the 22-bit address. This is followed by a dummy byte. After the dummy
|
|
|
|
* byte, the FT80x responds to each host byte with read data bytes.
|
2018-02-17 18:59:07 +01:00
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
* For I2C memory read transaction, bytes are packed in the I2C protocol
|
|
|
|
* as follow:
|
2018-02-17 18:59:07 +01:00
|
|
|
*
|
|
|
|
* [start] <DEVICE ADDRESS + write bit>
|
|
|
|
* <00b+Address[21:16]>
|
|
|
|
* <Address[15:8]>
|
|
|
|
* <Address[7:0]>
|
|
|
|
* [restart] <DEVICE ADDRESS + read bit>
|
|
|
|
* <Read data byte 0>
|
|
|
|
* ....
|
|
|
|
* <Read data byte n> [stop]
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct ft80x_spiread_s
|
|
|
|
{
|
|
|
|
uint8_t addrh; /* Bits 6-7: 00, Bits 0-5: Address[21:16] */
|
|
|
|
uint8_t addrm; /* Address[15:8] */
|
|
|
|
uint8_t addrl; /* Address[7:0] */
|
|
|
|
uint8_t dummy; /* Dummy byte */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ft80x_i2cread_s
|
|
|
|
{
|
|
|
|
uint8_t addrh; /* Bits 6-7: 00, Bits 0-5: Address[21:16] */
|
|
|
|
uint8_t addrm; /* Address[15:8] */
|
|
|
|
uint8_t addrl; /* Address[7:0] */
|
|
|
|
};
|
|
|
|
|
2021-03-04 08:02:21 +01:00
|
|
|
/* For SPI memory write transaction, the host sends a '1' bit and '0' bit,
|
|
|
|
* followed by the 22-bit address. This is followed by the write data.
|
2018-02-17 18:59:07 +01:00
|
|
|
*
|
2021-03-04 08:02:21 +01:00
|
|
|
* For I2C memory write transaction, bytes are packed in the I2C protocol
|
|
|
|
* as follow:
|
2018-02-17 18:59:07 +01:00
|
|
|
*
|
|
|
|
* [start] <DEVICE ADDRESS + write bit>
|
|
|
|
* <10b,Address[21:16]>
|
|
|
|
* <Address[15:8]>
|
|
|
|
* <Address[7:0]>
|
|
|
|
* <Write data byte 0>
|
|
|
|
* ....
|
|
|
|
* <Write data byte n> [stop]
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct ft80x_spiwrite_s
|
|
|
|
{
|
|
|
|
uint8_t addrh; /* Bits 6-7: 10, Bits 0-5: Address[21:16] */
|
|
|
|
uint8_t addrm; /* Address[15:8] */
|
|
|
|
uint8_t addrl; /* Address[7:0] */
|
|
|
|
/* Write data follows */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ft80x_spiwrite8_s
|
|
|
|
{
|
|
|
|
uint8_t addrh; /* Bits 6-7: 10, Bits 0-5: Address[21:16] */
|
|
|
|
uint8_t addrm; /* Address[15:8] */
|
|
|
|
uint8_t addrl; /* Address[7:0] */
|
|
|
|
uint8_t data; /* 8-bit data follows */
|
|
|
|
};
|
|
|
|
struct ft80x_spiwrite16_s
|
|
|
|
{
|
|
|
|
uint8_t addrh; /* Bits 6-7: 10, Bits 0-5: Address[21:16] */
|
|
|
|
uint8_t addrm; /* Address[15:8] */
|
|
|
|
uint8_t addrl; /* Address[7:0] */
|
|
|
|
uint8_t data[2]; /* 16-bit data follows */
|
|
|
|
};
|
|
|
|
struct ft80x_spiwrite32_s
|
|
|
|
{
|
|
|
|
uint8_t addrh; /* Bits 6-7: 10, Bits 0-5: Address[21:16] */
|
|
|
|
uint8_t addrm; /* Address[15:8] */
|
|
|
|
uint8_t addrl; /* Address[7:0] */
|
|
|
|
uint8_t data[4]; /* 32-bit data follows */
|
|
|
|
};
|
|
|
|
struct ft80x_i2cwrite_s
|
|
|
|
{
|
|
|
|
uint8_t addrh; /* Bits 6-7: 10, Bits 0-5: Address[21:16] */
|
|
|
|
uint8_t addrm; /* Address[15:8] */
|
|
|
|
uint8_t addrl; /* Address[7:0] */
|
|
|
|
/* Write data follows */
|
|
|
|
};
|
|
|
|
|
2018-02-18 01:30:24 +01:00
|
|
|
/* This structure describes one signal notification */
|
|
|
|
|
|
|
|
struct ft80x_eventinfo_s
|
|
|
|
{
|
2019-01-27 15:53:12 +01:00
|
|
|
struct sigevent event; /* Describe the way a task is to be notified */
|
2019-01-27 16:28:59 +01:00
|
|
|
struct sigwork_s work; /* Work for SIGEV_THREAD */
|
2018-02-18 01:30:24 +01:00
|
|
|
bool enable; /* True: enable notification; false: disable */
|
2022-03-21 23:47:09 +01:00
|
|
|
pid_t pid; /* Send the notification to this task */
|
2018-02-18 01:30:24 +01:00
|
|
|
};
|
|
|
|
|
2018-02-17 18:59:07 +01:00
|
|
|
/* This structure describes the overall state of the FT80x driver */
|
|
|
|
|
|
|
|
struct spi_dev_s; /* Forward reference */
|
|
|
|
struct i2c_master_s; /* Forward reference */
|
|
|
|
|
|
|
|
struct ft80x_dev_s
|
|
|
|
{
|
2018-02-18 01:30:24 +01:00
|
|
|
/* Cached interface instances */
|
|
|
|
|
2018-02-17 18:59:07 +01:00
|
|
|
#ifdef CONFIG_LCD_FT80X_SPI
|
|
|
|
FAR struct spi_dev_s *spi; /* Cached SPI device reference */
|
|
|
|
#else
|
|
|
|
FAR struct i2c_master_s *i2c; /* Cached SPI device reference */
|
|
|
|
#endif
|
|
|
|
FAR const struct ft80x_config_s *lower; /* Cached lower half instance */
|
2018-02-18 01:30:24 +01:00
|
|
|
|
|
|
|
/* Internal driver logic */
|
|
|
|
|
2018-02-17 23:36:11 +01:00
|
|
|
struct work_s intwork; /* Support back end interrupt processing */
|
2018-02-17 18:59:07 +01:00
|
|
|
uint32_t frequency; /* Effective frequency */
|
2022-09-06 08:18:45 +02:00
|
|
|
mutex_t lock; /* Mutual exclusion mutex */
|
2018-02-17 20:01:06 +01:00
|
|
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
|
|
|
uint8_t crefs; /* Number of open references */
|
|
|
|
bool unlinked; /* True if the driver has been unlinked */
|
|
|
|
#endif
|
2018-02-18 01:30:24 +01:00
|
|
|
|
|
|
|
/* Event notification support */
|
|
|
|
|
|
|
|
struct ft80x_eventinfo_s notify[FT80X_INT_NEVENTS];
|
2018-02-17 18:59:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
2021-03-04 08:02:21 +01:00
|
|
|
* Public Functions Definitions
|
2018-02-17 18:59:07 +01:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: ft80x_host_command
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Send a host command to the FT80x
|
|
|
|
*
|
|
|
|
* FFor a SPI write command write transaction, the host writes a zero bit
|
|
|
|
* followed by a one bit, followed by the 5-bit command, followed by two
|
|
|
|
* bytes of zero. All data is streamed with a single chip select.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void ft80x_host_command(FAR struct ft80x_dev_s *priv, uint8_t cmd);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: ft80x_read_memory
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Read from FT80X memory
|
|
|
|
*
|
|
|
|
* For SPI memory read transaction, the host sends two zero bits, followed
|
|
|
|
* by the 22-bit address. This is followed by a dummy byte. After the dummy
|
|
|
|
* byte, the FT80x responds to each host byte with read data bytes.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void ft80x_read_memory(FAR struct ft80x_dev_s *priv, uint32_t addr,
|
|
|
|
FAR void *buffer, size_t buflen);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: ft80x_read_byte, ft80x_read_hword, ft80x_read_word
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Read an 8-, 16-, or 32-bt bit value from FT80X memory
|
|
|
|
*
|
|
|
|
* For SPI memory read transaction, the host sends two zero bits, followed
|
|
|
|
* by the 22-bit address. This is followed by a dummy byte. After the dummy
|
|
|
|
* byte, the FT80x responds to each host byte with read data bytes.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
uint8_t ft80x_read_byte(FAR struct ft80x_dev_s *priv, uint32_t addr);
|
|
|
|
uint16_t ft80x_read_hword(FAR struct ft80x_dev_s *priv, uint32_t addr);
|
|
|
|
uint32_t ft80x_read_word(FAR struct ft80x_dev_s *priv, uint32_t addr);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: ft80x_write_memory
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Write to FT80X memory
|
|
|
|
*
|
|
|
|
* For SPI memory write transaction, the host sends a '1' bit and '0' bit,
|
|
|
|
* followed by the 22-bit address. This is followed by the write data.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void ft80x_write_memory(FAR struct ft80x_dev_s *priv, uint32_t addr,
|
|
|
|
FAR const void *buffer, size_t buflen);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: ft80x_write_byte, ft80x_write_hword, ft80x_write_word
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Write an 8-, 16-, or 32-bt bit value to FT80X memory
|
|
|
|
*
|
|
|
|
* For SPI memory write transaction, the host sends a '1' bit and '0' bit,
|
|
|
|
* followed by the 22-bit address. This is followed by the write data.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void ft80x_write_byte(FAR struct ft80x_dev_s *priv, uint32_t addr,
|
|
|
|
uint8_t data);
|
|
|
|
void ft80x_write_hword(FAR struct ft80x_dev_s *priv, uint32_t addr,
|
|
|
|
uint16_t data);
|
|
|
|
void ft80x_write_word(FAR struct ft80x_dev_s *priv, uint32_t addr,
|
|
|
|
uint32_t data);
|
|
|
|
|
2020-02-07 14:17:25 +01:00
|
|
|
#endif /* __DRIVERS_LCD_FT80X_H */
|