1
0

add P4 & P5

This commit is contained in:
2025-11-24 15:44:12 +01:00
parent bd24f1fb79
commit f6fa6d94ce
1120 changed files with 576492 additions and 83 deletions

View File

@@ -0,0 +1,212 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for BSP Components Common Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-bsp-components-common-drivers"><small>Release Notes for</small> <mark>BSP Components Common Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the BSP components common drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V5.1.2 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section21" aria-hidden="true"> <label for="collapse-section21" aria-hidden="true">V5.1.1 / 31-August-2018</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
<li>Correct sensor names in headers files hsensor.h and psensor.h</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section20" aria-hidden="true"> <label for="collapse-section20" aria-hidden="true">V5.1.0 / 21-November-2017</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>Add dpredriver.h: support of DP redriver class</li>
<li>Add pwrmon.h: support of power monitor class</li>
<li>Add usbtypecswitch.h: support of USB type C switch class</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V5.0.0 / 01-March-2017</label>
<div>
<h2 id="main-changes-3">Main Changes</h2>
<ul>
<li>Add hsensor.h: support of humidity class</li>
<li>Add psensor.h: support of pressure class</li>
<li>Update tsensor.h: Temperature can be negative</li>
<li>Update accelero.h: LowPower API can enable or disable the low power mode</li>
<li>Update magneto.h: LowPower API can enable or disable the low power mode</li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">Notes:</span></span></strong></p>
<p>This version breaks the compatibility with previous versions.</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V4.0.1 / 21-July-2015</label>
<div>
<h2 id="main-changes-4">Main Changes</h2>
<ul>
<li>tsensor.h: Fix compilation issue on TSENSOR_InitTypeDef</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section17" aria-hidden="true"> <label for="collapse-section17" aria-hidden="true">V4.0.0 / 22-June-2015</label>
<div>
<h2 id="main-changes-5">Main Changes</h2>
<ul>
<li>accelero.h: add *DeInit field in ACCELERO_DrvTypeDef structure</li>
<li>audio.h: add *DeInit field in AUDIO_DrvTypeDef structure</li>
<li>idd.h:
<ul>
<li>add Shunt0StabDelay, Shunt1StabDelay, Shunt2StabDelay, Shunt3StabDelay, Shunt4StabDelay and ShuntNbOnBoard fields in IDD_ConfigTypeDef structure</li>
<li>rename ShuntNumber field to ShuntNbUsed in IDD_ConfigTypeDef structure</li>
</ul></li>
<li>magneto.h: add *DeInit field in MAGNETO_DrvTypeDef structure</li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">Important Note:</span></span></strong></p>
<p>This release V4.0.0 is not backward compatible with V3.0.0.</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section16" aria-hidden="true"> <label for="collapse-section16" aria-hidden="true">V3.0.0 / 28-April-2015</label>
<div>
<h2 id="main-changes-6">Main Changes</h2>
<ul>
<li>accelero.h: add <em>LowPower</em> field in ACCELERO_DrvTypeDef structure</li>
<li>magneto.h: add <em>LowPower</em> field in MAGNETO_DrvTypeDef structure</li>
<li>gyro.h: add <em>DeInit</em> and <em>LowPower</em> fields in GYRO_DrvTypeDef structure</li>
<li>camera.h: add CAMERA_COLOR_EFFECT_NONE define</li>
<li>idd.h:
<ul>
<li>add MeasureNb, DeltaDelayUnit and DeltaDelayValue fields in IDD_ConfigTypeDef structure</li>
<li>rename PreDelay field to PreDelayUnit in IDD_ConfigTypeDef structure</li>
</ul></li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">Important Note:</span></span></strong></p>
<p>This release V3.0.0 is not backward compatible with V2.2.0.</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section155" aria-hidden="true"> <label for="collapse-section155" aria-hidden="true">V2.2.0 / 09-February-2015</label>
<div>
<h2 id="main-changes-7">Main Changes</h2>
<ul>
<li>Magnetometer driver function prototypes added (magneto.h file)</li>
<li>Update “idd.h” file to provide DeInit() and WakeUp() services in IDD current measurement driver</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section15" aria-hidden="true"> <label for="collapse-section15" aria-hidden="true">V2.1.0 / 06-February-2015</label>
<div>
<h2 id="main-changes-8">Main Changes</h2>
<ul>
<li>IDD current measurement driver function prototypes added (idd.h file)</li>
<li>io.h: add new typedef enum IO_PinState with IO_PIN_RESET and IO_PIN_SET values</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section12" aria-hidden="true"> <label for="collapse-section12" aria-hidden="true">V2.0.0 / 15-December-2014</label>
<div>
<h2 id="main-changes-9">Main Changes</h2>
<ul>
<li>Update “io.h” file to support MFX (Multi Function eXpander) device available on some STM32 boards
<ul>
<li>add new entries for IO_ModeTypedef enumeration structure</li>
<li>update the IO_DrvTypeDef structure
<ul>
<li>Update all return values and function parameters to uint32_t</li>
<li>Add a return value for Config field</li>
</ul></li>
</ul></li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">Important Note:</span></span></strong></p>
<p>This version V2.0.0 is not backward compatible with V1.2.1.</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section9" aria-hidden="true"> <label for="collapse-section9" aria-hidden="true">V1.2.1 / 02-December-2014</label>
<div>
<h2 id="main-changes-10">Main Changes</h2>
<ul>
<li>gyro.h: change “__GIRO_H” by “__GYRO_H” to fix compilation issue under Mac OS</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section8" aria-hidden="true"> <label for="collapse-section8" aria-hidden="true">V1.2.0 / 18-June-2014</label>
<div>
<h2 id="main-changes-11">Main Changes</h2>
<ul>
<li>EPD (E Paper Display) driver function prototype added (epd.h file)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section7" aria-hidden="true"> <label for="collapse-section7" aria-hidden="true">V1.1.0 / 21-March-2014</label>
<div>
<h2 id="main-changes-12">Main Changes</h2>
<ul>
<li>Temperature Sensor driver function prototype added</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section7" aria-hidden="true"> <label for="collapse-section7" aria-hidden="true">V1.0.0 / 18-February-2014</label>
<div>
<h2 id="main-changes-13">Main Changes</h2>
<ul>
<li>First official release with Accelerometer, Audio, Camera, Gyroscope, IO, LCD and Touch Screen drivers function prototypes</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,125 @@
/**
******************************************************************************
* @file accelero.h
* @author MCD Application Team
* @brief This header file contains the functions prototypes for the Accelerometer driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __ACCELERO_H
#define __ACCELERO_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup ACCELERO
* @{
*/
/** @defgroup ACCELERO_Exported_Types
* @{
*/
/** @defgroup ACCELERO_Driver_structure Accelerometer Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t);
void (*DeInit)(void);
uint8_t (*ReadID)(void);
void (*Reset)(void);
void (*LowPower)(uint16_t);
void (*ConfigIT)(void);
void (*EnableIT)(uint8_t);
void (*DisableIT)(uint8_t);
uint8_t (*ITStatus)(uint16_t);
void (*ClearIT)(void);
void (*FilterConfig)(uint8_t);
void (*FilterCmd)(uint8_t);
void (*GetXYZ)(int16_t *);
}ACCELERO_DrvTypeDef;
/**
* @}
*/
/** @defgroup ACCELERO_Configuration_structure Accelerometer Configuration structure
* @{
*/
/* ACCELERO struct */
typedef struct
{
uint8_t Power_Mode; /* Power-down/Normal Mode */
uint8_t AccOutput_DataRate; /* OUT data rate */
uint8_t Axes_Enable; /* Axes enable */
uint8_t High_Resolution; /* High Resolution enabling/disabling */
uint8_t BlockData_Update; /* Block Data Update */
uint8_t Endianness; /* Endian Data selection */
uint8_t AccFull_Scale; /* Full Scale selection */
uint8_t Communication_Mode;
}ACCELERO_InitTypeDef;
/* ACCELERO High Pass Filter struct */
typedef struct
{
uint8_t HighPassFilter_Mode_Selection; /* Internal filter mode */
uint8_t HighPassFilter_CutOff_Frequency; /* High pass filter cut-off frequency */
uint8_t HighPassFilter_AOI1; /* HPF_enabling/disabling for AOI function on interrupt 1 */
uint8_t HighPassFilter_AOI2; /* HPF_enabling/disabling for AOI function on interrupt 2 */
uint8_t HighPassFilter_Data_Sel;
uint8_t HighPassFilter_Stat;
}ACCELERO_FilterConfigTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __ACCELERO_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,104 @@
/**
******************************************************************************
* @file audio.h
* @author MCD Application Team
* @brief This header file contains the common defines and functions prototypes
* for the Audio driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __AUDIO_H
#define __AUDIO_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup AUDIO
* @{
*/
/** @defgroup AUDIO_Exported_Constants
* @{
*/
/* Codec audio Standards */
#define CODEC_STANDARD 0x04
#define I2S_STANDARD I2S_STANDARD_PHILIPS
/**
* @}
*/
/** @defgroup AUDIO_Exported_Types
* @{
*/
/** @defgroup AUDIO_Driver_structure Audio Driver structure
* @{
*/
typedef struct
{
uint32_t (*Init)(uint16_t, uint16_t, uint8_t, uint32_t);
void (*DeInit)(void);
uint32_t (*ReadID)(uint16_t);
uint32_t (*Play)(uint16_t, uint16_t*, uint16_t);
uint32_t (*Pause)(uint16_t);
uint32_t (*Resume)(uint16_t);
uint32_t (*Stop)(uint16_t, uint32_t);
uint32_t (*SetFrequency)(uint16_t, uint32_t);
uint32_t (*SetVolume)(uint16_t, uint8_t);
uint32_t (*SetMute)(uint16_t, uint32_t);
uint32_t (*SetOutputMode)(uint16_t, uint8_t);
uint32_t (*Reset)(uint16_t);
}AUDIO_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __AUDIO_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,123 @@
/**
******************************************************************************
* @file camera.h
* @author MCD Application Team
* @brief This header file contains the common defines and functions prototypes
* for the camera driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CAMERA_H
#define __CAMERA_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup CAMERA
* @{
*/
/** @defgroup CAMERA_Exported_Types
* @{
*/
/** @defgroup CAMERA_Driver_structure Camera Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t, uint32_t);
uint16_t (*ReadID)(uint16_t);
void (*Config)(uint16_t, uint32_t, uint32_t, uint32_t);
}CAMERA_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/** @defgroup CAMERA_Exported_Constants
* @{
*/
#define CAMERA_R160x120 0x00 /* QQVGA Resolution */
#define CAMERA_R320x240 0x01 /* QVGA Resolution */
#define CAMERA_R480x272 0x02 /* 480x272 Resolution */
#define CAMERA_R640x480 0x03 /* VGA Resolution */
#define CAMERA_CONTRAST_BRIGHTNESS 0x00 /* Camera contrast brightness features */
#define CAMERA_BLACK_WHITE 0x01 /* Camera black white feature */
#define CAMERA_COLOR_EFFECT 0x03 /* Camera color effect feature */
#define CAMERA_BRIGHTNESS_LEVEL0 0x00 /* Brightness level -2 */
#define CAMERA_BRIGHTNESS_LEVEL1 0x01 /* Brightness level -1 */
#define CAMERA_BRIGHTNESS_LEVEL2 0x02 /* Brightness level 0 */
#define CAMERA_BRIGHTNESS_LEVEL3 0x03 /* Brightness level +1 */
#define CAMERA_BRIGHTNESS_LEVEL4 0x04 /* Brightness level +2 */
#define CAMERA_CONTRAST_LEVEL0 0x05 /* Contrast level -2 */
#define CAMERA_CONTRAST_LEVEL1 0x06 /* Contrast level -1 */
#define CAMERA_CONTRAST_LEVEL2 0x07 /* Contrast level 0 */
#define CAMERA_CONTRAST_LEVEL3 0x08 /* Contrast level +1 */
#define CAMERA_CONTRAST_LEVEL4 0x09 /* Contrast level +2 */
#define CAMERA_BLACK_WHITE_BW 0x00 /* Black and white effect */
#define CAMERA_BLACK_WHITE_NEGATIVE 0x01 /* Negative effect */
#define CAMERA_BLACK_WHITE_BW_NEGATIVE 0x02 /* BW and Negative effect */
#define CAMERA_BLACK_WHITE_NORMAL 0x03 /* Normal effect */
#define CAMERA_COLOR_EFFECT_NONE 0x00 /* No effects */
#define CAMERA_COLOR_EFFECT_BLUE 0x01 /* Blue effect */
#define CAMERA_COLOR_EFFECT_GREEN 0x02 /* Green effect */
#define CAMERA_COLOR_EFFECT_RED 0x03 /* Red effect */
#define CAMERA_COLOR_EFFECT_ANTIQUE 0x04 /* Antique effect */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __CAMERA_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,104 @@
/**
******************************************************************************
* @file dpredriver.h
* @author MCD Application Team
* @brief This header file contains the functions prototypes for the
* DisplayPort Linear Redriver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __DPREDRIVER_H
#define __DPREDRIVER_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup DPREDRIVER
* @{
*/
/** @defgroup DPREDRIVER_Exported_Types
* @{
*/
/** @defgroup DPREDRIVER_Channel_Identifier Channel Identifier
* @{
*/
typedef enum {
CHANNEL_DP0 = 0,
CHANNEL_DP1,
CHANNEL_DP2,
CHANNEL_DP3,
CHANNEL_RX1,
CHANNEL_RX2,
CHANNEL_SSTX
} DPREDRIVER_ChannelId_t;
/**
* @}
*/
/** @defgroup DPREDRIVER_Driver_structure DisplayPort Linear Redriver Driver structure
* @{
*/
typedef struct
{
uint32_t (*Init)(uint16_t);
void (*DeInit)(uint16_t);
uint32_t (*PowerOn)(uint16_t);
uint32_t (*PowerOff)(uint16_t);
uint32_t (*SetEQGain)(uint16_t, DPREDRIVER_ChannelId_t, uint8_t);
uint32_t (*EnableChannel)(uint16_t, DPREDRIVER_ChannelId_t);
uint32_t (*DisableChannel)(uint16_t, DPREDRIVER_ChannelId_t);
}DPREDRIVER_Drv_t;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __DPREDRIVER_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,97 @@
/**
******************************************************************************
* @file epd.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the
* EPD (E Paper Display) driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __EPD_H
#define __EPD_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup Common
* @{
*/
/** @addtogroup EPD
* @{
*/
/** @defgroup EPD_Exported_Types
* @{
*/
/** @defgroup EPD_Driver_structure E Paper Display Driver structure
* @{
*/
typedef struct
{
void (*Init)(void);
void (*WritePixel)(uint8_t);
/* Optimized operation */
void (*SetDisplayWindow)(uint16_t, uint16_t, uint16_t, uint16_t);
void (*RefreshDisplay)(void);
void (*CloseChargePump)(void);
uint16_t (*GetEpdPixelWidth)(void);
uint16_t (*GetEpdPixelHeight)(void);
void (*DrawImage)(uint16_t, uint16_t, uint16_t, uint16_t, uint8_t*);
}
EPD_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* EPD_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,127 @@
/**
******************************************************************************
* @file gyro.h
* @author MCD Application Team
* @brief This header file contains the functions prototypes for the gyroscope driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __GYRO_H
#define __GYRO_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup GYRO
* @{
*/
/** @defgroup GYRO_Exported_Types
* @{
*/
/** @defgroup GYRO_Driver_structure Gyroscope Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t);
void (*DeInit)(void);
uint8_t (*ReadID)(void);
void (*Reset)(void);
void (*LowPower)(uint16_t);
void (*ConfigIT)(uint16_t);
void (*EnableIT)(uint8_t);
void (*DisableIT)(uint8_t);
uint8_t (*ITStatus)(uint16_t, uint16_t);
void (*ClearIT)(uint16_t, uint16_t);
void (*FilterConfig)(uint8_t);
void (*FilterCmd)(uint8_t);
void (*GetXYZ)(float *);
}GYRO_DrvTypeDef;
/**
* @}
*/
/** @defgroup GYRO_Config_structure Gyroscope Configuration structure
* @{
*/
typedef struct
{
uint8_t Power_Mode; /* Power-down/Sleep/Normal Mode */
uint8_t Output_DataRate; /* OUT data rate */
uint8_t Axes_Enable; /* Axes enable */
uint8_t Band_Width; /* Bandwidth selection */
uint8_t BlockData_Update; /* Block Data Update */
uint8_t Endianness; /* Endian Data selection */
uint8_t Full_Scale; /* Full Scale selection */
}GYRO_InitTypeDef;
/* GYRO High Pass Filter struct */
typedef struct
{
uint8_t HighPassFilter_Mode_Selection; /* Internal filter mode */
uint8_t HighPassFilter_CutOff_Frequency; /* High pass filter cut-off frequency */
}GYRO_FilterConfigTypeDef;
/*GYRO Interrupt struct */
typedef struct
{
uint8_t Latch_Request; /* Latch interrupt request into CLICK_SRC register */
uint8_t Interrupt_Axes; /* X, Y, Z Axes Interrupts */
uint8_t Interrupt_ActiveEdge; /* Interrupt Active edge */
}GYRO_InterruptConfigTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __GYRO_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,83 @@
/**
******************************************************************************
* @file hsensor.h
* @author MCD Application Team
* @brief This header file contains the functions prototypes for the
* Humidity Sensor driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __HSENSOR_H
#define __HSENSOR_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup HSENSOR
* @{
*/
/** @defgroup HSENSOR_Exported_Types
* @{
*/
/** @defgroup HSENSOR_Driver_structure Humidity Sensor Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t);
uint8_t (*ReadID)(uint16_t);
float (*ReadHumidity)(uint16_t);
}HSENSOR_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __HSENSOR_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,150 @@
/**
******************************************************************************
* @file idd.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the IDD driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __IDD_H
#define __IDD_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup IDD
* @{
*/
/** @defgroup IDD_Exported_Types IDD Exported Types
* @{
*/
/** @defgroup IDD_Config_structure IDD Configuration structure
* @{
*/
typedef struct
{
uint16_t AmpliGain; /*!< Specifies ampli gain value
*/
uint16_t VddMin; /*!< Specifies minimum MCU VDD can reach to protect MCU from reset
*/
uint16_t Shunt0Value; /*!< Specifies value of Shunt 0 if existing
*/
uint16_t Shunt1Value; /*!< Specifies value of Shunt 1 if existing
*/
uint16_t Shunt2Value; /*!< Specifies value of Shunt 2 if existing
*/
uint16_t Shunt3Value; /*!< Specifies value of Shunt 3 if existing
*/
uint16_t Shunt4Value; /*!< Specifies value of Shunt 4 if existing
*/
uint16_t Shunt0StabDelay; /*!< Specifies delay of Shunt 0 stabilization if existing
*/
uint16_t Shunt1StabDelay; /*!< Specifies delay of Shunt 1 stabilization if existing
*/
uint16_t Shunt2StabDelay; /*!< Specifies delay of Shunt 2 stabilization if existing
*/
uint16_t Shunt3StabDelay; /*!< Specifies delay of Shunt 3 stabilization if existing
*/
uint16_t Shunt4StabDelay; /*!< Specifies delay of Shunt 4 stabilization if existing
*/
uint8_t ShuntNbOnBoard; /*!< Specifies number of shunts that are present on board
This parameter can be a value of @ref IDD_shunt_number */
uint8_t ShuntNbUsed; /*!< Specifies number of shunts used for measurement
This parameter can be a value of @ref IDD_shunt_number */
uint8_t VrefMeasurement; /*!< Specifies if Vref is automatically measured before each Idd measurement
This parameter can be a value of @ref IDD_Vref_Measurement */
uint8_t Calibration; /*!< Specifies if calibration is done before each Idd measurement
*/
uint8_t PreDelayUnit; /*!< Specifies Pre delay unit
This parameter can be a value of @ref IDD_PreDelay */
uint8_t PreDelayValue; /*!< Specifies Pre delay value in selected unit
*/
uint8_t MeasureNb; /*!< Specifies number of Measure to be performed
This parameter can be a value between 1 and 256 */
uint8_t DeltaDelayUnit; /*!< Specifies Delta delay unit
This parameter can be a value of @ref IDD_DeltaDelay */
uint8_t DeltaDelayValue; /*!< Specifies Delta delay between 2 measures
value can be between 1 and 128 */
}IDD_ConfigTypeDef;
/**
* @}
*/
/** @defgroup IDD_Driver_structure IDD Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t);
void (*DeInit)(uint16_t);
uint16_t (*ReadID)(uint16_t);
void (*Reset)(uint16_t);
void (*LowPower)(uint16_t);
void (*WakeUp)(uint16_t);
void (*Start)(uint16_t);
void (*Config)(uint16_t,IDD_ConfigTypeDef);
void (*GetValue)(uint16_t, uint32_t *);
void (*EnableIT)(uint16_t);
void (*ClearIT)(uint16_t);
uint8_t (*GetITStatus)(uint16_t);
void (*DisableIT)(uint16_t);
void (*ErrorEnableIT)(uint16_t);
void (*ErrorClearIT)(uint16_t);
uint8_t (*ErrorGetITStatus)(uint16_t);
void (*ErrorDisableIT)(uint16_t);
uint8_t (*ErrorGetSrc)(uint16_t);
uint8_t (*ErrorGetCode)(uint16_t);
}IDD_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __IDD_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,132 @@
/**
******************************************************************************
* @file io.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the IO driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __IO_H
#define __IO_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup IO
* @{
*/
/** @defgroup IO_Exported_Types
* @{
*/
/**
* @brief IO Bit SET and Bit RESET enumeration
*/
typedef enum
{
IO_PIN_RESET = 0,
IO_PIN_SET
}IO_PinState;
typedef enum
{
IO_MODE_INPUT = 0, /* input floating */
IO_MODE_OUTPUT, /* output Push Pull */
IO_MODE_IT_RISING_EDGE, /* float input - irq detect on rising edge */
IO_MODE_IT_FALLING_EDGE, /* float input - irq detect on falling edge */
IO_MODE_IT_LOW_LEVEL, /* float input - irq detect on low level */
IO_MODE_IT_HIGH_LEVEL, /* float input - irq detect on high level */
/* following modes only available on MFX*/
IO_MODE_ANALOG, /* analog mode */
IO_MODE_OFF, /* when pin isn't used*/
IO_MODE_INPUT_PU, /* input with internal pull up resistor */
IO_MODE_INPUT_PD, /* input with internal pull down resistor */
IO_MODE_OUTPUT_OD, /* Open Drain output without internal resistor */
IO_MODE_OUTPUT_OD_PU, /* Open Drain output with internal pullup resistor */
IO_MODE_OUTPUT_OD_PD, /* Open Drain output with internal pulldown resistor */
IO_MODE_OUTPUT_PP, /* PushPull output without internal resistor */
IO_MODE_OUTPUT_PP_PU, /* PushPull output with internal pullup resistor */
IO_MODE_OUTPUT_PP_PD, /* PushPull output with internal pulldown resistor */
IO_MODE_IT_RISING_EDGE_PU, /* push up resistor input - irq on rising edge */
IO_MODE_IT_RISING_EDGE_PD, /* push dw resistor input - irq on rising edge */
IO_MODE_IT_FALLING_EDGE_PU, /* push up resistor input - irq on falling edge */
IO_MODE_IT_FALLING_EDGE_PD, /* push dw resistor input - irq on falling edge */
IO_MODE_IT_LOW_LEVEL_PU, /* push up resistor input - irq detect on low level */
IO_MODE_IT_LOW_LEVEL_PD, /* push dw resistor input - irq detect on low level */
IO_MODE_IT_HIGH_LEVEL_PU, /* push up resistor input - irq detect on high level */
IO_MODE_IT_HIGH_LEVEL_PD, /* push dw resistor input - irq detect on high level */
}IO_ModeTypedef;
/** @defgroup IO_Driver_structure IO Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t);
uint16_t (*ReadID)(uint16_t);
void (*Reset)(uint16_t);
void (*Start)(uint16_t, uint32_t);
uint8_t (*Config)(uint16_t, uint32_t, IO_ModeTypedef);
void (*WritePin)(uint16_t, uint32_t, uint8_t);
uint32_t (*ReadPin)(uint16_t, uint32_t);
void (*EnableIT)(uint16_t);
void (*DisableIT)(uint16_t);
uint32_t (*ITStatus)(uint16_t, uint32_t);
void (*ClearIT)(uint16_t, uint32_t);
}IO_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __IO_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,96 @@
/**
******************************************************************************
* @file lcd.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the LCD driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __LCD_H
#define __LCD_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup LCD
* @{
*/
/** @defgroup LCD_Exported_Types
* @{
*/
/** @defgroup LCD_Driver_structure LCD Driver structure
* @{
*/
typedef struct
{
void (*Init)(void);
uint16_t (*ReadID)(void);
void (*DisplayOn)(void);
void (*DisplayOff)(void);
void (*SetCursor)(uint16_t, uint16_t);
void (*WritePixel)(uint16_t, uint16_t, uint16_t);
uint16_t (*ReadPixel)(uint16_t, uint16_t);
/* Optimized operation */
void (*SetDisplayWindow)(uint16_t, uint16_t, uint16_t, uint16_t);
void (*DrawHLine)(uint16_t, uint16_t, uint16_t, uint16_t);
void (*DrawVLine)(uint16_t, uint16_t, uint16_t, uint16_t);
uint16_t (*GetLcdPixelWidth)(void);
uint16_t (*GetLcdPixelHeight)(void);
void (*DrawBitmap)(uint16_t, uint16_t, uint8_t*);
void (*DrawRGBImage)(uint16_t, uint16_t, uint16_t, uint16_t, uint8_t*);
}LCD_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __LCD_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,107 @@
/**
******************************************************************************
* @file magneto.h
* @author MCD Application Team
* @brief This header file contains the functions prototypes for the MAGNETO driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAGNETO_H
#define __MAGNETO_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup MAGNETO
* @{
*/
/** @defgroup MAGNETO_Exported_Types
* @{
*/
/** @defgroup MAGNETO_Config_structure Magnetometer Configuration structure
* @{
*/
typedef struct
{
uint8_t Register1;
uint8_t Register2;
uint8_t Register3;
uint8_t Register4;
uint8_t Register5;
}MAGNETO_InitTypeDef;
/**
* @}
*/
/** @defgroup MAGNETO_Driver_structure Magnetometer Driver structure
* @{
*/
typedef struct
{
void (*Init)(MAGNETO_InitTypeDef);
void (*DeInit)(void);
uint8_t (*ReadID)(void);
void (*Reset)(void);
void (*LowPower)(uint16_t);
void (*ConfigIT)(void);
void (*EnableIT)(uint8_t);
void (*DisableIT)(uint8_t);
uint8_t (*ITStatus)(uint16_t);
void (*ClearIT)(void);
void (*FilterConfig)(uint8_t);
void (*FilterCmd)(uint8_t);
void (*GetXYZ)(int16_t *);
}MAGNETO_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __MAGNETO_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,83 @@
/**
******************************************************************************
* @file psensor.h
* @author MCD Application Team
* @brief This header file contains the functions prototypes for the
* Pressure Sensor driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __PSENSOR_H
#define __PSENSOR_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup PSENSOR
* @{
*/
/** @defgroup PSENSOR_Exported_Types
* @{
*/
/** @defgroup PSENSOR_Driver_structure Pressure Sensor Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t);
uint8_t (*ReadID)(uint16_t);
float (*ReadPressure)(uint16_t);
}PSENSOR_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __PSENSOR_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,246 @@
/**
******************************************************************************
* @file pwrmon.h
* @author MCD Application Team
* @brief This header file contains the functions prototypes for the
* Current/Power Monitor device driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __PWRMON_H
#define __PWRMON_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup PWRMON
* @{
*/
/** @defgroup PWRMON_Exported_Types
* @{
*/
/** @defgroup PWRMON_Operating_Mode_enum Power Monitor Operating Mode enums
* @{
*/
typedef enum {
OPERATING_MODE_TRIGGERED = 0,
OPERATING_MODE_CONTINUOUS,
OPERATING_MODE_NB
} PWRMON_OperatingMode_t;
/**
* @}
*/
/** @defgroup PWRMON_Conversion_Time_enum Power Monitor Conversion_Time enums
* @{
*/
typedef enum {
CONVERT_TIME_140 = 0,
CONVERT_TIME_204,
CONVERT_TIME_332,
CONVERT_TIME_588,
CONVERT_TIME_1100,
CONVERT_TIME_2116,
CONVERT_TIME_4156,
CONVERT_TIME_8244,
CONVERT_TIME_NB
} PWRMON_ConvertTime_t;
/**
* @}
*/
/** @defgroup PWRMON_Conversion_Time_enum Power Monitor Conversion_Time enums
* @{
*/
typedef enum {
AVERAGING_MODE_1 = 0,
AVERAGING_MODE_4,
AVERAGING_MODE_16,
AVERAGING_MODE_64,
AVERAGING_MODE_128,
AVERAGING_MODE_256,
AVERAGING_MODE_512,
AVERAGING_MODE_1024,
AVERAGING_MODE_NB
} PWRMON_AveragingMode_t;
/**
* @}
*/
/** @defgroup PWRMON_Device_Configuration_structure Power Monitor Device Configuration structure
* @{
*/
typedef struct
{
PWRMON_ConvertTime_t ShuntConvertTime;
PWRMON_ConvertTime_t BusConvertTime;
PWRMON_AveragingMode_t AveragingMode;
} PWRMON_Config_t;
/**
* @}
*/
/** @defgroup PWRMON_Alert_Polarity_enum Power Monitor Alert Polarity enums
* @{
*/
typedef enum {
ALERT_POLARITY_NORMAL = 0,
ALERT_POLARITY_INVERTED,
ALERT_POLARITY_NB
} PWRMON_AlertPolarity_t;
/**
* @}
*/
/** @defgroup PWRMON_Alert_Latch_Enable_enum Power Monitor Alert Latch Enable enums
* @{
*/
typedef enum {
ALERT_LATCH_DISABLE = 0,
ALERT_LATCH_ENABLE,
ALERT_LATCH_NB
} PWRMON_AlertLatchEnable_t;
/**
* @}
*/
/** @defgroup PWRMON_Alert_Function_enum Power Monitor Alert Function enums
* @{
*/
typedef enum {
ALERT_FUNCTION_NONE = 0,
ALERT_FUNCTION_SOL,
ALERT_FUNCTION_SUL,
ALERT_FUNCTION_BOL,
ALERT_FUNCTION_BUL,
ALERT_FUNCTION_POL,
ALERT_FUNCTION_NB,
} PWRMON_AlertFunction_t;
/**
* @}
*/
/** @defgroup PWRMON_Alert_Configuration_structure Power Monitor Alert Configuration structure
* @{
*/
typedef struct
{
PWRMON_AlertPolarity_t Polarity;
PWRMON_AlertLatchEnable_t LatchEnable;
} PWRMON_AlertPinConfig_t;
/**
* @}
*/
/** @defgroup PWRMON_Voltage_Input_enum Power Monitor Voltage Input enums
* @{
*/
typedef enum {
VOLTAGE_INPUT_SHUNT = 0,
VOLTAGE_INPUT_BUS,
VOLTAGE_INPUT_ALL,
VOLTAGE_INPUT_NB
} PWRMON_InputSignal_t;
/**
* @}
*/
/** @defgroup PWRMON_Flag_enum Power Monitor Flag enums
* @{
*/
typedef enum {
FLAG_ALERT_FUNCTION = 0,
FLAG_CONVERSION_READY,
FLAG_MATH_OVERFLOW,
FLAG_NB
} PWRMON_Flag_t;
/**
* @}
*/
/** @defgroup PWRMON_Driver_structure Power Monitor Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t, PWRMON_Config_t *);
void (*DeInit)(uint16_t);
uint16_t (*ReadId)(uint16_t);
void (*Reset)(uint16_t);
void (*SetCalibration)(uint16_t, uint16_t);
uint16_t (*GetCalibration)(uint16_t);
void (*SetAlertFunction)(uint16_t, PWRMON_AlertFunction_t);
PWRMON_AlertFunction_t (*GetAlertFunction)(uint16_t);
void (*AlertPinConfig)(uint16_t, PWRMON_AlertPinConfig_t *);
void (*SetVBusThreshold)(uint16_t, uint16_t);
uint16_t (*GetVBusThreshold)(uint16_t);
void (*SetVShuntThreshold)(uint16_t, int16_t);
int16_t (*GetVShuntThreshold)(uint16_t);
void (*SetPowerThreshold)(uint16_t, uint32_t);
uint32_t (*GetPowerThreshold)(uint16_t);
void (*AlertThresholdEnableIT)(uint16_t);
void (*AlertThresholdDisableIT)(uint16_t);
void (*ConversionReadyEnableIT)(uint16_t);
void (*ConversionReadyDisableIT)(uint16_t);
void (*StartConversion)(uint16_t, PWRMON_InputSignal_t, PWRMON_OperatingMode_t);
void (*StopConversion)(uint16_t);
uint16_t (*GetVBus)(uint16_t);
int16_t (*GetVShunt)(uint16_t);
uint16_t (*GetPower)(uint16_t);
int16_t (*GetCurrent)(uint16_t);
uint8_t (*GetFlag)(uint16_t, PWRMON_Flag_t);
} PWRMON_Drv_t;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __PWRMON_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,89 @@
/**
******************************************************************************
* @file ts.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the Touch Screen driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __TS_H
#define __TS_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup TS
* @{
*/
/** @defgroup TS_Exported_Types
* @{
*/
/** @defgroup TS_Driver_structure Touch Sensor Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t);
uint16_t (*ReadID)(uint16_t);
void (*Reset)(uint16_t);
void (*Start)(uint16_t);
uint8_t (*DetectTouch)(uint16_t);
void (*GetXY)(uint16_t, uint16_t*, uint16_t*);
void (*EnableIT)(uint16_t);
void (*ClearIT)(uint16_t);
uint8_t (*GetITStatus)(uint16_t);
void (*DisableIT)(uint16_t);
}TS_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __TS_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,100 @@
/**
******************************************************************************
* @file tsensor.h
* @author MCD Application Team
* @brief This header file contains the functions prototypes for the
* Temperature Sensor driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __TSENSOR_H
#define __TSENSOR_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup TSENSOR
* @{
*/
/** @defgroup TSENSOR_Exported_Types
* @{
*/
/** @defgroup TSENSOR_Config_structure Temperature Sensor Configuration structure
* @{
*/
typedef struct
{
uint8_t AlertMode; /* Alert Mode Temperature out of range*/
uint8_t ConversionMode; /* Continuous/One Shot Mode */
uint8_t ConversionResolution; /* Temperature Resolution */
uint8_t ConversionRate; /* Number of measure per second */
int8_t TemperatureLimitHigh; /* High Temperature Limit Range */
int8_t TemperatureLimitLow; /* Low Temperature Limit Range */
}TSENSOR_InitTypeDef;
/**
* @}
*/
/** @defgroup TSENSOR_Driver_structure Temperature Sensor Driver structure
* @{
*/
typedef struct
{
void (*Init)(uint16_t, TSENSOR_InitTypeDef *);
uint8_t (*IsReady)(uint16_t, uint32_t);
uint8_t (*ReadStatus)(uint16_t);
float (*ReadTemp)(uint16_t);
}TSENSOR_DrvTypeDef;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __TSENSOR_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,114 @@
/**
******************************************************************************
* @file usbtypecswitch.h
* @author MCD Application Team
* @brief This header file contains the functions prototypes for the
* crossbar switch device for USB Type-C systems.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USBTYPECSWITCH_H
#define __USBTYPECSWITCH_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup TYPECSWITCH
* @{
*/
/** @defgroup TYPECSWITCH_Exported_Types
* @{
*/
typedef enum {
USB_NORMAL = 0,
USB_FLIPPED,
DFP_D_PIN_ASSIGNMENT_A_NORMAL,
DFP_D_PIN_ASSIGNMENT_A_FLIPPED,
DFP_D_PIN_ASSIGNMENT_B_NORMAL,
DFP_D_PIN_ASSIGNMENT_B_FLIPPED,
DFP_D_PIN_ASSIGNMENT_C_NORMAL,
DFP_D_PIN_ASSIGNMENT_C_FLIPPED,
DFP_D_PIN_ASSIGNMENT_D_NORMAL,
DFP_D_PIN_ASSIGNMENT_D_FLIPPED,
DFP_D_PIN_ASSIGNMENT_E_NORMAL,
DFP_D_PIN_ASSIGNMENT_E_FLIPPED,
DFP_D_PIN_ASSIGNMENT_F_NORMAL,
DFP_D_PIN_ASSIGNMENT_F_FLIPPED,
UFP_D_PIN_ASSIGNMENT_A_NORMAL,
UFP_D_PIN_ASSIGNMENT_A_FLIPPED,
UFP_D_PIN_ASSIGNMENT_B_NORMAL,
UFP_D_PIN_ASSIGNMENT_B_FLIPPED,
UFP_D_PIN_ASSIGNMENT_C_NORMAL,
UFP_D_PIN_ASSIGNMENT_C_FLIPPED,
UFP_D_PIN_ASSIGNMENT_D_NORMAL,
UFP_D_PIN_ASSIGNMENT_D_FLIPPED,
UFP_D_PIN_ASSIGNMENT_E_NORMAL,
UFP_D_PIN_ASSIGNMENT_E_FLIPPED,
UFP_D_PIN_ASSIGNMENT_F_NORMAL,
UFP_D_PIN_ASSIGNMENT_F_FLIPPED
} TYPECSWITCH_Mode_t;
/** @defgroup TYPECSWITCH_Driver_structure USB Type-C Crossbar Switch Driver structure
* @{
*/
typedef struct
{
uint32_t (*Init)(uint16_t);
void (*DeInit)(uint16_t);
uint32_t (*PowerOn)(uint16_t);
uint32_t (*PowerOff)(uint16_t);
uint32_t (*SetMode)(uint16_t, TYPECSWITCH_Mode_t);
uint32_t (*IsSupportedMode)(TYPECSWITCH_Mode_t);
} TYPECSWITCH_Drv_t;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __USBTYPECSWITCH_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for CS42L51 Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-cs42l51-component-drivers"><small>Release Notes for</small> <mark>CS42L51 Component Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the CS42L51 component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section20" aria-hidden="true"> <label for="collapse-section20" aria-hidden="true">V1.0.0 / 17-February-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release of CS42L51 Audio codec Component driver</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,504 @@
/**
******************************************************************************
* @file cs42l51.c
* @author MCD Application Team
* @brief This file provides the CS42L51 Audio Codec driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "cs42l51.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup CS42L51
* @brief This file provides a set of functions needed to drive the
* CS42L51 audio codec.
* @{
*/
/** @defgroup CS42L51_Exported_Variables
* @{
*/
/* Audio codec driver structure initialization */
AUDIO_DrvTypeDef cs42l51_drv =
{
cs42l51_Init,
cs42l51_DeInit,
cs42l51_ReadID,
cs42l51_Play,
cs42l51_Pause,
cs42l51_Resume,
cs42l51_Stop,
cs42l51_SetFrequency,
cs42l51_SetVolume,
cs42l51_SetMute,
cs42l51_SetOutputMode,
cs42l51_Reset,
};
/**
* @}
*/
/** @defgroup CS42L51_Private_Types
* @{
*/
/**
* @}
*/
/** @defgroup CS42L51_Private_Defines
* @{
*/
/* Uncomment this line to enable verifying data sent to codec after each write
operation (for debug purpose) */
#if !defined (VERIFY_WRITTENDATA)
#define VERIFY_WRITTENDATA
#endif /* VERIFY_WRITTENDATA */
/**
* @}
*/
/** @defgroup CS42L51_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup CS42L51_Private_Variables
* @{
*/
static uint8_t Is_CS42L51_Initialized = 0;
static uint8_t Is_CS42L51_Stop = 1;
static uint16_t CS42L51_Device = OUTPUT_DEVICE_HEADPHONE;
/**
* @}
*/
/** @defgroup CS42L51_Private_Functions
* @{
*/
static uint8_t CODEC_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
/**
* @}
*/
/** @addtogroup CS42L51_Exported_Functions
* @{
*/
/**
* @brief Initialize the audio codec and the control interface.
* @param DeviceAddr: Device address on communication bus.
* @param Device: Can be combination values of OUTPUT_DEVICE_HEADPHONE and
* INPUT_DEVICE_MIC1.
* @param Volume: Initial output volume level (from 0 (-100dB) to 100 (0dB)).
* @param AudioFreq: Initial audio frequency (currently not used).
* @retval 0 if correct communication, else wrong communication.
*/
uint32_t cs42l51_Init(uint16_t DeviceAddr, uint16_t Device, uint8_t Volume, uint32_t AudioFreq)
{
uint32_t counter = 0;
uint8_t Value;
/* Check if codec is already initialized */
if(Is_CS42L51_Initialized == 0)
{
/* Initialize the Control interface of the Audio Codec */
AUDIO_IO_Init();
Is_CS42L51_Initialized = 1;
}
else
{
/* Set all power down bits to 1 exept PDN to mute ADCs and DACs*/
counter += CODEC_IO_Write(DeviceAddr, 0x02, 0x7E);
Value = AUDIO_IO_Read(DeviceAddr, 0x03);
counter += CODEC_IO_Write(DeviceAddr, 0x03, (Value | 0x0E));
/* Disable zero cross and soft ramp */
Value = AUDIO_IO_Read(DeviceAddr, 0x09);
counter += CODEC_IO_Write(DeviceAddr, 0x09, (Value & 0xFC));
/* Power control : Enter standby (PDN = 1) */
Value = AUDIO_IO_Read(DeviceAddr, 0x02);
counter += CODEC_IO_Write(DeviceAddr, 0x02, (Value | 0x01));
}
/* Mic Power and Speed Control : Auto detect on, Speed mode SSM, tri state off, MCLK divide by 2 off */
Value = AUDIO_IO_Read(DeviceAddr, 0x03);
counter += CODEC_IO_Write(DeviceAddr, 0x03, ((Value & 0x0E) | 0xA0));
/* Interface control : Loopback off, Slave, I2S (SDIN and SOUT), Digital mix off, Mic mix off */
counter += CODEC_IO_Write(DeviceAddr, 0x04, 0x0C);
/* Mic control : ADC single volume off, ADCB boost off, ADCA boost off, MicBias on AIN3B/MICIN2 pin, MicBias level 0.8xVA, MICB boost 16db, MICA boost 16dB */
counter += CODEC_IO_Write(DeviceAddr, 0x05, 0x00);
/* ADC control : ADCB HPF off, ADCB HPF freeze off, ADCA HPF off, ADCA HPF freeze off, Soft ramp B off, Zero cross B off, Soft ramp A off, Zero cross A off */
counter += CODEC_IO_Write(DeviceAddr, 0x06, 0x00);
/* ADC Input Select, Invert and Mute : AIN1B to PGAB, AIN3A to PreAmp to PGAA, ADCB invert off, ADCA invert off, ADCB mute on, ADCA mute off */
counter += CODEC_IO_Write(DeviceAddr, 0x07, 0x32);
/* DAC output control : HP Gain to 1, Single volume control off, PCM invert signals polarity off, DAC channels mute on */
counter += CODEC_IO_Write(DeviceAddr, 0x08, 0xC3);
/* DAC control : Signal processing to DAC, Freeze off, De-emphasis off, Analog output auto mute off, DAC soft ramp */
counter += CODEC_IO_Write(DeviceAddr, 0x09, 0x42);
/* ALCA and PGAA Control : ALCA soft ramp disable on, ALCA zero cross disable on, PGA A Gain 0dB */
counter += CODEC_IO_Write(DeviceAddr, 0x0A, 0xC0);
/* ALCB and PGAB Control : ALCB soft ramp disable on, ALCB zero cross disable on, PGA B Gain 0dB */
counter += CODEC_IO_Write(DeviceAddr, 0x0B, 0xC0);
/* ADCA Attenuator : 0dB */
counter += CODEC_IO_Write(DeviceAddr, 0x0C, 0x00);
/* ADCB Attenuator : 0dB */
counter += CODEC_IO_Write(DeviceAddr, 0x0D, 0x00);
/* ADCA mixer volume control : ADCA mixer channel mute on, ADCA mixer volume 0dB */
counter += CODEC_IO_Write(DeviceAddr, 0x0E, 0x80);
/* ADCB mixer volume control : ADCB mixer channel mute on, ADCB mixer volume 0dB */
counter += CODEC_IO_Write(DeviceAddr, 0x0F, 0x80);
/* PCMA mixer volume control : PCMA mixer channel mute off, PCMA mixer volume 0dB */
counter += CODEC_IO_Write(DeviceAddr, 0x10, 0x00);
/* PCMB mixer volume control : PCMB mixer channel mute off, PCMB mixer volume 0dB */
counter += CODEC_IO_Write(DeviceAddr, 0x11, 0x00);
/* PCM channel mixer : AOUTA Left, AOUTB Right */
counter += CODEC_IO_Write(DeviceAddr, 0x18, 0x00);
if(Device & OUTPUT_DEVICE_HEADPHONE)
{
Value = VOLUME_CONVERT(Volume);
/* AOUTA volume control : AOUTA volume */
counter += CODEC_IO_Write(DeviceAddr, 0x16, Value);
/* AOUTB volume control : AOUTB volume */
counter += CODEC_IO_Write(DeviceAddr, 0x17, Value);
}
/* Store device */
CS42L51_Device = Device;
/* Return communication control value */
return counter;
}
/**
* @brief Deinitialize the audio codec.
* @param None
* @retval None
*/
void cs42l51_DeInit(void)
{
/* Deinitialize Audio Codec interface */
AUDIO_IO_DeInit();
Is_CS42L51_Initialized = 0;
}
/**
* @brief Get the CS42L51 ID.
* @param DeviceAddr: Device address on communication Bus.
* @retval The CS42L51 ID
*/
uint32_t cs42l51_ReadID(uint16_t DeviceAddr)
{
uint8_t Value;
if(Is_CS42L51_Initialized == 0)
{
/* Initialize the Control interface of the Audio Codec */
AUDIO_IO_Init();
Value = AUDIO_IO_Read(DeviceAddr, CS42L51_CHIPID_ADDR);
Value = (Value & CS42L51_ID_MASK);
/* Deinitialize Audio Codec interface */
AUDIO_IO_DeInit();
}
else
{
Value = AUDIO_IO_Read(DeviceAddr, CS42L51_CHIPID_ADDR);
Value = (Value & CS42L51_ID_MASK);
}
return((uint32_t) Value);
}
/**
* @brief Start the audio Codec play feature.
* @note For this codec no Play options are required.
* @param DeviceAddr: Device address on communication Bus.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs42l51_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size)
{
uint32_t counter = 0;
uint8_t Value;
if(Is_CS42L51_Stop == 1)
{
/* Unmute output device */
counter += cs42l51_SetMute(DeviceAddr, AUDIO_MUTE_OFF);
if(CS42L51_Device & OUTPUT_DEVICE_HEADPHONE)
{
/* DAC control : Signal processing to DAC, Freeze off, De-emphasis off, Analog output auto mute off, DAC soft ramp */
counter += CODEC_IO_Write(DeviceAddr, 0x09, 0x42);
/* Power control 1 : PDN_DACA, PDN_DACB disable. */
Value = AUDIO_IO_Read(DeviceAddr, 0x02);
counter += CODEC_IO_Write(DeviceAddr, 0x02, (Value & 0x9F));
}
if(CS42L51_Device & INPUT_DEVICE_MIC1)
{
/* Power control 1 : PDN_PGAA, PDN_ADCA disable. */
Value = AUDIO_IO_Read(DeviceAddr, 0x02);
counter += CODEC_IO_Write(DeviceAddr, 0x02, (Value & 0xF5));
/* Mic Power and Speed Control : PDN_MICA, PDN_MIC_BIAS disable. */
Value = AUDIO_IO_Read(DeviceAddr, 0x03);
counter += CODEC_IO_Write(DeviceAddr, 0x03, (Value & 0xF9));
}
/* Power control : Exit standby (PDN = 0) */
Value = AUDIO_IO_Read(DeviceAddr, 0x02);
counter += CODEC_IO_Write(DeviceAddr, 0x02, (Value & 0xFE));
Is_CS42L51_Stop = 0;
}
/* Return communication control value */
return counter;
}
/**
* @brief Pause playing on the audio codec.
* @param DeviceAddr: Device address on communication Bus.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs42l51_Pause(uint16_t DeviceAddr)
{
uint32_t counter = 0;
/* Pause the audio file playing */
/* Mute the output first */
counter += cs42l51_SetMute(DeviceAddr, AUDIO_MUTE_ON);
return counter;
}
/**
* @brief Resume playing on the audio codec.
* @param DeviceAddr: Device address on communication Bus.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs42l51_Resume(uint16_t DeviceAddr)
{
uint32_t counter = 0;
/* Unmute the output */
counter += cs42l51_SetMute(DeviceAddr, AUDIO_MUTE_OFF);
return counter;
}
/**
* @brief Stop audio Codec playing. It powers down the codec.
* @param DeviceAddr: Device address on communication Bus.
* @param CodecPdwnMode: selects the power down mode (currently not used).
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs42l51_Stop(uint16_t DeviceAddr, uint32_t CodecPdwnMode)
{
uint32_t counter = 0;
uint8_t Value;
/* Set all power down bits to 1 exept PDN to mute ADCs and DACs*/
counter += CODEC_IO_Write(DeviceAddr, 0x02, 0x7E);
Value = AUDIO_IO_Read(DeviceAddr, 0x03);
counter += CODEC_IO_Write(DeviceAddr, 0x03, (Value | 0x0E));
/* Disable zero cross and soft ramp */
Value = AUDIO_IO_Read(DeviceAddr, 0x09);
counter += CODEC_IO_Write(DeviceAddr, 0x09, (Value & 0xFC));
/* Power control : Enter standby (PDN = 1) */
Value = AUDIO_IO_Read(DeviceAddr, 0x02);
counter += CODEC_IO_Write(DeviceAddr, 0x02, (Value | 0x01));
Is_CS42L51_Stop = 1;
return counter;
}
/**
* @brief Set higher or lower the codec volume level.
* @param DeviceAddr: Device address on communication Bus.
* @param Volume: output volume level (from 0 (-100dB) to 100 (0dB)).
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs42l51_SetVolume(uint16_t DeviceAddr, uint8_t Volume)
{
uint32_t counter = 0;
uint8_t convertedvol = VOLUME_CONVERT(Volume);
/* AOUTA volume control : AOUTA volume */
counter += CODEC_IO_Write(DeviceAddr, 0x16, convertedvol);
/* AOUTB volume control : AOUTB volume */
counter += CODEC_IO_Write(DeviceAddr, 0x17, convertedvol);
return counter;
}
/**
* @brief Set new frequency.
* @param DeviceAddr: Device address on communication Bus.
* @param AudioFreq: Audio frequency used to play the audio stream.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs42l51_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq)
{
return 0;
}
/**
* @brief Enable or disable the mute feature on the audio codec.
* @param DeviceAddr: Device address on communication Bus.
* @param Cmd: AUDIO_MUTE_ON to enable the mute or AUDIO_MUTE_OFF to disable the
* mute mode.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs42l51_SetMute(uint16_t DeviceAddr, uint32_t Cmd)
{
uint32_t counter = 0;
uint8_t Value;
/* Read DAC output control register */
Value = AUDIO_IO_Read(DeviceAddr, 0x08);
/* Set the Mute mode */
if(Cmd == AUDIO_MUTE_ON)
{
/* Mute DAC channels */
counter += CODEC_IO_Write(DeviceAddr, 0x08, (Value | 0x03));
}
else /* AUDIO_MUTE_OFF Disable the Mute */
{
/* Unmute DAC channels */
counter += CODEC_IO_Write(DeviceAddr, 0x08, (Value & 0xFC));
}
return counter;
}
/**
* @brief Switch dynamically (while audio file is played) the output target
* (speaker, headphone, etc).
* @note This function is currently not used (only headphone output device).
* @param DeviceAddr: Device address on communication Bus.
* @param Output: specifies the audio output device target.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs42l51_SetOutputMode(uint16_t DeviceAddr, uint8_t Output)
{
return 0;
}
/**
* @brief Reset CS42L51 registers.
* @param DeviceAddr: Device address on communication Bus.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs42l51_Reset(uint16_t DeviceAddr)
{
if(Is_CS42L51_Initialized == 1)
{
/* Deinitialize Audio Codec interface */
AUDIO_IO_DeInit();
/* Initialize the Control interface of the Audio Codec */
AUDIO_IO_Init();
}
return 0;
}
/**
* @}
*/
/** @addtogroup CS42L51_Private_Functions
* @{
*/
/**
* @brief Write and optionally read back a single data.
* @param Addr: I2C address
* @param Reg: Reg address
* @param Value: Data to be written
* @retval None
*/
static uint8_t CODEC_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value)
{
uint32_t result = 0;
AUDIO_IO_Write(Addr, Reg, Value);
#ifdef VERIFY_WRITTENDATA
/* Verify that the data has been correctly written */
result = (AUDIO_IO_Read(Addr, Reg) == Value)? 0:1;
#endif /* VERIFY_WRITTENDATA */
return result;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,171 @@
/**
******************************************************************************
* @file cs42l51.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the cs42l51.c driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CS42L51_H
#define __CS42L51_H
/* Includes ------------------------------------------------------------------*/
#include "../Common/audio.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @addtogroup CS42L51
* @{
*/
/** @defgroup CS42L51_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup CS42L51_Exported_Constants
* @{
*/
/******************************************************************************/
/*************************** Codec User defines ******************************/
/******************************************************************************/
/* Codec output devices */
#define OUTPUT_DEVICE_HEADPHONE 0x01
/* Codec input devices */
#define INPUT_DEVICE_MIC1 0x10
/* Volume Levels values */
#define DEFAULT_VOLMIN 0x00
#define DEFAULT_VOLMAX 0xFF
#define DEFAULT_VOLSTEP 0x04
#define AUDIO_PAUSE 0
#define AUDIO_RESUME 1
/* Codec POWER DOWN modes */
#define CODEC_PDWN_HW 1
#define CODEC_PDWN_SW 2
/* MUTE commands */
#define AUDIO_MUTE_ON 1
#define AUDIO_MUTE_OFF 0
/* AUDIO FREQUENCY */
#define AUDIO_FREQUENCY_192K ((uint32_t)192000)
#define AUDIO_FREQUENCY_96K ((uint32_t)96000)
#define AUDIO_FREQUENCY_48K ((uint32_t)48000)
#define AUDIO_FREQUENCY_44K ((uint32_t)44100)
#define AUDIO_FREQUENCY_32K ((uint32_t)32000)
#define AUDIO_FREQUENCY_22K ((uint32_t)22050)
#define AUDIO_FREQUENCY_16K ((uint32_t)16000)
#define AUDIO_FREQUENCY_11K ((uint32_t)11025)
#define AUDIO_FREQUENCY_8K ((uint32_t)8000)
/******************************************************************************/
/****************************** REGISTER MAPPING ******************************/
/******************************************************************************/
/**
* @brief CS42L51 ID
*/
#define CS42L51_ID 0xD8
#define CS42L51_ID_MASK 0xF8
/**
* @brief Chip ID Register: Chip I.D. and Revision Register
* Read only register
* Default value: 0x01
* [7:3] CHIPID[4:0]: I.D. code for the CS42L51.
* Default value: 11100b
* [2:0] REVID[2:0]: CS42L51 revision level.
* Default value:
* 000 - Rev A0
* 001 - Rev A1
* 010 - Rev B0
* 011 - Rev B1
*/
#define CS42L51_CHIPID_ADDR 0x01
/**
* @}
*/
/** @defgroup CS42L51_Exported_Macros
* @{
*/
#define VOLUME_CONVERT(Volume) ((Volume >= 100) ? 0 : ((uint8_t)(((Volume * 2) + 56))))
/**
* @}
*/
/** @defgroup CS42L51_Exported_Functions
* @{
*/
/*------------------------------------------------------------------------------
Audio Codec functions
------------------------------------------------------------------------------*/
/* High Layer codec functions */
uint32_t cs42l51_Init(uint16_t DeviceAddr, uint16_t Device, uint8_t Volume, uint32_t AudioFreq);
void cs42l51_DeInit(void);
uint32_t cs42l51_ReadID(uint16_t DeviceAddr);
uint32_t cs42l51_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size);
uint32_t cs42l51_Pause(uint16_t DeviceAddr);
uint32_t cs42l51_Resume(uint16_t DeviceAddr);
uint32_t cs42l51_Stop(uint16_t DeviceAddr, uint32_t Cmd);
uint32_t cs42l51_SetVolume(uint16_t DeviceAddr, uint8_t Volume);
uint32_t cs42l51_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq);
uint32_t cs42l51_SetMute(uint16_t DeviceAddr, uint32_t Cmd);
uint32_t cs42l51_SetOutputMode(uint16_t DeviceAddr, uint8_t Output);
uint32_t cs42l51_Reset(uint16_t DeviceAddr);
/* AUDIO IO functions */
void AUDIO_IO_Init(void);
void AUDIO_IO_DeInit(void);
void AUDIO_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg);
void AUDIO_IO_Delay(uint32_t Delay);
/* Audio driver structure */
extern AUDIO_DrvTypeDef cs42l51_drv;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#endif /* __CS42L51_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,136 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for CS43L22 Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-cs43l22-component-drivers"><small>Release Notes for</small> <mark>CS43L22 Component Drivers</mark></h1>
<p>Copyright © 2014 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the CS43L22 component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V2.0.4 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section20" aria-hidden="true"> <label for="collapse-section20" aria-hidden="true">V2.0.3 / 31-August-2018</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V2.0.2 / 02-October-2015</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>cs43l22.c/.h:
<ul>
<li>Move VOLUME_CONVERT macro from cs43l22.h to cs43l22.c as internally used to convert volume.</li>
<li>Add literals instead of magic number for cs34l22 registers</li>
</ul></li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V2.0.1 / 16-September-2015</label>
<div>
<h2 id="main-changes-3">Main Changes</h2>
<ul>
<li>cs43l22.c:
<ul>
<li>Enable the digital soft ramp to avoid clac noise</li>
<li>Improve mute/unmute by muting/unmuting also the DAC inputs</li>
</ul></li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V2.0.0 / 24-June-2015</label>
<div>
<h2 id="main-changes-4">Main Changes</h2>
<ul>
<li>cs43l22.c/.h:
<ul>
<li>Add codec de-initialization function: cs43l22_DeInit()</li>
<li>Add Audio IO de-initialization function prototype: AUDIO_IO_DeInit()</li>
</ul></li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">NOTE</span></span></strong><br />
This release must be used with BSP Common driver V4.0.0 or later</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section17" aria-hidden="true"> <label for="collapse-section17" aria-hidden="true">V1.1.0 / 10-February-2015</label>
<div>
<h2 id="main-changes-5">Main Changes</h2>
<ul>
<li>cs43l22.c/.h:
<ul>
<li>Add AUDIO_FREQUENCY_xxx defines for frequencies capabilities (8K to 192K)</li>
<li>Add codec reset function: cs43l22_Reset()</li>
</ul></li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section16" aria-hidden="true"> <label for="collapse-section16" aria-hidden="true">V1.0.1 / 02-December-2014</label>
<div>
<h2 id="main-changes-6">Main Changes</h2>
<ul>
<li>cs43l22.c: change “\” by “/” in the include path to fix compilation issue under Linux</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section15" aria-hidden="true"> <label for="collapse-section15" aria-hidden="true">V1.0.0 / 18-February-2014</label>
<div>
<h2 id="main-changes-7">Main Changes</h2>
<ul>
<li>First official release of CS43L22 audio codec</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,477 @@
/**
******************************************************************************
* @file cs43l22.c
* @author MCD Application Team
* @brief This file provides the CS43L22 Audio Codec driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "cs43l22.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup CS43L22
* @brief This file provides a set of functions needed to drive the
* CS43L22 audio codec.
* @{
*/
/** @defgroup CS43L22_Private_Types
* @{
*/
/**
* @}
*/
/** @defgroup CS43L22_Private_Defines
* @{
*/
#define VOLUME_CONVERT(Volume) (((Volume) > 100)? 255:((uint8_t)(((Volume) * 255) / 100)))
/* Uncomment this line to enable verifying data sent to codec after each write
operation (for debug purpose) */
#if !defined (VERIFY_WRITTENDATA)
/* #define VERIFY_WRITTENDATA */
#endif /* VERIFY_WRITTENDATA */
/**
* @}
*/
/** @defgroup CS43L22_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup CS43L22_Private_Variables
* @{
*/
/* Audio codec driver structure initialization */
AUDIO_DrvTypeDef cs43l22_drv =
{
cs43l22_Init,
cs43l22_DeInit,
cs43l22_ReadID,
cs43l22_Play,
cs43l22_Pause,
cs43l22_Resume,
cs43l22_Stop,
cs43l22_SetFrequency,
cs43l22_SetVolume,
cs43l22_SetMute,
cs43l22_SetOutputMode,
cs43l22_Reset,
};
static uint8_t Is_cs43l22_Stop = 1;
volatile uint8_t OutputDev = 0;
/**
* @}
*/
/** @defgroup CS43L22_Function_Prototypes
* @{
*/
static uint8_t CODEC_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
/**
* @}
*/
/** @defgroup CS43L22_Private_Functions
* @{
*/
/**
* @brief Initializes the audio codec and the control interface.
* @param DeviceAddr: Device address on communication Bus.
* @param OutputDevice: can be OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE,
* OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO .
* @param Volume: Initial volume level (from 0 (Mute) to 100 (Max))
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs43l22_Init(uint16_t DeviceAddr, uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq)
{
uint32_t counter = 0;
/* Initialize the Control interface of the Audio Codec */
AUDIO_IO_Init();
/* Keep Codec powered OFF */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL1, 0x01);
/*Save Output device for mute ON/OFF procedure*/
switch (OutputDevice)
{
case OUTPUT_DEVICE_SPEAKER:
OutputDev = 0xFA;
break;
case OUTPUT_DEVICE_HEADPHONE:
OutputDev = 0xAF;
break;
case OUTPUT_DEVICE_BOTH:
OutputDev = 0xAA;
break;
case OUTPUT_DEVICE_AUTO:
OutputDev = 0x05;
break;
default:
OutputDev = 0x05;
break;
}
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, OutputDev);
/* Clock configuration: Auto detection */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_CLOCKING_CTL, 0x81);
/* Set the Slave Mode and the audio Standard */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_INTERFACE_CTL1, CODEC_STANDARD);
/* Set the Master volume */
counter += cs43l22_SetVolume(DeviceAddr, Volume);
/* If the Speaker is enabled, set the Mono mode and volume attenuation level */
if(OutputDevice != OUTPUT_DEVICE_HEADPHONE)
{
/* Set the Speaker Mono mode */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_PLAYBACK_CTL2, 0x06);
/* Set the Speaker attenuation level */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_SPEAKER_A_VOL, 0x00);
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_SPEAKER_B_VOL, 0x00);
}
/* Additional configuration for the CODEC. These configurations are done to reduce
the time needed for the Codec to power off. If these configurations are removed,
then a long delay should be added between powering off the Codec and switching
off the I2S peripheral MCLK clock (which is the operating clock for Codec).
If this delay is not inserted, then the codec will not shut down properly and
it results in high noise after shut down. */
/* Disable the analog soft ramp */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_ANALOG_ZC_SR_SETT, 0x00);
/* Disable the digital soft ramp */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MISC_CTL, 0x04);
/* Disable the limiter attack level */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_LIMIT_CTL1, 0x00);
/* Adjust Bass and Treble levels */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_TONE_CTL, 0x0F);
/* Adjust PCM volume level */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_PCMA_VOL, 0x0A);
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_PCMB_VOL, 0x0A);
/* Return communication control value */
return counter;
}
/**
* @brief Deinitializes the audio codec.
* @param None
* @retval None
*/
void cs43l22_DeInit(void)
{
/* Deinitialize Audio Codec interface */
AUDIO_IO_DeInit();
}
/**
* @brief Get the CS43L22 ID.
* @param DeviceAddr: Device address on communication Bus.
* @retval The CS43L22 ID
*/
uint32_t cs43l22_ReadID(uint16_t DeviceAddr)
{
uint8_t Value;
/* Initialize the Control interface of the Audio Codec */
AUDIO_IO_Init();
Value = AUDIO_IO_Read(DeviceAddr, CS43L22_CHIPID_ADDR);
Value = (Value & CS43L22_ID_MASK);
return((uint32_t) Value);
}
/**
* @brief Start the audio Codec play feature.
* @note For this codec no Play options are required.
* @param DeviceAddr: Device address on communication Bus.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs43l22_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size)
{
uint32_t counter = 0;
if(Is_cs43l22_Stop == 1)
{
/* Enable the digital soft ramp */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MISC_CTL, 0x06);
/* Enable Output device */
counter += cs43l22_SetMute(DeviceAddr, AUDIO_MUTE_OFF);
/* Power on the Codec */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL1, 0x9E);
Is_cs43l22_Stop = 0;
}
/* Return communication control value */
return counter;
}
/**
* @brief Pauses playing on the audio codec.
* @param DeviceAddr: Device address on communication Bus.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs43l22_Pause(uint16_t DeviceAddr)
{
uint32_t counter = 0;
/* Pause the audio file playing */
/* Mute the output first */
counter += cs43l22_SetMute(DeviceAddr, AUDIO_MUTE_ON);
/* Put the Codec in Power save mode */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL1, 0x01);
return counter;
}
/**
* @brief Resumes playing on the audio codec.
* @param DeviceAddr: Device address on communication Bus.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs43l22_Resume(uint16_t DeviceAddr)
{
uint32_t counter = 0;
volatile uint32_t index = 0x00;
/* Resumes the audio file playing */
/* Unmute the output first */
counter += cs43l22_SetMute(DeviceAddr, AUDIO_MUTE_OFF);
for(index = 0x00; index < 0xFF; index++);
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, OutputDev);
/* Exit the Power save mode */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL1, 0x9E);
return counter;
}
/**
* @brief Stops audio Codec playing. It powers down the codec.
* @param DeviceAddr: Device address on communication Bus.
* @param CodecPdwnMode: selects the power down mode.
* - CODEC_PDWN_HW: Physically power down the codec. When resuming from this
* mode, the codec is set to default configuration
* (user should re-Initialize the codec in order to
* play again the audio stream).
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs43l22_Stop(uint16_t DeviceAddr, uint32_t CodecPdwnMode)
{
uint32_t counter = 0;
/* Mute the output first */
counter += cs43l22_SetMute(DeviceAddr, AUDIO_MUTE_ON);
/* Disable the digital soft ramp */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MISC_CTL, 0x04);
/* Power down the DAC and the speaker (PMDAC and PMSPK bits)*/
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL1, 0x9F);
Is_cs43l22_Stop = 1;
return counter;
}
/**
* @brief Sets higher or lower the codec volume level.
* @param DeviceAddr: Device address on communication Bus.
* @param Volume: a byte value from 0 to 255 (refer to codec registers
* description for more details).
*
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs43l22_SetVolume(uint16_t DeviceAddr, uint8_t Volume)
{
uint32_t counter = 0;
uint8_t convertedvol = VOLUME_CONVERT(Volume);
if(convertedvol > 0xE6)
{
/* Set the Master volume */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MASTER_A_VOL, convertedvol - 0xE7);
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MASTER_B_VOL, convertedvol - 0xE7);
}
else
{
/* Set the Master volume */
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MASTER_A_VOL, convertedvol + 0x19);
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MASTER_B_VOL, convertedvol + 0x19);
}
return counter;
}
/**
* @brief Sets new frequency.
* @param DeviceAddr: Device address on communication Bus.
* @param AudioFreq: Audio frequency used to play the audio stream.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs43l22_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq)
{
return 0;
}
/**
* @brief Enables or disables the mute feature on the audio codec.
* @param DeviceAddr: Device address on communication Bus.
* @param Cmd: AUDIO_MUTE_ON to enable the mute or AUDIO_MUTE_OFF to disable the
* mute mode.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs43l22_SetMute(uint16_t DeviceAddr, uint32_t Cmd)
{
uint32_t counter = 0;
/* Set the Mute mode */
if(Cmd == AUDIO_MUTE_ON)
{
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0xFF);
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_HEADPHONE_A_VOL, 0x01);
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_HEADPHONE_B_VOL, 0x01);
}
else /* AUDIO_MUTE_OFF Disable the Mute */
{
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_HEADPHONE_A_VOL, 0x00);
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_HEADPHONE_B_VOL, 0x00);
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, OutputDev);
}
return counter;
}
/**
* @brief Switch dynamically (while audio file is played) the output target
* (speaker or headphone).
* @note This function modifies a global variable of the audio codec driver: OutputDev.
* @param DeviceAddr: Device address on communication Bus.
* @param Output: specifies the audio output target: OUTPUT_DEVICE_SPEAKER,
* OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs43l22_SetOutputMode(uint16_t DeviceAddr, uint8_t Output)
{
uint32_t counter = 0;
switch (Output)
{
case OUTPUT_DEVICE_SPEAKER:
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0xFA); /* SPK always ON & HP always OFF */
OutputDev = 0xFA;
break;
case OUTPUT_DEVICE_HEADPHONE:
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0xAF); /* SPK always OFF & HP always ON */
OutputDev = 0xAF;
break;
case OUTPUT_DEVICE_BOTH:
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0xAA); /* SPK always ON & HP always ON */
OutputDev = 0xAA;
break;
case OUTPUT_DEVICE_AUTO:
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0x05); /* Detect the HP or the SPK automatically */
OutputDev = 0x05;
break;
default:
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0x05); /* Detect the HP or the SPK automatically */
OutputDev = 0x05;
break;
}
return counter;
}
/**
* @brief Resets cs43l22 registers.
* @param DeviceAddr: Device address on communication Bus.
* @retval 0 if correct communication, else wrong communication
*/
uint32_t cs43l22_Reset(uint16_t DeviceAddr)
{
return 0;
}
/**
* @brief Writes/Read a single data.
* @param Addr: I2C address
* @param Reg: Reg address
* @param Value: Data to be written
* @retval None
*/
static uint8_t CODEC_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value)
{
uint32_t result = 0;
AUDIO_IO_Write(Addr, Reg, Value);
#ifdef VERIFY_WRITTENDATA
/* Verify that the data has been correctly written */
result = (AUDIO_IO_Read(Addr, Reg) == Value)? 0:1;
#endif /* VERIFY_WRITTENDATA */
return result;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,210 @@
/**
******************************************************************************
* @file cs43l22.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the cs43l22.c driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CS43L22_H
#define __CS43L22_H
/* Includes ------------------------------------------------------------------*/
#include "../Common/audio.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @addtogroup CS43L22
* @{
*/
/** @defgroup CS43L22_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup CS43L22_Exported_Constants
* @{
*/
/******************************************************************************/
/*************************** Codec User defines ******************************/
/******************************************************************************/
/* Codec output DEVICE */
#define OUTPUT_DEVICE_SPEAKER 1
#define OUTPUT_DEVICE_HEADPHONE 2
#define OUTPUT_DEVICE_BOTH 3
#define OUTPUT_DEVICE_AUTO 4
/* Volume Levels values */
#define DEFAULT_VOLMIN 0x00
#define DEFAULT_VOLMAX 0xFF
#define DEFAULT_VOLSTEP 0x04
#define AUDIO_PAUSE 0
#define AUDIO_RESUME 1
/* Codec POWER DOWN modes */
#define CODEC_PDWN_HW 1
#define CODEC_PDWN_SW 2
/* MUTE commands */
#define AUDIO_MUTE_ON 1
#define AUDIO_MUTE_OFF 0
/* AUDIO FREQUENCY */
#define AUDIO_FREQUENCY_192K ((uint32_t)192000)
#define AUDIO_FREQUENCY_96K ((uint32_t)96000)
#define AUDIO_FREQUENCY_48K ((uint32_t)48000)
#define AUDIO_FREQUENCY_44K ((uint32_t)44100)
#define AUDIO_FREQUENCY_32K ((uint32_t)32000)
#define AUDIO_FREQUENCY_22K ((uint32_t)22050)
#define AUDIO_FREQUENCY_16K ((uint32_t)16000)
#define AUDIO_FREQUENCY_11K ((uint32_t)11025)
#define AUDIO_FREQUENCY_8K ((uint32_t)8000)
/** CS43l22 Registers ***/
#define CS43L22_REG_ID 0x01
#define CS43L22_REG_POWER_CTL1 0x02
#define CS43L22_REG_POWER_CTL2 0x04
#define CS43L22_REG_CLOCKING_CTL 0x05
#define CS43L22_REG_INTERFACE_CTL1 0x06
#define CS43L22_REG_INTERFACE_CTL2 0x07
#define CS43L22_REG_PASSTHR_A_SELECT 0x08
#define CS43L22_REG_PASSTHR_B_SELECT 0x09
#define CS43L22_REG_ANALOG_ZC_SR_SETT 0x0A
#define CS43L22_REG_PASSTHR_GANG_CTL 0x0C
#define CS43L22_REG_PLAYBACK_CTL1 0x0D
#define CS43L22_REG_MISC_CTL 0x0E
#define CS43L22_REG_PLAYBACK_CTL2 0x0F
#define CS43L22_REG_PASSTHR_A_VOL 0x14
#define CS43L22_REG_PASSTHR_B_VOL 0x15
#define CS43L22_REG_PCMA_VOL 0x1A
#define CS43L22_REG_PCMB_VOL 0x1B
#define CS43L22_REG_BEEP_FREQ_ON_TIME 0x1C
#define CS43L22_REG_BEEP_VOL_OFF_TIME 0x1D
#define CS43L22_REG_BEEP_TONE_CFG 0x1E
#define CS43L22_REG_TONE_CTL 0x1F
#define CS43L22_REG_MASTER_A_VOL 0x20
#define CS43L22_REG_MASTER_B_VOL 0x21
#define CS43L22_REG_HEADPHONE_A_VOL 0x22
#define CS43L22_REG_HEADPHONE_B_VOL 0x23
#define CS43L22_REG_SPEAKER_A_VOL 0x24
#define CS43L22_REG_SPEAKER_B_VOL 0x25
#define CS43L22_REG_CH_MIXER_SWAP 0x26
#define CS43L22_REG_LIMIT_CTL1 0x27
#define CS43L22_REG_LIMIT_CTL2 0x28
#define CS43L22_REG_LIMIT_ATTACK_RATE 0x29
#define CS43L22_REG_OVF_CLK_STATUS 0x2E
#define CS43L22_REG_BATT_COMPENSATION 0x2F
#define CS43L22_REG_VP_BATTERY_LEVEL 0x30
#define CS43L22_REG_SPEAKER_STATUS 0x31
#define CS43L22_REG_TEMPMONITOR_CTL 0x32
#define CS43L22_REG_THERMAL_FOLDBACK 0x33
#define CS43L22_REG_CHARGE_PUMP_FREQ 0x34
/******************************************************************************/
/****************************** REGISTER MAPPING ******************************/
/******************************************************************************/
/**
* @brief CS43L22 ID
*/
#define CS43L22_ID 0xE0
#define CS43L22_ID_MASK 0xF8
/**
* @brief Chip ID Register: Chip I.D. and Revision Register
* Read only register
* Default value: 0x01
* [7:3] CHIPID[4:0]: I.D. code for the CS43L22.
* Default value: 11100b
* [2:0] REVID[2:0]: CS43L22 revision level.
* Default value:
* 000 - Rev A0
* 001 - Rev A1
* 010 - Rev B0
* 011 - Rev B1
*/
#define CS43L22_CHIPID_ADDR 0x01
/**
* @}
*/
/** @defgroup CS43L22_Exported_Macros
* @{
*/
/**
* @}
*/
/** @defgroup CS43L22_Exported_Functions
* @{
*/
/*------------------------------------------------------------------------------
Audio Codec functions
------------------------------------------------------------------------------*/
/* High Layer codec functions */
uint32_t cs43l22_Init(uint16_t DeviceAddr, uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq);
void cs43l22_DeInit(void);
uint32_t cs43l22_ReadID(uint16_t DeviceAddr);
uint32_t cs43l22_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size);
uint32_t cs43l22_Pause(uint16_t DeviceAddr);
uint32_t cs43l22_Resume(uint16_t DeviceAddr);
uint32_t cs43l22_Stop(uint16_t DeviceAddr, uint32_t Cmd);
uint32_t cs43l22_SetVolume(uint16_t DeviceAddr, uint8_t Volume);
uint32_t cs43l22_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq);
uint32_t cs43l22_SetMute(uint16_t DeviceAddr, uint32_t Cmd);
uint32_t cs43l22_SetOutputMode(uint16_t DeviceAddr, uint8_t Output);
uint32_t cs43l22_Reset(uint16_t DeviceAddr);
/* AUDIO IO functions */
void AUDIO_IO_Init(void);
void AUDIO_IO_DeInit(void);
void AUDIO_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg);
/* Audio driver structure */
extern AUDIO_DrvTypeDef cs43l22_drv;
#endif /* __CS43L22_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for CY8C4014LQI Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-cy8c4014lqi-component-drivers"><small>Release Notes for</small> <mark>CY8C4014LQI Component Drivers</mark></h1>
<p>Copyright © 2019 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the CY8C4014LQI component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section1" checked aria-hidden="true"> <label for="collapse-section1" aria-hidden="true">V1.0.0 / 05-July-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>First official release of CY8C4014LQI Touch Screen Component driver</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,359 @@
/**
******************************************************************************
* @file cy8c4014lqi.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the CY8C4014LQI
* touch screen devices.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "cy8c4014lqi.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @addtogroup CY8C4014LQI
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/** @defgroup CY8C4014LQI_Private_Types_Definitions
* @{
*/
/* cy8c4014lqi Handle definition. */
typedef struct
{
uint8_t i2cInitialized;
/* field holding the current number of simultaneous active touches */
uint8_t currActiveTouchNb;
/* field holding the touch index currently managed */
uint8_t currActiveTouchIdx;
} cy8c4014lqi_handle_TypeDef;
/**
* @}
*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
volatile uint8_t is_touch = 0;
/** @defgroup CY8C4014LQI_Private_Variables
* @{
*/
/* Touch screen driver structure initialization */
TS_DrvTypeDef cy8c4014lqi_ts_drv =
{
cy8c4014lqi_Init,
cy8c4014lqi_ReadID,
cy8c4014lqi_Reset,
cy8c4014lqi_TS_Start,
cy8c4014lqi_TS_DetectTouch,
cy8c4014lqi_TS_GetXY,
cy8c4014lqi_TS_EnableIT,
cy8c4014lqi_TS_ClearIT,
cy8c4014lqi_TS_ITStatus,
cy8c4014lqi_TS_DisableIT
};
/* Global cy8c4014lqi handle */
static cy8c4014lqi_handle_TypeDef cy8c4014lqi_handle = { CY8C4014LQI_I2C_NOT_INITIALIZED, 0U, 0U};
/**
* @}
*/
/* Private functions prototypes-----------------------------------------------*/
/** @defgroup CY8C4014LQI_Private_Functions
* @{
*/
static uint8_t cy8c4014lqi_Get_I2C_InitializedStatus(void);
static void cy8c4014lqi_I2C_InitializeIfRequired(void);
/**
* @}
*/
/* Exported functions --------------------------------------------------------*/
/** @addtogroup CY8C4014LQI_Exported_Functions
* @{
*/
/**
* @brief Initialize the cy8c4014lqi communication bus
* from MCU to CY8C4014LQI : ie I2C channel initialization (if required).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of CY8C4014LQI).
* @retval None
*/
void cy8c4014lqi_Init(uint16_t DeviceAddr)
{
/* Initialize I2C link if needed */
cy8c4014lqi_I2C_InitializeIfRequired();
}
/**
* @brief Software Reset the cy8c4014lqi.
* @note : Not applicable to CY8C4014LQI.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of CY8C4014LQI).
* @retval None
*/
void cy8c4014lqi_Reset(uint16_t DeviceAddr)
{
/* Do nothing */
/* No software reset sequence available in CY8C4014LQI IC */
}
/**
* @brief Read the cy8c4014lqi device ID, pre initialize I2C in case of need to be
* able to read the CY8C4014LQI device ID, and verify this is a CY8C4014LQI.
* @param DeviceAddr: I2C CY8C4014LQI Slave address.
* @retval The Device ID (two bytes).
*/
uint16_t cy8c4014lqi_ReadID(uint16_t DeviceAddr)
{
/* Initialize I2C link if needed */
cy8c4014lqi_I2C_InitializeIfRequired();
/* Return the device ID value */
return(TS_IO_Read(DeviceAddr, CY8C4014LQI_ADEVICE_ID));
}
/**
* @brief Configures the touch Screen IC device to start detecting touches
* @param DeviceAddr: Device address on communication Bus (I2C slave address).
* @retval None.
*/
void cy8c4014lqi_TS_Start(uint16_t DeviceAddr)
{
/* Do nothing */
/* No software available in CY8C4014LQI IC */
}
/**
* @brief Return if there is touches detected or not.
* Try to detect new touches and forget the old ones (reset internal global
* variables).
* @param DeviceAddr: Device address on communication Bus.
* @retval : Number of active touches detected (can be 0, 1 or 2).
*/
uint8_t cy8c4014lqi_TS_DetectTouch(uint16_t DeviceAddr)
{
return is_touch;
}
/**
* @brief Get the touch screen X and Y positions values
* Manage multi touch thanks to touch Index global
* variable 'cy8c4014lqi_handle.currActiveTouchIdx'.
* @param DeviceAddr: Device address on communication Bus.
* @param X: Pointer to X position value
* @param Y: Pointer to Y position value
* @retval None.
*/
void cy8c4014lqi_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y)
{
*X = TS_IO_Read(CY8C4014LQI_ADDR, CY8C4014LQI_POS_X);
*Y = TS_IO_Read(CY8C4014LQI_ADDR, CY8C4014LQI_POS_Y);
}
/**
* @brief Configure the CY8C4014LQI device to generate IT on given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of CY8C4014LQI).
* @retval None
*/
void cy8c4014lqi_TS_EnableIT(uint16_t DeviceAddr)
{
/* Do nothing */
/* Action done by BSP software */
}
/**
* @brief Configure the CY8C4014LQI device to stop generating IT on the given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of CY8C4014LQI).
* @retval None
*/
void cy8c4014lqi_TS_DisableIT(uint16_t DeviceAddr)
{
/* Do nothing */
/* Action done by BSP software */
}
/**
* @brief Get IT status from CY8C4014LQI interrupt status registers
* Should be called Following an EXTI coming to the MCU to know the detailed
* reason of the interrupt.
* @note : This feature is not applicable to CY8C4014LQI.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of CY8C4014LQI).
* @retval TS interrupts status : always return 0 here
*/
uint8_t cy8c4014lqi_TS_ITStatus(uint16_t DeviceAddr)
{
/* Always return 0 as feature not applicable to CY8C4014LQI */
return 0U;
}
/**
* @brief Clear IT status in CY8C4014LQI interrupt status clear registers
* Should be called Following an EXTI coming to the MCU.
* @note : This feature is not applicable to CY8C4014LQI.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of CY8C4014LQI).
* @retval None
*/
void cy8c4014lqi_TS_ClearIT(uint16_t DeviceAddr)
{
/* Do nothing */
/* Action done by BSP software */
}
/**
* @brief Configure gesture feature (enable/disable).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of CY8C4014LQI).
* @param Activation : Enable or disable gesture feature. Possible values are
* CY8C4014LQI_GESTURE_DISABLE or CY8C4014LQI_GESTURE_ENABLE.
* @retval None.
*/
void cy8c4014lqi_TS_GestureConfig(uint16_t DeviceAddr, uint32_t Activation)
{
/* Do nothing */
/* No software available in CY8C4014LQI IC */
}
/**
* @brief Get the last touch gesture identification (zoom, move up/down...).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of CY8C4014LQI).
* @param pGestureId : Pointer to get last touch gesture Identification.
* @retval None.
*/
void cy8c4014lqi_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId)
{
/* Do nothing */
/* No software available in CY8C4014LQI IC */
}
/**
* @brief Get the touch detailed informations on touch number 'touchIdx' (0..1)
* This touch detailed information contains :
* - weight that was applied to this touch
* - sub-area of the touch in the touch panel
* - event of linked to the touch (press down, lift up, ...)
* @param DeviceAddr: Device address on communication Bus (I2C slave address of CY8C4014LQI).
* @param touchIdx : Passed index of the touch (0..1) on which we want to get the
* detailed information.
* @param pWeight : Pointer to to get the weight information of 'touchIdx'.
* @param pArea : Pointer to to get the sub-area information of 'touchIdx'.
* @param pEvent : Pointer to to get the event information of 'touchIdx'.
* @note Area and Weight features are not supported by CY8C4014LQI. Return always 0 value.
* @retval None.
*/
void cy8c4014lqi_TS_GetTouchInfo(uint16_t DeviceAddr,
uint32_t touchIdx,
uint32_t * pWeight,
uint32_t * pArea,
uint32_t * pEvent)
{
/* Do nothing */
/* No software available in CY8C4014LQI IC */
}
/**
* @}
*/
/* Private functions bodies---------------------------------------------------*/
/** @addtogroup CY8C4014LQI_Private_Functions
* @{
*/
/**
* @brief Return the status of I2C was initialized or not.
* @param None.
* @retval : I2C initialization status.
*/
static uint8_t cy8c4014lqi_Get_I2C_InitializedStatus(void)
{
return(cy8c4014lqi_handle.i2cInitialized);
}
/**
* @brief I2C initialize if needed.
* @param None.
* @retval : None.
*/
static void cy8c4014lqi_I2C_InitializeIfRequired(void)
{
if(cy8c4014lqi_Get_I2C_InitializedStatus() == CY8C4014LQI_I2C_NOT_INITIALIZED)
{
/* Initialize TS IO BUS layer (I2C) */
TS_IO_Init();
/* Set state to initialized */
cy8c4014lqi_handle.i2cInitialized = CY8C4014LQI_I2C_INITIALIZED;
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,165 @@
/**
******************************************************************************
* @file cy8c4014lqi.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the
* cy8c4014lqi.c touch screen driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __CY8C4014LQI_H
#define __CY8C4014LQI_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/ts.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup CY8C4014LQI
* @{
*/
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup CY8C4014LQI_Exported_Constants
* @{
*/
#define CY8C4014LQI_ADDR (0x08<<1)
#define CY8C4014LQI_ADEVICE_ID (0x00)
#define CY8C4014LQI_VERSION (0x01)
#define CY8C4014LQI_SYSMODE (0x03)
#define CY8C4014LQI_TOUCH_EVENT (0x04)
#define CY8C4014LQI_POS_X (0x06)
#define CY8C4014LQI_POS_Y (0x07)
#define CY8C4014LQI_GESTURE (0x08)
#define CY8C4014LQI_DISTENCE_X (0x09)
#define CY8C4014LQI_DISTENCE_Y (0x0A)
#define DATA_VALUE_FLAG (0x0B)
/* Possible values of global variable 'TS_I2C_Initialized' */
#define CY8C4014LQI_I2C_NOT_INITIALIZED 0x00U
#define CY8C4014LQI_I2C_INITIALIZED 0x01U
/**
* @}
*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
/** @defgroup CY8C4014LQI_Exported_Functions
* @{
*/
void cy8c4014lqi_Init(uint16_t DeviceAddr);
void cy8c4014lqi_Reset(uint16_t DeviceAddr);
uint16_t cy8c4014lqi_ReadID(uint16_t DeviceAddr);
void cy8c4014lqi_TS_Start(uint16_t DeviceAddr);
uint8_t cy8c4014lqi_TS_DetectTouch(uint16_t DeviceAddr);
void cy8c4014lqi_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y);
void cy8c4014lqi_TS_EnableIT(uint16_t DeviceAddr);
void cy8c4014lqi_TS_DisableIT(uint16_t DeviceAddr);
uint8_t cy8c4014lqi_TS_ITStatus (uint16_t DeviceAddr);
void cy8c4014lqi_TS_ClearIT (uint16_t DeviceAddr);
void cy8c4014lqi_TS_GestureConfig(uint16_t DeviceAddr, uint32_t Activation);
void cy8c4014lqi_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId);
void cy8c4014lqi_TS_GetTouchInfo(uint16_t DeviceAddr,
uint32_t touchIdx,
uint32_t * pWeight,
uint32_t * pArea,
uint32_t * pEvent);
/**
* @}
*/
/* Imported TS IO functions --------------------------------------------------------*/
/** @defgroup CY8C4014LQI_Imported_Functions
* @{
*/
/* TouchScreen (TS) external IO functions */
extern void TS_IO_Init(void);
extern void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
extern uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg);
extern uint16_t TS_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
extern void TS_IO_Delay(uint32_t Delay);
/**
* @}
*/
/* Imported global variables --------------------------------------------------------*/
/** @defgroup CY8C4014LQI_Imported_Globals
* @{
*/
/* Touch screen driver structure */
extern TS_DrvTypeDef cy8c4014lqi_ts_drv;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __CY8C4014LQI_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for FT3X67 Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-ft3x67-component-drivers"><small>Release Notes for</small> <mark>FT3X67 Component Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the FT3X67 component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 07-August-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release of Touch Screen FT3x67 Component driver</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,443 @@
/**
******************************************************************************
* @file ft3x67.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the FT3X67
* touch screen devices.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "ft3x67.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @addtogroup FT3X67
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/** @defgroup FT3X67_Private_Types_Definitions
* @{
*/
/* ft3x67 Handle definition. */
typedef struct
{
uint8_t i2cInitialized;
/* field holding the current number of simultaneous active touches */
uint8_t currActiveTouchNb;
/* field holding the touch index currently managed */
uint8_t currActiveTouchIdx;
} ft3x67_handle_TypeDef;
/**
* @}
*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/** @defgroup FT3X67_Private_Variables
* @{
*/
/* Touch screen driver structure initialization */
TS_DrvTypeDef ft3x67_ts_drv =
{
ft3x67_Init,
ft3x67_ReadID,
ft3x67_Reset,
ft3x67_TS_Start,
ft3x67_TS_DetectTouch,
ft3x67_TS_GetXY,
ft3x67_TS_EnableIT,
ft3x67_TS_ClearIT,
ft3x67_TS_ITStatus,
ft3x67_TS_DisableIT
};
/* Global ft3x67 handle */
static ft3x67_handle_TypeDef ft3x67_handle = { FT3X67_I2C_NOT_INITIALIZED, 0U, 0U};
/**
* @}
*/
/* Private functions prototypes-----------------------------------------------*/
/** @defgroup FT3X67_Private_Functions
* @{
*/
static uint8_t ft3x67_Get_I2C_InitializedStatus(void);
static void ft3x67_I2C_InitializeIfRequired(void);
static uint32_t ft3x67_TS_Configure(uint16_t DeviceAddr);
/**
* @}
*/
/* Exported functions --------------------------------------------------------*/
/** @addtogroup FT3X67_Exported_Functions
* @{
*/
/**
* @brief Initialize the ft3x67 communication bus
* from MCU to FT3X67 : ie I2C channel initialization (if required).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT3X67).
* @retval None
*/
void ft3x67_Init(uint16_t DeviceAddr)
{
/* Initialize I2C link if needed */
ft3x67_I2C_InitializeIfRequired();
}
/**
* @brief Software Reset the ft3x67.
* @note : Not applicable to FT3X67.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT3X67).
* @retval None
*/
void ft3x67_Reset(uint16_t DeviceAddr)
{
/* Do nothing */
/* No software reset sequence available in FT3X67 IC */
}
/**
* @brief Read the ft3x67 device ID, pre initialize I2C in case of need to be
* able to read the FT3X67 device ID, and verify this is a FT3X67.
* @param DeviceAddr: I2C FT3X67 Slave address.
* @retval The Device ID (two bytes).
*/
uint16_t ft3x67_ReadID(uint16_t DeviceAddr)
{
/* Initialize I2C link if needed */
ft3x67_I2C_InitializeIfRequired();
/* Return the device ID value */
return(TS_IO_Read(DeviceAddr, FT3X67_CHIP_ID_REG));
}
/**
* @brief Configures the touch Screen IC device to start detecting touches
* @param DeviceAddr: Device address on communication Bus (I2C slave address).
* @retval None.
*/
void ft3x67_TS_Start(uint16_t DeviceAddr)
{
/* Minimum static configuration of FT3X67 */
ft3x67_TS_Configure(DeviceAddr);
/* By default set FT3X67 IC in Polling mode : no INT generation on FT3X67 for new touch available */
/* Note TS_INT is active low */
ft3x67_TS_DisableIT(DeviceAddr);
}
/**
* @brief Return if there is touches detected or not.
* Try to detect new touches and forget the old ones (reset internal global
* variables).
* @param DeviceAddr: Device address on communication Bus.
* @retval : Number of active touches detected (can be 0, 1 or 2).
*/
uint8_t ft3x67_TS_DetectTouch(uint16_t DeviceAddr)
{
volatile uint8_t nbTouch = 0U;
/* Read register FT3X67_TD_STAT_REG to check number of touches detection */
nbTouch = TS_IO_Read(DeviceAddr, FT3X67_TD_STAT_REG);
nbTouch &= FT3X67_TD_STAT_MASK;
if(nbTouch > FT3X67_MAX_DETECTABLE_TOUCH)
{
/* If invalid number of touch detected, set it to zero */
nbTouch = 0U;
}
/* Update ft3x67 driver internal global : current number of active touches */
ft3x67_handle.currActiveTouchNb = nbTouch;
/* Reset current active touch index on which to work on */
ft3x67_handle.currActiveTouchIdx = 0U;
return(nbTouch);
}
/**
* @brief Get the touch screen X and Y positions values
* Manage multi touch thanks to touch Index global
* variable 'ft3x67_handle.currActiveTouchIdx'.
* @param DeviceAddr: Device address on communication Bus.
* @param X: Pointer to X position value
* @param Y: Pointer to Y position value
* @retval None.
*/
void ft3x67_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y)
{
uint8_t regAddress = 0U;
uint8_t dataxy[4U];
if(ft3x67_handle.currActiveTouchIdx < ft3x67_handle.currActiveTouchNb)
{
switch(ft3x67_handle.currActiveTouchIdx)
{
case 0U :
regAddress = FT3X67_P1_XH_REG;
break;
case 1U :
regAddress = FT3X67_P2_XH_REG;
break;
default :
break;
} /* end switch(ft3x67_handle.currActiveTouchIdx) */
/* Read X and Y positions */
TS_IO_ReadMultiple(DeviceAddr, regAddress, dataxy, sizeof(dataxy));
/* Send back ready X position to caller */
*X = ((dataxy[0U] & FT3X67_TOUCH_POS_MSB_MASK) << 8U) | dataxy[1U];
/* Send back ready Y position to caller */
*Y = ((dataxy[2U] & FT3X67_TOUCH_POS_MSB_MASK) << 8U) | dataxy[3U];
/* Increment current touch index */
ft3x67_handle.currActiveTouchIdx++;
}
}
/**
* @brief Configure the FT3X67 device to generate IT on given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT3X67).
* @retval None
*/
void ft3x67_TS_EnableIT(uint16_t DeviceAddr)
{
/* Set interrupt trigger mode in FT3X67_GMODE_REG */
TS_IO_Write(DeviceAddr, FT3X67_GMODE_REG, FT3X67_G_MODE_INTERRUPT_TRIGGER);
}
/**
* @brief Configure the FT3X67 device to stop generating IT on the given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT3X67).
* @retval None
*/
void ft3x67_TS_DisableIT(uint16_t DeviceAddr)
{
/* Set interrupt polling mode in FT3X67_GMODE_REG */
TS_IO_Write(DeviceAddr, FT3X67_GMODE_REG, FT3X67_G_MODE_INTERRUPT_POLLING);
}
/**
* @brief Get IT status from FT3X67 interrupt status registers
* Should be called Following an EXTI coming to the MCU to know the detailed
* reason of the interrupt.
* @note : This feature is not applicable to FT3X67.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT3X67).
* @retval TS interrupts status : always return 0 here
*/
uint8_t ft3x67_TS_ITStatus(uint16_t DeviceAddr)
{
/* Always return 0 as feature not applicable to FT3X67 */
return 0U;
}
/**
* @brief Clear IT status in FT3X67 interrupt status clear registers
* Should be called Following an EXTI coming to the MCU.
* @note : This feature is not applicable to FT3X67.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT3X67).
* @retval None
*/
void ft3x67_TS_ClearIT(uint16_t DeviceAddr)
{
/* Nothing to be done here for FT3X67 */
}
/**
* @brief Configure gesture feature (enable/disable).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT3X67).
* @param Activation : Enable or disable gesture feature. Possible values are
* FT3X67_GESTURE_DISABLE or FT3X67_GESTURE_ENABLE.
* @retval None.
*/
void ft3x67_TS_GestureConfig(uint16_t DeviceAddr, uint32_t Activation)
{
if(Activation == FT3X67_GESTURE_ENABLE)
{
/* Enable gesture feature. */
TS_IO_Write(DeviceAddr, FT3X67_GESTURE_FLAG_REG, FT3X67_GEST_ALL_FLAGS_ENABLE);
TS_IO_Write(DeviceAddr, FT3X67_GESTURE_ENABLE_REG, FT3X67_GESTURE_ENABLE);
}
else
{
/* Disable gesture feature. */
TS_IO_Write(DeviceAddr, FT3X67_GESTURE_FLAG_REG, FT3X67_GEST_ALL_FLAGS_DISABLE);
TS_IO_Write(DeviceAddr, FT3X67_GESTURE_ENABLE_REG, FT3X67_GESTURE_DISABLE);
}
}
/**
* @brief Get the last touch gesture identification (zoom, move up/down...).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT3X67).
* @param pGestureId : Pointer to get last touch gesture Identification.
* @retval None.
*/
void ft3x67_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId)
{
volatile uint8_t ucReadData = 0U;
ucReadData = TS_IO_Read(DeviceAddr, FT3X67_GEST_ID_REG);
*pGestureId = ucReadData;
}
/**
* @brief Get the touch detailed informations on touch number 'touchIdx' (0..1)
* This touch detailed information contains :
* - weight that was applied to this touch
* - sub-area of the touch in the touch panel
* - event of linked to the touch (press down, lift up, ...)
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT3X67).
* @param touchIdx : Passed index of the touch (0..1) on which we want to get the
* detailed information.
* @param pWeight : Pointer to to get the weight information of 'touchIdx'.
* @param pArea : Pointer to to get the sub-area information of 'touchIdx'.
* @param pEvent : Pointer to to get the event information of 'touchIdx'.
* @note Area and Weight features are not supported by FT3X67. Return always 0 value.
* @retval None.
*/
void ft3x67_TS_GetTouchInfo(uint16_t DeviceAddr,
uint32_t touchIdx,
uint32_t * pWeight,
uint32_t * pArea,
uint32_t * pEvent)
{
volatile uint8_t ucReadData = 0U;
uint8_t regAddressXHigh = 0U;
if(touchIdx < ft3x67_handle.currActiveTouchNb)
{
switch(touchIdx)
{
case 0U :
regAddressXHigh = FT3X67_P1_XH_REG;
break;
case 1U :
regAddressXHigh = FT3X67_P2_XH_REG;
break;
default :
break;
} /* end switch(touchIdx) */
/* Read Event Id of touch index */
ucReadData = TS_IO_Read(DeviceAddr, regAddressXHigh);
*pEvent = (ucReadData & FT3X67_TOUCH_EVT_FLAG_MASK) >> FT3X67_TOUCH_EVT_FLAG_SHIFT;
/* Weight and area of touch index not supported by FT3X67 */
*pWeight = 0;
*pArea = 0;
} /* of if(touchIdx < ft3x67_handle.currActiveTouchNb) */
}
/**
* @}
*/
/* Private functions bodies---------------------------------------------------*/
/** @addtogroup FT3X67_Private_Functions
* @{
*/
/**
* @brief Return the status of I2C was initialized or not.
* @param None.
* @retval : I2C initialization status.
*/
static uint8_t ft3x67_Get_I2C_InitializedStatus(void)
{
return(ft3x67_handle.i2cInitialized);
}
/**
* @brief I2C initialize if needed.
* @param None.
* @retval : None.
*/
static void ft3x67_I2C_InitializeIfRequired(void)
{
if(ft3x67_Get_I2C_InitializedStatus() == FT3X67_I2C_NOT_INITIALIZED)
{
/* Initialize TS IO BUS layer (I2C) */
TS_IO_Init();
/* Set state to initialized */
ft3x67_handle.i2cInitialized = FT3X67_I2C_INITIALIZED;
}
}
/**
* @brief Basic static configuration of TouchScreen
* @param DeviceAddr: FT3X67 Device address for communication on I2C Bus.
* @retval Status FT3X67_STATUS_OK or FT3X67_STATUS_NOT_OK.
*/
static uint32_t ft3x67_TS_Configure(uint16_t DeviceAddr)
{
uint32_t status = FT3X67_STATUS_OK;
/* Disable gesture feature */
TS_IO_Write(DeviceAddr, FT3X67_GESTURE_ENABLE_REG, FT3X67_GESTURE_DISABLE);
return(status);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,273 @@
/**
******************************************************************************
* @file ft3x67.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the
* ft3x67.c touch screen driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __FT3X67_H
#define __FT3X67_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/ts.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup FT3X67
* @{
*/
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup FT3X67_Exported_Constants
* @{
*/
/* Maximum border values of the touchscreen pad */
#define FT3X67_MAX_WIDTH 390U /* Touchscreen pad max width */
#define FT3X67_MAX_HEIGHT 390U /* Touchscreen pad max height */
/* Possible values of driver functions return status */
#define FT3X67_STATUS_OK 0x00U
#define FT3X67_STATUS_NOT_OK 0x01U
/* Possible values of global variable 'TS_I2C_Initialized' */
#define FT3X67_I2C_NOT_INITIALIZED 0x00U
#define FT3X67_I2C_INITIALIZED 0x01U
/* Max detectable simultaneous touches */
#define FT3X67_MAX_DETECTABLE_TOUCH 0x02U
/* Definitions for FT3X67 registers */
/* Current mode register of the FT3X67 (R/W) */
#define FT3X67_DEV_MODE_REG 0x00U
/* Possible values of FT3X67_DEV_MODE_REG */
#define FT3X67_DEV_MODE_WORKING 0x00U
#define FT3X67_DEV_MODE_FACTORY 0x40U
/* Touch Data Status register : gives number of active touch points (0..2) */
#define FT3X67_TD_STAT_REG 0x02U
/* Values related to FT3X67_TD_STAT_REG */
#define FT3X67_TD_STAT_MASK 0x0FU
/* Values Pn_XH and Pn_YH related */
#define FT3X67_TOUCH_EVT_FLAG_PRESS_DOWN 0x00U
#define FT3X67_TOUCH_EVT_FLAG_LIFT_UP 0x01U
#define FT3X67_TOUCH_EVT_FLAG_CONTACT 0x02U
#define FT3X67_TOUCH_EVT_FLAG_NO_EVENT 0x03U
#define FT3X67_TOUCH_EVT_FLAG_SHIFT 0x06U
#define FT3X67_TOUCH_EVT_FLAG_MASK (3U << FT3X67_TOUCH_EVT_FLAG_SHIFT)
#define FT3X67_TOUCH_POS_MSB_MASK 0x0FU
/* Point 1 registers */
#define FT3X67_P1_XH_REG 0x03U
#define FT3X67_P1_XL_REG 0x04U
#define FT3X67_P1_YH_REG 0x05U
#define FT3X67_P1_YL_REG 0x06U
#define FT3X67_P1_WEIGHT_REG 0x07U
#define FT3X67_P1_MISC_REG 0x08U
/* Point 2 registers */
#define FT3X67_P2_XH_REG 0x09U
#define FT3X67_P2_XL_REG 0x0AU
#define FT3X67_P2_YH_REG 0x0BU
#define FT3X67_P2_YL_REG 0x0CU
#define FT3X67_P2_WEIGHT_REG 0x0DU
#define FT3X67_P2_MISC_REG 0x0EU
/* Values related to Pn_MISC register */
#define FT3X67_TOUCH_AREA_MASK (0xFU << FT3X67_TOUCH_AREA_SHIFT)
#define FT3X67_TOUCH_AREA_SHIFT 0x04U
/* Threshold for touch detection register */
#define FT3X67_TH_GROUP_REG 0x80U
/* Filter function coefficients register */
#define FT3X67_TH_DIFF_REG 0x85U
/* Control register */
#define FT3X67_CTRL_REG 0x86U
/* Values related to FT3X67_CTRL_REG */
#define FT3X67_CTRL_KEEP_ACTIVE_MODE 0x00U
#define FT3X67_CTRL_KEEP_AUTO_SWITCH_MONITOR_MODE 0x01U
/* The time period of switching from Active mode to Monitor mode when there is no touching */
#define FT3X67_TIMEENTERMONITOR_REG 0x87U
/* Report rate in Active mode */
#define FT3X67_PERIODACTIVE_REG 0x88U
/* Report rate in Monitor mode */
#define FT3X67_PERIODMONITOR_REG 0x89U
/* High 8-bit of LIB Version info */
#define FT3X67_LIB_VER_H_REG 0xA1U
/* Low 8-bit of LIB Version info */
#define FT3X67_LIB_VER_L_REG 0xA2U
/* Chip Selecting */
#define FT3X67_CIPHER_REG 0xA3U
/* Interrupt mode register (used when in interrupt mode) */
#define FT3X67_GMODE_REG 0xA4U
/* Possible values of FT3X67_GMODE_REG */
#define FT3X67_G_MODE_INTERRUPT_POLLING 0x00U
#define FT3X67_G_MODE_INTERRUPT_TRIGGER 0x01U
/* Current power mode */
#define FT3X67_PWR_MODE_REG 0xA5U
/* Firmware version */
#define FT3X67_FIRMID_REG 0xA6U
/* Chip identification register */
#define FT3X67_CHIP_ID_REG 0xA8U
/* Possible values of FT3X67_CHIP_ID_REG */
#define FT3X67_ID_VALUE 0x11U
/* Release code version */
#define FT3X67_RELEASE_CODE_ID_REG 0xAFU
/* Current operating mode register */
#define FT3X67_STATE_REG 0xBCU
/* Possible values of FT3X67_STATE_REG */
#define FT3X67_STATE_INFO_MODE 0x00U
#define FT3X67_STATE_NORMAL_MODE 0x01U
#define FT3X67_STATE_FACTORY_MODE 0x03U
#define FT3X67_STATE_AUTO_CALIB_MODE 0x04U
/* Gesture enable register */
#define FT3X67_GESTURE_ENABLE_REG 0xD0U
/* Possible values of FT3X67_GESTURE_ENABLE_REG */
#define FT3X67_GESTURE_DISABLE 0x00U
#define FT3X67_GESTURE_ENABLE 0x01U
/* Gesture flag register */
#define FT3X67_GESTURE_FLAG_REG 0xD1U
/* Possible values of FT3X67_GESTURE_FLAG_REG can be any combination of following values */
#define FT3X67_GEST_LINE_RIGHT_TO_LEFT_ENABLE 0x01U
#define FT3X67_GEST_LINE_LEFT_TO_RIGHT_ENABLE 0x02U
#define FT3X67_GEST_LINE_DOWN_TO_UP_ENABLE 0x04U
#define FT3X67_GEST_LINE_UP_TO_DOWN_ENABLE 0x08U
#define FT3X67_GEST_DOUBLE_TAP_ENABLE 0x10U
#define FT3X67_GEST_ALL_FLAGS_ENABLE 0x1FU
#define FT3X67_GEST_ALL_FLAGS_DISABLE 0x00U
/* Gesture ID register */
#define FT3X67_GEST_ID_REG 0xD3U
/* Possible values of FT3X67_GEST_ID_REG */
#define FT3X67_GEST_ID_NO_GESTURE 0x00U
#define FT3X67_GEST_ID_MOVE_UP 0x22U
#define FT3X67_GEST_ID_MOVE_RIGHT 0x21U
#define FT3X67_GEST_ID_MOVE_DOWN 0x23U
#define FT3X67_GEST_ID_MOVE_LEFT 0x20U
#define FT3X67_GEST_ID_DOUBLE_CLICK 0x24U
/**
* @}
*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
/** @defgroup FT3X67_Exported_Functions
* @{
*/
void ft3x67_Init(uint16_t DeviceAddr);
void ft3x67_Reset(uint16_t DeviceAddr);
uint16_t ft3x67_ReadID(uint16_t DeviceAddr);
void ft3x67_TS_Start(uint16_t DeviceAddr);
uint8_t ft3x67_TS_DetectTouch(uint16_t DeviceAddr);
void ft3x67_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y);
void ft3x67_TS_EnableIT(uint16_t DeviceAddr);
void ft3x67_TS_DisableIT(uint16_t DeviceAddr);
uint8_t ft3x67_TS_ITStatus (uint16_t DeviceAddr);
void ft3x67_TS_ClearIT (uint16_t DeviceAddr);
void ft3x67_TS_GestureConfig(uint16_t DeviceAddr, uint32_t Activation);
void ft3x67_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId);
void ft3x67_TS_GetTouchInfo(uint16_t DeviceAddr,
uint32_t touchIdx,
uint32_t * pWeight,
uint32_t * pArea,
uint32_t * pEvent);
/**
* @}
*/
/* Imported TS IO functions --------------------------------------------------------*/
/** @defgroup FT3X67_Imported_Functions
* @{
*/
/* TouchScreen (TS) external IO functions */
extern void TS_IO_Init(void);
extern void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
extern uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg);
extern uint16_t TS_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
extern void TS_IO_Delay(uint32_t Delay);
/**
* @}
*/
/* Imported global variables --------------------------------------------------------*/
/** @defgroup FT3X67_Imported_Globals
* @{
*/
/* Touch screen driver structure */
extern TS_DrvTypeDef ft3x67_ts_drv;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __FT3X67_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,73 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for FT5336GQQ Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-ft5336gqq-component-drivers"><small>Release Notes for</small> <mark>FT5336GQQ Component Drivers</mark></h1>
<p>Copyright © 2015 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the FT5336GQQ component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.2 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section20" aria-hidden="true"> <label for="collapse-section20" aria-hidden="true">V1.0.1 / 31-August-2018</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 25-June-2015</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>First official release</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,607 @@
/**
******************************************************************************
* @file ft5336.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the FT5336
* touch screen devices.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "ft5336.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup FT5336
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/** @defgroup FT5336_Private_Types_Definitions
* @{
*/
/* Private define ------------------------------------------------------------*/
/** @defgroup FT5336_Private_Defines
* @{
*/
/* Private macro -------------------------------------------------------------*/
/** @defgroup FT5336_Private_Macros
* @{
*/
/* Private variables ---------------------------------------------------------*/
/** @defgroup FT5336_Private_Variables
* @{
*/
/* Touch screen driver structure initialization */
TS_DrvTypeDef ft5336_ts_drv =
{
ft5336_Init,
ft5336_ReadID,
ft5336_Reset,
ft5336_TS_Start,
ft5336_TS_DetectTouch,
ft5336_TS_GetXY,
ft5336_TS_EnableIT,
ft5336_TS_ClearIT,
ft5336_TS_ITStatus,
ft5336_TS_DisableIT
};
/* Global ft5336 handle */
static ft5336_handle_TypeDef ft5336_handle = { FT5336_I2C_NOT_INITIALIZED, 0, 0};
/**
* @}
*/
/** @defgroup ft5336_Private_Function_Prototypes
* @{
*/
/* Private functions prototypes-----------------------------------------------*/
/**
* @brief Return the status of I2C was initialized or not.
* @param None.
* @retval : I2C initialization status.
*/
static uint8_t ft5336_Get_I2C_InitializedStatus(void);
/**
* @brief I2C initialize if needed.
* @param None.
* @retval : None.
*/
static void ft5336_I2C_InitializeIfRequired(void);
/**
* @brief Basic static configuration of TouchScreen
* @param DeviceAddr: FT5336 Device address for communication on I2C Bus.
* @retval Status FT5336_STATUS_OK or FT5336_STATUS_NOT_OK.
*/
static uint32_t ft5336_TS_Configure(uint16_t DeviceAddr);
/** @defgroup ft5336_Private_Functions
* @{
*/
/** @defgroup ft5336_Public_Function_Body
* @{
*/
/* Public functions bodies-----------------------------------------------*/
/**
* @brief Initialize the ft5336 communication bus
* from MCU to FT5336 : ie I2C channel initialization (if required).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @retval None
*/
void ft5336_Init(uint16_t DeviceAddr)
{
/* Wait at least 200ms after power up before accessing registers
* Trsi timing (Time of starting to report point after resetting) from FT5336GQQ datasheet */
TS_IO_Delay(200);
/* Initialize I2C link if needed */
ft5336_I2C_InitializeIfRequired();
}
/**
* @brief Software Reset the ft5336.
* @note : Not applicable to FT5336.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @retval None
*/
void ft5336_Reset(uint16_t DeviceAddr)
{
/* Do nothing */
/* No software reset sequence available in FT5336 IC */
}
/**
* @brief Read the ft5336 device ID, pre initialize I2C in case of need to be
* able to read the FT5336 device ID, and verify this is a FT5336.
* @param DeviceAddr: I2C FT5336 Slave address.
* @retval The Device ID (two bytes).
*/
uint16_t ft5336_ReadID(uint16_t DeviceAddr)
{
volatile uint8_t ucReadId = 0;
uint8_t nbReadAttempts = 0;
uint8_t bFoundDevice = 0; /* Device not found by default */
/* Initialize I2C link if needed */
ft5336_I2C_InitializeIfRequired();
/* At maximum 4 attempts to read ID : exit at first finding of the searched device ID */
for(nbReadAttempts = 0; ((nbReadAttempts < 3) && !(bFoundDevice)); nbReadAttempts++)
{
/* Read register FT5336_CHIP_ID_REG as DeviceID detection */
ucReadId = TS_IO_Read(DeviceAddr, FT5336_CHIP_ID_REG);
/* Found the searched device ID ? */
if(ucReadId == FT5336_ID_VALUE)
{
/* Set device as found */
bFoundDevice = 1;
}
}
/* Return the device ID value */
return (ucReadId);
}
/**
* @brief Configures the touch Screen IC device to start detecting touches
* @param DeviceAddr: Device address on communication Bus (I2C slave address).
* @retval None.
*/
void ft5336_TS_Start(uint16_t DeviceAddr)
{
/* Minimum static configuration of FT5336 */
FT5336_ASSERT(ft5336_TS_Configure(DeviceAddr));
/* By default set FT5336 IC in Polling mode : no INT generation on FT5336 for new touch available */
/* Note TS_INT is active low */
ft5336_TS_DisableIT(DeviceAddr);
}
/**
* @brief Return if there is touches detected or not.
* Try to detect new touches and forget the old ones (reset internal global
* variables).
* @param DeviceAddr: Device address on communication Bus.
* @retval : Number of active touches detected (can be 0, 1 or 2).
*/
uint8_t ft5336_TS_DetectTouch(uint16_t DeviceAddr)
{
volatile uint8_t nbTouch = 0;
/* Read register FT5336_TD_STAT_REG to check number of touches detection */
nbTouch = TS_IO_Read(DeviceAddr, FT5336_TD_STAT_REG);
nbTouch &= FT5336_TD_STAT_MASK;
if(nbTouch > FT5336_MAX_DETECTABLE_TOUCH)
{
/* If invalid number of touch detected, set it to zero */
nbTouch = 0;
}
/* Update ft5336 driver internal global : current number of active touches */
ft5336_handle.currActiveTouchNb = nbTouch;
/* Reset current active touch index on which to work on */
ft5336_handle.currActiveTouchIdx = 0;
return(nbTouch);
}
/**
* @brief Get the touch screen X and Y positions values
* Manage multi touch thanks to touch Index global
* variable 'ft5336_handle.currActiveTouchIdx'.
* @param DeviceAddr: Device address on communication Bus.
* @param X: Pointer to X position value
* @param Y: Pointer to Y position value
* @retval None.
*/
void ft5336_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y)
{
volatile uint8_t ucReadData = 0;
static uint16_t coord;
uint8_t regAddressXLow = 0;
uint8_t regAddressXHigh = 0;
uint8_t regAddressYLow = 0;
uint8_t regAddressYHigh = 0;
if(ft5336_handle.currActiveTouchIdx < ft5336_handle.currActiveTouchNb)
{
switch(ft5336_handle.currActiveTouchIdx)
{
case 0 :
regAddressXLow = FT5336_P1_XL_REG;
regAddressXHigh = FT5336_P1_XH_REG;
regAddressYLow = FT5336_P1_YL_REG;
regAddressYHigh = FT5336_P1_YH_REG;
break;
case 1 :
regAddressXLow = FT5336_P2_XL_REG;
regAddressXHigh = FT5336_P2_XH_REG;
regAddressYLow = FT5336_P2_YL_REG;
regAddressYHigh = FT5336_P2_YH_REG;
break;
case 2 :
regAddressXLow = FT5336_P3_XL_REG;
regAddressXHigh = FT5336_P3_XH_REG;
regAddressYLow = FT5336_P3_YL_REG;
regAddressYHigh = FT5336_P3_YH_REG;
break;
case 3 :
regAddressXLow = FT5336_P4_XL_REG;
regAddressXHigh = FT5336_P4_XH_REG;
regAddressYLow = FT5336_P4_YL_REG;
regAddressYHigh = FT5336_P4_YH_REG;
break;
case 4 :
regAddressXLow = FT5336_P5_XL_REG;
regAddressXHigh = FT5336_P5_XH_REG;
regAddressYLow = FT5336_P5_YL_REG;
regAddressYHigh = FT5336_P5_YH_REG;
break;
case 5 :
regAddressXLow = FT5336_P6_XL_REG;
regAddressXHigh = FT5336_P6_XH_REG;
regAddressYLow = FT5336_P6_YL_REG;
regAddressYHigh = FT5336_P6_YH_REG;
break;
case 6 :
regAddressXLow = FT5336_P7_XL_REG;
regAddressXHigh = FT5336_P7_XH_REG;
regAddressYLow = FT5336_P7_YL_REG;
regAddressYHigh = FT5336_P7_YH_REG;
break;
case 7 :
regAddressXLow = FT5336_P8_XL_REG;
regAddressXHigh = FT5336_P8_XH_REG;
regAddressYLow = FT5336_P8_YL_REG;
regAddressYHigh = FT5336_P8_YH_REG;
break;
case 8 :
regAddressXLow = FT5336_P9_XL_REG;
regAddressXHigh = FT5336_P9_XH_REG;
regAddressYLow = FT5336_P9_YL_REG;
regAddressYHigh = FT5336_P9_YH_REG;
break;
case 9 :
regAddressXLow = FT5336_P10_XL_REG;
regAddressXHigh = FT5336_P10_XH_REG;
regAddressYLow = FT5336_P10_YL_REG;
regAddressYHigh = FT5336_P10_YH_REG;
break;
default :
break;
} /* end switch(ft5336_handle.currActiveTouchIdx) */
/* Read low part of X position */
ucReadData = TS_IO_Read(DeviceAddr, regAddressXLow);
coord = (ucReadData & FT5336_TOUCH_POS_LSB_MASK) >> FT5336_TOUCH_POS_LSB_SHIFT;
/* Read high part of X position */
ucReadData = TS_IO_Read(DeviceAddr, regAddressXHigh);
coord |= ((ucReadData & FT5336_TOUCH_POS_MSB_MASK) >> FT5336_TOUCH_POS_MSB_SHIFT) << 8;
/* Send back ready X position to caller */
*X = coord;
/* Read low part of Y position */
ucReadData = TS_IO_Read(DeviceAddr, regAddressYLow);
coord = (ucReadData & FT5336_TOUCH_POS_LSB_MASK) >> FT5336_TOUCH_POS_LSB_SHIFT;
/* Read high part of Y position */
ucReadData = TS_IO_Read(DeviceAddr, regAddressYHigh);
coord |= ((ucReadData & FT5336_TOUCH_POS_MSB_MASK) >> FT5336_TOUCH_POS_MSB_SHIFT) << 8;
/* Send back ready Y position to caller */
*Y = coord;
ft5336_handle.currActiveTouchIdx++; /* next call will work on next touch */
} /* of if(ft5336_handle.currActiveTouchIdx < ft5336_handle.currActiveTouchNb) */
}
/**
* @brief Configure the FT5336 device to generate IT on given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT5336).
* @retval None
*/
void ft5336_TS_EnableIT(uint16_t DeviceAddr)
{
uint8_t regValue = 0;
regValue = (FT5336_G_MODE_INTERRUPT_TRIGGER & (FT5336_G_MODE_INTERRUPT_MASK >> FT5336_G_MODE_INTERRUPT_SHIFT)) << FT5336_G_MODE_INTERRUPT_SHIFT;
/* Set interrupt trigger mode in FT5336_GMODE_REG */
TS_IO_Write(DeviceAddr, FT5336_GMODE_REG, regValue);
}
/**
* @brief Configure the FT5336 device to stop generating IT on the given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT5336).
* @retval None
*/
void ft5336_TS_DisableIT(uint16_t DeviceAddr)
{
uint8_t regValue = 0;
regValue = (FT5336_G_MODE_INTERRUPT_POLLING & (FT5336_G_MODE_INTERRUPT_MASK >> FT5336_G_MODE_INTERRUPT_SHIFT)) << FT5336_G_MODE_INTERRUPT_SHIFT;
/* Set interrupt polling mode in FT5336_GMODE_REG */
TS_IO_Write(DeviceAddr, FT5336_GMODE_REG, regValue);
}
/**
* @brief Get IT status from FT5336 interrupt status registers
* Should be called Following an EXTI coming to the MCU to know the detailed
* reason of the interrupt.
* @note : This feature is not applicable to FT5336.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @retval TS interrupts status : always return 0 here
*/
uint8_t ft5336_TS_ITStatus(uint16_t DeviceAddr)
{
/* Always return 0 as feature not applicable to FT5336 */
return 0;
}
/**
* @brief Clear IT status in FT5336 interrupt status clear registers
* Should be called Following an EXTI coming to the MCU.
* @note : This feature is not applicable to FT5336.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @retval None
*/
void ft5336_TS_ClearIT(uint16_t DeviceAddr)
{
/* Nothing to be done here for FT5336 */
}
/**** NEW FEATURES enabled when Multi-touch support is enabled ****/
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
/**
* @brief Get the last touch gesture identification (zoom, move up/down...).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @param pGestureId : Pointer to get last touch gesture Identification.
* @retval None.
*/
void ft5336_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId)
{
volatile uint8_t ucReadData = 0;
ucReadData = TS_IO_Read(DeviceAddr, FT5336_GEST_ID_REG);
* pGestureId = ucReadData;
}
/**
* @brief Get the touch detailed informations on touch number 'touchIdx' (0..1)
* This touch detailed information contains :
* - weight that was applied to this touch
* - sub-area of the touch in the touch panel
* - event of linked to the touch (press down, lift up, ...)
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @param touchIdx : Passed index of the touch (0..1) on which we want to get the
* detailed information.
* @param pWeight : Pointer to to get the weight information of 'touchIdx'.
* @param pArea : Pointer to to get the sub-area information of 'touchIdx'.
* @param pEvent : Pointer to to get the event information of 'touchIdx'.
* @retval None.
*/
void ft5336_TS_GetTouchInfo(uint16_t DeviceAddr,
uint32_t touchIdx,
uint32_t * pWeight,
uint32_t * pArea,
uint32_t * pEvent)
{
volatile uint8_t ucReadData = 0;
uint8_t regAddressXHigh = 0;
uint8_t regAddressPWeight = 0;
uint8_t regAddressPMisc = 0;
if(touchIdx < ft5336_handle.currActiveTouchNb)
{
switch(touchIdx)
{
case 0 :
regAddressXHigh = FT5336_P1_XH_REG;
regAddressPWeight = FT5336_P1_WEIGHT_REG;
regAddressPMisc = FT5336_P1_MISC_REG;
break;
case 1 :
regAddressXHigh = FT5336_P2_XH_REG;
regAddressPWeight = FT5336_P2_WEIGHT_REG;
regAddressPMisc = FT5336_P2_MISC_REG;
break;
case 2 :
regAddressXHigh = FT5336_P3_XH_REG;
regAddressPWeight = FT5336_P3_WEIGHT_REG;
regAddressPMisc = FT5336_P3_MISC_REG;
break;
case 3 :
regAddressXHigh = FT5336_P4_XH_REG;
regAddressPWeight = FT5336_P4_WEIGHT_REG;
regAddressPMisc = FT5336_P4_MISC_REG;
break;
case 4 :
regAddressXHigh = FT5336_P5_XH_REG;
regAddressPWeight = FT5336_P5_WEIGHT_REG;
regAddressPMisc = FT5336_P5_MISC_REG;
break;
case 5 :
regAddressXHigh = FT5336_P6_XH_REG;
regAddressPWeight = FT5336_P6_WEIGHT_REG;
regAddressPMisc = FT5336_P6_MISC_REG;
break;
case 6 :
regAddressXHigh = FT5336_P7_XH_REG;
regAddressPWeight = FT5336_P7_WEIGHT_REG;
regAddressPMisc = FT5336_P7_MISC_REG;
break;
case 7 :
regAddressXHigh = FT5336_P8_XH_REG;
regAddressPWeight = FT5336_P8_WEIGHT_REG;
regAddressPMisc = FT5336_P8_MISC_REG;
break;
case 8 :
regAddressXHigh = FT5336_P9_XH_REG;
regAddressPWeight = FT5336_P9_WEIGHT_REG;
regAddressPMisc = FT5336_P9_MISC_REG;
break;
case 9 :
regAddressXHigh = FT5336_P10_XH_REG;
regAddressPWeight = FT5336_P10_WEIGHT_REG;
regAddressPMisc = FT5336_P10_MISC_REG;
break;
default :
break;
} /* end switch(touchIdx) */
/* Read Event Id of touch index */
ucReadData = TS_IO_Read(DeviceAddr, regAddressXHigh);
* pEvent = (ucReadData & FT5336_TOUCH_EVT_FLAG_MASK) >> FT5336_TOUCH_EVT_FLAG_SHIFT;
/* Read weight of touch index */
ucReadData = TS_IO_Read(DeviceAddr, regAddressPWeight);
* pWeight = (ucReadData & FT5336_TOUCH_WEIGHT_MASK) >> FT5336_TOUCH_WEIGHT_SHIFT;
/* Read area of touch index */
ucReadData = TS_IO_Read(DeviceAddr, regAddressPMisc);
* pArea = (ucReadData & FT5336_TOUCH_AREA_MASK) >> FT5336_TOUCH_AREA_SHIFT;
} /* of if(touchIdx < ft5336_handle.currActiveTouchNb) */
}
#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
/** @defgroup ft5336_Static_Function_Body
* @{
*/
/* Static functions bodies-----------------------------------------------*/
/**
* @brief Return the status of I2C was initialized or not.
* @param None.
* @retval : I2C initialization status.
*/
static uint8_t ft5336_Get_I2C_InitializedStatus(void)
{
return(ft5336_handle.i2cInitialized);
}
/**
* @brief I2C initialize if needed.
* @param None.
* @retval : None.
*/
static void ft5336_I2C_InitializeIfRequired(void)
{
if(ft5336_Get_I2C_InitializedStatus() == FT5336_I2C_NOT_INITIALIZED)
{
/* Initialize TS IO BUS layer (I2C) */
TS_IO_Init();
/* Set state to initialized */
ft5336_handle.i2cInitialized = FT5336_I2C_INITIALIZED;
}
}
/**
* @brief Basic static configuration of TouchScreen
* @param DeviceAddr: FT5336 Device address for communication on I2C Bus.
* @retval Status FT5336_STATUS_OK or FT5336_STATUS_NOT_OK.
*/
static uint32_t ft5336_TS_Configure(uint16_t DeviceAddr)
{
uint32_t status = FT5336_STATUS_OK;
/* Nothing special to be done for FT5336 */
return(status);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,522 @@
/**
******************************************************************************
* @file ft5336.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the
* ft5336.c Touch screen driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __FT5336_H
#define __FT5336_H
#ifdef __cplusplus
extern "C" {
#endif
/* Set Multi-touch as supported */
#if !defined(TS_MONO_TOUCH_SUPPORTED)
#define TS_MULTI_TOUCH_SUPPORTED 1
#endif /* TS_MONO_TOUCH_SUPPORTED */
/* Includes ------------------------------------------------------------------*/
#include "../Common/ts.h"
/* Macros --------------------------------------------------------------------*/
#if defined(FT5336_ENABLE_ASSERT)
/* Assert activated */
#define FT5336_ASSERT(__condition__) do { if(__condition__) \
{ \
while(1); \
} \
}while(0)
#else
/* Assert not activated : macro has no effect */
#define FT5336_ASSERT(__condition__) do { if(__condition__) \
{ \
; \
} \
}while(0)
#endif /* FT5336_ENABLE_ASSERT == 1 */
/** @typedef ft5336_handle_TypeDef
* ft5336 Handle definition.
*/
typedef struct
{
uint8_t i2cInitialized;
/* field holding the current number of simultaneous active touches */
uint8_t currActiveTouchNb;
/* field holding the touch index currently managed */
uint8_t currActiveTouchIdx;
} ft5336_handle_TypeDef;
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup FT5336
* @{
*/
/* Exported types ------------------------------------------------------------*/
/** @defgroup FT5336_Exported_Types
* @{
*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup FT5336_Exported_Constants
* @{
*/
/* I2C Slave address of touchscreen FocalTech FT5336 */
#define FT5336_I2C_SLAVE_ADDRESS ((uint8_t)0x70)
/* Maximum border values of the touchscreen pad */
#define FT5336_MAX_WIDTH ((uint16_t)480) /* Touchscreen pad max width */
#define FT5336_MAX_HEIGHT ((uint16_t)272) /* Touchscreen pad max height */
/* Possible values of driver functions return status */
#define FT5336_STATUS_OK ((uint8_t)0x00)
#define FT5336_STATUS_NOT_OK ((uint8_t)0x01)
/* Possible values of global variable 'TS_I2C_Initialized' */
#define FT5336_I2C_NOT_INITIALIZED ((uint8_t)0x00)
#define FT5336_I2C_INITIALIZED ((uint8_t)0x01)
/* Max detectable simultaneous touches */
#define FT5336_MAX_DETECTABLE_TOUCH ((uint8_t)0x05)
/**
* @brief : Definitions for FT5336 I2C register addresses on 8 bit
**/
/* Current mode register of the FT5336 (R/W) */
#define FT5336_DEV_MODE_REG ((uint8_t)0x00)
/* Possible values of FT5336_DEV_MODE_REG */
#define FT5336_DEV_MODE_WORKING ((uint8_t)0x00)
#define FT5336_DEV_MODE_FACTORY ((uint8_t)0x04)
#define FT5336_DEV_MODE_MASK ((uint8_t)0x07)
#define FT5336_DEV_MODE_SHIFT ((uint8_t)0x04)
/* Gesture ID register */
#define FT5336_GEST_ID_REG ((uint8_t)0x01)
/* Possible values of FT5336_GEST_ID_REG */
#define FT5336_GEST_ID_NO_GESTURE ((uint8_t)0x00)
#define FT5336_GEST_ID_MOVE_UP ((uint8_t)0x10)
#define FT5336_GEST_ID_MOVE_RIGHT ((uint8_t)0x14)
#define FT5336_GEST_ID_MOVE_DOWN ((uint8_t)0x18)
#define FT5336_GEST_ID_MOVE_LEFT ((uint8_t)0x1C)
#define FT5336_GEST_ID_SINGLE_CLICK ((uint8_t)0x20)
#define FT5336_GEST_ID_DOUBLE_CLICK ((uint8_t)0x22)
#define FT5336_GEST_ID_ROTATE_CLOCKWISE ((uint8_t)0x28)
#define FT5336_GEST_ID_ROTATE_C_CLOCKWISE ((uint8_t)0x29)
#define FT5336_GEST_ID_ZOOM_IN ((uint8_t)0x40)
#define FT5336_GEST_ID_ZOOM_OUT ((uint8_t)0x49)
/* Touch Data Status register : gives number of active touch points (0..5) */
#define FT5336_TD_STAT_REG ((uint8_t)0x02)
/* Values related to FT5336_TD_STAT_REG */
#define FT5336_TD_STAT_MASK ((uint8_t)0x0F)
#define FT5336_TD_STAT_SHIFT ((uint8_t)0x00)
/* Values Pn_XH and Pn_YH related */
#define FT5336_TOUCH_EVT_FLAG_PRESS_DOWN ((uint8_t)0x00)
#define FT5336_TOUCH_EVT_FLAG_LIFT_UP ((uint8_t)0x01)
#define FT5336_TOUCH_EVT_FLAG_CONTACT ((uint8_t)0x02)
#define FT5336_TOUCH_EVT_FLAG_NO_EVENT ((uint8_t)0x03)
#define FT5336_TOUCH_EVT_FLAG_SHIFT ((uint8_t)0x06)
#define FT5336_TOUCH_EVT_FLAG_MASK ((uint8_t)(3 << FT5336_TOUCH_EVT_FLAG_SHIFT))
#define FT5336_TOUCH_POS_MSB_MASK ((uint8_t)0x0F)
#define FT5336_TOUCH_POS_MSB_SHIFT ((uint8_t)0x00)
/* Values Pn_XL and Pn_YL related */
#define FT5336_TOUCH_POS_LSB_MASK ((uint8_t)0xFF)
#define FT5336_TOUCH_POS_LSB_SHIFT ((uint8_t)0x00)
#define FT5336_P1_XH_REG ((uint8_t)0x03)
#define FT5336_P1_XL_REG ((uint8_t)0x04)
#define FT5336_P1_YH_REG ((uint8_t)0x05)
#define FT5336_P1_YL_REG ((uint8_t)0x06)
/* Touch Pressure register value (R) */
#define FT5336_P1_WEIGHT_REG ((uint8_t)0x07)
/* Values Pn_WEIGHT related */
#define FT5336_TOUCH_WEIGHT_MASK ((uint8_t)0xFF)
#define FT5336_TOUCH_WEIGHT_SHIFT ((uint8_t)0x00)
/* Touch area register */
#define FT5336_P1_MISC_REG ((uint8_t)0x08)
/* Values related to FT5336_Pn_MISC_REG */
#define FT5336_TOUCH_AREA_MASK ((uint8_t)(0x04 << 4))
#define FT5336_TOUCH_AREA_SHIFT ((uint8_t)0x04)
#define FT5336_P2_XH_REG ((uint8_t)0x09)
#define FT5336_P2_XL_REG ((uint8_t)0x0A)
#define FT5336_P2_YH_REG ((uint8_t)0x0B)
#define FT5336_P2_YL_REG ((uint8_t)0x0C)
#define FT5336_P2_WEIGHT_REG ((uint8_t)0x0D)
#define FT5336_P2_MISC_REG ((uint8_t)0x0E)
#define FT5336_P3_XH_REG ((uint8_t)0x0F)
#define FT5336_P3_XL_REG ((uint8_t)0x10)
#define FT5336_P3_YH_REG ((uint8_t)0x11)
#define FT5336_P3_YL_REG ((uint8_t)0x12)
#define FT5336_P3_WEIGHT_REG ((uint8_t)0x13)
#define FT5336_P3_MISC_REG ((uint8_t)0x14)
#define FT5336_P4_XH_REG ((uint8_t)0x15)
#define FT5336_P4_XL_REG ((uint8_t)0x16)
#define FT5336_P4_YH_REG ((uint8_t)0x17)
#define FT5336_P4_YL_REG ((uint8_t)0x18)
#define FT5336_P4_WEIGHT_REG ((uint8_t)0x19)
#define FT5336_P4_MISC_REG ((uint8_t)0x1A)
#define FT5336_P5_XH_REG ((uint8_t)0x1B)
#define FT5336_P5_XL_REG ((uint8_t)0x1C)
#define FT5336_P5_YH_REG ((uint8_t)0x1D)
#define FT5336_P5_YL_REG ((uint8_t)0x1E)
#define FT5336_P5_WEIGHT_REG ((uint8_t)0x1F)
#define FT5336_P5_MISC_REG ((uint8_t)0x20)
#define FT5336_P6_XH_REG ((uint8_t)0x21)
#define FT5336_P6_XL_REG ((uint8_t)0x22)
#define FT5336_P6_YH_REG ((uint8_t)0x23)
#define FT5336_P6_YL_REG ((uint8_t)0x24)
#define FT5336_P6_WEIGHT_REG ((uint8_t)0x25)
#define FT5336_P6_MISC_REG ((uint8_t)0x26)
#define FT5336_P7_XH_REG ((uint8_t)0x27)
#define FT5336_P7_XL_REG ((uint8_t)0x28)
#define FT5336_P7_YH_REG ((uint8_t)0x29)
#define FT5336_P7_YL_REG ((uint8_t)0x2A)
#define FT5336_P7_WEIGHT_REG ((uint8_t)0x2B)
#define FT5336_P7_MISC_REG ((uint8_t)0x2C)
#define FT5336_P8_XH_REG ((uint8_t)0x2D)
#define FT5336_P8_XL_REG ((uint8_t)0x2E)
#define FT5336_P8_YH_REG ((uint8_t)0x2F)
#define FT5336_P8_YL_REG ((uint8_t)0x30)
#define FT5336_P8_WEIGHT_REG ((uint8_t)0x31)
#define FT5336_P8_MISC_REG ((uint8_t)0x32)
#define FT5336_P9_XH_REG ((uint8_t)0x33)
#define FT5336_P9_XL_REG ((uint8_t)0x34)
#define FT5336_P9_YH_REG ((uint8_t)0x35)
#define FT5336_P9_YL_REG ((uint8_t)0x36)
#define FT5336_P9_WEIGHT_REG ((uint8_t)0x37)
#define FT5336_P9_MISC_REG ((uint8_t)0x38)
#define FT5336_P10_XH_REG ((uint8_t)0x39)
#define FT5336_P10_XL_REG ((uint8_t)0x3A)
#define FT5336_P10_YH_REG ((uint8_t)0x3B)
#define FT5336_P10_YL_REG ((uint8_t)0x3C)
#define FT5336_P10_WEIGHT_REG ((uint8_t)0x3D)
#define FT5336_P10_MISC_REG ((uint8_t)0x3E)
/* Threshold for touch detection */
#define FT5336_TH_GROUP_REG ((uint8_t)0x80)
/* Values FT5336_TH_GROUP_REG : threshold related */
#define FT5336_THRESHOLD_MASK ((uint8_t)0xFF)
#define FT5336_THRESHOLD_SHIFT ((uint8_t)0x00)
/* Filter function coefficients */
#define FT5336_TH_DIFF_REG ((uint8_t)0x85)
/* Control register */
#define FT5336_CTRL_REG ((uint8_t)0x86)
/* Values related to FT5336_CTRL_REG */
/* Will keep the Active mode when there is no touching */
#define FT5336_CTRL_KEEP_ACTIVE_MODE ((uint8_t)0x00)
/* Switching from Active mode to Monitor mode automatically when there is no touching */
#define FT5336_CTRL_KEEP_AUTO_SWITCH_MONITOR_MODE ((uint8_t)0x01
/* The time period of switching from Active mode to Monitor mode when there is no touching */
#define FT5336_TIMEENTERMONITOR_REG ((uint8_t)0x87)
/* Report rate in Active mode */
#define FT5336_PERIODACTIVE_REG ((uint8_t)0x88)
/* Report rate in Monitor mode */
#define FT5336_PERIODMONITOR_REG ((uint8_t)0x89)
/* The value of the minimum allowed angle while Rotating gesture mode */
#define FT5336_RADIAN_VALUE_REG ((uint8_t)0x91)
/* Maximum offset while Moving Left and Moving Right gesture */
#define FT5336_OFFSET_LEFT_RIGHT_REG ((uint8_t)0x92)
/* Maximum offset while Moving Up and Moving Down gesture */
#define FT5336_OFFSET_UP_DOWN_REG ((uint8_t)0x93)
/* Minimum distance while Moving Left and Moving Right gesture */
#define FT5336_DISTANCE_LEFT_RIGHT_REG ((uint8_t)0x94)
/* Minimum distance while Moving Up and Moving Down gesture */
#define FT5336_DISTANCE_UP_DOWN_REG ((uint8_t)0x95)
/* Maximum distance while Zoom In and Zoom Out gesture */
#define FT5336_DISTANCE_ZOOM_REG ((uint8_t)0x96)
/* High 8-bit of LIB Version info */
#define FT5336_LIB_VER_H_REG ((uint8_t)0xA1)
/* Low 8-bit of LIB Version info */
#define FT5336_LIB_VER_L_REG ((uint8_t)0xA2)
/* Chip Selecting */
#define FT5336_CIPHER_REG ((uint8_t)0xA3)
/* Interrupt mode register (used when in interrupt mode) */
#define FT5336_GMODE_REG ((uint8_t)0xA4)
#define FT5336_G_MODE_INTERRUPT_MASK ((uint8_t)0x03)
#define FT5336_G_MODE_INTERRUPT_SHIFT ((uint8_t)0x00)
/* Possible values of FT5336_GMODE_REG */
#define FT5336_G_MODE_INTERRUPT_POLLING ((uint8_t)0x00)
#define FT5336_G_MODE_INTERRUPT_TRIGGER ((uint8_t)0x01)
/* Current power mode the FT5336 system is in (R) */
#define FT5336_PWR_MODE_REG ((uint8_t)0xA5)
/* FT5336 firmware version */
#define FT5336_FIRMID_REG ((uint8_t)0xA6)
/* FT5336 Chip identification register */
#define FT5336_CHIP_ID_REG ((uint8_t)0xA8)
/* Possible values of FT5336_CHIP_ID_REG */
#define FT5336_ID_VALUE ((uint8_t)0x51)
/* Release code version */
#define FT5336_RELEASE_CODE_ID_REG ((uint8_t)0xAF)
/* Current operating mode the FT5336 system is in (R) */
#define FT5336_STATE_REG ((uint8_t)0xBC)
/**
* @}
*/
/* Exported macro ------------------------------------------------------------*/
/** @defgroup ft5336_Exported_Macros
* @{
*/
/* Exported functions --------------------------------------------------------*/
/** @defgroup ft5336_Exported_Functions
* @{
*/
/**
* @brief ft5336 Control functions
*/
/**
* @brief Initialize the ft5336 communication bus
* from MCU to FT5336 : ie I2C channel initialization (if required).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @retval None
*/
void ft5336_Init(uint16_t DeviceAddr);
/**
* @brief Software Reset the ft5336.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @retval None
*/
void ft5336_Reset(uint16_t DeviceAddr);
/**
* @brief Read the ft5336 device ID, pre initialize I2C in case of need to be
* able to read the FT5336 device ID, and verify this is a FT5336.
* @param DeviceAddr: I2C FT5336 Slave address.
* @retval The Device ID (two bytes).
*/
uint16_t ft5336_ReadID(uint16_t DeviceAddr);
/**
* @brief Configures the touch Screen IC device to start detecting touches
* @param DeviceAddr: Device address on communication Bus (I2C slave address).
* @retval None.
*/
void ft5336_TS_Start(uint16_t DeviceAddr);
/**
* @brief Return if there is touches detected or not.
* Try to detect new touches and forget the old ones (reset internal global
* variables).
* @param DeviceAddr: Device address on communication Bus.
* @retval : Number of active touches detected (can be 0, 1 or 2).
*/
uint8_t ft5336_TS_DetectTouch(uint16_t DeviceAddr);
/**
* @brief Get the touch screen X and Y positions values
* Manage multi touch thanks to touch Index global
* variable 'ft5336_handle.currActiveTouchIdx'.
* @param DeviceAddr: Device address on communication Bus.
* @param X: Pointer to X position value
* @param Y: Pointer to Y position value
* @retval None.
*/
void ft5336_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y);
/**
* @brief Configure the FT5336 device to generate IT on given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT5336).
* @retval None
*/
void ft5336_TS_EnableIT(uint16_t DeviceAddr);
/**
* @brief Configure the FT5336 device to stop generating IT on the given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT5336).
* @retval None
*/
void ft5336_TS_DisableIT(uint16_t DeviceAddr);
/**
* @brief Get IT status from FT5336 interrupt status registers
* Should be called Following an EXTI coming to the MCU to know the detailed
* reason of the interrupt.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @retval TS interrupts status
*/
uint8_t ft5336_TS_ITStatus (uint16_t DeviceAddr);
/**
* @brief Clear IT status in FT5336 interrupt status clear registers
* Should be called Following an EXTI coming to the MCU.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @retval TS interrupts status
*/
void ft5336_TS_ClearIT (uint16_t DeviceAddr);
/**** NEW FEATURES enabled when Multi-touch support is enabled ****/
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
/**
* @brief Get the last touch gesture identification (zoom, move up/down...).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @param pGestureId : Pointer to get last touch gesture Identification.
* @retval None.
*/
void ft5336_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId);
/**
* @brief Get the touch detailed informations on touch number 'touchIdx' (0..1)
* This touch detailed information contains :
* - weight that was applied to this touch
* - sub-area of the touch in the touch panel
* - event of linked to the touch (press down, lift up, ...)
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
* @param touchIdx : Passed index of the touch (0..1) on which we want to get the
* detailed information.
* @param pWeight : Pointer to to get the weight information of 'touchIdx'.
* @param pArea : Pointer to to get the sub-area information of 'touchIdx'.
* @param pEvent : Pointer to to get the event information of 'touchIdx'.
* @retval None.
*/
void ft5336_TS_GetTouchInfo(uint16_t DeviceAddr,
uint32_t touchIdx,
uint32_t * pWeight,
uint32_t * pArea,
uint32_t * pEvent);
#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
/* Imported TS IO functions --------------------------------------------------------*/
/** @defgroup ft5336_Imported_Functions
* @{
*/
/* TouchScreen (TS) external IO functions */
extern void TS_IO_Init(void);
extern void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
extern uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg);
extern void TS_IO_Delay(uint32_t Delay);
/**
* @}
*/
/* Imported global variables --------------------------------------------------------*/
/** @defgroup ft5336_Imported_Globals
* @{
*/
/* Touch screen driver structure */
extern TS_DrvTypeDef ft5336_ts_drv;
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __FT5336_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,82 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for FT6X06 Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-ft6x06-component-drivers"><small>Release Notes for</small> <mark>FT6X06 Component Drivers</mark></h1>
<p>Copyright © 2016 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the FT6X06 component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.3 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section20" aria-hidden="true"> <label for="collapse-section20" aria-hidden="true">V1.0.2 / 31-August-2018</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.1 / 03-May-2016</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>Add support of FT6x36 Touch controller</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.0.0 / 03-August-2015</label>
<div>
<h2 id="main-changes-3">Main Changes</h2>
<ul>
<li>First official release</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,496 @@
/**
******************************************************************************
* @file ft6x06.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the FT6X06
* IO Expander devices.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "ft6x06.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup FT6X06
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/** @defgroup FT6X06_Private_Defines FT6X06 Private Defines
* @{
*/
#define FT6x06_MAX_INSTANCE 2
/**
* @}
*/
/* Private macro -------------------------------------------------------------*/
/** @defgroup FT6X06_Private_Variables FT6X06 Private Variables
* @{
*/
/* Touch screen driver structure initialization */
TS_DrvTypeDef ft6x06_ts_drv =
{
ft6x06_Init,
ft6x06_ReadID,
ft6x06_Reset,
ft6x06_TS_Start,
ft6x06_TS_DetectTouch,
ft6x06_TS_GetXY,
ft6x06_TS_EnableIT,
ft6x06_TS_ClearIT,
ft6x06_TS_ITStatus,
ft6x06_TS_DisableIT
};
/* ft6x06 instances by address */
uint8_t ft6x06[FT6x06_MAX_INSTANCE] = {0};
/* Global ft6x06 handle */
static ft6x06_handle_TypeDef ft6x06_handle = { FT6206_I2C_NOT_INITIALIZED, 0, 0};
/**
* @}
*/
/** @defgroup ft6x06_Private_Function_Prototypes ft6x06 Private Function Prototypes
* @{
*/
static uint8_t ft6x06_GetInstance(uint16_t DeviceAddr);
/* Private functions prototypes-----------------------------------------------*/
#if (TS_AUTO_CALIBRATION_SUPPORTED == 1)
/**
* @brief Start TouchScreen calibration phase
* @param DeviceAddr: FT6206 Device address for communication on I2C Bus.
* @retval Status FT6206_STATUS_OK or FT6206_STATUS_NOT_OK.
*/
static uint32_t ft6x06_TS_Calibration(uint16_t DeviceAddr);
#endif /* TS_AUTO_CALIBRATION_SUPPORTED == 1 */
/**
* @brief Basic static configuration of TouchScreen
* @param DeviceAddr: FT6206 Device address for communication on I2C Bus.
* @retval Status FT6206_STATUS_OK or FT6206_STATUS_NOT_OK.
*/
static uint32_t ft6x06_TS_Configure(uint16_t DeviceAddr);
/**
* @}
*/
/** @defgroup ft6x06_Private_Functions ft6x06 Private Functions
* @{
*/
/**
* @brief Initialize the ft6x06 communication bus
* from MCU to FT6206 : ie I2C channel initialization (if required).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
* @retval None
*/
void ft6x06_Init(uint16_t DeviceAddr)
{
uint8_t instance;
uint8_t empty;
/* Check if device instance already exists */
instance = ft6x06_GetInstance(DeviceAddr);
/* To prevent double initialization */
if(instance == 0xFF)
{
/* Look for empty instance */
empty = ft6x06_GetInstance(0);
if(empty < FT6x06_MAX_INSTANCE)
{
/* Register the current device instance */
ft6x06[empty] = DeviceAddr;
/* Initialize IO BUS layer */
TS_IO_Init();
}
}
}
/**
* @brief Software Reset the ft6x06.
* @note : Not applicable to FT6206.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
* @retval None
*/
void ft6x06_Reset(uint16_t DeviceAddr)
{
/* Do nothing */
/* No software reset sequence available in FT6206 IC */
}
/**
* @brief Read the ft6x06 device ID, pre initialize I2C in case of need to be
* able to read the FT6206 device ID, and verify this is a FT6206.
* @param DeviceAddr: I2C FT6x06 Slave address.
* @retval The Device ID (two bytes).
*/
uint16_t ft6x06_ReadID(uint16_t DeviceAddr)
{
/* Initialize I2C link if needed */
TS_IO_Init();
/* Return the device ID value */
return (TS_IO_Read(DeviceAddr, FT6206_CHIP_ID_REG));
}
/**
* @brief Configures the touch Screen IC device to start detecting touches
* It goes through an internal calibration process (Hw calibration sequence of
* the touch screen).
* @param DeviceAddr: Device address on communication Bus (I2C slave address).
* @retval None.
*/
void ft6x06_TS_Start(uint16_t DeviceAddr)
{
#if (TS_AUTO_CALIBRATION_SUPPORTED == 1)
/* Hw Calibration sequence start : should be done once after each power up */
/* This is called internal calibration of the touch screen */
ft6x06_TS_Calibration(DeviceAddr);
#endif
/* Minimum static configuration of FT6206 */
ft6x06_TS_Configure(DeviceAddr);
/* By default set FT6206 IC in Polling mode : no INT generation on FT6206 for new touch available */
/* Note TS_INT is active low */
ft6x06_TS_DisableIT(DeviceAddr);
}
/**
* @brief Return if there is touches detected or not.
* Try to detect new touches and forget the old ones (reset internal global
* variables).
* @param DeviceAddr: Device address on communication Bus.
* @retval : Number of active touches detected (can be 0, 1 or 2).
*/
uint8_t ft6x06_TS_DetectTouch(uint16_t DeviceAddr)
{
volatile uint8_t nbTouch = 0;
/* Read register FT6206_TD_STAT_REG to check number of touches detection */
nbTouch = TS_IO_Read(DeviceAddr, FT6206_TD_STAT_REG);
nbTouch &= FT6206_TD_STAT_MASK;
if(nbTouch > FT6206_MAX_DETECTABLE_TOUCH)
{
/* If invalid number of touch detected, set it to zero */
nbTouch = 0;
}
/* Update ft6x06 driver internal global : current number of active touches */
ft6x06_handle.currActiveTouchNb = nbTouch;
/* Reset current active touch index on which to work on */
ft6x06_handle.currActiveTouchIdx = 0;
return(nbTouch);
}
/**
* @brief Get the touch screen X and Y positions values
* Manage multi touch thanks to touch Index global
* variable 'ft6x06_handle.currActiveTouchIdx'.
* @param DeviceAddr: Device address on communication Bus.
* @param X: Pointer to X position value
* @param Y: Pointer to Y position value
* @retval None.
*/
void ft6x06_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y)
{
uint8_t regAddress = 0;
uint8_t dataxy[4];
if(ft6x06_handle.currActiveTouchIdx < ft6x06_handle.currActiveTouchNb)
{
switch(ft6x06_handle.currActiveTouchIdx)
{
case 0 :
regAddress = FT6206_P1_XH_REG;
break;
case 1 :
regAddress = FT6206_P2_XH_REG;
break;
default :
break;
}
/* Read X and Y positions */
TS_IO_ReadMultiple(DeviceAddr, regAddress, dataxy, sizeof(dataxy));
/* Send back ready X position to caller */
*X = ((dataxy[0] & FT6206_MSB_MASK) << 8) | (dataxy[1] & FT6206_LSB_MASK);
/* Send back ready Y position to caller */
*Y = ((dataxy[2] & FT6206_MSB_MASK) << 8) | (dataxy[3] & FT6206_LSB_MASK);
ft6x06_handle.currActiveTouchIdx++;
}
}
/**
* @brief Configure the FT6206 device to generate IT on given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT6206).
* @retval None
*/
void ft6x06_TS_EnableIT(uint16_t DeviceAddr)
{
uint8_t regValue = 0;
regValue = (FT6206_G_MODE_INTERRUPT_TRIGGER & (FT6206_G_MODE_INTERRUPT_MASK >> FT6206_G_MODE_INTERRUPT_SHIFT)) << FT6206_G_MODE_INTERRUPT_SHIFT;
/* Set interrupt trigger mode in FT6206_GMODE_REG */
TS_IO_Write(DeviceAddr, FT6206_GMODE_REG, regValue);
}
/**
* @brief Configure the FT6206 device to stop generating IT on the given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT6206).
* @retval None
*/
void ft6x06_TS_DisableIT(uint16_t DeviceAddr)
{
uint8_t regValue = 0;
regValue = (FT6206_G_MODE_INTERRUPT_POLLING & (FT6206_G_MODE_INTERRUPT_MASK >> FT6206_G_MODE_INTERRUPT_SHIFT)) << FT6206_G_MODE_INTERRUPT_SHIFT;
/* Set interrupt polling mode in FT6206_GMODE_REG */
TS_IO_Write(DeviceAddr, FT6206_GMODE_REG, regValue);
}
/**
* @brief Get IT status from FT6206 interrupt status registers
* Should be called Following an EXTI coming to the MCU to know the detailed
* reason of the interrupt.
* @note : This feature is not applicable to FT6206.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
* @retval TS interrupts status : always return 0 here
*/
uint8_t ft6x06_TS_ITStatus(uint16_t DeviceAddr)
{
/* Always return 0 as feature not applicable to FT6206 */
return 0;
}
/**
* @brief Clear IT status in FT6206 interrupt status clear registers
* Should be called Following an EXTI coming to the MCU.
* @note : This feature is not applicable to FT6206.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
* @retval None
*/
void ft6x06_TS_ClearIT(uint16_t DeviceAddr)
{
/* Nothing to be done here for FT6206 */
}
/**** NEW FEATURES enabled when Multi-touch support is enabled ****/
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
/**
* @brief Get the last touch gesture identification (zoom, move up/down...).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6x06).
* @param pGestureId : Pointer to get last touch gesture Identification.
* @retval None.
*/
void ft6x06_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId)
{
volatile uint8_t ucReadData = 0;
ucReadData = TS_IO_Read(DeviceAddr, FT6206_GEST_ID_REG);
* pGestureId = ucReadData;
}
/**
* @brief Get the touch detailed informations on touch number 'touchIdx' (0..1)
* This touch detailed information contains :
* - weight that was applied to this touch
* - sub-area of the touch in the touch panel
* - event of linked to the touch (press down, lift up, ...)
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6x06).
* @param touchIdx : Passed index of the touch (0..1) on which we want to get the
* detailed information.
* @param pWeight : Pointer to to get the weight information of 'touchIdx'.
* @param pArea : Pointer to to get the sub-area information of 'touchIdx'.
* @param pEvent : Pointer to to get the event information of 'touchIdx'.
* @retval None.
*/
void ft6x06_TS_GetTouchInfo(uint16_t DeviceAddr,
uint32_t touchIdx,
uint32_t * pWeight,
uint32_t * pArea,
uint32_t * pEvent)
{
uint8_t regAddress = 0;
uint8_t dataxy[3];
if(touchIdx < ft6x06_handle.currActiveTouchNb)
{
switch(touchIdx)
{
case 0 :
regAddress = FT6206_P1_WEIGHT_REG;
break;
case 1 :
regAddress = FT6206_P2_WEIGHT_REG;
break;
default :
break;
} /* end switch(touchIdx) */
/* Read weight, area and Event Id of touch index */
TS_IO_ReadMultiple(DeviceAddr, regAddress, dataxy, sizeof(dataxy));
/* Return weight of touch index */
* pWeight = (dataxy[0] & FT6206_TOUCH_WEIGHT_MASK) >> FT6206_TOUCH_WEIGHT_SHIFT;
/* Return area of touch index */
* pArea = (dataxy[1] & FT6206_TOUCH_AREA_MASK) >> FT6206_TOUCH_AREA_SHIFT;
/* Return Event Id of touch index */
* pEvent = (dataxy[2] & FT6206_TOUCH_EVT_FLAG_MASK) >> FT6206_TOUCH_EVT_FLAG_SHIFT;
} /* of if(touchIdx < ft6x06_handle.currActiveTouchNb) */
}
#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
#if (TS_AUTO_CALIBRATION_SUPPORTED == 1)
/**
* @brief Start TouchScreen calibration phase
* @param DeviceAddr: FT6206 Device address for communication on I2C Bus.
* @retval Status FT6206_STATUS_OK or FT6206_STATUS_NOT_OK.
*/
static uint32_t ft6x06_TS_Calibration(uint16_t DeviceAddr)
{
uint32_t nbAttempt = 0;
volatile uint8_t ucReadData;
volatile uint8_t regValue;
uint32_t status = FT6206_STATUS_OK;
uint8_t bEndCalibration = 0;
/* >> Calibration sequence start */
/* Switch FT6206 back to factory mode to calibrate */
regValue = (FT6206_DEV_MODE_FACTORY & FT6206_DEV_MODE_MASK) << FT6206_DEV_MODE_SHIFT;
TS_IO_Write(DeviceAddr, FT6206_DEV_MODE_REG, regValue); /* 0x40 */
/* Read back the same register FT6206_DEV_MODE_REG */
ucReadData = TS_IO_Read(DeviceAddr, FT6206_DEV_MODE_REG);
TS_IO_Delay(300); /* Wait 300 ms */
if(((ucReadData & (FT6206_DEV_MODE_MASK << FT6206_DEV_MODE_SHIFT)) >> FT6206_DEV_MODE_SHIFT) != FT6206_DEV_MODE_FACTORY )
{
/* Return error to caller */
return(FT6206_STATUS_NOT_OK);
}
/* Start calibration command */
TS_IO_Write(DeviceAddr, FT6206_TD_STAT_REG, 0x04);
TS_IO_Delay(300); /* Wait 300 ms */
/* 100 attempts to wait switch from factory mode (calibration) to working mode */
for (nbAttempt=0; ((nbAttempt < 100) && (!bEndCalibration)) ; nbAttempt++)
{
ucReadData = TS_IO_Read(DeviceAddr, FT6206_DEV_MODE_REG);
ucReadData = (ucReadData & (FT6206_DEV_MODE_MASK << FT6206_DEV_MODE_SHIFT)) >> FT6206_DEV_MODE_SHIFT;
if(ucReadData == FT6206_DEV_MODE_WORKING)
{
/* Auto Switch to FT6206_DEV_MODE_WORKING : means calibration have ended */
bEndCalibration = 1; /* exit for loop */
}
TS_IO_Delay(200); /* Wait 200 ms */
}
/* Calibration sequence end << */
return(status);
}
#endif /* TS_AUTO_CALIBRATION_SUPPORTED == 1 */
/**
* @brief Basic static configuration of TouchScreen
* @param DeviceAddr: FT6206 Device address for communication on I2C Bus.
* @retval Status FT6206_STATUS_OK or FT6206_STATUS_NOT_OK.
*/
static uint32_t ft6x06_TS_Configure(uint16_t DeviceAddr)
{
uint32_t status = FT6206_STATUS_OK;
/* Nothing special to be done for FT6206 */
return(status);
}
/**
* @brief Check if the device instance of the selected address is already registered
* and return its index
* @param DeviceAddr: Device address on communication Bus.
* @retval Index of the device instance if registered, 0xFF if not.
*/
static uint8_t ft6x06_GetInstance(uint16_t DeviceAddr)
{
uint8_t idx = 0;
/* Check all the registered instances */
for(idx = 0; idx < FT6x06_MAX_INSTANCE ; idx ++)
{
if(ft6x06[idx] == DeviceAddr)
{
return idx;
}
}
return 0xFF;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,453 @@
/**
******************************************************************************
* @file ft6x06.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the
* ft6x06.c IO expander driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __FT6X06_H
#define __FT6X06_H
#ifdef __cplusplus
extern "C" {
#endif
/* Set Multi-touch as non supported */
#ifndef TS_MULTI_TOUCH_SUPPORTED
#define TS_MULTI_TOUCH_SUPPORTED 0
#endif
/* Set Auto-calibration as non supported */
#ifndef TS_AUTO_CALIBRATION_SUPPORTED
#define TS_AUTO_CALIBRATION_SUPPORTED 0
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/ts.h"
/* Macros --------------------------------------------------------------------*/
/** @typedef ft6x06_handle_TypeDef
* ft6x06 Handle definition.
*/
typedef struct
{
uint8_t i2cInitialized;
/* field holding the current number of simultaneous active touches */
uint8_t currActiveTouchNb;
/* field holding the touch index currently managed */
uint8_t currActiveTouchIdx;
} ft6x06_handle_TypeDef;
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup FT6X06
* @{
*/
/* Exported types ------------------------------------------------------------*/
/** @defgroup FT6X06_Exported_Types
* @{
*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup FT6X06_Exported_Constants
* @{
*/
/* Maximum border values of the touchscreen pad */
#define FT_6206_MAX_WIDTH ((uint16_t)800) /* Touchscreen pad max width */
#define FT_6206_MAX_HEIGHT ((uint16_t)480) /* Touchscreen pad max height */
/* Touchscreen pad max width and height values for FT6x36 Touch*/
#define FT_6206_MAX_WIDTH_HEIGHT ((uint16_t)240)
/* Possible values of driver functions return status */
#define FT6206_STATUS_OK 0
#define FT6206_STATUS_NOT_OK 1
/* Possible values of global variable 'TS_I2C_Initialized' */
#define FT6206_I2C_NOT_INITIALIZED 0
#define FT6206_I2C_INITIALIZED 1
/* Max detectable simultaneous touches */
#define FT6206_MAX_DETECTABLE_TOUCH 2
/**
* @brief : Definitions for FT6206 I2C register addresses on 8 bit
**/
/* Current mode register of the FT6206 (R/W) */
#define FT6206_DEV_MODE_REG 0x00
/* Possible values of FT6206_DEV_MODE_REG */
#define FT6206_DEV_MODE_WORKING 0x00
#define FT6206_DEV_MODE_FACTORY 0x04
#define FT6206_DEV_MODE_MASK 0x7
#define FT6206_DEV_MODE_SHIFT 4
/* Gesture ID register */
#define FT6206_GEST_ID_REG 0x01
/* Possible values of FT6206_GEST_ID_REG */
#define FT6206_GEST_ID_NO_GESTURE 0x00
#define FT6206_GEST_ID_MOVE_UP 0x10
#define FT6206_GEST_ID_MOVE_RIGHT 0x14
#define FT6206_GEST_ID_MOVE_DOWN 0x18
#define FT6206_GEST_ID_MOVE_LEFT 0x1C
#define FT6206_GEST_ID_ZOOM_IN 0x48
#define FT6206_GEST_ID_ZOOM_OUT 0x49
/* Touch Data Status register : gives number of active touch points (0..2) */
#define FT6206_TD_STAT_REG 0x02
/* Values related to FT6206_TD_STAT_REG */
#define FT6206_TD_STAT_MASK 0x0F
#define FT6206_TD_STAT_SHIFT 0x00
/* Values Pn_XH and Pn_YH related */
#define FT6206_TOUCH_EVT_FLAG_PRESS_DOWN 0x00
#define FT6206_TOUCH_EVT_FLAG_LIFT_UP 0x01
#define FT6206_TOUCH_EVT_FLAG_CONTACT 0x02
#define FT6206_TOUCH_EVT_FLAG_NO_EVENT 0x03
#define FT6206_TOUCH_EVT_FLAG_SHIFT 6
#define FT6206_TOUCH_EVT_FLAG_MASK (3 << FT6206_TOUCH_EVT_FLAG_SHIFT)
#define FT6206_MSB_MASK 0x0F
#define FT6206_MSB_SHIFT 0
/* Values Pn_XL and Pn_YL related */
#define FT6206_LSB_MASK 0xFF
#define FT6206_LSB_SHIFT 0
#define FT6206_P1_XH_REG 0x03
#define FT6206_P1_XL_REG 0x04
#define FT6206_P1_YH_REG 0x05
#define FT6206_P1_YL_REG 0x06
/* Touch Pressure register value (R) */
#define FT6206_P1_WEIGHT_REG 0x07
/* Values Pn_WEIGHT related */
#define FT6206_TOUCH_WEIGHT_MASK 0xFF
#define FT6206_TOUCH_WEIGHT_SHIFT 0
/* Touch area register */
#define FT6206_P1_MISC_REG 0x08
/* Values related to FT6206_Pn_MISC_REG */
#define FT6206_TOUCH_AREA_MASK (0x04 << 4)
#define FT6206_TOUCH_AREA_SHIFT 0x04
#define FT6206_P2_XH_REG 0x09
#define FT6206_P2_XL_REG 0x0A
#define FT6206_P2_YH_REG 0x0B
#define FT6206_P2_YL_REG 0x0C
#define FT6206_P2_WEIGHT_REG 0x0D
#define FT6206_P2_MISC_REG 0x0E
/* Threshold for touch detection */
#define FT6206_TH_GROUP_REG 0x80
/* Values FT6206_TH_GROUP_REG : threshold related */
#define FT6206_THRESHOLD_MASK 0xFF
#define FT6206_THRESHOLD_SHIFT 0
/* Filter function coefficients */
#define FT6206_TH_DIFF_REG 0x85
/* Control register */
#define FT6206_CTRL_REG 0x86
/* Values related to FT6206_CTRL_REG */
/* Will keep the Active mode when there is no touching */
#define FT6206_CTRL_KEEP_ACTIVE_MODE 0x00
/* Switching from Active mode to Monitor mode automatically when there is no touching */
#define FT6206_CTRL_KEEP_AUTO_SWITCH_MONITOR_MODE 0x01
/* The time period of switching from Active mode to Monitor mode when there is no touching */
#define FT6206_TIMEENTERMONITOR_REG 0x87
/* Report rate in Active mode */
#define FT6206_PERIODACTIVE_REG 0x88
/* Report rate in Monitor mode */
#define FT6206_PERIODMONITOR_REG 0x89
/* The value of the minimum allowed angle while Rotating gesture mode */
#define FT6206_RADIAN_VALUE_REG 0x91
/* Maximum offset while Moving Left and Moving Right gesture */
#define FT6206_OFFSET_LEFT_RIGHT_REG 0x92
/* Maximum offset while Moving Up and Moving Down gesture */
#define FT6206_OFFSET_UP_DOWN_REG 0x93
/* Minimum distance while Moving Left and Moving Right gesture */
#define FT6206_DISTANCE_LEFT_RIGHT_REG 0x94
/* Minimum distance while Moving Up and Moving Down gesture */
#define FT6206_DISTANCE_UP_DOWN_REG 0x95
/* Maximum distance while Zoom In and Zoom Out gesture */
#define FT6206_DISTANCE_ZOOM_REG 0x96
/* High 8-bit of LIB Version info */
#define FT6206_LIB_VER_H_REG 0xA1
/* Low 8-bit of LIB Version info */
#define FT6206_LIB_VER_L_REG 0xA2
/* Chip Selecting */
#define FT6206_CIPHER_REG 0xA3
/* Interrupt mode register (used when in interrupt mode) */
#define FT6206_GMODE_REG 0xA4
#define FT6206_G_MODE_INTERRUPT_MASK 0x03
#define FT6206_G_MODE_INTERRUPT_SHIFT 0x00
/* Possible values of FT6206_GMODE_REG */
#define FT6206_G_MODE_INTERRUPT_POLLING 0x00
#define FT6206_G_MODE_INTERRUPT_TRIGGER 0x01
/* Current power mode the FT6206 system is in (R) */
#define FT6206_PWR_MODE_REG 0xA5
/* FT6206 firmware version */
#define FT6206_FIRMID_REG 0xA6
/* FT6206 Chip identification register */
#define FT6206_CHIP_ID_REG 0xA8
/* Possible values of FT6206_CHIP_ID_REG */
#define FT6206_ID_VALUE 0x11
#define FT6x36_ID_VALUE 0xCD
/* Release code version */
#define FT6206_RELEASE_CODE_ID_REG 0xAF
/* Current operating mode the FT6206 system is in (R) */
#define FT6206_STATE_REG 0xBC
/**
* @}
*/
/* Exported macro ------------------------------------------------------------*/
/** @defgroup ft6x06_Exported_Macros
* @{
*/
/* Exported functions --------------------------------------------------------*/
/** @defgroup ft6x06_Exported_Functions
* @{
*/
/**
* @brief ft6x06 Control functions
*/
/**
* @brief Initialize the ft6x06 communication bus
* from MCU to FT6206 : ie I2C channel initialization (if required).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
* @retval None
*/
void ft6x06_Init(uint16_t DeviceAddr);
/**
* @brief Software Reset the ft6x06.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
* @retval None
*/
void ft6x06_Reset(uint16_t DeviceAddr);
/**
* @brief Read the ft6x06 device ID, pre intitalize I2C in case of need to be
* able to read the FT6206 device ID, and verify this is a FT6206.
* @param DeviceAddr: I2C FT6x06 Slave address.
* @retval The Device ID (two bytes).
*/
uint16_t ft6x06_ReadID(uint16_t DeviceAddr);
/**
* @brief Configures the touch Screen IC device to start detecting touches
* @param DeviceAddr: Device address on communication Bus (I2C slave address).
* @retval None.
*/
void ft6x06_TS_Start(uint16_t DeviceAddr);
/**
* @brief Return if there is touches detected or not.
* Try to detect new touches and forget the old ones (reset internal global
* variables).
* @param DeviceAddr: Device address on communication Bus.
* @retval : Number of active touches detected (can be 0, 1 or 2).
*/
uint8_t ft6x06_TS_DetectTouch(uint16_t DeviceAddr);
/**
* @brief Get the touch screen X and Y positions values
* Manage multi touch thanks to touch Index global
* variable 'ft6x06_handle.currActiveTouchIdx'.
* @param DeviceAddr: Device address on communication Bus.
* @param X: Pointer to X position value
* @param Y: Pointer to Y position value
* @retval None.
*/
void ft6x06_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y);
/**
* @brief Configure the FT6206 device to generate IT on given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT6206).
* @retval None
*/
void ft6x06_TS_EnableIT(uint16_t DeviceAddr);
/**
* @brief Configure the FT6206 device to stop generating IT on the given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT6206).
* @retval None
*/
void ft6x06_TS_DisableIT(uint16_t DeviceAddr);
/**
* @brief Get IT status from FT6206 interrupt status registers
* Should be called Following an EXTI coming to the MCU to know the detailed
* reason of the interrupt.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
* @retval TS interrupts status
*/
uint8_t ft6x06_TS_ITStatus (uint16_t DeviceAddr);
/**
* @brief Clear IT status in FT6206 interrupt status clear registers
* Should be called Following an EXTI coming to the MCU.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
* @retval TS interrupts status
*/
void ft6x06_TS_ClearIT (uint16_t DeviceAddr);
/**** NEW FEATURES enabled when Multi-touch support is enabled ****/
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
/**
* @brief Get the last touch gesture identification (zoom, move up/down...).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6x06).
* @param pGestureId : Pointer to get last touch gesture Identification.
* @retval None.
*/
void ft6x06_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId);
/**
* @brief Get the touch detailed informations on touch number 'touchIdx' (0..1)
* This touch detailed information contains :
* - weight that was applied to this touch
* - sub-area of the touch in the touch panel
* - event of linked to the touch (press down, lift up, ...)
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6x06).
* @param touchIdx : Passed index of the touch (0..1) on which we want to get the
* detailed information.
* @param pWeight : Pointer to to get the weight information of 'touchIdx'.
* @param pArea : Pointer to to get the sub-area information of 'touchIdx'.
* @param pEvent : Pointer to to get the event information of 'touchIdx'.
* @retval None.
*/
void ft6x06_TS_GetTouchInfo(uint16_t DeviceAddr,
uint32_t touchIdx,
uint32_t * pWeight,
uint32_t * pArea,
uint32_t * pEvent);
#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
/* Imported TS IO functions --------------------------------------------------------*/
/** @defgroup ft6x06_Imported_Functions
* @{
*/
/* TouchScreen (TS) external IO functions */
extern void TS_IO_Init(void);
extern void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
extern uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg);
extern uint16_t TS_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
extern void TS_IO_Delay(uint32_t Delay);
/**
* @}
*/
/* Imported global variables --------------------------------------------------------*/
/** @defgroup ft6x06_Imported_Globals
* @{
*/
/* Touch screen driver structure */
extern TS_DrvTypeDef ft6x06_ts_drv;
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __FT6X06_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for HTS221 Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-hts221-component-drivers"><small>Release Notes for</small> <mark>HTS221 Component Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the HTS221 component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 14-February-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release of HTS221 Temperature/Humidity sensor</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,229 @@
/**
******************************************************************************
* @file hts221.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the HTS221
* humidity and temperature devices
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "hts221.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup HTS221 HTS221
* @{
*/
/** @defgroup HTS221_Private_Variables HTS221 Private Variables
* @{
*/
/* HTS221 Humidity Private Variables */
HSENSOR_DrvTypeDef HTS221_H_Drv =
{
HTS221_H_Init,
HTS221_H_ReadID,
HTS221_H_ReadHumidity
};
/* HTS221_Temperature_Private_Variables */
TSENSOR_DrvTypeDef HTS221_T_Drv =
{
HTS221_T_Init,
0,
0,
HTS221_T_ReadTemp
};
/**
* @}
*/
/** @defgroup HTS221_Humidity_Private_Functions HTS221 Humidity Private Functions
* @{
*/
/**
* @brief Set HTS221 humidity sensor Initialization.
*/
void HTS221_H_Init(uint16_t DeviceAddr)
{
uint8_t tmp;
/* Read CTRL_REG1 */
tmp = SENSOR_IO_Read(DeviceAddr, HTS221_CTRL_REG1);
/* Enable BDU */
tmp &= ~HTS221_BDU_MASK;
tmp |= (1 << HTS221_BDU_BIT);
/* Set default ODR */
tmp &= ~HTS221_ODR_MASK;
tmp |= (uint8_t)0x01; /* Set ODR to 1Hz */
/* Activate the device */
tmp |= HTS221_PD_MASK;
/* Apply settings to CTRL_REG1 */
SENSOR_IO_Write(DeviceAddr, HTS221_CTRL_REG1, tmp);
}
/**
* @brief Read HTS221 ID.
* @retval ID
*/
uint8_t HTS221_H_ReadID(uint16_t DeviceAddr)
{
uint8_t ctrl = 0x00;
/* IO interface initialization */
SENSOR_IO_Init();
/* Read value at Who am I register address */
ctrl = SENSOR_IO_Read(DeviceAddr, HTS221_WHO_AM_I_REG);
return ctrl;
}
/**
* @brief Read humidity value of HTS221
* @retval humidity value;
*/
float HTS221_H_ReadHumidity(uint16_t DeviceAddr)
{
int16_t H0_T0_out, H1_T0_out, H_T_out;
int16_t H0_rh, H1_rh;
uint8_t buffer[2];
float tmp_f;
SENSOR_IO_ReadMultiple(DeviceAddr, (HTS221_H0_RH_X2 | 0x80), buffer, 2);
H0_rh = buffer[0] >> 1;
H1_rh = buffer[1] >> 1;
SENSOR_IO_ReadMultiple(DeviceAddr, (HTS221_H0_T0_OUT_L | 0x80), buffer, 2);
H0_T0_out = (((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0];
SENSOR_IO_ReadMultiple(DeviceAddr, (HTS221_H1_T0_OUT_L | 0x80), buffer, 2);
H1_T0_out = (((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0];
SENSOR_IO_ReadMultiple(DeviceAddr, (HTS221_HR_OUT_L_REG | 0x80), buffer, 2);
H_T_out = (((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0];
tmp_f = (float)(H_T_out - H0_T0_out) * (float)(H1_rh - H0_rh) / (float)(H1_T0_out - H0_T0_out) + H0_rh;
tmp_f *= 10.0f;
tmp_f = ( tmp_f > 1000.0f ) ? 1000.0f
: ( tmp_f < 0.0f ) ? 0.0f
: tmp_f;
return (tmp_f / 10.0f);
}
/**
* @}
*/
/** @defgroup HTS221_Temperature_Private_Functions HTS221 Temperature Private Functions
* @{
*/
/**
* @brief Set HTS221 temperature sensor Initialization.
* @param DeviceAddr: I2C device address
* @param InitStruct: pointer to a TSENSOR_InitTypeDef structure
* that contains the configuration setting for the HTS221.
*/
void HTS221_T_Init(uint16_t DeviceAddr, TSENSOR_InitTypeDef *pInitStruct)
{
uint8_t tmp;
/* Read CTRL_REG1 */
tmp = SENSOR_IO_Read(DeviceAddr, HTS221_CTRL_REG1);
/* Enable BDU */
tmp &= ~HTS221_BDU_MASK;
tmp |= (1 << HTS221_BDU_BIT);
/* Set default ODR */
tmp &= ~HTS221_ODR_MASK;
tmp |= (uint8_t)0x01; /* Set ODR to 1Hz */
/* Activate the device */
tmp |= HTS221_PD_MASK;
/* Apply settings to CTRL_REG1 */
SENSOR_IO_Write(DeviceAddr, HTS221_CTRL_REG1, tmp);
}
/**
* @brief Read temperature value of HTS221
* @param DeviceAddr: I2C device address
* @retval temperature value
*/
float HTS221_T_ReadTemp(uint16_t DeviceAddr)
{
int16_t T0_out, T1_out, T_out, T0_degC_x8_u16, T1_degC_x8_u16;
int16_t T0_degC, T1_degC;
uint8_t buffer[4], tmp;
float tmp_f;
SENSOR_IO_ReadMultiple(DeviceAddr, (HTS221_T0_DEGC_X8 | 0x80), buffer, 2);
tmp = SENSOR_IO_Read(DeviceAddr, HTS221_T0_T1_DEGC_H2);
T0_degC_x8_u16 = (((uint16_t)(tmp & 0x03)) << 8) | ((uint16_t)buffer[0]);
T1_degC_x8_u16 = (((uint16_t)(tmp & 0x0C)) << 6) | ((uint16_t)buffer[1]);
T0_degC = T0_degC_x8_u16 >> 3;
T1_degC = T1_degC_x8_u16 >> 3;
SENSOR_IO_ReadMultiple(DeviceAddr, (HTS221_T0_OUT_L | 0x80), buffer, 4);
T0_out = (((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0];
T1_out = (((uint16_t)buffer[3]) << 8) | (uint16_t)buffer[2];
SENSOR_IO_ReadMultiple(DeviceAddr, (HTS221_TEMP_OUT_L_REG | 0x80), buffer, 2);
T_out = (((uint16_t)buffer[1]) << 8) | (uint16_t)buffer[0];
tmp_f = (float)(T_out - T0_out) * (float)(T1_degC - T0_degC) / (float)(T1_out - T0_out) + T0_degC;
return tmp_f;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,320 @@
/**
******************************************************************************
* @file hts221.h
* @author MCD Application Team
* @brief HTS221 header driver file
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __HTS221__H
#define __HTS221__H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/hsensor.h"
#include "../Common/tsensor.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @addtogroup HTS221
* @{
*/
/** @defgroup HTS221_Exported_Constants HTS221 Exported Constants
* @{
*/
/**
* @brief Bitfield positioning.
*/
#define HTS221_BIT(x) ((uint8_t)x)
/**
* @brief Device Identification register.
* Read
* Default value: 0xBC
* 7:0 This read-only register contains the device identifier for HTS221.
*/
#define HTS221_WHO_AM_I_REG (uint8_t)0x0F
/**
* @brief Device Identification value.
*/
#define HTS221_WHO_AM_I_VAL (uint8_t)0xBC
/**
* @brief Humidity and temperature average mode register.
* Read/write
* Default value: 0x1B
* 7:6 Reserved.
* 5:3 AVGT2-AVGT1-AVGT0: Select the temperature internal average.
*
* AVGT2 | AVGT1 | AVGT0 | Nr. Internal Average
* ----------------------------------------------------
* 0 | 0 | 0 | 2
* 0 | 0 | 1 | 4
* 0 | 1 | 0 | 8
* 0 | 1 | 1 | 16
* 1 | 0 | 0 | 32
* 1 | 0 | 1 | 64
* 1 | 1 | 0 | 128
* 1 | 1 | 1 | 256
*
* 2:0 AVGH2-AVGH1-AVGH0: Select humidity internal average.
* AVGH2 | AVGH1 | AVGH0 | Nr. Internal Average
* ------------------------------------------------------
* 0 | 0 | 0 | 4
* 0 | 0 | 1 | 8
* 0 | 1 | 0 | 16
* 0 | 1 | 1 | 32
* 1 | 0 | 0 | 64
* 1 | 0 | 1 | 128
* 1 | 1 | 0 | 256
* 1 | 1 | 1 | 512
*
*/
#define HTS221_AV_CONF_REG (uint8_t)0x10
#define HTS221_AVGT_BIT HTS221_BIT(3)
#define HTS221_AVGH_BIT HTS221_BIT(0)
#define HTS221_AVGH_MASK (uint8_t)0x07
#define HTS221_AVGT_MASK (uint8_t)0x38
/**
* @brief Control register 1.
* Read/write
* Default value: 0x00
* 7 PD: power down control. 0 - power down mode; 1 - active mode.
* 6:3 Reserved.
* 2 BDU: block data update. 0 - continuous update
* 1 - output registers not updated until MSB and LSB reading.
* 1:0 ODR1, ODR0: output data rate selection.
*
* ODR1 | ODR0 | Humidity output data-rate(Hz) | Pressure output data-rate(Hz)
* ----------------------------------------------------------------------------------
* 0 | 0 | one shot | one shot
* 0 | 1 | 1 | 1
* 1 | 0 | 7 | 7
* 1 | 1 | 12.5 | 12.5
*
*/
#define HTS221_CTRL_REG1 (uint8_t)0x20
#define HTS221_PD_BIT HTS221_BIT(7)
#define HTS221_BDU_BIT HTS221_BIT(2)
#define HTS221_ODR_BIT HTS221_BIT(0)
#define HTS221_PD_MASK (uint8_t)0x80
#define HTS221_BDU_MASK (uint8_t)0x04
#define HTS221_ODR_MASK (uint8_t)0x03
/**
* @brief Control register 2.
* Read/write
* Default value: 0x00
* 7 BOOT: Reboot memory content. 0: normal mode
* 1: reboot memory content. Self-cleared upon completation.
* 6:2 Reserved.
* 1 HEATHER: 0: heater enable; 1: heater disable.
* 0 ONE_SHOT: 0: waiting for start of conversion
* 1: start for a new dataset. Self-cleared upon completation.
*/
#define HTS221_CTRL_REG2 (uint8_t)0x21
#define HTS221_BOOT_BIT HTS221_BIT(7)
#define HTS221_HEATHER_BIT HTS221_BIT(1)
#define HTS221_ONESHOT_BIT HTS221_BIT(0)
#define HTS221_BOOT_MASK (uint8_t)0x80
#define HTS221_HEATHER_MASK (uint8_t)0x02
#define HTS221_ONE_SHOT_MASK (uint8_t)0x01
/**
* @brief Control register 3.
* Read/write
* Default value: 0x00
* 7 DRDY_H_L: Interrupt edge. 0: active high, 1: active low.
* 6 PP_OD: Push-Pull/OpenDrain selection on interrupt pads. 0: push-pull
* 1: open drain.
* 5:3 Reserved.
* 2 DRDY: interrupt config. 0: disable, 1: enable.
*/
#define HTS221_CTRL_REG3 (uint8_t)0x22
#define HTS221_DRDY_H_L_BIT HTS221_BIT(7)
#define HTS221_PP_OD_BIT HTS221_BIT(6)
#define HTS221_DRDY_BIT HTS221_BIT(2)
#define HTS221_DRDY_H_L_MASK (uint8_t)0x80
#define HTS221_PP_OD_MASK (uint8_t)0x40
#define HTS221_DRDY_MASK (uint8_t)0x04
/**
* @brief Status register.
* Read
* Default value: 0x00
* 7:2 Reserved.
* 1 H_DA: Humidity data available. 0: new data for humidity is not yet available
* 1: new data for humidity is available.
* 0 T_DA: Temperature data available. 0: new data for temperature is not yet available
* 1: new data for temperature is available.
*/
#define HTS221_STATUS_REG (uint8_t)0x27
#define HTS221_H_DA_BIT HTS221_BIT(1)
#define HTS221_T_DA_BIT HTS221_BIT(0)
#define HTS221_HDA_MASK (uint8_t)0x02
#define HTS221_TDA_MASK (uint8_t)0x01
/**
* @brief Humidity data (LSB).
* Read
* Default value: 0x00.
* HOUT7 - HOUT0: Humidity data LSB (2's complement).
*/
#define HTS221_HR_OUT_L_REG (uint8_t)0x28
/**
* @brief Humidity data (MSB).
* Read
* Default value: 0x00.
* HOUT15 - HOUT8: Humidity data MSB (2's complement).
*/
#define HTS221_HR_OUT_H_REG (uint8_t)0x29
/**
* @brief Temperature data (LSB).
* Read
* Default value: 0x00.
* TOUT7 - TOUT0: temperature data LSB.
*/
#define HTS221_TEMP_OUT_L_REG (uint8_t)0x2A
/**
* @brief Temperature data (MSB).
* Read
* Default value: 0x00.
* TOUT15 - TOUT8: temperature data MSB.
*/
#define HTS221_TEMP_OUT_H_REG (uint8_t)0x2B
/**
* @brief Calibration registers.
* Read
*/
#define HTS221_H0_RH_X2 (uint8_t)0x30
#define HTS221_H1_RH_X2 (uint8_t)0x31
#define HTS221_T0_DEGC_X8 (uint8_t)0x32
#define HTS221_T1_DEGC_X8 (uint8_t)0x33
#define HTS221_T0_T1_DEGC_H2 (uint8_t)0x35
#define HTS221_H0_T0_OUT_L (uint8_t)0x36
#define HTS221_H0_T0_OUT_H (uint8_t)0x37
#define HTS221_H1_T0_OUT_L (uint8_t)0x3A
#define HTS221_H1_T0_OUT_H (uint8_t)0x3B
#define HTS221_T0_OUT_L (uint8_t)0x3C
#define HTS221_T0_OUT_H (uint8_t)0x3D
#define HTS221_T1_OUT_L (uint8_t)0x3E
#define HTS221_T1_OUT_H (uint8_t)0x3F
/**
* @}
*/
/** @defgroup HTS221_Humidity_Exported_Functions HTS221 Humidity Exported Functions
* @{
*/
/* HUMIDITY functions */
void HTS221_H_Init(uint16_t DeviceAddr);
uint8_t HTS221_H_ReadID(uint16_t DeviceAddr);
float HTS221_H_ReadHumidity(uint16_t DeviceAddr);
/**
* @}
*/
/** @defgroup HTS221_HumImported_Globals Humidity Imported Globals
* @{
*/
/* Humidity driver structure */
extern HSENSOR_DrvTypeDef HTS221_H_Drv;
/**
* @}
*/
/** @defgroup HTS221_Temperature_Exported_Functions HTS221 Temperature Exported Functions
* @{
*/
/* TEMPERATURE functions */
void HTS221_T_Init(uint16_t DeviceAddr, TSENSOR_InitTypeDef *pInitStruct);
float HTS221_T_ReadTemp(uint16_t DeviceAddr);
/**
* @}
*/
/** @defgroup HTS221_TempImported_Globals Temperature Imported Globals
* @{
*/
/* Temperature driver structure */
extern TSENSOR_DrvTypeDef HTS221_T_Drv;
/**
* @}
*/
/** @defgroup HTS221_Imported_Functions HTS221 Imported Functions
* @{
*/
/* IO functions */
extern void SENSOR_IO_Init(void);
extern void SENSOR_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
extern uint8_t SENSOR_IO_Read(uint8_t Addr, uint8_t Reg);
extern uint16_t SENSOR_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
extern void SENSOR_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __HTS221__H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,92 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for HX8347G Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-hx8347g-component-drivers"><small>Release Notes for</small> <mark>HX8347G Component Drivers</mark></h1>
<p>Copyright © 2016 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the HX8347G component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.1.2 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.1.1 / 16-February-2016</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Fix hx8347g_ReadReg() to write Index in Index Register (IR)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.1.0 / 10-February-2015</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>Harmonize all LCD controllers Link usage (Change LCD_IO_WriteData to LCD_IO_WriteMultipleData)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section185" aria-hidden="true"> <label for="collapse-section185" aria-hidden="true">V1.0.1 / 02-December-2014</label>
<div>
<h2 id="main-changes-3">Main Changes</h2>
<ul>
<li>hx8347g.h: change “\” by “/” in the include path to fix compilation issue under Linux</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section17" aria-hidden="true"> <label for="collapse-section17" aria-hidden="true">V1.0.0 / 06-May-2014</label>
<div>
<h2 id="main-changes-4">Main Changes</h2>
<ul>
<li>First official release of HX8347G LCD component driver</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,473 @@
/**
******************************************************************************
* @file hx8347g.c
* @author MCD Application Team
* @brief This file includes the LCD driver for HX8347G LCD.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "hx8347g.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup HX8347G
* @brief This file provides a set of functions needed to drive the
* HX8347G LCD.
* @{
*/
/** @defgroup HX8347G_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup HX8347G_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup HX8347G_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup HX8347G_Private_Variables
* @{
*/
LCD_DrvTypeDef hx8347g_drv =
{
hx8347g_Init,
hx8347g_ReadID,
hx8347g_DisplayOn,
hx8347g_DisplayOff,
hx8347g_SetCursor,
hx8347g_WritePixel,
hx8347g_ReadPixel,
hx8347g_SetDisplayWindow,
hx8347g_DrawHLine,
hx8347g_DrawVLine,
hx8347g_GetLcdPixelWidth,
hx8347g_GetLcdPixelHeight,
hx8347g_DrawBitmap,
};
static uint8_t Is_hx8347g_Initialized = 0;
static uint16_t ArrayRGB[320] = {0};
/**
* @}
*/
/** @defgroup HX8347G_Private_FunctionPrototypes
* @{
*/
/**
* @}
*/
/** @defgroup HX8347G_Private_Functions
* @{
*/
/**
* @brief Initialise the HX8347G LCD Component.
* @param None
* @retval None
*/
void hx8347g_Init(void)
{
if(Is_hx8347g_Initialized == 0)
{
Is_hx8347g_Initialized = 1;
/* Initialise HX8347G low level bus layer --------------------------------*/
LCD_IO_Init();
/* HX8347G requests 120ms (worst case) after reset */
LCD_Delay(120);
/* Driving ability setting */
hx8347g_WriteReg(LCD_REG_234, 0x00);
hx8347g_WriteReg(LCD_REG_235, 0x20);
hx8347g_WriteReg(LCD_REG_236, 0x0C);
hx8347g_WriteReg(LCD_REG_237, 0xC4);
hx8347g_WriteReg(LCD_REG_232, 0x40);
hx8347g_WriteReg(LCD_REG_233, 0x38);
hx8347g_WriteReg(LCD_REG_241, 0x01);
hx8347g_WriteReg(LCD_REG_242, 0x10);
hx8347g_WriteReg(LCD_REG_39, 0xA3);
/* Adjust the Gamma Curve */
hx8347g_WriteReg(LCD_REG_64, 0x01);
hx8347g_WriteReg(LCD_REG_65, 0x00);
hx8347g_WriteReg(LCD_REG_66, 0x00);
hx8347g_WriteReg(LCD_REG_67, 0x10);
hx8347g_WriteReg(LCD_REG_68, 0x0E);
hx8347g_WriteReg(LCD_REG_69, 0x24);
hx8347g_WriteReg(LCD_REG_70, 0x04);
hx8347g_WriteReg(LCD_REG_71, 0x50);
hx8347g_WriteReg(LCD_REG_72, 0x02);
hx8347g_WriteReg(LCD_REG_73, 0x13);
hx8347g_WriteReg(LCD_REG_74, 0x19);
hx8347g_WriteReg(LCD_REG_75, 0x19);
hx8347g_WriteReg(LCD_REG_76, 0x16);
hx8347g_WriteReg(LCD_REG_80, 0x1B);
hx8347g_WriteReg(LCD_REG_81, 0x31);
hx8347g_WriteReg(LCD_REG_82, 0x2F);
hx8347g_WriteReg(LCD_REG_83, 0x3F);
hx8347g_WriteReg(LCD_REG_84, 0x3F);
hx8347g_WriteReg(LCD_REG_85, 0x3E);
hx8347g_WriteReg(LCD_REG_86, 0x2F);
hx8347g_WriteReg(LCD_REG_87, 0x7B);
hx8347g_WriteReg(LCD_REG_88, 0x09);
hx8347g_WriteReg(LCD_REG_89, 0x06);
hx8347g_WriteReg(LCD_REG_90, 0x06);
hx8347g_WriteReg(LCD_REG_91, 0x0C);
hx8347g_WriteReg(LCD_REG_92, 0x1D);
hx8347g_WriteReg(LCD_REG_93, 0xCC);
/* Power voltage setting */
hx8347g_WriteReg(LCD_REG_27, 0x1B);
hx8347g_WriteReg(LCD_REG_26, 0x01);
hx8347g_WriteReg(LCD_REG_36, 0x2F);
hx8347g_WriteReg(LCD_REG_37, 0x57);
/*****VCOM offset ****/
hx8347g_WriteReg(LCD_REG_35, 0x86);
hx8347g_DisplayOn();
/* Set GRAM Area - Partial Display Control */
hx8347g_WriteReg(LCD_REG_1, 0x00); /* DP_STB = 0, DP_STB_S = 0, SCROLL = 0, */
hx8347g_SetDisplayWindow(0, 0, hx8347g_GetLcdPixelWidth(), hx8347g_GetLcdPixelHeight());
hx8347g_WriteReg(LCD_REG_22, 0xA0); /* Memory access control: MY = 1, MX = 0, MV = 1, ML = 0 */
}
/* Set the Cursor */
hx8347g_SetCursor(0, 0);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
}
/**
* @brief Enables the Display.
* @param None
* @retval None
*/
void hx8347g_DisplayOn(void)
{
/* Power On sequence ---------------------------------------------------------*/
hx8347g_WriteReg(LCD_REG_24, 0x36); /* Display frame rate = 70Hz RADJ = '0110' */
hx8347g_WriteReg(LCD_REG_25, 0x01); /* OSC_EN = 1 */
hx8347g_WriteReg(LCD_REG_28, 0x06); /* AP[2:0] = 111 */
hx8347g_WriteReg(LCD_REG_31, 0x90); /* GAS=1, VOMG=00, PON=1, DK=0, XDK=0, DVDH_TRI=0, STB=0*/
LCD_Delay(10);
/* 262k/65k color selection */
hx8347g_WriteReg(LCD_REG_23, 0x05); /* default 0x06 262k color, 0x05 65k color */
/* SET PANEL */
hx8347g_WriteReg(LCD_REG_54, 0x09); /* SS_PANEL = 1, GS_PANEL = 0,REV_PANEL = 0, BGR_PANEL = 1 */
/* Display On */
hx8347g_WriteReg(LCD_REG_40, 0x38);
LCD_Delay(60);
hx8347g_WriteReg(LCD_REG_40, 0x3C);
}
/**
* @brief Disables the Display.
* @param None
* @retval None
*/
void hx8347g_DisplayOff(void)
{
/* Display Off */
hx8347g_WriteReg(LCD_REG_40, 0x38);
LCD_Delay(60);
hx8347g_WriteReg(LCD_REG_40, 0x04);
/* Power Off sequence ---------------------------------------------------------*/
hx8347g_WriteReg(LCD_REG_23, 0x0000); /* default 0x06 262k color, 0x05 65k color */
hx8347g_WriteReg(LCD_REG_24, 0x0000); /* Display frame rate = 70Hz RADJ = '0110' */
hx8347g_WriteReg(LCD_REG_25, 0x0000); /* OSC_EN = 1 */
hx8347g_WriteReg(LCD_REG_28, 0x0000); /* AP[2:0] = 111 */
hx8347g_WriteReg(LCD_REG_31, 0x0000); /* GAS=1, VOMG=00, PON=1, DK=0, XDK=0, DVDH_TRI=0, STB=0*/
hx8347g_WriteReg(LCD_REG_54, 0x0000); /* SS_PANEL = 1, GS_PANEL = 0,REV_PANEL = 0, BGR_PANEL = 1 */
}
/**
* @brief Get the LCD pixel Width.
* @param None
* @retval The Lcd Pixel Width
*/
uint16_t hx8347g_GetLcdPixelWidth(void)
{
return (uint16_t)HX8347G_LCD_PIXEL_WIDTH;
}
/**
* @brief Get the LCD pixel Height.
* @param None
* @retval The Lcd Pixel Height
*/
uint16_t hx8347g_GetLcdPixelHeight(void)
{
return (uint16_t)HX8347G_LCD_PIXEL_HEIGHT;
}
/**
* @brief Get the HX8347G ID.
* @param None
* @retval The HX8347G ID
*/
uint16_t hx8347g_ReadID(void)
{
if(Is_hx8347g_Initialized == 0)
{
LCD_IO_Init();
/* HX8347G requests 120ms (worst case) after reset */
LCD_Delay(120);
}
return (hx8347g_ReadReg(0x00));
}
/**
* @brief Set Cursor position.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @retval None
*/
void hx8347g_SetCursor(uint16_t Xpos, uint16_t Ypos)
{
hx8347g_WriteReg(LCD_REG_6, 0x00);
hx8347g_WriteReg(LCD_REG_7, Xpos);
hx8347g_WriteReg(LCD_REG_2, Ypos >> 8);
hx8347g_WriteReg(LCD_REG_3, Ypos & 0xFF);
}
/**
* @brief Write pixel.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param RGBCode: the RGB pixel color
* @retval None
*/
void hx8347g_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode)
{
/* Set Cursor */
hx8347g_SetCursor(Xpos, Ypos);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
/* Write 16-bit GRAM Reg */
LCD_IO_WriteMultipleData((uint8_t*)&RGBCode, 2);
}
/**
* @brief Read pixel.
* @param None
* @retval the RGB pixel color
*/
uint16_t hx8347g_ReadPixel(uint16_t Xpos, uint16_t Ypos)
{
/* Set Cursor */
hx8347g_SetCursor(Xpos, Ypos);
/* Dummy read */
LCD_IO_ReadData(LCD_REG_34);
/* Read 16-bit Reg */
return (LCD_IO_ReadData(LCD_REG_34));
}
/**
* @brief Writes to the selected LCD register.
* @param LCDReg: address of the selected register.
* @param LCDRegValue: value to write to the selected register.
* @retval None
*/
void hx8347g_WriteReg(uint8_t LCDReg, uint16_t LCDRegValue)
{
LCD_IO_WriteReg(LCDReg);
/* Write 16-bit GRAM Reg */
LCD_IO_WriteMultipleData((uint8_t*)&LCDRegValue, 2);
}
/**
* @brief Reads the selected LCD Register.
* @param LCDReg: address of the selected register.
* @retval LCD Register Value.
*/
uint16_t hx8347g_ReadReg(uint8_t LCDReg)
{
/* Write 16-bit Index (then Read Reg) */
LCD_IO_WriteReg(LCDReg);
/* Read 16-bit Reg */
return (LCD_IO_ReadData(LCDReg));
}
/**
* @brief Sets a display window
* @param Xpos: specifies the X bottom left position.
* @param Ypos: specifies the Y bottom left position.
* @param Height: display window height.
* @param Width: display window width.
* @retval None
*/
void hx8347g_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
{
/* Horizontal GRAM Start Address */
hx8347g_WriteReg(LCD_REG_6, (Xpos) >> 8); /* SP */
hx8347g_WriteReg(LCD_REG_7, (Xpos) & 0xFF); /* SP */
/* Horizontal GRAM End Address */
hx8347g_WriteReg(LCD_REG_8, (Xpos + Height - 1) >> 8); /* EP */
hx8347g_WriteReg(LCD_REG_9, (Xpos + Height - 1) & 0xFF); /* EP */
/* Vertical GRAM Start Address */
hx8347g_WriteReg(LCD_REG_2, (Ypos) >> 8); /* SC */
hx8347g_WriteReg(LCD_REG_3, (Ypos) & 0xFF); /* SC */
/* Vertical GRAM End Address */
hx8347g_WriteReg(LCD_REG_4, (Ypos + Width - 1) >> 8); /* EC */
hx8347g_WriteReg(LCD_REG_5, (Ypos + Width - 1) & 0xFF); /* EC */
}
/**
* @brief Draw vertical line.
* @param RGBCode: Specifies the RGB color
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Length: specifies the Line length.
* @retval None
*/
void hx8347g_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint32_t i = 0;
/* Set Cursor */
hx8347g_SetCursor(Xpos, Ypos);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
/* Sent a complete line */
for(i = 0; i < Length; i++)
{
ArrayRGB[i] = RGBCode;
}
LCD_IO_WriteMultipleData((uint8_t*)&ArrayRGB[0], Length * 2);
}
/**
* @brief Draw vertical line.
* @param RGBCode: Specifies the RGB color
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Length: specifies the Line length.
* @retval None
*/
void hx8347g_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint16_t counter = 0;
/* Set Cursor */
hx8347g_SetCursor(Xpos, Ypos);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
/* Fill a complete vertical line */
for(counter = 0; counter < Length; counter++)
{
ArrayRGB[counter] = RGBCode;
}
/* Write 16-bit GRAM Reg */
LCD_IO_WriteMultipleData((uint8_t*)&ArrayRGB[0], Length * 2);
}
/**
* @brief Displays a bitmap picture loaded in the internal Flash.
* @param BmpAddress: Bmp picture address in the internal Flash.
* @retval None
*/
void hx8347g_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp)
{
uint32_t index = 0, size = 0;
/* Read bitmap size */
size = *(volatile uint16_t *) (pbmp + 2);
size |= (*(volatile uint16_t *) (pbmp + 4)) << 16;
/* Get bitmap data address offset */
index = *(volatile uint16_t *) (pbmp + 10);
index |= (*(volatile uint16_t *) (pbmp + 12)) << 16;
size = (size - index)/2;
pbmp += index;
/* Set GRAM write direction and BGR = 0 */
/* Memory access control: MY = 1, MX = 0, MV = 1, ML = 0 */
hx8347g_WriteReg(LCD_REG_22, 0xE0);
/* Set Cursor */
hx8347g_SetCursor(Xpos, Ypos);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
LCD_IO_WriteMultipleData((uint8_t*)pbmp, size*2);
/* Set GRAM write direction and BGR = 0 */
/* Memory access control: MY = 1, MX = 1, MV = 1, ML = 0 */
hx8347g_WriteReg(LCD_REG_22, 0xA0);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,256 @@
/**
******************************************************************************
* @file hx8347g.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the hx8347g.c
* driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __HX8347G_H
#define __HX8347G_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/lcd.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup hx8347g
* @{
*/
/** @defgroup HX8347G_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup HX8347G_Exported_Constants
* @{
*/
/**
* @brief HX8347G ID
*/
#define HX8347G_ID 0x0075
/**
* @brief HX8347G Size
*/
#define HX8347G_LCD_PIXEL_WIDTH ((uint16_t)320)
#define HX8347G_LCD_PIXEL_HEIGHT ((uint16_t)240)
/**
* @brief HX8347G Registers
*/
#define LCD_REG_0 0x00
#define LCD_REG_1 0x01
#define LCD_REG_2 0x02
#define LCD_REG_3 0x03
#define LCD_REG_4 0x04
#define LCD_REG_5 0x05
#define LCD_REG_6 0x06
#define LCD_REG_7 0x07
#define LCD_REG_8 0x08
#define LCD_REG_9 0x09
#define LCD_REG_10 0x0A
#define LCD_REG_11 0x0B
#define LCD_REG_12 0x0C
#define LCD_REG_13 0x0D
#define LCD_REG_14 0x0E
#define LCD_REG_15 0x0F
#define LCD_REG_16 0x10
#define LCD_REG_17 0x11
#define LCD_REG_18 0x12
#define LCD_REG_19 0x13
#define LCD_REG_20 0x14
#define LCD_REG_21 0x15
#define LCD_REG_22 0x16
#define LCD_REG_23 0x17
#define LCD_REG_24 0x18
#define LCD_REG_25 0x19
#define LCD_REG_26 0x1A
#define LCD_REG_27 0x1B
#define LCD_REG_28 0x1C
#define LCD_REG_29 0x1D
#define LCD_REG_30 0x1E
#define LCD_REG_31 0x1F
#define LCD_REG_32 0x20
#define LCD_REG_33 0x21
#define LCD_REG_34 0x22
#define LCD_REG_35 0x23
#define LCD_REG_36 0x24
#define LCD_REG_37 0x25
#define LCD_REG_38 0x26
#define LCD_REG_39 0x27
#define LCD_REG_40 0x28
#define LCD_REG_41 0x29
#define LCD_REG_42 0x2A
#define LCD_REG_43 0x2B
#define LCD_REG_44 0x2C
#define LCD_REG_45 0x2D
#define LCD_REG_46 0x2E
#define LCD_REG_47 0x2F
#define LCD_REG_48 0x30
#define LCD_REG_49 0x31
#define LCD_REG_50 0x32
#define LCD_REG_51 0x33
#define LCD_REG_52 0x34
#define LCD_REG_53 0x35
#define LCD_REG_54 0x36
#define LCD_REG_55 0x37
#define LCD_REG_56 0x38
#define LCD_REG_57 0x39
#define LCD_REG_58 0x3A
#define LCD_REG_59 0x3B
#define LCD_REG_60 0x3C
#define LCD_REG_61 0x3D
#define LCD_REG_62 0x3E
#define LCD_REG_63 0x3F
#define LCD_REG_64 0x40
#define LCD_REG_65 0x41
#define LCD_REG_66 0x42
#define LCD_REG_67 0x43
#define LCD_REG_68 0x44
#define LCD_REG_69 0x45
#define LCD_REG_70 0x46
#define LCD_REG_71 0x47
#define LCD_REG_72 0x48
#define LCD_REG_73 0x49
#define LCD_REG_74 0x4A
#define LCD_REG_75 0x4B
#define LCD_REG_76 0x4C
#define LCD_REG_77 0x4D
#define LCD_REG_78 0x4E
#define LCD_REG_79 0x4F
#define LCD_REG_80 0x50
#define LCD_REG_81 0x51
#define LCD_REG_82 0x52
#define LCD_REG_83 0x53
#define LCD_REG_84 0x54
#define LCD_REG_85 0x55
#define LCD_REG_86 0x56
#define LCD_REG_87 0x57
#define LCD_REG_88 0x58
#define LCD_REG_89 0x59
#define LCD_REG_90 0x5A
#define LCD_REG_91 0x5B
#define LCD_REG_92 0x5C
#define LCD_REG_93 0x5D
#define LCD_REG_94 0x5E
#define LCD_REG_95 0x5F
#define LCD_REG_96 0x60
#define LCD_REG_97 0x61
#define LCD_REG_98 0x62
#define LCD_REG_99 0x63
#define LCD_REG_104 0x68
#define LCD_REG_105 0x69
#define LCD_REG_112 0x70
#define LCD_REG_113 0x71
#define LCD_REG_132 0x84
#define LCD_REG_133 0x85
#define LCD_REG_195 0xC3
#define LCD_REG_197 0xC5
#define LCD_REG_199 0xC7
#define LCD_REG_203 0xCB
#define LCD_REG_204 0xCC
#define LCD_REG_205 0xCD
#define LCD_REG_206 0xCE
#define LCD_REG_207 0xCF
#define LCD_REG_208 0xD0
#define LCD_REG_209 0xD1
#define LCD_REG_210 0xD2
#define LCD_REG_211 0xD3
#define LCD_REG_232 0xE8
#define LCD_REG_233 0xE9
#define LCD_REG_234 0xEA
#define LCD_REG_235 0xEB
#define LCD_REG_236 0xEC
#define LCD_REG_237 0xED
#define LCD_REG_241 0xF1
#define LCD_REG_242 0xF2
#define LCD_REG_255 0xFF
/**
* @}
*/
/** @defgroup HX8347G_Exported_Functions
* @{
*/
void hx8347g_Init(void);
uint16_t hx8347g_ReadID(void);
void hx8347g_WriteReg(uint8_t LCDReg, uint16_t LCDRegValue);
uint16_t hx8347g_ReadReg(uint8_t LCDReg);
void hx8347g_DisplayOn(void);
void hx8347g_DisplayOff(void);
void hx8347g_SetCursor(uint16_t Xpos, uint16_t Ypos);
void hx8347g_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode);
uint16_t hx8347g_ReadPixel(uint16_t Xpos, uint16_t Ypos);
void hx8347g_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
void hx8347g_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
void hx8347g_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp);
void hx8347g_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
uint16_t hx8347g_GetLcdPixelWidth(void);
uint16_t hx8347g_GetLcdPixelHeight(void);
/* LCD driver structure */
extern LCD_DrvTypeDef hx8347g_drv;
/* LCD IO functions */
void LCD_IO_Init(void);
void LCD_IO_WriteMultipleData(uint8_t *pData, uint32_t Size);
void LCD_IO_WriteReg(uint8_t Reg);
uint16_t LCD_IO_ReadData(uint16_t Reg);
void LCD_Delay (uint32_t delay);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __HX8347G_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,64 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for HX8347I Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-hx8347i-component-drivers"><small>Release Notes for</small> <mark>HX8347I Component Drivers</mark></h1>
<p>Copyright © 2019 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the HX8347I component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 28-June-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update HX8347I controller initialization sequence</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section1" checked aria-hidden="true"> <label for="collapse-section1" aria-hidden="true">V1.0.0 / 03-April-2019</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release of HX8347I LCD controller component drivers.</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,479 @@
/**
******************************************************************************
* @file hx8347i.c
* @author MCD Application Team
* @brief This file includes the driver for HX8347I LCD.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "hx8347i.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup HX8347I
* @brief This file provides a set of functions needed to drive the
* HX8347I LCD.
* @{
*/
/** @defgroup HX8347I_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup HX8347I_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup HX8347I_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup HX8347I_Private_Variables
* @{
*/
LCD_DrvTypeDef hx8347i_drv =
{
hx8347i_Init,
hx8347i_ReadID,
hx8347i_DisplayOn,
hx8347i_DisplayOff,
hx8347i_SetCursor,
hx8347i_WritePixel,
hx8347i_ReadPixel,
hx8347i_SetDisplayWindow,
hx8347i_DrawHLine,
hx8347i_DrawVLine,
hx8347i_GetLcdPixelWidth,
hx8347i_GetLcdPixelHeight,
hx8347i_DrawBitmap,
};
static uint8_t Is_hx8347i_Initialized = 0;
static uint16_t ArrayRGB[320] = {0};
/**
* @}
*/
/** @defgroup HX8347I_Private_FunctionPrototypes
* @{
*/
/**
* @}
*/
/** @defgroup HX8347I_Private_Functions
* @{
*/
/**
* @brief Initialize the HX8347I LCD Component.
* @param None
* @retval None
*/
void hx8347i_Init(void)
{
if(Is_hx8347i_Initialized == 0)
{
Is_hx8347i_Initialized = 1;
/* Initialize HX8347I low level bus layer --------------------------------*/
LCD_IO_Init();
/* HX8347I requests 120ms (worst case) after reset */
LCD_Delay(120);
/* Adjust the Gamma Curve */
hx8347i_WriteReg(LCD_REG_64, 0x00);
hx8347i_WriteReg(LCD_REG_65, 0x00);
hx8347i_WriteReg(LCD_REG_66, 0x04);
hx8347i_WriteReg(LCD_REG_67, 0x13);
hx8347i_WriteReg(LCD_REG_68, 0x0E);
hx8347i_WriteReg(LCD_REG_69, 0x2D);
hx8347i_WriteReg(LCD_REG_70, 0x0E);
hx8347i_WriteReg(LCD_REG_71, 0x57);
hx8347i_WriteReg(LCD_REG_72, 0x09);
hx8347i_WriteReg(LCD_REG_73, 0x13);
hx8347i_WriteReg(LCD_REG_74, 0x19);
hx8347i_WriteReg(LCD_REG_75, 0x1A);
hx8347i_WriteReg(LCD_REG_76, 0x1B);
hx8347i_WriteReg(LCD_REG_80, 0x12);
hx8347i_WriteReg(LCD_REG_81, 0x31);
hx8347i_WriteReg(LCD_REG_82, 0x2C);
hx8347i_WriteReg(LCD_REG_83, 0x3B);
hx8347i_WriteReg(LCD_REG_84, 0x3F);
hx8347i_WriteReg(LCD_REG_85, 0x3F);
hx8347i_WriteReg(LCD_REG_86, 0x28);
hx8347i_WriteReg(LCD_REG_87, 0x71);
hx8347i_WriteReg(LCD_REG_88, 0x04);
hx8347i_WriteReg(LCD_REG_89, 0x05);
hx8347i_WriteReg(LCD_REG_90, 0x06);
hx8347i_WriteReg(LCD_REG_91, 0x0C);
hx8347i_WriteReg(LCD_REG_92, 0x16);
hx8347i_WriteReg(LCD_REG_93, 0x88);
/* Power voltage setting */
hx8347i_WriteReg(LCD_REG_27, 0x1E); /* VRH=4.60V */
hx8347i_WriteReg(LCD_REG_28, 0x07); /* AP Crosstalk */
hx8347i_WriteReg(LCD_REG_26, 0x01); /* BT (VGH~15V,VGL~-10V,DDVDH~5V) */
hx8347i_WriteReg(LCD_REG_36, 0x38); /* VMH */
hx8347i_WriteReg(LCD_REG_37, 0x5F); /* VML */
/*****VCOM offset ****/
hx8347i_WriteReg(LCD_REG_35, 0x6B);
/* Driving ability setting */
hx8347i_WriteReg(LCD_REG_232, 0x7C);
hx8347i_WriteReg(LCD_REG_236, 0x14);
hx8347i_WriteReg(LCD_REG_237, 0x0C);
hx8347i_WriteReg(LCD_REG_228, 0x10);
hx8347i_WriteReg(LCD_REG_229, 0x02);
hx8347i_WriteReg(LCD_REG_230, 0x10);
hx8347i_WriteReg(LCD_REG_231, 0x02);
hx8347i_DisplayOn();
/* Set GRAM Area - Partial Display Control */
hx8347i_WriteReg(LCD_REG_1, 0x00); /* DP_STB = 0, DP_STB_S = 0, SCROLL = 0, */
hx8347i_SetDisplayWindow(0, 0, hx8347i_GetLcdPixelWidth(), hx8347i_GetLcdPixelHeight());
hx8347i_WriteReg(LCD_REG_22, 0xA0); /* Memory access control: MY = 1, MX = 0, MV = 1, ML = 0 */
}
/* Set the Cursor */
hx8347i_SetCursor(0, 0);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
}
/**
* @brief Enables the Display.
* @param None
* @retval None
*/
void hx8347i_DisplayOn(void)
{
/* Power On sequence ---------------------------------------------------------*/
hx8347i_WriteReg(LCD_REG_24, 0x99); /* Display frame rate = 75Hz UADJ */
hx8347i_WriteReg(LCD_REG_25, 0x01); /* OSC_EN = 1 */
hx8347i_WriteReg(LCD_REG_26, 0x04); /* BT[2:0] = 4 before sleep out */
hx8347i_WriteReg(LCD_REG_31, 0x88); /* GAS=1, VOMG=00, PON=0, DK=1, XDK=0, DVDH_TRI=0, STB=0*/
LCD_Delay(5);
hx8347i_WriteReg(LCD_REG_31, 0x80); /* GAS=1, VOMG=00, PON=0, DK=0, XDK=0, DVDH_TRI=0, STB=0*/
LCD_Delay(5);
hx8347i_WriteReg(LCD_REG_31, 0x90); /* GAS=1, VOMG=00, PON=1, DK=0, XDK=0, DVDH_TRI=0, STB=0*/
LCD_Delay(5);
hx8347i_WriteReg(LCD_REG_31, 0xD0); /* GAS=1, VOMG=10, PON=1, DK=0, XDK=0, DDVDH_TRI=0, STB=0 */
LCD_Delay(5);
/* 262k/65k color selection */
hx8347i_WriteReg(LCD_REG_23, 0x05); /* default 0x06 262k color, 0x05 65k color */
/* SET PANEL */
hx8347i_WriteReg(LCD_REG_54, 0x09); /* SS_PANEL = 1, GS_PANEL = 0,REV_PANEL = 0, BGR_PANEL = 1 */
/* Display On */
hx8347i_WriteReg(LCD_REG_40, 0x38);
LCD_Delay(60);
hx8347i_WriteReg(LCD_REG_40, 0x3C);
}
/**
* @brief Disables the Display.
* @param None
* @retval None
*/
void hx8347i_DisplayOff(void)
{
/* Display Off */
hx8347i_WriteReg(LCD_REG_40, 0x38);
LCD_Delay(60);
hx8347i_WriteReg(LCD_REG_40, 0x04);
/* Power Off sequence ---------------------------------------------------------*/
hx8347i_WriteReg(LCD_REG_23, 0x0000); /* default 0x06 262k color, 0x05 65k color */
hx8347i_WriteReg(LCD_REG_24, 0x0000); /* Display frame rate = 70Hz RADJ = '0110' */
hx8347i_WriteReg(LCD_REG_25, 0x0000); /* OSC_EN = 1 */
hx8347i_WriteReg(LCD_REG_28, 0x0000); /* AP[2:0] = 111 */
hx8347i_WriteReg(LCD_REG_31, 0x0000); /* GAS=1, VOMG=00, PON=1, DK=0, XDK=0, DVDH_TRI=0, STB=0*/
hx8347i_WriteReg(LCD_REG_54, 0x0000); /* SS_PANEL = 1, GS_PANEL = 0,REV_PANEL = 0, BGR_PANEL = 1 */
}
/**
* @brief Get the LCD pixel Width.
* @param None
* @retval The Lcd Pixel Width
*/
uint16_t hx8347i_GetLcdPixelWidth(void)
{
return (uint16_t)HX8347I_LCD_PIXEL_WIDTH;
}
/**
* @brief Get the LCD pixel Height.
* @param None
* @retval The Lcd Pixel Height
*/
uint16_t hx8347i_GetLcdPixelHeight(void)
{
return (uint16_t)HX8347I_LCD_PIXEL_HEIGHT;
}
/**
* @brief Get the HX8347I ID.
* @param None
* @retval The HX8347I ID
*/
uint16_t hx8347i_ReadID(void)
{
if(Is_hx8347i_Initialized == 0)
{
LCD_IO_Init();
/* HX8347I requests 120ms (worst case) after reset */
LCD_Delay(120);
}
return (hx8347i_ReadReg(0x00));
}
/**
* @brief Set Cursor position.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @retval None
*/
void hx8347i_SetCursor(uint16_t Xpos, uint16_t Ypos)
{
hx8347i_WriteReg(LCD_REG_6, 0x00);
hx8347i_WriteReg(LCD_REG_7, Xpos);
hx8347i_WriteReg(LCD_REG_2, Ypos >> 8);
hx8347i_WriteReg(LCD_REG_3, Ypos & 0xFF);
}
/**
* @brief Write pixel.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param RGBCode: the RGB pixel color
* @retval None
*/
void hx8347i_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode)
{
/* Set Cursor */
hx8347i_SetCursor(Xpos, Ypos);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
/* Write 16-bit GRAM Reg */
LCD_IO_WriteMultipleData((uint8_t*)&RGBCode, 2);
}
/**
* @brief Read pixel.
* @param None
* @retval the RGB pixel color
*/
uint16_t hx8347i_ReadPixel(uint16_t Xpos, uint16_t Ypos)
{
/* Set Cursor */
hx8347i_SetCursor(Xpos, Ypos);
/* Dummy read */
LCD_IO_ReadData(LCD_REG_34);
/* Read 16-bit Reg */
return (LCD_IO_ReadData(LCD_REG_34));
}
/**
* @brief Writes to the selected LCD register.
* @param LCDReg: address of the selected register.
* @param LCDRegValue: value to write to the selected register.
* @retval None
*/
void hx8347i_WriteReg(uint8_t LCDReg, uint16_t LCDRegValue)
{
LCD_IO_WriteReg(LCDReg);
/* Write 16-bit GRAM Reg */
LCD_IO_WriteMultipleData((uint8_t*)&LCDRegValue, 2);
}
/**
* @brief Reads the selected LCD Register.
* @param LCDReg: address of the selected register.
* @retval LCD Register Value.
*/
uint16_t hx8347i_ReadReg(uint8_t LCDReg)
{
/* Write 16-bit Index (then Read Reg) */
LCD_IO_WriteReg(LCDReg);
/* Read 16-bit Reg */
return (LCD_IO_ReadData(LCDReg));
}
/**
* @brief Sets a display window
* @param Xpos: specifies the X bottom left position.
* @param Ypos: specifies the Y bottom left position.
* @param Height: display window height.
* @param Width: display window width.
* @retval None
*/
void hx8347i_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
{
/* Horizontal GRAM Start Address */
hx8347i_WriteReg(LCD_REG_6, (Xpos) >> 8); /* SP */
hx8347i_WriteReg(LCD_REG_7, (Xpos) & 0xFF); /* SP */
/* Horizontal GRAM End Address */
hx8347i_WriteReg(LCD_REG_8, (Xpos + Height - 1) >> 8); /* EP */
hx8347i_WriteReg(LCD_REG_9, (Xpos + Height - 1) & 0xFF); /* EP */
/* Vertical GRAM Start Address */
hx8347i_WriteReg(LCD_REG_2, (Ypos) >> 8); /* SC */
hx8347i_WriteReg(LCD_REG_3, (Ypos) & 0xFF); /* SC */
/* Vertical GRAM End Address */
hx8347i_WriteReg(LCD_REG_4, (Ypos + Width - 1) >> 8); /* EC */
hx8347i_WriteReg(LCD_REG_5, (Ypos + Width - 1) & 0xFF); /* EC */
}
/**
* @brief Draw vertical line.
* @param RGBCode: Specifies the RGB color
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Length: specifies the Line length.
* @retval None
*/
void hx8347i_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint32_t i = 0;
/* Set Cursor */
hx8347i_SetCursor(Xpos, Ypos);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
/* Sent a complete line */
for(i = 0; i < Length; i++)
{
ArrayRGB[i] = RGBCode;
}
LCD_IO_WriteMultipleData((uint8_t*)&ArrayRGB[0], Length * 2);
}
/**
* @brief Draw vertical line.
* @param RGBCode: Specifies the RGB color
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Length: specifies the Line length.
* @retval None
*/
void hx8347i_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint16_t counter = 0;
/* Set Cursor */
hx8347i_SetCursor(Xpos, Ypos);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
/* Fill a complete vertical line */
for(counter = 0; counter < Length; counter++)
{
ArrayRGB[counter] = RGBCode;
}
/* Write 16-bit GRAM Reg */
LCD_IO_WriteMultipleData((uint8_t*)&ArrayRGB[0], Length * 2);
}
/**
* @brief Displays a bitmap picture loaded in the internal Flash.
* @param BmpAddress: Bmp picture address in the internal Flash.
* @retval None
*/
void hx8347i_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp)
{
uint32_t index = 0, size = 0;
/* Read bitmap size */
size = *(volatile uint16_t *) (pbmp + 2);
size |= (*(volatile uint16_t *) (pbmp + 4)) << 16;
/* Get bitmap data address offset */
index = *(volatile uint16_t *) (pbmp + 10);
index |= (*(volatile uint16_t *) (pbmp + 12)) << 16;
size = (size - index)/2;
pbmp += index;
/* Set GRAM write direction and BGR = 0 */
/* Memory access control: MY = 1, MX = 0, MV = 1, ML = 0 */
hx8347i_WriteReg(LCD_REG_22, 0xE0);
/* Set Cursor */
hx8347i_SetCursor(Xpos, Ypos);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
LCD_IO_WriteMultipleData((uint8_t*)pbmp, size*2);
/* Set GRAM write direction and BGR = 0 */
/* Memory access control: MY = 1, MX = 1, MV = 1, ML = 0 */
hx8347i_WriteReg(LCD_REG_22, 0xA0);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,245 @@
/**
******************************************************************************
* @file hx8347i.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the hx8347i.c
* driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef HX8347I_H
#define HX8347I_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/lcd.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup hx8347i
* @{
*/
/** @defgroup HX8347I_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup HX8347I_Exported_Constants
* @{
*/
/**
* @brief HX8347I ID
*/
#define HX8347I_ID 0x0095
/**
* @brief HX8347I Size
*/
#define HX8347I_LCD_PIXEL_WIDTH ((uint16_t)320)
#define HX8347I_LCD_PIXEL_HEIGHT ((uint16_t)240)
/**
* @brief HX8347I Registers
*/
#define LCD_REG_0 0x00
#define LCD_REG_1 0x01
#define LCD_REG_2 0x02
#define LCD_REG_3 0x03
#define LCD_REG_4 0x04
#define LCD_REG_5 0x05
#define LCD_REG_6 0x06
#define LCD_REG_7 0x07
#define LCD_REG_8 0x08
#define LCD_REG_9 0x09
#define LCD_REG_10 0x0A
#define LCD_REG_11 0x0B
#define LCD_REG_12 0x0C
#define LCD_REG_13 0x0D
#define LCD_REG_14 0x0E
#define LCD_REG_15 0x0F
#define LCD_REG_16 0x10
#define LCD_REG_17 0x11
#define LCD_REG_18 0x12
#define LCD_REG_19 0x13
#define LCD_REG_20 0x14
#define LCD_REG_21 0x15
#define LCD_REG_22 0x16
#define LCD_REG_23 0x17
#define LCD_REG_24 0x18
#define LCD_REG_25 0x19
#define LCD_REG_26 0x1A
#define LCD_REG_27 0x1B
#define LCD_REG_28 0x1C
#define LCD_REG_29 0x1D
#define LCD_REG_30 0x1E
#define LCD_REG_31 0x1F
#define LCD_REG_32 0x20
#define LCD_REG_33 0x21
#define LCD_REG_34 0x22
#define LCD_REG_35 0x23
#define LCD_REG_36 0x24
#define LCD_REG_37 0x25
#define LCD_REG_38 0x26
#define LCD_REG_39 0x27
#define LCD_REG_40 0x28
#define LCD_REG_41 0x29
#define LCD_REG_42 0x2A
#define LCD_REG_43 0x2B
#define LCD_REG_44 0x2C
#define LCD_REG_45 0x2D
#define LCD_REG_46 0x2E
#define LCD_REG_47 0x2F
#define LCD_REG_48 0x30
#define LCD_REG_49 0x31
#define LCD_REG_50 0x32
#define LCD_REG_51 0x33
#define LCD_REG_52 0x34
#define LCD_REG_53 0x35
#define LCD_REG_54 0x36
#define LCD_REG_55 0x37
#define LCD_REG_56 0x38
#define LCD_REG_57 0x39
#define LCD_REG_58 0x3A
#define LCD_REG_59 0x3B
#define LCD_REG_60 0x3C
#define LCD_REG_61 0x3D
#define LCD_REG_62 0x3E
#define LCD_REG_63 0x3F
#define LCD_REG_64 0x40
#define LCD_REG_65 0x41
#define LCD_REG_66 0x42
#define LCD_REG_67 0x43
#define LCD_REG_68 0x44
#define LCD_REG_69 0x45
#define LCD_REG_70 0x46
#define LCD_REG_71 0x47
#define LCD_REG_72 0x48
#define LCD_REG_73 0x49
#define LCD_REG_74 0x4A
#define LCD_REG_75 0x4B
#define LCD_REG_76 0x4C
#define LCD_REG_77 0x4D
#define LCD_REG_78 0x4E
#define LCD_REG_79 0x4F
#define LCD_REG_80 0x50
#define LCD_REG_81 0x51
#define LCD_REG_82 0x52
#define LCD_REG_83 0x53
#define LCD_REG_84 0x54
#define LCD_REG_85 0x55
#define LCD_REG_86 0x56
#define LCD_REG_87 0x57
#define LCD_REG_88 0x58
#define LCD_REG_89 0x59
#define LCD_REG_90 0x5A
#define LCD_REG_91 0x5B
#define LCD_REG_92 0x5C
#define LCD_REG_93 0x5D
#define LCD_REG_94 0x5E
#define LCD_REG_95 0x5F
#define LCD_REG_96 0x60
#define LCD_REG_97 0x61
#define LCD_REG_98 0x62
#define LCD_REG_129 0x81
#define LCD_REG_130 0x82
#define LCD_REG_132 0x84
#define LCD_REG_133 0x85
#define LCD_REG_228 0xE4
#define LCD_REG_229 0xE5
#define LCD_REG_230 0xE6
#define LCD_REG_231 0xE7
#define LCD_REG_232 0xE8
#define LCD_REG_233 0xE9
#define LCD_REG_234 0xEA
#define LCD_REG_235 0xEB
#define LCD_REG_236 0xEC
#define LCD_REG_237 0xED
#define LCD_REG_243 0xF3
#define LCD_REG_244 0xF4
#define LCD_REG_255 0xFF
/**
* @}
*/
/** @defgroup HX8347I_Exported_Functions
* @{
*/
void hx8347i_Init(void);
uint16_t hx8347i_ReadID(void);
void hx8347i_WriteReg(uint8_t LCDReg, uint16_t LCDRegValue);
uint16_t hx8347i_ReadReg(uint8_t LCDReg);
void hx8347i_DisplayOn(void);
void hx8347i_DisplayOff(void);
void hx8347i_SetCursor(uint16_t Xpos, uint16_t Ypos);
void hx8347i_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode);
uint16_t hx8347i_ReadPixel(uint16_t Xpos, uint16_t Ypos);
void hx8347i_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
void hx8347i_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
void hx8347i_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp);
void hx8347i_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
uint16_t hx8347i_GetLcdPixelWidth(void);
uint16_t hx8347i_GetLcdPixelHeight(void);
/* LCD driver structure */
extern LCD_DrvTypeDef hx8347i_drv;
/* LCD IO functions */
void LCD_IO_Init(void);
void LCD_IO_WriteMultipleData(uint8_t *pData, uint32_t Size);
void LCD_IO_WriteReg(uint8_t Reg);
uint16_t LCD_IO_ReadData(uint16_t Reg);
void LCD_Delay (uint32_t delay);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* HX8347I_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for ISS66WVH8M8 Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-iss66wvh8m8-component-drivers"><small>Release Notes for</small> <mark>ISS66WVH8M8 Component Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the ISS66WVH8M8 component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 07-August-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release of HyperRAM ISS66WVH8M8 Component driver</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,133 @@
/**
******************************************************************************
* @file iss66wvh8m8.h
* @author MCD Application Team
* @brief This file contains all the description of the ISS66WVH8M8 Octal memory.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __ISS66WVH8M8_H
#define __ISS66WVH8M8_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup ISS66WVH8M8
* @{
*/
/** @defgroup ISS66WVH8M8_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup ISS66WVH8M8_Exported_Constants
* @{
*/
/**
* @brief ISS66WVH8M8 Configuration
*/
#define ISS66WVH8M8_RAM_SIZE 0x800000 /* 64 MBits => 8 MBytes */
#define ISS66WVH8M8_LATENCY_83M 3
#define ISS66WVH8M8_LATENCY_100M 4
#define ISS66WVH8M8_LATENCY_133M 5
#define ISS66WVH8M8_LATENCY_166M 6
#define ISS66WVH8M8_CR0_LATENCY_83M ISS66WVH8M8_CR0_IL_3_CLOCK
#define ISS66WVH8M8_CR0_LATENCY_100M ISS66WVH8M8_CR0_IL_4_CLOCK
#define ISS66WVH8M8_CR0_LATENCY_133M ISS66WVH8M8_CR0_IL_5_CLOCK
#define ISS66WVH8M8_CR0_LATENCY_166M ISS66WVH8M8_CR0_IL_6_CLOCK
/**
* @brief ISS66WVH8M8 Registers
*/
/* Device Identification Register 0 */
#define ISS66WVH8M8_DIR0_ADDRESS ((uint32_t)0x00000000)
#define ISS66WVH8M8_DIR0_MANUFACTURER ((uint16_t)0x000F) /*!< Manufacturer */
#define ISS66WVH8M8_DIR0_CADC ((uint16_t)0x00F0) /*!< Column Address Bit Count */
#define ISS66WVH8M8_DIR0_RABC ((uint16_t)0x1F00) /*!< Row Address Bit Count */
#define ISS66WVH8M8_DIR0_DADDR ((uint16_t)0xC000) /*!< Die Address */
/* Device Identification Register 1 */
#define ISS66WVH8M8_DIR1_ADDRESS ((uint32_t)0x00000001)
#define ISS66WVH8M8_DIR1_DTYPE ((uint16_t)0x000F) /*!< Device Type */
/* Configuration Register 0 */
#define ISS66WVH8M8_CR0_ADDRESS ((uint32_t)0x00000800)
#define ISS66WVH8M8_CR0_BLENGTH ((uint16_t)0x0003) /*!< Burst length */
#define ISS66WVH8M8_CR0_HBE ((uint16_t)0x0004) /*!< Hybrid burst enable */
#define ISS66WVH8M8_CR0_FLE ((uint16_t)0x0008) /*!< Fixed latency enable */
#define ISS66WVH8M8_CR0_IL ((uint16_t)0x00F0) /*!< Initial latency */
#define ISS66WVH8M8_CR0_IL_5_CLOCK ((uint16_t)0x0000) /*!< 5 clock latency */
#define ISS66WVH8M8_CR0_IL_6_CLOCK ((uint16_t)0x0010) /*!< 6 clock latency */
#define ISS66WVH8M8_CR0_IL_3_CLOCK ((uint16_t)0x00E0) /*!< 3 clock latency */
#define ISS66WVH8M8_CR0_IL_4_CLOCK ((uint16_t)0x00F0) /*!< 4 clock latency */
#define ISS66WVH8M8_CR0_DS ((uint16_t)0x7000) /*!< Drive strength */
#define ISS66WVH8M8_CR0_DPDE ((uint16_t)0x8000) /*!< Deep Power down enable */
/* Configuration Register 1 */
#define ISS66WVH8M8_CR1_ADDRESS ((uint32_t)0x00000801)
#define ISS66WVH8M8_CR1_DRI ((uint16_t)0x0003) /*!< Distributed refresh interval */
/**
* @}
*/
/** @defgroup ISS66WVH8M8_Exported_Functions
* @{
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __ISS66WVH8M8_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,98 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for L3GD20 Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-l3gd20-component-drivers"><small>Release Notes for</small> <mark>L3GD20 Component Drivers</mark></h1>
<p>Copyright © 2015 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the L3GD20 component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V2.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V2.0.0 / 24-June-2015</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>l3gd20.h/.c:
<ul>
<li>Add gyroscope de-initialization function: L3GD20_DeInit()</li>
<li>Add gyroscope low power configuration function: L3GD20_LowPower()</li>
</ul></li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">NOTE</span></span></strong> This release must be used with BSP Common driver V4.0.0 or later</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.1.1 / 27-November-2014</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>3gd20.h: change “\” by “/” in the include path to fix compilation issue under Linux</li>
<li>Miscellaneous formatting and comments update</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section185" aria-hidden="true"> <label for="collapse-section185" aria-hidden="true">V1.1.0 / 10-June-2014</label>
<div>
<h2 id="main-changes-3">Main Changes</h2>
<ul>
<li>Update to support new revision of L3GD20 component having new device ID 0xD5 (new define added: I_AM_L3GD20_TR)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section17" aria-hidden="true"> <label for="collapse-section17" aria-hidden="true">V1.0.0 / 18-February-2014</label>
<div>
<h2 id="main-changes-4">Main Changes</h2>
<ul>
<li>First official release of L3GD20 gyroscope</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,398 @@
/**
******************************************************************************
* @file l3gd20.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the L3GD20,
* ST MEMS motion sensor, 3-axis digital output gyroscope.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "l3gd20.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup L3GD20
* @{
*/
/** @defgroup L3GD20_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup L3GD20_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup L3GD20_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup L3GD20_Private_Variables
* @{
*/
GYRO_DrvTypeDef L3gd20Drv =
{
L3GD20_Init,
L3GD20_DeInit,
L3GD20_ReadID,
L3GD20_RebootCmd,
L3GD20_LowPower,
L3GD20_INT1InterruptConfig,
L3GD20_EnableIT,
L3GD20_DisableIT,
0,
0,
L3GD20_FilterConfig,
L3GD20_FilterCmd,
L3GD20_ReadXYZAngRate
};
/**
* @}
*/
/** @defgroup L3GD20_Private_FunctionPrototypes
* @{
*/
/**
* @}
*/
/** @defgroup L3GD20_Private_Functions
* @{
*/
/**
* @brief Set L3GD20 Initialization.
* @param L3GD20_InitStruct: pointer to a L3GD20_InitTypeDef structure
* that contains the configuration setting for the L3GD20.
* @retval None
*/
void L3GD20_Init(uint16_t InitStruct)
{
uint8_t ctrl = 0x00;
/* Configure the low level interface */
GYRO_IO_Init();
/* Write value to MEMS CTRL_REG1 register */
ctrl = (uint8_t) InitStruct;
GYRO_IO_Write(&ctrl, L3GD20_CTRL_REG1_ADDR, 1);
/* Write value to MEMS CTRL_REG4 register */
ctrl = (uint8_t) (InitStruct >> 8);
GYRO_IO_Write(&ctrl, L3GD20_CTRL_REG4_ADDR, 1);
}
/**
* @brief L3GD20 De-initialization
* @param None
* @retval None
*/
void L3GD20_DeInit(void)
{
}
/**
* @brief Read ID address of L3GD20
* @param None
* @retval ID name
*/
uint8_t L3GD20_ReadID(void)
{
uint8_t tmp;
/* Configure the low level interface */
GYRO_IO_Init();
/* Read WHO I AM register */
GYRO_IO_Read(&tmp, L3GD20_WHO_AM_I_ADDR, 1);
/* Return the ID */
return (uint8_t)tmp;
}
/**
* @brief Reboot memory content of L3GD20
* @param None
* @retval None
*/
void L3GD20_RebootCmd(void)
{
uint8_t tmpreg;
/* Read CTRL_REG5 register */
GYRO_IO_Read(&tmpreg, L3GD20_CTRL_REG5_ADDR, 1);
/* Enable or Disable the reboot memory */
tmpreg |= L3GD20_BOOT_REBOOTMEMORY;
/* Write value to MEMS CTRL_REG5 register */
GYRO_IO_Write(&tmpreg, L3GD20_CTRL_REG5_ADDR, 1);
}
/**
* @brief Set L3GD20 in low-power mode
* @param
* @retval None
*/
void L3GD20_LowPower(uint16_t InitStruct)
{
uint8_t ctrl = 0x00;
/* Write value to MEMS CTRL_REG1 register */
ctrl = (uint8_t) InitStruct;
GYRO_IO_Write(&ctrl, L3GD20_CTRL_REG1_ADDR, 1);
}
/**
* @brief Set L3GD20 Interrupt INT1 configuration
* @param Int1Config: the configuration setting for the L3GD20 Interrupt.
* @retval None
*/
void L3GD20_INT1InterruptConfig(uint16_t Int1Config)
{
uint8_t ctrl_cfr = 0x00, ctrl3 = 0x00;
/* Read INT1_CFG register */
GYRO_IO_Read(&ctrl_cfr, L3GD20_INT1_CFG_ADDR, 1);
/* Read CTRL_REG3 register */
GYRO_IO_Read(&ctrl3, L3GD20_CTRL_REG3_ADDR, 1);
ctrl_cfr &= 0x80;
ctrl_cfr |= ((uint8_t) Int1Config >> 8);
ctrl3 &= 0xDF;
ctrl3 |= ((uint8_t) Int1Config);
/* Write value to MEMS INT1_CFG register */
GYRO_IO_Write(&ctrl_cfr, L3GD20_INT1_CFG_ADDR, 1);
/* Write value to MEMS CTRL_REG3 register */
GYRO_IO_Write(&ctrl3, L3GD20_CTRL_REG3_ADDR, 1);
}
/**
* @brief Enable INT1 or INT2 interrupt
* @param IntSel: choice of INT1 or INT2
* This parameter can be:
* @arg L3GD20_INT1
* @arg L3GD20_INT2
* @retval None
*/
void L3GD20_EnableIT(uint8_t IntSel)
{
uint8_t tmpreg;
/* Read CTRL_REG3 register */
GYRO_IO_Read(&tmpreg, L3GD20_CTRL_REG3_ADDR, 1);
if(IntSel == L3GD20_INT1)
{
tmpreg &= 0x7F;
tmpreg |= L3GD20_INT1INTERRUPT_ENABLE;
}
else if(IntSel == L3GD20_INT2)
{
tmpreg &= 0xF7;
tmpreg |= L3GD20_INT2INTERRUPT_ENABLE;
}
/* Write value to MEMS CTRL_REG3 register */
GYRO_IO_Write(&tmpreg, L3GD20_CTRL_REG3_ADDR, 1);
}
/**
* @brief Disable INT1 or INT2 interrupt
* @param IntSel: choice of INT1 or INT2
* This parameter can be:
* @arg L3GD20_INT1
* @arg L3GD20_INT2
* @retval None
*/
void L3GD20_DisableIT(uint8_t IntSel)
{
uint8_t tmpreg;
/* Read CTRL_REG3 register */
GYRO_IO_Read(&tmpreg, L3GD20_CTRL_REG3_ADDR, 1);
if(IntSel == L3GD20_INT1)
{
tmpreg &= 0x7F;
tmpreg |= L3GD20_INT1INTERRUPT_DISABLE;
}
else if(IntSel == L3GD20_INT2)
{
tmpreg &= 0xF7;
tmpreg |= L3GD20_INT2INTERRUPT_DISABLE;
}
/* Write value to MEMS CTRL_REG3 register */
GYRO_IO_Write(&tmpreg, L3GD20_CTRL_REG3_ADDR, 1);
}
/**
* @brief Set High Pass Filter Modality
* @param FilterStruct: contains the configuration setting for the L3GD20.
* @retval None
*/
void L3GD20_FilterConfig(uint8_t FilterStruct)
{
uint8_t tmpreg;
/* Read CTRL_REG2 register */
GYRO_IO_Read(&tmpreg, L3GD20_CTRL_REG2_ADDR, 1);
tmpreg &= 0xC0;
/* Configure MEMS: mode and cutoff frequency */
tmpreg |= FilterStruct;
/* Write value to MEMS CTRL_REG2 register */
GYRO_IO_Write(&tmpreg, L3GD20_CTRL_REG2_ADDR, 1);
}
/**
* @brief Enable or Disable High Pass Filter
* @param HighPassFilterState: new state of the High Pass Filter feature.
* This parameter can be:
* @arg: L3GD20_HIGHPASSFILTER_DISABLE
* @arg: L3GD20_HIGHPASSFILTER_ENABLE
* @retval None
*/
void L3GD20_FilterCmd(uint8_t HighPassFilterState)
{
uint8_t tmpreg;
/* Read CTRL_REG5 register */
GYRO_IO_Read(&tmpreg, L3GD20_CTRL_REG5_ADDR, 1);
tmpreg &= 0xEF;
tmpreg |= HighPassFilterState;
/* Write value to MEMS CTRL_REG5 register */
GYRO_IO_Write(&tmpreg, L3GD20_CTRL_REG5_ADDR, 1);
}
/**
* @brief Get status for L3GD20 data
* @param None
* @retval Data status in a L3GD20 Data
*/
uint8_t L3GD20_GetDataStatus(void)
{
uint8_t tmpreg;
/* Read STATUS_REG register */
GYRO_IO_Read(&tmpreg, L3GD20_STATUS_REG_ADDR, 1);
return tmpreg;
}
/**
* @brief Calculate the L3GD20 angular data.
* @param pfData: Data out pointer
* @retval None
*/
void L3GD20_ReadXYZAngRate(float *pfData)
{
uint8_t tmpbuffer[6] ={0};
int16_t RawData[3] = {0};
uint8_t tmpreg = 0;
float sensitivity = 0;
int i =0;
GYRO_IO_Read(&tmpreg,L3GD20_CTRL_REG4_ADDR,1);
GYRO_IO_Read(tmpbuffer,L3GD20_OUT_X_L_ADDR,6);
/* check in the control register 4 the data alignment (Big Endian or Little Endian)*/
if(!(tmpreg & L3GD20_BLE_MSB))
{
for(i=0; i<3; i++)
{
RawData[i]=(int16_t)(((uint16_t)tmpbuffer[2*i+1] << 8) + tmpbuffer[2*i]);
}
}
else
{
for(i=0; i<3; i++)
{
RawData[i]=(int16_t)(((uint16_t)tmpbuffer[2*i] << 8) + tmpbuffer[2*i+1]);
}
}
/* Switch the sensitivity value set in the CRTL4 */
switch(tmpreg & L3GD20_FULLSCALE_SELECTION)
{
case L3GD20_FULLSCALE_250:
sensitivity=L3GD20_SENSITIVITY_250DPS;
break;
case L3GD20_FULLSCALE_500:
sensitivity=L3GD20_SENSITIVITY_500DPS;
break;
case L3GD20_FULLSCALE_2000:
sensitivity=L3GD20_SENSITIVITY_2000DPS;
break;
}
/* Divide by sensitivity */
for(i=0; i<3; i++)
{
pfData[i]=(float)(RawData[i] * sensitivity);
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,306 @@
/**
******************************************************************************
* @file l3gd20.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the l3gd20.c driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __L3GD20_H
#define __L3GD20_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/gyro.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup L3GD20
* @{
*/
/** @defgroup L3GD20_Exported_Constants
* @{
*/
/******************************************************************************/
/*************************** START REGISTER MAPPING **************************/
/******************************************************************************/
#define L3GD20_WHO_AM_I_ADDR 0x0F /* device identification register */
#define L3GD20_CTRL_REG1_ADDR 0x20 /* Control register 1 */
#define L3GD20_CTRL_REG2_ADDR 0x21 /* Control register 2 */
#define L3GD20_CTRL_REG3_ADDR 0x22 /* Control register 3 */
#define L3GD20_CTRL_REG4_ADDR 0x23 /* Control register 4 */
#define L3GD20_CTRL_REG5_ADDR 0x24 /* Control register 5 */
#define L3GD20_REFERENCE_REG_ADDR 0x25 /* Reference register */
#define L3GD20_OUT_TEMP_ADDR 0x26 /* Out temp register */
#define L3GD20_STATUS_REG_ADDR 0x27 /* Status register */
#define L3GD20_OUT_X_L_ADDR 0x28 /* Output Register X */
#define L3GD20_OUT_X_H_ADDR 0x29 /* Output Register X */
#define L3GD20_OUT_Y_L_ADDR 0x2A /* Output Register Y */
#define L3GD20_OUT_Y_H_ADDR 0x2B /* Output Register Y */
#define L3GD20_OUT_Z_L_ADDR 0x2C /* Output Register Z */
#define L3GD20_OUT_Z_H_ADDR 0x2D /* Output Register Z */
#define L3GD20_FIFO_CTRL_REG_ADDR 0x2E /* Fifo control Register */
#define L3GD20_FIFO_SRC_REG_ADDR 0x2F /* Fifo src Register */
#define L3GD20_INT1_CFG_ADDR 0x30 /* Interrupt 1 configuration Register */
#define L3GD20_INT1_SRC_ADDR 0x31 /* Interrupt 1 source Register */
#define L3GD20_INT1_TSH_XH_ADDR 0x32 /* Interrupt 1 Threshold X register */
#define L3GD20_INT1_TSH_XL_ADDR 0x33 /* Interrupt 1 Threshold X register */
#define L3GD20_INT1_TSH_YH_ADDR 0x34 /* Interrupt 1 Threshold Y register */
#define L3GD20_INT1_TSH_YL_ADDR 0x35 /* Interrupt 1 Threshold Y register */
#define L3GD20_INT1_TSH_ZH_ADDR 0x36 /* Interrupt 1 Threshold Z register */
#define L3GD20_INT1_TSH_ZL_ADDR 0x37 /* Interrupt 1 Threshold Z register */
#define L3GD20_INT1_DURATION_ADDR 0x38 /* Interrupt 1 DURATION register */
/******************************************************************************/
/**************************** END REGISTER MAPPING ***************************/
/******************************************************************************/
#define I_AM_L3GD20 ((uint8_t)0xD4)
#define I_AM_L3GD20_TR ((uint8_t)0xD5)
/** @defgroup Power_Mode_selection
* @{
*/
#define L3GD20_MODE_POWERDOWN ((uint8_t)0x00)
#define L3GD20_MODE_ACTIVE ((uint8_t)0x08)
/**
* @}
*/
/** @defgroup OutPut_DataRate_Selection
* @{
*/
#define L3GD20_OUTPUT_DATARATE_1 ((uint8_t)0x00)
#define L3GD20_OUTPUT_DATARATE_2 ((uint8_t)0x40)
#define L3GD20_OUTPUT_DATARATE_3 ((uint8_t)0x80)
#define L3GD20_OUTPUT_DATARATE_4 ((uint8_t)0xC0)
/**
* @}
*/
/** @defgroup Axes_Selection
* @{
*/
#define L3GD20_X_ENABLE ((uint8_t)0x02)
#define L3GD20_Y_ENABLE ((uint8_t)0x01)
#define L3GD20_Z_ENABLE ((uint8_t)0x04)
#define L3GD20_AXES_ENABLE ((uint8_t)0x07)
#define L3GD20_AXES_DISABLE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Bandwidth_Selection
* @{
*/
#define L3GD20_BANDWIDTH_1 ((uint8_t)0x00)
#define L3GD20_BANDWIDTH_2 ((uint8_t)0x10)
#define L3GD20_BANDWIDTH_3 ((uint8_t)0x20)
#define L3GD20_BANDWIDTH_4 ((uint8_t)0x30)
/**
* @}
*/
/** @defgroup Full_Scale_Selection
* @{
*/
#define L3GD20_FULLSCALE_250 ((uint8_t)0x00)
#define L3GD20_FULLSCALE_500 ((uint8_t)0x10)
#define L3GD20_FULLSCALE_2000 ((uint8_t)0x20)
#define L3GD20_FULLSCALE_SELECTION ((uint8_t)0x30)
/**
* @}
*/
/** @defgroup Full_Scale_Sensitivity
* @{
*/
#define L3GD20_SENSITIVITY_250DPS ((float)8.75f) /*!< gyroscope sensitivity with 250 dps full scale [DPS/LSB] */
#define L3GD20_SENSITIVITY_500DPS ((float)17.50f) /*!< gyroscope sensitivity with 500 dps full scale [DPS/LSB] */
#define L3GD20_SENSITIVITY_2000DPS ((float)70.00f) /*!< gyroscope sensitivity with 2000 dps full scale [DPS/LSB] */
/**
* @}
*/
/** @defgroup Block_Data_Update
* @{
*/
#define L3GD20_BlockDataUpdate_Continous ((uint8_t)0x00)
#define L3GD20_BlockDataUpdate_Single ((uint8_t)0x80)
/**
* @}
*/
/** @defgroup Endian_Data_selection
* @{
*/
#define L3GD20_BLE_LSB ((uint8_t)0x00)
#define L3GD20_BLE_MSB ((uint8_t)0x40)
/**
* @}
*/
/** @defgroup High_Pass_Filter_status
* @{
*/
#define L3GD20_HIGHPASSFILTER_DISABLE ((uint8_t)0x00)
#define L3GD20_HIGHPASSFILTER_ENABLE ((uint8_t)0x10)
/**
* @}
*/
/** @defgroup INT1_INT2_selection
* @{
*/
#define L3GD20_INT1 ((uint8_t)0x00)
#define L3GD20_INT2 ((uint8_t)0x01)
/**
* @}
*/
/** @defgroup INT1_Interrupt_status
* @{
*/
#define L3GD20_INT1INTERRUPT_DISABLE ((uint8_t)0x00)
#define L3GD20_INT1INTERRUPT_ENABLE ((uint8_t)0x80)
/**
* @}
*/
/** @defgroup INT2_Interrupt_status
* @{
*/
#define L3GD20_INT2INTERRUPT_DISABLE ((uint8_t)0x00)
#define L3GD20_INT2INTERRUPT_ENABLE ((uint8_t)0x08)
/**
* @}
*/
/** @defgroup INT1_Interrupt_ActiveEdge
* @{
*/
#define L3GD20_INT1INTERRUPT_LOW_EDGE ((uint8_t)0x20)
#define L3GD20_INT1INTERRUPT_HIGH_EDGE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Boot_Mode_selection
* @{
*/
#define L3GD20_BOOT_NORMALMODE ((uint8_t)0x00)
#define L3GD20_BOOT_REBOOTMEMORY ((uint8_t)0x80)
/**
* @}
*/
/** @defgroup High_Pass_Filter_Mode
* @{
*/
#define L3GD20_HPM_NORMAL_MODE_RES ((uint8_t)0x00)
#define L3GD20_HPM_REF_SIGNAL ((uint8_t)0x10)
#define L3GD20_HPM_NORMAL_MODE ((uint8_t)0x20)
#define L3GD20_HPM_AUTORESET_INT ((uint8_t)0x30)
/**
* @}
*/
/** @defgroup High_Pass_CUT OFF_Frequency
* @{
*/
#define L3GD20_HPFCF_0 0x00
#define L3GD20_HPFCF_1 0x01
#define L3GD20_HPFCF_2 0x02
#define L3GD20_HPFCF_3 0x03
#define L3GD20_HPFCF_4 0x04
#define L3GD20_HPFCF_5 0x05
#define L3GD20_HPFCF_6 0x06
#define L3GD20_HPFCF_7 0x07
#define L3GD20_HPFCF_8 0x08
#define L3GD20_HPFCF_9 0x09
/**
* @}
*/
/**
* @}
*/
/** @defgroup L3GD20_Exported_Functions
* @{
*/
/* Sensor Configuration Functions */
void L3GD20_Init(uint16_t InitStruct);
void L3GD20_DeInit(void);
void L3GD20_LowPower(uint16_t InitStruct);
uint8_t L3GD20_ReadID(void);
void L3GD20_RebootCmd(void);
/* Interrupt Configuration Functions */
void L3GD20_INT1InterruptConfig(uint16_t Int1Config);
void L3GD20_EnableIT(uint8_t IntSel);
void L3GD20_DisableIT(uint8_t IntSel);
/* High Pass Filter Configuration Functions */
void L3GD20_FilterConfig(uint8_t FilterStruct);
void L3GD20_FilterCmd(uint8_t HighPassFilterState);
void L3GD20_ReadXYZAngRate(float *pfData);
uint8_t L3GD20_GetDataStatus(void);
/* Gyroscope IO functions */
void GYRO_IO_Init(void);
void GYRO_IO_DeInit(void);
void GYRO_IO_Write(uint8_t *pBuffer, uint8_t WriteAddr, uint16_t NumByteToWrite);
void GYRO_IO_Read(uint8_t *pBuffer, uint8_t ReadAddr, uint16_t NumByteToRead);
/* Gyroscope driver structure */
extern GYRO_DrvTypeDef L3gd20Drv;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __L3GD20_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for LIS3MDL Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-lis3mdl-component-drivers"><small>Release Notes for</small> <mark>LIS3MDL Component Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the LIS3MDL component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 07-August-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release of LIS3MDL Magnetometer sensor</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,202 @@
/**
******************************************************************************
* @file lis3mdl.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the LIS3MDL
* magnetometer devices
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "lis3mdl.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup LIS3MDL LIS3MDL
* @{
*/
/** @defgroup LIS3MDL_Mag_Private_Variables LIS3MDL Mag Private Variables
* @{
*/
MAGNETO_DrvTypeDef Lis3mdlMagDrv =
{
LIS3MDL_MagInit,
LIS3MDL_MagDeInit,
LIS3MDL_MagReadID,
0,
LIS3MDL_MagLowPower,
0,
0,
0,
0,
0,
0,
0,
LIS3MDL_MagReadXYZ
};
/**
* @}
*/
/** @defgroup LIS3MDL_Mag_Private_Functions LIS3MDL Mag Private Functions
* @{
*/
/**
* @brief Set LIS3MDL Magnetometer Initialization.
* @param LIS3MDL_InitStruct: pointer to a LIS3MDL_MagInitTypeDef structure
* that contains the configuration setting for the LIS3MDL.
*/
void LIS3MDL_MagInit(MAGNETO_InitTypeDef LIS3MDL_InitStruct)
{
SENSOR_IO_Write(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_CTRL_REG1, LIS3MDL_InitStruct.Register1);
SENSOR_IO_Write(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_CTRL_REG2, LIS3MDL_InitStruct.Register2);
SENSOR_IO_Write(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_CTRL_REG3, LIS3MDL_InitStruct.Register3);
SENSOR_IO_Write(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_CTRL_REG4, LIS3MDL_InitStruct.Register4);
SENSOR_IO_Write(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_CTRL_REG5, LIS3MDL_InitStruct.Register5);
}
/**
* @brief LIS3MDL Magnetometer De-initialization.
*/
void LIS3MDL_MagDeInit(void)
{
uint8_t ctrl = 0x00;
/* Read control register 1 value */
ctrl = SENSOR_IO_Read(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_CTRL_REG3);
/* Clear Selection Mode bits */
ctrl &= ~(LIS3MDL_MAG_SELECTION_MODE);
/* Set Power down */
ctrl |= LIS3MDL_MAG_POWERDOWN2_MODE;
/* write back control register */
SENSOR_IO_Write(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_CTRL_REG3, ctrl);
}
/**
* @brief Read LIS3MDL ID.
* @retval ID
*/
uint8_t LIS3MDL_MagReadID(void)
{
/* IO interface initialization */
SENSOR_IO_Init();
/* Read value at Who am I register address */
return (SENSOR_IO_Read(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_WHO_AM_I_REG));
}
/**
* @brief Set/Unset Magnetometer in low power mode.
* @param status 0 means disable Low Power Mode, otherwise Low Power Mode is enabled
*/
void LIS3MDL_MagLowPower(uint16_t status)
{
uint8_t ctrl = 0;
/* Read control register 1 value */
ctrl = SENSOR_IO_Read(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_CTRL_REG3);
/* Clear Low Power Mode bit */
ctrl &= ~(0x20);
/* Set Low Power Mode */
if(status)
{
ctrl |= LIS3MDL_MAG_CONFIG_LOWPOWER_MODE;
}else
{
ctrl |= LIS3MDL_MAG_CONFIG_NORMAL_MODE;
}
/* write back control register */
SENSOR_IO_Write(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_CTRL_REG3, ctrl);
}
/**
* @brief Read X, Y & Z Magnetometer values
* @param pData: Data out pointer
*/
void LIS3MDL_MagReadXYZ(int16_t* pData)
{
int16_t pnRawData[3];
uint8_t ctrlm= 0;
uint8_t buffer[6];
uint8_t i = 0;
float sensitivity = 0;
/* Read the magnetometer control register content */
ctrlm = SENSOR_IO_Read(LIS3MDL_MAG_I2C_ADDRESS_HIGH, LIS3MDL_MAG_CTRL_REG2);
/* Read output register X, Y & Z acceleration */
SENSOR_IO_ReadMultiple(LIS3MDL_MAG_I2C_ADDRESS_HIGH, (LIS3MDL_MAG_OUTX_L | 0x80), buffer, 6);
for(i=0; i<3; i++)
{
pnRawData[i]=((((uint16_t)buffer[2*i+1]) << 8) + (uint16_t)buffer[2*i]);
}
/* Normal mode */
/* Switch the sensitivity value set in the CRTL_REG2 */
switch(ctrlm & 0x60)
{
case LIS3MDL_MAG_FS_4_GA:
sensitivity = LIS3MDL_MAG_SENSITIVITY_FOR_FS_4GA;
break;
case LIS3MDL_MAG_FS_8_GA:
sensitivity = LIS3MDL_MAG_SENSITIVITY_FOR_FS_8GA;
break;
case LIS3MDL_MAG_FS_12_GA:
sensitivity = LIS3MDL_MAG_SENSITIVITY_FOR_FS_12GA;
break;
case LIS3MDL_MAG_FS_16_GA:
sensitivity = LIS3MDL_MAG_SENSITIVITY_FOR_FS_16GA;
break;
}
/* Obtain the mGauss value for the three axis */
for(i=0; i<3; i++)
{
pData[i]=( int16_t )(pnRawData[i] * sensitivity);
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,214 @@
/**
******************************************************************************
* @file lis3mdl.h
* @author MCD Application Team
* @brief LIS3MDL header driver file
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __LIS3MDL__H
#define __LIS3MDL__H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/magneto.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @addtogroup LIS3MDL
* @{
*/
/** @defgroup LIS3MDL_Exported_Constants LIS3MDL Exported Constants
* @{
*/
/************** I2C Address *****************/
#define LIS3MDL_MAG_I2C_ADDRESS_LOW ((uint8_t)0x38) // SAD[0] = 0
#define LIS3MDL_MAG_I2C_ADDRESS_HIGH ((uint8_t)0x3C) // SAD[0] = 1
/************** Who am I *******************/
#define I_AM_LIS3MDL ((uint8_t)0x3D)
/************** Device Register *******************/
#define LIS3MDL_MAG_WHO_AM_I_REG 0x0F
#define LIS3MDL_MAG_CTRL_REG1 0x20
#define LIS3MDL_MAG_CTRL_REG2 0x21
#define LIS3MDL_MAG_CTRL_REG3 0x22
#define LIS3MDL_MAG_CTRL_REG4 0x23
#define LIS3MDL_MAG_CTRL_REG5 0x24
#define LIS3MDL_MAG_STATUS_REG 0x27
#define LIS3MDL_MAG_OUTX_L 0x28
#define LIS3MDL_MAG_OUTX_H 0x29
#define LIS3MDL_MAG_OUTY_L 0x2A
#define LIS3MDL_MAG_OUTY_H 0x2B
#define LIS3MDL_MAG_OUTZ_L 0x2C
#define LIS3MDL_MAG_OUTZ_H 0x2D
#define LIS3MDL_MAG_TEMP_OUT_L 0x2E
#define LIS3MDL_MAG_TEMP_OUT_H 0x2F
#define LIS3MDL_MAG_INT_CFG 0x30
#define LIS3MDL_MAG_INT_SRC 0x31
#define LIS3MDL_MAG_INT_THS_L 0x32
#define LIS3MDL_MAG_INT_THS_H 0x33
/* Mag Temperature Sensor Control*/
#define LIS3MDL_MAG_TEMPSENSOR_ENABLE ((uint8_t) 0x80) /*!< Temp sensor Enable */
#define LIS3MDL_MAG_TEMPSENSOR_DISABLE ((uint8_t) 0x00) /*!< Temp sensor Disable */
/* Mag_XY-axis Operating Mode */
#define LIS3MDL_MAG_OM_XY_LOWPOWER ((uint8_t) 0x00)
#define LIS3MDL_MAG_OM_XY_MEDIUM ((uint8_t) 0x20)
#define LIS3MDL_MAG_OM_XY_HIGH ((uint8_t) 0x40)
#define LIS3MDL_MAG_OM_XY_ULTRAHIGH ((uint8_t) 0x60)
/* Mag Data Rate */
#define LIS3MDL_MAG_ODR_0_625_HZ ((uint8_t) 0x00) /*!< Output Data Rate = 0.625 Hz */
#define LIS3MDL_MAG_ODR_1_25_HZ ((uint8_t) 0x04) /*!< Output Data Rate = 1.25 Hz */
#define LIS3MDL_MAG_ODR_2_5_HZ ((uint8_t) 0x08) /*!< Output Data Rate = 2.5 Hz */
#define LIS3MDL_MAG_ODR_5_0_HZ ((uint8_t) 0x0C) /*!< Output Data Rate = 5.0 Hz */
#define LIS3MDL_MAG_ODR_10_HZ ((uint8_t) 0x10) /*!< Output Data Rate = 10 Hz */
#define LIS3MDL_MAG_ODR_20_HZ ((uint8_t) 0x14) /*!< Output Data Rate = 20 Hz */
#define LIS3MDL_MAG_ODR_40_HZ ((uint8_t) 0x18) /*!< Output Data Rate = 40 Hz */
#define LIS3MDL_MAG_ODR_80_HZ ((uint8_t) 0x1C) /*!< Output Data Rate = 80 Hz */
/* Mag Data Rate */
#define LMS303C_MAG_SELFTEST_DISABLE ((uint8_t 0x00)
#define LMS303C_MAG_SELFTEST_ENABLE ((uint8_t 0x01)
/* Mag Full Scale */
#define LIS3MDL_MAG_FS_DEFAULT ((uint8_t) 0x00)
#define LIS3MDL_MAG_FS_4_GA ((uint8_t) 0x00)
#define LIS3MDL_MAG_FS_8_GA ((uint8_t) 0x20)
#define LIS3MDL_MAG_FS_12_GA ((uint8_t) 0x40)
#define LIS3MDL_MAG_FS_16_GA ((uint8_t) 0x60) /*!< Full scale = <20>16 Gauss */
/* Mag_Reboot */
#define LIS3MDL_MAG_REBOOT_DEFAULT ((uint8_t) 0x00)
#define LIS3MDL_MAG_REBOOT_ENABLE ((uint8_t) 0x08)
/* Mag Soft reset */
#define LIS3MDL_MAG_SOFT_RESET_DEFAULT ((uint8_t) 0x00)
#define LIS3MDL_MAG_SOFT_RESET_ENABLE ((uint8_t) 0x04)
/* Mag_Communication_Mode */
#define LIS3MDL_MAG_SIM_4_WIRE ((uint8_t) 0x00)
#define LIS3MDL_MAG_SIM_3_WIRE ((uint8_t) 0x04)
/* Mag Lowpower mode config */
#define LIS3MDL_MAG_CONFIG_NORMAL_MODE ((uint8_t) 0x00)
#define LIS3MDL_MAG_CONFIG_LOWPOWER_MODE ((uint8_t) 0x20)
/* Mag Operation Mode */
#define LIS3MDL_MAG_SELECTION_MODE ((uint8_t) 0x03) /* CTRL_REG3 */
#define LIS3MDL_MAG_CONTINUOUS_MODE ((uint8_t) 0x00)
#define LIS3MDL_MAG_SINGLE_MODE ((uint8_t) 0x01)
#define LIS3MDL_MAG_POWERDOWN1_MODE ((uint8_t) 0x02)
#define LIS3MDL_MAG_POWERDOWN2_MODE ((uint8_t) 0x03)
/* Mag_Z-axis Operation Mode */
#define LIS3MDL_MAG_OM_Z_LOWPOWER ((uint8_t) 0x00)
#define LIS3MDL_MAG_OM_Z_MEDIUM ((uint8_t) 0x04)
#define LIS3MDL_MAG_OM_Z_HIGH ((uint8_t) 0x08)
#define LIS3MDL_MAG_OM_Z_ULTRAHIGH ((uint8_t) 0x0C)
/* Mag Big little-endian selection */
#define LIS3MDL_MAG_BLE_LSB ((uint8_t) 0x00)
#define LIS3MDL_MAG_BLE_MSB ((uint8_t) 0x02)
/* Mag_Bloc_update_magnetic_data */
#define LIS3MDL_MAG_BDU_CONTINUOUS ((uint8_t) 0x00)
#define LIS3MDL_MAG_BDU_MSBLSB ((uint8_t) 0x40)
/* Magnetometer_Sensitivity */
#define LIS3MDL_MAG_SENSITIVITY_FOR_FS_4GA ((float)0.14f) /**< Sensitivity value for 4 gauss full scale [mgauss/LSB] */
#define LIS3MDL_MAG_SENSITIVITY_FOR_FS_8GA ((float)0.29f) /**< Sensitivity value for 8 gauss full scale [mgauss/LSB] */
#define LIS3MDL_MAG_SENSITIVITY_FOR_FS_12GA ((float)0.43f) /**< Sensitivity value for 12 gauss full scale [mgauss/LSB] */
#define LIS3MDL_MAG_SENSITIVITY_FOR_FS_16GA ((float)0.58f) /**< Sensitivity value for 16 gauss full scale [mgauss/LSB] */
/**
* @}
*/
/** @defgroup LIS3MDL_Exported_Functions LIS3MDL Exported Functions
* @{
*/
void LIS3MDL_MagInit(MAGNETO_InitTypeDef LIS3MDL_InitStruct);
void LIS3MDL_MagDeInit(void);
uint8_t LIS3MDL_MagReadID(void);
void LIS3MDL_MagLowPower(uint16_t status);
void LIS3MDL_MagReadXYZ(int16_t* pData);
/**
* @}
*/
/** @defgroup LIS3MDL_Imported_Functions LIS3MDL Imported Functions
* @{
*/
/* IO functions */
extern void SENSOR_IO_Init(void);
extern void SENSOR_IO_DeInit(void);
extern void SENSOR_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
extern uint8_t SENSOR_IO_Read(uint8_t Addr, uint8_t Reg);
extern uint16_t SENSOR_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
extern void SENSOR_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
/**
* @}
*/
/** @defgroup LIS3MDL_Imported_Globals Imported Globals
* @{
*/
/* MAG driver structure */
extern MAGNETO_DrvTypeDef Lis3mdlMagDrv;
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __LIS3MDL__H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for LPS22HB Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-lps22hb-component-drivers"><small>Release Notes for</small> <mark>LPS22HB Component Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the LPS22HB component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 14-February-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release of LPS22HB Temperature/Pressure sensor</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,228 @@
/**
******************************************************************************
* @file lps22hb.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the LPS22HB
* pressure and temperature devices
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "lps22hb.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup LPS22HB LPS22HB
* @{
*/
/** @defgroup LPS22HB_Private_FunctionsPrototypes LPS22HB Private Functions Prototypes
* @{
*/
static void LPS22HB_Init(uint16_t DeviceAddr);
/**
* @}
*/
/** @defgroup LPS22HB_Private_Variables LPS22HB Private Variables
* @{
*/
/* Pressure Private Variables */
PSENSOR_DrvTypeDef LPS22HB_P_Drv =
{
LPS22HB_P_Init,
LPS22HB_P_ReadID,
LPS22HB_P_ReadPressure
};
/* Temperature Private Variables */
TSENSOR_DrvTypeDef LPS22HB_T_Drv =
{
LPS22HB_T_Init,
0,
0,
LPS22HB_T_ReadTemp
};
/**
* @}
*/
/** @defgroup LPS22HB_Pressure_Private_Functions LPS22HB Pressure Private Functions
* @{
*/
/**
* @brief Set LPS22HB pressure sensor Initialization.
*/
void LPS22HB_P_Init(uint16_t DeviceAddr)
{
LPS22HB_Init(DeviceAddr);
}
/**
* @brief Read LPS22HB ID.
* @retval ID
*/
uint8_t LPS22HB_P_ReadID(uint16_t DeviceAddr)
{
uint8_t ctrl = 0x00;
/* IO interface initialization */
SENSOR_IO_Init();
/* Read value at Who am I register address */
ctrl = SENSOR_IO_Read(DeviceAddr, LPS22HB_WHO_AM_I_REG);
return ctrl;
}
/**
* @brief Read pressure value of LPS22HB
* @retval pressure value
*/
float LPS22HB_P_ReadPressure(uint16_t DeviceAddr)
{
int32_t raw_press;
uint8_t buffer[3];
uint32_t tmp = 0;
uint8_t i;
for(i = 0; i < 3; i++)
{
buffer[i] = SENSOR_IO_Read(DeviceAddr, (LPS22HB_PRESS_OUT_XL_REG + i));
}
/* Build the raw data */
for(i = 0; i < 3; i++)
tmp |= (((uint32_t)buffer[i]) << (8 * i));
/* convert the 2's complement 24 bit to 2's complement 32 bit */
if(tmp & 0x00800000)
tmp |= 0xFF000000;
raw_press = ((int32_t)tmp);
raw_press = (raw_press * 100) / 4096;
return (float)((float)raw_press / 100.0f);
}
/**
* @}
*/
/** @defgroup LPS22HB_Temperature_Private_Functions LPS22HB Temperature Private Functions
* @{
*/
/**
* @brief Set LPS22HB temperature sensor Initialization.
* @param DeviceAddr: I2C device address
* @param InitStruct: pointer to a TSENSOR_InitTypeDef structure
* that contains the configuration setting for the HTS221.
* @retval None
*/
void LPS22HB_T_Init(uint16_t DeviceAddr, TSENSOR_InitTypeDef *pInitStruct)
{
LPS22HB_Init(DeviceAddr);
}
/**
* @brief Read temperature value of LPS22HB
* @param DeviceAddr: I2C device address
* @retval temperature value
*/
float LPS22HB_T_ReadTemp(uint16_t DeviceAddr)
{
int16_t raw_data;
uint8_t buffer[2];
uint16_t tmp;
uint8_t i;
for(i = 0; i < 2; i++)
{
buffer[i] = SENSOR_IO_Read(DeviceAddr, (LPS22HB_TEMP_OUT_L_REG + i));
}
/* Build the raw tmp */
tmp = (((uint16_t)buffer[1]) << 8) + (uint16_t)buffer[0];
raw_data = (tmp * 10) / 100;
return ((float)(raw_data / 10.0f));
}
/**
* @}
*/
/** @addtogroup LPS22HB_Private_Functions LPS22HB Private functions
* @{
*/
/**
* @brief Set LPS22HB Initialization.
* @param DeviceAddr: I2C device address
* @retval None
*/
static void LPS22HB_Init(uint16_t DeviceAddr)
{
uint8_t tmp;
/* Set Power mode */
tmp = SENSOR_IO_Read(DeviceAddr, LPS22HB_RES_CONF_REG);
tmp &= ~LPS22HB_LCEN_MASK;
tmp |= (uint8_t)0x01; /* Set low current mode */
SENSOR_IO_Write(DeviceAddr, LPS22HB_RES_CONF_REG, tmp);
/* Read CTRL_REG1 */
tmp = SENSOR_IO_Read(DeviceAddr, LPS22HB_CTRL_REG1);
/* Set default ODR */
tmp &= ~LPS22HB_ODR_MASK;
tmp |= (uint8_t)0x30; /* Set ODR to 25Hz */
/* Enable BDU */
tmp &= ~LPS22HB_BDU_MASK;
tmp |= ((uint8_t)0x02);
/* Apply settings to CTRL_REG1 */
SENSOR_IO_Write(DeviceAddr, LPS22HB_CTRL_REG1, tmp);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,516 @@
/**
******************************************************************************
* @file lps22hb.h
* @author MCD Application Team
* @brief LPS22HB header driver file
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __LPS22HB__H
#define __LPS22HB__H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/psensor.h"
#include "../Common/tsensor.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @addtogroup LPS22HB
* @{
*/
/** @defgroup LPS22HB_Exported_Macros LPS22HB Exported Macros
* @{
*/
/**
* @brief Bitfield positioning.
*/
#define LPS22HB_BIT(x) ((uint8_t)x)
/**
* @}
*/
/** @defgroup LPS22HB_Exported_Constants LPS22HB Exported Constants
* @{
*/
/**
* @brief Device Identification register.
* Read
* Default value: 0xB1
* 7:0 This read-only register contains the device identifier that, for LPS22HB, is set to B1h.
*/
#define LPS22HB_WHO_AM_I_REG (uint8_t)0x0F
/**
* @brief Device Identification value.
*/
#define LPS22HB_WHO_AM_I_VAL (uint8_t)0xB1
/**
* @brief Reference Pressure Register(LSB data)
* Read/write
* Default value: 0x00
* 7:0 REFL7-0: Lower part of the reference pressure value that
* is sum to the sensor output pressure.
*/
#define LPS22HB_REF_P_XL_REG (uint8_t)0x15
/**
* @brief Reference Pressure Register (Middle data)
* Read/write
* Default value: 0x00
* 7:0 REFL15-8: Middle part of the reference pressure value that
* is sum to the sensor output pressure.
*/
#define LPS22HB_REF_P_L_REG (uint8_t)0x16
/**
* @brief Reference Pressure Register (MSB data)
* Read/write
* Default value: 0x00
* 7:0 REFL23-16 Higest part of the reference pressure value that
* is sum to the sensor output pressure.
*/
#define LPS22HB_REF_P_H_REG (uint8_t)0x17
/**
* @brief Pressure and temperature resolution mode Register
* Read/write
* Default value: 0x05
* 7:2 These bits must be set to 0 for proper operation of the device
* 1: Reserved
* 0 LC_EN: Low Current Mode Enable. Default 0
*/
#define LPS22HB_RES_CONF_REG (uint8_t)0x1A
#define LPS22HB_LCEN_MASK (uint8_t)0x01
/**
* @brief Control Register 1
* Read/write
* Default value: 0x00
* 7: This bit must be set to 0 for proper operation of the device
* 6:4 ODR2, ODR1, ODR0: output data rate selection.Default 000
* ODR2 | ODR1 | ODR0 | Pressure output data-rate(Hz) | Pressure output data-rate(Hz)
* ----------------------------------------------------------------------------------
* 0 | 0 | 0 | one shot | one shot
* 0 | 0 | 1 | 1 | 1
* 0 | 1 | 0 | 10 | 10
* 0 | 1 | 1 | 25 | 25
* 1 | 0 | 0 | 50 | 50
* 1 | 0 | 1 | 75 | 75
* 1 | 1 | 0 | Reserved | Reserved
* 1 | 1 | 1 | Reserved | Reserved
*
* 3 EN_LPFP: Enable Low Pass filter on Pressure data. Default value:0
* 2:LPF_CFG Low-pass configuration register. (0: Filter cutoff is ODR/9; 1: filter cutoff is ODR/20)
* 1 BDU: block data update. 0 - continuous update; 1 - output registers not updated until MSB and LSB reading.
* 0 SIM: SPI Serial Interface Mode selection. 0 - SPI 4-wire; 1 - SPI 3-wire
*/
#define LPS22HB_CTRL_REG1 (uint8_t)0x10
#define LPS22HB_ODR_MASK (uint8_t)0x70
#define LPS22HB_LPFP_MASK (uint8_t)0x08
#define LPS22HB_LPFP_CUTOFF_MASK (uint8_t)0x04
#define LPS22HB_BDU_MASK (uint8_t)0x02
#define LPS22HB_SIM_MASK (uint8_t)0x01
#define LPS22HB_LPFP_BIT LPS22HB_BIT(3)
/**
* @brief Control Register 2
* Read/write
* Default value: 0x10
* 7 BOOT: Reboot memory content. 0: normal mode; 1: reboot memory content. Self-clearing upon completation
* 6 FIFO_EN: FIFO Enable. 0: disable; 1: enable
* 5 STOP_ON_FTH: Stop on FIFO Threshold FIFO Watermark level use. 0: disable; 1: enable
* 4 IF_ADD_INC: Register address automatically incrementeed during a multiple byte access with a serial interface (I2C or SPI).
* Default value 1.( 0: disable; 1: enable)
* 3 I2C DIS: Disable I2C interface 0: I2C Enabled; 1: I2C disabled
* 2 SWRESET: Software reset. 0: normal mode; 1: SW reset. Self-clearing upon completation
* 1 AUTO_ZERO: Autozero enable. 0: normal mode; 1: autozero enable.
* 0 ONE_SHOT: One shot enable. 0: waiting for start of conversion; 1: start for a new dataset
*/
#define LPS22HB_CTRL_REG2 (uint8_t)0x11
#define LPS22HB_BOOT_BIT LPS22HB_BIT(7)
#define LPS22HB_FIFO_EN_BIT LPS22HB_BIT(6)
#define LPS22HB_WTM_EN_BIT LPS22HB_BIT(5)
#define LPS22HB_ADD_INC_BIT LPS22HB_BIT(4)
#define LPS22HB_I2C_BIT LPS22HB_BIT(3)
#define LPS22HB_SW_RESET_BIT LPS22HB_BIT(2)
#define LPS22HB_FIFO_EN_MASK (uint8_t)0x40
#define LPS22HB_WTM_EN_MASK (uint8_t)0x20
#define LPS22HB_ADD_INC_MASK (uint8_t)0x10
#define LPS22HB_I2C_MASK (uint8_t)0x08
#define LPS22HB_ONE_SHOT_MASK (uint8_t)0x01
/**
* @brief CTRL Reg3 Interrupt Control Register
* Read/write
* Default value: 0x00
* 7 INT_H_L: Interrupt active high, low. 0:active high; 1: active low.
* 6 PP_OD: Push-Pull/OpenDrain selection on interrupt pads. 0: Push-pull; 1: open drain.
* 5 F_FSS5: FIFO full flag on INT_DRDY pin. Defaul value: 0. (0: Diasable; 1 : Enable).
* 4 F_FTH: FIFO threshold (watermark) status on INT_DRDY pin. Defaul value: 0. (0: Diasable; 1 : Enable).
* 3 F_OVR: FIFO overrun interrupt on INT_DRDY pin. Defaul value: 0. (0: Diasable; 1 : Enable).
* 2 DRDY: Data-ready signal on INT_DRDY pin. Defaul value: 0. (0: Diasable; 1 : Enable).
* 1:0 INT_S2, INT_S1: data signal on INT pad control bits.
* INT_S2 | INT_S1 | INT pin
* ------------------------------------------------------
* 0 | 0 | Data signal( in order of priority:PTH_DRDY or F_FTH or F_OVR_or F_FSS5
* 0 | 1 | Pressure high (P_high)
* 1 | 0 | Pressure low (P_low)
* 1 | 1 | P_low OR P_high
*/
#define LPS22HB_CTRL_REG3 (uint8_t)0x12
#define LPS22HB_PP_OD_BIT LPS22HB_BIT(6)
#define LPS22HB_FIFO_FULL_BIT LPS22HB_BIT(5)
#define LPS22HB_FIFO_FTH_BIT LPS22HB_BIT(4)
#define LPS22HB_FIFO_OVR_BIT LPS22HB_BIT(3)
#define LPS22HB_DRDY_BIT LPS22HB_BIT(2)
#define LPS22HB_INT_H_L_MASK (uint8_t)0x80
#define LPS22HB_PP_OD_MASK (uint8_t)0x40
#define LPS22HB_FIFO_FULL_MASK (uint8_t)0x20
#define LPS22HB_FIFO_FTH_MASK (uint8_t)0x10
#define LPS22HB_FIFO_OVR_MASK (uint8_t)0x08
#define LPS22HB_DRDY_MASK (uint8_t)0x04
#define LPS22HB_INT_S12_MASK (uint8_t)0x03
/**
* @brief Interrupt Differential configuration Register
* Read/write
* Default value: 0x00.
* 7 AUTORIFP: AutoRifP Enable
* 6 RESET_ARP: Reset AutoRifP function
* 4 AUTOZERO: Autozero enabled
* 5 RESET_AZ: Reset Autozero Function
* 3 DIFF_EN: Interrupt generation enable
* 2 LIR: Latch Interrupt request into INT_SOURCE register. 0 - interrupt request not latched
* 1 - interrupt request latched
* 1 PL_E: Enable interrupt generation on differential pressure low event. 0 - disable; 1 - enable
* 0 PH_E: Enable interrupt generation on differential pressure high event. 0 - disable; 1 - enable
*/
#define LPS22HB_INTERRUPT_CFG_REG (uint8_t)0x0B
#define LPS22HB_DIFF_EN_BIT LPS22HB_BIT(3)
#define LPS22HB_LIR_BIT LPS22HB_BIT(2)
#define LPS22HB_PLE_BIT LPS22HB_BIT(1)
#define LPS22HB_PHE_BIT LPS22HB_BIT(0)
#define LPS22HB_AUTORIFP_MASK (uint8_t)0x80
#define LPS22HB_RESET_ARP_MASK (uint8_t)0x40
#define LPS22HB_AUTOZERO_MASK (uint8_t)0x20
#define LPS22HB_RESET_AZ_MASK (uint8_t)0x10
#define LPS22HB_DIFF_EN_MASK (uint8_t)0x08
#define LPS22HB_LIR_MASK (uint8_t)0x04
#define LPS22HB_PLE_MASK (uint8_t)0x02
#define LPS22HB_PHE_MASK (uint8_t)0x01
/**
* @brief Interrupt source Register (It is cleared by reading it)
* Read
* 7 BOOT_STATUS: If 1 indicates that the Boot (Reboot) phase is running.
* 6:3 Reserved: Keep these bits at 0
* 2 IA: Interrupt Active.0: no interrupt has been generated
* 1: one or more interrupt events have been generated.
* 1 PL: Differential pressure Low. 0: no interrupt has been generated
* 1: Low differential pressure event has occurred.
* 0 PH: Differential pressure High. 0: no interrupt has been generated
* 1: High differential pressure event has occurred.
*/
#define LPS22HB_INTERRUPT_SOURCE_REG (uint8_t)0x25
#define LPS22HB_BOOT_STATUS_BIT LPS22HB_BIT(7)
#define LPS22HB_IA_BIT LPS22HB_BIT(2)
#define LPS22HB_PL_BIT LPS22HB_BIT(1)
#define LPS22HB_PH_BIT LPS22HB_BIT(0)
#define LPS22HB_BOOT_STATUS_MASK (uint8_t)0x80
#define LPS22HB_IA_MASK (uint8_t)0x04
#define LPS22HB_PL_MASK (uint8_t)0x02
#define LPS22HB_PH_MASK (uint8_t)0x01
/**
* @brief Status Register
* Read
* 7:6 Reserved: 0
* 5 T_OR: Temperature data overrun. 0: no overrun has occurred
* 1: a new data for temperature has overwritten the previous one.
* 4 P_OR: Pressure data overrun. 0: no overrun has occurred
* 1: new data for pressure has overwritten the previous one.
* 3:2 Reserved: 0
* 1 T_DA: Temperature data available. 0: new data for temperature is not yet available
* 1: new data for temperature is available.
* 0 P_DA: Pressure data available. 0: new data for pressure is not yet available
* 1: new data for pressure is available.
*/
#define LPS22HB_STATUS_REG (uint8_t)0x27
#define LPS22HB_TOR_BIT LPS22HB_BIT(5)
#define LPS22HB_POR_BIT LPS22HB_BIT(4)
#define LPS22HB_TDA_BIT LPS22HB_BIT(1)
#define LPS22HB_PDA_BIT LPS22HB_BIT(0)
#define LPS22HB_TOR_MASK (uint8_t)0x20
#define LPS22HB_POR_MASK (uint8_t)0x10
#define LPS22HB_TDA_MASK (uint8_t)0x02
#define LPS22HB_PDA_MASK (uint8_t)0x01
/**
* @brief Pressure data (LSB) register.
* Read
* Default value: 0x00.(To be verified)
* POUT7 - POUT0: Pressure data LSB (2's complement).
* Pressure output data: Pout(hPA)=(PRESS_OUT_H & PRESS_OUT_L &
* PRESS_OUT_XL)[dec]/4096.
*/
#define LPS22HB_PRESS_OUT_XL_REG (uint8_t)0x28
/**
* @brief Pressure data (Middle part) register.
* Read
* Default value: 0x80.
* POUT15 - POUT8: Pressure data middle part (2's complement).
* Pressure output data: Pout(hPA)=(PRESS_OUT_H & PRESS_OUT_L &
* PRESS_OUT_XL)[dec]/4096.
*/
#define LPS22HB_PRESS_OUT_L_REG (uint8_t)0x29
/**
* @brief Pressure data (MSB) register.
* Read
* Default value: 0x2F.
* POUT23 - POUT16: Pressure data MSB (2's complement).
* Pressure output data: Pout(hPA)=(PRESS_OUT_H & PRESS_OUT_L &
* PRESS_OUT_XL)[dec]/4096.
*/
#define LPS22HB_PRESS_OUT_H_REG (uint8_t)0x2A
/**
* @brief Temperature data (LSB) register.
* Read
* Default value: 0x00.
* TOUT7 - TOUT0: temperature data LSB.
* Tout(degC)=TEMP_OUT/100
*/
#define LPS22HB_TEMP_OUT_L_REG (uint8_t)0x2B
/**
* @brief Temperature data (MSB) register.
* Read
* Default value: 0x00.
* TOUT15 - TOUT8: temperature data MSB.
* Tout(degC)=TEMP_OUT/100
*/
#define LPS22HBH_TEMP_OUT_H_REG (uint8_t)0x2C
/**
* @brief Threshold pressure (LSB) register.
* Read/write
* Default value: 0x00.
* 7:0 THS7-THS0: LSB Threshold pressure Low part of threshold value for pressure interrupt
* generation. The complete threshold value is given by THS_P_H & THS_P_L and is
* expressed as unsigned number. P_ths(hPA)=(THS_P_H & THS_P_L)[dec]/16.
*/
#define LPS22HB_THS_P_LOW_REG (uint8_t)0x0C
/**
* @brief Threshold pressure (MSB)
* Read/write
* Default value: 0x00.
* 7:0 THS15-THS8: MSB Threshold pressure. High part of threshold value for pressure interrupt
* generation. The complete threshold value is given by THS_P_H & THS_P_L and is
* expressed as unsigned number. P_ths(mbar)=(THS_P_H & THS_P_L)[dec]/16.
*/
#define LPS22HB_THS_P_HIGH_REG (uint8_t)0x0D
/**
* @brief FIFO control register
* Read/write
* Default value: 0x00
* 7:5 F_MODE2, F_MODE1, F_MODE0: FIFO mode selection.
* FM2 | FM1 | FM0 | FIFO MODE
* ---------------------------------------------------
* 0 | 0 | 0 | BYPASS MODE
* 0 | 0 | 1 | FIFO MODE. Stops collecting data when full
* 0 | 1 | 0 | STREAM MODE: Keep the newest measurements in the FIFO
* 0 | 1 | 1 | STREAM MODE until trigger deasserted, then change to FIFO MODE
* 1 | 0 | 0 | BYPASS MODE until trigger deasserted, then STREAM MODE
* 1 | 0 | 1 | Reserved for future use
* 1 | 1 | 0 | Reserved
* 1 | 1 | 1 | BYPASS mode until trigger deasserted, then FIFO MODE
*
* 4:0 WTM_POINT4-0 : FIFO Watermark level selection (0-31)
*/
#define LPS22HB_CTRL_FIFO_REG (uint8_t)0x14
#define LPS22HB_FIFO_MODE_MASK (uint8_t)0xE0
#define LPS22HB_WTM_POINT_MASK (uint8_t)0x1F
/**
* @brief FIFO Status register
* Read
* 7 FTH_FIFO: FIFO threshold status. 0:FIFO filling is lower than FTH level
* 1: FIFO is equal or higher than FTH level.
* 6 OVR: Overrun bit status. 0 - FIFO not full
* 1 - FIFO is full and at least one sample in the FIFO has been overwritten.
* 5:0 FSS: FIFO Stored data level. 000000: FIFO empty, 100000: FIFO is full and has 32 unread samples.
*/
#define LPS22HB_STATUS_FIFO_REG (uint8_t)0x26
#define LPS22HB_FTH_FIFO_BIT LPS22HB_BIT(7)
#define LPS22HB_OVR_FIFO_BIT LPS22HB_BIT(6)
#define LPS22HB_FTH_FIFO_MASK (uint8_t)0x80
#define LPS22HB_OVR_FIFO_MASK (uint8_t)0x40
#define LPS22HB_LEVEL_FIFO_MASK (uint8_t)0x3F
#define LPS22HB_FIFO_EMPTY (uint8_t)0x00
#define LPS22HB_FIFO_FULL (uint8_t)0x20
/**
* @brief Pressure offset register (LSB)
* Read/write
* Default value: 0x00
* 7:0 RPDS7-0:Pressure Offset for 1 point calibration (OPC) after soldering.
* This register contains the low part of the pressure offset value after soldering,for
* differential pressure computing. The complete value is given by RPDS_L & RPDS_H
* and is expressed as signed 2 complement value.
*/
#define LPS22HB_RPDS_L_REG (uint8_t)0x18
/**
* @brief Pressure offset register (MSB)
* Read/write
* Default value: 0x00
* 7:0 RPDS15-8:Pressure Offset for 1 point calibration (OPC) after soldering.
* This register contains the high part of the pressure offset value after soldering (see description RPDS_L)
*/
#define LPS22HB_RPDS_H_REG (uint8_t)0x19
/**
* @brief Clock Tree Configuration register
* Read/write
* Default value: 0x00
* 7:6 Reserved.
* 5: CTE: Clock Tree Enhancement
*/
#define LPS22HB_CLOCK_TREE_CONFIGURATION (uint8_t)0x43
#define LPS22HB_CTE_MASK (uint8_t)0x20
/**
* @}
*/
/** @defgroup LPS22HB_Pressure_Exported_Functions LPS22HB Pressure Exported Functions
* @{
*/
/* PRESSURE functions */
void LPS22HB_P_Init(uint16_t DeviceAddr);
uint8_t LPS22HB_P_ReadID(uint16_t DeviceAddr);
float LPS22HB_P_ReadPressure(uint16_t DeviceAddr);
/**
* @}
*/
/** @defgroup HTS221_PressImported_Globals PRESSURE Imported Globals
* @{
*/
/* PRESSURE driver structure */
extern PSENSOR_DrvTypeDef LPS22HB_P_Drv;
/**
* @}
*/
/** @defgroup LPS22HB_Temperature_Exported_Functions LPS22HB Temperature Exported Functions
* @{
*/
/* TEMPERATURE functions */
void LPS22HB_T_Init(uint16_t DeviceAddr, TSENSOR_InitTypeDef *pInitStruct);
float LPS22HB_T_ReadTemp(uint16_t DeviceAddr);
/**
* @}
*/
/** @defgroup HTS221_TempImported_Globals Temperature Imported Globals
* @{
*/
/* Temperature driver structure */
extern TSENSOR_DrvTypeDef LPS22HB_T_Drv;
/**
* @}
*/
/** @defgroup LPS22HB_Imported_Functions LPS22HB Imported Functions
* @{
*/
/* IO functions */
extern void SENSOR_IO_Init(void);
extern void SENSOR_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
extern uint8_t SENSOR_IO_Read(uint8_t Addr, uint8_t Reg);
extern uint16_t SENSOR_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
extern void SENSOR_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __LPS22HB__H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for LS016B8UY Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-ls016b8uy-component-drivers"><small>Release Notes for</small> <mark>LS016B8UY Component Drivers</mark></h1>
<p>Copyright © 2016 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the LS016B8UY component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 10-May-2016</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,643 @@
/**
******************************************************************************
* @file ls016b8uy.c
* @author MCD Application Team
* @brief This file includes the LCD driver for LS016B8UY LCD.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "ls016b8uy.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup ls016b8uy
* @brief This file provides a set of functions needed to drive the
* LS016B8UY LCD.
* @{
*/
/** @defgroup LS016B8UY_Private_TypesDefinitions
* @{
*/
typedef struct {
uint8_t red;
uint8_t green;
uint8_t blue;
} LS016B8UY_Rgb888;
/**
* @}
*/
/** @defgroup LS016B8UY_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup LS016B8UY_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup LS016B8UY_Private_Variables
* @{
*/
LCD_DrvTypeDef ls016b8uy_drv =
{
ls016b8uy_Init,
ls016b8uy_ReadID,
ls016b8uy_DisplayOn,
ls016b8uy_DisplayOff,
ls016b8uy_SetCursor,
ls016b8uy_WritePixel,
ls016b8uy_ReadPixel,
ls016b8uy_SetDisplayWindow,
ls016b8uy_DrawHLine,
ls016b8uy_DrawVLine,
ls016b8uy_GetLcdPixelWidth,
ls016b8uy_GetLcdPixelHeight,
ls016b8uy_DrawBitmap,
ls016b8uy_DrawRGBImage,
};
static uint16_t WindowsXstart = 0;
static uint16_t WindowsYstart = 0;
static uint16_t WindowsXend = LS016B8UY_LCD_PIXEL_WIDTH-1;
static uint16_t WindowsYend = LS016B8UY_LCD_PIXEL_HEIGHT-1;
/**
* @}
*/
/** @defgroup LS016B8UY_Private_FunctionPrototypes
* @{
*/
static LS016B8UY_Rgb888 ls016b8uy_ReadPixel_rgb888(uint16_t Xpos, uint16_t Ypos);
static void ls016b8uy_DrawRGBHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint8_t *pdata);
/**
* @}
*/
/** @defgroup LS016B8UY_Private_Functions
* @{
*/
/**
* @brief Initialize the LS016B8UY LCD Component.
* @param None
* @retval None
*/
void ls016b8uy_Init(void)
{
uint8_t parameter[4];
/* Initialize LS016B8UY low level bus layer ----------------------------------*/
LCD_IO_Init();
parameter[0] = 0x00; /* VSYNC output */
ls016b8uy_WriteReg(LCD_CMD_VSYNC_OUTPUT, parameter, 1);
parameter[0] = 0x06; /* 18 bits color mode */
ls016b8uy_WriteReg(LCD_CMD_COLOR_MODE, parameter, 1);
parameter[0] = 0x01; /* Panel setting command <No.1 UN-Lock> */
parameter[1] = 0xFE;
ls016b8uy_WriteReg(LCD_CMD_PANEL_SETTING_1, parameter, 2);
parameter[0] = 0xDE; /* Panel setting command <No.2 UN-Lock> */
parameter[1] = 0x21;
ls016b8uy_WriteReg(LCD_CMD_PANEL_SETTING_2, parameter, 2);
parameter[0] = 0x05; /* V-Porch setting */
parameter[1] = 0x33;
ls016b8uy_WriteReg(LCD_CMD_PANEL_V_PORCH, parameter, 2);
parameter[0] = 0x05; /* Idle mode V-Porch setting */
parameter[1] = 0x33;
ls016b8uy_WriteReg(LCD_CMD_PANEL_IDLE_V_PORCH, parameter, 2);
parameter[0] = 0x04; /* panel timing setting */
parameter[1] = 0x03;
ls016b8uy_WriteReg(LCD_CMD_PANEL_TIMING_1, parameter, 2);
parameter[0] = 0x5E; /* panel timing setting */
parameter[1] = 0x08;
ls016b8uy_WriteReg(LCD_CMD_PANEL_TIMING_2, parameter, 2);
parameter[0] = 0x0A; /* panel timing setting */
parameter[1] = 0x0C;
parameter[2] = 0x02;
ls016b8uy_WriteReg(LCD_CMD_PANEL_TIMING_3, parameter, 3);
parameter[0] = 0x03; /* panel timing setting */
parameter[1] = 0x04;
ls016b8uy_WriteReg(LCD_CMD_PANEL_TIMING_4, parameter, 2);
parameter[0] = 0x0C; /* panel power setting */
ls016b8uy_WriteReg(LCD_CMD_PANEL_POWER, parameter, 1);
parameter[0] = 0x02; /* Oscillator Setting = 2MHz */
ls016b8uy_WriteReg(LCD_CMD_OSCILLATOR, parameter, 1);
parameter[0] = 0x53; /* GVDD = 4.76V setting */
ls016b8uy_WriteReg(LCD_CMD_GVDD, parameter, 1);
parameter[0] = 0x00; /* Reload MTP After SLPOUT */
parameter[1] = 0x45; /* VCOMH=3.76V */
ls016b8uy_WriteReg(LCD_CMD_RELOAD_MTP_VCOMH, parameter, 2);
parameter[0] = 0x03; /* OP-Amp Ability. (Normal) */
parameter[1] = 0x12; /* Step-up Cycle for AVDD Booster Freq./4 */
ls016b8uy_WriteReg(LCD_CMD_OPAMP, parameter, 2);
parameter[0] = 0x00; /* Tearing Effect Option (00h:VSYNC Interface OFF, 01h:VSYNC Interface ON) */
ls016b8uy_WriteReg(LCD_CMD_TEARING_EFFECT, parameter, 1);
ls016b8uy_WriteReg(LCD_CMD_PANEL_SETTING_LOCK, parameter, 0); /* Panel setting command <Lock> */
ls016b8uy_WriteReg(LCD_CMD_SLEEP_OUT, parameter, 0); /* Sleep Out Command */
LCD_IO_Delay(150); /* Wait for 150ms */
parameter[0] = 0x00; /* CASET */
parameter[1] = 0x1E;
parameter[2] = 0x00;
parameter[3] = 0xD1;
ls016b8uy_WriteReg(LCD_CMD_CASET, parameter, 4);
parameter[0] = 0x00; /* RASET */
parameter[1] = 0x00;
parameter[2] = 0x00;
parameter[3] = 0xB3;
ls016b8uy_WriteReg(LCD_CMD_RASET, parameter, 4);
parameter[0] = 0x83; /* Normal display for Driver Down side */
ls016b8uy_WriteReg(LCD_CMD_NORMAL_DISPLAY, parameter, 1);
ls016b8uy_DisplayOn(); /* Display ON command */
}
/**
* @brief Enables the Display.
* @param None
* @retval None
*/
void ls016b8uy_DisplayOn(void)
{
ls016b8uy_WriteReg(LCD_CMD_DISPLAY_ON, (uint8_t*)NULL, 0); /* Display ON command */
ls016b8uy_WriteReg(LCD_CMD_IDLE_MODE_OFF, (uint8_t*)NULL, 0); /* Idle mode OFF command */
}
/**
* @brief Disables the Display.
* @param None
* @retval None
*/
void ls016b8uy_DisplayOff(void)
{
ls016b8uy_WriteReg(LCD_CMD_DISPLAY_OFF, (uint8_t*)NULL, 0); /* Display OFF command */
LCD_IO_Delay(20); /* Wait for 20ms */
ls016b8uy_WriteReg(LCD_CMD_SLEEP_IN, (uint8_t*)NULL, 0); /* Sleep In Command */
LCD_IO_Delay(150); /* Wait for 150ms */
}
/**
* @brief Get the LCD pixel Width.
* @param None
* @retval The Lcd Pixel Width
*/
uint16_t ls016b8uy_GetLcdPixelWidth(void)
{
return (uint16_t)LS016B8UY_LCD_PIXEL_WIDTH;
}
/**
* @brief Get the LCD pixel Height.
* @param None
* @retval The Lcd Pixel Height
*/
uint16_t ls016b8uy_GetLcdPixelHeight(void)
{
return (uint16_t)LS016B8UY_LCD_PIXEL_HEIGHT;
}
/**
* @brief Get the LS016B8UY ID.
* @param None
* @retval The LS016B8UY ID
*/
uint16_t ls016b8uy_ReadID(void)
{
LCD_IO_Init();
/* TODO : LCD read ID command not known for now, so assumption that the connected LCD is LS016B8UY */
return (LS016B8UY_ID);
}
/**
* @brief Set Cursor position.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @retval None
*/
void ls016b8uy_SetCursor(uint16_t Xpos, uint16_t Ypos)
{
uint8_t parameter[4];
parameter[0] = 0x00; /* CASET */
parameter[1] = 0x1E + Xpos;
parameter[2] = 0x00;
parameter[3] = 0xD1 + Xpos;
ls016b8uy_WriteReg(LCD_CMD_CASET, parameter, 4);
parameter[0] = 0x00; /* RASET */
parameter[1] = 0x00 + Ypos;
parameter[2] = 0x00;
parameter[3] = 0xB3 + Ypos;
ls016b8uy_WriteReg(LCD_CMD_RASET, parameter, 4);
}
/**
* @brief Write pixel.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param RGBCode: the RGB pixel color in RGB565 format
* @retval None
*/
void ls016b8uy_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode)
{
uint16_t r, g, b;
uint16_t rgb888_part1, rgb888_part2;
r = (RGBCode & 0xF800) >> 11; /* Extract red component from RGB565 pixel data */
g = (RGBCode & 0x07E0) >> 5; /* Extract green component from RGB565 pixel data */
b = (RGBCode & 0x001F) >> 0; /* Extract blue component from RGB565 pixel data */
/* Prepare data to write with new pixel components and read old pixel component */
rgb888_part1 = (r << 11) + (g << 2);
rgb888_part2 = (b << 11);
/* Set Cursor */
ls016b8uy_SetCursor(Xpos, Ypos);
/* Prepare to write to LCD RAM */
ls016b8uy_WriteReg(LCD_CMD_WRITE_RAM, (uint8_t*)NULL, 0); /* RAM write data command */
/* Write RAM data */
LCD_IO_WriteData(rgb888_part1);
LCD_IO_WriteData(rgb888_part2);
}
/**
* @brief Read pixel.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @retval The RGB pixel color in RGB565 format
*/
uint16_t ls016b8uy_ReadPixel(uint16_t Xpos, uint16_t Ypos)
{
LS016B8UY_Rgb888 rgb888;
uint8_t r, g, b;
uint16_t rgb565;
/* Set Cursor */
ls016b8uy_SetCursor(Xpos, Ypos);
/* Read RGB888 data from LCD RAM */
rgb888 = ls016b8uy_ReadPixel_rgb888(Xpos, Ypos);
/* Convert RGB888 to RGB565 */
r = ((rgb888.red & 0xF8) >> 3); /* Extract the red component 5 most significant bits */
g = ((rgb888.green & 0xFC) >> 2); /* Extract the green component 6 most significant bits */
b = ((rgb888.blue & 0xF8) >> 3); /* Extract the blue component 5 most significant bits */
rgb565 = ((uint16_t)(r) << 11) + ((uint16_t)(g) << 5) + ((uint16_t)(b) << 0);
return (rgb565);
}
/**
* @brief Writes to the selected LCD register.
* @param Command: command value (or register address as named in LS016B8UY doc).
* @param Parameters: pointer on parameters value (if command uses one or several parameters).
* @param NbParameters: number of command parameters (0 if no parameter)
* @retval None
*/
void ls016b8uy_WriteReg(uint8_t Command, uint8_t *Parameters, uint8_t NbParameters)
{
uint8_t i;
/* Send command */
LCD_IO_WriteReg(Command);
/* Send command's parameters if any */
for (i=0; i<NbParameters; i++)
{
LCD_IO_WriteData(Parameters[i]);
}
}
/**
* @brief Reads the selected LCD Register.
* @param Command: command value (or register address as named in LS016B8UY doc).
* @retval Register Value.
*/
uint8_t ls016b8uy_ReadReg(uint8_t Command)
{
/* Send command */
LCD_IO_WriteReg(Command);
/* Read dummy data */
LCD_IO_ReadData();
/* Read register value */
return (LCD_IO_ReadData());
}
/**
* @brief Sets a display window
* @param Xpos: specifies the X bottom left position.
* @param Ypos: specifies the Y bottom left position.
* @param Height: display window height.
* @param Width: display window width.
* @retval None
*/
void ls016b8uy_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
{
if (Xpos < LS016B8UY_LCD_PIXEL_WIDTH)
{
WindowsXstart = Xpos;
}
else
{
WindowsXstart = 0;
}
if (Ypos < LS016B8UY_LCD_PIXEL_HEIGHT)
{
WindowsYstart = Ypos;
}
else
{
WindowsYstart = 0;
}
if (Width + Xpos <= LS016B8UY_LCD_PIXEL_WIDTH)
{
WindowsXend = Width + Xpos - 1;
}
else
{
WindowsXend = LS016B8UY_LCD_PIXEL_WIDTH - 1;
}
if (Height + Ypos <= LS016B8UY_LCD_PIXEL_HEIGHT)
{
WindowsYend = Height + Ypos - 1;
}
else
{
WindowsYend = LS016B8UY_LCD_PIXEL_HEIGHT-1;
}
}
/**
* @brief Draw vertical line.
* @param RGBCode: Specifies the RGB color in RGB565 format
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Length: specifies the Line length.
* @retval None
*/
void ls016b8uy_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint16_t counter = 0;
uint16_t r, g, b;
uint16_t rgb888_part1, rgb888_part2, rgb888_part3;
r = (RGBCode & 0xF800) >> 11; /* Extract red component from RGB565 pixel data */
g = (RGBCode & 0x07E0) >> 5; /* Extract green component from RGB565 pixel data */
b = (RGBCode & 0x001F) >> 0; /* Extract blue component from RGB565 pixel data */
rgb888_part1 = (r << 11) + (g << 2); /* Build pattern first part to write in LCD RAM */
rgb888_part2 = (b << 11) + (r << 3); /* Build pattern second part to write in LCD RAM */
rgb888_part3 = (g << 10) + (b << 3); /* Build pattern third part to write in LCD RAM */
/* Set Cursor */
ls016b8uy_SetCursor(Xpos, Ypos);
/* Prepare to write to LCD RAM */
ls016b8uy_WriteReg(LCD_CMD_WRITE_RAM, (uint8_t*)NULL, 0); /* RAM write data command */
/* Sent a complete line */
for(counter = 0; counter < Length; counter+=2)
{
/* Write 2 pixels at a time by performing 3 access (pixels coded on 24 bits in LCD RAM whereas access are coded on 16 bits) */
LCD_IO_WriteData(rgb888_part1);
LCD_IO_WriteData(rgb888_part2);
if (counter != (Length-1)) /* When writing last pixel when Length is odd, the third part is not written */
{
LCD_IO_WriteData(rgb888_part3);
}
}
}
/**
* @brief Draw vertical line.
* @param RGBCode: Specifies the RGB color
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Length: specifies the Line length.
* @retval None
*/
void ls016b8uy_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint16_t counter = 0;
/* Set Cursor */
ls016b8uy_SetCursor(Xpos, Ypos);
/* Prepare to write to LCD RAM */
ls016b8uy_WriteReg(LCD_CMD_WRITE_RAM, (uint8_t*)NULL, 0); /* RAM write data command */
/* Fill a complete vertical line */
for(counter = 0; counter < Length; counter++)
{
ls016b8uy_WritePixel(Xpos, Ypos + counter, RGBCode);
}
}
/**
* @brief Displays a bitmap picture.
* @param BmpAddress: Bmp picture address.
* @param Xpos: Bmp X position in the LCD
* @param Ypos: Bmp Y position in the LCD
* @retval None
*/
void ls016b8uy_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp)
{
uint32_t index = 0, size = 0;
uint32_t posY;
uint32_t nb_line = 0;
uint16_t Xsize = WindowsXend - WindowsXstart + 1;
uint16_t Ysize = WindowsYend - WindowsYstart + 1;
/* Read bitmap size */
size = *(volatile uint16_t *) (pbmp + 2);
size |= (*(volatile uint16_t *) (pbmp + 4)) << 16;
/* Get bitmap data address offset */
index = *(volatile uint16_t *) (pbmp + 10);
index |= (*(volatile uint16_t *) (pbmp + 12)) << 16;
size = (size - index)/2;
pbmp += index;
for (posY = (Ypos + Ysize); posY > Ypos; posY--) /* In BMP files the line order is inverted */
{
/* Set Cursor */
ls016b8uy_SetCursor(Xpos, posY - 1);
/* Draw one line of the picture */
ls016b8uy_DrawRGBHLine(Xpos, posY - 1, Xsize, (pbmp + (nb_line * Xsize * 2)));
nb_line++;
}
}
/**
* @brief Displays picture.
* @param pdata: picture address.
* @param Xpos: Image X position in the LCD
* @param Ypos: Image Y position in the LCD
* @param Xsize: Image X size in the LCD
* @param Ysize: Image Y size in the LCD
* @retval None
*/
void ls016b8uy_DrawRGBImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata)
{
uint32_t posY;
uint32_t nb_line = 0;
for (posY = Ypos; posY < (Ypos + Ysize); posY ++)
{
/* Set Cursor */
ls016b8uy_SetCursor(Xpos, posY);
/* Draw one line of the picture */
ls016b8uy_DrawRGBHLine(Xpos, posY, Xsize, (pdata + (nb_line * Xsize * 2)));
nb_line++;
}
}
/******************************************************************************
Static Functions
*******************************************************************************/
/**
* @brief Read pixel from LCD RAM in RGB888 format
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @retval Each RGB pixel color components in a structure
*/
static LS016B8UY_Rgb888 ls016b8uy_ReadPixel_rgb888(uint16_t Xpos, uint16_t Ypos)
{
LS016B8UY_Rgb888 rgb888;
uint16_t rgb888_part1, rgb888_part2;
/* In LCD RAM, pixels are 24 bits packed and read with 16 bits access
* Here is the pixels components arrangement in memory :
* bits: 15 14 13 12 11 10 09 08 | 07 06 05 04 03 02 01 00
* address 0 : red pixel 0 X X | green pixel 0 X X
* address 1 : blue pixel 0 X X | red pixel 1 X X
* address 2 : green pixel 1 X X | blue pixel 1 X X
*/
/* Set Cursor */
ls016b8uy_SetCursor(Xpos, Ypos);
/* Prepare to read LCD RAM */
ls016b8uy_WriteReg(LCD_CMD_READ_RAM, (uint8_t*)NULL, 0); /* RAM read data command */
/* Dummy read */
LCD_IO_ReadData();
/* Read first part of the RGB888 data */
rgb888_part1 = LCD_IO_ReadData();
/* Read first part of the RGB888 data */
rgb888_part2 = LCD_IO_ReadData();
/* red component */
rgb888.red = (rgb888_part1 & 0xFC00) >> 8;
/* green component */
rgb888.green = (rgb888_part1 & 0x00FC) >> 0;
/* blue component */
rgb888.blue = (rgb888_part2 & 0xFC00) >> 8;
return rgb888;
}
/**
* @brief Displays a single picture line.
* @param pdata: picture address.
* @param Xpos: Image X position in the LCD
* @param Ypos: Image Y position in the LCD
* @param Xsize: Image X size in the LCD
* @retval None
*/
static void ls016b8uy_DrawRGBHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint8_t *pdata)
{
uint32_t i = 0;
uint32_t posX;
uint16_t r, g, b;
uint16_t rgb888_part;
uint16_t *rgb565 = (uint16_t*)pdata;
/* Prepare to write to LCD RAM */
ls016b8uy_WriteReg(LCD_CMD_WRITE_RAM, (uint8_t*)NULL, 0); /* RAM write data command */
for (posX = Xpos; posX < (Xsize + Xpos); posX += 2)
{
if ((posX >= WindowsXstart) && (Ypos >= WindowsYstart) && /* Check we are in the defined window */
(posX <= WindowsXend) && (Ypos <= WindowsYend))
{
/* Write pixels in LCD RAM after RGB565 -> RGB888 conversion */
/* As data in LCD RAM are 24bits packed, three 16 bits writes access are needed to transmit 2 pixels data */
r = (rgb565[i] & 0xF800) >> 11; /* Extract red component from first RGB565 pixel data */
g = (rgb565[i] & 0x07E0) >> 5; /* Extract green component from first RGB565 pixel data */
rgb888_part = (r << 11) + (g << 2); /* Build data to be written in LCD RAM */
LCD_IO_WriteData(rgb888_part);
b = (rgb565[i] & 0x001F) >> 0; /* Extract blue component from first RGB565 pixel data */
r = (rgb565[i+1] & 0xF800) >> 11; /* Extract red component from second RGB565 pixel data */
rgb888_part = (b << 11) + (r << 3); /* Build data to be written in LCD RAM */
LCD_IO_WriteData(rgb888_part);
if (posX != (Xsize + Xpos - 1)) /* When writing last pixel when size is odd, the third part is not written */
{
g = (rgb565[i+1] & 0x07E0) >> 5; /* Extract green component from second RGB565 pixel data */
b = (rgb565[i+1] & 0x001F) >> 0; /* Extract blue component from second RGB565 pixel data */
rgb888_part = (g << 10) + (b << 3); /* Build data to be written in LCD RAM */
LCD_IO_WriteData(rgb888_part);
}
i += 2;
}
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,161 @@
/**
******************************************************************************
* @file ls016b8uy.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the ls016b8uy.c
* driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __LS016B8UY_H
#define __LS016B8UY_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdio.h>
#include "../Common/lcd.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup ls016b8uy
* @{
*/
/** @defgroup LS016B8UY_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup LS016B8UY_Exported_Constants
* @{
*/
/**
* @brief LS016B8UY ID
*/
#define LS016B8UY_ID 0xFFFF
/**
* @brief LS016B8UY Size
*/
#define LS016B8UY_LCD_PIXEL_WIDTH ((uint16_t)180)
#define LS016B8UY_LCD_PIXEL_HEIGHT ((uint16_t)180)
/**
* @brief LS016B8UY Registers
*/
#define LCD_CMD_SLEEP_IN 0x10
#define LCD_CMD_SLEEP_OUT 0x11
#define LCD_CMD_DISPLAY_OFF 0x28
#define LCD_CMD_DISPLAY_ON 0x29
#define LCD_CMD_WRITE_RAM 0x2C
#define LCD_CMD_READ_RAM 0x2E
#define LCD_CMD_CASET 0x2A
#define LCD_CMD_RASET 0x2B
#define LCD_CMD_VSYNC_OUTPUT 0x35
#define LCD_CMD_NORMAL_DISPLAY 0x36
#define LCD_CMD_IDLE_MODE_OFF 0x38
#define LCD_CMD_IDLE_MODE_ON 0x39
#define LCD_CMD_COLOR_MODE 0x3A
#define LCD_CMD_PANEL_SETTING_1 0xB0
#define LCD_CMD_PANEL_SETTING_2 0xB1
#define LCD_CMD_OSCILLATOR 0xB3
#define LCD_CMD_PANEL_SETTING_LOCK 0xB4
#define LCD_CMD_PANEL_V_PORCH 0xB7
#define LCD_CMD_PANEL_IDLE_V_PORCH 0xB8
#define LCD_CMD_GVDD 0xC0
#define LCD_CMD_OPAMP 0xC2
#define LCD_CMD_RELOAD_MTP_VCOMH 0xC5
#define LCD_CMD_PANEL_TIMING_1 0xC8
#define LCD_CMD_PANEL_TIMING_2 0xC9
#define LCD_CMD_PANEL_TIMING_3 0xCA
#define LCD_CMD_PANEL_TIMING_4 0xCC
#define LCD_CMD_PANEL_POWER 0xD0
#define LCD_CMD_TEARING_EFFECT 0xDD
/**
* @}
*/
/** @defgroup LS016B8UY_Exported_Functions
* @{
*/
void ls016b8uy_Init(void);
uint16_t ls016b8uy_ReadID(void);
void ls016b8uy_WriteReg(uint8_t Command, uint8_t *Parameters, uint8_t NbParameters);
uint8_t ls016b8uy_ReadReg(uint8_t Command);
void ls016b8uy_DisplayOn(void);
void ls016b8uy_DisplayOff(void);
void ls016b8uy_SetCursor(uint16_t Xpos, uint16_t Ypos);
void ls016b8uy_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode);
uint16_t ls016b8uy_ReadPixel(uint16_t Xpos, uint16_t Ypos);
void ls016b8uy_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
void ls016b8uy_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
void ls016b8uy_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp);
void ls016b8uy_DrawRGBImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata);
void ls016b8uy_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
uint16_t ls016b8uy_GetLcdPixelWidth(void);
uint16_t ls016b8uy_GetLcdPixelHeight(void);
/* LCD driver structure */
extern LCD_DrvTypeDef ls016b8uy_drv;
/* LCD IO functions */
void LCD_IO_Init(void);
void LCD_IO_WriteMultipleData(uint16_t *pData, uint32_t Size);
void LCD_IO_WriteReg(uint8_t Reg);
void LCD_IO_WriteData(uint16_t RegValue);
uint16_t LCD_IO_ReadData(void);
void LCD_IO_Delay(uint32_t delay);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __LS016B8UY_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,76 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for LSM303C Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-lsm303c-component-drivers"><small>Release Notes for</small> <mark>LSM303C Component Drivers</mark></h1>
<p>Copyright © 2015 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the LSM303C component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V2.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V2.0.0 / 07-April-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>LSM303C_AccLowPower(uint16 Mode) and LSM303C_MagLowPower(uint16_t Mode) API updates to set or not component Low Power mode feature</li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">NOTE</span></span></strong> This release must be used with BSP Common driver V5.0.0 or later</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.0.0 / 24-June-2015</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>First official release of LSM303C component driver</li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">NOTE</span></span></strong> This release must be used with BSP Common driver V4.0.0 or later</p>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,390 @@
/**
******************************************************************************
* @file lsm303c.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the LSM303C
* MEMS accelerometer.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "lsm303c.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup LSM303C
* @{
*/
/** @defgroup LSM303C_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup LSM303C_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup LSM303C_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup LSM303C_Private_Functions
* @{
*/
/**
* @}
*/
/** @defgroup LSM303C_Private_Variables
* @{
*/
ACCELERO_DrvTypeDef Lsm303cDrv_accelero =
{
LSM303C_AccInit,
LSM303C_AccDeInit,
LSM303C_AccReadID,
0,
LSM303C_AccLowPower,
0,
0,
0,
0,
0,
LSM303C_AccFilterConfig,
0,
LSM303C_AccReadXYZ
};
MAGNETO_DrvTypeDef Lsm303cDrv_magneto =
{
LSM303C_MagInit,
LSM303C_MagDeInit,
LSM303C_MagReadID,
0,
LSM303C_MagLowPower,
0,
0,
0,
0,
0,
0,
0,
LSM303C_MagReadXYZ
};
/**
* @}
*/
/**
* @brief Set LSM303C Accelerometer Initialization.
* @param InitStruct: Init parameters
* @retval None
*/
void LSM303C_AccInit(uint16_t InitStruct)
{
uint8_t ctrl = 0x00;
/* Low level init */
ACCELERO_IO_Init();
/* Write value to ACC MEMS CTRL_REG1 register */
ctrl = (uint8_t) InitStruct;
ACCELERO_IO_Write(LSM303C_CTRL_REG1_A, ctrl);
/* Write value to ACC MEMS CTRL_REG4 register */
ctrl = ((uint8_t) (InitStruct >> 8));
ACCELERO_IO_Write(LSM303C_CTRL_REG4_A, ctrl);
}
/**
* @brief LSM303C Accelerometer De-initialization.
* @param None
* @retval None
*/
void LSM303C_AccDeInit(void)
{
}
/**
* @brief Read LSM303C ID.
* @param None
* @retval ID
*/
uint8_t LSM303C_AccReadID(void)
{
uint8_t ctrl = 0x00;
/* Low level init */
ACCELERO_IO_Init();
/* Enabled SPI/I2C read communication */
ACCELERO_IO_Write(LSM303C_CTRL_REG4_A, 0x5);
/* Read value at Who am I register address */
ctrl = ACCELERO_IO_Read(LSM303C_WHO_AM_I_ADDR);
return ctrl;
}
/**
* @brief Put Accelerometer in power down mode or not.
* @param Mode equal to LSM303C_ACC_ODR_OFF means enable Low Power Mode, otherwise Output data rate is set.
* This parameter can be a value of @ref Acc_OutPut_DataRate_Selection
* @retval None
*/
void LSM303C_AccLowPower(uint16_t Mode)
{
uint8_t ctrl = 0x00;
/* Read control register 1 value */
ctrl = ACCELERO_IO_Read(LSM303C_CTRL_REG1_A);
/* Clear ODR bits */
ctrl &= ~(LSM303C_ACC_ODR_BITPOSITION);
/* Set Power down */
ctrl |= (uint8_t)Mode;
/* write back control register */
ACCELERO_IO_Write(LSM303C_CTRL_REG1_A, ctrl);
}
/**
* @brief Set High Pass Filter Modality
* @param FilterStruct: contains data for filter config
* @retval None
*/
void LSM303C_AccFilterConfig(uint8_t FilterStruct)
{
uint8_t tmpreg;
// /* Read CTRL_REG2 register */
// tmpreg = ACCELERO_IO_Read(LSM303C_CTRL_REG2_A);
//
// tmpreg &= 0x0C;
tmpreg = FilterStruct;
/* Write value to ACC MEMS CTRL_REG2 register */
ACCELERO_IO_Write(LSM303C_CTRL_REG2_A, tmpreg);
}
/**
* @brief Read X, Y & Z Acceleration values
* @param pData: Data out pointer
* @retval None
*/
void LSM303C_AccReadXYZ(int16_t* pData)
{
int16_t pnRawData[3];
uint8_t ctrlx[2]={0,0};
uint8_t buffer[6];
uint8_t i = 0;
uint8_t sensitivity = LSM303C_ACC_SENSITIVITY_2G;
/* Read the acceleration control register content */
ctrlx[0] = ACCELERO_IO_Read(LSM303C_CTRL_REG4_A);
ctrlx[1] = ACCELERO_IO_Read(LSM303C_CTRL_REG5_A);
/* Read output register X, Y & Z acceleration */
buffer[0] = ACCELERO_IO_Read(LSM303C_OUT_X_L_A);
buffer[1] = ACCELERO_IO_Read(LSM303C_OUT_X_H_A);
buffer[2] = ACCELERO_IO_Read(LSM303C_OUT_Y_L_A);
buffer[3] = ACCELERO_IO_Read(LSM303C_OUT_Y_H_A);
buffer[4] = ACCELERO_IO_Read(LSM303C_OUT_Z_L_A);
buffer[5] = ACCELERO_IO_Read(LSM303C_OUT_Z_H_A);
for(i=0; i<3; i++)
{
pnRawData[i]=((int16_t)((uint16_t)buffer[2*i+1] << 8) + buffer[2*i]);
}
/* Normal mode */
/* Switch the sensitivity value set in the CRTL4 */
switch(ctrlx[0] & LSM303C_ACC_FULLSCALE_8G)
{
case LSM303C_ACC_FULLSCALE_2G:
sensitivity = LSM303C_ACC_SENSITIVITY_2G;
break;
case LSM303C_ACC_FULLSCALE_4G:
sensitivity = LSM303C_ACC_SENSITIVITY_4G;
break;
case LSM303C_ACC_FULLSCALE_8G:
sensitivity = LSM303C_ACC_SENSITIVITY_8G;
break;
}
/* Obtain the mg value for the three axis */
for(i=0; i<3; i++)
{
pData[i]=(pnRawData[i] * sensitivity);
}
}
/***********************************************************************************************
Magnetometer driver
***********************************************************************************************/
/**
* @brief Set LSM303C Magnetometer Initialization.
* @param LSM303C_InitStruct: pointer to a LSM303C_MagInitTypeDef structure
* that contains the configuration setting for the LSM303C.
* @retval None
*/
void LSM303C_MagInit(MAGNETO_InitTypeDef LSM303C_InitStruct)
{
MAGNETO_IO_Write(LSM303C_CTRL_REG1_M, LSM303C_InitStruct.Register1);
MAGNETO_IO_Write(LSM303C_CTRL_REG2_M, LSM303C_InitStruct.Register2);
MAGNETO_IO_Write(LSM303C_CTRL_REG3_M, LSM303C_InitStruct.Register3);
MAGNETO_IO_Write(LSM303C_CTRL_REG4_M, LSM303C_InitStruct.Register4);
MAGNETO_IO_Write(LSM303C_CTRL_REG5_M, LSM303C_InitStruct.Register5);
}
/**
* @brief LSM303C Magnetometer De-initialization.
* @param None
* @retval None
*/
void LSM303C_MagDeInit(void)
{
}
/**
* @brief Read LSM303C ID.
* @param None
* @retval ID
*/
uint8_t LSM303C_MagReadID(void)
{
/* Low level init */
MAGNETO_IO_Init();
/* Enabled the SPI/I2C read operation */
MAGNETO_IO_Write(LSM303C_CTRL_REG3_M, 0x84);
/* Read value at Who am I register address */
return MAGNETO_IO_Read(LSM303C_WHO_AM_I_ADDR);
}
/**
* @brief Put Magnetometer in power down mode or not.
* @param Mode equal to LSM303C_MAG_POWERDOWN2_MODE means enable deepest Low Power Mode, otherwise other mode is set.
* This parameter can be a value of @ref Mag_Operation_Mode
* @retval None
*/
void LSM303C_MagLowPower(uint16_t Mode)
{
uint8_t ctrl = 0x00;
/* Read control register 1 value */
ctrl = MAGNETO_IO_Read(LSM303C_CTRL_REG3_M);
/* Clear ODR bits */
ctrl &= ~(LSM303C_MAG_SELECTION_MODE);
/* Set mode */
ctrl |= (uint8_t)Mode;
/* write back control register */
MAGNETO_IO_Write(LSM303C_CTRL_REG3_M, ctrl);
}
/**
* @brief Get status for Mag LSM303C data
* @param None
* @retval Data status in a LSM303C Data register
*/
uint8_t LSM303C_MagGetDataStatus(void)
{
/* Read Mag STATUS register */
return MAGNETO_IO_Read(LSM303C_STATUS_REG_M);
}
/**
* @brief Read X, Y & Z Magnetometer values
* @param pData: Data out pointer
* @retval None
*/
void LSM303C_MagReadXYZ(int16_t* pData)
{
uint8_t ctrlx;
uint8_t buffer[6];
uint8_t i=0;
/* Read the magnetometer control register content */
ctrlx = MAGNETO_IO_Read(LSM303C_CTRL_REG4_M);
/* Read output register X, Y & Z magnetometer */
buffer[0] = MAGNETO_IO_Read(LSM303C_OUT_X_L_M);
buffer[1] = MAGNETO_IO_Read(LSM303C_OUT_X_H_M);
buffer[2] = MAGNETO_IO_Read(LSM303C_OUT_Y_L_M);
buffer[3] = MAGNETO_IO_Read(LSM303C_OUT_Y_H_M);
buffer[4] = MAGNETO_IO_Read(LSM303C_OUT_Z_L_M);
buffer[5] = MAGNETO_IO_Read(LSM303C_OUT_Z_H_M);
/* Check in the control register4 the data alignment*/
if((ctrlx & LSM303C_MAG_BLE_MSB))
{
for(i=0; i<3; i++)
{
pData[i]=((int16_t)((uint16_t)buffer[2*i] << 8) + buffer[2*i+1]);
}
}
else
{
for(i=0; i<3; i++)
{
pData[i]=((int16_t)((uint16_t)buffer[2*i+1] << 8) + buffer[2*i]);
}
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,601 @@
/**
******************************************************************************
* @file lsm303c.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the LSM303C.c driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __LSM303C_H
#define __LSM303C_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/accelero.h"
#include "../Common/magneto.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup LSM303C
* @{
*/
/** @defgroup LSM303C_Exported_Types
* @{
*/
/**
* @}
*/
/******************************************************************************/
/*************************** START REGISTER MAPPING **************************/
/******************************************************************************/
/* Acceleration Registers */
#define LSM303C_WHO_AM_I_ADDR 0x0F /* device identification register */
#define LSM303C_ACT_THS_A 0x1E
#define LSM303C_ACT_DUR_A 0x1F
#define LSM303C_CTRL_REG1_A 0x20 /* Control register 1 acceleration */
#define LSM303C_CTRL_REG2_A 0x21 /* Control register 2 acceleration */
#define LSM303C_CTRL_REG3_A 0x22 /* Control register 3 acceleration */
#define LSM303C_CTRL_REG4_A 0x23 /* Control register 4 acceleration */
#define LSM303C_CTRL_REG5_A 0x24 /* Control register 5 acceleration */
#define LSM303C_CTRL_REG6_A 0x25 /* Control register 6 acceleration */
#define LSM303C_CTRL_REG7_A 0x26 /* Control register 6 acceleration */
#define LSM303C_STATUS_REG_A 0x27 /* Status register acceleration */
#define LSM303C_OUT_X_L_A 0x28 /* Output Register X acceleration */
#define LSM303C_OUT_X_H_A 0x29 /* Output Register X acceleration */
#define LSM303C_OUT_Y_L_A 0x2A /* Output Register Y acceleration */
#define LSM303C_OUT_Y_H_A 0x2B /* Output Register Y acceleration */
#define LSM303C_OUT_Z_L_A 0x2C /* Output Register Z acceleration */
#define LSM303C_OUT_Z_H_A 0x2D /* Output Register Z acceleration */
#define LSM303C_FIFO_CTRL 0x2E /* Fifo control Register acceleration */
#define LSM303C_FIFO_SRC 0x2F /* Fifo src Register acceleration */
#define LSM303C_IG_CFG1_A 0x30 /* Interrupt 1 configuration Register acceleration */
#define LSM303C_IG_SRC1_A 0x31 /* Interrupt 1 source Register acceleration */
#define LSM303C_IG_THS_X1_A 0x32
#define LSM303C_IG_THS_Y1_A 0x33
#define LSM303C_IG_THS_Z1_A 0x34
#define LSM303C_IG_DUR1_A 0x32
#define LSM303C_INT1_DURATION_A 0x33 /* Interrupt 1 DURATION register acceleration */
#define LSM303C_INT2_CFG_A 0x34 /* Interrupt 2 configuration Register acceleration */
#define LSM303C_INT2_SOURCE_A 0x35 /* Interrupt 2 source Register acceleration */
#define LSM303C_INT2_THS_A 0x36 /* Interrupt 2 Threshold register acceleration */
#define LSM303C_INT2_DURATION_A 0x37 /* Interrupt 2 DURATION register acceleration */
#define LSM303C_CLICK_CFG_A 0x38 /* Click configuration Register acceleration */
#define LSM303C_CLICK_SOURCE_A 0x39 /* Click 2 source Register acceleration */
#define LSM303C_CLICK_THS_A 0x3A /* Click 2 Threshold register acceleration */
#define LSM303C_TIME_LIMIT_A 0x3B /* Time Limit Register acceleration */
#define LSM303C_TIME_LATENCY_A 0x3C /* Time Latency Register acceleration */
#define LSM303C_TIME_WINDOW_A 0x3D /* Time window register acceleration */
/* Magnetic field Registers */
#define LSM303C_CTRL_REG1_M 0x20 /* Magnetic control register 1 */
#define LSM303C_CTRL_REG2_M 0x21 /* Magnetic control register 2 */
#define LSM303C_CTRL_REG3_M 0x22 /* Magnetic control register 3 */
#define LSM303C_CTRL_REG4_M 0x23 /* Magnetic control register 4 */
#define LSM303C_CTRL_REG5_M 0x24 /* Magnetic control register 5 */
#define LSM303C_STATUS_REG_M 0x27 /* Magnetic status register M */
#define LSM303C_OUT_X_L_M 0x28 /* Output Register X magnetic field */
#define LSM303C_OUT_X_H_M 0x29 /* Output Register X magnetic field */
#define LSM303C_OUT_Y_L_M 0x2A /* Output Register Y magnetic field */
#define LSM303C_OUT_Y_H_M 0x2B /* Output Register Y magnetic field */
#define LSM303C_OUT_Z_L_M 0x2C /* Output Register Z magnetic field */
#define LSM303C_OUT_Z_H_M 0x2D /* Output Register Z magnetic field */
#define LSM303C_TEMP_OUT_L_M 0x2E /* Temperature Register magnetic field */
#define LSM303C_TEMP_OUT_H_M 0x2F /* Temperature Register magnetic field */
#define LSM303C_INT_CFG_M 0x30 /* Axis interrupt configuration */
#define LSM303C_INT_SRC_M 0x31 /* Axis interrupt source */
#define LSM303C_INT_THS_L_M 0x32 /* Interrupt threshold L */
#define LSM303C_INT_THS_H_M 0x33 /* Interrupt threshold M */
/******************************************************************************/
/**************************** END REGISTER MAPPING ***************************/
/******************************************************************************/
/** @defgroup Power_Mode_selection
* @{
*/
#define LMS303C_ACC_ID ((uint8_t)0x41)
#define LMS303C_MAG_ID ((uint8_t)0x3D)
/**
* @}
*/
/** @defgroup Acc_OutPut_DataRate_Selection
* @{
*/
#define LSM303C_ACC_ODR_BITPOSITION ((uint8_t)0x70) /*!< Output Data Rate bit position */
#define LSM303C_ACC_ODR_OFF ((uint8_t)0x00) /*!< Output Data Rate powerdown */
#define LSM303C_ACC_ODR_10_HZ ((uint8_t)0x10) /*!< Output Data Rate = 10 Hz */
#define LSM303C_ACC_ODR_50_HZ ((uint8_t)0x20) /*!< Output Data Rate = 50 Hz */
#define LSM303C_ACC_ODR_100_HZ ((uint8_t)0x30) /*!< Output Data Rate = 100 Hz */
#define LSM303C_ACC_ODR_200_HZ ((uint8_t)0x40) /*!< Output Data Rate = 200 Hz */
#define LSM303C_ACC_ODR_400_HZ ((uint8_t)0x50) /*!< Output Data Rate = 400 Hz */
#define LSM303C_ACC_ODR_800_HZ ((uint8_t)0x60) /*!< Output Data Rate = 800 Hz */
/**
* @}
*/
/** @defgroup Acc_Axes_Selection
* @{
*/
#define LSM303C_ACC_X_ENABLE ((uint8_t)0x01)
#define LSM303C_ACC_Y_ENABLE ((uint8_t)0x02)
#define LSM303C_ACC_Z_ENABLE ((uint8_t)0x04)
#define LSM303C_ACC_AXES_ENABLE ((uint8_t)0x07)
#define LSM303C_ACC_AXES_DISABLE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Acc_High_Resolution
* @{
*/
#define LSM303C_ACC_HR_ENABLE ((uint8_t)0x80)
#define LSM303C_ACC_HR_DISABLE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Communication_Mode
* @{
*/
#define LSM303C_ACC_I2C_MODE ((uint8_t) 0x02)
#define LSM303C_ACC_SPI_MODE ((uint8_t) 0x01)
/**
* @}
*/
/** @defgroup Acc_Full_Scale_Selection
* @{
*/
#define LSM303C_ACC_FULLSCALE_2G ((uint8_t)0x00) /*!< <20>2 g */
#define LSM303C_ACC_FULLSCALE_4G ((uint8_t)0x20) /*!< <20>4 g */
#define LSM303C_ACC_FULLSCALE_8G ((uint8_t)0x30) /*!< <20>8 g */
/**
* @}
*/
/** @defgroup Acc_Full_Scale_Selection
* @{
*/
#define LSM303C_ACC_SENSITIVITY_2G ((uint8_t)1) /*!< accelerometer sensitivity with 2 g full scale [mg/LSB] */
#define LSM303C_ACC_SENSITIVITY_4G ((uint8_t)2) /*!< accelerometer sensitivity with 4 g full scale [mg/LSB] */
#define LSM303C_ACC_SENSITIVITY_8G ((uint8_t)4) /*!< accelerometer sensitivity with 8 g full scale [mg/LSB] */
#define LSM303C_ACC_SENSITIVITY_16G ((uint8_t)12) /*!< accelerometer sensitivity with 12 g full scale [mg/LSB] */
/**
* @}
*/
/** @defgroup Acc_Block_Data_Update
* @{
*/
#define LSM303C_ACC_BDU_CONTINUOUS ((uint8_t)0x00) /*!< Continuos Update */
#define LSM303C_ACC_BDU_MSBLSB ((uint8_t)0x08) /*!< Single Update: output registers not updated until MSB and LSB reading */
/**
* @}
*/
/** @defgroup Acc_Endian_Data_selection
* @{
*/
#define LSM303C_ACC_BLE_LSB ((uint8_t)0x00) /*!< Little Endian: data LSB @ lower address */
#define LSM303C_ACC_BLE_MSB ((uint8_t)0x40) /*!< Big Endian: data MSB @ lower address */
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_Mode
* @{
*/
#define LSM303C_ACC_HPM_REF_SIGNAL ((uint8_t)0x08)
#define LSM303C_ACC_HPM_NORMAL_MODE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Acc_High_Pass_CUT OFF_Frequency
* @{
*/
#define LSM303C_ACC_DFC1_ODRDIV50 ((uint8_t)0x00)
#define LSM303C_ACC_DFC1_ODRDIV100 ((uint8_t)0x20)
#define LSM303C_ACC_DFC1_ODRDIV9 ((uint8_t)0x40)
#define LSM303C_ACC_DFC1_ODRDIV400 ((uint8_t)0x60)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_status
* @{
*/
#define LSM303C_ACC_HPF_DISABLE ((uint8_t)0x00)
#define LSM303C_ACC_HPF_ENABLE ((uint8_t)0x08)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_Click_status
* @{
*/
#define LSM303C_ACC_HPF_CLICK_DISABLE ((uint8_t)0x00)
#define LSM303C_ACC_HPF_CLICK_ENABLE ((uint8_t)0x04)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_HPI2S_status
* @{
*/
#define LSM303C_ACC_HPI2S_INT1_DISABLE ((uint8_t)0x00)
#define LSM303C_ACC_HPI2S_INT1_ENABLE ((uint8_t)0x01)
#define LSM303C_ACC_HPI2S_INT2_DISABLE ((uint8_t)0x00)
#define LSM303C_ACC_HPI2S_INT2_ENABLE ((uint8_t)0x02)
/**
* @}
*/
/** @defgroup Acc_Interrupt1_Configuration_definition
* @{
*/
#define LSM303C_IT1_CLICK ((uint8_t)0x80)
#define LSM303C_IT1_AOI1 ((uint8_t)0x40)
#define LSM303C_IT1_AOI2 ((uint8_t)0x20)
#define LSM303C_IT1_DRY1 ((uint8_t)0x10)
#define LSM303C_IT1_DRY2 ((uint8_t)0x08)
#define LSM303C_IT1_WTM ((uint8_t)0x04)
#define LSM303C_IT1_OVERRUN ((uint8_t)0x02)
/**
* @}
*/
/** @defgroup Acc_Interrupt2_Configuration_definition
* @{
*/
#define LSM303C_IT2_CLICK ((uint8_t)0x80)
#define LSM303C_IT2_INT1 ((uint8_t)0x40)
#define LSM303C_IT2_INT2 ((uint8_t)0x20)
#define LSM303C_IT2_BOOT ((uint8_t)0x10)
#define LSM303C_IT2_ACT ((uint8_t)0x08)
#define LSM303C_IT2_HLACTIVE ((uint8_t)0x02)
/**
* @}
*/
/** @defgroup Acc_INT_Combination_Status
* @{
*/
#define LSM303C_OR_COMBINATION ((uint8_t)0x00) /*!< OR combination of enabled IRQs */
#define LSM303C_AND_COMBINATION ((uint8_t)0x80) /*!< AND combination of enabled IRQs */
#define LSM303C_MOV_RECOGNITION ((uint8_t)0x40) /*!< 6D movement recognition */
#define LSM303C_POS_RECOGNITION ((uint8_t)0xC0) /*!< 6D position recognition */
/**
* @}
*/
/** @defgroup Acc_INT_Axes
* @{
*/
#define LSM303C_Z_HIGH ((uint8_t)0x20) /*!< Z High enabled IRQs */
#define LSM303C_Z_LOW ((uint8_t)0x10) /*!< Z low enabled IRQs */
#define LSM303C_Y_HIGH ((uint8_t)0x08) /*!< Y High enabled IRQs */
#define LSM303C_Y_LOW ((uint8_t)0x04) /*!< Y low enabled IRQs */
#define LSM303C_X_HIGH ((uint8_t)0x02) /*!< X High enabled IRQs */
#define LSM303C_X_LOW ((uint8_t)0x01) /*!< X low enabled IRQs */
/**
* @}
*/
/** @defgroup Acc_INT_Click
* @{
*/
#define LSM303C_Z_DOUBLE_CLICK ((uint8_t)0x20) /*!< Z double click IRQs */
#define LSM303C_Z_SINGLE_CLICK ((uint8_t)0x10) /*!< Z single click IRQs */
#define LSM303C_Y_DOUBLE_CLICK ((uint8_t)0x08) /*!< Y double click IRQs */
#define LSM303C_Y_SINGLE_CLICK ((uint8_t)0x04) /*!< Y single click IRQs */
#define LSM303C_X_DOUBLE_CLICK ((uint8_t)0x02) /*!< X double click IRQs */
#define LSM303C_X_SINGLE_CLICK ((uint8_t)0x01) /*!< X single click IRQs */
/**
* @}
*/
/** @defgroup Acc_INT1_Interrupt_status
* @{
*/
#define LSM303C_INT1INTERRUPT_DISABLE ((uint8_t)0x00)
#define LSM303C_INT1INTERRUPT_ENABLE ((uint8_t)0x80)
/**
* @}
*/
/** @defgroup Acc_INT1_Interrupt_ActiveEdge
* @{
*/
#define LSM303C_INT1INTERRUPT_LOW_EDGE ((uint8_t)0x20)
#define LSM303C_INT1INTERRUPT_HIGH_EDGE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Mag_Temperature_Sensor
* @{
*/
#define LSM303C_MAG_TEMPSENSOR_ENABLE ((uint8_t) 0x80) /*!< Temp sensor Enable */
#define LSM303C_MAG_TEMPSENSOR_DISABLE ((uint8_t) 0x00) /*!< Temp sensor Disable */
/**
* @}
*/
/** @defgroup Mag_XY-axis_Operating_Mode
* @{
*/
#define LSM303C_MAG_OM_XY_LOWPOWER ((uint8_t) 0x00 << 5)
#define LSM303C_MAG_OM_XY_MEDIUM ((uint8_t) 0x01 << 5)
#define LSM303C_MAG_OM_XY_HIGH ((uint8_t) 0x02 << 5)
#define LSM303C_MAG_OM_XY_ULTRAHIGH ((uint8_t) 0x03 << 5)
/**
* @}
*/
/** @defgroup Mag_Data_Rate
* @{
*/
#define LSM303C_MAG_ODR_0_625_HZ ((uint8_t) 0x00 << 2) /*!< Output Data Rate = 0.625 Hz */
#define LSM303C_MAG_ODR_1_25_HZ ((uint8_t) 0x01 << 2) /*!< Output Data Rate = 1.25 Hz */
#define LSM303C_MAG_ODR_2_5_HZ ((uint8_t) 0x02 << 2) /*!< Output Data Rate = 2.5 Hz */
#define LSM303C_MAG_ODR_5_0_HZ ((uint8_t) 0x03 << 2) /*!< Output Data Rate = 5.0 Hz */
#define LSM303C_MAG_ODR_10_HZ ((uint8_t) 0x04 << 2) /*!< Output Data Rate = 10 Hz */
#define LSM303C_MAG_ODR_20_HZ ((uint8_t) 0x05 << 2) /*!< Output Data Rate = 20 Hz */
#define LSM303C_MAG_ODR_40_HZ ((uint8_t) 0x06 << 2) /*!< Output Data Rate = 40 Hz */
#define LSM303C_MAG_ODR_80_HZ ((uint8_t) 0x07 << 2) /*!< Output Data Rate = 80 Hz */
/**
* @}
*/
/** @defgroup Mag_Data_Rate
* @{
*/
#define LMS303C_MAG_SELFTEST_DISABLE ((uint8_t 0x00)
#define LMS303C_MAG_SELFTEST_ENABLE ((uint8_t 0x01)
/**
* @}
*/
/** @defgroup Mag_Full_Scale
* @{
*/
#define LSM303C_MAG_FS_DEFAULT ((uint8_t) 0x00 << 5)
#define LSM303C_MAG_FS_16_GA ((uint8_t) 0x03 << 5) /*!< Full scale = <20>16 Gauss */
/**
* @}
*/
/** @defgroup Mag_Reboot
* @{
*/
#define LSM303C_MAG_REBOOT_DEFAULT ((uint8_t) 0x00 << 3)
#define LSM303C_MAG_REBOOT_ENABLE ((uint8_t) 0x01 << 3)
/**
* @}
*/
/** @defgroup Mag_Soft_reset
* @{
*/
#define LSM303C_MAG_SOFT_RESET_DEFAULT ((uint8_t) 0x00 << 2)
#define LSM303C_MAG_SOFT_RESET_ENABLE ((uint8_t) 0x01 << 2)
/**
* @}
*/
/** @defgroup Mag_Communication_Mode
* @{
*/
#define LSM303C_MAG_I2C_MODE ((uint8_t) 0x80)
#define LSM303C_MAG_SPI_MODE ((uint8_t) 0x04)
/**
* @}
*/
/** @defgroup Mag_Lowpower_mode_config
* @{
*/
#define LSM303C_MAG_CONFIG_NORMAL_MODE ((uint8_t) 0x00)
#define LSM303C_MAG_CONFIG_LOWPOWER_MODE ((uint8_t) 0x20)
/**
* @}
*/
/** @defgroup Mag_Operation_Mode
* @{
*/
#define LSM303C_MAG_SELECTION_MODE ((uint8_t) 0x03)
#define LSM303C_MAG_CONTINUOUS_MODE ((uint8_t) 0x00)
#define LSM303C_MAG_SINGLE_MODE ((uint8_t) 0x01)
#define LSM303C_MAG_POWERDOWN1_MODE ((uint8_t) 0x02)
#define LSM303C_MAG_POWERDOWN2_MODE ((uint8_t) 0x03)
/**
* @}
*/
/** @defgroup Mag_Z-axis_Operation_Mode
* @{
*/
#define LSM303C_MAG_OM_Z_LOWPOWER ((uint8_t) 0x00 << 2)
#define LSM303C_MAG_OM_Z_MEDIUM ((uint8_t) 0x01 << 2)
#define LSM303C_MAG_OM_Z_HIGH ((uint8_t) 0x02 << 2)
#define LSM303C_MAG_OM_Z_ULTRAHIGH ((uint8_t) 0x03 << 2)
/**
* @}
*/
/** @defgroup Mag_Big_little-endian_selection
* @{
*/
#define LSM303C_MAG_BLE_LSB ((uint8_t) 0x00)
#define LSM303C_MAG_BLE_MSB ((uint8_t) 0x02)
/**
* @}
*/
/** @defgroup Mag_Bloc_update_magnetic_data
* @{
*/
#define LSM303C_MAG_BDU_CONTINUOUS ((uint8_t) 0x00)
#define LSM303C_MAG_BDU_MSBLSB ((uint8_t) 0x40)
/**
* @}
*/
/**
* @defgroup Magnetometer_Sensitivity
* @{
*/
#define LSM303C_M_SENSITIVITY_XY_1_3Ga 1100 /*!< magnetometer X Y axes sensitivity for 1.3 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_XY_1_9Ga 855 /*!< magnetometer X Y axes sensitivity for 1.9 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_XY_2_5Ga 670 /*!< magnetometer X Y axes sensitivity for 2.5 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_XY_4Ga 450 /*!< magnetometer X Y axes sensitivity for 4 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_XY_4_7Ga 400 /*!< magnetometer X Y axes sensitivity for 4.7 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_XY_5_6Ga 330 /*!< magnetometer X Y axes sensitivity for 5.6 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_XY_8_1Ga 230 /*!< magnetometer X Y axes sensitivity for 8.1 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_Z_1_3Ga 980 /*!< magnetometer Z axis sensitivity for 1.3 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_Z_1_9Ga 760 /*!< magnetometer Z axis sensitivity for 1.9 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_Z_2_5Ga 600 /*!< magnetometer Z axis sensitivity for 2.5 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_Z_4Ga 400 /*!< magnetometer Z axis sensitivity for 4 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_Z_4_7Ga 355 /*!< magnetometer Z axis sensitivity for 4.7 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_Z_5_6Ga 295 /*!< magnetometer Z axis sensitivity for 5.6 Ga full scale [LSB/Ga] */
#define LSM303C_M_SENSITIVITY_Z_8_1Ga 205 /*!< magnetometer Z axis sensitivity for 8.1 Ga full scale [LSB/Ga] */
/**
* @}
*/
/** @defgroup Mag_Working_Mode
* @{
*/
#define LSM303C_CONTINUOUS_CONVERSION ((uint8_t) 0x00) /*!< Continuous-Conversion Mode */
#define LSM303C_SINGLE_CONVERSION ((uint8_t) 0x01) /*!< Single-Conversion Mode */
#define LSM303C_SLEEP ((uint8_t) 0x02) /*!< Sleep Mode */
/**
* @}
*/
/** @defgroup LSM303C_AccExported_Functions ACCELEROMETER Exported functions
* @{
*/
void LSM303C_AccInit(uint16_t InitStruct);
void LSM303C_AccDeInit(void);
uint8_t LSM303C_AccReadID(void);
void LSM303C_AccLowPower(uint16_t Mode);
void LSM303C_AccFilterConfig(uint8_t FilterStruct);
void LSM303C_AccFilterCmd(uint8_t HighPassFilterState);
void LSM303C_AccReadXYZ(int16_t* pData);
void LSM303C_AccFilterClickCmd(uint8_t HighPassFilterClickState);
void LSM303C_AccIT1Enable(uint8_t LSM303C_IT);
void LSM303C_AccIT1Disable(uint8_t LSM303C_IT);
void LSM303C_AccIT2Enable(uint8_t LSM303C_IT);
void LSM303C_AccIT2Disable(uint8_t LSM303C_IT);
void LSM303C_AccClickITEnable(uint8_t ITClick);
void LSM303C_AccClickITDisable(uint8_t ITClick);
void LSM303C_AccZClickITConfig(void);
/**
* @}
*/
/** @defgroup LSM303C_AccImported_Globals ACCELEROMETER Imported Globals
* @{
*/
extern ACCELERO_DrvTypeDef Lsm303cDrv_accelero;
/**
* @}
*/
/** @defgroup LSM303C_MagExported_Functions MAGNETOMETER Exported functions
* @{
*/
void LSM303C_MagInit(MAGNETO_InitTypeDef LSM303C_InitStruct);
void LSM303C_MagDeInit(void);
uint8_t LSM303C_MagReadID(void);
void LSM303C_MagLowPower(uint16_t Mode);
void LSM303C_MagReadXYZ(int16_t* pData);
uint8_t LSM303C_MagGetDataStatus(void);
/**
* @}
*/
/** @defgroup LSM303C_MagImported_Globals MAGNETOMETER Imported Globals
* @{
*/
extern MAGNETO_DrvTypeDef Lsm303cDrv_magneto;
/**
* @}
*/
/** @defgroup LSM303C_Imported_Functions LSM303C IO Imported Functions
* @{
*/
/* ACCELERO IO functions */
extern void ACCELERO_IO_Init(void);
extern void ACCELERO_IO_ITConfig(void);
extern void ACCELERO_IO_Write(uint8_t RegisterAddr, uint8_t Value);
extern uint8_t ACCELERO_IO_Read(uint8_t RegisterAddr);
/* MAGNETO IO function */
extern void MAGNETO_IO_Init(void);
extern void MAGNETO_IO_ITConfig(void);
extern void MAGNETO_IO_Write(uint8_t RegisterAddr, uint8_t Value);
extern uint8_t MAGNETO_IO_Read(uint8_t RegisterAddr);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __LSM303C_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,88 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for LSM303DLHC Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-lsm303dlhc-component-drivers"><small>Release Notes for</small> <mark>LSM303DLHC Component Drivers</mark></h1>
<p>Copyright © 2015 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the LSM303DLHC component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V2.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V2.0.0 / 24-June-2015</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>lsm303dlhc.c
<ul>
<li>Add accelerometer de-initialization function: LSM303DLHC_AccDeInit()</li>
</ul></li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">NOTE</span></span></strong> This release must be used with BSP Common driver V4.0.0 or later</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.0.1 / 21-November-2014</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>lsm303dlhc.h: change “\” by “/” in the include path to fix compilation issue under Linux</li>
<li>Miscellaneous comments update</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section17" aria-hidden="true"> <label for="collapse-section17" aria-hidden="true">V1.0.0 / 18-February-2014</label>
<div>
<h2 id="main-changes-3">Main Changes</h2>
<ul>
<li>First official release</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,560 @@
/**
******************************************************************************
* @file lsm303dlhc.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the lsm303dlhc
* MEMS accelerometer.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "lsm303dlhc.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup LSM303DLHC
* @{
*/
/** @defgroup LSM303DLHC_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup LSM303DLHC_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup LSM303DLHC_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup LSM303DLHC_Private_Variables
* @{
*/
ACCELERO_DrvTypeDef Lsm303dlhcDrv =
{
LSM303DLHC_AccInit,
LSM303DLHC_AccDeInit,
LSM303DLHC_AccReadID,
LSM303DLHC_AccRebootCmd,
0,
LSM303DLHC_AccZClickITConfig,
0,
0,
0,
0,
LSM303DLHC_AccFilterConfig,
LSM303DLHC_AccFilterCmd,
LSM303DLHC_AccReadXYZ
};
/**
* @}
*/
/** @defgroup LSM303DLHC_Private_Functions
* @{
*/
/**
* @brief Set LSM303DLHC Initialization.
* @param InitStruct: Init parameters
* @retval None
*/
void LSM303DLHC_AccInit(uint16_t InitStruct)
{
uint8_t ctrl = 0x00;
/* Low level init */
COMPASSACCELERO_IO_Init();
/* Write value to ACC MEMS CTRL_REG1 register */
ctrl = (uint8_t) InitStruct;
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG1_A, ctrl);
/* Write value to ACC MEMS CTRL_REG4 register */
ctrl = (uint8_t) (InitStruct << 8);
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG4_A, ctrl);
}
/**
* @brief LSM303DLHC De-initialization.
* @param None
* @retval None
*/
void LSM303DLHC_AccDeInit(void)
{
}
/**
* @brief Read LSM303DLHC ID.
* @param None
* @retval ID
*/
uint8_t LSM303DLHC_AccReadID(void)
{
uint8_t ctrl = 0x00;
/* Low level init */
COMPASSACCELERO_IO_Init();
/* Read value at Who am I register address */
ctrl = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_WHO_AM_I_ADDR);
return ctrl;
}
/**
* @brief Reboot memory content of LSM303DLHC
* @param None
* @retval None
*/
void LSM303DLHC_AccRebootCmd(void)
{
uint8_t tmpreg;
/* Read CTRL_REG5 register */
tmpreg = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG5_A);
/* Enable or Disable the reboot memory */
tmpreg |= LSM303DLHC_BOOT_REBOOTMEMORY;
/* Write value to ACC MEMS CTRL_REG5 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG5_A, tmpreg);
}
/**
* @brief Set High Pass Filter Modality
* @param FilterStruct: contains data for filter config
* @retval None
*/
void LSM303DLHC_AccFilterConfig(uint8_t FilterStruct)
{
uint8_t tmpreg;
/* Read CTRL_REG2 register */
tmpreg = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG2_A);
tmpreg &= 0x0C;
tmpreg |= FilterStruct;
/* Write value to ACC MEMS CTRL_REG2 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG2_A, tmpreg);
}
/**
* @brief Enable or Disable High Pass Filter
* @param HighPassFilterState: new state of the High Pass Filter feature.
* This parameter can be:
* @arg: LSM303DLHC_HIGHPASSFILTER_DISABLE
* @arg: LSM303DLHC_HIGHPASSFILTER_ENABLE
* @retval None
*/
void LSM303DLHC_AccFilterCmd(uint8_t HighPassFilterState)
{
uint8_t tmpreg;
/* Read CTRL_REG2 register */
tmpreg = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG2_A);
tmpreg &= 0xF7;
tmpreg |= HighPassFilterState;
/* Write value to ACC MEMS CTRL_REG2 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG2_A, tmpreg);
}
/**
* @brief Read X, Y & Z Acceleration values
* @param pData: Data out pointer
* @retval None
*/
void LSM303DLHC_AccReadXYZ(int16_t* pData)
{
int16_t pnRawData[3];
uint8_t ctrlx[2]={0,0};
int8_t buffer[6];
uint8_t i = 0;
uint8_t sensitivity = LSM303DLHC_ACC_SENSITIVITY_2G;
/* Read the acceleration control register content */
ctrlx[0] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG4_A);
ctrlx[1] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG5_A);
/* Read output register X, Y & Z acceleration */
buffer[0] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_X_L_A);
buffer[1] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_X_H_A);
buffer[2] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_Y_L_A);
buffer[3] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_Y_H_A);
buffer[4] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_Z_L_A);
buffer[5] = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_Z_H_A);
/* Check in the control register4 the data alignment*/
if(!(ctrlx[0] & LSM303DLHC_BLE_MSB))
{
for(i=0; i<3; i++)
{
pnRawData[i]=((int16_t)((uint16_t)buffer[2*i+1] << 8) + buffer[2*i]);
}
}
else /* Big Endian Mode */
{
for(i=0; i<3; i++)
{
pnRawData[i]=((int16_t)((uint16_t)buffer[2*i] << 8) + buffer[2*i+1]);
}
}
/* Normal mode */
/* Switch the sensitivity value set in the CRTL4 */
switch(ctrlx[0] & LSM303DLHC_FULLSCALE_16G)
{
case LSM303DLHC_FULLSCALE_2G:
sensitivity = LSM303DLHC_ACC_SENSITIVITY_2G;
break;
case LSM303DLHC_FULLSCALE_4G:
sensitivity = LSM303DLHC_ACC_SENSITIVITY_4G;
break;
case LSM303DLHC_FULLSCALE_8G:
sensitivity = LSM303DLHC_ACC_SENSITIVITY_8G;
break;
case LSM303DLHC_FULLSCALE_16G:
sensitivity = LSM303DLHC_ACC_SENSITIVITY_16G;
break;
}
/* Obtain the mg value for the three axis */
for(i=0; i<3; i++)
{
pData[i]=(pnRawData[i] * sensitivity);
}
}
/**
* @brief Enable or Disable High Pass Filter on CLick
* @param HighPassFilterState: new state of the High Pass Filter feature.
* This parameter can be:
* @arg: LSM303DLHC_HPF_CLICK_DISABLE
* @arg: LSM303DLHC_HPF_CLICK_ENABLE
* @retval None
*/
void LSM303DLHC_AccFilterClickCmd(uint8_t HighPassFilterClickState)
{
uint8_t tmpreg = 0x00;
/* Read CTRL_REG2 register */
tmpreg = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG2_A);
tmpreg &= ~(LSM303DLHC_HPF_CLICK_ENABLE);
tmpreg |= HighPassFilterClickState;
/* Write value to ACC MEMS CTRL_REG2 regsister */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG2_A, tmpreg);
}
/**
* @brief Enable LSM303DLHC Interrupt1
* @param LSM303DLHC_IT: specifies the LSM303DLHC interrupt source to be enabled.
* This parameter can be any combination of the following values:
* @arg LSM303DLHC_IT1_CLICK
* @arg LSM303DLHC_IT1_AOI1
* @arg LSM303DLHC_IT1_AOI2
* @arg LSM303DLHC_IT1_DRY1
* @arg LSM303DLHC_IT1_DRY2
* @arg LSM303DLHC_IT1_WTM
* @arg LSM303DLHC_IT1_OVERRUN
* @retval None
*/
void LSM303DLHC_AccIT1Enable(uint8_t LSM303DLHC_IT)
{
uint8_t tmpval = 0x00;
/* Read CTRL_REG3 register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG3_A);
/* Enable IT1 */
tmpval |= LSM303DLHC_IT;
/* Write value to MEMS CTRL_REG3 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG3_A, tmpval);
}
/**
* @brief Disable LSM303DLHC Interrupt1
* @param LSM303DLHC_IT: specifies the LSM303DLHC interrupt source to be disabled.
* This parameter can be any combination of the following values:
* @arg LSM303DLHC_IT1_CLICK
* @arg LSM303DLHC_IT1_AOI1
* @arg LSM303DLHC_IT1_AOI2
* @arg LSM303DLHC_IT1_DRY1
* @arg LSM303DLHC_IT1_DRY2
* @arg LSM303DLHC_IT1_WTM
* @arg LSM303DLHC_IT1_OVERRUN
* @retval None
*/
void LSM303DLHC_AccIT1Disable(uint8_t LSM303DLHC_IT)
{
uint8_t tmpval = 0x00;
/* Read CTRL_REG3 register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG3_A);
/* Disable IT1 */
tmpval &= ~LSM303DLHC_IT;
/* Write value to MEMS CTRL_REG3 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG3_A, tmpval);
}
/**
* @brief Enable LSM303DLHC Interrupt2
* @param LSM303DLHC_IT: specifies the LSM303DLHC interrupt source to be enabled.
* This parameter can be any combination of the following values:
* @arg LSM303DLHC_IT2_CLICK
* @arg LSM303DLHC_IT2_INT1
* @arg LSM303DLHC_IT2_INT2
* @arg LSM303DLHC_IT2_BOOT
* @arg LSM303DLHC_IT2_ACT
* @arg LSM303DLHC_IT2_HLACTIVE
* @retval None
*/
void LSM303DLHC_AccIT2Enable(uint8_t LSM303DLHC_IT)
{
uint8_t tmpval = 0x00;
/* Read CTRL_REG3 register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG6_A);
/* Enable IT2 */
tmpval |= LSM303DLHC_IT;
/* Write value to MEMS CTRL_REG3 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG6_A, tmpval);
}
/**
* @brief Disable LSM303DLHC Interrupt2
* @param LSM303DLHC_IT: specifies the LSM303DLHC interrupt source to be disabled.
* This parameter can be any combination of the following values:
* @arg LSM303DLHC_IT2_CLICK
* @arg LSM303DLHC_IT2_INT1
* @arg LSM303DLHC_IT2_INT2
* @arg LSM303DLHC_IT2_BOOT
* @arg LSM303DLHC_IT2_ACT
* @arg LSM303DLHC_IT2_HLACTIVE
* @retval None
*/
void LSM303DLHC_AccIT2Disable(uint8_t LSM303DLHC_IT)
{
uint8_t tmpval = 0x00;
/* Read CTRL_REG3 register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG6_A);
/* Disable IT2 */
tmpval &= ~LSM303DLHC_IT;
/* Write value to MEMS CTRL_REG3 register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG6_A, tmpval);
}
/**
* @brief INT1 interrupt enable
* @param ITCombination: Or or And combination
* ITAxes: Axes to be enabled
* @retval None
*/
void LSM303DLHC_AccINT1InterruptEnable(uint8_t ITCombination, uint8_t ITAxes)
{
uint8_t tmpval = 0x00;
/* Read INT1_CFR register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_INT1_CFG_A);
/* Enable the selected interrupt */
tmpval |= (ITAxes | ITCombination);
/* Write value to MEMS INT1_CFR register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_INT1_CFG_A, tmpval);
}
/**
* @brief INT1 interrupt disable
* @param ITCombination: Or or And combination
* ITAxes: Axes to be enabled
* @retval None
*/
void LSM303DLHC_AccINT1InterruptDisable(uint8_t ITCombination, uint8_t ITAxes)
{
uint8_t tmpval = 0x00;
/* Read INT1_CFR register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_INT1_CFG_A);
/* Disable the selected interrupt */
tmpval &= ~(ITAxes | ITCombination);
/* Write value to MEMS INT1_CFR register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_INT1_CFG_A, tmpval);
}
/**
* @brief INT2 interrupt enable
* @param ITCombination: Or or And combination
* ITAxes: axes to be enabled
* @retval None
*/
void LSM303DLHC_AccINT2InterruptEnable(uint8_t ITCombination, uint8_t ITAxes)
{
uint8_t tmpval = 0x00;
/* Read INT2_CFR register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_INT2_CFG_A);
/* Enable the selected interrupt */
tmpval |= (ITAxes | ITCombination);
/* Write value to MEMS INT2_CFR register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_INT2_CFG_A, tmpval);
}
/**
* @brief INT2 interrupt config
* @param ITCombination: Or or And combination
* ITAxes: axes to be enabled
* @retval None
*/
void LSM303DLHC_AccINT2InterruptDisable(uint8_t ITCombination, uint8_t ITAxes)
{
uint8_t tmpval = 0x00;
/* Read INT2_CFR register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_INT2_CFG_A);
/* Disable the selected interrupt */
tmpval &= ~(ITAxes | ITCombination);
/* Write value to MEMS INT2_CFR register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_INT2_CFG_A, tmpval);
}
/**
* @brief Click interrupt enable
* @param ITClick: the selected interrupt to enable
* @retval None
*/
void LSM303DLHC_AccClickITEnable(uint8_t ITClick)
{
uint8_t tmpval = 0x00;
/* Read CLICK_CFR register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CLICK_CFG_A);
/* Enable the selected interrupt */
tmpval |= ITClick;
/* Write value to MEMS CLICK CFG register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CLICK_CFG_A, tmpval);
/* Configure Click Threshold on Z axis */
tmpval = 0x0A;
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CLICK_THS_A, tmpval);
/* Configure Time Limit */
tmpval = 0x05;
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_TIME_LIMIT_A, tmpval);
/* Configure Latency */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_TIME_LATENCY_A, tmpval);
/* Configure Click Window */
tmpval = 0x32;
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_TIME_WINDOW_A, tmpval);
}
/**
* @brief Click interrupt disable
* @param ITClick: the selected click interrupt to disable
* @retval None
*/
void LSM303DLHC_AccClickITDisable(uint8_t ITClick)
{
uint8_t tmpval = 0x00;
/* Read CLICK_CFR register */
tmpval = COMPASSACCELERO_IO_Read(ACC_I2C_ADDRESS, LSM303DLHC_CLICK_CFG_A);
/* Disable the selected interrupt */
tmpval &= ~ITClick;
/* Write value to MEMS CLICK_CFR register */
COMPASSACCELERO_IO_Write(ACC_I2C_ADDRESS, LSM303DLHC_CLICK_CFG_A, tmpval);
}
/**
* @brief Click on Z axis interrupt config
* @param None
* @retval None
*/
void LSM303DLHC_AccZClickITConfig(void)
{
/* Configure low level IT config */
COMPASSACCELERO_IO_ITConfig();
/* Select click IT as INT1 interrupt */
LSM303DLHC_AccIT1Enable(LSM303DLHC_IT1_CLICK);
/* Enable High pass filter for click IT */
LSM303DLHC_AccFilterClickCmd(LSM303DLHC_HPF_CLICK_ENABLE);
/* Enable simple click IT on Z axis, */
LSM303DLHC_AccClickITEnable(LSM303DLHC_Z_SINGLE_CLICK);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,480 @@
/**
******************************************************************************
* @file lsm303dlhc.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the lsm303dlhc.c driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __LSM303DLHC_H
#define __LSM303DLHC_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/accelero.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup LSM303DLHC
* @{
*/
/** @defgroup LSM303DLHC_Exported_Types
* @{
*/
/**
* @}
*/
/******************************************************************************/
/*************************** START REGISTER MAPPING **************************/
/******************************************************************************/
/* Exported constant IO ------------------------------------------------------*/
#define ACC_I2C_ADDRESS 0x32
#define MAG_I2C_ADDRESS 0x3C
/* Acceleration Registers */
#define LSM303DLHC_WHO_AM_I_ADDR 0x0F /* device identification register */
#define LSM303DLHC_CTRL_REG1_A 0x20 /* Control register 1 acceleration */
#define LSM303DLHC_CTRL_REG2_A 0x21 /* Control register 2 acceleration */
#define LSM303DLHC_CTRL_REG3_A 0x22 /* Control register 3 acceleration */
#define LSM303DLHC_CTRL_REG4_A 0x23 /* Control register 4 acceleration */
#define LSM303DLHC_CTRL_REG5_A 0x24 /* Control register 5 acceleration */
#define LSM303DLHC_CTRL_REG6_A 0x25 /* Control register 6 acceleration */
#define LSM303DLHC_REFERENCE_A 0x26 /* Reference register acceleration */
#define LSM303DLHC_STATUS_REG_A 0x27 /* Status register acceleration */
#define LSM303DLHC_OUT_X_L_A 0x28 /* Output Register X acceleration */
#define LSM303DLHC_OUT_X_H_A 0x29 /* Output Register X acceleration */
#define LSM303DLHC_OUT_Y_L_A 0x2A /* Output Register Y acceleration */
#define LSM303DLHC_OUT_Y_H_A 0x2B /* Output Register Y acceleration */
#define LSM303DLHC_OUT_Z_L_A 0x2C /* Output Register Z acceleration */
#define LSM303DLHC_OUT_Z_H_A 0x2D /* Output Register Z acceleration */
#define LSM303DLHC_FIFO_CTRL_REG_A 0x2E /* Fifo control Register acceleration */
#define LSM303DLHC_FIFO_SRC_REG_A 0x2F /* Fifo src Register acceleration */
#define LSM303DLHC_INT1_CFG_A 0x30 /* Interrupt 1 configuration Register acceleration */
#define LSM303DLHC_INT1_SOURCE_A 0x31 /* Interrupt 1 source Register acceleration */
#define LSM303DLHC_INT1_THS_A 0x32 /* Interrupt 1 Threshold register acceleration */
#define LSM303DLHC_INT1_DURATION_A 0x33 /* Interrupt 1 DURATION register acceleration */
#define LSM303DLHC_INT2_CFG_A 0x34 /* Interrupt 2 configuration Register acceleration */
#define LSM303DLHC_INT2_SOURCE_A 0x35 /* Interrupt 2 source Register acceleration */
#define LSM303DLHC_INT2_THS_A 0x36 /* Interrupt 2 Threshold register acceleration */
#define LSM303DLHC_INT2_DURATION_A 0x37 /* Interrupt 2 DURATION register acceleration */
#define LSM303DLHC_CLICK_CFG_A 0x38 /* Click configuration Register acceleration */
#define LSM303DLHC_CLICK_SOURCE_A 0x39 /* Click 2 source Register acceleration */
#define LSM303DLHC_CLICK_THS_A 0x3A /* Click 2 Threshold register acceleration */
#define LSM303DLHC_TIME_LIMIT_A 0x3B /* Time Limit Register acceleration */
#define LSM303DLHC_TIME_LATENCY_A 0x3C /* Time Latency Register acceleration */
#define LSM303DLHC_TIME_WINDOW_A 0x3D /* Time window register acceleration */
/* Magnetic field Registers */
#define LSM303DLHC_CRA_REG_M 0x00 /* Control register A magnetic field */
#define LSM303DLHC_CRB_REG_M 0x01 /* Control register B magnetic field */
#define LSM303DLHC_MR_REG_M 0x02 /* Control register MR magnetic field */
#define LSM303DLHC_OUT_X_H_M 0x03 /* Output Register X magnetic field */
#define LSM303DLHC_OUT_X_L_M 0x04 /* Output Register X magnetic field */
#define LSM303DLHC_OUT_Z_H_M 0x05 /* Output Register Z magnetic field */
#define LSM303DLHC_OUT_Z_L_M 0x06 /* Output Register Z magnetic field */
#define LSM303DLHC_OUT_Y_H_M 0x07 /* Output Register Y magnetic field */
#define LSM303DLHC_OUT_Y_L_M 0x08 /* Output Register Y magnetic field */
#define LSM303DLHC_SR_REG_M 0x09 /* Status Register magnetic field */
#define LSM303DLHC_IRA_REG_M 0x0A /* IRA Register magnetic field */
#define LSM303DLHC_IRB_REG_M 0x0B /* IRB Register magnetic field */
#define LSM303DLHC_IRC_REG_M 0x0C /* IRC Register magnetic field */
#define LSM303DLHC_TEMP_OUT_H_M 0x31 /* Temperature Register magnetic field */
#define LSM303DLHC_TEMP_OUT_L_M 0x32 /* Temperature Register magnetic field */
/******************************************************************************/
/**************************** END REGISTER MAPPING ***************************/
/******************************************************************************/
#define I_AM_LMS303DLHC ((uint8_t)0x33)
/** @defgroup Acc_Power_Mode_selection
* @{
*/
#define LSM303DLHC_NORMAL_MODE ((uint8_t)0x00)
#define LSM303DLHC_LOWPOWER_MODE ((uint8_t)0x08)
/**
* @}
*/
/** @defgroup Acc_OutPut_DataRate_Selection
* @{
*/
#define LSM303DLHC_ODR_1_HZ ((uint8_t)0x10) /*!< Output Data Rate = 1 Hz */
#define LSM303DLHC_ODR_10_HZ ((uint8_t)0x20) /*!< Output Data Rate = 10 Hz */
#define LSM303DLHC_ODR_25_HZ ((uint8_t)0x30) /*!< Output Data Rate = 25 Hz */
#define LSM303DLHC_ODR_50_HZ ((uint8_t)0x40) /*!< Output Data Rate = 50 Hz */
#define LSM303DLHC_ODR_100_HZ ((uint8_t)0x50) /*!< Output Data Rate = 100 Hz */
#define LSM303DLHC_ODR_200_HZ ((uint8_t)0x60) /*!< Output Data Rate = 200 Hz */
#define LSM303DLHC_ODR_400_HZ ((uint8_t)0x70) /*!< Output Data Rate = 400 Hz */
#define LSM303DLHC_ODR_1620_HZ_LP ((uint8_t)0x80) /*!< Output Data Rate = 1620 Hz only in Low Power Mode */
#define LSM303DLHC_ODR_1344_HZ ((uint8_t)0x90) /*!< Output Data Rate = 1344 Hz in Normal mode and 5376 Hz in Low Power Mode */
/**
* @}
*/
/** @defgroup Acc_Axes_Selection
* @{
*/
#define LSM303DLHC_X_ENABLE ((uint8_t)0x01)
#define LSM303DLHC_Y_ENABLE ((uint8_t)0x02)
#define LSM303DLHC_Z_ENABLE ((uint8_t)0x04)
#define LSM303DLHC_AXES_ENABLE ((uint8_t)0x07)
#define LSM303DLHC_AXES_DISABLE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Acc_High_Resolution
* @{
*/
#define LSM303DLHC_HR_ENABLE ((uint8_t)0x08)
#define LSM303DLHC_HR_DISABLE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Acc_Full_Scale_Selection
* @{
*/
#define LSM303DLHC_FULLSCALE_2G ((uint8_t)0x00) /*!< <20>2 g */
#define LSM303DLHC_FULLSCALE_4G ((uint8_t)0x10) /*!< <20>4 g */
#define LSM303DLHC_FULLSCALE_8G ((uint8_t)0x20) /*!< <20>8 g */
#define LSM303DLHC_FULLSCALE_16G ((uint8_t)0x30) /*!< <20>16 g */
/**
* @}
*/
/** @defgroup Acc_Full_Scale_Selection
* @{
*/
#define LSM303DLHC_ACC_SENSITIVITY_2G ((uint8_t)1) /*!< accelerometer sensitivity with 2 g full scale [mg/LSB] */
#define LSM303DLHC_ACC_SENSITIVITY_4G ((uint8_t)2) /*!< accelerometer sensitivity with 4 g full scale [mg/LSB] */
#define LSM303DLHC_ACC_SENSITIVITY_8G ((uint8_t)4) /*!< accelerometer sensitivity with 8 g full scale [mg/LSB] */
#define LSM303DLHC_ACC_SENSITIVITY_16G ((uint8_t)12) /*!< accelerometer sensitivity with 12 g full scale [mg/LSB] */
/**
* @}
*/
/** @defgroup Acc_Block_Data_Update
* @{
*/
#define LSM303DLHC_BlockUpdate_Continous ((uint8_t)0x00) /*!< Continuos Update */
#define LSM303DLHC_BlockUpdate_Single ((uint8_t)0x80) /*!< Single Update: output registers not updated until MSB and LSB reading */
/**
* @}
*/
/** @defgroup Acc_Endian_Data_selection
* @{
*/
#define LSM303DLHC_BLE_LSB ((uint8_t)0x00) /*!< Little Endian: data LSB @ lower address */
#define LSM303DLHC_BLE_MSB ((uint8_t)0x40) /*!< Big Endian: data MSB @ lower address */
/**
* @}
*/
/** @defgroup Acc_Boot_Mode_selection
* @{
*/
#define LSM303DLHC_BOOT_NORMALMODE ((uint8_t)0x00)
#define LSM303DLHC_BOOT_REBOOTMEMORY ((uint8_t)0x80)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_Mode
* @{
*/
#define LSM303DLHC_HPM_NORMAL_MODE_RES ((uint8_t)0x00)
#define LSM303DLHC_HPM_REF_SIGNAL ((uint8_t)0x40)
#define LSM303DLHC_HPM_NORMAL_MODE ((uint8_t)0x80)
#define LSM303DLHC_HPM_AUTORESET_INT ((uint8_t)0xC0)
/**
* @}
*/
/** @defgroup Acc_High_Pass_CUT OFF_Frequency
* @{
*/
#define LSM303DLHC_HPFCF_8 ((uint8_t)0x00)
#define LSM303DLHC_HPFCF_16 ((uint8_t)0x10)
#define LSM303DLHC_HPFCF_32 ((uint8_t)0x20)
#define LSM303DLHC_HPFCF_64 ((uint8_t)0x30)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_status
* @{
*/
#define LSM303DLHC_HIGHPASSFILTER_DISABLE ((uint8_t)0x00)
#define LSM303DLHC_HIGHPASSFILTER_ENABLE ((uint8_t)0x08)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_Click_status
* @{
*/
#define LSM303DLHC_HPF_CLICK_DISABLE ((uint8_t)0x00)
#define LSM303DLHC_HPF_CLICK_ENABLE ((uint8_t)0x04)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_AOI1_status
* @{
*/
#define LSM303DLHC_HPF_AOI1_DISABLE ((uint8_t)0x00)
#define LSM303DLHC_HPF_AOI1_ENABLE ((uint8_t)0x01)
/**
* @}
*/
/** @defgroup Acc_High_Pass_Filter_AOI2_status
* @{
*/
#define LSM303DLHC_HPF_AOI2_DISABLE ((uint8_t)0x00)
#define LSM303DLHC_HPF_AOI2_ENABLE ((uint8_t)0x02)
/**
* @}
*/
/** @defgroup Acc_Interrupt1_Configuration_definition
* @{
*/
#define LSM303DLHC_IT1_CLICK ((uint8_t)0x80)
#define LSM303DLHC_IT1_AOI1 ((uint8_t)0x40)
#define LSM303DLHC_IT1_AOI2 ((uint8_t)0x20)
#define LSM303DLHC_IT1_DRY1 ((uint8_t)0x10)
#define LSM303DLHC_IT1_DRY2 ((uint8_t)0x08)
#define LSM303DLHC_IT1_WTM ((uint8_t)0x04)
#define LSM303DLHC_IT1_OVERRUN ((uint8_t)0x02)
/**
* @}
*/
/** @defgroup Acc_Interrupt2_Configuration_definition
* @{
*/
#define LSM303DLHC_IT2_CLICK ((uint8_t)0x80)
#define LSM303DLHC_IT2_INT1 ((uint8_t)0x40)
#define LSM303DLHC_IT2_INT2 ((uint8_t)0x20)
#define LSM303DLHC_IT2_BOOT ((uint8_t)0x10)
#define LSM303DLHC_IT2_ACT ((uint8_t)0x08)
#define LSM303DLHC_IT2_HLACTIVE ((uint8_t)0x02)
/**
* @}
*/
/** @defgroup Acc_INT_Combination_Status
* @{
*/
#define LSM303DLHC_OR_COMBINATION ((uint8_t)0x00) /*!< OR combination of enabled IRQs */
#define LSM303DLHC_AND_COMBINATION ((uint8_t)0x80) /*!< AND combination of enabled IRQs */
#define LSM303DLHC_MOV_RECOGNITION ((uint8_t)0x40) /*!< 6D movement recognition */
#define LSM303DLHC_POS_RECOGNITION ((uint8_t)0xC0) /*!< 6D position recognition */
/**
* @}
*/
/** @defgroup Acc_INT_Axes
* @{
*/
#define LSM303DLHC_Z_HIGH ((uint8_t)0x20) /*!< Z High enabled IRQs */
#define LSM303DLHC_Z_LOW ((uint8_t)0x10) /*!< Z low enabled IRQs */
#define LSM303DLHC_Y_HIGH ((uint8_t)0x08) /*!< Y High enabled IRQs */
#define LSM303DLHC_Y_LOW ((uint8_t)0x04) /*!< Y low enabled IRQs */
#define LSM303DLHC_X_HIGH ((uint8_t)0x02) /*!< X High enabled IRQs */
#define LSM303DLHC_X_LOW ((uint8_t)0x01) /*!< X low enabled IRQs */
/**
* @}
*/
/** @defgroup Acc_INT_Click
* @{
*/
#define LSM303DLHC_Z_DOUBLE_CLICK ((uint8_t)0x20) /*!< Z double click IRQs */
#define LSM303DLHC_Z_SINGLE_CLICK ((uint8_t)0x10) /*!< Z single click IRQs */
#define LSM303DLHC_Y_DOUBLE_CLICK ((uint8_t)0x08) /*!< Y double click IRQs */
#define LSM303DLHC_Y_SINGLE_CLICK ((uint8_t)0x04) /*!< Y single click IRQs */
#define LSM303DLHC_X_DOUBLE_CLICK ((uint8_t)0x02) /*!< X double click IRQs */
#define LSM303DLHC_X_SINGLE_CLICK ((uint8_t)0x01) /*!< X single click IRQs */
/**
* @}
*/
/** @defgroup Acc_INT1_Interrupt_status
* @{
*/
#define LSM303DLHC_INT1INTERRUPT_DISABLE ((uint8_t)0x00)
#define LSM303DLHC_INT1INTERRUPT_ENABLE ((uint8_t)0x80)
/**
* @}
*/
/** @defgroup Acc_INT1_Interrupt_ActiveEdge
* @{
*/
#define LSM303DLHC_INT1INTERRUPT_LOW_EDGE ((uint8_t)0x20)
#define LSM303DLHC_INT1INTERRUPT_HIGH_EDGE ((uint8_t)0x00)
/**
* @}
*/
/** @defgroup Mag_Data_Rate
* @{
*/
#define LSM303DLHC_ODR_0_75_HZ ((uint8_t) 0x00) /*!< Output Data Rate = 0.75 Hz */
#define LSM303DLHC_ODR_1_5_HZ ((uint8_t) 0x04) /*!< Output Data Rate = 1.5 Hz */
#define LSM303DLHC_ODR_3_0_HZ ((uint8_t) 0x08) /*!< Output Data Rate = 3 Hz */
#define LSM303DLHC_ODR_7_5_HZ ((uint8_t) 0x0C) /*!< Output Data Rate = 7.5 Hz */
#define LSM303DLHC_ODR_15_HZ ((uint8_t) 0x10) /*!< Output Data Rate = 15 Hz */
#define LSM303DLHC_ODR_30_HZ ((uint8_t) 0x14) /*!< Output Data Rate = 30 Hz */
#define LSM303DLHC_ODR_75_HZ ((uint8_t) 0x18) /*!< Output Data Rate = 75 Hz */
#define LSM303DLHC_ODR_220_HZ ((uint8_t) 0x1C) /*!< Output Data Rate = 220 Hz */
/**
* @}
*/
/** @defgroup Mag_Full_Scale
* @{
*/
#define LSM303DLHC_FS_1_3_GA ((uint8_t) 0x20) /*!< Full scale = <20>1.3 Gauss */
#define LSM303DLHC_FS_1_9_GA ((uint8_t) 0x40) /*!< Full scale = <20>1.9 Gauss */
#define LSM303DLHC_FS_2_5_GA ((uint8_t) 0x60) /*!< Full scale = <20>2.5 Gauss */
#define LSM303DLHC_FS_4_0_GA ((uint8_t) 0x80) /*!< Full scale = <20>4.0 Gauss */
#define LSM303DLHC_FS_4_7_GA ((uint8_t) 0xA0) /*!< Full scale = <20>4.7 Gauss */
#define LSM303DLHC_FS_5_6_GA ((uint8_t) 0xC0) /*!< Full scale = <20>5.6 Gauss */
#define LSM303DLHC_FS_8_1_GA ((uint8_t) 0xE0) /*!< Full scale = <20>8.1 Gauss */
/**
* @}
*/
/**
* @defgroup Magnetometer_Sensitivity
* @{
*/
#define LSM303DLHC_M_SENSITIVITY_XY_1_3Ga 1100 /*!< magnetometer X Y axes sensitivity for 1.3 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_XY_1_9Ga 855 /*!< magnetometer X Y axes sensitivity for 1.9 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_XY_2_5Ga 670 /*!< magnetometer X Y axes sensitivity for 2.5 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_XY_4Ga 450 /*!< magnetometer X Y axes sensitivity for 4 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_XY_4_7Ga 400 /*!< magnetometer X Y axes sensitivity for 4.7 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_XY_5_6Ga 330 /*!< magnetometer X Y axes sensitivity for 5.6 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_XY_8_1Ga 230 /*!< magnetometer X Y axes sensitivity for 8.1 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_Z_1_3Ga 980 /*!< magnetometer Z axis sensitivity for 1.3 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_Z_1_9Ga 760 /*!< magnetometer Z axis sensitivity for 1.9 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_Z_2_5Ga 600 /*!< magnetometer Z axis sensitivity for 2.5 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_Z_4Ga 400 /*!< magnetometer Z axis sensitivity for 4 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_Z_4_7Ga 355 /*!< magnetometer Z axis sensitivity for 4.7 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_Z_5_6Ga 295 /*!< magnetometer Z axis sensitivity for 5.6 Ga full scale [LSB/Ga] */
#define LSM303DLHC_M_SENSITIVITY_Z_8_1Ga 205 /*!< magnetometer Z axis sensitivity for 8.1 Ga full scale [LSB/Ga] */
/**
* @}
*/
/** @defgroup Mag_Working_Mode
* @{
*/
#define LSM303DLHC_CONTINUOS_CONVERSION ((uint8_t) 0x00) /*!< Continuous-Conversion Mode */
#define LSM303DLHC_SINGLE_CONVERSION ((uint8_t) 0x01) /*!< Single-Conversion Mode */
#define LSM303DLHC_SLEEP ((uint8_t) 0x02) /*!< Sleep Mode */
/**
* @}
*/
/** @defgroup Mag_Temperature_Sensor
* @{
*/
#define LSM303DLHC_TEMPSENSOR_ENABLE ((uint8_t) 0x80) /*!< Temp sensor Enable */
#define LSM303DLHC_TEMPSENSOR_DISABLE ((uint8_t) 0x00) /*!< Temp sensor Disable */
/**
* @}
*/
/** @defgroup LSM303DLHC_Exported_Functions
* @{
*/
/* ACC functions */
void LSM303DLHC_AccInit(uint16_t InitStruct);
void LSM303DLHC_AccDeInit(void);
uint8_t LSM303DLHC_AccReadID(void);
void LSM303DLHC_AccRebootCmd(void);
void LSM303DLHC_AccFilterConfig(uint8_t FilterStruct);
void LSM303DLHC_AccFilterCmd(uint8_t HighPassFilterState);
void LSM303DLHC_AccReadXYZ(int16_t* pData);
void LSM303DLHC_AccFilterClickCmd(uint8_t HighPassFilterClickState);
void LSM303DLHC_AccIT1Enable(uint8_t LSM303DLHC_IT);
void LSM303DLHC_AccIT1Disable(uint8_t LSM303DLHC_IT);
void LSM303DLHC_AccIT2Enable(uint8_t LSM303DLHC_IT);
void LSM303DLHC_AccIT2Disable(uint8_t LSM303DLHC_IT);
void LSM303DLHC_AccINT1InterruptEnable(uint8_t ITCombination, uint8_t ITAxes);
void LSM303DLHC_AccINT1InterruptDisable(uint8_t ITCombination, uint8_t ITAxes);
void LSM303DLHC_AccINT2InterruptEnable(uint8_t ITCombination, uint8_t ITAxes);
void LSM303DLHC_AccINT2InterruptDisable(uint8_t ITCombination, uint8_t ITAxes);
void LSM303DLHC_AccClickITEnable(uint8_t ITClick);
void LSM303DLHC_AccClickITDisable(uint8_t ITClick);
void LSM303DLHC_AccZClickITConfig(void);
/* COMPASS / ACCELERO IO functions */
void COMPASSACCELERO_IO_Init(void);
void COMPASSACCELERO_IO_ITConfig(void);
void COMPASSACCELERO_IO_Write(uint16_t DeviceAddr, uint8_t RegisterAddr, uint8_t Value);
uint8_t COMPASSACCELERO_IO_Read(uint16_t DeviceAddr, uint8_t RegisterAddr);
/* ACC driver structure */
extern ACCELERO_DrvTypeDef Lsm303dlhcDrv;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __LSM303DLHC_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for LSM6DSL Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-lsm6dsl-component-drivers"><small>Release Notes for</small> <mark>LSM6DSL Component Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the LSM6DSL component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 14-February-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release of LSM6DSL Accelerometer/Gyroscope sensor</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,376 @@
/**
******************************************************************************
* @file lsm6dsl.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the LSM6DSL
* accelero and gyro devices
******************************************************************************
* @attention
*
* <<h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "lsm6dsl.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup LSM6DSL LSM6DSL
* @{
*/
/** @defgroup LSM6DSL_Private_Variables LSM6DSL Private Variables
* @{
*/
ACCELERO_DrvTypeDef Lsm6dslAccDrv =
{
LSM6DSL_AccInit,
LSM6DSL_AccDeInit,
LSM6DSL_AccReadID,
0,
LSM6DSL_AccLowPower,
0,
0,
0,
0,
0,
0,
0,
LSM6DSL_AccReadXYZ
};
GYRO_DrvTypeDef Lsm6dslGyroDrv =
{
LSM6DSL_GyroInit,
LSM6DSL_GyroDeInit,
LSM6DSL_GyroReadID,
0,
LSM6DSL_GyroLowPower,
0,
0,
0,
0,
0,
0,
0,
LSM6DSL_GyroReadXYZAngRate
};
/**
* @}
*/
/** @defgroup LSM6DSL_ACC_Private_Functions LSM6DSL ACC Private Functions
* @{
*/
/**
* @brief Set LSM6DSL Accelerometer Initialization.
* @param InitStruct: Init parameters
*/
void LSM6DSL_AccInit(uint16_t InitStruct)
{
uint8_t ctrl = 0x00;
uint8_t tmp;
/* Read CTRL1_XL */
tmp = SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL1_XL);
/* Write value to ACC MEMS CTRL1_XL register: FS and Data Rate */
ctrl = (uint8_t) InitStruct;
tmp &= ~(0xFC);
tmp |= ctrl;
SENSOR_IO_Write(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL1_XL, tmp);
/* Read CTRL3_C */
tmp = SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL3_C);
/* Write value to ACC MEMS CTRL3_C register: BDU and Auto-increment */
ctrl = ((uint8_t) (InitStruct >> 8));
tmp &= ~(0x44);
tmp |= ctrl;
SENSOR_IO_Write(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL3_C, tmp);
}
/**
* @brief LSM6DSL Accelerometer De-initialization.
*/
void LSM6DSL_AccDeInit(void)
{
uint8_t ctrl = 0x00;
/* Read control register 1 value */
ctrl = SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL1_XL);
/* Clear ODR bits */
ctrl &= ~(LSM6DSL_ODR_BITPOSITION);
/* Set Power down */
ctrl |= LSM6DSL_ODR_POWER_DOWN;
/* write back control register */
SENSOR_IO_Write(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL1_XL, ctrl);
}
/**
* @brief Read LSM6DSL ID.
* @retval ID
*/
uint8_t LSM6DSL_AccReadID(void)
{
/* IO interface initialization */
SENSOR_IO_Init();
/* Read value at Who am I register address */
return (SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_WHO_AM_I_REG));
}
/**
* @brief Set/Unset Accelerometer in low power mode.
* @param status 0 means disable Low Power Mode, otherwise Low Power Mode is enabled
*/
void LSM6DSL_AccLowPower(uint16_t status)
{
uint8_t ctrl = 0x00;
/* Read CTRL6_C value */
ctrl = SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL6_C);
/* Clear Low Power Mode bit */
ctrl &= ~(0x10);
/* Set Low Power Mode */
if(status)
{
ctrl |= LSM6DSL_ACC_GYRO_LP_XL_ENABLED;
}else
{
ctrl |= LSM6DSL_ACC_GYRO_LP_XL_DISABLED;
}
/* write back control register */
SENSOR_IO_Write(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL6_C, ctrl);
}
/**
* @brief Read X, Y & Z Acceleration values
* @param pData: Data out pointer
*/
void LSM6DSL_AccReadXYZ(int16_t* pData)
{
int16_t pnRawData[3];
uint8_t ctrlx= 0;
uint8_t buffer[6];
uint8_t i = 0;
float sensitivity = 0;
/* Read the acceleration control register content */
ctrlx = SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL1_XL);
/* Read output register X, Y & Z acceleration */
SENSOR_IO_ReadMultiple(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_OUTX_L_XL, buffer, 6);
for(i=0; i<3; i++)
{
pnRawData[i]=((((uint16_t)buffer[2*i+1]) << 8) + (uint16_t)buffer[2*i]);
}
/* Normal mode */
/* Switch the sensitivity value set in the CRTL1_XL */
switch(ctrlx & 0x0C)
{
case LSM6DSL_ACC_FULLSCALE_2G:
sensitivity = LSM6DSL_ACC_SENSITIVITY_2G;
break;
case LSM6DSL_ACC_FULLSCALE_4G:
sensitivity = LSM6DSL_ACC_SENSITIVITY_4G;
break;
case LSM6DSL_ACC_FULLSCALE_8G:
sensitivity = LSM6DSL_ACC_SENSITIVITY_8G;
break;
case LSM6DSL_ACC_FULLSCALE_16G:
sensitivity = LSM6DSL_ACC_SENSITIVITY_16G;
break;
}
/* Obtain the mg value for the three axis */
for(i=0; i<3; i++)
{
pData[i]=( int16_t )(pnRawData[i] * sensitivity);
}
}
/**
* @}
*/
/** @defgroup LSM6DSL_GYRO_Private_Functions LSM6DSL GYRO Private Functions
* @{
*/
/**
* @brief Set LSM6DSL Gyroscope Initialization.
* @param InitStruct: pointer to a LSM6DSL_InitTypeDef structure
* that contains the configuration setting for the LSM6DSL.
*/
void LSM6DSL_GyroInit(uint16_t InitStruct)
{
uint8_t ctrl = 0x00;
uint8_t tmp;
/* Read CTRL2_G */
tmp = SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL2_G);
/* Write value to GYRO MEMS CTRL2_G register: FS and Data Rate */
ctrl = (uint8_t) InitStruct;
tmp &= ~(0xFC);
tmp |= ctrl;
SENSOR_IO_Write(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL2_G, tmp);
/* Read CTRL3_C */
tmp = SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL3_C);
/* Write value to GYRO MEMS CTRL3_C register: BDU and Auto-increment */
ctrl = ((uint8_t) (InitStruct >> 8));
tmp &= ~(0x44);
tmp |= ctrl;
SENSOR_IO_Write(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL3_C, tmp);
}
/**
* @brief LSM6DSL Gyroscope De-initialization
*/
void LSM6DSL_GyroDeInit(void)
{
uint8_t ctrl = 0x00;
/* Read control register 1 value */
ctrl = SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL2_G);
/* Clear ODR bits */
ctrl &= ~(LSM6DSL_ODR_BITPOSITION);
/* Set Power down */
ctrl |= LSM6DSL_ODR_POWER_DOWN;
/* write back control register */
SENSOR_IO_Write(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL2_G, ctrl);
}
/**
* @brief Read ID address of LSM6DSL
* @retval ID
*/
uint8_t LSM6DSL_GyroReadID(void)
{
/* IO interface initialization */
SENSOR_IO_Init();
/* Read value at Who am I register address */
return SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_WHO_AM_I_REG);
}
/**
* @brief Set/Unset LSM6DSL Gyroscope in low power mode
* @param status 0 means disable Low Power Mode, otherwise Low Power Mode is enabled
*/
void LSM6DSL_GyroLowPower(uint16_t status)
{
uint8_t ctrl = 0x00;
/* Read CTRL7_G value */
ctrl = SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL7_G);
/* Clear Low Power Mode bit */
ctrl &= ~(0x80);
/* Set Low Power Mode */
if(status)
{
ctrl |= LSM6DSL_ACC_GYRO_LP_G_ENABLED;
}else
{
ctrl |= LSM6DSL_ACC_GYRO_LP_G_DISABLED;
}
/* write back control register */
SENSOR_IO_Write(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL7_G, ctrl);
}
/**
* @brief Calculate the LSM6DSL angular data.
* @param pfData: Data out pointer
*/
void LSM6DSL_GyroReadXYZAngRate(float *pfData)
{
int16_t pnRawData[3];
uint8_t ctrlg= 0;
uint8_t buffer[6];
uint8_t i = 0;
float sensitivity = 0;
/* Read the gyro control register content */
ctrlg = SENSOR_IO_Read(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_CTRL2_G);
/* Read output register X, Y & Z acceleration */
SENSOR_IO_ReadMultiple(LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW, LSM6DSL_ACC_GYRO_OUTX_L_G, buffer, 6);
for(i=0; i<3; i++)
{
pnRawData[i]=((((uint16_t)buffer[2*i+1]) << 8) + (uint16_t)buffer[2*i]);
}
/* Normal mode */
/* Switch the sensitivity value set in the CRTL2_G */
switch(ctrlg & 0x0C)
{
case LSM6DSL_GYRO_FS_245:
sensitivity = LSM6DSL_GYRO_SENSITIVITY_245DPS;
break;
case LSM6DSL_GYRO_FS_500:
sensitivity = LSM6DSL_GYRO_SENSITIVITY_500DPS;
break;
case LSM6DSL_GYRO_FS_1000:
sensitivity = LSM6DSL_GYRO_SENSITIVITY_1000DPS;
break;
case LSM6DSL_GYRO_FS_2000:
sensitivity = LSM6DSL_GYRO_SENSITIVITY_2000DPS;
break;
}
/* Obtain the mg value for the three axis */
for(i=0; i<3; i++)
{
pfData[i]=( float )(pnRawData[i] * sensitivity);
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,328 @@
/**
******************************************************************************
* @file lsm6dsl.h
* @author MCD Application Team
* @brief LSM6DSL header driver file
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __LSM6DSL__H
#define __LSM6DSL__H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/accelero.h"
#include "../Common/gyro.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @addtogroup LSM6DSL
* @{
*/
/** @defgroup LSM6DSL_Exported_Constants LSM6DSL Exported Constants
* @{
*/
/************** I2C Address *****************/
#define LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW 0xD4 // SAD[0] = 0
#define LSM6DSL_ACC_GYRO_I2C_ADDRESS_HIGH 0xD6 // SAD[0] = 1
/************** Who am I *******************/
#define LSM6DSL_ACC_GYRO_WHO_AM_I 0x6A
/************** Device Register *******************/
#define LSM6DSL_ACC_GYRO_FUNC_CFG_ACCESS 0x01
#define LSM6DSL_ACC_GYRO_SENSOR_SYNC_TIME 0x04
#define LSM6DSL_ACC_GYRO_SENSOR_RES_RATIO 0x05
#define LSM6DSL_ACC_GYRO_FIFO_CTRL1 0x06
#define LSM6DSL_ACC_GYRO_FIFO_CTRL2 0x07
#define LSM6DSL_ACC_GYRO_FIFO_CTRL3 0x08
#define LSM6DSL_ACC_GYRO_FIFO_CTRL4 0x09
#define LSM6DSL_ACC_GYRO_FIFO_CTRL5 0x0A
#define LSM6DSL_ACC_GYRO_DRDY_PULSE_CFG_G 0x0B
#define LSM6DSL_ACC_GYRO_INT1_CTRL 0x0D
#define LSM6DSL_ACC_GYRO_INT2_CTRL 0x0E
#define LSM6DSL_ACC_GYRO_WHO_AM_I_REG 0x0F
#define LSM6DSL_ACC_GYRO_CTRL1_XL 0x10
#define LSM6DSL_ACC_GYRO_CTRL2_G 0x11
#define LSM6DSL_ACC_GYRO_CTRL3_C 0x12
#define LSM6DSL_ACC_GYRO_CTRL4_C 0x13
#define LSM6DSL_ACC_GYRO_CTRL5_C 0x14
#define LSM6DSL_ACC_GYRO_CTRL6_C 0x15
#define LSM6DSL_ACC_GYRO_CTRL7_G 0x16
#define LSM6DSL_ACC_GYRO_CTRL8_XL 0x17
#define LSM6DSL_ACC_GYRO_CTRL9_XL 0x18
#define LSM6DSL_ACC_GYRO_CTRL10_C 0x19
#define LSM6DSL_ACC_GYRO_MASTER_CONFIG 0x1A
#define LSM6DSL_ACC_GYRO_WAKE_UP_SRC 0x1B
#define LSM6DSL_ACC_GYRO_TAP_SRC 0x1C
#define LSM6DSL_ACC_GYRO_D6D_SRC 0x1D
#define LSM6DSL_ACC_GYRO_STATUS_REG 0x1E
#define LSM6DSL_ACC_GYRO_OUT_TEMP_L 0x20
#define LSM6DSL_ACC_GYRO_OUT_TEMP_H 0x21
#define LSM6DSL_ACC_GYRO_OUTX_L_G 0x22
#define LSM6DSL_ACC_GYRO_OUTX_H_G 0x23
#define LSM6DSL_ACC_GYRO_OUTY_L_G 0x24
#define LSM6DSL_ACC_GYRO_OUTY_H_G 0x25
#define LSM6DSL_ACC_GYRO_OUTZ_L_G 0x26
#define LSM6DSL_ACC_GYRO_OUTZ_H_G 0x27
#define LSM6DSL_ACC_GYRO_OUTX_L_XL 0x28
#define LSM6DSL_ACC_GYRO_OUTX_H_XL 0x29
#define LSM6DSL_ACC_GYRO_OUTY_L_XL 0x2A
#define LSM6DSL_ACC_GYRO_OUTY_H_XL 0x2B
#define LSM6DSL_ACC_GYRO_OUTZ_L_XL 0x2C
#define LSM6DSL_ACC_GYRO_OUTZ_H_XL 0x2D
#define LSM6DSL_ACC_GYRO_SENSORHUB1_REG 0x2E
#define LSM6DSL_ACC_GYRO_SENSORHUB2_REG 0x2F
#define LSM6DSL_ACC_GYRO_SENSORHUB3_REG 0x30
#define LSM6DSL_ACC_GYRO_SENSORHUB4_REG 0x31
#define LSM6DSL_ACC_GYRO_SENSORHUB5_REG 0x32
#define LSM6DSL_ACC_GYRO_SENSORHUB6_REG 0x33
#define LSM6DSL_ACC_GYRO_SENSORHUB7_REG 0x34
#define LSM6DSL_ACC_GYRO_SENSORHUB8_REG 0x35
#define LSM6DSL_ACC_GYRO_SENSORHUB9_REG 0x36
#define LSM6DSL_ACC_GYRO_SENSORHUB10_REG 0x37
#define LSM6DSL_ACC_GYRO_SENSORHUB11_REG 0x38
#define LSM6DSL_ACC_GYRO_SENSORHUB12_REG 0x39
#define LSM6DSL_ACC_GYRO_FIFO_STATUS1 0x3A
#define LSM6DSL_ACC_GYRO_FIFO_STATUS2 0x3B
#define LSM6DSL_ACC_GYRO_FIFO_STATUS3 0x3C
#define LSM6DSL_ACC_GYRO_FIFO_STATUS4 0x3D
#define LSM6DSL_ACC_GYRO_FIFO_DATA_OUT_L 0x3E
#define LSM6DSL_ACC_GYRO_FIFO_DATA_OUT_H 0x3F
#define LSM6DSL_ACC_GYRO_TIMESTAMP0_REG 0x40
#define LSM6DSL_ACC_GYRO_TIMESTAMP1_REG 0x41
#define LSM6DSL_ACC_GYRO_TIMESTAMP2_REG 0x42
#define LSM6DSL_ACC_GYRO_TIMESTAMP_L 0x49
#define LSM6DSL_ACC_GYRO_TIMESTAMP_H 0x4A
#define LSM6DSL_ACC_GYRO_STEP_COUNTER_L 0x4B
#define LSM6DSL_ACC_GYRO_STEP_COUNTER_H 0x4C
#define LSM6DSL_ACC_GYRO_SENSORHUB13_REG 0x4D
#define LSM6DSL_ACC_GYRO_SENSORHUB14_REG 0x4E
#define LSM6DSL_ACC_GYRO_SENSORHUB15_REG 0x4F
#define LSM6DSL_ACC_GYRO_SENSORHUB16_REG 0x50
#define LSM6DSL_ACC_GYRO_SENSORHUB17_REG 0x51
#define LSM6DSL_ACC_GYRO_SENSORHUB18_REG 0x52
#define LSM6DSL_ACC_GYRO_FUNC_SRC 0x53
#define LSM6DSL_ACC_GYRO_TAP_CFG1 0x58
#define LSM6DSL_ACC_GYRO_TAP_THS_6D 0x59
#define LSM6DSL_ACC_GYRO_INT_DUR2 0x5A
#define LSM6DSL_ACC_GYRO_WAKE_UP_THS 0x5B
#define LSM6DSL_ACC_GYRO_WAKE_UP_DUR 0x5C
#define LSM6DSL_ACC_GYRO_FREE_FALL 0x5D
#define LSM6DSL_ACC_GYRO_MD1_CFG 0x5E
#define LSM6DSL_ACC_GYRO_MD2_CFG 0x5F
#define LSM6DSL_ACC_GYRO_OUT_MAG_RAW_X_L 0x66
#define LSM6DSL_ACC_GYRO_OUT_MAG_RAW_X_H 0x67
#define LSM6DSL_ACC_GYRO_OUT_MAG_RAW_Y_L 0x68
#define LSM6DSL_ACC_GYRO_OUT_MAG_RAW_Y_H 0x69
#define LSM6DSL_ACC_GYRO_OUT_MAG_RAW_Z_L 0x6A
#define LSM6DSL_ACC_GYRO_OUT_MAG_RAW_Z_H 0x6B
#define LSM6DSL_ACC_GYRO_X_OFS_USR 0x73
#define LSM6DSL_ACC_GYRO_Y_OFS_USR 0x74
#define LSM6DSL_ACC_GYRO_Z_OFS_USR 0x75
/************** Embedded functions register mapping *******************/
#define LSM6DSL_ACC_GYRO_SLV0_ADD 0x02
#define LSM6DSL_ACC_GYRO_SLV0_SUBADD 0x03
#define LSM6DSL_ACC_GYRO_SLAVE0_CONFIG 0x04
#define LSM6DSL_ACC_GYRO_SLV1_ADD 0x05
#define LSM6DSL_ACC_GYRO_SLV1_SUBADD 0x06
#define LSM6DSL_ACC_GYRO_SLAVE1_CONFIG 0x07
#define LSM6DSL_ACC_GYRO_SLV2_ADD 0x08
#define LSM6DSL_ACC_GYRO_SLV2_SUBADD 0x09
#define LSM6DSL_ACC_GYRO_SLAVE2_CONFIG 0x0A
#define LSM6DSL_ACC_GYRO_SLV3_ADD 0x0B
#define LSM6DSL_ACC_GYRO_SLV3_SUBADD 0x0C
#define LSM6DSL_ACC_GYRO_SLAVE3_CONFIG 0x0D
#define LSM6DSL_ACC_GYRO_DATAWRITE_SRC_MODE_SUB_SLV0 0x0E
#define LSM6DSL_ACC_GYRO_CONFIG_PEDO_THS_MIN 0x0F
#define LSM6DSL_ACC_GYRO_SM_STEP_THS 0x13
#define LSM6DSL_ACC_GYRO_PEDO_DEB_REG 0x14
#define LSM6DSL_ACC_GYRO_STEP_COUNT_DELTA 0x15
#define LSM6DSL_ACC_GYRO_MAG_SI_XX 0x24
#define LSM6DSL_ACC_GYRO_MAG_SI_XY 0x25
#define LSM6DSL_ACC_GYRO_MAG_SI_XZ 0x26
#define LSM6DSL_ACC_GYRO_MAG_SI_YX 0x27
#define LSM6DSL_ACC_GYRO_MAG_SI_YY 0x28
#define LSM6DSL_ACC_GYRO_MAG_SI_YZ 0x29
#define LSM6DSL_ACC_GYRO_MAG_SI_ZX 0x2A
#define LSM6DSL_ACC_GYRO_MAG_SI_ZY 0x2B
#define LSM6DSL_ACC_GYRO_MAG_SI_ZZ 0x2C
#define LSM6DSL_ACC_GYRO_MAG_OFFX_L 0x2D
#define LSM6DSL_ACC_GYRO_MAG_OFFX_H 0x2E
#define LSM6DSL_ACC_GYRO_MAG_OFFY_L 0x2F
#define LSM6DSL_ACC_GYRO_MAG_OFFY_H 0x30
#define LSM6DSL_ACC_GYRO_MAG_OFFZ_L 0x31
#define LSM6DSL_ACC_GYRO_MAG_OFFZ_H 0x32
/* Accelero Full_ScaleSelection */
#define LSM6DSL_ACC_FULLSCALE_2G ((uint8_t)0x00) /*!< <20>2 g */
#define LSM6DSL_ACC_FULLSCALE_4G ((uint8_t)0x08) /*!< <20>4 g */
#define LSM6DSL_ACC_FULLSCALE_8G ((uint8_t)0x0C) /*!< <20>8 g */
#define LSM6DSL_ACC_FULLSCALE_16G ((uint8_t)0x04) /*!< <20>16 g */
/* Accelero Full Scale Sensitivity */
#define LSM6DSL_ACC_SENSITIVITY_2G ((float)0.061f) /*!< accelerometer sensitivity with 2 g full scale [mgauss/LSB] */
#define LSM6DSL_ACC_SENSITIVITY_4G ((float)0.122f) /*!< accelerometer sensitivity with 4 g full scale [mgauss/LSB] */
#define LSM6DSL_ACC_SENSITIVITY_8G ((float)0.244f) /*!< accelerometer sensitivity with 8 g full scale [mgauss/LSB] */
#define LSM6DSL_ACC_SENSITIVITY_16G ((float)0.488f) /*!< accelerometer sensitivity with 12 g full scale [mgauss/LSB] */
/* Accelero Power Mode selection */
#define LSM6DSL_ACC_GYRO_LP_XL_DISABLED ((uint8_t)0x00) /* LP disabled*/
#define LSM6DSL_ACC_GYRO_LP_XL_ENABLED ((uint8_t)0x10) /* LP enabled*/
/* Output Data Rate */
#define LSM6DSL_ODR_BITPOSITION ((uint8_t)0xF0) /*!< Output Data Rate bit position */
#define LSM6DSL_ODR_POWER_DOWN ((uint8_t)0x00) /* Power Down mode */
#define LSM6DSL_ODR_13Hz ((uint8_t)0x10) /* Low Power mode */
#define LSM6DSL_ODR_26Hz ((uint8_t)0x20) /* Low Power mode */
#define LSM6DSL_ODR_52Hz ((uint8_t)0x30) /* Low Power mode */
#define LSM6DSL_ODR_104Hz ((uint8_t)0x40) /* Normal mode */
#define LSM6DSL_ODR_208Hz ((uint8_t)0x50) /* Normal mode */
#define LSM6DSL_ODR_416Hz ((uint8_t)0x60) /* High Performance mode */
#define LSM6DSL_ODR_833Hz ((uint8_t)0x70) /* High Performance mode */
#define LSM6DSL_ODR_1660Hz ((uint8_t)0x80) /* High Performance mode */
#define LSM6DSL_ODR_3330Hz ((uint8_t)0x90) /* High Performance mode */
#define LSM6DSL_ODR_6660Hz ((uint8_t)0xA0) /* High Performance mode */
/* Gyro Full Scale Selection */
#define LSM6DSL_GYRO_FS_245 ((uint8_t)0x00)
#define LSM6DSL_GYRO_FS_500 ((uint8_t)0x04)
#define LSM6DSL_GYRO_FS_1000 ((uint8_t)0x08)
#define LSM6DSL_GYRO_FS_2000 ((uint8_t)0x0C)
/* Gyro Full Scale Sensitivity */
#define LSM6DSL_GYRO_SENSITIVITY_245DPS ((float)8.750f) /**< Sensitivity value for 245 dps full scale [mdps/LSB] */
#define LSM6DSL_GYRO_SENSITIVITY_500DPS ((float)17.50f) /**< Sensitivity value for 500 dps full scale [mdps/LSB] */
#define LSM6DSL_GYRO_SENSITIVITY_1000DPS ((float)35.00f) /**< Sensitivity value for 1000 dps full scale [mdps/LSB] */
#define LSM6DSL_GYRO_SENSITIVITY_2000DPS ((float)70.00f) /**< Sensitivity value for 2000 dps full scale [mdps/LSB] */
/* Gyro Power Mode selection */
#define LSM6DSL_ACC_GYRO_LP_G_DISABLED ((uint8_t)0x00) /* LP disabled*/
#define LSM6DSL_ACC_GYRO_LP_G_ENABLED ((uint8_t)0x80) /* LP enabled*/
/* Block Data Update */
#define LSM6DSL_BDU_CONTINUOS ((uint8_t)0x00)
#define LSM6DSL_BDU_BLOCK_UPDATE ((uint8_t)0x40)
/* Auto-increment */
#define LSM6DSL_ACC_GYRO_IF_INC_DISABLED ((uint8_t)0x00)
#define LSM6DSL_ACC_GYRO_IF_INC_ENABLED ((uint8_t)0x04)
/**
* @}
*/
/** @defgroup LSM6DSL_AccExported_Functions ACCELEROMETER Exported functions
* @{
*/
void LSM6DSL_AccInit(uint16_t InitStruct);
void LSM6DSL_AccDeInit(void);
uint8_t LSM6DSL_AccReadID(void);
void LSM6DSL_AccLowPower(uint16_t status);
void LSM6DSL_AccReadXYZ(int16_t* pData);
/**
* @}
*/
/** @defgroup LSM6DSL_AccImported_Globals ACCELEROMETER Imported Globals
* @{
*/
extern ACCELERO_DrvTypeDef Lsm6dslAccDrv;
/**
* @}
*/
/** @defgroup LSM6DSL_GyroExported_Functions GYROSCOPE Exported functions
* @{
*/
/* Sensor Configuration Functions */
void LSM6DSL_GyroInit(uint16_t InitStruct);
void LSM6DSL_GyroDeInit(void);
uint8_t LSM6DSL_GyroReadID(void);
void LSM6DSL_GyroLowPower(uint16_t status);
void LSM6DSL_GyroReadXYZAngRate(float *pfData);
/**
* @}
*/
/** @defgroup LSM6DSL_GyroImported_Globals GYROSCOPE Imported Globals
* @{
*/
/* Gyroscope driver structure */
extern GYRO_DrvTypeDef Lsm6dslGyroDrv;
/**
* @}
*/
/** @defgroup LSM6DSL_Imported_Functions LSM6DSL Imported Functions
* @{
*/
/* IO functions */
extern void SENSOR_IO_Init(void);
extern void SENSOR_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
extern uint8_t SENSOR_IO_Read(uint8_t Addr, uint8_t Reg);
extern uint16_t SENSOR_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
extern void SENSOR_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __LSM6DSL__H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,83 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for M24SR Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-m24sr-component-drivers"><small>Release Notes for</small> <mark>M24SR Component Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the M24SR component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.1.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section20" aria-hidden="true"> <label for="collapse-section20" aria-hidden="true">V1.1.0 / 21-April-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Calls BSP IO functions (NFC_IO_xxx) as unique low layer interface.</li>
<li>Made it fully independent by board and device (no external inclusion).</li>
<li>Adapt #defines and m24sr.h accordingly API.</li>
<li>Types renaming uc8 -&gt; uint8_t and uc16 -&gt; uint16_t.</li>
<li>Pass I2C device address as param to all functions that use it.</li>
<li>Remove goto instructions.</li>
<li>Moved here some functions: M24SR_RFConfig(), M24SR_SetI2CSynchroMode(), M24SR_IsAnswerReady().</li>
<li>Added M24SR_GPO_Callback().</li>
<li>Added M24SR_GPO_Callback().</li>
<li>Move lib_M24SR.c/h from driver to application.</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 20-October-2014</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>First official release by STM MMY division</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,157 @@
/**
******************************************************************************
* @file m24sr.h
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage M24SR
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __M24SR_H
#define __M24SR_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stdint.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @addtogroup M24SR
* @{
*/
/** @defgroup M24SR_Exported_Constants M24SR Exported Constants
* @{
*/
/* NFC IO specific config parameters */
#define NFC_IO_STATUS_SUCCESS (uint16_t) 0x0000
#define NFC_IO_ERROR_TIMEOUT (uint16_t) 0x0011
#define NFC_IO_TRIALS (uint32_t) 1 /* In case M24SR will reply ACK failed allow to perform retry */
/* Status and error code -----------------------------------------------------*/
#define M24SR_ACTION_COMPLETED (uint16_t) 0x9000
#define M24SR_STATUS_SUCCESS (uint16_t) 0x0000
#define M24SR_ERROR_DEFAULT (uint16_t) 0x0010
#define M24SR_ERROR_TIMEOUT (uint16_t) 0x0011
#define M24SR_ERROR_CRC (uint16_t) 0x0012
#define M24SR_ERROR_NACK (uint16_t) 0x0013
#define M24SR_ERROR_PARAMETER (uint16_t) 0x0014
#define M24SR_ERROR_NBATEMPT (uint16_t) 0x0015
#define M24SR_ERROR_NOACKNOWLEDGE (uint16_t) 0x0016
#define M24SR_ANSWER_TIMEOUT (uint32_t) 80 /* Timeout used by the component function NFC_IO_IsDeviceReady() */
#define M24SR_ANSWER_STABLE (uint8_t) 5 /* Loop repetition used by the component function NFC_IO_IsDeviceReady() */
/*-------------------------- GPO_Mode ----------------------------*/
#define M24SR_GPO_POLLING (uint8_t) 0x00 /* Normal I²C polling */
#define M24SR_GPO_SYNCHRO (uint8_t) 0x01 /* allow to use GPO polling as I2C synchronization */
#define M24SR_GPO_INTERRUPT (uint8_t) 0x02 /* allow to use GPO interrupt as I2C synchronization */
/*-------------------------- Password_Management ----------------------------*/
#define M24SR_READ_PWD (uint16_t) 0x0001
#define M24SR_WRITE_PWD (uint16_t) 0x0002
#define M24SR_I2C_PWD (uint16_t) 0x0003
/*-------------------------- Verify command answer ----------------------------*/
#define M24SR_PWD_NOT_NEEDED (uint16_t) 0x9000
#define M24SR_PWD_NEEDED (uint16_t) 0x6300
#define M24SR_PWD_CORRECT (uint16_t) 0x9000
/**
* @}
*/
/** @defgroup M24SR_Exported_FunctionsPrototypes M24SR Exported FunctionsPrototypes
* @{
*/
/* public function --------------------------------------------------------------------------*/
void M24SR_Init (uint16_t DeviceAddr, uint8_t GpoMode);
uint16_t M24SR_GetSession (uint16_t DeviceAddr);
uint16_t M24SR_KillSession (uint16_t DeviceAddr);
uint16_t M24SR_Deselect (uint16_t DeviceAddr);
uint16_t M24SR_SelectApplication (uint16_t DeviceAddr);
uint16_t M24SR_SelectCCfile (uint16_t DeviceAddr);
uint16_t M24SR_SelectNDEFfile (uint16_t DeviceAddr, uint16_t NDEFfileId);
uint16_t M24SR_SelectSystemfile (uint16_t DeviceAddr);
uint16_t M24SR_ReadBinary (uint16_t DeviceAddr, uint16_t Offset, uint8_t NbByteToRead, uint8_t *pBufferRead);
uint16_t M24SR_STReadBinary (uint16_t DeviceAddr, uint16_t Offset, uint8_t NbByteToRead, uint8_t *pBufferRead);
uint16_t M24SR_UpdateBinary (uint16_t DeviceAddr, uint16_t Offset, uint8_t NbByteToWrite, uint8_t *pDataToWrite);
uint16_t M24SR_Verify (uint16_t DeviceAddr, uint16_t uPwdId, uint8_t NbPwdByte, uint8_t *pPwd);
uint16_t M24SR_ChangeReferenceData (uint16_t DeviceAddr, uint16_t uPwdId, uint8_t *pPwd);
uint16_t M24SR_EnableVerificationRequirement (uint16_t DeviceAddr, uint16_t uReadOrWrite);
uint16_t M24SR_DisableVerificationRequirement (uint16_t DeviceAddr, uint16_t uReadOrWrite);
uint16_t M24SR_EnablePermanentState (uint16_t DeviceAddr, uint16_t uReadOrWrite);
uint16_t M24SR_DisablePermanentState (uint16_t DeviceAddr, uint16_t uReadOrWrite);
uint16_t M24SR_SendInterrupt (uint16_t DeviceAddr);
uint16_t M24SR_StateControl (uint16_t DeviceAddr, uint8_t uSetOrReset);
uint16_t M24SR_ManageI2CGPO (uint16_t DeviceAddr, uint8_t GPO_I2Cconfig);
uint16_t M24SR_ManageRFGPO (uint16_t DeviceAddr, uint8_t GPO_RFconfig);
void M24SR_RFConfig (uint8_t OnOffChoice);
void M24SR_GPO_Callback (void );
/**
* @}
*/
/** @defgroup M24SR_Imported_Functions M24SR Imported Functions
* @{
*/
/* IO functions */
extern void NFC_IO_Init(uint8_t GpoIrqEnable);
extern void NFC_IO_DeInit(void);
extern uint16_t NFC_IO_ReadMultiple (uint8_t Addr, uint8_t *pBuffer, uint16_t Length );
extern uint16_t NFC_IO_WriteMultiple (uint8_t Addr, uint8_t *pBuffer, uint16_t Length);
extern uint16_t NFC_IO_IsDeviceReady (uint8_t Addr, uint32_t Trials);
extern void NFC_IO_ReadState(uint8_t * pPinState);
extern void NFC_IO_RfDisable(uint8_t PinState);
extern void NFC_IO_Delay(uint32_t Delay);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __M24SR_H */
/******************* (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,126 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for MFXSTM32L152 Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-mfxstm32l152-component-drivers"><small>Release Notes for</small> <mark>MFXSTM32L152 Component Drivers</mark></h1>
<p>Copyright © 2015 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the MFXSTM32L152 component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V2.0.3 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section20" aria-hidden="true"> <label for="collapse-section20" aria-hidden="true">V2.0.2 / 25-October-2018</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V2.0.1 / 02-June-2017</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>Update comments to be used for PDSC generation</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section185" aria-hidden="true"> <label for="collapse-section185" aria-hidden="true">V2.0.0 / 24-June-2015</label>
<div>
<h2 id="main-changes-3">Main Changes</h2>
<ul>
<li>Add Shunt management of MFXSTM32L152 component
<ul>
<li>new mfxstm32l152_IDD_ConfigShuntNbLimit() and mfxstm32l152_IDD_GetShuntUsed() APIs</li>
</ul></li>
<li>Add mfxstm32l152_WriteReg() API</li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">NOTE</span></span></strong> This release must be used with BSP Common driver V4.0.0 or later</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.2.0 / 28-April-2015</label>
<div>
<h2 id="main-changes-4">Main Changes</h2>
<ul>
<li>mfxstm32l152_IO_Config(): remove unnecessary delay</li>
<li>mfxstm32l152_TS_DetectTouch(): improve TouchScreen speed</li>
<li>mfxstm32l152_IDD_Config(): add configuration of number of measure to be performed, with delay between 2 measures</li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">NOTE</span></span></strong><br />
This release must be used with BSP Common driver V3.0.0 or later</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section17" aria-hidden="true"> <label for="collapse-section17" aria-hidden="true">V1.1.0 / 10-February-2015</label>
<div>
<h2 id="main-changes-5">Main Changes</h2>
<ul>
<li>Low Power management of MFXSTM32L152 component:
<ul>
<li>New mfxstm32l152_DeInit() and mfxstm32l152_WakeUp() API</li>
<li>mfxstm32l152_LowPower() API completed to be MFXSTM32L152 in Standby mode</li>
</ul></li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">NOTE</span></span></strong><br />
This release must be used with BSP Common driver V2.2.0 or later</p>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section16" aria-hidden="true"> <label for="collapse-section16" aria-hidden="true">V1.0.0 / 05-February-2014</label>
<div>
<h2 id="main-changes-6">Main Changes</h2>
<ul>
<li>First official release of MFXSTM32L152 IO Expander component driver.</li>
</ul>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">NOTE</span></span></strong><br />
This release must be used with BSP Common driver V2.1.0 or later</p>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,650 @@
/**
******************************************************************************
* @file mfxstm32l152.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the
* mfxstm32l152.c IO expander driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MFXSTM32L152_H
#define __MFXSTM32L152_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/ts.h"
#include "../Common/io.h"
#include "../Common/idd.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup MFXSTM32L152
* @{
*/
/* Exported types ------------------------------------------------------------*/
/** @defgroup MFXSTM32L152_Exported_Types
* @{
*/
typedef struct
{
uint8_t SYS_CTRL;
uint8_t ERROR_SRC;
uint8_t ERROR_MSG;
uint8_t IRQ_OUT;
uint8_t IRQ_SRC_EN;
uint8_t IRQ_PENDING;
uint8_t IDD_CTRL;
uint8_t IDD_PRE_DELAY;
uint8_t IDD_SHUNT0_MSB;
uint8_t IDD_SHUNT0_LSB;
uint8_t IDD_SHUNT1_MSB;
uint8_t IDD_SHUNT1_LSB;
uint8_t IDD_SHUNT2_MSB;
uint8_t IDD_SHUNT2_LSB;
uint8_t IDD_SHUNT3_MSB;
uint8_t IDD_SHUNT3_LSB;
uint8_t IDD_SHUNT4_MSB;
uint8_t IDD_SHUNT4_LSB;
uint8_t IDD_GAIN_MSB;
uint8_t IDD_GAIN_LSB;
uint8_t IDD_VDD_MIN_MSB;
uint8_t IDD_VDD_MIN_LSB;
uint8_t IDD_VALUE_MSB;
uint8_t IDD_VALUE_MID;
uint8_t IDD_VALUE_LSB;
uint8_t IDD_CAL_OFFSET_MSB;
uint8_t IDD_CAL_OFFSET_LSB;
uint8_t IDD_SHUNT_USED;
}IDD_dbgTypeDef;
/**
* @}
*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup MFXSTM32L152_Exported_Constants
* @{
*/
/**
* @brief MFX COMMON defines
*/
/**
* @brief Register address: chip IDs (R)
*/
#define MFXSTM32L152_REG_ADR_ID ((uint8_t)0x00)
/**
* @brief Register address: chip FW_VERSION (R)
*/
#define MFXSTM32L152_REG_ADR_FW_VERSION_MSB ((uint8_t)0x01)
#define MFXSTM32L152_REG_ADR_FW_VERSION_LSB ((uint8_t)0x00)
/**
* @brief Register address: System Control Register (R/W)
*/
#define MFXSTM32L152_REG_ADR_SYS_CTRL ((uint8_t)0x40)
/**
* @brief Register address: Vdd monitoring (R)
*/
#define MFXSTM32L152_REG_ADR_VDD_REF_MSB ((uint8_t)0x06)
#define MFXSTM32L152_REG_ADR_VDD_REF_LSB ((uint8_t)0x07)
/**
* @brief Register address: Error source
*/
#define MFXSTM32L152_REG_ADR_ERROR_SRC ((uint8_t)0x03)
/**
* @brief Register address: Error Message
*/
#define MFXSTM32L152_REG_ADR_ERROR_MSG ((uint8_t)0x04)
/**
* @brief Reg Addr IRQs: to config the pin that informs Main MCU that MFX events appear
*/
#define MFXSTM32L152_REG_ADR_MFX_IRQ_OUT ((uint8_t)0x41)
/**
* @brief Reg Addr IRQs: to select the events which activate the MFXSTM32L152_IRQ_OUT signal
*/
#define MFXSTM32L152_REG_ADR_IRQ_SRC_EN ((uint8_t)0x42)
/**
* @brief Reg Addr IRQs: the Main MCU must read the IRQ_PENDING register to know the interrupt reason
*/
#define MFXSTM32L152_REG_ADR_IRQ_PENDING ((uint8_t)0x08)
/**
* @brief Reg Addr IRQs: the Main MCU must acknowledge it thanks to a writing access to the IRQ_ACK register
*/
#define MFXSTM32L152_REG_ADR_IRQ_ACK ((uint8_t)0x44)
/**
* @brief MFXSTM32L152_REG_ADR_ID choices
*/
#define MFXSTM32L152_ID_1 ((uint8_t)0x7B)
#define MFXSTM32L152_ID_2 ((uint8_t)0x79)
/**
* @brief MFXSTM32L152_REG_ADR_SYS_CTRL choices
*/
#define MFXSTM32L152_SWRST ((uint8_t)0x80)
#define MFXSTM32L152_STANDBY ((uint8_t)0x40)
#define MFXSTM32L152_ALTERNATE_GPIO_EN ((uint8_t)0x08) /* by the way if IDD and TS are enabled they take automatically the AF pins*/
#define MFXSTM32L152_IDD_EN ((uint8_t)0x04)
#define MFXSTM32L152_TS_EN ((uint8_t)0x02)
#define MFXSTM32L152_GPIO_EN ((uint8_t)0x01)
/**
* @brief MFXSTM32L152_REG_ADR_ERROR_SRC choices
*/
#define MFXSTM32L152_IDD_ERROR_SRC ((uint8_t)0x04) /* Error raised by Idd */
#define MFXSTM32L152_TS_ERROR_SRC ((uint8_t)0x02) /* Error raised by Touch Screen */
#define MFXSTM32L152_GPIO_ERROR_SRC ((uint8_t)0x01) /* Error raised by Gpio */
/**
* @brief MFXSTM32L152_REG_ADR_MFX_IRQ_OUT choices
*/
#define MFXSTM32L152_OUT_PIN_TYPE_OPENDRAIN ((uint8_t)0x00)
#define MFXSTM32L152_OUT_PIN_TYPE_PUSHPULL ((uint8_t)0x01)
#define MFXSTM32L152_OUT_PIN_POLARITY_LOW ((uint8_t)0x00)
#define MFXSTM32L152_OUT_PIN_POLARITY_HIGH ((uint8_t)0x02)
/**
* @brief REG_ADR_IRQ_SRC_EN, REG_ADR_IRQ_PENDING & REG_ADR_IRQ_ACK choices
*/
#define MFXSTM32L152_IRQ_TS_OVF ((uint8_t)0x80) /* TouchScreen FIFO Overflow irq*/
#define MFXSTM32L152_IRQ_TS_FULL ((uint8_t)0x40) /* TouchScreen FIFO Full irq*/
#define MFXSTM32L152_IRQ_TS_TH ((uint8_t)0x20) /* TouchScreen FIFO threshold triggered irq*/
#define MFXSTM32L152_IRQ_TS_NE ((uint8_t)0x10) /* TouchScreen FIFO Not Empty irq*/
#define MFXSTM32L152_IRQ_TS_DET ((uint8_t)0x08) /* TouchScreen Detect irq*/
#define MFXSTM32L152_IRQ_ERROR ((uint8_t)0x04) /* Error message from MFXSTM32L152 firmware irq */
#define MFXSTM32L152_IRQ_IDD ((uint8_t)0x02) /* IDD function irq */
#define MFXSTM32L152_IRQ_GPIO ((uint8_t)0x01) /* General GPIO irq (only for SRC_EN and PENDING) */
#define MFXSTM32L152_IRQ_ALL ((uint8_t)0xFF) /* All global interrupts */
#define MFXSTM32L152_IRQ_TS (MFXSTM32L152_IRQ_TS_DET | MFXSTM32L152_IRQ_TS_NE | MFXSTM32L152_IRQ_TS_TH | MFXSTM32L152_IRQ_TS_FULL | MFXSTM32L152_IRQ_TS_OVF )
/**
* @brief GPIO: 24 programmable input/output called MFXSTM32L152_GPIO[23:0] are provided
*/
/**
* @brief Reg addr: GPIO DIRECTION (R/W): GPIO pins direction: (0) input, (1) output.
*/
#define MFXSTM32L152_REG_ADR_GPIO_DIR1 ((uint8_t)0x60) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_GPIO_DIR2 ((uint8_t)0x61) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_GPIO_DIR3 ((uint8_t)0x62) /* agpio [0:7] */
/**
* @brief Reg addr: GPIO TYPE (R/W): If GPIO in output: (0) output push pull, (1) output open drain.
* If GPIO in input: (0) input without pull resistor, (1) input with pull resistor.
*/
#define MFXSTM32L152_REG_ADR_GPIO_TYPE1 ((uint8_t)0x64) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_GPIO_TYPE2 ((uint8_t)0x65) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_GPIO_TYPE3 ((uint8_t)0x66) /* agpio [0:7] */
/**
* @brief Reg addr: GPIO PULL_UP_PULL_DOWN (R/W): discussion open with Jean Claude
*/
#define MFXSTM32L152_REG_ADR_GPIO_PUPD1 ((uint8_t)0x68) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_GPIO_PUPD2 ((uint8_t)0x69) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_GPIO_PUPD3 ((uint8_t)0x6A) /* agpio [0:7] */
/**
* @brief Reg addr: GPIO SET (W): When GPIO is in output mode, write (1) puts the corresponding GPO in High level.
*/
#define MFXSTM32L152_REG_ADR_GPO_SET1 ((uint8_t)0x6C) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_GPO_SET2 ((uint8_t)0x6D) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_GPO_SET3 ((uint8_t)0x6E) /* agpio [0:7] */
/**
* @brief Reg addr: GPIO CLEAR (W): When GPIO is in output mode, write (1) puts the corresponding GPO in Low level.
*/
#define MFXSTM32L152_REG_ADR_GPO_CLR1 ((uint8_t)0x70) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_GPO_CLR2 ((uint8_t)0x71) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_GPO_CLR3 ((uint8_t)0x72) /* agpio [0:7] */
/**
* @brief Reg addr: GPIO STATE (R): Give state of the GPIO pin.
*/
#define MFXSTM32L152_REG_ADR_GPIO_STATE1 ((uint8_t)0x10) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_GPIO_STATE2 ((uint8_t)0x11) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_GPIO_STATE3 ((uint8_t)0x12) /* agpio [0:7] */
/**
* @brief GPIO IRQ_GPIs
*/
/* GPIOs can INDIVIDUALLY generate interruption to the Main MCU thanks to the MFXSTM32L152_IRQ_OUT signal */
/* the general MFXSTM32L152_IRQ_GPIO_SRC_EN shall be enabled too */
/**
* @brief GPIO IRQ_GPI_SRC1/2/3 (R/W): registers enable or not the feature to generate irq
*/
#define MFXSTM32L152_REG_ADR_IRQ_GPI_SRC1 ((uint8_t)0x48) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_IRQ_GPI_SRC2 ((uint8_t)0x49) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_IRQ_GPI_SRC3 ((uint8_t)0x4A) /* agpio [0:7] */
/**
* @brief GPIO IRQ_GPI_EVT1/2/3 (R/W): Irq generated on level (0) or edge (1).
*/
#define MFXSTM32L152_REG_ADR_IRQ_GPI_EVT1 ((uint8_t)0x4C) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_IRQ_GPI_EVT2 ((uint8_t)0x4D) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_IRQ_GPI_EVT3 ((uint8_t)0x4E) /* agpio [0:7] */
/**
* @brief GPIO IRQ_GPI_TYPE1/2/3 (R/W): Irq generated on (0) : Low level or Falling edge. (1) : High level or Rising edge.
*/
#define MFXSTM32L152_REG_ADR_IRQ_GPI_TYPE1 ((uint8_t)0x50) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_IRQ_GPI_TYPE2 ((uint8_t)0x51) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_IRQ_GPI_TYPE3 ((uint8_t)0x52) /* agpio [0:7] */
/**
* @brief GPIO IRQ_GPI_PENDING1/2/3 (R): irq occurs
*/
#define MFXSTM32L152_REG_ADR_IRQ_GPI_PENDING1 ((uint8_t)0x0C) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_IRQ_GPI_PENDING2 ((uint8_t)0x0D) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_IRQ_GPI_PENDING3 ((uint8_t)0x0E) /* agpio [0:7] */
/**
* @brief GPIO IRQ_GPI_ACK1/2/3 (W): Write (1) to acknowledge IRQ event
*/
#define MFXSTM32L152_REG_ADR_IRQ_GPI_ACK1 ((uint8_t)0x54) /* gpio [0:7] */
#define MFXSTM32L152_REG_ADR_IRQ_GPI_ACK2 ((uint8_t)0x55) /* gpio [8:15] */
#define MFXSTM32L152_REG_ADR_IRQ_GPI_ACK3 ((uint8_t)0x56) /* agpio [0:7] */
/**
* @brief GPIO: IO Pins definition
*/
#define MFXSTM32L152_GPIO_PIN_0 ((uint32_t)0x0001)
#define MFXSTM32L152_GPIO_PIN_1 ((uint32_t)0x0002)
#define MFXSTM32L152_GPIO_PIN_2 ((uint32_t)0x0004)
#define MFXSTM32L152_GPIO_PIN_3 ((uint32_t)0x0008)
#define MFXSTM32L152_GPIO_PIN_4 ((uint32_t)0x0010)
#define MFXSTM32L152_GPIO_PIN_5 ((uint32_t)0x0020)
#define MFXSTM32L152_GPIO_PIN_6 ((uint32_t)0x0040)
#define MFXSTM32L152_GPIO_PIN_7 ((uint32_t)0x0080)
#define MFXSTM32L152_GPIO_PIN_8 ((uint32_t)0x0100)
#define MFXSTM32L152_GPIO_PIN_9 ((uint32_t)0x0200)
#define MFXSTM32L152_GPIO_PIN_10 ((uint32_t)0x0400)
#define MFXSTM32L152_GPIO_PIN_11 ((uint32_t)0x0800)
#define MFXSTM32L152_GPIO_PIN_12 ((uint32_t)0x1000)
#define MFXSTM32L152_GPIO_PIN_13 ((uint32_t)0x2000)
#define MFXSTM32L152_GPIO_PIN_14 ((uint32_t)0x4000)
#define MFXSTM32L152_GPIO_PIN_15 ((uint32_t)0x8000)
#define MFXSTM32L152_GPIO_PIN_16 ((uint32_t)0x010000)
#define MFXSTM32L152_GPIO_PIN_17 ((uint32_t)0x020000)
#define MFXSTM32L152_GPIO_PIN_18 ((uint32_t)0x040000)
#define MFXSTM32L152_GPIO_PIN_19 ((uint32_t)0x080000)
#define MFXSTM32L152_GPIO_PIN_20 ((uint32_t)0x100000)
#define MFXSTM32L152_GPIO_PIN_21 ((uint32_t)0x200000)
#define MFXSTM32L152_GPIO_PIN_22 ((uint32_t)0x400000)
#define MFXSTM32L152_GPIO_PIN_23 ((uint32_t)0x800000)
#define MFXSTM32L152_AGPIO_PIN_0 MFXSTM32L152_GPIO_PIN_16
#define MFXSTM32L152_AGPIO_PIN_1 MFXSTM32L152_GPIO_PIN_17
#define MFXSTM32L152_AGPIO_PIN_2 MFXSTM32L152_GPIO_PIN_18
#define MFXSTM32L152_AGPIO_PIN_3 MFXSTM32L152_GPIO_PIN_19
#define MFXSTM32L152_AGPIO_PIN_4 MFXSTM32L152_GPIO_PIN_20
#define MFXSTM32L152_AGPIO_PIN_5 MFXSTM32L152_GPIO_PIN_21
#define MFXSTM32L152_AGPIO_PIN_6 MFXSTM32L152_GPIO_PIN_22
#define MFXSTM32L152_AGPIO_PIN_7 MFXSTM32L152_GPIO_PIN_23
#define MFXSTM32L152_GPIO_PINS_ALL ((uint32_t)0xFFFFFF)
/**
* @brief GPIO: constant
*/
#define MFXSTM32L152_GPIO_DIR_IN ((uint8_t)0x0)
#define MFXSTM32L152_GPIO_DIR_OUT ((uint8_t)0x1)
#define MFXSTM32L152_IRQ_GPI_EVT_LEVEL ((uint8_t)0x0)
#define MFXSTM32L152_IRQ_GPI_EVT_EDGE ((uint8_t)0x1)
#define MFXSTM32L152_IRQ_GPI_TYPE_LLFE ((uint8_t)0x0) /* Low Level Falling Edge */
#define MFXSTM32L152_IRQ_GPI_TYPE_HLRE ((uint8_t)0x1) /*High Level Raising Edge */
#define MFXSTM32L152_GPI_WITHOUT_PULL_RESISTOR ((uint8_t)0x0)
#define MFXSTM32L152_GPI_WITH_PULL_RESISTOR ((uint8_t)0x1)
#define MFXSTM32L152_GPO_PUSH_PULL ((uint8_t)0x0)
#define MFXSTM32L152_GPO_OPEN_DRAIN ((uint8_t)0x1)
#define MFXSTM32L152_GPIO_PULL_DOWN ((uint8_t)0x0)
#define MFXSTM32L152_GPIO_PULL_UP ((uint8_t)0x1)
/**
* @brief TOUCH SCREEN Registers
*/
/**
* @brief Touch Screen Registers
*/
#define MFXSTM32L152_TS_SETTLING ((uint8_t)0xA0)
#define MFXSTM32L152_TS_TOUCH_DET_DELAY ((uint8_t)0xA1)
#define MFXSTM32L152_TS_AVE ((uint8_t)0xA2)
#define MFXSTM32L152_TS_TRACK ((uint8_t)0xA3)
#define MFXSTM32L152_TS_FIFO_TH ((uint8_t)0xA4)
#define MFXSTM32L152_TS_FIFO_STA ((uint8_t)0x20)
#define MFXSTM32L152_TS_FIFO_LEVEL ((uint8_t)0x21)
#define MFXSTM32L152_TS_XY_DATA ((uint8_t)0x24)
/**
* @brief TS registers masks
*/
#define MFXSTM32L152_TS_CTRL_STATUS ((uint8_t)0x08)
#define MFXSTM32L152_TS_CLEAR_FIFO ((uint8_t)0x80)
/**
* @brief Register address: Idd control register (R/W)
*/
#define MFXSTM32L152_REG_ADR_IDD_CTRL ((uint8_t)0x80)
/**
* @brief Register address: Idd pre delay register (R/W)
*/
#define MFXSTM32L152_REG_ADR_IDD_PRE_DELAY ((uint8_t)0x81)
/**
* @brief Register address: Idd Shunt registers (R/W)
*/
#define MFXSTM32L152_REG_ADR_IDD_SHUNT0_MSB ((uint8_t)0x82)
#define MFXSTM32L152_REG_ADR_IDD_SHUNT0_LSB ((uint8_t)0x83)
#define MFXSTM32L152_REG_ADR_IDD_SHUNT1_MSB ((uint8_t)0x84)
#define MFXSTM32L152_REG_ADR_IDD_SHUNT1_LSB ((uint8_t)0x85)
#define MFXSTM32L152_REG_ADR_IDD_SHUNT2_MSB ((uint8_t)0x86)
#define MFXSTM32L152_REG_ADR_IDD_SHUNT2_LSB ((uint8_t)0x87)
#define MFXSTM32L152_REG_ADR_IDD_SHUNT3_MSB ((uint8_t)0x88)
#define MFXSTM32L152_REG_ADR_IDD_SHUNT3_LSB ((uint8_t)0x89)
#define MFXSTM32L152_REG_ADR_IDD_SHUNT4_MSB ((uint8_t)0x8A)
#define MFXSTM32L152_REG_ADR_IDD_SHUNT4_LSB ((uint8_t)0x8B)
/**
* @brief Register address: Idd ampli gain register (R/W)
*/
#define MFXSTM32L152_REG_ADR_IDD_GAIN_MSB ((uint8_t)0x8C)
#define MFXSTM32L152_REG_ADR_IDD_GAIN_LSB ((uint8_t)0x8D)
/**
* @brief Register address: Idd VDD min register (R/W)
*/
#define MFXSTM32L152_REG_ADR_IDD_VDD_MIN_MSB ((uint8_t)0x8E)
#define MFXSTM32L152_REG_ADR_IDD_VDD_MIN_LSB ((uint8_t)0x8F)
/**
* @brief Register address: Idd value register (R)
*/
#define MFXSTM32L152_REG_ADR_IDD_VALUE_MSB ((uint8_t)0x14)
#define MFXSTM32L152_REG_ADR_IDD_VALUE_MID ((uint8_t)0x15)
#define MFXSTM32L152_REG_ADR_IDD_VALUE_LSB ((uint8_t)0x16)
/**
* @brief Register address: Idd calibration offset register (R)
*/
#define MFXSTM32L152_REG_ADR_IDD_CAL_OFFSET_MSB ((uint8_t)0x18)
#define MFXSTM32L152_REG_ADR_IDD_CAL_OFFSET_LSB ((uint8_t)0x19)
/**
* @brief Register address: Idd shunt used offset register (R)
*/
#define MFXSTM32L152_REG_ADR_IDD_SHUNT_USED ((uint8_t)0x1A)
/**
* @brief Register address: shunt stabilisation delay registers (R/W)
*/
#define MFXSTM32L152_REG_ADR_IDD_SH0_STABILIZATION ((uint8_t)0x90)
#define MFXSTM32L152_REG_ADR_IDD_SH1_STABILIZATION ((uint8_t)0x91)
#define MFXSTM32L152_REG_ADR_IDD_SH2_STABILIZATION ((uint8_t)0x92)
#define MFXSTM32L152_REG_ADR_IDD_SH3_STABILIZATION ((uint8_t)0x93)
#define MFXSTM32L152_REG_ADR_IDD_SH4_STABILIZATION ((uint8_t)0x94)
/**
* @brief Register address: Idd number of measurements register (R/W)
*/
#define MFXSTM32L152_REG_ADR_IDD_NBR_OF_MEAS ((uint8_t)0x96)
/**
* @brief Register address: Idd delta delay between 2 measurements register (R/W)
*/
#define MFXSTM32L152_REG_ADR_IDD_MEAS_DELTA_DELAY ((uint8_t)0x97)
/**
* @brief Register address: Idd number of shunt on board register (R/W)
*/
#define MFXSTM32L152_REG_ADR_IDD_SHUNTS_ON_BOARD ((uint8_t)0x98)
/** @defgroup IDD_Control_Register_Defines IDD Control Register Defines
* @{
*/
/**
* @brief IDD control register masks
*/
#define MFXSTM32L152_IDD_CTRL_REQ ((uint8_t)0x01)
#define MFXSTM32L152_IDD_CTRL_SHUNT_NB ((uint8_t)0x0E)
#define MFXSTM32L152_IDD_CTRL_VREF_DIS ((uint8_t)0x40)
#define MFXSTM32L152_IDD_CTRL_CAL_DIS ((uint8_t)0x80)
/**
* @brief IDD Shunt Number
*/
#define MFXSTM32L152_IDD_SHUNT_NB_1 ((uint8_t) 0x01)
#define MFXSTM32L152_IDD_SHUNT_NB_2 ((uint8_t) 0x02)
#define MFXSTM32L152_IDD_SHUNT_NB_3 ((uint8_t) 0x03)
#define MFXSTM32L152_IDD_SHUNT_NB_4 ((uint8_t) 0x04)
#define MFXSTM32L152_IDD_SHUNT_NB_5 ((uint8_t) 0x05)
/**
* @brief Vref Measurement
*/
#define MFXSTM32L152_IDD_VREF_AUTO_MEASUREMENT_ENABLE ((uint8_t) 0x00)
#define MFXSTM32L152_IDD_VREF_AUTO_MEASUREMENT_DISABLE ((uint8_t) 0x70)
/**
* @brief IDD Calibration
*/
#define MFXSTM32L152_IDD_AUTO_CALIBRATION_ENABLE ((uint8_t) 0x00)
#define MFXSTM32L152_IDD_AUTO_CALIBRATION_DISABLE ((uint8_t) 0x80)
/**
* @}
*/
/** @defgroup IDD_PreDelay_Defines IDD PreDelay Defines
* @{
*/
/**
* @brief IDD PreDelay masks
*/
#define MFXSTM32L152_IDD_PREDELAY_UNIT ((uint8_t) 0x80)
#define MFXSTM32L152_IDD_PREDELAY_VALUE ((uint8_t) 0x7F)
/**
* @brief IDD PreDelay unit
*/
#define MFXSTM32L152_IDD_PREDELAY_0_5_MS ((uint8_t) 0x00)
#define MFXSTM32L152_IDD_PREDELAY_20_MS ((uint8_t) 0x80)
/**
* @}
*/
/** @defgroup IDD_DeltaDelay_Defines IDD Delta DElay Defines
* @{
*/
/**
* @brief IDD Delta Delay masks
*/
#define MFXSTM32L152_IDD_DELTADELAY_UNIT ((uint8_t) 0x80)
#define MFXSTM32L152_IDD_DELTADELAY_VALUE ((uint8_t) 0x7F)
/**
* @brief IDD Delta Delay unit
*/
#define MFXSTM32L152_IDD_DELTADELAY_0_5_MS ((uint8_t) 0x00)
#define MFXSTM32L152_IDD_DELTADELAY_20_MS ((uint8_t) 0x80)
/**
* @}
*/
/**
* @}
*/
/* Exported macro ------------------------------------------------------------*/
/** @defgroup MFXSTM32L152_Exported_Macros
* @{
*/
/**
* @}
*/
/* Exported functions --------------------------------------------------------*/
/** @defgroup MFXSTM32L152_Exported_Functions
* @{
*/
/**
* @brief MFXSTM32L152 Control functions
*/
void mfxstm32l152_Init(uint16_t DeviceAddr);
void mfxstm32l152_DeInit(uint16_t DeviceAddr);
void mfxstm32l152_Reset(uint16_t DeviceAddr);
uint16_t mfxstm32l152_ReadID(uint16_t DeviceAddr);
uint16_t mfxstm32l152_ReadFwVersion(uint16_t DeviceAddr);
void mfxstm32l152_LowPower(uint16_t DeviceAddr);
void mfxstm32l152_WakeUp(uint16_t DeviceAddr);
void mfxstm32l152_EnableITSource(uint16_t DeviceAddr, uint8_t Source);
void mfxstm32l152_DisableITSource(uint16_t DeviceAddr, uint8_t Source);
uint8_t mfxstm32l152_GlobalITStatus(uint16_t DeviceAddr, uint8_t Source);
void mfxstm32l152_ClearGlobalIT(uint16_t DeviceAddr, uint8_t Source);
void mfxstm32l152_SetIrqOutPinPolarity(uint16_t DeviceAddr, uint8_t Polarity);
void mfxstm32l152_SetIrqOutPinType(uint16_t DeviceAddr, uint8_t Type);
/**
* @brief MFXSTM32L152 IO functionalities functions
*/
void mfxstm32l152_IO_Start(uint16_t DeviceAddr, uint32_t IO_Pin);
uint8_t mfxstm32l152_IO_Config(uint16_t DeviceAddr, uint32_t IO_Pin, IO_ModeTypedef IO_Mode);
void mfxstm32l152_IO_WritePin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t PinState);
uint32_t mfxstm32l152_IO_ReadPin(uint16_t DeviceAddr, uint32_t IO_Pin);
void mfxstm32l152_IO_EnableIT(uint16_t DeviceAddr);
void mfxstm32l152_IO_DisableIT(uint16_t DeviceAddr);
uint32_t mfxstm32l152_IO_ITStatus(uint16_t DeviceAddr, uint32_t IO_Pin);
void mfxstm32l152_IO_ClearIT(uint16_t DeviceAddr, uint32_t IO_Pin);
void mfxstm32l152_IO_InitPin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Direction);
void mfxstm32l152_IO_EnableAF(uint16_t DeviceAddr);
void mfxstm32l152_IO_DisableAF(uint16_t DeviceAddr);
void mfxstm32l152_IO_SetIrqTypeMode(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Type);
void mfxstm32l152_IO_SetIrqEvtMode(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Evt);
void mfxstm32l152_IO_EnablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin);
void mfxstm32l152_IO_DisablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin);
/**
* @brief MFXSTM32L152 Touch screen functionalities functions
*/
void mfxstm32l152_TS_Start(uint16_t DeviceAddr);
uint8_t mfxstm32l152_TS_DetectTouch(uint16_t DeviceAddr);
void mfxstm32l152_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y);
void mfxstm32l152_TS_EnableIT(uint16_t DeviceAddr);
void mfxstm32l152_TS_DisableIT(uint16_t DeviceAddr);
uint8_t mfxstm32l152_TS_ITStatus (uint16_t DeviceAddr);
void mfxstm32l152_TS_ClearIT (uint16_t DeviceAddr);
/**
* @brief MFXSTM32L152 IDD current measurement functionalities functions
*/
void mfxstm32l152_IDD_Start(uint16_t DeviceAddr);
void mfxstm32l152_IDD_Config(uint16_t DeviceAddr, IDD_ConfigTypeDef MfxIddConfig);
void mfxstm32l152_IDD_ConfigShuntNbLimit(uint16_t DeviceAddr, uint8_t ShuntNbLimit);
void mfxstm32l152_IDD_GetValue(uint16_t DeviceAddr, uint32_t *ReadValue);
uint8_t mfxstm32l152_IDD_GetShuntUsed(uint16_t DeviceAddr);
void mfxstm32l152_IDD_EnableIT(uint16_t DeviceAddr);
void mfxstm32l152_IDD_ClearIT(uint16_t DeviceAddr);
uint8_t mfxstm32l152_IDD_GetITStatus(uint16_t DeviceAddr);
void mfxstm32l152_IDD_DisableIT(uint16_t DeviceAddr);
/**
* @brief MFXSTM32L152 Error management functions
*/
uint8_t mfxstm32l152_Error_ReadSrc(uint16_t DeviceAddr);
uint8_t mfxstm32l152_Error_ReadMsg(uint16_t DeviceAddr);
void mfxstm32l152_Error_EnableIT(uint16_t DeviceAddr);
void mfxstm32l152_Error_ClearIT(uint16_t DeviceAddr);
uint8_t mfxstm32l152_Error_GetITStatus(uint16_t DeviceAddr);
void mfxstm32l152_Error_DisableIT(uint16_t DeviceAddr);
uint8_t mfxstm32l152_ReadReg(uint16_t DeviceAddr, uint8_t RegAddr);
void mfxstm32l152_WriteReg(uint16_t DeviceAddr, uint8_t RegAddr, uint8_t Value);
/**
* @brief iobus prototypes (they should be defined in common/stm32_iobus.h)
*/
void MFX_IO_Init(void);
void MFX_IO_DeInit(void);
void MFX_IO_ITConfig (void);
void MFX_IO_EnableWakeupPin(void);
void MFX_IO_Wakeup(void);
void MFX_IO_Delay(uint32_t delay);
void MFX_IO_Write(uint16_t addr, uint8_t reg, uint8_t value);
uint8_t MFX_IO_Read(uint16_t addr, uint8_t reg);
uint16_t MFX_IO_ReadMultiple(uint16_t addr, uint8_t reg, uint8_t *buffer, uint16_t length);
/**
* @}
*/
/* Touch screen driver structure */
extern TS_DrvTypeDef mfxstm32l152_ts_drv;
/* IO driver structure */
extern IO_DrvTypeDef mfxstm32l152_io_drv;
/* IDD driver structure */
extern IDD_DrvTypeDef mfxstm32l152_idd_drv;
#ifdef __cplusplus
}
#endif
#endif /* __MFXSTM32L152_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for MX25LM51245G Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-mx25lm51245g-component-drivers"><small>Release Notes for</small> <mark>MX25LM51245G Component Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the MX25LM51245G component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 07-August-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release of MX25LM51245G Octal Flash Memory Component driver</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,301 @@
/**
******************************************************************************
* @file mx25lm51245g.h
* @author MCD Application Team
* @brief This file contains all the description of the MX25LM51245G Octal memory.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MX25LM51245G_H
#define __MX25LM51245G_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup MX25LM51245G
* @{
*/
/** @defgroup MX25LM51245G_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup MX25LM51245G_Exported_Constants
* @{
*/
/**
* @brief MX25LM51245G Configuration
*/
#define MX25LM51245G_FLASH_SIZE 0x4000000 /* 512 MBits => 64 MBytes */
#define MX25LM51245G_BLOCK_SIZE 0x10000 /* 1024 blocks of 64 KBytes */
#define MX25LM51245G_SECTOR_SIZE 0x1000 /* 16384 sectors of 4 kBytes */
#define MX25LM51245G_PAGE_SIZE 0x100 /* 262144 pages of 256 bytes */
#define MX25LM51245G_DUMMY_CYCLES_READ 8
#define MX25LM51245G_DUMMY_CYCLES_READ_OCTAL_66M 6
#define MX25LM51245G_DUMMY_CYCLES_READ_OCTAL_84M 8
#define MX25LM51245G_DUMMY_CYCLES_READ_OCTAL_104M 10
#define MX25LM51245G_DUMMY_CYCLES_READ_OCTAL_133M 14
#define MX25LM51245G_CR2_DC_66M MX25LM51245G_CR2_DC_6_CYCLES
#define MX25LM51245G_CR2_DC_84M MX25LM51245G_CR2_DC_8_CYCLES
#define MX25LM51245G_CR2_DC_104M MX25LM51245G_CR2_DC_10_CYCLES
#define MX25LM51245G_CR2_DC_133M MX25LM51245G_CR2_DC_14_CYCLES
#define MX25LM51245G_CHIP_ERASE_MAX_TIME 300000
#define MX25LM51245G_BLOCK_ERASE_MAX_TIME 2000
#define MX25LM51245G_SECTOR_ERASE_MAX_TIME 400
#define MX25LM51245G_WRITE_REG_MAX_TIME 40
/**
* @brief MX25LM51245G Commands
*/
/* Read Operations */
#define READ_CMD 0x03
#define READ_4_BYTE_ADDR_CMD 0x13
#define FAST_READ_CMD 0x0B
#define FAST_READ_4_BYTE_ADDR_CMD 0x0C
#define OCTAL_IO_READ_CMD 0xEC13
#define OCTAL_IO_DTR_READ_CMD 0xEE11
/* Program Operations */
#define PAGE_PROG_CMD 0x02
#define PAGE_PROG_4_BYTE_ADDR_CMD 0x12
#define OCTAL_PAGE_PROG_CMD 0x12ED
/* Erase Operations */
#define SECTOR_ERASE_CMD 0x20
#define SECTOR_ERASE_4_BYTE_ADDR_CMD 0x21
#define OCTAL_SECTOR_ERASE_CMD 0x21DE
#define BLOCK_ERASE_CMD 0xD8
#define BLOCK_ERASE_4_BYTE_ADDR_CMD 0xDC
#define OCTAL_BLOCK_ERASE_CMD 0xDC23
#define CHIP_ERASE_CMD 0x60
#define CHIP_ERASE_CMD_2 0xC7
#define OCTAL_CHIP_ERASE_CMD 0x609F
#define OCTAL_CHIP_ERASE_CMD_2 0xC738
#define PROG_ERASE_RESUME_CMD 0x30
#define PROG_ERASE_SUSPEND_CMD 0xB0
#define OCTAL_PROG_ERASE_RESUME_CMD 0x30CF
#define OCTAL_PROG_ERASE_SUSPEND_CMD 0xB04F
/* Identification Operations */
#define READ_ID_CMD 0x9F
#define READ_SERIAL_FLASH_DISCO_PARAM_CMD 0x5A
#define OCTAL_READ_ID_CMD 0x9F60
#define OCTAL_READ_SERIAL_FLASH_DISCO_PARAM_CMD 0x5AA5
/* Write Operations */
#define WRITE_ENABLE_CMD 0x06
#define WRITE_DISABLE_CMD 0x04
#define OCTAL_WRITE_ENABLE_CMD 0x06F9
#define OCTAL_WRITE_DISABLE_CMD 0x04FB
/* Register Operations */
#define READ_STATUS_REG_CMD 0x05
#define READ_CFG_REG_CMD 0x15
#define WRITE_STATUS_CFG_REG_CMD 0x01
#define OCTAL_READ_STATUS_REG_CMD 0x05FA
#define OCTAL_READ_CFG_REG_CMD 0x15EA
#define OCTAL_WRITE_STATUS_CFG_REG_CMD 0x01FE
#define READ_CFG_REG_2_CMD 0x71
#define WRITE_CFG_REG_2_CMD 0x72
#define OCTAL_READ_CFG_REG_2_CMD 0x718E
#define OCTAL_WRITE_CFG_REG_2_CMD 0x728D
#define READ_FAST_BOOT_REG_CMD 0x16
#define WRITE_FAST_BOOT_REG 0x17
#define ERASE_FAST_BOOT_REG 0x18
#define OCTAL_READ_FAST_BOOT_REG_CMD 0x16E9
#define OCTAL_WRITE_FAST_BOOT_REG 0x17E8
#define OCTAL_ERASE_FAST_BOOT_REG 0x18E7
#define READ_SEC_REG_CMD 0x2B
#define WRITE_SEC_REG_CMD 0x2F
#define OCTAL_READ_SECURITY_REG_CMD 0x2BD4
#define OCTAL_WRITE_SECURITY_REG_CMD 0x2FD0
#define READ_LOCK_REG_CMD 0x2D
#define WRITE_LOCK_REG_CMD 0x2C
#define OCTAL_READ_LOCK_REG_CMD 0x2DD2
#define OCTAL_WRITE_LOCK_REG_CMD 0x2CD3
#define READ_SPB_STATUS_CMD 0xE2
#define PROG_SPB_BIT_CMD 0xE3
#define ERASE_ALL_SPB_BIT_CMD 0xE4
#define OCTAL_READ_SPB_STATUS_CMD 0xE21D
#define OCTAL_PROG_SPB_BIT_CMD 0xE31C
#define OCTAL_ERASE_ALL_SPB_BIT_CMD 0xE41B
#define READ_DPB_REG_CMD 0xE0
#define WRITE_DPB_REG_CMD 0xE1
#define OCTAL_READ_DPB_REG_CMD 0xE01F
#define OCTAL_WRITE_DPB_REG_CMD 0xE11E
/* Power Down Operations */
#define DEEP_POWER_DOWN_CMD 0xB9
#define RELEASE_DEEP_POWER_DOWN_CMD 0xAB
#define OCTAL_ENTER_DEEP_POWER_DOWN_CMD 0xB946
/* Burst Operations */
#define SET_BURST_LENGTH_CMD 0xC0
#define OCTAL_SET_BURST_LENGTH_CMD 0xC03F
/* One-Time Programmable Operations */
#define ENTER_SECURED_OTP_CMD 0xB1
#define EXIT_SECURED_OTP_CMD 0xC1
#define OCTAL_ENTER_SECURED_OTP_CMD 0xB14E
#define OCTAL_EXIT_SECURED_OTP_CMD 0xC13E
/* No Operation */
#define NO_OPERATION_CMD 0x00
#define OCTAL_NO_OPERATION_CMD 0x00FF
/* Reset Operations */
#define RESET_ENABLE_CMD 0x66
#define RESET_MEMORY_CMD 0x99
#define OCTAL_RESET_ENABLE_CMD 0x6699
#define OCTAL_RESET_MEMORY_CMD 0x9966
/* Protection Operations */
#define WRITE_PROTECT_SEL_CMD 0x68
#define OCTAL_WRITE_PROTECT_SEL_CMD 0x6897
#define GANG_BLOCK_LOCK_CMD 0x7E
#define GANG_BLOCK_UNLOCK_CMD 0x98
#define OCTAL_GANG_BLOCK_LOCK_CMD 0x7E81
#define OCTAL_GANG_BLOCK_UNLOCK_CMD 0x9867
/**
* @brief MX25LM51245G Registers
*/
/* Status Register */
#define MX25LM51245G_SR_WIP ((uint8_t)0x01) /*!< Write in progress */
#define MX25LM51245G_SR_WEL ((uint8_t)0x02) /*!< Write enable latch */
#define MX25LM51245G_SR_BP ((uint8_t)0x3C) /*!< Block protect */
/* Configuration Register 1 */
#define MX25LM51245G_CR1_ODS ((uint8_t)0x07) /*!< Output driver strength */
#define MX25LM51245G_CR1_TB ((uint8_t)0x08) /*!< Top / bottom */
/* Configuration Register 2 */
/* Address : 0x00000000 */
#define MX25LM51245G_CR2_REG1_ADDR ((uint32_t)0x00000000) /*!< CR2 register address 0x00000000 */
#define MX25LM51245G_CR2_SOPI ((uint8_t)0x01) /*!< STR OPI Enable */
#define MX25LM51245G_CR2_DOPI ((uint8_t)0x02) /*!< DTR OPI Enable */
/* Address : 0x00000200 */
#define MX25LM51245G_CR2_REG2_ADDR ((uint32_t)0x00000200) /*!< CR2 register address 0x00000200 */
#define MX25LM51245G_CR2_DQSPRC ((uint8_t)0x01) /*!< DTR DQS pre-cycle */
#define MX25LM51245G_CR2_DOS ((uint8_t)0x02) /*!< DQS on STR mode */
/* Address : 0x00000300 */
#define MX25LM51245G_CR2_REG3_ADDR ((uint32_t)0x00000300) /*!< CR2 register address 0x00000300 */
#define MX25LM51245G_CR2_DC ((uint8_t)0x07) /*!< Dummy cycle */
#define MX25LM51245G_CR2_DC_20_CYCLES ((uint8_t)0x00) /*!< 20 Dummy cycles */
#define MX25LM51245G_CR2_DC_18_CYCLES ((uint8_t)0x01) /*!< 18 Dummy cycles */
#define MX25LM51245G_CR2_DC_16_CYCLES ((uint8_t)0x02) /*!< 16 Dummy cycles */
#define MX25LM51245G_CR2_DC_14_CYCLES ((uint8_t)0x03) /*!< 14 Dummy cycles */
#define MX25LM51245G_CR2_DC_12_CYCLES ((uint8_t)0x04) /*!< 12 Dummy cycles */
#define MX25LM51245G_CR2_DC_10_CYCLES ((uint8_t)0x05) /*!< 10 Dummy cycles */
#define MX25LM51245G_CR2_DC_8_CYCLES ((uint8_t)0x06) /*!< 8 Dummy cycles */
#define MX25LM51245G_CR2_DC_6_CYCLES ((uint8_t)0x07) /*!< 6 Dummy cycles */
/* Address : 0x00000500 */
#define MX25LM51245G_CR2_REG4_ADDR ((uint32_t)0x00000500) /*!< CR2 register address 0x00000500 */
#define MX25LM51245G_CR2_PPTSEL ((uint8_t)0x01) /*!< Preamble pattern selection */
/* Address : 0x40000000 */
#define MX25LM51245G_CR2_REG5_ADDR ((uint32_t)0x40000000) /*!< CR2 register address 0x40000000 */
#define MX25LM51245G_CR2_DEFSOPI ((uint8_t)0x01) /*!< Enable SOPI after power on reset */
#define MX25LM51245G_CR2_DEFDOPI ((uint8_t)0x02) /*!< Enable DOPI after power on reset */
/* Security Register */
#define MX25LM51245G_SECR_SOI ((uint8_t)0x01) /*!< Secured OTP indicator */
#define MX25LM51245G_SECR_LDSO ((uint8_t)0x02) /*!< Lock-down secured OTP */
#define MX25LM51245G_SECR_PSB ((uint8_t)0x04) /*!< Program suspend bit */
#define MX25LM51245G_SECR_ESB ((uint8_t)0x08) /*!< Erase suspend bit */
#define MX25LM51245G_SECR_P_FAIL ((uint8_t)0x20) /*!< Program fail flag */
#define MX25LM51245G_SECR_E_FAIL ((uint8_t)0x40) /*!< Erase fail flag */
#define MX25LM51245G_SECR_WPSEL ((uint8_t)0x40) /*!< Write protection selection */
/**
* @}
*/
/** @defgroup MX25LM51245G_Exported_Functions
* @{
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __MX25LM51245G_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for MX25R6435F Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-mx25r6435f-component-drivers"><small>Release Notes for</small> <mark>MX25R6435F Component Drivers</mark></h1>
<p>Copyright © 2017 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the MX25R6435F component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 03-April-2019</label>
<div>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">Main Changes</span></span></strong></p>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" checked aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 07-August-2017</label>
<div>
<p><strong><span class="underline"><span style="font-size: 10pt; font-family: Verdana; color: black;">Main Changes</span></span></strong></p>
<ul>
<li>First official release of MX256435F QuadSPI Flash memory</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,193 @@
/**
******************************************************************************
* @file mx25r6435f.h
* @author MCD Application Team
* @brief This file contains all the description of the MX25R6435F QSPI memory.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MX25R6435F_H
#define __MX25R6435F_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup mx25r6435f
* @{
*/
/** @defgroup MX25R6435F_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup MX25R6435F_Exported_Constants
* @{
*/
/**
* @brief MX25R6435F Configuration
*/
#define MX25R6435F_FLASH_SIZE 0x800000 /* 64 MBits => 8MBytes */
#define MX25R6435F_BLOCK_SIZE 0x10000 /* 128 blocks of 64KBytes */
#define MX25R6435F_SUBBLOCK_SIZE 0x8000 /* 256 blocks of 32KBytes */
#define MX25R6435F_SECTOR_SIZE 0x1000 /* 2048 sectors of 4kBytes */
#define MX25R6435F_PAGE_SIZE 0x100 /* 32768 pages of 256 bytes */
#define MX25R6435F_DUMMY_CYCLES_READ 8
#define MX25R6435F_DUMMY_CYCLES_READ_DUAL 4
#define MX25R6435F_DUMMY_CYCLES_READ_QUAD 4
#define MX25R6435F_DUMMY_CYCLES_2READ 2
#define MX25R6435F_DUMMY_CYCLES_4READ 4
#define MX25R6435F_ALT_BYTES_PE_MODE 0xA5
#define MX25R6435F_ALT_BYTES_NO_PE_MODE 0xAA
#define MX25R6435F_CHIP_ERASE_MAX_TIME 240000
#define MX25R6435F_BLOCK_ERASE_MAX_TIME 3500
#define MX25R6435F_SUBBLOCK_ERASE_MAX_TIME 3000
#define MX25R6435F_SECTOR_ERASE_MAX_TIME 240
/**
* @brief MX25R6435F Commands
*/
/* Read Operations */
#define READ_CMD 0x03
#define FAST_READ_CMD 0x0B
#define DUAL_OUT_READ_CMD 0x3B
#define DUAL_INOUT_READ_CMD 0xBB
#define QUAD_OUT_READ_CMD 0x6B
#define QUAD_INOUT_READ_CMD 0xEB
/* Program Operations */
#define PAGE_PROG_CMD 0x02
#define QUAD_PAGE_PROG_CMD 0x38
/* Erase Operations */
#define SECTOR_ERASE_CMD 0x20
#define SUBBLOCK_ERASE_CMD 0x52
#define BLOCK_ERASE_CMD 0xD8
#define CHIP_ERASE_CMD 0x60
#define CHIP_ERASE_CMD_2 0xC7
#define PROG_ERASE_RESUME_CMD 0x7A
#define PROG_ERASE_RESUME_CMD_2 0x30
#define PROG_ERASE_SUSPEND_CMD 0x75
#define PROG_ERASE_SUSPEND_CMD_2 0xB0
/* Identification Operations */
#define READ_ID_CMD 0x9F
#define READ_ELECTRONIC_ID_CMD 0xAB
#define READ_ELEC_MANUFACTURER_DEVICE_ID_CMD 0x90
#define READ_SERIAL_FLASH_DISCO_PARAM_CMD 0x5A
/* Write Operations */
#define WRITE_ENABLE_CMD 0x06
#define WRITE_DISABLE_CMD 0x04
/* Register Operations */
#define READ_STATUS_REG_CMD 0x05
#define READ_CFG_REG_CMD 0x15
#define WRITE_STATUS_CFG_REG_CMD 0x01
#define READ_SEC_REG_CMD 0x2B
#define WRITE_SEC_REG_CMD 0x2F
/* Power Down Operations */
#define DEEP_POWER_DOWN_CMD 0xB9
/* Burst Operations */
#define SET_BURST_LENGTH_CMD 0xC0
/* One-Time Programmable Operations */
#define ENTER_SECURED_OTP_CMD 0xB1
#define EXIT_SECURED_OTP_CMD 0xC1
/* No Operation */
#define NO_OPERATION_CMD 0x00
/* Reset Operations */
#define RESET_ENABLE_CMD 0x66
#define RESET_MEMORY_CMD 0x99
#define RELEASE_READ_ENHANCED_CMD 0xFF
/**
* @brief MX25R6435F Registers
*/
/* Status Register */
#define MX25R6435F_SR_WIP ((uint8_t)0x01) /*!< Write in progress */
#define MX25R6435F_SR_WEL ((uint8_t)0x02) /*!< Write enable latch */
#define MX25R6435F_SR_BP ((uint8_t)0x3C) /*!< Block protect */
#define MX25R6435F_SR_QE ((uint8_t)0x40) /*!< Quad enable */
#define MX25R6435F_SR_SRWD ((uint8_t)0x80) /*!< Status register write disable */
/* Configuration Register 1 */
#define MX25R6435F_CR1_TB ((uint8_t)0x08) /*!< Top / bottom */
/* Configuration Register 2 */
#define MX25R6435F_CR2_LH_SWITCH ((uint8_t)0x02) /*!< Low power / high performance switch */
/* Security Register */
#define MX25R6435F_SECR_SOI ((uint8_t)0x01) /*!< Secured OTP indicator */
#define MX25R6435F_SECR_LDSO ((uint8_t)0x02) /*!< Lock-down secured OTP */
#define MX25R6435F_SECR_PSB ((uint8_t)0x04) /*!< Program suspend bit */
#define MX25R6435F_SECR_ESB ((uint8_t)0x08) /*!< Erase suspend bit */
#define MX25R6435F_SECR_P_FAIL ((uint8_t)0x20) /*!< Program fail flag */
#define MX25R6435F_SECR_E_FAIL ((uint8_t)0x40) /*!< Erase fail flag */
/**
* @}
*/
/** @defgroup MX25R6435F_Exported_Functions
* @{
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __MX25R6435F_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,73 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for N25Q128A Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-n25q128a-component-drivers"><small>Release Notes for</small> <mark>N25Q128A Component Drivers</mark></h1>
<p>Copyright © 2015 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the N25Q128A component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.2 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.1 / 31-August-2018</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.0.0 / 29-May-2015</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>First official release of N25Q128A QuadSPI Flash Component driver</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,201 @@
/**
******************************************************************************
* @file n25q128a.h
* @author MCD Application Team
* @brief This file contains all the description of the N25Q128A QSPI memory.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __N25Q128A_H
#define __N25Q128A_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup n25q128a
* @{
*/
/** @defgroup N25Q128A_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup N25Q128A_Exported_Constants
* @{
*/
/**
* @brief N25Q128A Configuration
*/
#define N25Q128A_FLASH_SIZE 0x1000000 /* 128 MBits => 16MBytes */
#define N25Q128A_SECTOR_SIZE 0x10000 /* 256 sectors of 64KBytes */
#define N25Q128A_SUBSECTOR_SIZE 0x1000 /* 4096 subsectors of 4kBytes */
#define N25Q128A_PAGE_SIZE 0x100 /* 65536 pages of 256 bytes */
#define N25Q128A_DUMMY_CYCLES_READ 8
#define N25Q128A_DUMMY_CYCLES_READ_QUAD 10
#define N25Q128A_BULK_ERASE_MAX_TIME 250000
#define N25Q128A_SECTOR_ERASE_MAX_TIME 3000
#define N25Q128A_SUBSECTOR_ERASE_MAX_TIME 800
/**
* @brief N25Q128A Commands
*/
/* Reset Operations */
#define RESET_ENABLE_CMD 0x66
#define RESET_MEMORY_CMD 0x99
/* Identification Operations */
#define READ_ID_CMD 0x9E
#define READ_ID_CMD2 0x9F
#define MULTIPLE_IO_READ_ID_CMD 0xAF
#define READ_SERIAL_FLASH_DISCO_PARAM_CMD 0x5A
/* Read Operations */
#define READ_CMD 0x03
#define FAST_READ_CMD 0x0B
#define DUAL_OUT_FAST_READ_CMD 0x3B
#define DUAL_INOUT_FAST_READ_CMD 0xBB
#define QUAD_OUT_FAST_READ_CMD 0x6B
#define QUAD_INOUT_FAST_READ_CMD 0xEB
/* Write Operations */
#define WRITE_ENABLE_CMD 0x06
#define WRITE_DISABLE_CMD 0x04
/* Register Operations */
#define READ_STATUS_REG_CMD 0x05
#define WRITE_STATUS_REG_CMD 0x01
#define READ_LOCK_REG_CMD 0xE8
#define WRITE_LOCK_REG_CMD 0xE5
#define READ_FLAG_STATUS_REG_CMD 0x70
#define CLEAR_FLAG_STATUS_REG_CMD 0x50
#define READ_NONVOL_CFG_REG_CMD 0xB5
#define WRITE_NONVOL_CFG_REG_CMD 0xB1
#define READ_VOL_CFG_REG_CMD 0x85
#define WRITE_VOL_CFG_REG_CMD 0x81
#define READ_ENHANCED_VOL_CFG_REG_CMD 0x65
#define WRITE_ENHANCED_VOL_CFG_REG_CMD 0x61
/* Program Operations */
#define PAGE_PROG_CMD 0x02
#define DUAL_IN_FAST_PROG_CMD 0xA2
#define EXT_DUAL_IN_FAST_PROG_CMD 0xD2
#define QUAD_IN_FAST_PROG_CMD 0x32
#define EXT_QUAD_IN_FAST_PROG_CMD 0x12
/* Erase Operations */
#define SUBSECTOR_ERASE_CMD 0x20
#define SECTOR_ERASE_CMD 0xD8
#define BULK_ERASE_CMD 0xC7
#define PROG_ERASE_RESUME_CMD 0x7A
#define PROG_ERASE_SUSPEND_CMD 0x75
/* One-Time Programmable Operations */
#define READ_OTP_ARRAY_CMD 0x4B
#define PROG_OTP_ARRAY_CMD 0x42
/**
* @brief N25Q128A Registers
*/
/* Status Register */
#define N25Q128A_SR_WIP ((uint8_t)0x01) /*!< Write in progress */
#define N25Q128A_SR_WREN ((uint8_t)0x02) /*!< Write enable latch */
#define N25Q128A_SR_BLOCKPR ((uint8_t)0x5C) /*!< Block protected against program and erase operations */
#define N25Q128A_SR_PRBOTTOM ((uint8_t)0x20) /*!< Protected memory area defined by BLOCKPR starts from top or bottom */
#define N25Q128A_SR_SRWREN ((uint8_t)0x80) /*!< Status register write enable/disable */
/* Nonvolatile Configuration Register */
#define N25Q128A_NVCR_LOCK ((uint16_t)0x0001) /*!< Lock nonvolatile configuration register */
#define N25Q128A_NVCR_DUAL ((uint16_t)0x0004) /*!< Dual I/O protocol */
#define N25Q128A_NVCR_QUAB ((uint16_t)0x0008) /*!< Quad I/O protocol */
#define N25Q128A_NVCR_RH ((uint16_t)0x0010) /*!< Reset/hold */
#define N25Q128A_NVCR_ODS ((uint16_t)0x01C0) /*!< Output driver strength */
#define N25Q128A_NVCR_XIP ((uint16_t)0x0E00) /*!< XIP mode at power-on reset */
#define N25Q128A_NVCR_NB_DUMMY ((uint16_t)0xF000) /*!< Number of dummy clock cycles */
/* Volatile Configuration Register */
#define N25Q128A_VCR_WRAP ((uint8_t)0x03) /*!< Wrap */
#define N25Q128A_VCR_XIP ((uint8_t)0x08) /*!< XIP */
#define N25Q128A_VCR_NB_DUMMY ((uint8_t)0xF0) /*!< Number of dummy clock cycles */
/* Enhanced Volatile Configuration Register */
#define N25Q128A_EVCR_ODS ((uint8_t)0x07) /*!< Output driver strength */
#define N25Q128A_EVCR_VPPA ((uint8_t)0x08) /*!< Vpp accelerator */
#define N25Q128A_EVCR_RH ((uint8_t)0x10) /*!< Reset/hold */
#define N25Q128A_EVCR_DUAL ((uint8_t)0x40) /*!< Dual I/O protocol */
#define N25Q128A_EVCR_QUAD ((uint8_t)0x80) /*!< Quad I/O protocol */
/* Flag Status Register */
#define N25Q128A_FSR_PRERR ((uint8_t)0x02) /*!< Protection error */
#define N25Q128A_FSR_PGSUS ((uint8_t)0x04) /*!< Program operation suspended */
#define N25Q128A_FSR_VPPERR ((uint8_t)0x08) /*!< Invalid voltage during program or erase */
#define N25Q128A_FSR_PGERR ((uint8_t)0x10) /*!< Program error */
#define N25Q128A_FSR_ERERR ((uint8_t)0x20) /*!< Erase error */
#define N25Q128A_FSR_ERSUS ((uint8_t)0x40) /*!< Erase operation suspended */
#define N25Q128A_FSR_READY ((uint8_t)0x80) /*!< Ready or command in progress */
/**
* @}
*/
/** @defgroup N25Q128A_Exported_Functions
* @{
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __N25Q128A_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for N25Q256A Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-n25q256a-component-drivers"><small>Release Notes for</small> <mark>N25Q256A Component Drivers</mark></h1>
<p>Copyright © 2015 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the N25Q256A component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 07-August-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,243 @@
/**
******************************************************************************
* @file n25q256a.h
* @author MCD Application Team
* @brief This file contains all the description of the N25Q256A QSPI memory.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __N25Q256A_H
#define __N25Q256A_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup n25q256a
* @{
*/
/** @defgroup N25Q256A_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup N25Q256A_Exported_Constants
* @{
*/
/**
* @brief N25Q256A Configuration
*/
#define N25Q256A_FLASH_SIZE 0x2000000 /* 256 MBits => 32MBytes */
#define N25Q256A_SECTOR_SIZE 0x10000 /* 512 sectors of 64KBytes */
#define N25Q256A_SUBSECTOR_SIZE 0x1000 /* 8192 subsectors of 4kBytes */
#define N25Q256A_PAGE_SIZE 0x100 /* 131072 pages of 256 bytes */
#define N25Q256A_DUMMY_CYCLES_READ 8
#define N25Q256A_DUMMY_CYCLES_READ_QUAD 10
#define N25Q256A_DUMMY_CYCLES_READ_DTR 6
#define N25Q256A_DUMMY_CYCLES_READ_QUAD_DTR 8
#define N25Q256A_BULK_ERASE_MAX_TIME 480000
#define N25Q256A_SECTOR_ERASE_MAX_TIME 3000
#define N25Q256A_SUBSECTOR_ERASE_MAX_TIME 800
/**
* @brief N25Q256A Commands
*/
/* Reset Operations */
#define RESET_ENABLE_CMD 0x66
#define RESET_MEMORY_CMD 0x99
/* Identification Operations */
#define READ_ID_CMD 0x9E
#define READ_ID_CMD2 0x9F
#define MULTIPLE_IO_READ_ID_CMD 0xAF
#define READ_SERIAL_FLASH_DISCO_PARAM_CMD 0x5A
/* Read Operations */
#define READ_CMD 0x03
#define READ_4_BYTE_ADDR_CMD 0x13
#define FAST_READ_CMD 0x0B
#define FAST_READ_DTR_CMD 0x0D
#define FAST_READ_4_BYTE_ADDR_CMD 0x0C
#define DUAL_OUT_FAST_READ_CMD 0x3B
#define DUAL_OUT_FAST_READ_DTR_CMD 0x3D
#define DUAL_OUT_FAST_READ_4_BYTE_ADDR_CMD 0x3C
#define DUAL_INOUT_FAST_READ_CMD 0xBB
#define DUAL_INOUT_FAST_READ_DTR_CMD 0xBD
#define DUAL_INOUT_FAST_READ_4_BYTE_ADDR_CMD 0xBC
#define QUAD_OUT_FAST_READ_CMD 0x6B
#define QUAD_OUT_FAST_READ_DTR_CMD 0x6D
#define QUAD_OUT_FAST_READ_4_BYTE_ADDR_CMD 0x6C
#define QUAD_INOUT_FAST_READ_CMD 0xEB
#define QUAD_INOUT_FAST_READ_DTR_CMD 0xED
#define QUAD_INOUT_FAST_READ_4_BYTE_ADDR_CMD 0xEC
/* Write Operations */
#define WRITE_ENABLE_CMD 0x06
#define WRITE_DISABLE_CMD 0x04
/* Register Operations */
#define READ_STATUS_REG_CMD 0x05
#define WRITE_STATUS_REG_CMD 0x01
#define READ_LOCK_REG_CMD 0xE8
#define WRITE_LOCK_REG_CMD 0xE5
#define READ_FLAG_STATUS_REG_CMD 0x70
#define CLEAR_FLAG_STATUS_REG_CMD 0x50
#define READ_NONVOL_CFG_REG_CMD 0xB5
#define WRITE_NONVOL_CFG_REG_CMD 0xB1
#define READ_VOL_CFG_REG_CMD 0x85
#define WRITE_VOL_CFG_REG_CMD 0x81
#define READ_ENHANCED_VOL_CFG_REG_CMD 0x65
#define WRITE_ENHANCED_VOL_CFG_REG_CMD 0x61
#define READ_EXT_ADDR_REG_CMD 0xC8
#define WRITE_EXT_ADDR_REG_CMD 0xC5
/* Program Operations */
#define PAGE_PROG_CMD 0x02
#define PAGE_PROG_4_BYTE_ADDR_CMD 0x12
#define DUAL_IN_FAST_PROG_CMD 0xA2
#define EXT_DUAL_IN_FAST_PROG_CMD 0xD2
#define QUAD_IN_FAST_PROG_CMD 0x32
#define EXT_QUAD_IN_FAST_PROG_CMD 0x12 /*0x38*/
#define QUAD_IN_FAST_PROG_4_BYTE_ADDR_CMD 0x34
/* Erase Operations */
#define SUBSECTOR_ERASE_CMD 0x20
#define SUBSECTOR_ERASE_4_BYTE_ADDR_CMD 0x21
#define SECTOR_ERASE_CMD 0xD8
#define SECTOR_ERASE_4_BYTE_ADDR_CMD 0xDC
#define BULK_ERASE_CMD 0xC7
#define PROG_ERASE_RESUME_CMD 0x7A
#define PROG_ERASE_SUSPEND_CMD 0x75
/* One-Time Programmable Operations */
#define READ_OTP_ARRAY_CMD 0x4B
#define PROG_OTP_ARRAY_CMD 0x42
/* 4-byte Address Mode Operations */
#define ENTER_4_BYTE_ADDR_MODE_CMD 0xB7
#define EXIT_4_BYTE_ADDR_MODE_CMD 0xE9
/* Quad Operations */
#define ENTER_QUAD_CMD 0x35
#define EXIT_QUAD_CMD 0xF5
/**
* @brief N25Q256A Registers
*/
/* Status Register */
#define N25Q256A_SR_WIP ((uint8_t)0x01) /*!< Write in progress */
#define N25Q256A_SR_WREN ((uint8_t)0x02) /*!< Write enable latch */
#define N25Q256A_SR_BLOCKPR ((uint8_t)0x5C) /*!< Block protected against program and erase operations */
#define N25Q256A_SR_PRBOTTOM ((uint8_t)0x20) /*!< Protected memory area defined by BLOCKPR starts from top or bottom */
#define N25Q256A_SR_SRWREN ((uint8_t)0x80) /*!< Status register write enable/disable */
/* Nonvolatile Configuration Register */
#define N25Q256A_NVCR_NBADDR ((uint16_t)0x0001) /*!< 3-bytes or 4-bytes addressing */
#define N25Q256A_NVCR_SEGMENT ((uint16_t)0x0002) /*!< Upper or lower 128Mb segment selected by default */
#define N25Q256A_NVCR_DUAL ((uint16_t)0x0004) /*!< Dual I/O protocol */
#define N25Q256A_NVCR_QUAB ((uint16_t)0x0008) /*!< Quad I/O protocol */
#define N25Q256A_NVCR_RH ((uint16_t)0x0010) /*!< Reset/hold */
#define N25Q256A_NVCR_ODS ((uint16_t)0x01C0) /*!< Output driver strength */
#define N25Q256A_NVCR_XIP ((uint16_t)0x0E00) /*!< XIP mode at power-on reset */
#define N25Q256A_NVCR_NB_DUMMY ((uint16_t)0xF000) /*!< Number of dummy clock cycles */
/* Volatile Configuration Register */
#define N25Q256A_VCR_WRAP ((uint8_t)0x03) /*!< Wrap */
#define N25Q256A_VCR_XIP ((uint8_t)0x08) /*!< XIP */
#define N25Q256A_VCR_NB_DUMMY ((uint8_t)0xF0) /*!< Number of dummy clock cycles */
/* Extended Address Register */
#define N25Q256A_EAR_A24 ((uint8_t)0x01) /*!< Select the lower or upper 128Mb segment */
/* Enhanced Volatile Configuration Register */
#define N25Q256A_EVCR_ODS ((uint8_t)0x07) /*!< Output driver strength */
#define N25Q256A_EVCR_VPPA ((uint8_t)0x08) /*!< Vpp accelerator */
#define N25Q256A_EVCR_RH ((uint8_t)0x10) /*!< Reset/hold */
#define N25Q256A_EVCR_DUAL ((uint8_t)0x40) /*!< Dual I/O protocol */
#define N25Q256A_EVCR_QUAD ((uint8_t)0x80) /*!< Quad I/O protocol */
/* Flag Status Register */
#define N25Q256A_FSR_NBADDR ((uint8_t)0x01) /*!< 3-bytes or 4-bytes addressing */
#define N25Q256A_FSR_PRERR ((uint8_t)0x02) /*!< Protection error */
#define N25Q256A_FSR_PGSUS ((uint8_t)0x04) /*!< Program operation suspended */
#define N25Q256A_FSR_VPPERR ((uint8_t)0x08) /*!< Invalid voltage during program or erase */
#define N25Q256A_FSR_PGERR ((uint8_t)0x10) /*!< Program error */
#define N25Q256A_FSR_ERERR ((uint8_t)0x20) /*!< Erase error */
#define N25Q256A_FSR_ERSUS ((uint8_t)0x40) /*!< Erase operation suspended */
#define N25Q256A_FSR_READY ((uint8_t)0x80) /*!< Ready or command in progress */
/**
* @}
*/
/** @defgroup N25Q256A_Exported_Functions
* @{
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __N25Q256A_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,73 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for OV9655 Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-ov9655-component-drivers"><small>Release Notes for</small> <mark>OV9655 Component Drivers</mark></h1>
<p>Copyright © 2015 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the OV9655 component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.2 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section21" aria-hidden="true"> <label for="collapse-section21" aria-hidden="true">V1.0.1 / 31-August-2018</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 25-June-2015</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>First official release</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,843 @@
/**
******************************************************************************
* @file ov9655.c
* @author MCD Application Team
* @brief This file provides the OV9655 camera driver
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "ov9655.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup OV9655
* @brief This file provides a set of functions needed to drive the
* OV9655 Camera module.
* @{
*/
/** @defgroup OV9655_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup OV9655_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup OV9655_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup OV9655_Private_FunctionPrototypes
* @{
*/
static uint64_t ov9655_ConvertValue(uint32_t feature, uint32_t value);
/**
* @}
*/
/** @defgroup OV9655_Private_Variables
* @{
*/
CAMERA_DrvTypeDef ov9655_drv =
{
ov9655_Init,
ov9655_ReadID,
ov9655_Config,
};
/* Initialization sequence for VGA resolution (640x480)*/
const unsigned char OV9655_VGA[][2]=
{
{0x00, 0x00},
{0x01, 0x80},
{0x02, 0x80},
{0xb5, 0x00},
{0x35, 0x00},
{0xa8, 0xc1},
{0x3a, 0xcc},
{0x3d, 0x99},
{0x77, 0x02},
{0x13, 0xe7},
{0x26, 0x72},
{0x27, 0x08},
{0x28, 0x08},
{0x2c, 0x08},
{0xab, 0x04},
{0x6e, 0x00},
{0x6d, 0x55},
{0x00, 0x11},
{0x10, 0x7b},
{0xbb, 0xae},
{0x11, 0x03},
{0x72, 0x00},
{0x3e, 0x0c},
{0x74, 0x3a},
{0x76, 0x01},
{0x75, 0x35},
{0x73, 0x00},
{0xc7, 0x80},
{0x62, 0x00},
{0x63, 0x00},
{0x64, 0x02},
{0x65, 0x20},
{0x66, 0x01},
{0xc3, 0x4e},
{0x33, 0x00},
{0xa4, 0x50},
{0xaa, 0x92},
{0xc2, 0x01},
{0xc1, 0xc8},
{0x1e, 0x04},
{0xa9, 0xef},
{0x0e, 0x61},
{0x39, 0x57},
{0x0f, 0x48},
{0x24, 0x3c},
{0x25, 0x36},
{0x12, 0x63},
{0x03, 0x12},
{0x32, 0xff},
{0x17, 0x16},
{0x18, 0x02},
{0x19, 0x01},
{0x1a, 0x3d},
{0x36, 0xfa},
{0x69, 0x0a},
{0x8c, 0x8d},
{0xc0, 0xaa},
{0x40, 0xd0},
{0x43, 0x14},
{0x44, 0xf0},
{0x45, 0x46},
{0x46, 0x62},
{0x47, 0x2a},
{0x48, 0x3c},
{0x59, 0x85},
{0x5a, 0xa9},
{0x5b, 0x64},
{0x5c, 0x84},
{0x5d, 0x53},
{0x5e, 0x0e},
{0x6c, 0x0c},
{0xc6, 0x85},
{0xcb, 0xf0},
{0xcc, 0xd8},
{0x71, 0x78},
{0xa5, 0x68},
{0x6f, 0x9e},
{0x42, 0xc0},
{0x3f, 0x82},
{0x8a, 0x23},
{0x14, 0x3a},
{0x3b, 0xcc},
{0x34, 0x3d},
{0x41, 0x40},
{0xc9, 0xe0},
{0xca, 0xe8},
{0xcd, 0x93},
{0x7a, 0x20},
{0x7b, 0x1c},
{0x7c, 0x28},
{0x7d, 0x3c},
{0x7e, 0x5a},
{0x7f, 0x68},
{0x80, 0x76},
{0x81, 0x80},
{0x82, 0x88},
{0x83, 0x8f},
{0x84, 0x96},
{0x85, 0xa3},
{0x86, 0xaf},
{0x87, 0xc4},
{0x88, 0xd7},
{0x89, 0xe8},
{0x4f, 0x98},
{0x50, 0x98},
{0x51, 0x00},
{0x52, 0x28},
{0x53, 0x70},
{0x54, 0x98},
{0x58, 0x1a},
{0x6b, 0x5a},
{0x90, 0x92},
{0x91, 0x92},
{0x9f, 0x90},
{0xa0, 0x90},
{0x16, 0x24},
{0x2a, 0x00},
{0x2b, 0x00},
{0xac, 0x80},
{0xad, 0x80},
{0xae, 0x80},
{0xaf, 0x80},
{0xb2, 0xf2},
{0xb3, 0x20},
{0xb4, 0x20},
{0xb6, 0xaf},
{0x29, 0x15},
{0x9d, 0x02},
{0x9e, 0x02},
{0x9e, 0x02},
{0x04, 0x03},
{0x05, 0x2e},
{0x06, 0x2e},
{0x07, 0x2e},
{0x08, 0x2e},
{0x2f, 0x2e},
{0x4a, 0xe9},
{0x4b, 0xdd},
{0x4c, 0xdd},
{0x4d, 0xdd},
{0x4e, 0xdd},
{0x70, 0x06},
{0xa6, 0x40},
{0xbc, 0x02},
{0xbd, 0x01},
{0xbe, 0x02},
{0xbf, 0x01},
};
/* Initialization sequence for QVGA resolution (320x240) */
const unsigned char OV9655_QVGA[][2]=
{
{0x00, 0x00},
{0x01, 0x80},
{0x02, 0x80},
{0x03, 0x02},
{0x04, 0x03},
{0x09, 0x01},
{0x0b, 0x57},
{0x0e, 0x61},
{0x0f, 0x40},
{0x11, 0x01},
{0x12, 0x62},
{0x13, 0xc7},
{0x14, 0x3a},
{0x16, 0x24},
{0x17, 0x18},
{0x18, 0x04},
{0x19, 0x01},
{0x1a, 0x81},
{0x1e, 0x00},
{0x24, 0x3c},
{0x25, 0x36},
{0x26, 0x72},
{0x27, 0x08},
{0x28, 0x08},
{0x29, 0x15},
{0x2a, 0x00},
{0x2b, 0x00},
{0x2c, 0x08},
{0x32, 0x12},
{0x33, 0x00},
{0x34, 0x3f},
{0x35, 0x00},
{0x36, 0x3a},
{0x38, 0x72},
{0x39, 0x57},
{0x3a, 0xcc},
{0x3b, 0x04},
{0x3d, 0x99},
{0x3e, 0x02},
{0x3f, 0xc1},
{0x40, 0xc0},
{0x41, 0x41},
{0x42, 0xc0},
{0x43, 0x0a},
{0x44, 0xf0},
{0x45, 0x46},
{0x46, 0x62},
{0x47, 0x2a},
{0x48, 0x3c},
{0x4a, 0xfc},
{0x4b, 0xfc},
{0x4c, 0x7f},
{0x4d, 0x7f},
{0x4e, 0x7f},
{0x4f, 0x98},
{0x50, 0x98},
{0x51, 0x00},
{0x52, 0x28},
{0x53, 0x70},
{0x54, 0x98},
{0x58, 0x1a},
{0x59, 0x85},
{0x5a, 0xa9},
{0x5b, 0x64},
{0x5c, 0x84},
{0x5d, 0x53},
{0x5e, 0x0e},
{0x5f, 0xf0},
{0x60, 0xf0},
{0x61, 0xf0},
{0x62, 0x00},
{0x63, 0x00},
{0x64, 0x02},
{0x65, 0x20},
{0x66, 0x00},
{0x69, 0x0a},
{0x6b, 0x5a},
{0x6c, 0x04},
{0x6d, 0x55},
{0x6e, 0x00},
{0x6f, 0x9d},
{0x70, 0x21},
{0x71, 0x78},
{0x72, 0x11},
{0x73, 0x01},
{0x74, 0x10},
{0x75, 0x10},
{0x76, 0x01},
{0x77, 0x02},
{0x7A, 0x12},
{0x7B, 0x08},
{0x7C, 0x16},
{0x7D, 0x30},
{0x7E, 0x5e},
{0x7F, 0x72},
{0x80, 0x82},
{0x81, 0x8e},
{0x82, 0x9a},
{0x83, 0xa4},
{0x84, 0xac},
{0x85, 0xb8},
{0x86, 0xc3},
{0x87, 0xd6},
{0x88, 0xe6},
{0x89, 0xf2},
{0x8a, 0x24},
{0x8c, 0x80},
{0x90, 0x7d},
{0x91, 0x7b},
{0x9d, 0x02},
{0x9e, 0x02},
{0x9f, 0x7a},
{0xa0, 0x79},
{0xa1, 0x40},
{0xa4, 0x50},
{0xa5, 0x68},
{0xa6, 0x4a},
{0xa8, 0xc1},
{0xa9, 0xef},
{0xaa, 0x92},
{0xab, 0x04},
{0xac, 0x80},
{0xad, 0x80},
{0xae, 0x80},
{0xaf, 0x80},
{0xb2, 0xf2},
{0xb3, 0x20},
{0xb4, 0x20},
{0xb5, 0x00},
{0xb6, 0xaf},
{0xb6, 0xaf},
{0xbb, 0xae},
{0xbc, 0x7f},
{0xbd, 0x7f},
{0xbe, 0x7f},
{0xbf, 0x7f},
{0xbf, 0x7f},
{0xc0, 0xaa},
{0xc1, 0xc0},
{0xc2, 0x01},
{0xc3, 0x4e},
{0xc6, 0x05},
{0xc7, 0x81},
{0xc9, 0xe0},
{0xca, 0xe8},
{0xcb, 0xf0},
{0xcc, 0xd8},
{0xcd, 0x93},
{0x12, 0x63},
{0x40, 0x10},
};
/* Initialization sequence for QQVGA resolution (160x120) */
const char OV9655_QQVGA[][2]=
{
{0x00, 0x00},
{0x01, 0x80},
{0x02, 0x80},
{0x03, 0x02},
{0x04, 0x03},
{0x09, 0x01},
{0x0b, 0x57},
{0x0e, 0x61},
{0x0f, 0x40},
{0x11, 0x01},
{0x12, 0x62},
{0x13, 0xc7},
{0x14, 0x3a},
{0x16, 0x24},
{0x17, 0x18},
{0x18, 0x04},
{0x19, 0x01},
{0x1a, 0x81},
{0x1e, 0x00},
{0x24, 0x3c},
{0x25, 0x36},
{0x26, 0x72},
{0x27, 0x08},
{0x28, 0x08},
{0x29, 0x15},
{0x2a, 0x00},
{0x2b, 0x00},
{0x2c, 0x08},
{0x32, 0xa4},
{0x33, 0x00},
{0x34, 0x3f},
{0x35, 0x00},
{0x36, 0x3a},
{0x38, 0x72},
{0x39, 0x57},
{0x3a, 0xcc},
{0x3b, 0x04},
{0x3d, 0x99},
{0x3e, 0x0e},
{0x3f, 0xc1},
{0x40, 0xc0},
{0x41, 0x41},
{0x42, 0xc0},
{0x43, 0x0a},
{0x44, 0xf0},
{0x45, 0x46},
{0x46, 0x62},
{0x47, 0x2a},
{0x48, 0x3c},
{0x4a, 0xfc},
{0x4b, 0xfc},
{0x4c, 0x7f},
{0x4d, 0x7f},
{0x4e, 0x7f},
{0x4f, 0x98},
{0x50, 0x98},
{0x51, 0x00},
{0x52, 0x28},
{0x53, 0x70},
{0x54, 0x98},
{0x58, 0x1a},
{0x59, 0x85},
{0x5a, 0xa9},
{0x5b, 0x64},
{0x5c, 0x84},
{0x5d, 0x53},
{0x5e, 0x0e},
{0x5f, 0xf0},
{0x60, 0xf0},
{0x61, 0xf0},
{0x62, 0x00},
{0x63, 0x00},
{0x64, 0x02},
{0x65, 0x20},
{0x66, 0x00},
{0x69, 0x0a},
{0x6b, 0x5a},
{0x6c, 0x04},
{0x6d, 0x55},
{0x6e, 0x00},
{0x6f, 0x9d},
{0x70, 0x21},
{0x71, 0x78},
{0x72, 0x22},
{0x73, 0x02},
{0x74, 0x10},
{0x75, 0x10},
{0x76, 0x01},
{0x77, 0x02},
{0x7A, 0x12},
{0x7B, 0x08},
{0x7C, 0x16},
{0x7D, 0x30},
{0x7E, 0x5e},
{0x7F, 0x72},
{0x80, 0x82},
{0x81, 0x8e},
{0x82, 0x9a},
{0x83, 0xa4},
{0x84, 0xac},
{0x85, 0xb8},
{0x86, 0xc3},
{0x87, 0xd6},
{0x88, 0xe6},
{0x89, 0xf2},
{0x8a, 0x24},
{0x8c, 0x80},
{0x90, 0x7d},
{0x91, 0x7b},
{0x9d, 0x02},
{0x9e, 0x02},
{0x9f, 0x7a},
{0xa0, 0x79},
{0xa1, 0x40},
{0xa4, 0x50},
{0xa5, 0x68},
{0xa6, 0x4a},
{0xa8, 0xc1},
{0xa9, 0xef},
{0xaa, 0x92},
{0xab, 0x04},
{0xac, 0x80},
{0xad, 0x80},
{0xae, 0x80},
{0xaf, 0x80},
{0xb2, 0xf2},
{0xb3, 0x20},
{0xb4, 0x20},
{0xb5, 0x00},
{0xb6, 0xaf},
{0xb6, 0xaf},
{0xbb, 0xae},
{0xbc, 0x7f},
{0xbd, 0x7f},
{0xbe, 0x7f},
{0xbf, 0x7f},
{0xbf, 0x7f},
{0xc0, 0xaa},
{0xc1, 0xc0},
{0xc2, 0x01},
{0xc3, 0x4e},
{0xc6, 0x05},
{0xc7, 0x82},
{0xc9, 0xe0},
{0xca, 0xe8},
{0xcb, 0xf0},
{0xcc, 0xd8},
{0xcd, 0x93},
{0x12, 0x63},
{0x40, 0x10},
};
/**
* @}
*/
/** @defgroup OV9655_Private_Functions
* @{
*/
/**
* @brief Initializes the OV9655 CAMERA component.
* @param DeviceAddr: Device address on communication Bus.
* @param resolution: Camera resolution
* @retval None
*/
void ov9655_Init(uint16_t DeviceAddr, uint32_t resolution)
{
uint32_t index;
/* Initialize I2C */
CAMERA_IO_Init();
/* Prepare the camera to be configured by resetting all its registers */
CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_COM7, 0x80);
CAMERA_Delay(200);
/* Initialize OV9655 */
switch (resolution)
{
case CAMERA_R160x120:
{
for(index=0; index<(sizeof(OV9655_QQVGA)/2); index++)
{
CAMERA_IO_Write(DeviceAddr, OV9655_QQVGA[index][0], OV9655_QQVGA[index][1]);
CAMERA_Delay(2);
}
break;
}
case CAMERA_R320x240:
{
for(index=0; index<(sizeof(OV9655_QVGA)/2); index++)
{
CAMERA_IO_Write(DeviceAddr, OV9655_QVGA[index][0], OV9655_QVGA[index][1]);
CAMERA_Delay(2);
}
break;
}
case CAMERA_R480x272:
{
/* Not supported resolution */
break;
}
case CAMERA_R640x480:
{
for(index=0; index<(sizeof(OV9655_VGA)/2); index++)
{
CAMERA_IO_Write(DeviceAddr, OV9655_VGA[index][0], OV9655_VGA[index][1]);
CAMERA_Delay(2);
}
break;
}
default:
{
break;
}
}
}
/**
* @brief Configures the OV9655 camera feature.
* @param DeviceAddr: Device address on communication Bus.
* @param feature: Camera feature to be configured
* @param value: Value to be configured
* @param brightness_value: Brightness value to be configured
* @retval None
*/
void ov9655_Config(uint16_t DeviceAddr, uint32_t feature, uint32_t value, uint32_t brightness_value)
{
uint8_t tslb, mtx1, mtx2, mtx3, mtx4, mtx5, mtx6;
uint64_t value_tmp;
uint32_t br_value;
/* Convert the input value into ov9655 parameters */
value_tmp = ov9655_ConvertValue(feature, value);
br_value = (uint32_t)ov9655_ConvertValue(CAMERA_CONTRAST_BRIGHTNESS, brightness_value);
switch(feature)
{
case CAMERA_CONTRAST_BRIGHTNESS:
{
CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_BRTN, br_value);
CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_CNST1, value_tmp);
break;
}
case CAMERA_BLACK_WHITE:
case CAMERA_COLOR_EFFECT:
{
tslb = (uint8_t)(value_tmp >> 48);
mtx1 = (uint8_t)(value_tmp >> 40);
mtx2 = (uint8_t)(value_tmp >> 32);
mtx3 = (uint8_t)(value_tmp >> 24);
mtx4 = (uint8_t)(value_tmp >> 16);
mtx5 = (uint8_t)(value_tmp >> 8);
mtx6 = (uint8_t)(value_tmp);
CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_TSLB, tslb);
CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_MTX1, mtx1);
CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_MTX2, mtx2);
CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_MTX3, mtx3);
CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_MTX4, mtx4);
CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_MTX5, mtx5);
CAMERA_IO_Write(DeviceAddr, OV9655_SENSOR_MTX6, mtx6);
break;
}
default:
{
break;
}
}
}
/**
* @brief Read the OV9655 Camera identity.
* @param DeviceAddr: Device address on communication Bus.
* @retval the OV9655 ID
*/
uint16_t ov9655_ReadID(uint16_t DeviceAddr)
{
/* Initialize I2C */
CAMERA_IO_Init();
/* Get the camera ID */
return (CAMERA_IO_Read(DeviceAddr, OV9655_SENSOR_PIDH));
}
/******************************************************************************
Static Functions
*******************************************************************************/
/**
* @brief Convert input values into ov9655 parameters.
* @param feature: Camera feature to be configured
* @param value: Value to be configured
* @retval The converted value
*/
static uint64_t ov9655_ConvertValue(uint32_t feature, uint32_t value)
{
uint64_t ret = 0;
switch(feature)
{
case CAMERA_BLACK_WHITE:
{
switch(value)
{
case CAMERA_BLACK_WHITE_BW:
{
ret = OV9655_BLACK_WHITE_BW;
break;
}
case CAMERA_BLACK_WHITE_NEGATIVE:
{
ret = OV9655_BLACK_WHITE_NEGATIVE;
break;
}
case CAMERA_BLACK_WHITE_BW_NEGATIVE:
{
ret = OV9655_BLACK_WHITE_BW_NEGATIVE;
break;
}
case CAMERA_BLACK_WHITE_NORMAL:
{
ret = OV9655_BLACK_WHITE_NORMAL;
break;
}
default:
{
ret = OV9655_BLACK_WHITE_NORMAL;
break;
}
}
break;
}
case CAMERA_CONTRAST_BRIGHTNESS:
{
switch(value)
{
case CAMERA_BRIGHTNESS_LEVEL0:
{
ret = OV9655_BRIGHTNESS_LEVEL0;
break;
}
case CAMERA_BRIGHTNESS_LEVEL1:
{
ret = OV9655_BRIGHTNESS_LEVEL1;
break;
}
case CAMERA_BRIGHTNESS_LEVEL2:
{
ret = OV9655_BRIGHTNESS_LEVEL2;
break;
}
case CAMERA_BRIGHTNESS_LEVEL3:
{
ret = OV9655_BRIGHTNESS_LEVEL3;
break;
}
case CAMERA_BRIGHTNESS_LEVEL4:
{
ret = OV9655_BRIGHTNESS_LEVEL4;
break;
}
case CAMERA_CONTRAST_LEVEL0:
{
ret = OV9655_CONTRAST_LEVEL0;
break;
}
case CAMERA_CONTRAST_LEVEL1:
{
ret = OV9655_CONTRAST_LEVEL1;
break;
}
case CAMERA_CONTRAST_LEVEL2:
{
ret = OV9655_CONTRAST_LEVEL2;
break;
}
case CAMERA_CONTRAST_LEVEL3:
{
ret = OV9655_CONTRAST_LEVEL3;
break;
}
case CAMERA_CONTRAST_LEVEL4:
{
ret = OV9655_CONTRAST_LEVEL4;
break;
}
default:
{
ret = OV9655_CONTRAST_LEVEL0;
break;
}
}
break;
}
case CAMERA_COLOR_EFFECT:
{
switch(value)
{
case CAMERA_COLOR_EFFECT_ANTIQUE:
{
ret = OV9655_COLOR_EFFECT_ANTIQUE;
break;
}
case CAMERA_COLOR_EFFECT_BLUE:
{
ret = OV9655_COLOR_EFFECT_BLUE;
break;
}
case CAMERA_COLOR_EFFECT_GREEN:
{
ret = OV9655_COLOR_EFFECT_GREEN;
break;
}
case CAMERA_COLOR_EFFECT_RED:
{
ret = OV9655_COLOR_EFFECT_RED;
break;
}
case CAMERA_COLOR_EFFECT_NONE:
default:
{
ret = OV9655_COLOR_EFFECT_NONE;
break;
}
}
break;
default:
{
ret = 0;
break;
}
}
}
return ret;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,141 @@
/**
******************************************************************************
* @file ov9655.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the ov9655.c
* driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __OV9655_H
#define __OV9655_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/camera.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup ov9655
* @{
*/
/** @defgroup OV9655_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup OV9655_Exported_Constants
* @{
*/
/**
* @brief OV9655 ID
*/
#define OV9655_ID 0x96
/**
* @brief OV9655 Registers
*/
/* OV9655 Registers definition */
#define OV9655_SENSOR_PIDH 0x0A
#define OV9655_SENSOR_PIDL 0x0B
#define OV9655_SENSOR_COM7 0x12
#define OV9655_SENSOR_TSLB 0x3A
#define OV9655_SENSOR_MTX1 0x4F
#define OV9655_SENSOR_MTX2 0x50
#define OV9655_SENSOR_MTX3 0x51
#define OV9655_SENSOR_MTX4 0x52
#define OV9655_SENSOR_MTX5 0x53
#define OV9655_SENSOR_MTX6 0x54
#define OV9655_SENSOR_BRTN 0x55
#define OV9655_SENSOR_CNST1 0x56
#define OV9655_SENSOR_CNST2 0x57
/**
* @brief OV9655 Features Parameters
*/
#define OV9655_BRIGHTNESS_LEVEL0 0xB0 /* Brightness level -2 */
#define OV9655_BRIGHTNESS_LEVEL1 0x98 /* Brightness level -1 */
#define OV9655_BRIGHTNESS_LEVEL2 0x00 /* Brightness level 0 */
#define OV9655_BRIGHTNESS_LEVEL3 0x18 /* Brightness level +1 */
#define OV9655_BRIGHTNESS_LEVEL4 0x30 /* Brightness level +2 */
#define OV9655_BLACK_WHITE_BW 0xCC000000000000 /* Black and white effect */
#define OV9655_BLACK_WHITE_NEGATIVE 0xEC808000008080 /* Negative effect */
#define OV9655_BLACK_WHITE_BW_NEGATIVE 0xEC000000000000 /* BW and Negative effect */
#define OV9655_BLACK_WHITE_NORMAL 0xCC808000008080 /* Normal effect */
#define OV9655_CONTRAST_LEVEL0 0x30 /* Contrast level -2 */
#define OV9655_CONTRAST_LEVEL1 0x38 /* Contrast level -1 */
#define OV9655_CONTRAST_LEVEL2 0x40 /* Contrast level 0 */
#define OV9655_CONTRAST_LEVEL3 0x50 /* Contrast level +1 */
#define OV9655_CONTRAST_LEVEL4 0x60 /* Contrast level +2 */
#define OV9655_COLOR_EFFECT_NONE 0xCC808000008080 /* No color effect */
#define OV9655_COLOR_EFFECT_ANTIQUE 0xCC000020F00000 /* Antique effect */
#define OV9655_COLOR_EFFECT_BLUE 0xCC000000000060 /* Blue effect */
#define OV9655_COLOR_EFFECT_GREEN 0xCC000000008000 /* Green effect */
#define OV9655_COLOR_EFFECT_RED 0xCC600000000000 /* Red effect */
/**
* @}
*/
/** @defgroup OV9655_Exported_Functions
* @{
*/
void ov9655_Init(uint16_t DeviceAddr, uint32_t resolution);
void ov9655_Config(uint16_t DeviceAddr, uint32_t feature, uint32_t value, uint32_t BR_value);
uint16_t ov9655_ReadID(uint16_t DeviceAddr);
void CAMERA_IO_Init(void);
void CAMERA_IO_Write(uint8_t addr, uint8_t reg, uint8_t value);
uint8_t CAMERA_IO_Read(uint8_t addr, uint8_t reg);
void CAMERA_Delay(uint32_t delay);
/* CAMERA driver structure */
extern CAMERA_DrvTypeDef ov9655_drv;
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __OV9655_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,73 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for RK043FN48H-CT672B LCD Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-rk043fn48h-ct672b-lcd-component-drivers"><small>Release Notes for</small> <mark>RK043FN48H-CT672B LCD Component Drivers</mark></h1>
<p>Copyright © 2015 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the RK043FN48H-CT672B LCD component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.2 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section21" aria-hidden="true"> <label for="collapse-section21" aria-hidden="true">V1.0.1 / 31-August-2018</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 25-June-2015</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>First official release</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,103 @@
/**
******************************************************************************
* @file rk043fn48h.h
* @author MCD Application Team
* @brief This file contains all the constants parameters for the RK043FN48H-CT672B
* LCD component.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __RK043FN48H_H
#define __RK043FN48H_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup rk043fn48h
* @{
*/
/** @defgroup RK043FN48H_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup RK043FN48H_Exported_Constants
* @{
*/
/**
* @brief RK043FN48H Size
*/
#define RK043FN48H_WIDTH ((uint16_t)480) /* LCD PIXEL WIDTH */
#define RK043FN48H_HEIGHT ((uint16_t)272) /* LCD PIXEL HEIGHT */
/**
* @brief RK043FN48H Timing
*/
#define RK043FN48H_HSYNC ((uint16_t)41) /* Horizontal synchronization */
#define RK043FN48H_HBP ((uint16_t)13) /* Horizontal back porch */
#define RK043FN48H_HFP ((uint16_t)32) /* Horizontal front porch */
#define RK043FN48H_VSYNC ((uint16_t)10) /* Vertical synchronization */
#define RK043FN48H_VBP ((uint16_t)2) /* Vertical back porch */
#define RK043FN48H_VFP ((uint16_t)2) /* Vertical front porch */
/**
* @brief RK043FN48H frequency divider
*/
#define RK043FN48H_FREQUENCY_DIVIDER 5 /* LCD Frequency divider */
/**
* @}
*/
/** @defgroup RK043FN48H_Exported_Functions
* @{
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __RK043FN48H_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for ST25DV-I2C Component Driver</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-st25dv-i2c-component-driver"><small>Release Notes for</small> <mark>ST25DV-I2C Component Driver</mark></h1>
<p>Copyright © 2020 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the ST25DV-I2C component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section19" checked aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.0 / 30-April-2020</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>First official release.</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,459 @@
/**
******************************************************************************
* @file st25dv.h
* @author MMY Application Team
* @brief This file provides set of driver functions to manage communication
* @brief between MCU and ST25DV chip
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef ST25DV_H
#define ST25DV_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "st25dv_reg.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup ST25DV
* @{
*/
/* Exported types ------------------------------------------------------------*/
/**
* @brief ST25DV Enable Disable enumerator definition.
*/
typedef enum
{
ST25DV_DISABLE = 0,
ST25DV_ENABLE
} ST25DV_EN_STATUS;
/**
* @brief ST25DV Energy Harvesting mode enumerator definition.
*/
typedef enum
{
ST25DV_EH_ACTIVE_AFTER_BOOT = 0,
ST25DV_EH_ON_DEMAND
} ST25DV_EH_MODE_STATUS;
/**
* @brief ST25DV FIELD status enumerator definition.
*/
typedef enum
{
ST25DV_FIELD_OFF = 0,
ST25DV_FIELD_ON
} ST25DV_FIELD_STATUS;
/**
* @brief ST25DV VCC status enumerator definition
*/
typedef enum
{
ST25DV_VCC_OFF = 0,
ST25DV_VCC_ON
} ST25DV_VCC_STATUS;
/**
* @brief ST25DV protection status enumerator definition
*/
typedef enum
{
ST25DV_NO_PROT = 0,
ST25DV_WRITE_PROT,
ST25DV_READ_PROT,
ST25DV_READWRITE_PROT
} ST25DV_PROTECTION_CONF;
/**
* @brief ST25DV area protection enumerator definition.
*/
typedef enum
{
ST25DV_PROT_ZONE1 = 0,
ST25DV_PROT_ZONE2,
ST25DV_PROT_ZONE3,
ST25DV_PROT_ZONE4
} ST25DV_PROTECTION_ZONE;
/**
* @brief ST25DV password protection status enumerator definition.
*/
typedef enum
{
ST25DV_NOT_PROTECTED = 0,
ST25DV_PROT_PASSWD1,
ST25DV_PROT_PASSWD2,
ST25DV_PROT_PASSWD3
} ST25DV_PASSWD_PROT_STATUS;
/**
* @brief ST25DV lock status enumerator definition.
*/
typedef enum
{
ST25DV_UNLOCKED = 0,
ST25DV_LOCKED
} ST25DV_LOCK_STATUS;
/**
* @brief ST25DV Number of Blocks for the CCFile enumerator definition.
*/
typedef enum
{
ST25DV_CCFILE_1BLCK = 0,
ST25DV_CCFILE_2BLCK
} ST25DV_CCFILE_BLOCK;
/**
* @brief ST25DV session status enumerator definition.
*/
typedef enum
{
ST25DV_SESSION_CLOSED = 0,
ST25DV_SESSION_OPEN
} ST25DV_I2CSSO_STATUS;
/**
* @brief ST25DV area end address enumerator definition.
*/
typedef enum
{
ST25DV_ZONE_END1 = 0,
ST25DV_ZONE_END2,
ST25DV_ZONE_END3
} ST25DV_END_ZONE;
/**
* @brief ST25DV IT pulse duration enumerator definition.
*/
typedef enum
{
ST25DV_302_US = 0,
ST25DV_264_US,
ST25DV_226_US,
ST25DV_188_US,
ST25DV_151_US,
ST25DV_113_US,
ST25DV_75_US,
ST25DV_37_US
} ST25DV_PULSE_DURATION;
/**
* @brief ST25DV Mailbox Current Message enumerator definition
*/
typedef enum
{
ST25DV_NO_MSG = 0,
ST25DV_HOST_MSG,
ST25DV_RF_MSG
} ST25DV_CURRENT_MSG;
/**
* @brief ST25DV EH Ctrl structure definition
*/
typedef struct
{
ST25DV_EN_STATUS EH_EN_Mode;
ST25DV_EN_STATUS EH_on;
ST25DV_EN_STATUS Field_on;
ST25DV_EN_STATUS VCC_on;
} ST25DV_EH_CTRL;
/**
* @brief ST25DV GPO structure definition
*/
typedef struct
{
ST25DV_EN_STATUS GPO_RFUser_en;
ST25DV_EN_STATUS GPO_RFActivity_en;
ST25DV_EN_STATUS GPO_RFInterrupt_en;
ST25DV_EN_STATUS GPO_FieldChange_en;
ST25DV_EN_STATUS GPO_RFPutMsg_en;
ST25DV_EN_STATUS GPO_RFGetMsg_en;
ST25DV_EN_STATUS GPO_RFWrite_en;
ST25DV_EN_STATUS GPO_Enable;
} ST25DV_GPO;
/**
* @brief ST25DV RF Management structure definition.
*/
typedef struct
{
ST25DV_EN_STATUS RfDisable;
ST25DV_EN_STATUS RfSleep;
} ST25DV_RF_MNGT;
/**
* @brief ST25DV RF Area protection structure definition.
*/
typedef struct
{
ST25DV_PASSWD_PROT_STATUS PasswdCtrl;
ST25DV_PROTECTION_CONF RWprotection;
} ST25DV_RF_PROT_ZONE;
/**
* @brief ST25DV I2C Area protection structure definition.
*/
typedef struct
{
ST25DV_PROTECTION_CONF ProtectZone1;
ST25DV_PROTECTION_CONF ProtectZone2;
ST25DV_PROTECTION_CONF ProtectZone3;
ST25DV_PROTECTION_CONF ProtectZone4;
} ST25DV_I2C_PROT_ZONE;
/**
* @brief ST25DV MB_CTRL_DYN register structure definition.
*/
typedef struct
{
uint8_t MbEnable;
uint8_t HostPutMsg;
uint8_t RfPutMsg;
uint8_t HostMissMsg;
uint8_t RFMissMsg;
ST25DV_CURRENT_MSG CurrentMsg;
} ST25DV_MB_CTRL_DYN_STATUS;
/**
* @brief ST25DV Lock CCFile structure definition.
*/
typedef struct
{
ST25DV_LOCK_STATUS LckBck0;
ST25DV_LOCK_STATUS LckBck1;
} ST25DV_LOCK_CCFILE;
/**
* @brief ST25DV Memory size structure definition.
*/
typedef struct
{
uint8_t BlockSize;
uint16_t Mem_Size;
} ST25DV_MEM_SIZE;
/**
* @brief ST25DV UID information structure definition.
*/
typedef struct
{
uint32_t MsbUid;
uint32_t LsbUid;
} ST25DV_UID;
/**
* @brief ST25DV Password structure definition.
*/
typedef struct
{
uint32_t MsbPasswd;
uint32_t LsbPasswd;
} ST25DV_PASSWD;
typedef int32_t (*ST25DV_Init_Func) (void);
typedef int32_t (*ST25DV_DeInit_Func) (void);
typedef uint32_t (*ST25DV_GetTick_Func) (void);
typedef int32_t (*ST25DV_Write_Func)(uint16_t, uint16_t, const uint8_t*, uint16_t);
typedef int32_t (*ST25DV_Read_Func) (uint16_t, uint16_t, uint8_t*, uint16_t);
typedef int32_t (*ST25DV_IsReady_Func) (uint16_t, const uint32_t);
typedef struct {
ST25DV_Init_Func Init;
ST25DV_DeInit_Func DeInit;
ST25DV_IsReady_Func IsReady;
ST25DV_Write_Func Write;
ST25DV_Read_Func Read;
ST25DV_GetTick_Func GetTick;
} ST25DV_IO_t;
typedef struct {
ST25DV_IO_t IO ;
st25dv_ctx_t Ctx ;
uint32_t IsInitialized;
} ST25DV_Object_t;
#ifndef DOXYGEN_SHOULD_SKIP_THIS
/**
* @brief NFCTAG standard driver API structure definition.
*/
typedef struct
{
int32_t (*Init)( void* );
int32_t (*ReadID)( void*, uint8_t * const );
int32_t (*IsReady)( void*, const uint32_t );
int32_t (*GetITStatus)( void*, uint16_t * const );
int32_t (*ConfigIT)( void*, const uint16_t );
int32_t (*ReadData)( void*, uint8_t * const, const uint16_t, const uint16_t );
int32_t (*WriteData)( void*, const uint8_t * const, const uint16_t, const uint16_t );
} NFCTAG_DrvTypeDef;
typedef struct
{
int32_t (*Init)( ST25DV_Object_t* );
int32_t (*ReadID)( ST25DV_Object_t*, uint8_t * const );
int32_t (*IsReady)( ST25DV_Object_t*, const uint32_t );
int32_t (*GetITStatus)( ST25DV_Object_t*, uint16_t * const );
int32_t (*ConfigIT)( ST25DV_Object_t*, const uint16_t );
int32_t (*ReadData)( ST25DV_Object_t*, uint8_t * const, const uint16_t, const uint16_t );
int32_t (*WriteData)( ST25DV_Object_t*, const uint8_t * const, const uint16_t, const uint16_t );
} ST25DV_Drv_t;
#endif
/* Exported constants --------------------------------------------------------*/
/** @brief ST25DV 4Kbits ICref */
#define I_AM_ST25DV04 0x24
/** @brief ST25DV 16/64Kbits ICref */
#define I_AM_ST25DV64 0x26
/** @brief Check ST25DV Open Drain version */
#define ST25DV_AM_I_OPEN_DRAIN(x) (((x) == 0x26) || ((x) == 0x24))
/** @brief Check ST25DV CMOS version */
#define ST25DV_AM_I_CMOS(x) (((x) == 0x27) || ((x) == 0x25))
#ifndef NULL
#define NULL (void *) 0
#endif
/** @brief I2C address to be used for ST25DV Data accesses. */
#define ST25DV_ADDR_DATA_I2C 0xA6
/** @brief I2C address to be used for ST25DV System accesses. */
#define ST25DV_ADDR_SYST_I2C 0xAE
/** @brief I2C Time out (ms), min value : (Max write bytes) / (Internal page write) * tw (256/4)*5. */
#define ST25DV_WRITE_TIMEOUT 320
/** @brief Size of the ST25DV write buffer. */
#define ST25DV_MAX_WRITE_BYTE 256
/** @brief Size of the ST25DVMailbox memory. */
#define ST25DV_MAX_MAILBOX_LENGTH 256
/** @brief Offset of ST25DV dynamic registers. */
#define ST25DV_IS_DYNAMIC_REGISTER 0x2000
/* External variables --------------------------------------------------------*/
/* NFCTAG driver structure */
extern ST25DV_Drv_t St25Dv_Drv;
/* Exported macro ------------------------------------------------------------*/
/* Imported functions ------------------------------------------------------- */
/* Exported functions ------------------------------------------------------- */
int32_t ST25DV_ReadRegister( ST25DV_Object_t*, uint8_t * const, const uint16_t, const uint16_t );
int32_t ST25DV_WriteRegister( ST25DV_Object_t*, const uint8_t * const, const uint16_t, const uint16_t );
int32_t ST25DV_RegisterBusIO (ST25DV_Object_t* pObj, ST25DV_IO_t *pIO);
int32_t ST25DV_ReadMemSize( ST25DV_Object_t* pObj, ST25DV_MEM_SIZE * const pSizeInfo );
int32_t ST25DV_ReadICRev(ST25DV_Object_t* pObj, uint8_t * const pICRev );
int32_t ST25DV_ReadITPulse(ST25DV_Object_t* pObj, ST25DV_PULSE_DURATION * const pITtime );
int32_t ST25DV_WriteITPulse(ST25DV_Object_t* pObj, const ST25DV_PULSE_DURATION ITtime );
int32_t ST25DV_ReadUID(ST25DV_Object_t* pObj, ST25DV_UID * const pUid );
int32_t ST25DV_ReadDSFID(ST25DV_Object_t* pObj, uint8_t * const pDsfid );
int32_t ST25DV_ReadDsfidRFProtection(ST25DV_Object_t* pObj, ST25DV_LOCK_STATUS * const pLockDsfid );
int32_t ST25DV_ReadAFI(ST25DV_Object_t* pObj, uint8_t * const pAfi );
int32_t ST25DV_ReadAfiRFProtection(ST25DV_Object_t* pObj, ST25DV_LOCK_STATUS * const pLockAfi );
int32_t ST25DV_ReadI2CProtectZone(ST25DV_Object_t* pObj, ST25DV_I2C_PROT_ZONE * const pProtZone );
int32_t ST25DV_WriteI2CProtectZonex( ST25DV_Object_t* pObj, const ST25DV_PROTECTION_ZONE Zone, const ST25DV_PROTECTION_CONF ReadWriteProtection );
int32_t ST25DV_ReadLockCCFile( ST25DV_Object_t* pObj, ST25DV_LOCK_CCFILE * const pLockCCFile );
int32_t ST25DV_WriteLockCCFile( ST25DV_Object_t* pObj, const ST25DV_CCFILE_BLOCK NbBlockCCFile, const ST25DV_LOCK_STATUS LockCCFile );
int32_t ST25DV_ReadLockCFG( ST25DV_Object_t* pObj, ST25DV_LOCK_STATUS * const pLockCfg );
int32_t ST25DV_WriteLockCFG( ST25DV_Object_t* pObj, const ST25DV_LOCK_STATUS LockCfg );
int32_t ST25DV_PresentI2CPassword( ST25DV_Object_t* pObj, const ST25DV_PASSWD PassWord );
int32_t ST25DV_WriteI2CPassword( ST25DV_Object_t* pObj, const ST25DV_PASSWD PassWord );
int32_t ST25DV_ReadRFZxSS( ST25DV_Object_t* pObj, const ST25DV_PROTECTION_ZONE Zone, ST25DV_RF_PROT_ZONE * const pRfprotZone );
int32_t ST25DV_WriteRFZxSS( ST25DV_Object_t* pObj, const ST25DV_PROTECTION_ZONE Zone, const ST25DV_RF_PROT_ZONE RfProtZone );
int32_t ST25DV_ReadEndZonex( ST25DV_Object_t* pObj, const ST25DV_END_ZONE EndZone, uint8_t * pEndZ );
int32_t ST25DV_WriteEndZonex( ST25DV_Object_t* pObj, const ST25DV_END_ZONE EndZone, const uint8_t EndZ );
int32_t ST25DV_InitEndZone( ST25DV_Object_t* pObj );
int32_t ST25DV_CreateUserZone( ST25DV_Object_t* pObj, uint16_t Zone1Length, uint16_t Zone2Length, uint16_t Zone3Length, uint16_t Zone4Length );
int32_t ST25DV_ReadMemSize( ST25DV_Object_t* pObj, ST25DV_MEM_SIZE * const pSizeInfo );
int32_t ST25DV_ReadEHMode( ST25DV_Object_t* pObj, ST25DV_EH_MODE_STATUS * const pEH_mode );
int32_t ST25DV_WriteEHMode( ST25DV_Object_t* pObj, const ST25DV_EH_MODE_STATUS EH_mode );
int32_t ST25DV_ReadRFMngt( ST25DV_Object_t* pObj, ST25DV_RF_MNGT * const pRF_Mngt );
int32_t ST25DV_WriteRFMngt( ST25DV_Object_t* pObj, const uint8_t Rfmngt );
int32_t ST25DV_GetRFDisable( ST25DV_Object_t* pObj, ST25DV_EN_STATUS * const pRFDisable );
int32_t ST25DV_SetRFDisable( ST25DV_Object_t* pObj );
int32_t ST25DV_ResetRFDisable( ST25DV_Object_t* pObj );
int32_t ST25DV_GetRFSleep( ST25DV_Object_t* pObj, ST25DV_EN_STATUS * const pRFSleep );
int32_t ST25DV_SetRFSleep( ST25DV_Object_t* pObj );
int32_t ST25DV_ResetRFSleep( ST25DV_Object_t* pObj );
int32_t ST25DV_ReadMBMode( ST25DV_Object_t* pObj, ST25DV_EN_STATUS * const pMB_mode );
int32_t ST25DV_WriteMBMode( ST25DV_Object_t* pObj, const ST25DV_EN_STATUS MB_mode );
int32_t ST25DV_ReadMBWDG( ST25DV_Object_t* pObj, uint8_t * const pWdgDelay );
int32_t ST25DV_WriteMBWDG( ST25DV_Object_t* pObj, const uint8_t WdgDelay );
int32_t ST25DV_ReadMailboxData( ST25DV_Object_t* pObj, uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte );
int32_t ST25DV_WriteMailboxData( ST25DV_Object_t* pObj, const uint8_t * const pData, const uint16_t NbByte );
int32_t ST25DV_ReadMailboxRegister( ST25DV_Object_t* pObj, uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte );
int32_t ST25DV_WriteMailboxRegister( ST25DV_Object_t* pObj, const uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte );
int32_t ST25DV_ReadI2CSecuritySession_Dyn( ST25DV_Object_t* pObj, ST25DV_I2CSSO_STATUS * const pSession );
int32_t ST25DV_ReadITSTStatus_Dyn( ST25DV_Object_t* pObj, uint8_t * const pITStatus );
int32_t ST25DV_ReadGPO_Dyn( ST25DV_Object_t* pObj, uint8_t *GPOConfig );
int32_t ST25DV_GetGPO_en_Dyn( ST25DV_Object_t* pObj, ST25DV_EN_STATUS * const pGPO_en );
int32_t ST25DV_SetGPO_en_Dyn( ST25DV_Object_t* pObj );
int32_t ST25DV_ResetGPO_en_Dyn( ST25DV_Object_t* pObj );
int32_t ST25DV_ReadEHCtrl_Dyn( ST25DV_Object_t* pObj, ST25DV_EH_CTRL * const pEH_CTRL );
int32_t ST25DV_GetEHENMode_Dyn( ST25DV_Object_t* pObj, ST25DV_EN_STATUS * const pEH_Val );
int32_t ST25DV_SetEHENMode_Dyn( ST25DV_Object_t* pObj );
int32_t ST25DV_ResetEHENMode_Dyn( ST25DV_Object_t* pObj );
int32_t ST25DV_GetEHON_Dyn( ST25DV_Object_t* pObj, ST25DV_EN_STATUS * const pEHON );
int32_t ST25DV_GetRFField_Dyn( ST25DV_Object_t* pObj, ST25DV_FIELD_STATUS * const pRF_Field );
int32_t ST25DV_GetVCC_Dyn( ST25DV_Object_t* pObj, ST25DV_VCC_STATUS * const pVCC );
int32_t ST25DV_ReadRFMngt_Dyn( ST25DV_Object_t* pObj, ST25DV_RF_MNGT * const pRF_Mngt );
int32_t ST25DV_WriteRFMngt_Dyn( ST25DV_Object_t* pObj, const uint8_t RF_Mngt );
int32_t ST25DV_GetRFDisable_Dyn( ST25DV_Object_t* pObj, ST25DV_EN_STATUS * const pRFDisable );
int32_t ST25DV_SetRFDisable_Dyn( ST25DV_Object_t* pObj );
int32_t ST25DV_ResetRFDisable_Dyn( ST25DV_Object_t* pObj );
int32_t ST25DV_GetRFSleep_Dyn( ST25DV_Object_t* pObj, ST25DV_EN_STATUS * const pRFSleep );
int32_t ST25DV_SetRFSleep_Dyn( ST25DV_Object_t* pObj );
int32_t ST25DV_ResetRFSleep_Dyn( ST25DV_Object_t* pObj );
int32_t ST25DV_ReadMBCtrl_Dyn( ST25DV_Object_t* pObj, ST25DV_MB_CTRL_DYN_STATUS * const pCtrlStatus );
int32_t ST25DV_GetMBEN_Dyn( ST25DV_Object_t* pObj, ST25DV_EN_STATUS * const pMBEN );
int32_t ST25DV_SetMBEN_Dyn( ST25DV_Object_t* pObj );
int32_t ST25DV_ResetMBEN_Dyn( ST25DV_Object_t* pObj );
int32_t ST25DV_ReadMBLength_Dyn( ST25DV_Object_t* pObj, uint8_t * const pMBLength );
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* ST25DV_H */
/******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,501 @@
/**
******************************************************************************
* @file st25dv_reg.h
* @author MMY Application Team
* @brief This file provides set of functions to access st25dv-i2c registers.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
******************************************************************************
*/
#ifndef ST25DV_REG_H
#define ST25DV_REG_H
#include <cmsis_compiler.h>
/* Registers i2c address */
/** @brief ST25DV GPO register address. */
#define ST25DV_GPO_REG 0x0000
/** @brief ST25DV IT duration register address. */
#define ST25DV_ITTIME_REG 0x0001
/** @brief ST25DV Energy Harvesting register address. */
#define ST25DV_EH_MODE_REG 0x0002
/** @brief ST25DV RF management register address. */
#define ST25DV_RF_MNGT_REG 0x0003
/** @brief ST25DV Area 1 security register address. */
#define ST25DV_RFA1SS_REG 0x0004
/** @brief ST25DV Area 1 end address register address. */
#define ST25DV_ENDA1_REG 0x0005
/** @brief ST25DV Area 2 security register address. */
#define ST25DV_RFA2SS_REG 0x0006
/** @brief ST25DV Area 2 end address register address. */
#define ST25DV_ENDA2_REG 0x0007
/** @brief ST25DV Area 3 security register address. */
#define ST25DV_RFA3SS_REG 0x0008
/** @brief ST25DV Area 3 end address register address. */
#define ST25DV_ENDA3_REG 0x0009
/** @brief ST25DV Area 4 security register address. */
#define ST25DV_RFA4SS_REG 0x000A
/** @brief ST25DV I2C security register address. */
#define ST25DV_I2CSS_REG 0x000B
/** @brief ST25DV Capability Container lock register address. */
#define ST25DV_LOCKCCFILE_REG 0x000C
/** @brief ST25DV Mailbox mode register address. */
#define ST25DV_MB_MODE_REG 0x000D
/** @brief ST25DV Mailbox Watchdog register address. */
#define ST25DV_MB_WDG_REG 0x000E
/** @brief ST25DV Configuration lock register address. */
#define ST25DV_LOCKCFG_REG 0x000F
/** @brief ST25DV DSFID lock register address. */
#define ST25DV_LOCKDSFID_REG 0x0010
/** @brief ST25DV AFI lock register address. */
#define ST25DV_LOCKAFI_REG 0x0011
/** @brief ST25DV DSFID register address. */
#define ST25DV_DSFID_REG 0x0012
/** @brief ST25DV AFI register address. */
#define ST25DV_AFI_REG 0x0013
/** @brief ST25DV Memory size register address. */
#define ST25DV_MEM_SIZE_LSB_REG 0x0014
/** @brief ST25DV Memory size register address. */
#define ST25DV_MEM_SIZE_MSB_REG 0x0015
/** @brief ST25DV Block size register address. */
#define ST25DV_BLK_SIZE_REG 0x0016
//** @brief ST25DV ICref register address. */
#define ST25DV_ICREF_REG 0x0017
/** @brief ST25DV UID register address. */
#define ST25DV_UID_REG 0x0018
/** @brief ST25DV IC revision register address. */
#define ST25DV_ICREV_REG 0x0020
/** @brief ST25DV I2C password register address. */
#define ST25DV_I2CPASSWD_REG 0x0900
/* Dynamic Registers i2c address */
/** @brief ST25DV GPO dynamic register address. */
#define ST25DV_GPO_DYN_REG 0x2000
/** @brief ST25DV Energy Harvesting control dynamic register address. */
#define ST25DV_EH_CTRL_DYN_REG 0x2002
/** @brief ST25DV RF management dynamic register address. */
#define ST25DV_RF_MNGT_DYN_REG 0x2003
/** @brief ST25DV I2C secure session opened dynamic register address. */
#define ST25DV_I2C_SSO_DYN_REG 0x2004
/** @brief ST25DV Interrupt status dynamic register address. */
#define ST25DV_ITSTS_DYN_REG 0x2005
/** @brief ST25DV Mailbox control dynamic register address. */
#define ST25DV_MB_CTRL_DYN_REG 0x2006
/** @brief ST25DV Mailbox message length dynamic register address. */
#define ST25DV_MBLEN_DYN_REG 0x2007
/** @brief ST25DV Mailbox buffer address. */
#define ST25DV_MAILBOX_RAM_REG 0x2008
/* Registers fields definitions */
/* MB_MODE */
#define ST25DV_MB_MODE_RW_SHIFT (0)
#define ST25DV_MB_MODE_RW_FIELD 0xFE
#define ST25DV_MB_MODE_RW_MASK 0x01
/* MB_LEN_Dyn */
#define ST25DV_MBLEN_DYN_MBLEN_SHIFT (0)
#define ST25DV_MBLEN_DYN_MBLEN_FIELD 0x00
#define ST25DV_MBLEN_DYN_MBLEN_MASK 0xFF
/* MB_CTRL_Dyn */
#define ST25DV_MB_CTRL_DYN_MBEN_SHIFT (0)
#define ST25DV_MB_CTRL_DYN_MBEN_FIELD 0xFE
#define ST25DV_MB_CTRL_DYN_MBEN_MASK 0x01
#define ST25DV_MB_CTRL_DYN_HOSTPUTMSG_SHIFT (1)
#define ST25DV_MB_CTRL_DYN_HOSTPUTMSG_FIELD 0xFD
#define ST25DV_MB_CTRL_DYN_HOSTPUTMSG_MASK 0x02
#define ST25DV_MB_CTRL_DYN_RFPUTMSG_SHIFT (2)
#define ST25DV_MB_CTRL_DYN_RFPUTMSG_FIELD 0xFB
#define ST25DV_MB_CTRL_DYN_RFPUTMSG_MASK 0x04
#define ST25DV_MB_CTRL_DYN_STRESERVED_SHIFT (3)
#define ST25DV_MB_CTRL_DYN_STRESERVED_FIELD 0xF7
#define ST25DV_MB_CTRL_DYN_STRESERVED_MASK 0x08
#define ST25DV_MB_CTRL_DYN_HOSTMISSMSG_SHIFT (4)
#define ST25DV_MB_CTRL_DYN_HOSTMISSMSG_FIELD 0xEF
#define ST25DV_MB_CTRL_DYN_HOSTMISSMSG_MASK 0x10
#define ST25DV_MB_CTRL_DYN_RFMISSMSG_SHIFT (5)
#define ST25DV_MB_CTRL_DYN_RFMISSMSG_FIELD 0xDF
#define ST25DV_MB_CTRL_DYN_RFMISSMSG_MASK 0x20
#define ST25DV_MB_CTRL_DYN_CURRENTMSG_SHIFT (6)
#define ST25DV_MB_CTRL_DYN_CURRENTMSG_FIELD 0x3F
#define ST25DV_MB_CTRL_DYN_CURRENTMSG_MASK 0xC0
/* MB_WDG */
#define ST25DV_MB_WDG_DELAY_SHIFT (0)
#define ST25DV_MB_WDG_DELAY_FIELD 0xF8
#define ST25DV_MB_WDG_DELAY_MASK 0x07
/* GPO */
#define ST25DV_GPO_RFUSERSTATE_SHIFT (0)
#define ST25DV_GPO_RFUSERSTATE_FIELD 0xFE
#define ST25DV_GPO_RFUSERSTATE_MASK 0x01
#define ST25DV_GPO_RFACTIVITY_SHIFT (1)
#define ST25DV_GPO_RFACTIVITY_FIELD 0xFD
#define ST25DV_GPO_RFACTIVITY_MASK 0x02
#define ST25DV_GPO_RFINTERRUPT_SHIFT (2)
#define ST25DV_GPO_RFINTERRUPT_FIELD 0xFB
#define ST25DV_GPO_RFINTERRUPT_MASK 0x04
#define ST25DV_GPO_FIELDCHANGE_SHIFT (3)
#define ST25DV_GPO_FIELDCHANGE_FIELD 0xF7
#define ST25DV_GPO_FIELDCHANGE_MASK 0x08
#define ST25DV_GPO_RFPUTMSG_SHIFT (4)
#define ST25DV_GPO_RFPUTMSG_FIELD 0xEF
#define ST25DV_GPO_RFPUTMSG_MASK 0x10
#define ST25DV_GPO_RFGETMSG_SHIFT (5)
#define ST25DV_GPO_RFGETMSG_FIELD 0xDF
#define ST25DV_GPO_RFGETMSG_MASK 0x20
#define ST25DV_GPO_RFWRITE_SHIFT (6)
#define ST25DV_GPO_RFWRITE_FIELD 0xBF
#define ST25DV_GPO_RFWRITE_MASK 0x40
#define ST25DV_GPO_ENABLE_SHIFT (7)
#define ST25DV_GPO_ENABLE_FIELD 0x7F
#define ST25DV_GPO_ENABLE_MASK 0x80
#define ST25DV_GPO_ALL_SHIFT (0)
#define ST25DV_GPO_ALL_MASK 0xFF
/* GPO_Dyn */
#define ST25DV_GPO_DYN_RFUSERSTATE_SHIFT (0)
#define ST25DV_GPO_DYN_RFUSERSTATE_FIELD 0xFE
#define ST25DV_GPO_DYN_RFUSERSTATE_MASK 0x01
#define ST25DV_GPO_DYN_RFACTIVITY_SHIFT (1)
#define ST25DV_GPO_DYN_RFACTIVITY_FIELD 0xFD
#define ST25DV_GPO_DYN_RFACTIVITY_MASK 0x02
#define ST25DV_GPO_DYN_RFINTERRUPT_SHIFT (2)
#define ST25DV_GPO_DYN_RFINTERRUPT_FIELD 0xFB
#define ST25DV_GPO_DYN_RFINTERRUPT_MASK 0x04
#define ST25DV_GPO_DYN_FIELDCHANGE_SHIFT (3)
#define ST25DV_GPO_DYN_FIELDCHANGE_FIELD 0xF7
#define ST25DV_GPO_DYN_FIELDCHANGE_MASK 0x08
#define ST25DV_GPO_DYN_RFPUTMSG_SHIFT (4)
#define ST25DV_GPO_DYN_RFPUTMSG_FIELD 0xEF
#define ST25DV_GPO_DYN_RFPUTMSG_MASK 0x10
#define ST25DV_GPO_DYN_RFGETMSG_SHIFT (5)
#define ST25DV_GPO_DYN_RFGETMSG_FIELD 0xDF
#define ST25DV_GPO_DYN_RFGETMSG_MASK 0x20
#define ST25DV_GPO_DYN_RFWRITE_SHIFT (6)
#define ST25DV_GPO_DYN_RFWRITE_FIELD 0xBF
#define ST25DV_GPO_DYN_RFWRITE_MASK 0x40
#define ST25DV_GPO_DYN_ENABLE_SHIFT (7)
#define ST25DV_GPO_DYN_ENABLE_FIELD 0x7F
#define ST25DV_GPO_DYN_ENABLE_MASK 0x80
#define ST25DV_GPO_DYN_ALL_SHIFT (0)
#define ST25DV_GPO_DYN_ALL_MASK 0xFF
/* ITTIME */
#define ST25DV_ITTIME_DELAY_SHIFT (0)
#define ST25DV_ITTIME_DELAY_FIELD 0xFC
#define ST25DV_ITTIME_DELAY_MASK 0x03
/* ITSTS_Dyn */
#define ST25DV_ITSTS_DYN_RFUSERSTATE_SHIFT (0)
#define ST25DV_ITSTS_DYN_RFUSERSTATE_FIELD 0xFE
#define ST25DV_ITSTS_DYN_RFUSERSTATE_MASK 0x01
#define ST25DV_ITSTS_DYN_RFACTIVITY_SHIFT (1)
#define ST25DV_ITSTS_DYN_RFACTIVITY_FIELD 0xFD
#define ST25DV_ITSTS_DYN_RFACTIVITY_MASK 0x02
#define ST25DV_ITSTS_DYN_RFINTERRUPT_SHIFT (2)
#define ST25DV_ITSTS_DYN_RFINTERRUPT_FIELD 0xFB
#define ST25DV_ITSTS_DYN_RFINTERRUPT_MASK 0x04
#define ST25DV_ITSTS_DYN_FIELDFALLING_SHIFT (3)
#define ST25DV_ITSTS_DYN_FIELDFALLING_FIELD 0xF7
#define ST25DV_ITSTS_DYN_FIELDFALLING_MASK 0x08
#define ST25DV_ITSTS_DYN_FIELDRISING_SHIFT (4)
#define ST25DV_ITSTS_DYN_FIELDRISING_FIELD 0xEF
#define ST25DV_ITSTS_DYN_FIELDRISING_MASK 0x10
#define ST25DV_ITSTS_DYN_RFPUTMSG_SHIFT (5)
#define ST25DV_ITSTS_DYN_RFPUTMSG_FIELD 0xDF
#define ST25DV_ITSTS_DYN_RFPUTMSG_MASK 0x20
#define ST25DV_ITSTS_DYN_RFGETMSG_SHIFT (6)
#define ST25DV_ITSTS_DYN_RFGETMSG_FIELD 0xBF
#define ST25DV_ITSTS_DYN_RFGETMSG_MASK 0x40
#define ST25DV_ITSTS_DYN_RFWRITE_SHIFT (7)
#define ST25DV_ITSTS_DYN_RFWRITE_FIELD 0x7F
#define ST25DV_ITSTS_DYN_RFWRITE_MASK 0x80
/* EH_MODE */
#define ST25DV_EH_MODE_SHIFT (0)
#define ST25DV_EH_MODE_FIELD 0xFE
#define ST25DV_EH_MODE_MASK 0x01
/* EH_CTRL_Dyn */
#define ST25DV_EH_CTRL_DYN_EH_EN_SHIFT (0)
#define ST25DV_EH_CTRL_DYN_EH_EN_FIELD 0xFE
#define ST25DV_EH_CTRL_DYN_EH_EN_MASK 0x01
#define ST25DV_EH_CTRL_DYN_EH_ON_SHIFT (1)
#define ST25DV_EH_CTRL_DYN_EH_ON_FIELD 0xFD
#define ST25DV_EH_CTRL_DYN_EH_ON_MASK 0x02
#define ST25DV_EH_CTRL_DYN_FIELD_ON_SHIFT (2)
#define ST25DV_EH_CTRL_DYN_FIELD_ON_FIELD 0xFB
#define ST25DV_EH_CTRL_DYN_FIELD_ON_MASK 0x04
#define ST25DV_EH_CTRL_DYN_VCC_ON_SHIFT (3)
#define ST25DV_EH_CTRL_DYN_VCC_ON_FIELD 0xF7
#define ST25DV_EH_CTRL_DYN_VCC_ON_MASK 0x08
#define ST25DV_EH_CTRL_DYN_ALL_SHIFT (0)
#define ST25DV_EH_CTRL_DYN_ALL_MASK 0x0F
/* RF_MNGT */
#define ST25DV_RF_MNGT_RFDIS_SHIFT (0)
#define ST25DV_RF_MNGT_RFDIS_FIELD 0xFE
#define ST25DV_RF_MNGT_RFDIS_MASK 0x01
#define ST25DV_RF_MNGT_RFSLEEP_SHIFT (1)
#define ST25DV_RF_MNGT_RFSLEEP_FIELD 0xFD
#define ST25DV_RF_MNGT_RFSLEEP_MASK 0x02
#define ST25DV_RF_MNGT_ALL_SHIFT (0)
#define ST25DV_RF_MNGT_ALL_MASK 0x03
/* RF_MNGT_Dyn */
#define ST25DV_RF_MNGT_DYN_RFDIS_SHIFT (0)
#define ST25DV_RF_MNGT_DYN_RFDIS_FIELD 0xFE
#define ST25DV_RF_MNGT_DYN_RFDIS_MASK 0x01
#define ST25DV_RF_MNGT_DYN_RFSLEEP_SHIFT (1)
#define ST25DV_RF_MNGT_DYN_RFSLEEP_FIELD 0xFD
#define ST25DV_RF_MNGT_DYN_RFSLEEP_MASK 0x02
#define ST25DV_RF_MNGT_DYN_ALL_SHIFT (0)
#define ST25DV_RF_MNGT_DYN_ALL_MASK 0x03
/* RFA1SS */
#define ST25DV_RFA1SS_PWDCTRL_SHIFT (0)
#define ST25DV_RFA1SS_PWDCTRL_FIELD 0xFC
#define ST25DV_RFA1SS_PWDCTRL_MASK 0x03
#define ST25DV_RFA1SS_RWPROT_SHIFT (2)
#define ST25DV_RFA1SS_RWPROT_FIELD 0xF3
#define ST25DV_RFA1SS_RWPROT_MASK 0x0C
#define ST25DV_RFA1SS_ALL_SHIFT (0)
#define ST25DV_RFA1SS_ALL_MASK 0x0F
/* RFA2SS */
#define ST25DV_RFA2SS_PWDCTRL_SHIFT (0)
#define ST25DV_RFA2SS_PWDCTRL_FIELD 0xFC
#define ST25DV_RFA2SS_PWDCTRL_MASK 0x03
#define ST25DV_RFA2SS_RWPROT_SHIFT (2)
#define ST25DV_RFA2SS_RWPROT_FIELD 0xF3
#define ST25DV_RFA2SS_RWPROT_MASK 0x0C
#define ST25DV_RFA2SS_ALL_SHIFT (0)
#define ST25DV_RFA2SS_ALL_MASK 0x0F
/* RFA3SS */
#define ST25DV_RFA3SS_PWDCTRL_SHIFT (0)
#define ST25DV_RFA3SS_PWDCTRL_FIELD 0xFC
#define ST25DV_RFA3SS_PWDCTRL_MASK 0x03
#define ST25DV_RFA3SS_RWPROT_SHIFT (2)
#define ST25DV_RFA3SS_RWPROT_FIELD 0xF3
#define ST25DV_RFA3SS_RWPROT_MASK 0x0C
#define ST25DV_RFA3SS_ALL_SHIFT (0)
#define ST25DV_RFA3SS_ALL_MASK 0x0F
/* RFA4SS */
#define ST25DV_RFA4SS_PWDCTRL_SHIFT (0)
#define ST25DV_RFA4SS_PWDCTRL_FIELD 0xFC
#define ST25DV_RFA4SS_PWDCTRL_MASK 0x03
#define ST25DV_RFA4SS_RWPROT_SHIFT (2)
#define ST25DV_RFA4SS_RWPROT_FIELD 0xF3
#define ST25DV_RFA4SS_RWPROT_MASK 0x0C
#define ST25DV_RFA4SS_ALL_SHIFT (0)
#define ST25DV_RFA4SS_ALL_MASK 0x0F
/* I2CSS */
#define ST25DV_I2CSS_PZ1_SHIFT (0)
#define ST25DV_I2CSS_PZ1_FIELD 0xFC
#define ST25DV_I2CSS_PZ1_MASK 0x03
#define ST25DV_I2CSS_PZ2_SHIFT (2)
#define ST25DV_I2CSS_PZ2_FIELD 0xF3
#define ST25DV_I2CSS_PZ2_MASK 0x0C
#define ST25DV_I2CSS_PZ3_SHIFT (4)
#define ST25DV_I2CSS_PZ3_FIELD 0xCF
#define ST25DV_I2CSS_PZ3_MASK 0x30
#define ST25DV_I2CSS_PZ4_SHIFT (6)
#define ST25DV_I2CSS_PZ4_FIELD 0x3F
#define ST25DV_I2CSS_PZ4_MASK 0xC0
/* LOCKCCFILE */
#define ST25DV_LOCKCCFILE_BLCK0_SHIFT (0)
#define ST25DV_LOCKCCFILE_BLCK0_FIELD 0xFE
#define ST25DV_LOCKCCFILE_BLCK0_MASK 0x01
#define ST25DV_LOCKCCFILE_BLCK1_SHIFT (1)
#define ST25DV_LOCKCCFILE_BLCK1_FIELD 0xFD
#define ST25DV_LOCKCCFILE_BLCK1_MASK 0x02
#define ST25DV_LOCKCCFILE_ALL_SHIFT (0)
#define ST25DV_LOCKCCFILE_ALL_MASK 0x03
/* LOCKCFG */
#define ST25DV_LOCKCFG_B0_SHIFT (0)
#define ST25DV_LOCKCFG_B0_FIELD 0xFE
#define ST25DV_LOCKCFG_B0_MASK 0x01
/* I2C_SSO_Dyn */
#define ST25DV_I2C_SSO_DYN_I2CSSO_SHIFT (0)
#define ST25DV_I2C_SSO_DYN_I2CSSO_FIELD 0xFE
#define ST25DV_I2C_SSO_DYN_I2CSSO_MASK 0x01
/**
* @brief ST25DV status enumerator definition.
*/
#define ST25DV_OK (0)
#define ST25DV_ERROR (-1)
#define ST25DV_BUSY (-2)
#define ST25DV_TIMEOUT (-3)
#define ST25DV_NACK (-102)
typedef int32_t (*ST25DV_WriteReg_Func)(void *, uint16_t, const uint8_t*, uint16_t);
typedef int32_t (*ST25DV_ReadReg_Func) (void *, uint16_t, uint8_t*, uint16_t);
typedef struct {
ST25DV_WriteReg_Func WriteReg;
ST25DV_ReadReg_Func ReadReg;
void *handle;
} st25dv_ctx_t;
int32_t st25dv_get_icref (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_enda1 (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_enda1 (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_enda2 (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_enda2 (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_enda3 (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_enda3 (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_dsfid (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_afi (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_mem_size_msb (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_blk_size (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_mem_size_lsb (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_icrev (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_uid (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_i2cpasswd (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_i2cpasswd (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_lockdsfid (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_lockafi (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_mb_mode_rw (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_mb_mode_rw (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_mblen_dyn_mblen (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_mb_ctrl_dyn_mben (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_mb_ctrl_dyn_mben (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_mb_ctrl_dyn_hostputmsg (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_mb_ctrl_dyn_rfputmsg (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_mb_ctrl_dyn_streserved (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_mb_ctrl_dyn_hostmissmsg (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_mb_ctrl_dyn_rfmissmsg (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_mb_ctrl_dyn_currentmsg (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_mb_ctrl_dyn_all (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_mb_wdg_delay (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_mb_wdg_delay (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_gpo_rfuserstate (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_gpo_rfuserstate (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_gpo_rfactivity (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_gpo_rfactivity (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_gpo_rfinterrupt (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_gpo_rfinterrupt (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_gpo_fieldchange (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_gpo_fieldchange (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_gpo_rfputmsg (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_gpo_rfputmsg (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_gpo_rfgetmsg (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_gpo_rfgetmsg (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_gpo_rfwrite (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_gpo_rfwrite (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_gpo_enable (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_gpo_enable (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_gpo_all (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_gpo_all (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_gpo_dyn_rfuserstate (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_gpo_dyn_rfuserstate (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_gpo_dyn_rfactivity (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_gpo_dyn_rfactivity (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_gpo_dyn_rfinterrupt (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_gpo_dyn_rfinterrupt (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_gpo_dyn_fieldchange (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_gpo_dyn_fieldchang (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_gpo_dyn_rfputmsg (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_gpo_dyn_rfputmsg (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_gpo_dyn_rfgetmsg (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_gpo_dyn_rfgetmsg (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_gpo_dyn_rfwrite (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_gpo_dyn_rfwrite (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_gpo_dyn_enable (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_gpo_dyn_enable (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_gpo_dyn_all (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_gpo_dyn_all (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_ittime_delay (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_ittime_delay (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_itsts_dyn_rfuserstate (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_itsts_dyn_rfactivity (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_itsts_dyn_rfinterrupt (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_itsts_dyn_fieldfalling (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_itsts_dyn_fieldrising (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_itsts_dyn_rfputmsg (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_itsts_dyn_rfgetmsg (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_itsts_dyn_rfwrite (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_itsts_dyn_all (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_eh_mode (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_eh_mode (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_eh_ctrl_dyn_eh_en (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_eh_ctrl_dyn_eh_en (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_eh_ctrl_dyn_eh_on (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_eh_ctrl_dyn_field_on (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_eh_ctrl_dyn_vcc_on (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_eh_ctrl_dyn_all (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_get_rf_mngt_rfdis (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_rf_mngt_rfdis (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_rf_mngt_rfsleep (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_rf_mngt_rfsleep (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_rf_mngt_all (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_rf_mngt_all (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_rf_mngt_dyn_rfdis (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_rf_mngt_dyn_rfdis (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_rf_mngt_dyn_rfsleep (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_rf_mngt_dyn_rfsleep (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_rf_mngt_dyn_all (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_rf_mngt_dyn_all (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_rfa1ss_pwdctrl (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_rfa1ss_pwdctrl (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_rfa1ss_rwprot (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_rfa1ss_rwprot (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_rfa1ss_all (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_rfa1ss_all (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_rfa2ss_pwdctrl (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_rfa2ss_pwdctrl (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_rfa2ss_rwprot (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_rfa2ss_rwprot (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_rfa2ss_all (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_rfa2ss_all (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_rfa3ss_pwdctrl (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_rfa3ss_pwdctrl (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_rfa3ss_rwprot (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_rfa3ss_rwprot (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_rfa3ss_all (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_rfa3ss_all (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_rfa4ss_pwdctrl (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_rfa4ss_pwdctrl (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_rfa4ss_rwprot (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_rfa4ss_rwprot (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_rfa4ss_all (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_rfa4ss_all (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_i2css_pz1 (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_i2css_pz1 (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_i2css_pz2 (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_i2css_pz2 (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_i2css_pz3 (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_i2css_pz3 (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_i2css_pz4 (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_i2css_pz4 (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_i2css_all (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_i2css_all (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_lockccfile_blck0 (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_lockccfile_blck0 (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_lockccfile_blck1 (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_lockccfile_blck1 (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_lockccfile_all (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_lockccfile_all (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_lockcfg_b0 (st25dv_ctx_t *ctx, uint8_t *value);
int32_t st25dv_set_lockcfg_b0 (st25dv_ctx_t *ctx, const uint8_t *value);
int32_t st25dv_get_i2c_sso_dyn_i2csso (st25dv_ctx_t *ctx, uint8_t *value);
#endif

View File

@@ -0,0 +1,109 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for ST7735 Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-st7735-component-drivers"><small>Release Notes for</small> <mark>ST7735 Component Drivers</mark></h1>
<p>Copyright © 2014 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the ST7735 component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.1.5 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section20" aria-hidden="true"> <label for="collapse-section20" aria-hidden="true">V1.1.4 / 17-December-2018</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Fix “Back to Release page” link</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.1.3 / 25-October-2018</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section185" aria-hidden="true"> <label for="collapse-section185" aria-hidden="true">V1.1.2 / 06-June-2017</label>
<div>
<h2 id="main-changes-3">Main Changes</h2>
<ul>
<li>Update comments to be used for PDSC generation</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.1.1 / 24-November-2014</label>
<div>
<h2 id="main-changes-4">Main Changes</h2>
<ul>
<li>st7735.h: change “\” by “/” in the include path to fix compilation issues under Linux</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section17" aria-hidden="true"> <label for="collapse-section17" aria-hidden="true">V1.1.0 / 22-July-2014</label>
<div>
<h2 id="main-changes-5">Main Changes</h2>
<ul>
<li>LCD Component driver update in order to harmonize all LCD controllers Link usage (Change LCD_IO_WriteData to LCD_IO_WriteMultipleData)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section16" aria-hidden="true"> <label for="collapse-section16" aria-hidden="true">V1.0.0 / 22-April-2014</label>
<div>
<h2 id="main-changes-6">Main Changes</h2>
<ul>
<li>First official release</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,453 @@
/**
******************************************************************************
* @file st7735.c
* @author MCD Application Team
* @brief This file includes the driver for ST7735 LCD mounted on the Adafruit
* 1.8" TFT LCD shield (reference ID 802).
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2014 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "st7735.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup ST7735
* @brief This file provides a set of functions needed to drive the
* ST7735 LCD.
* @{
*/
/** @defgroup ST7735_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup ST7735_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup ST7735_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup ST7735_Private_Variables
* @{
*/
LCD_DrvTypeDef st7735_drv =
{
st7735_Init,
0,
st7735_DisplayOn,
st7735_DisplayOff,
st7735_SetCursor,
st7735_WritePixel,
0,
st7735_SetDisplayWindow,
st7735_DrawHLine,
st7735_DrawVLine,
st7735_GetLcdPixelWidth,
st7735_GetLcdPixelHeight,
st7735_DrawBitmap,
};
static uint16_t ArrayRGB[320] = {0};
/**
* @}
*/
/** @defgroup ST7735_Private_FunctionPrototypes
* @{
*/
/**
* @}
*/
/** @defgroup ST7735_Private_Functions
* @{
*/
/**
* @brief Initialize the ST7735 LCD Component.
* @param None
* @retval None
*/
void st7735_Init(void)
{
uint8_t data = 0;
/* Initialize ST7735 low level bus layer -----------------------------------*/
LCD_IO_Init();
/* Out of sleep mode, 0 args, no delay */
st7735_WriteReg(LCD_REG_17, 0x00);
/* Frame rate ctrl - normal mode, 3 args:Rate = fosc/(1x2+40) * (LINE+2C+2D)*/
LCD_IO_WriteReg(LCD_REG_177);
data = 0x01;
LCD_IO_WriteMultipleData(&data, 1);
data = 0x2C;
LCD_IO_WriteMultipleData(&data, 1);
data = 0x2D;
LCD_IO_WriteMultipleData(&data, 1);
/* Frame rate control - idle mode, 3 args:Rate = fosc/(1x2+40) * (LINE+2C+2D) */
st7735_WriteReg(LCD_REG_178, 0x01);
st7735_WriteReg(LCD_REG_178, 0x2C);
st7735_WriteReg(LCD_REG_178, 0x2D);
/* Frame rate ctrl - partial mode, 6 args: Dot inversion mode, Line inversion mode */
st7735_WriteReg(LCD_REG_179, 0x01);
st7735_WriteReg(LCD_REG_179, 0x2C);
st7735_WriteReg(LCD_REG_179, 0x2D);
st7735_WriteReg(LCD_REG_179, 0x01);
st7735_WriteReg(LCD_REG_179, 0x2C);
st7735_WriteReg(LCD_REG_179, 0x2D);
/* Display inversion ctrl, 1 arg, no delay: No inversion */
st7735_WriteReg(LCD_REG_180, 0x07);
/* Power control, 3 args, no delay: -4.6V , AUTO mode */
st7735_WriteReg(LCD_REG_192, 0xA2);
st7735_WriteReg(LCD_REG_192, 0x02);
st7735_WriteReg(LCD_REG_192, 0x84);
/* Power control, 1 arg, no delay: VGH25 = 2.4C VGSEL = -10 VGH = 3 * AVDD */
st7735_WriteReg(LCD_REG_193, 0xC5);
/* Power control, 2 args, no delay: Opamp current small, Boost frequency */
st7735_WriteReg(LCD_REG_194, 0x0A);
st7735_WriteReg(LCD_REG_194, 0x00);
/* Power control, 2 args, no delay: BCLK/2, Opamp current small & Medium low */
st7735_WriteReg(LCD_REG_195, 0x8A);
st7735_WriteReg(LCD_REG_195, 0x2A);
/* Power control, 2 args, no delay */
st7735_WriteReg(LCD_REG_196, 0x8A);
st7735_WriteReg(LCD_REG_196, 0xEE);
/* Power control, 1 arg, no delay */
st7735_WriteReg(LCD_REG_197, 0x0E);
/* Don't invert display, no args, no delay */
LCD_IO_WriteReg(LCD_REG_32);
/* Set color mode, 1 arg, no delay: 16-bit color */
st7735_WriteReg(LCD_REG_58, 0x05);
/* Column addr set, 4 args, no delay: XSTART = 0, XEND = 127 */
LCD_IO_WriteReg(LCD_REG_42);
data = 0x00;
LCD_IO_WriteMultipleData(&data, 1);
LCD_IO_WriteMultipleData(&data, 1);
LCD_IO_WriteMultipleData(&data, 1);
data = 0x7F;
LCD_IO_WriteMultipleData(&data, 1);
/* Row addr set, 4 args, no delay: YSTART = 0, YEND = 159 */
LCD_IO_WriteReg(LCD_REG_43);
data = 0x00;
LCD_IO_WriteMultipleData(&data, 1);
LCD_IO_WriteMultipleData(&data, 1);
LCD_IO_WriteMultipleData(&data, 1);
data = 0x9F;
LCD_IO_WriteMultipleData(&data, 1);
/* Magical unicorn dust, 16 args, no delay */
st7735_WriteReg(LCD_REG_224, 0x02);
st7735_WriteReg(LCD_REG_224, 0x1c);
st7735_WriteReg(LCD_REG_224, 0x07);
st7735_WriteReg(LCD_REG_224, 0x12);
st7735_WriteReg(LCD_REG_224, 0x37);
st7735_WriteReg(LCD_REG_224, 0x32);
st7735_WriteReg(LCD_REG_224, 0x29);
st7735_WriteReg(LCD_REG_224, 0x2d);
st7735_WriteReg(LCD_REG_224, 0x29);
st7735_WriteReg(LCD_REG_224, 0x25);
st7735_WriteReg(LCD_REG_224, 0x2B);
st7735_WriteReg(LCD_REG_224, 0x39);
st7735_WriteReg(LCD_REG_224, 0x00);
st7735_WriteReg(LCD_REG_224, 0x01);
st7735_WriteReg(LCD_REG_224, 0x03);
st7735_WriteReg(LCD_REG_224, 0x10);
/* Sparkles and rainbows, 16 args, no delay */
st7735_WriteReg(LCD_REG_225, 0x03);
st7735_WriteReg(LCD_REG_225, 0x1d);
st7735_WriteReg(LCD_REG_225, 0x07);
st7735_WriteReg(LCD_REG_225, 0x06);
st7735_WriteReg(LCD_REG_225, 0x2E);
st7735_WriteReg(LCD_REG_225, 0x2C);
st7735_WriteReg(LCD_REG_225, 0x29);
st7735_WriteReg(LCD_REG_225, 0x2D);
st7735_WriteReg(LCD_REG_225, 0x2E);
st7735_WriteReg(LCD_REG_225, 0x2E);
st7735_WriteReg(LCD_REG_225, 0x37);
st7735_WriteReg(LCD_REG_225, 0x3F);
st7735_WriteReg(LCD_REG_225, 0x00);
st7735_WriteReg(LCD_REG_225, 0x00);
st7735_WriteReg(LCD_REG_225, 0x02);
st7735_WriteReg(LCD_REG_225, 0x10);
/* Normal display on, no args, no delay */
st7735_WriteReg(LCD_REG_19, 0x00);
/* Main screen turn on, no delay */
st7735_WriteReg(LCD_REG_41, 0x00);
/* Memory access control: MY = 1, MX = 1, MV = 0, ML = 0 */
st7735_WriteReg(LCD_REG_54, 0xC0);
}
/**
* @brief Enables the Display.
* @param None
* @retval None
*/
void st7735_DisplayOn(void)
{
uint8_t data = 0;
LCD_IO_WriteReg(LCD_REG_19);
LCD_Delay(10);
LCD_IO_WriteReg(LCD_REG_41);
LCD_Delay(10);
LCD_IO_WriteReg(LCD_REG_54);
data = 0xC0;
LCD_IO_WriteMultipleData(&data, 1);
}
/**
* @brief Disables the Display.
* @param None
* @retval None
*/
void st7735_DisplayOff(void)
{
uint8_t data = 0;
LCD_IO_WriteReg(LCD_REG_19);
LCD_Delay(10);
LCD_IO_WriteReg(LCD_REG_40);
LCD_Delay(10);
LCD_IO_WriteReg(LCD_REG_54);
data = 0xC0;
LCD_IO_WriteMultipleData(&data, 1);
}
/**
* @brief Sets Cursor position.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @retval None
*/
void st7735_SetCursor(uint16_t Xpos, uint16_t Ypos)
{
uint8_t data = 0;
LCD_IO_WriteReg(LCD_REG_42);
data = (Xpos) >> 8;
LCD_IO_WriteMultipleData(&data, 1);
data = (Xpos) & 0xFF;
LCD_IO_WriteMultipleData(&data, 1);
LCD_IO_WriteReg(LCD_REG_43);
data = (Ypos) >> 8;
LCD_IO_WriteMultipleData(&data, 1);
data = (Ypos) & 0xFF;
LCD_IO_WriteMultipleData(&data, 1);
LCD_IO_WriteReg(LCD_REG_44);
}
/**
* @brief Writes pixel.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param RGBCode: the RGB pixel color
* @retval None
*/
void st7735_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode)
{
uint8_t data = 0;
if((Xpos >= ST7735_LCD_PIXEL_WIDTH) || (Ypos >= ST7735_LCD_PIXEL_HEIGHT))
{
return;
}
/* Set Cursor */
st7735_SetCursor(Xpos, Ypos);
data = RGBCode >> 8;
LCD_IO_WriteMultipleData(&data, 1);
data = RGBCode;
LCD_IO_WriteMultipleData(&data, 1);
}
/**
* @brief Writes to the selected LCD register.
* @param LCDReg: Address of the selected register.
* @param LCDRegValue: value to write to the selected register.
* @retval None
*/
void st7735_WriteReg(uint8_t LCDReg, uint8_t LCDRegValue)
{
LCD_IO_WriteReg(LCDReg);
LCD_IO_WriteMultipleData(&LCDRegValue, 1);
}
/**
* @brief Sets a display window
* @param Xpos: specifies the X bottom left position.
* @param Ypos: specifies the Y bottom left position.
* @param Height: display window height.
* @param Width: display window width.
* @retval None
*/
void st7735_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
{
uint8_t data = 0;
/* Column addr set, 4 args, no delay: XSTART = Xpos, XEND = (Xpos + Width - 1) */
LCD_IO_WriteReg(LCD_REG_42);
data = (Xpos) >> 8;
LCD_IO_WriteMultipleData(&data, 1);
data = (Xpos) & 0xFF;
LCD_IO_WriteMultipleData(&data, 1);
data = (Xpos + Width - 1) >> 8;
LCD_IO_WriteMultipleData(&data, 1);
data = (Xpos + Width - 1) & 0xFF;
LCD_IO_WriteMultipleData(&data, 1);
/* Row addr set, 4 args, no delay: YSTART = Ypos, YEND = (Ypos + Height - 1) */
LCD_IO_WriteReg(LCD_REG_43);
data = (Ypos) >> 8;
LCD_IO_WriteMultipleData(&data, 1);
data = (Ypos) & 0xFF;
LCD_IO_WriteMultipleData(&data, 1);
data = (Ypos + Height - 1) >> 8;
LCD_IO_WriteMultipleData(&data, 1);
data = (Ypos + Height - 1) & 0xFF;
LCD_IO_WriteMultipleData(&data, 1);
}
/**
* @brief Draws horizontal line.
* @param RGBCode: Specifies the RGB color
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Length: specifies the line length.
* @retval None
*/
void st7735_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint8_t counter = 0;
if(Xpos + Length > ST7735_LCD_PIXEL_WIDTH) return;
/* Set Cursor */
st7735_SetCursor(Xpos, Ypos);
for(counter = 0; counter < Length; counter++)
{
ArrayRGB[counter] = RGBCode;
}
LCD_IO_WriteMultipleData((uint8_t*)&ArrayRGB[0], Length * 2);
}
/**
* @brief Draws vertical line.
* @param RGBCode: Specifies the RGB color
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Length: specifies the line length.
* @retval None
*/
void st7735_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint8_t counter = 0;
if(Ypos + Length > ST7735_LCD_PIXEL_HEIGHT) return;
for(counter = 0; counter < Length; counter++)
{
st7735_WritePixel(Xpos, Ypos + counter, RGBCode);
}
}
/**
* @brief Gets the LCD pixel Width.
* @param None
* @retval The Lcd Pixel Width
*/
uint16_t st7735_GetLcdPixelWidth(void)
{
return ST7735_LCD_PIXEL_WIDTH;
}
/**
* @brief Gets the LCD pixel Height.
* @param None
* @retval The Lcd Pixel Height
*/
uint16_t st7735_GetLcdPixelHeight(void)
{
return ST7735_LCD_PIXEL_HEIGHT;
}
/**
* @brief Displays a bitmap picture loaded in the internal Flash.
* @param BmpAddress: Bmp picture address in the internal Flash.
* @retval None
*/
void st7735_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp)
{
uint32_t index = 0, size = 0;
/* Read bitmap size */
size = *(volatile uint16_t *) (pbmp + 2);
size |= (*(volatile uint16_t *) (pbmp + 4)) << 16;
/* Get bitmap data address offset */
index = *(volatile uint16_t *) (pbmp + 10);
index |= (*(volatile uint16_t *) (pbmp + 12)) << 16;
size = (size - index)/2;
pbmp += index;
/* Set GRAM write direction and BGR = 0 */
/* Memory access control: MY = 0, MX = 1, MV = 0, ML = 0 */
st7735_WriteReg(LCD_REG_54, 0x40);
/* Set Cursor */
st7735_SetCursor(Xpos, Ypos);
LCD_IO_WriteMultipleData((uint8_t*)pbmp, size*2);
/* Set GRAM write direction and BGR = 0 */
/* Memory access control: MY = 1, MX = 1, MV = 0, ML = 0 */
st7735_WriteReg(LCD_REG_54, 0xC0);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,196 @@
/**
******************************************************************************
* @file st7735.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the st7735.c
* driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2014 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __ST7735_H
#define __ST7735_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/lcd.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup ST7735
* @{
*/
/** @defgroup ST7735_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup ST7735_Exported_Constants
* @{
*/
/**
* @brief ST7735 Size
*/
#define ST7735_LCD_PIXEL_WIDTH ((uint16_t)128)
#define ST7735_LCD_PIXEL_HEIGHT ((uint16_t)160)
/**
* @brief ST7735 Registers
*/
#define LCD_REG_0 0x00 /* No Operation: NOP */
#define LCD_REG_1 0x01 /* Software reset: SWRESET */
#define LCD_REG_4 0x04 /* Read Display ID: RDDID */
#define LCD_REG_9 0x09 /* Read Display Statu: RDDST */
#define LCD_REG_10 0x0A /* Read Display Power: RDDPM */
#define LCD_REG_11 0x0B /* Read Display: RDDMADCTL */
#define LCD_REG_12 0x0C /* Read Display Pixel: RDDCOLMOD */
#define LCD_REG_13 0x0D /* Read Display Image: RDDIM */
#define LCD_REG_14 0x0E /* Read Display Signal: RDDSM */
#define LCD_REG_16 0x10 /* Sleep in & booster off: SLPIN */
#define LCD_REG_17 0x11 /* Sleep out & booster on: SLPOUT */
#define LCD_REG_18 0x12 /* Partial mode on: PTLON */
#define LCD_REG_19 0x13 /* Partial off (Normal): NORON */
#define LCD_REG_32 0x20 /* Display inversion off: INVOFF */
#define LCD_REG_33 0x21 /* Display inversion on: INVON */
#define LCD_REG_38 0x26 /* Gamma curve select: GAMSET */
#define LCD_REG_40 0x28 /* Display off: DISPOFF */
#define LCD_REG_41 0x29 /* Display on: DISPON */
#define LCD_REG_42 0x2A /* Column address set: CASET */
#define LCD_REG_43 0x2B /* Row address set: RASET */
#define LCD_REG_44 0x2C /* Memory write: RAMWR */
#define LCD_REG_45 0x2D /* LUT for 4k,65k,262k color: RGBSET */
#define LCD_REG_46 0x2E /* Memory read: RAMRD*/
#define LCD_REG_48 0x30 /* Partial start/end address set: PTLAR */
#define LCD_REG_52 0x34 /* Tearing effect line off: TEOFF */
#define LCD_REG_53 0x35 /* Tearing effect mode set & on: TEON */
#define LCD_REG_54 0x36 /* Memory data access control: MADCTL */
#define LCD_REG_56 0x38 /* Idle mode off: IDMOFF */
#define LCD_REG_57 0x39 /* Idle mode on: IDMON */
#define LCD_REG_58 0x3A /* Interface pixel format: COLMOD */
#define LCD_REG_177 0xB1 /* In normal mode (Full colors): FRMCTR1 */
#define LCD_REG_178 0xB2 /* In Idle mode (8-colors): FRMCTR2 */
#define LCD_REG_179 0xB3 /* In partial mode + Full colors: FRMCTR3 */
#define LCD_REG_180 0xB4 /* Display inversion control: INVCTR */
#define LCD_REG_192 0xC0 /* Power control setting: PWCTR1 */
#define LCD_REG_193 0xC1 /* Power control setting: PWCTR2 */
#define LCD_REG_194 0xC2 /* In normal mode (Full colors): PWCTR3 */
#define LCD_REG_195 0xC3 /* In Idle mode (8-colors): PWCTR4 */
#define LCD_REG_196 0xC4 /* In partial mode + Full colors: PWCTR5 */
#define LCD_REG_197 0xC5 /* VCOM control 1: VMCTR1 */
#define LCD_REG_199 0xC7 /* Set VCOM offset control: VMOFCTR */
#define LCD_REG_209 0xD1 /* Set LCM version code: WRID2 */
#define LCD_REG_210 0xD2 /* Customer Project code: WRID3 */
#define LCD_REG_217 0xD9 /* NVM control status: NVCTR1 */
#define LCD_REG_218 0xDA /* Read ID1: RDID1 */
#define LCD_REG_219 0xDB /* Read ID2: RDID2 */
#define LCD_REG_220 0xDC /* Read ID3: RDID3 */
#define LCD_REG_222 0xDE /* NVM Read Command: NVCTR2 */
#define LCD_REG_223 0xDF /* NVM Write Command: NVCTR3 */
#define LCD_REG_224 0xE0 /* Set Gamma adjustment (+ polarity): GAMCTRP1 */
#define LCD_REG_225 0xE1 /* Set Gamma adjustment (- polarity): GAMCTRN1 */
/**
* @brief LCD Lines depending on the chosen fonts.
*/
#define LCD_LINE_0 LINE(0)
#define LCD_LINE_1 LINE(1)
#define LCD_LINE_2 LINE(2)
#define LCD_LINE_3 LINE(3)
#define LCD_LINE_4 LINE(4)
#define LCD_LINE_5 LINE(5)
#define LCD_LINE_6 LINE(6)
#define LCD_LINE_7 LINE(7)
#define LCD_LINE_8 LINE(8)
#define LCD_LINE_9 LINE(9)
#define LCD_LINE_10 LINE(10)
#define LCD_LINE_11 LINE(11)
#define LCD_LINE_12 LINE(12)
#define LCD_LINE_13 LINE(13)
#define LCD_LINE_14 LINE(14)
#define LCD_LINE_15 LINE(15)
#define LCD_LINE_16 LINE(16)
#define LCD_LINE_17 LINE(17)
#define LCD_LINE_18 LINE(18)
#define LCD_LINE_19 LINE(19)
/**
* @}
*/
/** @defgroup ADAFRUIT_SPI_LCD_Exported_Functions
* @{
*/
void st7735_Init(void);
uint16_t st7735_ReadID(void);
void st7735_DisplayOn(void);
void st7735_DisplayOff(void);
void st7735_SetCursor(uint16_t Xpos, uint16_t Ypos);
void st7735_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode);
void st7735_WriteReg(uint8_t LCDReg, uint8_t LCDRegValue);
uint8_t st7735_ReadReg(uint8_t LCDReg);
void st7735_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
void st7735_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
void st7735_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
uint16_t st7735_GetLcdPixelWidth(void);
uint16_t st7735_GetLcdPixelHeight(void);
void st7735_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp);
/* LCD driver structure */
extern LCD_DrvTypeDef st7735_drv;
/* LCD IO functions */
void LCD_IO_Init(void);
void LCD_IO_WriteMultipleData(uint8_t *pData, uint32_t Size);
void LCD_IO_WriteReg(uint8_t Reg);
void LCD_Delay(uint32_t delay);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __ST7735_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,109 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for ST7789H2 Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-st7789h2-component-drivers"><small>Release Notes for</small> <mark>ST7789H2 Component Drivers</mark></h1>
<p>Copyright © 2016 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the ST7789H2 component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.1.3 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section20" aria-hidden="true"> <label for="collapse-section20" aria-hidden="true">V1.1.2 / 31-August-2018</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.1.1 / 29-December-2016</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>st7789h2.c/.h:
<ul>
<li>Change “\” by “/” in the include path to fix compilation issue under linux</li>
</ul></li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section185" aria-hidden="true"> <label for="collapse-section185" aria-hidden="true">V1.1.0 / 22-December-2016</label>
<div>
<h2 id="main-changes-3">Main Changes</h2>
<ul>
<li>st7789h2.c/.h:
<ul>
<li>Add 180° orientation support</li>
</ul></li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.0.1 / 04-July-2016</label>
<div>
<h2 id="main-changes-4">Main Changes</h2>
<ul>
<li>st7789h2.c:
<ul>
<li>Update ST7789H2_DisplayOn()</li>
</ul></li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section17" aria-hidden="true"> <label for="collapse-section17" aria-hidden="true">V1.0.0 / 04-May-2016</label>
<div>
<h2 id="main-changes-5">Main Changes</h2>
<ul>
<li>First official release</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

View File

@@ -0,0 +1,707 @@
/**
******************************************************************************
* @file st7789h2.c
* @author MCD Application Team
* @brief This file includes the LCD driver for st7789h2 LCD.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "st7789h2.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @defgroup ST7789H2
* @brief This file provides a set of functions needed to drive the
* FRIDA FRD154BP2901 LCD.
* @{
*/
/** @defgroup ST7789H2_Private_TypesDefinitions ST7789H2 Private TypesDefinitions
* @{
*/
typedef struct {
uint8_t red;
uint8_t green;
uint8_t blue;
} ST7789H2_Rgb888;
/**
* @}
*/
/** @defgroup ST7789H2_Private_Defines ST7789H2 Private Defines
* @{
*/
/**
* @}
*/
/** @defgroup ST7789H2_Private_Macros ST7789H2 Private Macros
* @{
*/
/**
* @}
*/
/** @defgroup ST7789H2_Private_Variables ST7789H2 Private Variables
* @{
*/
LCD_DrvTypeDef ST7789H2_drv =
{
ST7789H2_Init,
ST7789H2_ReadID,
ST7789H2_DisplayOn,
ST7789H2_DisplayOff,
ST7789H2_SetCursor,
ST7789H2_WritePixel,
ST7789H2_ReadPixel,
ST7789H2_SetDisplayWindow,
ST7789H2_DrawHLine,
ST7789H2_DrawVLine,
ST7789H2_GetLcdPixelWidth,
ST7789H2_GetLcdPixelHeight,
ST7789H2_DrawBitmap,
ST7789H2_DrawRGBImage,
};
static uint16_t WindowsXstart = 0;
static uint16_t WindowsYstart = 0;
static uint16_t WindowsXend = ST7789H2_LCD_PIXEL_WIDTH-1;
static uint16_t WindowsYend = ST7789H2_LCD_PIXEL_HEIGHT-1;
/**
* @}
*/
/** @defgroup ST7789H2_Private_FunctionPrototypes ST7789H2 Private FunctionPrototypes
* @{
*/
static ST7789H2_Rgb888 ST7789H2_ReadPixel_rgb888(uint16_t Xpos, uint16_t Ypos);
static void ST7789H2_DrawRGBHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint8_t *pdata);
/**
* @}
*/
/** @defgroup ST7789H2_Private_Functions ST7789H2 Private Functions
* @{
*/
/**
* @brief Initialize the st7789h2 LCD Component.
* @param None
* @retval None
*/
void ST7789H2_Init(void)
{
uint8_t parameter[14];
/* Initialize st7789h2 low level bus layer ----------------------------------*/
LCD_IO_Init();
/* Sleep In Command */
ST7789H2_WriteReg(ST7789H2_SLEEP_IN, (uint8_t*)NULL, 0);
/* Wait for 10ms */
LCD_IO_Delay(10);
/* SW Reset Command */
ST7789H2_WriteReg(0x01, (uint8_t*)NULL, 0);
/* Wait for 200ms */
LCD_IO_Delay(200);
/* Sleep Out Command */
ST7789H2_WriteReg(ST7789H2_SLEEP_OUT, (uint8_t*)NULL, 0);
/* Wait for 120ms */
LCD_IO_Delay(120);
/* Normal display for Driver Down side */
parameter[0] = 0x00;
ST7789H2_WriteReg(ST7789H2_NORMAL_DISPLAY, parameter, 1);
/* Color mode 16bits/pixel */
parameter[0] = 0x05;
ST7789H2_WriteReg(ST7789H2_COLOR_MODE, parameter, 1);
/* Display inversion On */
ST7789H2_WriteReg(ST7789H2_DISPLAY_INVERSION, (uint8_t*)NULL, 0);
/* Set Column address CASET */
parameter[0] = 0x00;
parameter[1] = 0x00;
parameter[2] = 0x00;
parameter[3] = 0xEF;
ST7789H2_WriteReg(ST7789H2_CASET, parameter, 4);
/* Set Row address RASET */
parameter[0] = 0x00;
parameter[1] = 0x00;
parameter[2] = 0x00;
parameter[3] = 0xEF;
ST7789H2_WriteReg(ST7789H2_RASET, parameter, 4);
/*--------------- ST7789H2 Frame rate setting -------------------------------*/
/* PORCH control setting */
parameter[0] = 0x0C;
parameter[1] = 0x0C;
parameter[2] = 0x00;
parameter[3] = 0x33;
parameter[4] = 0x33;
ST7789H2_WriteReg(ST7789H2_PORCH_CTRL, parameter, 5);
/* GATE control setting */
parameter[0] = 0x35;
ST7789H2_WriteReg(ST7789H2_GATE_CTRL, parameter, 1);
/*--------------- ST7789H2 Power setting ------------------------------------*/
/* VCOM setting */
parameter[0] = 0x1F;
ST7789H2_WriteReg(ST7789H2_VCOM_SET, parameter, 1);
/* LCM Control setting */
parameter[0] = 0x2C;
ST7789H2_WriteReg(ST7789H2_LCM_CTRL, parameter, 1);
/* VDV and VRH Command Enable */
parameter[0] = 0x01;
parameter[1] = 0xC3;
ST7789H2_WriteReg(ST7789H2_VDV_VRH_EN, parameter, 2);
/* VDV Set */
parameter[0] = 0x20;
ST7789H2_WriteReg(ST7789H2_VDV_SET, parameter, 1);
/* Frame Rate Control in normal mode */
parameter[0] = 0x0F;
ST7789H2_WriteReg(ST7789H2_FR_CTRL, parameter, 1);
/* Power Control */
parameter[0] = 0xA4;
parameter[1] = 0xA1;
ST7789H2_WriteReg(ST7789H2_POWER_CTRL, parameter, 2);
/*--------------- ST7789H2 Gamma setting ------------------------------------*/
/* Positive Voltage Gamma Control */
parameter[0] = 0xD0;
parameter[1] = 0x08;
parameter[2] = 0x11;
parameter[3] = 0x08;
parameter[4] = 0x0C;
parameter[5] = 0x15;
parameter[6] = 0x39;
parameter[7] = 0x33;
parameter[8] = 0x50;
parameter[9] = 0x36;
parameter[10] = 0x13;
parameter[11] = 0x14;
parameter[12] = 0x29;
parameter[13] = 0x2D;
ST7789H2_WriteReg(ST7789H2_PV_GAMMA_CTRL, parameter, 14);
/* Negative Voltage Gamma Control */
parameter[0] = 0xD0;
parameter[1] = 0x08;
parameter[2] = 0x10;
parameter[3] = 0x08;
parameter[4] = 0x06;
parameter[5] = 0x06;
parameter[6] = 0x39;
parameter[7] = 0x44;
parameter[8] = 0x51;
parameter[9] = 0x0B;
parameter[10] = 0x16;
parameter[11] = 0x14;
parameter[12] = 0x2F;
parameter[13] = 0x31;
ST7789H2_WriteReg(ST7789H2_NV_GAMMA_CTRL, parameter, 14);
/* Display ON command */
ST7789H2_DisplayOn();
/* Tearing Effect Line On: Option (00h:VSYNC Interface OFF, 01h:VSYNC Interface ON) */
parameter[0] = 0x00;
ST7789H2_WriteReg(ST7789H2_TEARING_EFFECT, parameter, 1);
}
/**
* @brief Set the Display Orientation.
* @param orientation: ST7789H2_ORIENTATION_PORTRAIT, ST7789H2_ORIENTATION_LANDSCAPE
* or ST7789H2_ORIENTATION_LANDSCAPE_ROT180
* @retval None
*/
void ST7789H2_SetOrientation(uint32_t orientation)
{
uint8_t parameter[6];
if(orientation == ST7789H2_ORIENTATION_LANDSCAPE)
{
parameter[0] = 0x00;
}
else if(orientation == ST7789H2_ORIENTATION_LANDSCAPE_ROT180)
{
/* Vertical Scrolling Definition */
/* TFA describes the Top Fixed Area */
parameter[0] = 0x00;
parameter[1] = 0x00;
/* VSA describes the height of the Vertical Scrolling Area */
parameter[2] = 0x01;
parameter[3] = 0xF0;
/* BFA describes the Bottom Fixed Area */
parameter[4] = 0x00;
parameter[5] = 0x00;
ST7789H2_WriteReg(ST7789H2_VSCRDEF, parameter, 6);
/* Vertical Scroll Start Address of RAM */
/* GRAM row nbr (320) - Display row nbr (240) = 80 = 0x50 */
parameter[0] = 0x00;
parameter[1] = 0x50;
ST7789H2_WriteReg(ST7789H2_VSCSAD, parameter, 2);
parameter[0] = 0xC0;
}
else
{
parameter[0] = 0x60;
}
ST7789H2_WriteReg(ST7789H2_NORMAL_DISPLAY, parameter, 1);
}
/**
* @brief Enables the Display.
* @param None
* @retval None
*/
void ST7789H2_DisplayOn(void)
{
/* Display ON command */
ST7789H2_WriteReg(ST7789H2_DISPLAY_ON, (uint8_t*)NULL, 0);
/* Sleep Out command */
ST7789H2_WriteReg(ST7789H2_SLEEP_OUT, (uint8_t*)NULL, 0);
}
/**
* @brief Disables the Display.
* @param None
* @retval None
*/
void ST7789H2_DisplayOff(void)
{
uint8_t parameter[1];
parameter[0] = 0xFE;
/* Display OFF command */
ST7789H2_WriteReg(ST7789H2_DISPLAY_OFF, parameter, 1);
/* Sleep In Command */
ST7789H2_WriteReg(ST7789H2_SLEEP_IN, (uint8_t*)NULL, 0);
/* Wait for 10ms */
LCD_IO_Delay(10);
}
/**
* @brief Get the LCD pixel Width.
* @param None
* @retval The Lcd Pixel Width
*/
uint16_t ST7789H2_GetLcdPixelWidth(void)
{
return (uint16_t)ST7789H2_LCD_PIXEL_WIDTH;
}
/**
* @brief Get the LCD pixel Height.
* @param None
* @retval The Lcd Pixel Height
*/
uint16_t ST7789H2_GetLcdPixelHeight(void)
{
return (uint16_t)ST7789H2_LCD_PIXEL_HEIGHT;
}
/**
* @brief Get the st7789h2 ID.
* @param None
* @retval The st7789h2 ID
*/
uint16_t ST7789H2_ReadID(void)
{
LCD_IO_Init();
return ST7789H2_ReadReg(ST7789H2_LCD_ID);
}
/**
* @brief Set Cursor position.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @retval None
*/
void ST7789H2_SetCursor(uint16_t Xpos, uint16_t Ypos)
{
uint8_t parameter[4];
/* CASET: Comumn Addrses Set */
parameter[0] = 0x00;
parameter[1] = 0x00 + Xpos;
parameter[2] = 0x00;
parameter[3] = 0xEF + Xpos;
ST7789H2_WriteReg(ST7789H2_CASET, parameter, 4);
/* RASET: Row Addrses Set */
parameter[0] = 0x00;
parameter[1] = 0x00 + Ypos;
parameter[2] = 0x00;
parameter[3] = 0xEF + Ypos;
ST7789H2_WriteReg(ST7789H2_RASET, parameter, 4);
}
/**
* @brief Write pixel.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param RGBCode: the RGB pixel color in RGB565 format
* @retval None
*/
void ST7789H2_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode)
{
/* Set Cursor */
ST7789H2_SetCursor(Xpos, Ypos);
/* Prepare to write to LCD RAM */
ST7789H2_WriteReg(ST7789H2_WRITE_RAM, (uint8_t*)NULL, 0); /* RAM write data command */
/* Write RAM data */
LCD_IO_WriteData(RGBCode);
}
/**
* @brief Read pixel.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @retval The RGB pixel color in RGB565 format
*/
uint16_t ST7789H2_ReadPixel(uint16_t Xpos, uint16_t Ypos)
{
ST7789H2_Rgb888 rgb888;
uint8_t r, g, b;
uint16_t rgb565;
/* Set Cursor */
ST7789H2_SetCursor(Xpos, Ypos);
/* Read RGB888 data from LCD RAM */
rgb888 = ST7789H2_ReadPixel_rgb888(Xpos, Ypos);
/* Convert RGB888 to RGB565 */
r = ((rgb888.red & 0xF8) >> 3); /* Extract the red component 5 most significant bits */
g = ((rgb888.green & 0xFC) >> 2); /* Extract the green component 6 most significant bits */
b = ((rgb888.blue & 0xF8) >> 3); /* Extract the blue component 5 most significant bits */
rgb565 = ((uint16_t)(r) << 11) + ((uint16_t)(g) << 5) + ((uint16_t)(b) << 0);
return (rgb565);
}
/**
* @brief Writes to the selected LCD register.
* @param Command: command value (or register address as named in st7789h2 doc).
* @param Parameters: pointer on parameters value (if command uses one or several parameters).
* @param NbParameters: number of command parameters (0 if no parameter)
* @retval None
*/
void ST7789H2_WriteReg(uint8_t Command, uint8_t *Parameters, uint8_t NbParameters)
{
uint8_t i;
/* Send command */
LCD_IO_WriteReg(Command);
/* Send command's parameters if any */
for (i=0; i<NbParameters; i++)
{
LCD_IO_WriteData(Parameters[i]);
}
}
/**
* @brief Reads the selected LCD Register.
* @param Command: command value (or register address as named in st7789h2 doc).
* @retval Register Value.
*/
uint8_t ST7789H2_ReadReg(uint8_t Command)
{
/* Send command */
LCD_IO_WriteReg(Command);
/* Read dummy data */
LCD_IO_ReadData();
/* Read register value */
return (LCD_IO_ReadData());
}
/**
* @brief Sets a display window
* @param Xpos: specifies the X bottom left position.
* @param Ypos: specifies the Y bottom left position.
* @param Height: display window height.
* @param Width: display window width.
* @retval None
*/
void ST7789H2_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
{
if (Xpos < ST7789H2_LCD_PIXEL_WIDTH)
{
WindowsXstart = Xpos;
}
else
{
WindowsXstart = 0;
}
if (Ypos < ST7789H2_LCD_PIXEL_HEIGHT)
{
WindowsYstart = Ypos;
}
else
{
WindowsYstart = 0;
}
if (Width + Xpos <= ST7789H2_LCD_PIXEL_WIDTH)
{
WindowsXend = Width + Xpos - 1;
}
else
{
WindowsXend = ST7789H2_LCD_PIXEL_WIDTH - 1;
}
if (Height + Ypos <= ST7789H2_LCD_PIXEL_HEIGHT)
{
WindowsYend = Height + Ypos - 1;
}
else
{
WindowsYend = ST7789H2_LCD_PIXEL_HEIGHT-1;
}
}
/**
* @brief Draw vertical line.
* @param RGBCode: Specifies the RGB color in RGB565 format
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Length: specifies the Line length.
* @retval None
*/
void ST7789H2_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint16_t counter = 0;
/* Set Cursor */
ST7789H2_SetCursor(Xpos, Ypos);
/* Prepare to write to LCD RAM */
ST7789H2_WriteReg(ST7789H2_WRITE_RAM, (uint8_t*)NULL, 0); /* RAM write data command */
/* Sent a complete line */
for(counter = 0; counter < Length; counter++)
{
LCD_IO_WriteData(RGBCode);
}
}
/**
* @brief Draw vertical line.
* @param RGBCode: Specifies the RGB color
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @param Length: specifies the Line length.
* @retval None
*/
void ST7789H2_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint16_t counter = 0;
/* Set Cursor */
ST7789H2_SetCursor(Xpos, Ypos);
/* Prepare to write to LCD RAM */
ST7789H2_WriteReg(ST7789H2_WRITE_RAM, (uint8_t*)NULL, 0); /* RAM write data command */
/* Fill a complete vertical line */
for(counter = 0; counter < Length; counter++)
{
ST7789H2_WritePixel(Xpos, Ypos + counter, RGBCode);
}
}
/**
* @brief Displays a bitmap picture.
* @param BmpAddress: Bmp picture address.
* @param Xpos: Bmp X position in the LCD
* @param Ypos: Bmp Y position in the LCD
* @retval None
*/
void ST7789H2_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp)
{
uint32_t index = 0, size = 0;
uint32_t posY;
uint32_t nb_line = 0;
uint16_t Xsize = WindowsXend - WindowsXstart + 1;
uint16_t Ysize = WindowsYend - WindowsYstart + 1;
/* Read bitmap size */
size = *(volatile uint16_t *) (pbmp + 2);
size |= (*(volatile uint16_t *) (pbmp + 4)) << 16;
/* Get bitmap data address offset */
index = *(volatile uint16_t *) (pbmp + 10);
index |= (*(volatile uint16_t *) (pbmp + 12)) << 16;
size = (size - index)/2;
pbmp += index;
for (posY = (Ypos + Ysize); posY > Ypos; posY--) /* In BMP files the line order is inverted */
{
/* Set Cursor */
ST7789H2_SetCursor(Xpos, posY - 1);
/* Draw one line of the picture */
ST7789H2_DrawRGBHLine(Xpos, posY - 1, Xsize, (pbmp + (nb_line * Xsize * 2)));
nb_line++;
}
}
/**
* @brief Displays picture.
* @param pdata: picture address.
* @param Xpos: Image X position in the LCD
* @param Ypos: Image Y position in the LCD
* @param Xsize: Image X size in the LCD
* @param Ysize: Image Y size in the LCD
* @retval None
*/
void ST7789H2_DrawRGBImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata)
{
uint32_t posY;
uint32_t nb_line = 0;
for (posY = Ypos; posY < (Ypos + Ysize); posY ++)
{
/* Set Cursor */
ST7789H2_SetCursor(Xpos, posY);
/* Draw one line of the picture */
ST7789H2_DrawRGBHLine(Xpos, posY, Xsize, (pdata + (nb_line * Xsize * 2)));
nb_line++;
}
}
/******************************************************************************
Static Functions
*******************************************************************************/
/**
* @brief Read pixel from LCD RAM in RGB888 format
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @retval Each RGB pixel color components in a structure
*/
static ST7789H2_Rgb888 ST7789H2_ReadPixel_rgb888(uint16_t Xpos, uint16_t Ypos)
{
ST7789H2_Rgb888 rgb888;
uint16_t rgb888_part1, rgb888_part2;
/* In LCD RAM, pixels are 24 bits packed and read with 16 bits access
* Here is the pixels components arrangement in memory :
* bits: 15 14 13 12 11 10 09 08 | 07 06 05 04 03 02 01 00
* address 0 : red pixel 0 X X | green pixel 0 X X
* address 1 : blue pixel 0 X X | red pixel 1 X X
* address 2 : green pixel 1 X X | blue pixel 1 X X
*/
/* Set Cursor */
ST7789H2_SetCursor(Xpos, Ypos);
/* Prepare to read LCD RAM */
ST7789H2_WriteReg(ST7789H2_READ_RAM, (uint8_t*)NULL, 0); /* RAM read data command */
/* Dummy read */
LCD_IO_ReadData();
/* Read first part of the RGB888 data */
rgb888_part1 = LCD_IO_ReadData();
/* Read first part of the RGB888 data */
rgb888_part2 = LCD_IO_ReadData();
/* red component */
rgb888.red = (rgb888_part1 & 0xFC00) >> 8;
/* green component */
rgb888.green = (rgb888_part1 & 0x00FC) >> 0;
/* blue component */
rgb888.blue = (rgb888_part2 & 0xFC00) >> 8;
return rgb888;
}
/**
* @brief Displays a single picture line.
* @param pdata: picture address.
* @param Xpos: Image X position in the LCD
* @param Ypos: Image Y position in the LCD
* @param Xsize: Image X size in the LCD
* @retval None
*/
static void ST7789H2_DrawRGBHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint8_t *pdata)
{
uint32_t i = 0;
uint32_t posX;
uint16_t *rgb565 = (uint16_t*)pdata;
/* Prepare to write to LCD RAM */
ST7789H2_WriteReg(ST7789H2_WRITE_RAM, (uint8_t*)NULL, 0); /* RAM write data command */
for (posX = Xpos; posX < (Xsize + Xpos); posX++)
{
if ((posX >= WindowsXstart) && (Ypos >= WindowsYstart) && /* Check we are in the defined window */
(posX <= WindowsXend) && (Ypos <= WindowsYend))
{
if (posX != (Xsize + Xpos)) /* When writing last pixel when size is odd, the third part is not written */
{
LCD_IO_WriteData(rgb565[i]);
}
i++;
}
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,172 @@
/**
******************************************************************************
* @file st7789h2.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the st7789h2.c
* driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __ST7789H2_H
#define __ST7789H2_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdio.h>
#include "../Common/lcd.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup ST7789H2
* @{
*/
/** @defgroup ST7789H2_Exported_Types ST7789H2 Exported Types
* @{
*/
/**
* @}
*/
/** @defgroup ST7789H2_Exported_Constants ST7789H2 Exported Constants
* @{
*/
/**
* @brief ST7789H2 ID
*/
#define ST7789H2_ID 0x85
/**
* @brief ST7789H2 Size
*/
#define ST7789H2_LCD_PIXEL_WIDTH ((uint16_t)240)
#define ST7789H2_LCD_PIXEL_HEIGHT ((uint16_t)240)
/**
* @brief LCD_OrientationTypeDef
* Possible values of Display Orientation
*/
#define ST7789H2_ORIENTATION_PORTRAIT ((uint32_t)0x00) /* Portrait orientation choice of LCD screen */
#define ST7789H2_ORIENTATION_LANDSCAPE ((uint32_t)0x01) /* Landscape orientation choice of LCD screen */
#define ST7789H2_ORIENTATION_LANDSCAPE_ROT180 ((uint32_t)0x02) /* Landscape rotated 180<38> orientation choice of LCD screen */
/**
* @brief ST7789H2 Registers
*/
#define ST7789H2_LCD_ID 0x04
#define ST7789H2_SLEEP_IN 0x10
#define ST7789H2_SLEEP_OUT 0x11
#define ST7789H2_PARTIAL_DISPLAY 0x12
#define ST7789H2_DISPLAY_INVERSION 0x21
#define ST7789H2_DISPLAY_ON 0x29
#define ST7789H2_WRITE_RAM 0x2C
#define ST7789H2_READ_RAM 0x2E
#define ST7789H2_CASET 0x2A
#define ST7789H2_RASET 0x2B
#define ST7789H2_VSCRDEF 0x33 /* Vertical Scroll Definition */
#define ST7789H2_VSCSAD 0x37 /* Vertical Scroll Start Address of RAM */
#define ST7789H2_TEARING_EFFECT 0x35
#define ST7789H2_NORMAL_DISPLAY 0x36
#define ST7789H2_IDLE_MODE_OFF 0x38
#define ST7789H2_IDLE_MODE_ON 0x39
#define ST7789H2_COLOR_MODE 0x3A
#define ST7789H2_WRCABCMB 0x5E /* Write Content Adaptive Brightness Control */
#define ST7789H2_RDCABCMB 0x5F /* Read Content Adaptive Brightness Control */
#define ST7789H2_PORCH_CTRL 0xB2
#define ST7789H2_GATE_CTRL 0xB7
#define ST7789H2_VCOM_SET 0xBB
#define ST7789H2_DISPLAY_OFF 0xBD
#define ST7789H2_LCM_CTRL 0xC0
#define ST7789H2_VDV_VRH_EN 0xC2
#define ST7789H2_VDV_SET 0xC4
#define ST7789H2_VCOMH_OFFSET_SET 0xC5
#define ST7789H2_FR_CTRL 0xC6
#define ST7789H2_POWER_CTRL 0xD0
#define ST7789H2_PV_GAMMA_CTRL 0xE0
#define ST7789H2_NV_GAMMA_CTRL 0xE1
/**
* @}
*/
/** @defgroup ST7789H2_Exported_Functions ST7789H2 Exported Functions
* @{
*/
void ST7789H2_Init(void);
void ST7789H2_SetOrientation(uint32_t orientation);
uint16_t ST7789H2_ReadID(void);
void ST7789H2_WriteReg(uint8_t Command, uint8_t *Parameters, uint8_t NbParameters);
uint8_t ST7789H2_ReadReg(uint8_t Command);
void ST7789H2_DisplayOn(void);
void ST7789H2_DisplayOff(void);
void ST7789H2_SetCursor(uint16_t Xpos, uint16_t Ypos);
void ST7789H2_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode);
uint16_t ST7789H2_ReadPixel(uint16_t Xpos, uint16_t Ypos);
void ST7789H2_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
void ST7789H2_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
void ST7789H2_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp);
void ST7789H2_DrawRGBImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata);
void ST7789H2_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
uint16_t ST7789H2_GetLcdPixelWidth(void);
uint16_t ST7789H2_GetLcdPixelHeight(void);
/* LCD driver structure */
extern LCD_DrvTypeDef ST7789H2_drv;
/* LCD IO functions */
extern void LCD_IO_Init(void);
extern void LCD_IO_WriteMultipleData(uint16_t *pData, uint32_t Size);
extern void LCD_IO_WriteReg(uint8_t Reg);
extern void LCD_IO_WriteData(uint16_t RegValue);
extern uint16_t LCD_IO_ReadData(void);
extern void LCD_IO_Delay(uint32_t delay);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __ST7789H2_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,84 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Release Notes for STMPE1600 Component Drivers</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="card fluid">
<div class="sectione dark">
<center>
<h1 id="release-notes-for-stmpe1600-component-drivers"><small>Release Notes for</small> <mark>STMPE1600 Component Drivers</mark></h1>
<p>Copyright © 2015 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
</center>
</div>
</div>
<h1 id="license">License</h1>
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
<h1 id="purpose">Purpose</h1>
<p>This directory contains the STMPE1600 component drivers.</p>
</div>
<div class="col-sm-12 col-lg-8">
<h1 id="update-history">Update History</h1>
<div class="collapse">
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.1.1 / 03-April-2019</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.1.0 / 10-February-2015</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Update IO_Pin parameter to uint32_t in all IO functionalities functions</li>
<li>This version is to be used with Common V2.0.0 version</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section185" aria-hidden="true"> <label for="collapse-section185" aria-hidden="true">V1.0.1 / 02-December-2014</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>stmpe1600.h: change “\” by “/” in the include path to fix compilation issue under Linux</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.0.0 / 18-February-2014</label>
<div>
<h2 id="main-changes-3">Main Changes</h2>
<ul>
<li>First official release</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
</footer>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More