migration

This commit is contained in:
2023-03-09 16:08:27 +01:00
parent a5315c03a7
commit 966ff2ae3a
47 changed files with 25 additions and 142 deletions

File diff suppressed because it is too large Load Diff

361
lcd/ft5xx6.c Normal file
View File

@ -0,0 +1,361 @@
/****************************************************************************
**
** Copyright (C) 2020 MikroElektronika d.o.o.
** Contact: https://www.mikroe.com/contact
**
** This file is part of the mikroSDK package
**
** Commercial License Usage
**
** Licensees holding valid commercial NECTO compilers AI licenses may use this
** file in accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The mikroElektronika Company.
** For licensing terms and conditions see
** https://www.mikroe.com/legal/software-license-agreement.
** For further information use the contact form at
** https://www.mikroe.com/contact.
**
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used for
** non-commercial projects under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** The above copyright notice and this permission notice shall be
** included in all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** OF MERCHANTABILITY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
** TO THE WARRANTIES FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**
****************************************************************************/
/*!
* @file ft5xx6.c
* @brief FT5xx6 Touch Controller Driver.
*/
#include "ft5xx6.h"
#include "drv_digital_out.h"
#include "drv_digital_in.h"
/**
* @brief FT5xx6 Events Definition.
* @details Events code definition depending on the family of touch controller.
*/
const ft5xx6_controller_t FT5X06_CONTROLLER =
{
{
{ 0x00, TP_EVENT_GEST_NONE },
{ 0x10, TP_EVENT_GEST_LEFT },
{ 0x18, TP_EVENT_GEST_RIGHT },
{ 0x1C, TP_EVENT_GEST_UP },
{ 0x14, TP_EVENT_GEST_DOWN },
{ 0x48, TP_EVENT_GEST_ZOOM_IN },
{ 0x49, TP_EVENT_GEST_ZOOM_OUT }
}
};
const ft5xx6_controller_t FT5X16_CONTROLLER =
{
{
{ 0x00, TP_EVENT_GEST_NONE },
{ 0x10, TP_EVENT_GEST_LEFT },
{ 0x18, TP_EVENT_GEST_RIGHT },
{ 0x1C, TP_EVENT_GEST_UP },
{ 0x14, TP_EVENT_GEST_DOWN },
{ 0x48, TP_EVENT_GEST_ZOOM_IN },
{ 0x49, TP_EVENT_GEST_ZOOM_OUT }
}
};
const ft5xx6_controller_t FT5X26_CONTROLLER =
{
{
{ 0x00, TP_EVENT_GEST_NONE },
{ 0x1C, TP_EVENT_GEST_LEFT },
{ 0x14, TP_EVENT_GEST_RIGHT },
{ 0x10, TP_EVENT_GEST_UP },
{ 0x18, TP_EVENT_GEST_DOWN },
{ 0x48, TP_EVENT_GEST_ZOOM_IN },
{ 0x49, TP_EVENT_GEST_ZOOM_OUT }
}
};
const ft5xx6_controller_t FT5X46_CONTROLLER =
{
{
{ 0x00, TP_EVENT_GEST_NONE },
{ 0x1C, TP_EVENT_GEST_LEFT },
{ 0x14, TP_EVENT_GEST_RIGHT },
{ 0x10, TP_EVENT_GEST_UP },
{ 0x18, TP_EVENT_GEST_DOWN },
{ 0x48, TP_EVENT_GEST_ZOOM_IN },
{ 0x49, TP_EVENT_GEST_ZOOM_OUT }
}
};
/**
* @brief FT5xx6 Pressure Coordinates Read Function.
* @details This function reads the coordinates of pressed touch point/points.
* @param[out] ctx : FT5xx6 context object. See #ft5xx6_t structure definition
* for detailed explanation.
* @return @li @c 0 - OK,
* @li @c 5 - Number of pressed touches is out of range.
* See #tp_err_t structure definition for detailed explanation.
*/
static tp_err_t
ft5xx6_read_press_coordinates( ft5xx6_t * ctx );
/**
* @brief FT5xx6 Gesture Read Function.
* @details This function reads the gesture ID and allows user to see the slide
* direction.
* @param[out] ctx : FT5xx6 context object. See #ft5xx6_t structure definition
* for detailed explanation.
* @return Nothing.
*/
static void
ft5xx6_read_gesture( ft5xx6_t * ctx );
void
ft5xx6_cfg_setup( ft5xx6_cfg_t * cfg, const ft5xx6_controller_t * controller )
{
i2c_master_configure_default( &cfg->i2c_cfg );
cfg->int_pin = HAL_PIN_NC;
cfg->controller = controller;
}
tp_err_t
ft5xx6_init( ft5xx6_t * ctx, ft5xx6_cfg_t * cfg, tp_drv_t * drv )
{
// digital_out_t scl_pin;
// digital_in_t sda_pin;
// ** Linking problem for functions with different types of arguments.
tp_event_t ( * tmp_ptr1 )( ft5xx6_t * );
void ( * tmp_ptr2 )( ft5xx6_t *, tp_touch_item_t * );
void ( * tmp_ptr3 )( ft5xx6_t *, tp_event_t * );
tp_err_t ( * tmp_ptr4 )( ft5xx6_t * );
/*digital_out_init( &scl_pin, cfg->i2c_cfg.scl );
digital_in_init( &sda_pin, cfg->i2c_cfg.sda );
digital_out_high( &scl_pin );
while ( 0 == digital_in_read( &sda_pin ) )
{
digital_out_low( &scl_pin );
Delay_10us( );
digital_out_high( &scl_pin );
Delay_10us( );
}*/
if ( i2c_master_open( &ctx->i2c, &cfg->i2c_cfg ) == I2C_MASTER_ERROR )
{
return TP_ERR_INIT_DRV;
}
i2c_master_set_slave_address( &ctx->i2c, FT5XX6_I2C_ADDR );
i2c_master_set_speed( &ctx->i2c, I2C_MASTER_SPEED_STANDARD );
i2c_master_set_timeout( &ctx->i2c, 0 );
if ( digital_in_init( &ctx->int_pin, cfg->int_pin ) == DIGITAL_IN_UNSUPPORTED_PIN )
{
return TP_ERR_UNSUPPORTED_PIN;
}
ctx->controller = cfg->controller;
drv->tp_press_detect_f = ft5xx6_press_detect;
drv->tp_press_coordinates_f = ft5xx6_press_coordinates;
drv->tp_gesture_f = ft5xx6_gesture;
drv->tp_process_f = ft5xx6_process;
return TP_OK;
// **
tmp_ptr1( NULL );
tmp_ptr2( NULL, NULL );
tmp_ptr3( NULL, NULL );
tmp_ptr4( NULL );
}
void
ft5xx6_default_cfg( ft5xx6_t * ctx )
{
ft5xx6_run_mode_setup( ctx, FT5XX6_RUN_MODE_CFG );
ft5xx6_dev_mode_setup( ctx, FT5XX6_DEV_MODE_NORMAL );
ft5xx6_generic_write( ctx, FT5XX6_REG_IVT_TO_HOST_STATUS, FT5XX6_INT_MODE_POLLING );
ft5xx6_run_mode_setup( ctx, FT5XX6_RUN_MODE_WORK );
}
void
ft5xx6_generic_write( ft5xx6_t * ctx, uint8_t reg_addr, uint8_t data_in )
{
uint8_t tmp_data[ 2 ];
tmp_data[ 0 ] = reg_addr;
tmp_data[ 1 ] = data_in;
i2c_master_write( &ctx->i2c, tmp_data, 2 );
}
uint8_t
ft5xx6_generic_read_single( ft5xx6_t * ctx, uint8_t reg_addr )
{
uint8_t tmp_data;
tmp_data = reg_addr;
i2c_master_write_then_read( &ctx->i2c, &tmp_data, 1, &tmp_data, 1 );
return tmp_data;
}
tp_err_t
ft5xx6_generic_read_multiple( ft5xx6_t * ctx, uint8_t reg_addr,
uint8_t * data_out, uint16_t n_bytes )
{
uint8_t tmp_data;
if ( ( n_bytes < FT5XX6_N_DATA_TRANSFER_MIN ) ||
( n_bytes > FT5XX6_N_DATA_TRANSFER_MAX ) )
{
return TP_ERR_N_DATA;
}
tmp_data = reg_addr;
i2c_master_write_then_read( &ctx->i2c, &tmp_data, 1, data_out, n_bytes );
return TP_OK;
}
void
ft5xx6_dev_mode_setup( ft5xx6_t * ctx, ft5xx6_dev_mode_t mode )
{
ft5xx6_generic_write( ctx, FT5XX6_REG_DEVICE_MODE, mode << FT5XX6_OFFSET_DEV_MODE );
}
void
ft5xx6_run_mode_setup( ft5xx6_t * ctx, ft5xx6_run_mode_t mode )
{
ft5xx6_generic_write( ctx, FT5XX6_REG_RUNNING_STATE, mode );
}
tp_event_t
ft5xx6_press_detect( ft5xx6_t * ctx )
{
return ctx->press_det;
}
void
ft5xx6_press_coordinates( ft5xx6_t * ctx, tp_touch_item_t * touch_item )
{
touch_item->n_touches = ctx->touch.n_touches;
for ( uint8_t idx = 0; idx < ctx->touch.n_touches; idx++ )
{
touch_item->point[ idx ].coord_x = ctx->touch.point[ idx ].coord_x;
touch_item->point[ idx ].coord_y = ctx->touch.point[ idx ].coord_y;
touch_item->point[ idx ].event = ctx->touch.point[ idx ].event;
touch_item->point[ idx ].id = ctx->touch.point[ idx ].id;
}
}
void
ft5xx6_gesture( ft5xx6_t * ctx, tp_event_t * event )
{
*event = ctx->gesture;
}
tp_err_t
ft5xx6_process( ft5xx6_t * ctx )
{
tp_err_t status;
status = ft5xx6_read_press_coordinates( ctx );
if ( ( status == TP_OK ) && ( ctx->press_det == TP_EVENT_PRESS_DET ) )
{
ft5xx6_read_gesture( ctx );
}
return status;
}
static tp_err_t
ft5xx6_read_press_coordinates( ft5xx6_t * ctx )
{
if ( !digital_in_read( &ctx->int_pin ) )
{
ctx->touch.n_touches = ft5xx6_generic_read_single( ctx, FT5XX6_REG_TD_STATUS );
if ( ctx->touch.n_touches > TP_N_TOUCHES_MAX )
{
return TP_ERR_N_TOUCHES;
}
else
{
uint8_t read_data[ 4 ];
uint8_t touch_addr = FT5XX6_REG_TOUCH1_XH;
for ( uint8_t idx = 0; idx < ctx->touch.n_touches; idx++ )
{
ft5xx6_generic_read_multiple( ctx, touch_addr, read_data, 4 );
ctx->touch.point[ idx ].coord_x = read_data[ 0 ];
ctx->touch.point[ idx ].coord_x <<= 8;
ctx->touch.point[ idx ].coord_x |= read_data[ 1 ];
ctx->touch.point[ idx ].coord_x &= FT5XX6_MASK_PRESS_COORD;
ctx->touch.point[ idx ].coord_y = read_data[ 2 ];
ctx->touch.point[ idx ].coord_y <<= 8;
ctx->touch.point[ idx ].coord_y |= read_data[ 3 ];
ctx->touch.point[ idx ].coord_y &= FT5XX6_MASK_PRESS_COORD;
ctx->touch.point[ idx ].event = read_data[ 0 ] >> FT5XX6_OFFSET_PRESS_EVENT;
ctx->touch.point[ idx ].id = read_data[ 2 ] >> FT5XX6_OFFSET_PRESS_ID;
touch_addr += FT5XX6_OFFSET_TOUCH_READING;
}
ctx->press_det = TP_EVENT_PRESS_DET;
}
}
else
{
ctx->press_det = TP_EVENT_PRESS_NOT_DET;
}
return TP_OK;
}
static void
ft5xx6_read_gesture( ft5xx6_t * ctx )
{
uint8_t read_data;
read_data = ft5xx6_generic_read_single( ctx, FT5XX6_REG_GEST_ID );
for ( uint8_t idx = 0; idx < FT5XX6_GESTURE_ITEMS_MAX; idx++ )
{
if ( read_data == ctx->controller->gest_items[ idx ].key )
{
ctx->gesture = ctx->controller->gest_items[ idx ].value;
return;
}
}
}
// ------------------------------------------------------------------------ END

970
lcd/ft5xx6.h Normal file
View File

@ -0,0 +1,970 @@
/****************************************************************************
**
** Copyright (C) 2020 MikroElektronika d.o.o.
** Contact: https://www.mikroe.com/contact
**
** This file is part of the mikroSDK package
**
** Commercial License Usage
**
** Licensees holding valid commercial NECTO compilers AI licenses may use this
** file in accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The mikroElektronika Company.
** For licensing terms and conditions see
** https://www.mikroe.com/legal/software-license-agreement.
** For further information use the contact form at
** https://www.mikroe.com/contact.
**
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used for
** non-commercial projects under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** The above copyright notice and this permission notice shall be
** included in all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** OF MERCHANTABILITY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
** TO THE WARRANTIES FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**
****************************************************************************/
/*!
* @file ft5xx6.h
* @brief FT5xx6 Touch Controller Driver.
*/
#ifndef FT5XX6_H
#define FT5XX6_H
#include "drv_i2c_master.h"
#include "drv_digital_in.h"
#include "drv_name.h"
#include "tp.h"
/*!
* @addtogroup middlewaregroup Middleware
* @brief This section includes the mikroSDK API Reference for Middleware Layer.
* @{
*/
/*!
* @addtogroup ft5xx6 FT5xx6 Touch Controllers Driver
* @brief FT5xx6 Touch Controller Driver API Reference.
* @{
*/
/**
* @defgroup ft5xx6_registers FT5xx6 Registers
* @brief FT5xx6 Registers List.
* @details FT5xx6 registers description with respective addresses.
*/
/**
* @addtogroup ft5xx6_registers
* @{
*/
/**
* @brief FT5xx6 Device Mode Register.
* @details Register address specified for device mode of FT5xx6 touch
* controller.
*/
#define FT5XX6_REG_DEVICE_MODE 0x0
/**
* @brief FT5xx6 Gesture ID Register.
* @details Register address specified for gesture ID of FT5xx6 touch
* controller.
*/
#define FT5XX6_REG_GEST_ID 0x1
/**
* @brief FT5xx6 Status Register.
* @details Register address specified for status of FT5xx6 touch controller.
*/
#define FT5XX6_REG_TD_STATUS 0x2
/**
* @brief FT5xx6 Touch1 X-coord MSB Register.
* @details Register address specified for touch1 x coordinate higher byte of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH1_XH 0x3
/**
* @brief FT5xx6 Touch1 X-coord LSB Register.
* @details Register address specified for touch1 x coordinate lower byte of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH1_XL 0x4
/**
* @brief FT5xx6 Touch1 Y-coord MSB Register.
* @details Register address specified for touch1 y coordinate higher byte of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH1_YH 0x5
/**
* @brief FT5xx6 Touch1 Y-coord LSB Register.
* @details Register address specified for touch1 y coordinate lower byte of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH1_YL 0x6
/**
* @brief FT5xx6 Touch2 X-coord MSB Register.
* @details Register address specified for touch2 x coordinate higher byte of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH2_XH 0x9
/**
* @brief FT5xx6 Touch2 X-coord LSB Register.
* @details Register address specified for touch2 x coordinate lower byte of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH2_XL 0xA
/**
* @brief FT5xx6 Touch2 Y-coord MSB Register.
* @details Register address specified for touch2 y coordinate higher byte of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH2_YH 0xB
/**
* @brief FT5xx6 Touch2 Y-coord LSB Register.
* @details Register address specified for touch2 y coordinate lower byte of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH2_YL 0xC
/**
* @brief FT5xx6 Touch3 X-coord MSB Register.
* @details Register address specified for touch3 x coordinate higher byte of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH3_XH 0xF
/**
* @brief FT5xx6 Touch3 X-coord LSB Register.
* @details Register address specified for touch3 x coordinate lower byte of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH3_XL 0x10
/**
* @brief FT5xx6 Touch3 Y-coord MSB Register.
* @details Register address specified for touch3 y coordinate higher byte of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH3_YH 0x11
/**
* @brief FT5xx6 Touch3 Y-coord LSB Register.
* @details Register address specified for touch3 y coordinate lower byte of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH3_YL 0x12
/**
* @brief FT5xx6 Touch4 X-coord MSB Register.
* @details Register address specified for touch4 x coordinate higher byte of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH4_XH 0x15
/**
* @brief FT5xx6 Touch4 X-coord LSB Register.
* @details Register address specified for touch4 x coordinate lower byte of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH4_XL 0x16
/**
* @brief FT5xx6 Touch4 Y-coord MSB Register.
* @details Register address specified for touch4 y coordinate higher byte of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH4_YH 0x17
/**
* @brief FT5xx6 Touch4 Y-coord LSB Register.
* @details Register address specified for touch4 y coordinate lower byte of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH4_YL 0x18
/**
* @brief FT5xx6 Touch5 X-coord MSB Register.
* @details Register address specified for touch5 x coordinate higher byte of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH5_XH 0x1B
/**
* @brief FT5xx6 Touch5 X-coord LSB Register.
* @details Register address specified for touch5 x coordinate lower byte of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH5_XL 0x1C
/**
* @brief FT5xx6 Touch5 Y-coord MSB Register.
* @details Register address specified for touch5 y coordinate higher byte of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH5_YH 0x1D
/**
* @brief FT5xx6 Touch5 Y-coord LSB Register.
* @details Register address specified for touch5 y coordinate lower byte of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH5_YL 0x1E
/**
* @brief FT5xx6 Touch Detection Threshold Register.
* @details Register address specified for touch detection threshold of FT5xx6
* touch controller.
*/
#define FT5XX6_REG_TOUCH_DET_TH 0x80
/**
* @brief FT5xx6 Touch Peak Detection Threshold Register.
* @details Register address specified for touch peak detection threshold of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH_PEAK_DET_TH 0x81
/**
* @brief FT5xx6 Touch Threshold Calibration Register.
* @details Register address specified for touch threshold calibration of FT5xx6
* touch controller.
*/
#define FT5XX6_REG_TOUCH_TH_CAL 0x82
/**
* @brief FT5xx6 Touch Threshold Water Register.
* @details Register address specified for touch threshold water of FT5xx6 touch
* controller.
*/
#define FT5XX6_REG_TOUCH_TH_WATER 0x83
/**
* @brief FT5xx6 Touch Threshold Temperature Compensation Register.
* @details Register address specified for touch threshold temperature
* compensation of FT5xx6 touch controller.
*/
#define FT5XX6_REG_TOUCH_TH_TEMP_COMP 0x84
/**
* @brief FT5xx6 Power Control Register.
* @details Register address specified for power control of FT5xx6 touch
* controller.
*/
#define FT5XX6_REG_POWER_CTRL_MODE 0x86
/**
* @brief FT5xx6 Timer Status Monitor Register.
* @details Register address specified for timer status monitor of FT5xx6 touch
* controller.
*/
#define FT5XX6_REG_MONITOR_STATUS_TMR 0x87
/**
* @brief FT5xx6 Actual Period Monitor Register.
* @details Register address specified for actual period monitor of FT5xx6 touch
* controller.
*/
#define FT5XX6_REG_MONITOR_ACT_PERIOD 0x88
/**
* @brief FT5xx6 Enter Idle Timer Register.
* @details Register address specified for enter idle timer of FT5xx6 touch
* controller.
*/
#define FT5XX6_REG_ENTER_IDLE_TIMER 0x89
/**
* @brief FT5xx6 Auto Calibration Register.
* @details Register address specified for auto calibration of FT5xx6 touch
* controller.
*/
#define FT5XX6_REG_AUTO_CALIB_MODE 0xA0
/**
* @brief FT5xx6 Version MSB Register.
* @details Register address specified for version higher byte of FT5xx6 touch
* controller.
*/
#define FT5XX6_REG_LIB_VERSION_H 0xA1
/**
* @brief FT5xx6 Version LSB Register.
* @details Register address specified for version lower byte of FT5xx6 touch
* controller.
*/
#define FT5XX6_REG_LIB_VERSION_L 0xA2
/**
* @brief FT5xx6 Chip Vendor ID Register.
* @details Register address specified for chip vendor ID of FT5xx6 touch
* controller.
*/
#define FT5XX6_REG_LIB_CHIP_VENDOR_ID 0xA3
/**
* @brief FT5xx6 IVT To Host Status Register.
* @details Register address specified for IVT to host status of FT5xx6 touch
* controller.
*/
#define FT5XX6_REG_IVT_TO_HOST_STATUS 0xA4
/**
* @brief FT5xx6 Power Consume Register.
* @details Register address specified for power consume of FT5xx6 touch
* controller.
*/
#define FT5XX6_REG_POWER_CONSUME_MODE 0xA5
/**
* @brief FT5xx6 FW ID Register.
* @details Register address specified for firmware ID of FT5xx6 touch
* controller.
*/
#define FT5XX6_REG_FW_ID 0xA6
/**
* @brief FT5xx6 Running State Register.
* @details Register address specified for running state of FT5xx6 touch
* controller.
*/
#define FT5XX6_REG_RUNNING_STATE 0xA7
/**
* @brief FT5xx6 CTPM Vendor ID Register.
* @details Register address specified for CTPM vendor ID of FT5xx6 touch
* controller.
*/
#define FT5XX6_REG_CTPM_VENDOR_ID 0xA8
/**
* @brief FT5xx6 Error ID Register.
* @details Register address specified for error ID of FT5xx6 touch controller.
*/
#define FT5XX6_REG_ERROR_ID 0xA9
/**
* @brief FT5xx6 Calibration Mode Configuration Register.
* @details Register address specified for calibration mode configuration of
* FT5xx6 touch controller.
*/
#define FT5XX6_REG_CONFIGURE_CAL_MODE 0xAA
/**
* @brief FT5xx6 Big Area Threshold Register.
* @details Register address specified for big area threshold of FT5xx6 touch
* controller.
*/
#define FT5XX6_REG_BIG_AREA_TH 0xAE
/*! @} */ // ft5xx6_registers
/**
* @defgroup ft5xx6_settings FT5xx6 Settings
* @brief FT5xx6 Settings List.
* @details FT5xx6 settings description with respective values.
*/
/**
* @addtogroup ft5xx6_settings
* @{
*/
/**
* @brief FT5xx6 Interrupt Polling Mode Setting.
* @details INT pin polling mode setting for FT5xx6 series touch controllers.
*/
#define FT5XX6_INT_MODE_POLLING 0
/**
* @brief FT5xx6 Interrupt Trigger Mode Setting.
* @details INT pin trigger mode setting for FT5xx6 series touch controllers.
*/
#define FT5XX6_INT_MODE_TRIGGER 1
/**
* @brief FT5xx6 Slave Address Setting.
* @details Slave address setting for FT5xx6 series touch controllers.
*/
#define FT5XX6_I2C_ADDR 0x38
/**
* @brief FT5xx6 Data Transfer Limits Setting.
* @details Data transfer limits for FT5xx6 series touch controllers.
*/
#define FT5XX6_N_DATA_TRANSFER_MIN 1
#define FT5XX6_N_DATA_TRANSFER_MAX 256
/**
* @brief FT5xx6 Gesture Items Limit Setting.
* @details Gesture items limit for FT5xx6 series touch controllers.
*/
#define FT5XX6_GESTURE_ITEMS_MAX 7
/**
* @brief FT5xx6 Touch Pressure Event.
* @details Touch pressure event for FT5xx6 series touch controllers.
*/
#define FT5XX6_EVENT_PRESS_DET 0x80
/**
* @defgroup ft5xx6_masks FT5xx6 Masks
* @brief FT5xx6 Masks List.
* @details FT5xx6 masks description with respective values.
*/
/**
* @addtogroup ft5xx6_masks
* @{
*/
/**
* @brief FT5xx6 Touch Coordinates Mask.
* @details Touch pressure coordinates mask for FT5xx6 series touch controllers.
*/
#define FT5XX6_MASK_PRESS_COORD 0xFFF
/**
* @brief FT5xx6 Touch Event Mask.
* @details Touch pressure event mask for FT5xx6 series touch controllers.
*/
#define FT5XX6_MASK_PRESS_EVENT 0xC0
/**
* @brief FT5xx6 Touch Detection Mask.
* @details Touch pressure detection mask for FT5xx6 series touch controllers.
*/
#define FT5XX6_MASK_PRESS_DET 0xC0
/**
* @brief FT5xx6 TP Number Mask.
* @details Touch point number mask for FT5xx6 series touch controllers.
*/
#define FT5XX6_MASK_TP_NUM 0xF
/*! @} */ // ft5xx6_masks
/**
* @defgroup ft5xx6_offsets FT5xx6 Offsets
* @brief FT5xx6 Offsets List.
* @details FT5xx6 offsets description with respective values.
*/
/**
* @addtogroup ft5xx6_offsets
* @{
*/
/**
* @brief FT5xx6 Touch Event Offset.
* @details Touch event offset for FT5xx6 series touch controllers.
*/
#define FT5XX6_OFFSET_PRESS_EVENT 6
/**
* @brief FT5xx6 Touch ID Offset.
* @details Touch ID offset for FT5xx6 series touch controllers.
*/
#define FT5XX6_OFFSET_PRESS_ID 4
/**
* @brief FT5xx6 Device Mode Offset.
* @details Device mode offset for FT5xx6 series touch controllers.
*/
#define FT5XX6_OFFSET_DEV_MODE 4
/**
* @brief FT5xx6 Touch Reading Offset.
* @details Reading of touches offset for FT5xx6 series touch controllers.
*/
#define FT5XX6_OFFSET_TOUCH_READING 6
/*! @} */ // ft5xx6_offsets
/**
* @brief FT5xx6 Pin Mapping.
* @details Utility macro for mapping FT5xx6 series touch controllers.
*/
#define FT5XX6_MAP_PINS( cfg ) \
cfg.i2c_cfg.scl = CTP_SCL; \
cfg.i2c_cfg.sda = CTP_SDA; \
cfg.int_pin = CTP_INT
/*! @} */ // ft5xx6_settings
/*! @} */ // ft5xx6
/*! @} */ // middlewaregroup
/**
* @brief FT5xx6 Device Mode Settings.
* @details Device mode definition for FT5xx6 series touch controllers.
*/
typedef enum
{
FT5XX6_DEV_MODE_NORMAL, /**< Normal mode. */
FT5XX6_DEV_MODE_SYS_INFO, /**< System info mode. */
FT5XX6_DEV_MODE_TEST = 4 /**< Device test mode. */
} ft5xx6_dev_mode_t;
/**
* @brief FT5xx6 Run Mode Settings.
* @details Run mode definition for FT5xx6 series touch controllers.
*/
typedef enum
{
FT5XX6_RUN_MODE_CFG, /**< Config mode. */
FT5XX6_RUN_MODE_WORK, /**< Working mode. */
FT5XX6_RUN_MODE_CAL, /**< Calibration mode. */
FT5XX6_RUN_MODE_FACT, /**< Factory mode. */
FT5XX6_RUN_MODE_AUTO_CAL /**< Auto calibration mode. */
} ft5xx6_run_mode_t;
/**
* @brief FT5xx6 Gesture Item Definition.
* @details Gesture item definition for FT5xx6 series touch controllers.
*/
typedef struct
{
uint8_t key; /**< Gesture key. */
tp_event_t value; /**< Gesture event value. */
} ft5xx6_gest_item_t;
/**
* @brief FT5xx6 Gesture Items.
* @details Gesture items for FT5xx6 series touch controllers.
*/
typedef struct
{
ft5xx6_gest_item_t gest_items[ FT5XX6_GESTURE_ITEMS_MAX ];
} ft5xx6_controller_t;
/**
* @brief FT5xx6 Configuration Object.
* @details Configuration object definition for FT5xx6 series touch controllers.
*/
typedef struct
{
pin_name_t int_pin; /**< Interrupt pin. */
i2c_master_config_t i2c_cfg; /**< Configuration of communication module. */
const ft5xx6_controller_t * controller; /**< Touch controller descriptor. */
} ft5xx6_cfg_t;
/**
* @brief FT5xx6 Context Object.
* @details Context object definition for FT5xx6 series touch controllers.
*/
typedef struct
{
i2c_master_t i2c; /**< Communication module object. */
digital_in_t int_pin; /**< Interrupt pin object. */
const ft5xx6_controller_t * controller; /**< Touch controller descriptor. */
tp_event_t press_det; /**< Touch pressure event. */
tp_touch_item_t touch; /**< Touch item. */
tp_event_t gesture; /**< Gesture event. */
} ft5xx6_t;
/**
* @brief FT5x06 Touch Controllers Descriptor.
* @details Specified descriptor that describe events of the
* gesture for each controller from FT5x06 series touch controllers.
*/
extern const ft5xx6_controller_t FT5X06_CONTROLLER;
/**
* @brief FT5x16 Touch Controllers Descriptor.
* @details Specified descriptor that describe events of the
* gesture for each controller from FT5x16 series touch controllers.
*/
extern const ft5xx6_controller_t FT5X16_CONTROLLER;
/**
* @brief FT5x26 Touch Controllers Descriptor.
* @details Specified descriptor that describe events of the
* gesture for each controller from FT5x26 series touch controllers.
*/
extern const ft5xx6_controller_t FT5X26_CONTROLLER;
/**
* @brief FT5x46 Touch Controllers Descriptor.
* @details Specified descriptor that describe events of the
* gesture for each controller from FT5x46 series touch controllers.
*/
extern const ft5xx6_controller_t FT5X46_CONTROLLER;
/*!
* @addtogroup middlewaregroup Middleware
* @brief This section includes the mikroSDK API Reference for Middleware Layer.
* @{
*/
/*!
* @addtogroup ft5xx6 FT5xx6 Touch Controllers Driver
* @brief API for configuring and manipulating FT5xx6 Touch Controller driver.
* @{
*/
#ifdef __cplusplus
extern "C"{
#endif
/**
* @brief FT5xx6 Configuration Object Setup Function.
* @details This function initializes FT5xx6 configuration structure to default
* values.
* @param[out] cfg : FT5xx6 configuration object. See #ft5xx6_cfg_t structure
* definition for detailed explanation.
* @param[in] controller : Touch controller selector from FT5xx6 series touch
* controllers. See #ft5xx6_controller_t structure definition for detailed
* explanation.
* @return Nothing.
* @note The all used pins will be set to unconnected state.
*
* @b Example
* @code
* // FT5xx6 configuration object.
* ft5xx6_cfg_t ft5xx6_cfg;
* // FT5x26 series touch controllers descriptor.
* const ft5xx6_controller_t FT5X26_CONTROLLER =
* {
* {
* { 0x00, TP_EVENT_GEST_NONE },
* { 0x1C, TP_EVENT_GEST_LEFT },
* { 0x14, TP_EVENT_GEST_RIGHT },
* { 0x10, TP_EVENT_GEST_UP },
* { 0x18, TP_EVENT_GEST_DOWN },
* { 0x48, TP_EVENT_GEST_ZOOM_IN },
* { 0x49, TP_EVENT_GEST_ZOOM_OUT }
* }
* };
*
* // FT5xx6 configuration setup.
* ft5xx6_cfg_setup( &ft5xx6_cfg, &FT5X26_CONTROLLER );
* @endcode
*/
void
ft5xx6_cfg_setup( ft5xx6_cfg_t * cfg, const ft5xx6_controller_t * controller );
/**
* @brief FT5xx6 Initialization Function.
* @details This function initializes FT5xx6 context object to default values
* and allows driver interface object to be linked with FT5xx6 driver functions.
* @param[out] ctx : FT5xx6 context object. See #ft5xx6_t structure definition
* for detailed explanation.
* @param[in] cfg : FT5xx6 configuration object. See #ft5xx6_cfg_t structure
* definition for detailed explanation.
* @param[out] drv : TP driver interface object. See #tp_drv_t structure
* definition for detailed explanation.
* @return @li @c 0 - OK,
* @li @c 1 - I2C driver init error,
* @li @c 2 - Unsupported pin.
* See #tp_err_t structure definition for detailed explanation.
*
* @b Example
* @code
* // FT5xx6 driver object.
* ft5xx6_t ft5xx6;
* // FT5xx6 configuration object.
* ft5xx6_cfg_t ft5xx6_cfg;
* // FT5x26 series touch controllers descriptor.
* const ft5xx6_controller_t FT5X26_CONTROLLER;
* // TP driver interface object.
* tp_drv_t tp_interface;
*
* // FT5xx6 configuration setup.
* ft5xx6_cfg_setup( &ft5xx6_cfg, &FT5X26_CONTROLLER );
* // FT5xx6 controller pin mapping.
* FT5XX6_MAP_PINS( ft5xx6_cfg );
* // FT5xx6 driver initialization.
* ft5xx6_init( &ft5xx6, &ft5xx6_cfg, &tp_interface );
* @endcode
*/
tp_err_t
ft5xx6_init( ft5xx6_t * ctx, ft5xx6_cfg_t * cfg, tp_drv_t * drv );
/**
* @brief FT5xx6 Default Configuration Function.
* @details This function puts the FT5xx6 touch controller to normal operating
* mode.
* @param[in] ctx : FT5xx6 context object. See #ft5xx6_t structure definition
* for detailed explanation.
* @return Nothing.
* @note It's necessary for this functon to be executed after Initialization
* function for properly working of entire driver.
*
* @b Example
* @code
* // FT5xx6 driver object.
* ft5xx6_t ft5xx6;
*
* // FT5xx6 driver default configuration.
* ft5xx6_default_cfg( &ft5xx6 );
* @endcode
*/
void
ft5xx6_default_cfg( ft5xx6_t * ctx );
/**
* @brief FT5xx6 Generic Write Function.
* @details This function allows user to write any 8-bit data to the selected
* register of the FT5xx6 series touch controllers.
* @param[in] ctx : FT5xx6 context object. See #ft5xx6_t structure definition
* for detailed explanation.
* @param[in] reg_addr : Register address where data be written.
* @param[in] data_in : Data to be written.
* @return Nothing.
*
* @b Example
* @code
* // FT5xx6 driver object.
* ft5xx6_t ft5xx6;
*
* // Setting FT5xx6 controller to configuration mode.
* ft5xx6_generic_write( &ft5xx6, FT5XX6_REG_RUNNING_STATE,
* FT5XX6_RUN_MODE_CFG );
* @endcode
*/
void
ft5xx6_generic_write( ft5xx6_t * ctx, uint8_t reg_addr, uint8_t data_in );
/**
* @brief FT5xx6 Generic Single Read Function.
* @details This function allows user to read any desired register of the FT5xx6
* series touch controllers.
* @param[in] ctx : FT5xx6 context object. See #ft5xx6_t structure definition
* for detailed explanation.
* @param[in] reg_addr : Register address which from data be read.
* @return 8-bit read data.
*
* @b Example
* @code
* // FT5xx6 driver object.
* ft5xx6_t ft5xx6;
* // Read value.
* uint8_t read_data;
*
* // Reading status of FT5xx6 controller to get number of pressed touches.
* read_data = ft5xx6_generic_read_single( &ft5xx6, FT5XX6_REG_TD_STATUS );
* @endcode
*/
uint8_t
ft5xx6_generic_read_single( ft5xx6_t * ctx, uint8_t reg_addr );
/**
* @brief FT5xx6 Generic Multiple Read Function.
* @details This function allows user to read the desired number of data bytes,
* starting from the selected register address.
* @param[in] ctx : FT5xx6 context object. See #ft5xx6_t structure definition
* for detailed explanation.
* @param[in] reg_addr : Register address which from the data reading will be
* started.
* @param[out] data_out : Memory where read data will be stored.
* @param[in] n_bytes : Number of data bytes to be read.
* @return @li @c 0 - OK,
* @li @c 6 - Number of transfered bytes is out of range.
* See #tp_err_t structure definition for detailed explanation.
*
* @b Example
* @code
* // FT5xx6 driver object.
* ft5xx6_t ft5xx6;
* // Read value.
* uint8_t read_data[ 2 ];
* // TP error code.
* tp_err_t error;
*
* // Reading two data bytes to get x coordinate value of touch1.
* error = ft5xx6_generic_read_multiple( &ft5xx6, FT5XX6_REG_TOUCH1_XH,
* read_data, 2 );
* @endcode
*/
tp_err_t
ft5xx6_generic_read_multiple( ft5xx6_t * ctx, uint8_t reg_addr,
uint8_t * data_out, uint16_t n_bytes );
/**
* @brief FT5xx6 Device Mode Setup Function.
* @details This function puts the FT5xx6 series touch controllers to the
* selected device mode.
* @param[in] ctx : FT5xx6 context object. See #ft5xx6_t structure definition
* for detailed explanation.
* @param[in] mode : device mode of operation. See #ft5xx6_dev_mode_t for valid
* values.
* @return Nothing.
*
* @b Example
* @code
* // FT5xx6 driver object.
* ft5xx6_t ft5xx6;
*
* // Setting device normal operating mode of FT5xx6 series touch controllers.
* ft5xx6_dev_mode_setup( &ft5xx6, FT5XX6_DEV_MODE_NORMAL );
* @endcode
*/
void
ft5xx6_dev_mode_setup( ft5xx6_t * ctx, ft5xx6_dev_mode_t mode );
/**
* @brief FT5xx6 Run Mode Setup Function.
* @details This function puts the FT5xx6 series touch controllers to the
* selected run mode.
* @param[in] ctx : FT5xx6 context object. See #ft5xx6_t structure definition
* for detailed explanation.
* @param[in] mode : run mode of operation. See #ft5xx6_run_mode_t for valid
* values.
* @return Nothing.
*
* @b Example
* @code
* // FT5xx6 driver object.
* ft5xx6_t ft5xx6;
*
* // Setting run working mode of FT5xx6 series touch controllers.
* ft5xx6_run_mode_setup( &ft5xx6, FT5XX6_RUN_MODE_WORK );
* @endcode
*/
void
ft5xx6_run_mode_setup( ft5xx6_t * ctx, ft5xx6_run_mode_t mode );
/**
* @brief FT5xx6 Touch Pressure Detect Function.
* @details This function allows the touch pressure detection.
* @param[in] ctx : FT5xx6 context object. See #ft5xx6_t structure definition
* for detailed explanation.
* @return @li @c 3 - Touch pressure is not detected,
* @li @c 4 - Touch pressure is detected.
* See #tp_event_t structure definition for detailed explanation.
* @note #ft5xx6_process function must be called to update all events.
*
* @b Example
* @code
* // FT5xx6 driver object.
* ft5xx6_t ft5xx6;
* // Touch pressure event.
* tp_event_t event;
*
* // Checking touch pressure event.
* event = ft5xx6_press_detect( &ft5xx6 );
* @endcode
*/
tp_event_t
ft5xx6_press_detect( ft5xx6_t * ctx );
/**
* @brief FT5xx6 Pressure Coordinates Check Function.
* @details This function allows user to get the informations about the number
* of pressed touch points, coordinates and touch event for each pressed touch
* point.
* @param[in] ctx : FT5xx6 context object. See #ft5xx6_t structure definition
* for detailed explanation.
* @param[out] touch_item : Touch item data. See #tp_touch_item_t structure
* definition for detailed explanation.
* @return Nothing.
* @note #ft5xx6_process function must be called to update all events.
*
* @b Example
* @code
* // FT5xx6 driver object.
* ft5xx6_t ft5xx6;
* // Touch pressure item.
* tp_touch_item_t tp_item;
*
* // To get all necessary data information about pressed touch.
* ft5xx6_press_coordinates( &ft5xx6, &tp_item );
* @endcode
*/
void
ft5xx6_press_coordinates( ft5xx6_t * ctx, tp_touch_item_t * touch_item );
/**
* @brief FT5xx6 Gesture Check Function.
* @details This function allows user to get the informations about the gesture
* (slide direction).
* @param[in] ctx : FT5xx6 context object. See #ft5xx6_t structure definition
* for detailed explanation.
* @param[out] event : Touch panel gesture data. See #tp_event_t structure
* definition for detailed explanation.
* @return Nothing.
* @note #ft5xx6_process function must be called to update all events.
*
* @b Example
* @code
* // FT5xx6 driver object.
* ft5xx6_t ft5xx6;
* // Gesture event.
* tp_event_t event;
*
* // Checking slide direction event of pressed touch.
* ft5xx6_gesture( &ft5xx6, &event );
* @endcode
*/
void
ft5xx6_gesture( ft5xx6_t * ctx, tp_event_t * event );
/**
* @brief FT5xx6 Process Function.
* @details This function detects a touch pressure, and if any touch pressure
* was detected, then collects all informations about the pressed touch and
* slide direction (gesture).
* @param[in] ctx : FT5xx6 context object. See #ft5xx6_t structure definition
* for detailed explanation.
* @return @li @c 0 - OK,
* @li @c 5 - Number of pressed touches is out of range.
* See #tp_err_t structure definition for detailed explanation.
* @note To update all possible events, just need to call this function before
* the any other function for checking events is called.
*
* @b Example
* @code
* // FT5xx6 driver object.
* ft5xx6_t ft5xx6;
* // TP error code.
* tp_err_t error;
*
* // Processing all data and events of the target touch controller.
* error = ft5xx6_process( &ft5xx6 );
* @endcode
*/
tp_err_t
ft5xx6_process( ft5xx6_t * ctx );
#ifdef __cplusplus
}
#endif
#endif // FT5XX6_H
/*! @} */ // ft5xx6
/*! @} */ // middlewaregroup
// ------------------------------------------------------------------------ END

82
lcd/lcd.c Normal file
View File

@ -0,0 +1,82 @@
/*
* File: lcd.c
* Author: pascal.sartoret
*
* Created on 16. d<>cembre 2020, 14:04
*/
#define _XTAL_FREQ 25000000L
#include <xc.h>
#include <string.h>
#include "lcd.h"
#include "ssd1963_cmd.h"
int8_t Lcd_Init(void)
{
//--------------------------------------------------------------------------
// define GPIO for LCD
DIR_LCD_RS = 0; // RS is an output
LCD_RS = 0; // command mode
DIR_LCD_CS = 0; // chip select is an output
LCD_CS = 0; // do not select the LCD
LCD_DATA_L_DIR = LCD_DATA_L_DIR & 0x0F; // data port is 4 bits output
__delay_ms(200); // power on delay
LCD_2x16_WriteCmd(0x02);
LCD_2x16_WriteCmd(0x28);
// LCD_2x16_WriteCmd(0x2B);
// LCD_2x16_WriteCmd(0x2B);
LCD_2x16_WriteCmd(0x01); // clear display
LCD_2x16_WriteCmd(0x0C);
// LCD_2x16_WriteCmd(0x14);
// __delay_ms(2);
LCD_2x16_WriteCmd(0x06);
// __delay_ms(100);
return 0;
}
void LCD_2x16_WriteCmd(uint8_t command)
{
LCD_RS = 0; // command mode
LCD_DATA_L = (command & 0xF0) | (LCD_DATA_L & 0x0F); // bits to set
LCD_CS = 1; // chip select
__delay_us(10);
LCD_CS = 0; // chip deselect
__delay_us(1);
command = command << 4;
LCD_DATA_L = (command & 0xF0) | (LCD_DATA_L & 0x0F); // bits to set
LCD_CS = 1; // chip select
__delay_us(10);
LCD_CS = 0; // chip deselect
__delay_ms(3);
}
void LCD_2x16_WriteData(uint8_t command)
{
LCD_RS = 1; // command mode
LCD_DATA_L = (command & 0xF0) | (LCD_DATA_L & 0x0F); // bits to set
LCD_CS = 1; // chip select
__delay_us(1);
LCD_CS = 0; // chip deselect
__delay_us(1);
command = command << 4;
LCD_DATA_L = (command & 0xF0) | (LCD_DATA_L & 0x0F); // bits to set
LCD_CS = 1; // chip select
__delay_us(1);
LCD_CS = 0; // chip deselect
__delay_us(100);
}
void LCD_2x16_WriteMsg(unsigned char * msg, uint8_t line)
{
LCD_2x16_WriteCmd(0x80 | (line << 6));
do
{
LCD_2x16_WriteData(*msg);
msg++;
}while(*msg != 0);
}

59
lcd/lcd.h Normal file
View File

@ -0,0 +1,59 @@
/* Microchip Technology Inc. and its subsidiaries. You may use this software
* and any derivatives exclusively with Microchip products.
*
* THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
* EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
* WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
* PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
* WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
*
* IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
* INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
* WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
* BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
* FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS
* IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF
* ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
*
* MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
* TERMS.
*/
/*
* File:
* Author:
* Comments:
* Revision history:
*/
// This is a guard condition so that contents of this file are not included
// more than once.
#ifndef LCD_H
#define LCD_H
#include <xc.h> // include processor files - each processor file is guarded.
// 2x16 character definitions
#define LCD_RS LATDbits.LATD3
#define DIR_LCD_RS TRISDbits.TRISD3
#define LCD_CS LATDbits.LATD2
#define DIR_LCD_CS TRISDbits.TRISD2
#define LCD_DATA_L_DIR TRISJ
#define LCD_DATA_L LATJ
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
int8_t Lcd_Init(void);
void LCD_2x16_WriteCmd(uint8_t command);
void LCD_2x16_WriteData(uint8_t command);
void LCD_2x16_WriteMsg(unsigned char * msg, uint8_t line);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* LCD_H */

456
lcd/ssd1963_cmd.h Normal file
View File

@ -0,0 +1,456 @@
/****************************************************************************
**
** Copyright (C) 2020 MikroElektronika d.o.o.
** Contact: https://www.mikroe.com/contact
**
** This file is part of the mikroSDK package
**
** Commercial License Usage
**
** Licensees holding valid commercial NECTO compilers AI licenses may use this
** file in accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The mikroElektronika Company.
** For licensing terms and conditions see
** https://www.mikroe.com/legal/software-license-agreement.
** For further information use the contact form at
** https://www.mikroe.com/contact.
**
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used for
** non-commercial projects under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** The above copyright notice and this permission notice shall be
** included in all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** OF MERCHANTABILITY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
** TO THE WARRANTIES FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**
****************************************************************************/
/*!
* @file ssd1963_cmd.h
* @brief SSD1963 Display Controller Commands.
*/
/*!
* @addtogroup middlewaregroup Middleware
* @{
*/
/*!
* @addtogroup ssd1963 SSD1963 Display Controller Driver
* @{
*/
/*!
* @addtogroup ssd1963_commands SSD1963 Display Controller Commands
* @brief SSD1963 Display Controller Command List
* @{
*/
#ifndef SSD1963_CMD_H
#define SSD1963_CMD_H
/**
* @brief No operation.
*/
#define SSD1963_CMD_NOP 0X00
/**
* @brief Software Reset.
*/
#define SSD1963_CMD_SOFT_RESET 0x01
/**
* @brief Get the current power mode.
*/
#define SSD1963_CMD_GET_POWER_MODE 0x0A
/**
* @brief Get the frame buffer to the display panel read order.
*/
#define SSD1963_CMD_GET_ADDRESS_MODE 0x0B
// #define SSD1963_CMD_RESERVED 0X0C
/**
* @brief The SSD1963 returns the Display Image Mode.
*/
#define SSD1963_CMD_GET_DISPLAY_MODE 0x0D
/**
* @brief Get the Tear Effect status.
*/
#define SSD1963_CMD_GET_TEAR_EFFECT_status 0x0E
//#define SSD1963_CMD_RESERVED 0X0F
/**
* @brief Turn off the panel. This command will pull high the GPIO0. If GPIO0 is configured as normal GPIO or LCD miscellaneous signal with command set_gpio_conf, this command will be ignored.
*/
#define SSD1963_CMD_ENTER_SLEEP_MODE 0x10
/**
* @brief Turn on the panel. This command will pull low the GPIO0. If GPIO0 is configured as normal GPIO or LCD miscellaneous signal with command set_gpio_conf, this command will be ignored.
*/
#define SSD1963_CMD_EXIT_SLEEP_MODE 0x11
/**
* @brief Part of the display area is used for image display.
*/
#define SSD1963_CMD_ENTER_PARTIAL_MODE 0x12
/**
* @brief The whole display area is used for image display.
*/
#define SSD1963_CMD_ENTER_NORMAL_MODE 0x13
/**
* @brief Displayed image colors are not inverted.
*/
#define SSD1963_CMD_EXIT_INVERT_MODE 0x20
/**
* @brief Displayed image colors are inverted.
*/
#define SSD1963_CMD_ENTER_INVERT_MODE 0x21
/**
* @brief Selects the gamma curve used by the display panel.
*/
#define SSD1963_CMD_SET_GAMMA_CURVE 0x26
/**
* @brief Blanks the display panel.
*/
#define SSD1963_CMD_SET_DISPLAY_OFF 0x28
/**
* @brief Show the image on the display panel.
*/
#define SSD1963_CMD_SET_DISPLAY_ON 0x29
/**
* @brief Set the column address.
*/
#define SSD1963_CMD_SET_COLUMN_ADDRESS 0x2A
/**
* @brief Set the page address.
*/
#define SSD1963_CMD_SET_PAGE_ADDRESS 0x2B
/**
* @brief Transfer image information from the host processor interface to the SSD1963 starting at the location provided by set_column_address and set_page_address.
*/
#define SSD1963_CMD_WRITE_MEMORY_START 0x2C
/**
* @brief Transfer image data from the SSD1963 to the host processor interface starting at the location provided by set_column_address and set_page_address.
*/
#define SSD1963_CMD_READ_MEMORY_START 0x2E
/**
* @brief Defines the partial display area on the display panel.
*/
#define SSD1963_CMD_SET_PARTIAL_AREA 0x30
/**
* @brief Defines the vertical scrolling and fixed area on display area.
*/
#define SSD1963_CMD_SET_SCROLL_AREA 0x33
/**
* @brief Synchronization information is not sent from the SSD1963 to the host processor.
*/
#define SSD1963_CMD_SET_TEAR_OFF 0x34
/**
* @brief Synchronization information is sent from the SSD1963 to the host processor at the start of VFP.
*/
#define SSD1963_CMD_SET_TEAR_ON 0x35
/**
* @brief Set the read order from frame buffer to the display panel.
*/
#define SSD1963_CMD_SET_ADDRESS_MODE 0x36
/**
* @brief Defines the vertical scrolling starting point.
*/
#define SSD1963_CMD_SET_SCROLL_START 0x37
/**
* @brief Full color depth is used for the display panel.
*/
#define SSD1963_CMD_EXIT_IDLE_MODE 0x38
/**
* @brief Reduce color depth is used on the display panel.
*/
#define SSD1963_CMD_ENTER_IDLE_MODE 0x39
// #define SSD1963_CMD_RESERVED 0X3A
/**
* @brief Transfer image information from the host processor interface to the SSD1963 from the last written location.
*/
#define SSD1963_CMD_WRITE_MEMORY_CONTINUE 0x3C
/**
* @brief Read image data from the SSD1963 continuing after the last read_memory_continue or read_memory_start.
*/
#define SSD1963_CMD_READ_MEMORY_CONTINUE 0x3E
/**
* @brief Synchronization information is sent from the SSD1963 to the host processor when the display panel refresh reaches the provided scan line.
*/
#define SSD1963_CMD_SET_TEAR_SCANLINE 0x44
/**
* @brief Get the current scan line.
*/
#define SSD1963_CMD_GET_SCANLINE 0x45
/**
* @brief Read the DDB from the provided location.
*/
#define SSD1963_CMD_READ_DDB 0xA1
// #define SSD1963_CMD_RESERVED 0xA8
/**
* @brief Set the LCD panel mode and resolution.
*/
#define SSD1963_CMD_SET_LCD_MODE 0xB0
/**
* @brief Get the current LCD panel mode, pad strength and resolution.
*/
#define SSD1963_CMD_GET_LCD_MODE 0xB1
/**
* @brief Set front porch
*/
#define SSD1963_CMD_SET_HORI_PERIOD 0xB4
/**
* @brief Get current front porch settings.
*/
#define SSD1963_CMD_GET_HORI_PERIOD 0xB5
/**
* @brief Set the vertical blanking interval between last scan line and next LFRAME pulse.
*/
#define SSD1963_CMD_SET_VERT_PERIOD 0xB6
/**
* @brief Get the vertical blanking interval between last scan line and next LFRAME pulse.
*/
#define SSD1963_CMD_GET_VERT_PERIOD 0xB7
/**
* @brief Set the GPIO configuration. If the GPIO is not used for LCD, set the direction. Otherwise, they are toggled with LCD signals.
*/
#define SSD1963_CMD_SET_GPIO_CONF 0xB8
/**
* @brief Get the current GPIO configuration.
*/
#define SSD1963_CMD_GET_GPIO_CONF 0xB9
/**
* @brief Set GPIO value for GPIO configured as output.
*/
#define SSD1963_CMD_SET_GPIO_VALUE 0xBA
/**
* @brief Read current GPIO status. If the individual GPIO was configured as input, the value is the status of the corresponding pin. Otherwise, it is the programmed value.
*/
#define SSD1963_CMD_GET_GPIO_STATUS 0xBB
/**
* @brief Set the image post processor.
*/
#define SSD1963_CMD_SET_POST_PROC 0xBC
/**
* @brief Get the image post processor.
*/
#define SSD1963_CMD_GET_POST_PROC 0xBD
/**
* @brief Set the image post processor.
*/
#define SSD1963_CMD_SET_PWM_CONF 0xBE
/**
* @brief Get the image post processor.
*/
#define SSD1963_CMD_GET_PWM_CONF 0xBF
/**
* @brief Set the rise, fall, period and toggling properties of LCD signal generator 0.
*/
#define SSD1963_CMD_SET_LCD_GEN0 0xC0
/**
* @brief Get the current settings of LCD signal generator 0.
*/
#define SSD1963_CMD_GET_LCD_GEN0 0xC1
/**
* @brief Set the rise, fall, period and toggling properties of LCD signal generator 1.
*/
#define SSD1963_CMD_SET_LCD_GEN1 0xC2
/**
* @brief Get the current settings of LCD signal generator 1.
*/
#define SSD1963_CMD_GET_LCD_GEN1 0xC3
/**
* @brief Set the rise, fall, period and toggling properties of LCD signal generator 2.
*/
#define SSD1963_CMD_SET_LCD_GEN2 0xC4
/**
* @brief Get the current settings of LCD signal generator 2.
*/
#define SSD1963_CMD_GET_LCD_GEN2 0xC5
/**
* @brief Set the rise, fall, period and toggling properties of LCD signal generator 3.
*/
#define SSD1963_CMD_SET_LCD_GEN3 0xC6
/**
* @brief Get the current settings of LCD signal generator 3.
*/
#define SSD1963_CMD_GET_LCD_GEN3 0xC7
/**
* @brief Set the GPIO0 with respect to the LCD signal generators using ROP operation. No effect if the GPIO0 is configured as general GPIO.
*/
#define SSD1963_CMD_SET_GPIO0_ROP 0xC8
/**
* @brief Get the GPIO0 properties with respect to the LCD signal generators.
*/
#define SSD1963_CMD_GET_GPIO0_ROP 0xC9
/**
* @brief Set the GPIO1 with respect to the LCD signal generators using ROP operation. No effect if the GPIO1 is configured as general GPIO.
*/
#define SSD1963_CMD_SET_GPIO1_ROP 0xCA
/**
* @brief Get the GPIO1 properties with respect to the LCD signal generators.
*/
#define SSD1963_CMD_GET_GPIO1_ROP 0xCB
/**
* @brief Set the GPIO2 with respect to the LCD signal generators using ROP operation. No effect if the GPIO2 is configured as general GPIO.
*/
#define SSD1963_CMD_SET_GPIO2_ROP 0xCC
/**
* @brief Get the GPIO2 properties with respect to the LCD signal generators.
*/
#define SSD1963_CMD_GET_GPIO2_ROP 0xCD
/**
* @brief Set the GPIO3 with respect to the LCD signal generators using ROP operation. No effect if the GPIO3 is configured as general GPIO.
*/
#define SSD1963_CMD_SET_GPIO3_ROP 0xCE
/**
* @brief Get the GPIO3 properties with respect to the LCD signal generators.
*/
#define SSD1963_CMD_GET_GPIO3_ROP 0xCF
/**
* @brief Set the dynamic back light configuration.
*/
#define SSD1963_CMD_SET_DBC_CONF 0xD0
/**
* @brief Get the current dynamic back light configuration.
*/
#define SSD1963_CMD_GET_DBC_CONF 0xD
/**
* @brief Set the threshold for each level of power saving.
*/
#define SSD1963_CMD_SET_DBC_TH 0xD4
/**
* @brief Get the threshold for each level of power saving.
*/
#define SSD1963_CMD_GET_DBC_TH 0xD5
/**
* @brief Start the PLL. Before the start, the system was operated with the crystal oscillator or clock input.
*/
#define SSD1963_CMD_SET_PLL 0xE0
/**
* @brief Set the PLL.
*/
#define SSD1963_CMD_SET_PLL_MN 0xE2
/**
* @brief Get the PLL settings.
*/
#define SSD1963_CMD_GET_PLL_MN 0xE3
/**
* @brief Get the current PLL status.
*/
#define SSD1963_CMD_GET_PLL_STATUS 0xE4
/**
* @brief Set deep sleep mode.
*/
#define SSD1963_CMD_SET_DEEP_SLEEP 0xE5
/**
* @brief Set the LSHIFT (pixel clock) frequency.
*/
#define SSD1963_CMD_SET_LSHIFT_FREQ 0xE6
/**
* @brief Get current LSHIFT (pixel clock) frequency setting.
*/
#define SSD1963_CMD_GET_LSHIFT_FREQ 0xE7
// #define SSD1963_CMD_RESERVED 0xE8
// #define SSD1963_CMD_RESERVED 0xE9
/**
* @brief Set the pixel data format of the parallel host processor interface.
*/
#define SSD1963_CMD_SET_PIXEL_DATA_INTERFACE 0xF0
/**
* @brief Get the current pixel data format settings.
*/
#define SSD1963_CMD_GET_PIXEL_DATA_INTERFACE 0xF1
// #define SSD1963_CMD_RESERVED 0xFF
/*! @} */ // ssd1963
/*! @} */ // ssd1963
/*! @} */ // mwgroup
#endif // SSD1963_CMD_H
// ------------------------------------------------------------------------- END