Initial commit

This commit is contained in:
Jochen Friedrich 2021-01-01 14:06:20 +01:00
commit 66c5a26d69
1145 changed files with 938088 additions and 0 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 CBTL08GP053 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-cbtl08gp053-component-drivers"><small>Release Notes for</small> <mark>CBTL08GP053 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 CBTL08GP053 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-section12" checked aria-hidden="true"> <label for="collapse-section12" aria-hidden="true">V1.0.1 / 23-July-2020</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Fix minor mispelled words</li>
<li>Update Release Notes format</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section11" aria-hidden="true"> <label for="collapse-section11" aria-hidden="true">V1.0.0 / 16-November-2017</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>First official release of CBTL08GP053 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,391 @@
/**
******************************************************************************
* @file cbtl08gp053.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the CBTL08GP053
* (Crossbar switch device for USB Type-C systems).
******************************************************************************
* @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 "cbtl08gp053.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @defgroup CBTL08GP053
* @brief This file provides a set of functions needed to drive the
* CBTL08GP053 Crossbar switch device for USB Type-C systems.
* @{
*/
/** @defgroup CBTL08GP053_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup CBTL08GP053_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup CBTL08GP053_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup CBTL08GP053_Private_Variables
* @{
*/
#ifdef DBG_BSP_MUX
CBTL08GP053_TypeDef CBTL08GP053 =
{
.SYS_CTRL = 0x00,
.OP1_CTRL = 0x00,
.OP2_CTRL = 0x00,
.OP3_CTRL = 0x00,
.OP4_CTRL = 0x00,
.OP5_CTRL = 0x00,
.CROSS5_CTRL = 0x01,
.SW_CTRL = 0x00,
.SW_CTRL = 0x00,
.REVISION = 0xA0
};
#endif /* DBG_BSP_MUX */
/* Type-C Crosspoint Switch Driver structure initialization */
TYPECSWITCH_Drv_t cbtl08gp053_drv = {
cbtl08gp053_Init,
cbtl08gp053_DeInit,
cbtl08gp053_PowerOn,
cbtl08gp053_PowerOff,
cbtl08gp053_SetMode,
cbtl08gp053_IsSupportedMode
};
/* Supported USB Type-C pin assignments */
static const uint32_t cbtl08gp053_SupportedModes =
( 1 << USB_NORMAL |
1 << USB_FLIPPED |
1 << DFP_D_PIN_ASSIGNMENT_C_NORMAL |
1 << DFP_D_PIN_ASSIGNMENT_C_FLIPPED |
1 << DFP_D_PIN_ASSIGNMENT_D_NORMAL |
1 << DFP_D_PIN_ASSIGNMENT_D_FLIPPED |
1 << DFP_D_PIN_ASSIGNMENT_E_NORMAL |
1 << DFP_D_PIN_ASSIGNMENT_E_FLIPPED |
1 << DFP_D_PIN_ASSIGNMENT_F_NORMAL |
1 << DFP_D_PIN_ASSIGNMENT_F_FLIPPED |
1 << UFP_D_PIN_ASSIGNMENT_C_NORMAL |
1 << UFP_D_PIN_ASSIGNMENT_C_FLIPPED |
1 << UFP_D_PIN_ASSIGNMENT_D_NORMAL |
1 << UFP_D_PIN_ASSIGNMENT_D_FLIPPED |
1 << UFP_D_PIN_ASSIGNMENT_E_NORMAL |
1 << UFP_D_PIN_ASSIGNMENT_E_FLIPPED );
/**
* @}
*/
/** @defgroup CBTL08GP053_Private_FunctionPrototypes
* @{
*/
/**
* @}
*/
/** @defgroup CBTL08GP053_Private_Functions
* @{
*/
/**
* @brief Initialize the CBTL08GP053 and configure the needed hardware resources.
* @param Address CBTL08GP053 address on communication Bus.
* @retval 0: successful, else failed
*/
uint32_t cbtl08gp053_Init(uint16_t Address)
{
uint32_t err_count = 0;
/* Low level init */
err_count += MUX_IO_Init();
/* Restore CBTL08GP053 registers reset values */
MUX_IO_Write(Address, CBTL08GP053_REG_SYS_CTRL, 0x00);
MUX_IO_Write(Address, CBTL08GP053_REG_OP1_CTRL, 0x00);
MUX_IO_Write(Address, CBTL08GP053_REG_OP2_CTRL, 0x00);
MUX_IO_Write(Address, CBTL08GP053_REG_OP3_CTRL, 0x00);
MUX_IO_Write(Address, CBTL08GP053_REG_OP4_CTRL, 0x00);
MUX_IO_Write(Address, CBTL08GP053_REG_OP5_CTRL, 0x00);
MUX_IO_Write(Address, CBTL08GP053_REG_CROSS5_CTRL, 0x01);
MUX_IO_Write(Address, CBTL08GP053_REG_SW_CTRL, 0x00);
return err_count;
}
/**
* @brief Release the hardware resources required to use the CBTL08GP053.
* @param Address CBTL08GP053 address on communication Bus.
* @retval none
*/
void cbtl08gp053_DeInit(uint16_t Address)
{
/* Restore CBTL08GP053 registers reset values */
MUX_IO_Write(Address, CBTL08GP053_REG_SYS_CTRL, 0x00);
MUX_IO_Write(Address, CBTL08GP053_REG_OP1_CTRL, 0x00);
MUX_IO_Write(Address, CBTL08GP053_REG_OP2_CTRL, 0x00);
MUX_IO_Write(Address, CBTL08GP053_REG_OP3_CTRL, 0x00);
MUX_IO_Write(Address, CBTL08GP053_REG_OP4_CTRL, 0x00);
MUX_IO_Write(Address, CBTL08GP053_REG_OP5_CTRL, 0x00);
MUX_IO_Write(Address, CBTL08GP053_REG_CROSS5_CTRL, 0x01);
MUX_IO_Write(Address, CBTL08GP053_REG_SW_CTRL, 0x00);
/* Low level de-init */
MUX_IO_DeInit();
}
/**
* @brief Power on the CBTL08GP053.
* @param Address CBTL08GP053 address on communication Bus.
* @retval 0: successful, else failed
*/
uint32_t cbtl08gp053_PowerOn(uint16_t Address)
{
uint32_t err_count = 0;
/* Set SYS_CTRL.SWTICH_EN bit */
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_SYS_CTRL, CBTL08GP053_REG_SYS_CTRL_SWITCH_EN);
return err_count;
}
/**
* @brief Power down the CBTL08GP053.
* @param Address CBTL08GP053 address on communication Bus.
* @retval 0: successful, else failed
*/
uint32_t cbtl08gp053_PowerOff(uint16_t Address)
{
uint32_t err_count = 0;
/* Clear SYS_CTRL.SWTICH_EN bit */
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_SYS_CTRL, 0x00);
return err_count;
}
/**
* @brief Configure the CBTL08GP053 according to the requested USB Type-C
* connector pin assignment.
* @param Address CBTL08GP053 address on communication Bus.
* @param Mode USB Type-C connector pin assignment
* @retval 0: success, else error
*/
uint32_t cbtl08gp053_SetMode(uint16_t Address, TYPECSWITCH_Mode_t Mode)
{
uint32_t err_count = 0;
uint8_t sw_ctrl = (CBTL08GP053_REG_SW_X5_SET |
CBTL08GP053_REG_SW_OP1_SET |
CBTL08GP053_REG_SW_OP2_SET |
CBTL08GP053_REG_SW_OP3_SET |
CBTL08GP053_REG_SW_OP4_SET |
CBTL08GP053_REG_SW_OP5_SET);
/* Transition to safe mode prior updating cross switch configuration */
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP1_CTRL, 0x00);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP2_CTRL, 0x00);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP3_CTRL, 0x00);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP4_CTRL, 0x00);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP5_CTRL, 0x00);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_CROSS5_CTRL, 0x00);
/* Configure cross switch */
switch(Mode)
{
case USB_NORMAL:
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP1_CTRL, CBTL08GP053_REG_OP1_CTRL_EN_IP1);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP2_CTRL, 0x00);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP3_CTRL, CBTL08GP053_REG_OP3_CTRL_EN_IP4);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP4_CTRL, 0x00);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP5_CTRL, 0x00);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_CROSS5_CTRL, 0x00);
break;
case USB_FLIPPED:
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP1_CTRL, 0x00);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP2_CTRL, CBTL08GP053_REG_OP1_CTRL_EN_IP1);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP3_CTRL, 0x00);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP4_CTRL, CBTL08GP053_REG_OP3_CTRL_EN_IP4);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP5_CTRL, 0x00);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_CROSS5_CTRL, 0x00);
break;
case DFP_D_PIN_ASSIGNMENT_C_NORMAL:
case DFP_D_PIN_ASSIGNMENT_E_NORMAL:
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP1_CTRL, CBTL08GP053_REG_OP1_CTRL_EN_IP2);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP2_CTRL, CBTL08GP053_REG_OP2_CTRL_EN_IP3);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP3_CTRL, CBTL08GP053_REG_OP3_CTRL_EN_IP5);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP4_CTRL, CBTL08GP053_REG_OP4_CTRL_EN_IP6);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP5_CTRL, CBTL08GP053_REG_OP5_CTRL_EN_IP7);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_CROSS5_CTRL, CBTL08GP053_REG_CROSS5_PASS);
break;
case DFP_D_PIN_ASSIGNMENT_C_FLIPPED:
case DFP_D_PIN_ASSIGNMENT_E_FLIPPED:
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP1_CTRL, CBTL08GP053_REG_OP1_CTRL_EN_IP3);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP2_CTRL, CBTL08GP053_REG_OP2_CTRL_EN_IP2);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP3_CTRL, CBTL08GP053_REG_OP3_CTRL_EN_IP6);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP4_CTRL, CBTL08GP053_REG_OP4_CTRL_EN_IP5);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP5_CTRL, CBTL08GP053_REG_OP5_CTRL_EN_IP7);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_CROSS5_CTRL, CBTL08GP053_REG_CROSS5_CROSS);
break;
case DFP_D_PIN_ASSIGNMENT_D_NORMAL:
case DFP_D_PIN_ASSIGNMENT_F_NORMAL:
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP1_CTRL, CBTL08GP053_REG_OP1_CTRL_EN_IP1);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP2_CTRL, CBTL08GP053_REG_OP2_CTRL_EN_IP3);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP3_CTRL, CBTL08GP053_REG_OP3_CTRL_EN_IP4);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP4_CTRL, CBTL08GP053_REG_OP4_CTRL_EN_IP6);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP5_CTRL, CBTL08GP053_REG_OP5_CTRL_EN_IP7);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_CROSS5_CTRL, CBTL08GP053_REG_CROSS5_PASS);
break;
case DFP_D_PIN_ASSIGNMENT_D_FLIPPED:
case DFP_D_PIN_ASSIGNMENT_F_FLIPPED:
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP1_CTRL, CBTL08GP053_REG_OP1_CTRL_EN_IP3);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP2_CTRL, CBTL08GP053_REG_OP2_CTRL_EN_IP1);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP3_CTRL, CBTL08GP053_REG_OP3_CTRL_EN_IP6);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP4_CTRL, CBTL08GP053_REG_OP4_CTRL_EN_IP4);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP5_CTRL, CBTL08GP053_REG_OP5_CTRL_EN_IP7);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_CROSS5_CTRL, CBTL08GP053_REG_CROSS5_CROSS);
break;
case UFP_D_PIN_ASSIGNMENT_C_NORMAL:
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP1_CTRL, CBTL08GP053_REG_OP1_CTRL_EN_IP2);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP2_CTRL, CBTL08GP053_REG_OP2_CTRL_EN_IP3);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP3_CTRL, CBTL08GP053_REG_OP3_CTRL_EN_IP5);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP4_CTRL, CBTL08GP053_REG_OP4_CTRL_EN_IP6);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP5_CTRL, CBTL08GP053_REG_OP5_CTRL_EN_IP7);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_CROSS5_CTRL, CBTL08GP053_REG_CROSS5_CROSS);
break;
case UFP_D_PIN_ASSIGNMENT_C_FLIPPED:
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP1_CTRL, CBTL08GP053_REG_OP1_CTRL_EN_IP3);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP2_CTRL, CBTL08GP053_REG_OP2_CTRL_EN_IP2);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP3_CTRL, CBTL08GP053_REG_OP3_CTRL_EN_IP6);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP4_CTRL, CBTL08GP053_REG_OP4_CTRL_EN_IP5);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP5_CTRL, CBTL08GP053_REG_OP5_CTRL_EN_IP7);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_CROSS5_CTRL, CBTL08GP053_REG_CROSS5_PASS);
break;
case UFP_D_PIN_ASSIGNMENT_D_NORMAL:
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP1_CTRL, CBTL08GP053_REG_OP1_CTRL_EN_IP1);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP2_CTRL, CBTL08GP053_REG_OP2_CTRL_EN_IP3);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP3_CTRL, CBTL08GP053_REG_OP3_CTRL_EN_IP4);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP4_CTRL, CBTL08GP053_REG_OP4_CTRL_EN_IP6);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP5_CTRL, CBTL08GP053_REG_OP5_CTRL_EN_IP7);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_CROSS5_CTRL, CBTL08GP053_REG_CROSS5_CROSS);
break;
case UFP_D_PIN_ASSIGNMENT_D_FLIPPED:
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP1_CTRL, CBTL08GP053_REG_OP1_CTRL_EN_IP3);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP2_CTRL, CBTL08GP053_REG_OP2_CTRL_EN_IP1);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP3_CTRL, CBTL08GP053_REG_OP3_CTRL_EN_IP6);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP4_CTRL, CBTL08GP053_REG_OP4_CTRL_EN_IP4);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP5_CTRL, CBTL08GP053_REG_OP5_CTRL_EN_IP7);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_CROSS5_CTRL, CBTL08GP053_REG_CROSS5_PASS);
break;
case UFP_D_PIN_ASSIGNMENT_E_NORMAL:
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP1_CTRL, CBTL08GP053_REG_OP1_CTRL_EN_IP2);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP2_CTRL, CBTL08GP053_REG_OP2_CTRL_EN_IP3);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP3_CTRL, CBTL08GP053_REG_OP3_CTRL_EN_IP5);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP4_CTRL, CBTL08GP053_REG_OP4_CTRL_EN_IP6);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP5_CTRL, CBTL08GP053_REG_OP5_CTRL_EN_IP7);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_CROSS5_CTRL, CBTL08GP053_REG_CROSS5_CROSS);
break;
case UFP_D_PIN_ASSIGNMENT_E_FLIPPED:
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP1_CTRL, CBTL08GP053_REG_OP1_CTRL_EN_IP3);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP2_CTRL, CBTL08GP053_REG_OP2_CTRL_EN_IP2);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP3_CTRL, CBTL08GP053_REG_OP3_CTRL_EN_IP6);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP4_CTRL, CBTL08GP053_REG_OP4_CTRL_EN_IP5);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP5_CTRL, CBTL08GP053_REG_OP5_CTRL_EN_IP7);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_CROSS5_CTRL, CBTL08GP053_REG_CROSS5_PASS);
break;
default:
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP1_CTRL, 0x00);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP2_CTRL, 0x00);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP3_CTRL, 0x00);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP4_CTRL, 0x00);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_OP5_CTRL, 0x00);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_CROSS5_CTRL, 0x00);
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_SW_CTRL, sw_ctrl);
break;
}
/* Enable cross switch configuration */
err_count += MUX_IO_Write(Address, CBTL08GP053_REG_SW_CTRL, sw_ctrl);
return err_count;
}
/**
* @brief Indicate whether the requested USB Type-C connector pin assignment
* is supported by the CBTL08GP053.
* @param Mode USB Type-C connector pin assignment
* @retval 0: success, else error
*/
uint32_t cbtl08gp053_IsSupportedMode(TYPECSWITCH_Mode_t Mode)
{
return (((1 << Mode) & cbtl08gp053_SupportedModes ) == 0) ? 0 : 1;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,369 @@
/**
******************************************************************************
* @file cbtl08gp053.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the CBTL08GP053
* (Crossbar switch device for USB Type-C systems).
******************************************************************************
* @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 __CBTL08GP053_H
#define __CBTL08GP053_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
#include "../Common/usbtypecswitch.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup CBTL08GP053
* @{
*/
#ifdef DBG_BSP_MUX
typedef struct
{
uint8_t RESERVED1; /*!< Address offset: 0x00 */
uint8_t SYS_CTRL; /*!< Address offset: 0x01 */
uint8_t OP1_CTRL; /*!< Address offset: 0x02 */
uint8_t OP2_CTRL; /*!< Address offset: 0x03 */
uint8_t OP3_CTRL; /*!< Address offset: 0x04 */
uint8_t OP4_CTRL; /*!< Address offset: 0x05 */
uint8_t OP5_CTRL; /*!< Address offset: 0x06 */
uint8_t CROSS5_CTRL; /*!< Address offset: 0x07 */
uint8_t SW_CTRL; /*!< Address offset: 0x08 */
uint8_t REVISION; /*!< Address offset: 0x09 */
} CBTL08GP053_TypeDef;
extern CBTL08GP053_TypeDef CBTL08GP053;
#endif /* DBG_BSP_MUX */
/** @defgroup CBTL08GP053_Exported_Constants
* @{
*/
/******************************* Register Map ********************************/
#define CBTL08GP053_REG_SYS_CTRL 0x01 /*!< */
#define CBTL08GP053_REG_OP1_CTRL 0x02 /*!< */
#define CBTL08GP053_REG_OP2_CTRL 0x03 /*!< */
#define CBTL08GP053_REG_OP3_CTRL 0x04 /*!< */
#define CBTL08GP053_REG_OP4_CTRL 0x05 /*!< */
#define CBTL08GP053_REG_OP5_CTRL 0x06 /*!< */
#define CBTL08GP053_REG_CROSS5_CTRL 0x07 /*!< */
#define CBTL08GP053_REG_SW_CTRL 0x08 /*!< */
#define CBTL08GP053_REG_REVISION 0x09 /*!< */
/********************* Bit definition for SYS_CTRL register *****************/
#define CBTL08GP053_REG_SYS_CTRL_SWITCH_EN_Pos (7U)
#define CBTL08GP053_REG_SYS_CTRL_SWITCH_EN_Msk (0x1U << CBTL08GP053_REG_SYS_CTRL_SWITCH_EN_Pos) /*!< 0x80*/
#define CBTL08GP053_REG_SYS_CTRL_SWITCH_EN CBTL08GP053_REG_SYS_CTRL_SWITCH_EN_Msk /*!< */
/********************* Bit definition for OP1_CTRL register *****************/
#define CBTL08GP053_REG_OP1_CTRL_EN_IP1_Pos (0U)
#define CBTL08GP053_REG_OP1_CTRL_EN_IP1_Msk (0x1U << CBTL08GP053_REG_OP1_CTRL_EN_IP1_Pos) /*!< 0x01 */
#define CBTL08GP053_REG_OP1_CTRL_EN_IP1 CBTL08GP053_REG_OP1_CTRL_EN_IP1_Msk /*!< */
#define CBTL08GP053_REG_OP1_CTRL_EN_IP2_Pos (1U)
#define CBTL08GP053_REG_OP1_CTRL_EN_IP2_Msk (0x1U << CBTL08GP053_REG_OP1_CTRL_EN_IP2_Pos) /*!< 0x02 */
#define CBTL08GP053_REG_OP1_CTRL_EN_IP2 CBTL08GP053_REG_OP1_CTRL_EN_IP2_Msk /*!< */
#define CBTL08GP053_REG_OP1_CTRL_EN_IP3_Pos (2U)
#define CBTL08GP053_REG_OP1_CTRL_EN_IP3_Msk (0x1U << CBTL08GP053_REG_OP1_CTRL_EN_IP3_Pos) /*!< 0x04 */
#define CBTL08GP053_REG_OP1_CTRL_EN_IP3 CBTL08GP053_REG_OP1_CTRL_EN_IP3_Msk /*!< */
/********************* Bit definition for OP2_CTRL register *****************/
#define CBTL08GP053_REG_OP2_CTRL_EN_IP1_Pos (0U)
#define CBTL08GP053_REG_OP2_CTRL_EN_IP1_Msk (0x1U << CBTL08GP053_REG_OP2_CTRL_EN_IP1_Pos) /*!< 0x01 */
#define CBTL08GP053_REG_OP2_CTRL_EN_IP1 CBTL08GP053_REG_OP2_CTRL_EN_IP1_Msk /*!< */
#define CBTL08GP053_REG_OP2_CTRL_EN_IP2_Pos (1U)
#define CBTL08GP053_REG_OP2_CTRL_EN_IP2_Msk (0x1U << CBTL08GP053_REG_OP2_CTRL_EN_IP2_Pos) /*!< 0x02 */
#define CBTL08GP053_REG_OP2_CTRL_EN_IP2 CBTL08GP053_REG_OP2_CTRL_EN_IP2_Msk /*!< */
#define CBTL08GP053_REG_OP2_CTRL_EN_IP3_Pos (2U)
#define CBTL08GP053_REG_OP2_CTRL_EN_IP3_Msk (0x1U << CBTL08GP053_REG_OP2_CTRL_EN_IP3_Pos) /*!< 0x04 */
#define CBTL08GP053_REG_OP2_CTRL_EN_IP3 CBTL08GP053_REG_OP2_CTRL_EN_IP3_Msk /*!< */
/********************* Bit definition for OP3_CTRL register *****************/
#define CBTL08GP053_REG_OP3_CTRL_EN_IP4_Pos (3U)
#define CBTL08GP053_REG_OP3_CTRL_EN_IP4_Msk (0x1U << CBTL08GP053_REG_OP3_CTRL_EN_IP4_Pos) /*!< 0x08 */
#define CBTL08GP053_REG_OP3_CTRL_EN_IP4 CBTL08GP053_REG_OP3_CTRL_EN_IP4_Msk /*!< */
#define CBTL08GP053_REG_OP3_CTRL_EN_IP5_Pos (4U)
#define CBTL08GP053_REG_OP3_CTRL_EN_IP5_Msk (0x1U << CBTL08GP053_REG_OP3_CTRL_EN_IP5_Pos) /*!< 0x10 */
#define CBTL08GP053_REG_OP3_CTRL_EN_IP5 CBTL08GP053_REG_OP3_CTRL_EN_IP5_Msk /*!< */
#define CBTL08GP053_REG_OP3_CTRL_EN_IP6_Pos (5U)
#define CBTL08GP053_REG_OP3_CTRL_EN_IP6_Msk (0x1U << CBTL08GP053_REG_OP3_CTRL_EN_IP6_Pos) /*!< 0x20 */
#define CBTL08GP053_REG_OP3_CTRL_EN_IP6 CBTL08GP053_REG_OP3_CTRL_EN_IP6_Msk /*!< */
/********************* Bit definition for OP4_CTRL register *****************/
#define CBTL08GP053_REG_OP4_CTRL_EN_IP4_Pos (3U)
#define CBTL08GP053_REG_OP4_CTRL_EN_IP4_Msk (0x1U << CBTL08GP053_REG_OP4_CTRL_EN_IP4_Pos) /*!< 0x08 */
#define CBTL08GP053_REG_OP4_CTRL_EN_IP4 CBTL08GP053_REG_OP4_CTRL_EN_IP4_Msk /*!< */
#define CBTL08GP053_REG_OP4_CTRL_EN_IP5_Pos (4U)
#define CBTL08GP053_REG_OP4_CTRL_EN_IP5_Msk (0x1U << CBTL08GP053_REG_OP4_CTRL_EN_IP5_Pos) /*!< 0x10 */
#define CBTL08GP053_REG_OP4_CTRL_EN_IP5 CBTL08GP053_REG_OP4_CTRL_EN_IP5_Msk /*!< */
#define CBTL08GP053_REG_OP4_CTRL_EN_IP6_Pos (5U)
#define CBTL08GP053_REG_OP4_CTRL_EN_IP6_Msk (0x1U << CBTL08GP053_REG_OP4_CTRL_EN_IP6_Pos) /*!< 0x20 */
#define CBTL08GP053_REG_OP4_CTRL_EN_IP6 CBTL08GP053_REG_OP4_CTRL_EN_IP6_Msk /*!< */
/********************* Bit definition for OP5_CTRL register *****************/
#define CBTL08GP053_REG_OP5_CTRL_EN_IP7_Pos (6U)
#define CBTL08GP053_REG_OP5_CTRL_EN_IP7_Msk (0x1U << CBTL08GP053_REG_OP5_CTRL_EN_IP7_Pos) /*!< 0x40 */
#define CBTL08GP053_REG_OP5_CTRL_EN_IP7 CBTL08GP053_REG_OP5_CTRL_EN_IP7_Msk /*!< */
#define CBTL08GP053_REG_OP5_CTRL_EN_IP8_Pos (7U)
#define CBTL08GP053_REG_OP5_CTRL_EN_IP8_Msk (0x1U << CBTL08GP053_REG_OP5_CTRL_EN_IP8_Pos) /*!< 0x80 */
#define CBTL08GP053_REG_OP5_CTRL_EN_IP8 CBTL08GP053_REG_OP5_CTRL_EN_IP8_Msk /*!< */
/****************** Bit definition for CROSS5_CTRL register *****************/
#define CBTL08GP053_REG_CROSS5_PASS_Pos (0U)
#define CBTL08GP053_REG_CROSS5_PASS_Msk (0x1U << CBTL08GP053_REG_CROSS5_PASS_Pos) /*!< 0x01 */
#define CBTL08GP053_REG_CROSS5_PASS CBTL08GP053_REG_CROSS5_PASS_Msk /*!< */
#define CBTL08GP053_REG_CROSS5_CROSS_Pos (1U)
#define CBTL08GP053_REG_CROSS5_CROSS_Msk (0x1U << CBTL08GP053_REG_CROSS5_CROSS_Pos) /*!< 0x02 */
#define CBTL08GP053_REG_CROSS5_CROSS CBTL08GP053_REG_CROSS5_CROSS_Msk /*!< */
/******************* Bit definition for SW_CTRL register ********************/
#define CBTL08GP053_REG_SW_OP1_SET_Pos (0U)
#define CBTL08GP053_REG_SW_OP1_SET_Msk (0x1U << CBTL08GP053_REG_SW_OP1_SET_Pos) /*!< 0x01 */
#define CBTL08GP053_REG_SW_OP1_SET CBTL08GP053_REG_SW_OP1_SET_Msk /*!< */
#define CBTL08GP053_REG_SW_OP2_SET_Pos (1U)
#define CBTL08GP053_REG_SW_OP2_SET_Msk (0x1U << CBTL08GP053_REG_SW_OP2_SET_Pos) /*!< 0x02 */
#define CBTL08GP053_REG_SW_OP2_SET CBTL08GP053_REG_SW_OP2_SET_Msk /*!< */
#define CBTL08GP053_REG_SW_OP3_SET_Pos (2U)
#define CBTL08GP053_REG_SW_OP3_SET_Msk (0x1U << CBTL08GP053_REG_SW_OP3_SET_Pos) /*!< 0x04 */
#define CBTL08GP053_REG_SW_OP3_SET CBTL08GP053_REG_SW_OP3_SET_Msk /*!< */
#define CBTL08GP053_REG_SW_OP4_SET_Pos (3U)
#define CBTL08GP053_REG_SW_OP4_SET_Msk (0x1U << CBTL08GP053_REG_SW_OP4_SET_Pos) /*!< 0x08 */
#define CBTL08GP053_REG_SW_OP4_SET CBTL08GP053_REG_SW_OP4_SET_Msk /*!< */
#define CBTL08GP053_REG_SW_OP5_SET_Pos (4U)
#define CBTL08GP053_REG_SW_OP5_SET_Msk (0x1U << CBTL08GP053_REG_SW_OP5_SET_Pos) /*!< 0x10 */
#define CBTL08GP053_REG_SW_OP5_SET CBTL08GP053_REG_SW_OP5_SET_Msk /*!< */
#define CBTL08GP053_REG_SW_X5_SET_Pos (5U)
#define CBTL08GP053_REG_SW_X5_SET_Msk (0x1U << CBTL08GP053_REG_SW_X5_SET_Pos) /*!< 0x20 */
#define CBTL08GP053_REG_SW_X5_SET CBTL08GP053_REG_SW_X5_SET_Msk /*!< */
/******************** Bit definition for REVISION register ******************/
#define CBTL08GP053_REVISION_REV_ID_Pos (0U)
#define CBTL08GP053_REVISION_REV_ID_Msk (0xFFU << CBTL08GP053_REVISION_REV_ID_Pos) /*!< 0xFF */
#define CBTL08GP053_REVISION_REV_ID CBTL08GP053_REVISION_REV_ID_Msk /*!< */
/** @defgroup CBTL08GP053_DisplayPort_Alternate_Mode
* @{
*/
#define CBTL08GP053_DP_ALTMODE_DFP_D_C_E_NORMAL 0x00U
#define CBTL08GP053_DP_ALTMODE_DFP_D_C_E_FLIPPED 0x01U
#define CBTL08GP053_DP_ALTMODE_DFP_D_D_F_NORMAL 0x02U
#define CBTL08GP053_DP_ALTMODE_DFP_D_D_F_FLIPPED 0x03U
#define CBTL08GP053_DP_ALTMODE_UFP_D_C_NORMAL 0x04U
#define CBTL08GP053_DP_ALTMODE_UFP_D_C_FLIPPED 0x05U
#define CBTL08GP053_DP_ALTMODE_UFP_D_D_NORMAL 0x06U
#define CBTL08GP053_DP_ALTMODE_UFP_D_D_FLIPPED 0x07U
#define CBTL08GP053_DP_ALTMODE_UFP_D_E_NORMAL 0x08U
#define CBTL08GP053_DP_ALTMODE_UFP_D_E_FLIPPED 0x09U
/**
* @}
*/
/** @defgroup CBTL08GP053_DisplayPort_Standby_Mode
* @{
*/
#define CBTL08GP053_DP_STANDBYMODE_SAFE 0x00U
#define CBTL08GP053_DP_STANDBYMODE_USB3_NORMAL 0x01U
#define CBTL08GP053_DP_STANDBYMODE_USB3_FLIPPED 0x02U
/**
* @}
*/
/**
* @}
*/
#if defined(CBTL08GP053_DEBUG)
/** @defgroup CBTL08GP053_Exported_Structure CBTL08GP053 Exported Structure
* @{
*/
typedef union {
uint8_t Register;
struct {
uint8_t RESERVED :7;
uint8_t SWITCH_EN :1;
};
} CBTL08GP053_SysCtrlTypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t IP1 :1;
uint8_t IP2 :1;
uint8_t IP3 :1;
uint8_t RESERVED :5;
};
} CBTL08GP053_Op1CtrlTypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t IP1 :1;
uint8_t IP2 :1;
uint8_t IP3 :1;
uint8_t RESERVED :5;
};
} CBTL08GP053_Op2CtrlTypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t RESERVED1 :3;
uint8_t IP4 :1;
uint8_t IP5 :1;
uint8_t IP6 :1;
uint8_t RESERVED2 :2;
};
} CBTL08GP053_Op3CtrlTypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t RESERVED1 :3;
uint8_t IP4 :1;
uint8_t IP5 :1;
uint8_t IP6 :1;
uint8_t RESERVED2 :2;
};
} CBTL08GP053_Op4CtrlTypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t RESERVED :6;
uint8_t IP7 :1;
uint8_t IP8 :1;
};
} CBTL08GP053_Op5CtrlTypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t PASS :1;
uint8_t CROSS :1;
uint8_t RESERVED :6;
};
} CBTL08GP053_Cross5CtrlTypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t OP1_SET :1;
uint8_t OP2_SET :1;
uint8_t OP3_SET :1;
uint8_t OP4_SET :1;
uint8_t OP5_SET :1;
uint8_t X5_SET :1;
uint8_t RESERVED :2;
};
} CBTL08GP053_SwCtrlTypeDef;
typedef struct
{
CBTL08GP053_SysCtrlTypeDef SysCtrl; /*!< SYS_CTRL register (0x01) */
CBTL08GP053_Op1CtrlTypeDef Op1Ctrl; /*!< OP1_CTRL Registers (0x02) */
CBTL08GP053_Op2CtrlTypeDef Op2Ctrl; /*!< OP2_CTRL Registers (0x03) */
CBTL08GP053_Op3CtrlTypeDef Op3Ctrl; /*!< OP3_CTRL Registers (0x04) */
CBTL08GP053_Op4CtrlTypeDef Op4Ctrl; /*!< OP4_CTRL Registers (0x05) */
CBTL08GP053_Op5CtrlTypeDef Op5Ctrl; /*!< OP5_CTRL Registers (0x06) */
CBTL08GP053_Cross5CtrlTypeDef Cross5Ctrl; /*!< CROSS5_CTRL Registers (0x07) */
CBTL08GP053_SwCtrlTypeDef SwCtrl; /*!< SW_CTRL Registers (0x08) */
uint8_t Revision; /*!< REVISION Registers (0x09) */
} CBTL08GP053_RegistersTypeDef;
/**
* @}
*/
#endif /* CBTL08GP053_DEBUG */
/** @defgroup CBTL08GP053_Exported_Functions
* @{
*/
/* USB Type-C Crosspoint Switch management functions */
uint32_t cbtl08gp053_Init(uint16_t Address);
void cbtl08gp053_DeInit(uint16_t Address);
uint32_t cbtl08gp053_PowerOn(uint16_t Address);
uint32_t cbtl08gp053_PowerOff(uint16_t Address);
uint32_t cbtl08gp053_SetMode(uint16_t Address, TYPECSWITCH_Mode_t Mode);
uint32_t cbtl08gp053_IsSupportedMode(TYPECSWITCH_Mode_t Mode);
/* MUX IO functions */
uint8_t MUX_IO_Init(void);
void MUX_IO_DeInit(void);
uint8_t MUX_IO_Write(uint16_t Addr, uint16_t Reg, uint8_t Data);
uint8_t MUX_IO_Read(uint16_t Addr, uint16_t Reg, uint8_t *pData);
uint32_t MUX_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials);
/**
* @}
*/
/** @defgroup CBTL08GP053_Exported_Variables
* @{
*/
/* Type-C Crosspoint Switch Driver */
extern TYPECSWITCH_Drv_t cbtl08gp053_drv;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __CBTL08GP053_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,232 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head>
<script><endnote><head>
<script><endnote><head>
<script><endnote><head>
<script><endnote><head>
<script></script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="File-List" href="Release_Notes_files/filelist.xml">
<link rel="Edit-Time-Data" href="Release_Notes_files/editdata.mso"><title>Release Notes for HX8347D Component Drivers</title>
<style>
div.Section1 {
page: Section1;
font-family: Arial,Helvetica,sans-serif;
}
h1 {
font-size: 24pt;
font-weight: bold;
font-family: Arial,Helvetica,sans-serif;
text-align: center;
color: #3366ff;
}
h2 {
margin: 12pt 0in 3pt;
page-break-after: avoid;
font-weight: bold;
font-family: Arial,Helvetica,sans-serif;
background-color: #3366ff;
color: white;
padding-left: 5px;
font-size: 16pt;
}
h3 {
margin-left: 0in;
font-weight: bold;
font-family: Arial,Helvetica,sans-serif;
background-color: #3366ff;
width: 200px;
margin-right: 500pt;
color: white;
padding-left: 5px;
padding-top: 2px;
padding-bottom: 2px;
font-size: 12pt;
}
h4 {
font-family: Arial,Helvetica,sans-serif;
font-weight: bold;
text-decoration: underline;
font-size: 12pt;
}
p {
margin: 0px 0px 0px 0in;
font-family: Arial,Helvetica,sans-serif;
padding-top: 3px;
padding-bottom: 3px;
font-size: 12pt;
}
ul {
font-family: Arial,Helvetica,sans-serif;
margin-top: 3px;
margin-bottom: 3px;
font-size: 10pt;
}
caption {
margin-top: 10px;
font-family: Arial,Helvetica,sans-serif;
font-size: 11pt;
}
hr {
width: 100%;
}
.guidance {
background-color: #e5b8b7;
font-style: italic;
font-family: Arial,Helvetica,sans-serif;
padding-top: 3px;
padding-bottom: 3px;
margin-top: 3px;
margin-bottom: 3px;
font-size: 10pt;
}
.guidance_title {
font-style: normal;
font-weight: bold;
text-decoration: underline;
font-family: Arial,Helvetica,sans-serif;
font-size: 10pt;
}
.tickets {
border: 1pt solid #9cc2e5;
font-family: Arial,Helvetica,sans-serif;
margin-bottom: 3px;
margin-top: 3px;
font-size: 10pt;
}
.tickets th {
border: 1pt solid #9cc2e5;
font-size: 12pt;
background-color: #39a9dc;
color: white;
text-align: center;
}
.tickets td {
border: 1pt solid #9cc2e5;
min-height: 32px;
}
tr:nth-child(even) {background-color: #cee2f2;}
tr:nth-child(even) {background-color: #e8f1f9;}
.topic1 {
margin-top: 3px;
margin-bottom: 3px;
margin-left: 40px;
}
.topic2 {
margin-top: 3px;
margin-bottom: 3px;
}
.topic3 {
margin-top: 3px;
margin-bottom: 3px;
margin-left: 20px;
}
#purpose {
margin-top: 3px;
margin-bottom: 3px;
}
#identification {
margin-top: 3px;
margin-bottom: 3px;
}
</style><!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><!--[if gte mso 9]><xml> <o:DocumentProperties> <o:Author>STMicroelectronics</o:Author> <o:LastAuthor>Raouf Hosni</o:LastAuthor> <o:Revision>69</o:Revision> <o:TotalTime>153</o:TotalTime> <o:Created>2009-02-27T19:26:00Z</o:Created> <o:LastSaved>2009-07-21T16:16:00Z</o:LastSaved> <o:Pages>1</o:Pages> <o:Words>410</o:Words> <o:Characters>2339</o:Characters> <o:Company>STMicroelectronics</o:Company> <o:Lines>19</o:Lines> <o:Paragraphs>5</o:Paragraphs> <o:CharactersWithSpaces>2744</o:CharactersWithSpaces> <o:Version>11.8132</o:Version> </o:DocumentProperties> </xml><![endif]--><!--[if gte mso 9]><xml> <w:WordDocument> <w:Zoom>110</w:Zoom> <w:SpellingState>Clean</w:SpellingState> <w:GrammarState>Clean</w:GrammarState> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--><!--[if gte mso 9]><xml> <o:shapedefaults v:ext="edit" spidmax="6146"/> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext="edit"> <o:idmap v:ext="edit" data="1"/> </o:shapelayout></xml><![endif]-->
</head>
<body link="blue" vlink="blue">
<script type="text/javascript">
var toggle_hist_disp = true;
function toggle_history()
{
if (toggle_hist_disp)
{
toggle_hist_disp = false;
var filter_off_text = document.createTextNode("Hide History");
document.getElementById('filter_hist').innerHTML = "";
document.getElementById('filter_hist').appendChild(filter_off_text);
document.getElementById("history").hidden = false;
}
else
{
toggle_hist_disp = true;
var filter_on_text = document.createTextNode("Show History");
document.getElementById('filter_hist').innerHTML = "";
document.getElementById('filter_hist').appendChild(filter_on_text);
document.getElementById("history").hidden = true;
}
}</script>
<div style="width: 1034px;" class="Section1"><span style="font-size: 8pt; font-family: &quot;Arial&quot;,&quot;sans-serif&quot;; color: blue;"></span><small><a href="../../../../Release_Notes.html">Back to Release page</a></small>
<div id="header">
<h1 style="margin-bottom: 18pt; text-align: center;" align="center">Release
Notes for HX8347D Component Drivers</h1>
<p style="text-align: center;">Copyright 2014
STMicroelectronics</p>
<p style="text-align: center;"><span style="font-size: 10pt; font-family: &quot;Arial&quot;,&quot;sans-serif&quot;; color: black;"><img style="border: 0px solid ; width: 112px; height: 83px;" alt="" id="_x0000_i1026" src="../../../../_htmresc/st_logo.png"></span></p>
</div>
<div id="license" class="topic1">
<h2>License</h2>
This software component is licensed by ST under BSD 3-Clause
license, the "License"; You may not use this component except in
compliance with
the License. You may obtain a copy of the License at:
<p style="text-align: center;"><a href="https://opensource.org/licenses/BSD-3-Clause" target="_blank">https://opensource.org/licenses/BSD-3-Clause</a></p>
</div>
<br>
<div id="release_container" class="topic1">
<div class="topic2" id="identification">
<h3 style="width: 229px;">V1.1.2 / 11-October-2018</h3>
</div>
<div class="topic3" id="changes">
<h4><b><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: black;"></span><u><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: black;"></span></u></b><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main
Changes</span></u></b><o:p style="font-family: Helvetica,Arial,sans-serif;"></o:p></h4>
<span style="font-size: 12pt; font-family: Helvetica,Arial,sans-serif;"></span><span style="font-size: 11pt; color: rgb(0, 32, 96); font-family: Helvetica,Arial,sans-serif;" lang="EN-US"></span><span style="font-size: 10pt; font-family: Helvetica,Arial,sans-serif;"></span><span style="font-size: 10pt; font-family: Verdana;">Fix&nbsp;</span><small><span style="font-family: Verdana;" id="summary_container"><span id="short_desc_nonedit_display">HardFault issue in
hx8347d_DrawBitmap()</span></span></small><span style="font-size: 10pt; font-family: Helvetica,Arial,sans-serif;"></span>
<span style="font-size: 10pt; font-family: Helvetica,Arial,sans-serif;"></span></div>
<br>
</div>
<div style="margin-left: 40px;"><button id="filter_hist" onclick="toggle_history()">Show
History</button><br>
</div>
<div id="history" class="topic1" hidden="">
<h2>Update History</h2>
<b><u><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: black;"></span></u></b><br>
<h3 style="width: 229px;">V1.1.1 / 24-November-2014</h3>
<p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main
Changes<o:p></o:p></span></u></b></p>
<span style="font-size: 10pt; font-family: Verdana;"></span>
<span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span>
<ul style="list-style-type: square;">
<li><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-family: Verdana;"></span><span style="font-family: Verdana; font-size: 10pt;">hx8347d.h:
change </span><span style="font-family: Verdana; font-size: 10pt;">"\" by</span><span style="font-family: Verdana; font-size: 10pt;"> "/"&nbsp;</span><span style="font-family: Verdana; font-size: 10pt;"></span><span style="font-family: Verdana; font-size: 10pt;">in the</span><span style="font-family: Verdana; font-size: 10pt;"> include path
to fix compilation issue with Linux</span></li>
</ul>
<h3 style="width: 229px;">V1.1.0 / 11-July-2014</h3>
<p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main
Changes<o:p></o:p></span></u></b></p>
<span style="font-size: 10pt; font-family: Verdana;"></span>
<span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span>
<ul style="list-style-type: square;">
<li><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-family: Verdana;"></span><span style="font-family: Verdana; font-size: 10pt;">Harmonize all
LCD controllers Link usage (change LCD_IO_WriteData() to
LCD_IO_WriteMultipleData())</span><span style="font-family: Verdana; font-size: 10pt;"></span></li>
</ul>
<h3 style="width: 229px;">V1.0.0 / 06-May-2014</h3>
<p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main
Changes<o:p></o:p></span></u></b></p>
<span style="font-size: 10pt; font-family: Verdana;"></span>
<span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span>
<ul style="list-style-type: square;">
<li><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;">First
official release of<span>&nbsp;</span></span><span style="font-size: 10pt; font-family: Verdana;">HX8347D LCD
Component</span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"><span>&nbsp;</span>driver</span></li>
</ul>
<b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;"><o:p></o:p></span></u></b><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><br>
</div>
<div id="product_doc" class="topic1">
<hr>
<p style="text-align: center;">For complete
documentation on STM32 Microcontrollers<span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: black;"></span><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;"><span style="color: black;"></span></span>,
visit:&nbsp;<a href="http://www.st.com/STM32" target="_blank">www.st.com/STM32</a></p>
<br>
</div>
</div>
</body></html>

View file

@ -0,0 +1,485 @@
/**
******************************************************************************
* @file hx8347d.c
* @author MCD Application Team
* @brief This file includes the LCD driver for HX8347D LCD.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</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 "hx8347d.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup HX8347D
* @brief This file provides a set of functions needed to drive the
* HX8347D LCD.
* @{
*/
/** @defgroup HX8347D_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup HX8347D_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup HX8347D_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup HX8347D_Private_Variables
* @{
*/
LCD_DrvTypeDef hx8347d_drv =
{
hx8347d_Init,
hx8347d_ReadID,
hx8347d_DisplayOn,
hx8347d_DisplayOff,
hx8347d_SetCursor,
hx8347d_WritePixel,
hx8347d_ReadPixel,
hx8347d_SetDisplayWindow,
hx8347d_DrawHLine,
hx8347d_DrawVLine,
hx8347d_GetLcdPixelWidth,
hx8347d_GetLcdPixelHeight,
hx8347d_DrawBitmap,
};
static uint8_t Is_hx8347d_Initialized = 0;
static uint16_t ArrayRGB[320] = {0};
/**
* @}
*/
/** @defgroup HX8347D_Private_FunctionPrototypes
* @{
*/
/**
* @}
*/
/** @defgroup HX8347D_Private_Functions
* @{
*/
/**
* @brief Initialise the HX8347D LCD Component.
* @param None
* @retval None
*/
void hx8347d_Init(void)
{
if(Is_hx8347d_Initialized == 0)
{
Is_hx8347d_Initialized = 1;
/* Initialise HX8347D low level bus layer --------------------------------*/
LCD_IO_Init();
/* Driving ability setting */
hx8347d_WriteReg(LCD_REG_234, 0x00);
hx8347d_WriteReg(LCD_REG_235, 0x20);
hx8347d_WriteReg(LCD_REG_236, 0x0C);
hx8347d_WriteReg(LCD_REG_237, 0xC4);
hx8347d_WriteReg(LCD_REG_232, 0x40);
hx8347d_WriteReg(LCD_REG_233, 0x38);
hx8347d_WriteReg(LCD_REG_241, 0x01);
hx8347d_WriteReg(LCD_REG_242, 0x10);
hx8347d_WriteReg(LCD_REG_39, 0xA3);
/* Adjust the Gamma Curve */
hx8347d_WriteReg(LCD_REG_64, 0x01);
hx8347d_WriteReg(LCD_REG_65, 0x00);
hx8347d_WriteReg(LCD_REG_66, 0x00);
hx8347d_WriteReg(LCD_REG_67, 0x10);
hx8347d_WriteReg(LCD_REG_68, 0x0E);
hx8347d_WriteReg(LCD_REG_69, 0x24);
hx8347d_WriteReg(LCD_REG_70, 0x04);
hx8347d_WriteReg(LCD_REG_71, 0x50);
hx8347d_WriteReg(LCD_REG_72, 0x02);
hx8347d_WriteReg(LCD_REG_73, 0x13);
hx8347d_WriteReg(LCD_REG_74, 0x19);
hx8347d_WriteReg(LCD_REG_75, 0x19);
hx8347d_WriteReg(LCD_REG_76, 0x16);
hx8347d_WriteReg(LCD_REG_80, 0x1B);
hx8347d_WriteReg(LCD_REG_81, 0x31);
hx8347d_WriteReg(LCD_REG_82, 0x2F);
hx8347d_WriteReg(LCD_REG_83, 0x3F);
hx8347d_WriteReg(LCD_REG_84, 0x3F);
hx8347d_WriteReg(LCD_REG_85, 0x3E);
hx8347d_WriteReg(LCD_REG_86, 0x2F);
hx8347d_WriteReg(LCD_REG_87, 0x7B);
hx8347d_WriteReg(LCD_REG_88, 0x09);
hx8347d_WriteReg(LCD_REG_89, 0x06);
hx8347d_WriteReg(LCD_REG_90, 0x06);
hx8347d_WriteReg(LCD_REG_91, 0x0C);
hx8347d_WriteReg(LCD_REG_92, 0x1D);
hx8347d_WriteReg(LCD_REG_93, 0xCC);
/* Power voltage setting */
hx8347d_WriteReg(LCD_REG_27, 0x1B);
hx8347d_WriteReg(LCD_REG_26, 0x01);
hx8347d_WriteReg(LCD_REG_36, 0x2F);
hx8347d_WriteReg(LCD_REG_37, 0x57);
/*****VCOM offset ****/
hx8347d_WriteReg(LCD_REG_35, 0x86);
/* Power on setting up flow */
hx8347d_WriteReg(LCD_REG_24, 0x36); /* Display frame rate = 70Hz RADJ = '0110' */
hx8347d_WriteReg(LCD_REG_25, 0x01); /* OSC_EN = 1 */
hx8347d_WriteReg(LCD_REG_28, 0x06); /* AP[2:0] = 111 */
hx8347d_WriteReg(LCD_REG_29, 0x06); /* AP[2:0] = 111 */
hx8347d_WriteReg(LCD_REG_31,0x90); /* GAS=1, VOMG=00, PON=1, DK=0, XDK=0, DVDH_TRI=0, STB=0*/
hx8347d_WriteReg(LCD_REG_39, 1); /* REF = 1 */
LCD_Delay(10);
/* 262k/65k color selection */
hx8347d_WriteReg(LCD_REG_23, 0x05); /* default 0x06 262k color, 0x05 65k color */
/* SET PANEL */
hx8347d_WriteReg(LCD_REG_54, 0x09); /* SS_PANEL = 1, GS_PANEL = 0,REV_PANEL = 0, BGR_PANEL = 1 */
/* Display ON flow */
hx8347d_WriteReg(LCD_REG_40, 0x38); /* GON=1, DTE=1, D=10 */
LCD_Delay(60);
hx8347d_WriteReg(LCD_REG_40, 0x3C); /* GON=1, DTE=1, D=11 */
/* Set GRAM Area - Partial Display Control */
hx8347d_WriteReg(LCD_REG_1, 0x00); /* DP_STB = 0, DP_STB_S = 0, SCROLL = 0, */
hx8347d_WriteReg(LCD_REG_2, 0x00); /* Column address start 2 */
hx8347d_WriteReg(LCD_REG_3, 0x00); /* Column address start 1 */
hx8347d_WriteReg(LCD_REG_4, 0x01); /* Column address end 2 */
hx8347d_WriteReg(LCD_REG_5, 0x3F); /* Column address end 1 */
hx8347d_WriteReg(LCD_REG_6, 0x00); /* Row address start 2 */
hx8347d_WriteReg(LCD_REG_7, 0x00); /* Row address start 2 */
hx8347d_WriteReg(LCD_REG_8, 0x00); /* Row address end 2 */
hx8347d_WriteReg(LCD_REG_9, 0xEF); /* Row address end 1 */
hx8347d_WriteReg(LCD_REG_22, 0xE0); /* Memory access control: MY = 1, MX = 0, MV = 1, ML = 0 */
}
/* Set the Cursor */
hx8347d_SetCursor(0, 0);
/* Prepare to write GRAM */
LCD_IO_WriteReg(LCD_REG_34);
}
/**
* @brief Enables the Display.
* @param None
* @retval None
*/
void hx8347d_DisplayOn(void)
{
/* Power On sequence ---------------------------------------------------------*/
hx8347d_WriteReg(LCD_REG_24, 0x36); /* Display frame rate = 70Hz RADJ = '0110' */
hx8347d_WriteReg(LCD_REG_25, 0x01); /* OSC_EN = 1 */
hx8347d_WriteReg(LCD_REG_28, 0x06); /* AP[2:0] = 111 */
hx8347d_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 */
hx8347d_WriteReg(LCD_REG_23, 0x05); /* default 0x06 262k color, 0x05 65k color */
/* SET PANEL */
hx8347d_WriteReg(LCD_REG_54, 0x09); /* SS_PANEL = 1, GS_PANEL = 0,REV_PANEL = 0, BGR_PANEL = 1 */
/* Display On */
hx8347d_WriteReg(LCD_REG_40, 0x38);
LCD_Delay(60);
hx8347d_WriteReg(LCD_REG_40, 0x3C);
}
/**
* @brief Disables the Display.
* @param None
* @retval None
*/
void hx8347d_DisplayOff(void)
{
/* Power Off sequence ---------------------------------------------------------*/
hx8347d_WriteReg(LCD_REG_23, 0x0000); /* default 0x06 262k color, 0x05 65k color */
hx8347d_WriteReg(LCD_REG_24, 0x0000); /* Display frame rate = 70Hz RADJ = '0110' */
hx8347d_WriteReg(LCD_REG_25, 0x0000); /* OSC_EN = 1 */
hx8347d_WriteReg(LCD_REG_28, 0x0000); /* AP[2:0] = 111 */
hx8347d_WriteReg(LCD_REG_31, 0x0000); /* GAS=1, VOMG=00, PON=1, DK=0, XDK=0, DVDH_TRI=0, STB=0*/
hx8347d_WriteReg(LCD_REG_54, 0x0000); /* SS_PANEL = 1, GS_PANEL = 0,REV_PANEL = 0, BGR_PANEL = 1 */
/* Display Off */
hx8347d_WriteReg(LCD_REG_40, 0x38);
LCD_Delay(60);
hx8347d_WriteReg(LCD_REG_40, 0x04);
}
/**
* @brief Get the LCD pixel Width.
* @param None
* @retval The Lcd Pixel Width
*/
uint16_t hx8347d_GetLcdPixelWidth(void)
{
return (uint16_t)HX8347D_LCD_PIXEL_WIDTH;
}
/**
* @brief Get the LCD pixel Height.
* @param None
* @retval The Lcd Pixel Height
*/
uint16_t hx8347d_GetLcdPixelHeight(void)
{
return (uint16_t)HX8347D_LCD_PIXEL_HEIGHT;
}
/**
* @brief Get the HX8347D ID.
* @param None
* @retval The HX8347D ID
*/
uint16_t hx8347d_ReadID(void)
{
if(Is_hx8347d_Initialized == 0)
{
hx8347d_Init();
Is_hx8347d_Initialized = 1;
}
return (hx8347d_ReadReg(0x00));
}
/**
* @brief Set Cursor position.
* @param Xpos: specifies the X position.
* @param Ypos: specifies the Y position.
* @retval None
*/
void hx8347d_SetCursor(uint16_t Xpos, uint16_t Ypos)
{
hx8347d_WriteReg(LCD_REG_6, 0x00);
hx8347d_WriteReg(LCD_REG_7, Xpos);
hx8347d_WriteReg(LCD_REG_2, Ypos >> 8);
hx8347d_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 hx8347d_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode)
{
/* Set Cursor */
hx8347d_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 hx8347d_ReadPixel(uint16_t Xpos, uint16_t Ypos)
{
/* Set Cursor */
hx8347d_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 hx8347d_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 hx8347d_ReadReg(uint8_t 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 hx8347d_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
{
/* Horizontal GRAM Start Address */
hx8347d_WriteReg(LCD_REG_6, (Xpos) >> 8); /* SP */
hx8347d_WriteReg(LCD_REG_7, (Xpos) & 0xFF); /* SP */
/* Horizontal GRAM End Address */
hx8347d_WriteReg(LCD_REG_8, (Xpos + Height - 1) >> 8); /* EP */
hx8347d_WriteReg(LCD_REG_9, (Xpos + Height - 1) & 0xFF); /* EP */
/* Vertical GRAM Start Address */
hx8347d_WriteReg(LCD_REG_2, (Ypos) >> 8); /* SC */
hx8347d_WriteReg(LCD_REG_3, (Ypos) & 0xFF); /* SC */
/* Vertical GRAM End Address */
hx8347d_WriteReg(LCD_REG_4, (Ypos + Width - 1) >> 8); /* EC */
hx8347d_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 hx8347d_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint32_t i = 0;
/* Set Cursor */
hx8347d_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 hx8347d_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint16_t counter = 0;
/* Set Cursor */
hx8347d_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 hx8347d_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp)
{
uint32_t index = 0, size = 0;
/* Read bitmap size */
size = pbmp[2] + (pbmp[3] << 8) + (pbmp[4] << 16) + (pbmp[5] << 24);
/* Get bitmap data address offset */
index = pbmp[10] + (pbmp[11] << 8) + (pbmp[12] << 16) + (pbmp[13] << 24);
size = (size - index)/2;
pbmp += index;
/* Set GRAM write direction and BGR = 0 */
/* Memory access control: MY = 1, MX = 0, MV = 1, ML = 0 */
hx8347d_WriteReg(LCD_REG_22, 0xA0);
/* Set Cursor */
hx8347d_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 */
hx8347d_WriteReg(LCD_REG_22, 0xE0);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,259 @@
/**
******************************************************************************
* @file hx8347d.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the hx8347d.c
* driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</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 HX8347D_H
#define HX8347D_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/lcd.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup HX8347D
* @{
*/
/** @defgroup HX8347D_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup HX8347D_Exported_Constants
* @{
*/
/**
* @brief HX8347D ID
*/
#define HX8347D_ID 0x0047
/**
* @brief HX8347D Size
*/
#define HX8347D_LCD_PIXEL_WIDTH ((uint16_t)320)
#define HX8347D_LCD_PIXEL_HEIGHT ((uint16_t)240)
/**
* @brief HX8347D 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_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_39 0x27
#define LCD_REG_40 0x28
#define LCD_REG_41 0x29
#define LCD_REG_43 0x2B
#define LCD_REG_45 0x2D
#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_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_96 0x60
#define LCD_REG_97 0x61
#define LCD_REG_106 0x6A
#define LCD_REG_118 0x76
#define LCD_REG_128 0x80
#define LCD_REG_129 0x81
#define LCD_REG_130 0x82
#define LCD_REG_131 0x83
#define LCD_REG_132 0x84
#define LCD_REG_133 0x85
#define LCD_REG_134 0x86
#define LCD_REG_135 0x87
#define LCD_REG_136 0x88
#define LCD_REG_137 0x89
#define LCD_REG_139 0x8B
#define LCD_REG_140 0x8C
#define LCD_REG_141 0x8D
#define LCD_REG_143 0x8F
#define LCD_REG_144 0x90
#define LCD_REG_145 0x91
#define LCD_REG_146 0x92
#define LCD_REG_147 0x93
#define LCD_REG_148 0x94
#define LCD_REG_149 0x95
#define LCD_REG_150 0x96
#define LCD_REG_151 0x97
#define LCD_REG_152 0x98
#define LCD_REG_153 0x99
#define LCD_REG_154 0x9A
#define LCD_REG_157 0x9D
#define LCD_REG_192 0xC0
#define LCD_REG_193 0xC1
#define LCD_REG_227 0xE3
#define LCD_REG_229 0xE5
#define LCD_REG_231 0xE7
#define LCD_REG_239 0xEF
#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
/**
* @}
*/
/** @defgroup HX8347D_Exported_Functions
* @{
*/
void hx8347d_Init(void);
uint16_t hx8347d_ReadID(void);
void hx8347d_WriteReg(uint8_t LCDReg, uint16_t LCDRegValue);
uint16_t hx8347d_ReadReg(uint8_t LCDReg);
void hx8347d_DisplayOn(void);
void hx8347d_DisplayOff(void);
void hx8347d_SetCursor(uint16_t Xpos, uint16_t Ypos);
void hx8347d_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode);
uint16_t hx8347d_ReadPixel(uint16_t Xpos, uint16_t Ypos);
void hx8347d_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
void hx8347d_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
void hx8347d_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp);
void hx8347d_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
uint16_t hx8347d_GetLcdPixelWidth(void);
uint16_t hx8347d_GetLcdPixelHeight(void);
/* LCD driver structure */
extern LCD_DrvTypeDef hx8347d_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 /* HX8347D_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,74 @@
<!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 SN65DP141 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-sn65dp141-component-drivers"><small>Release Notes for</small> <mark>SN65DP141 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 SN65DP141 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-section13" checked aria-hidden="true"> <label for="collapse-section13" aria-hidden="true">V1.0.2 / 23-July-2020</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Update release notes format</li>
<li>Correct misspelled words</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section12" aria-hidden="true"> <label for="collapse-section12" aria-hidden="true">V1.0.1 / 10-October-2018</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Fix compilation warnings detected by IAR V8.30.1</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section11" aria-hidden="true"> <label for="collapse-section11" aria-hidden="true">V1.0.0 / 16-November-2017</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>First official release of SN65DP141 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,346 @@
/**
******************************************************************************
* @file sn65dp141.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the SN65DP141
* 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
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "sn65dp141.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @defgroup SN65DP141
* @brief This file provides a set of functions needed to drive the
* SN65DP141 DisplayPort Linear Redriver.
* @{
*/
/** @defgroup SN65DP141_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup SN65DP141_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup SN65DP141_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup SN65DP141_Private_Variables
* @{
*/
/* DisplayPort Linear Redriver Driver structure initialization */
DPREDRIVER_Drv_t sn65dp141_drv =
{
sn65dp141_Init,
sn65dp141_DeInit,
sn65dp141_PowerOn,
sn65dp141_PowerOff,
sn65dp141_SetEQGain,
sn65dp141_EnableChannel,
sn65dp141_DisableChannel
};
/**
* @}
*/
/** @defgroup SN65DP141_Private_FunctionPrototypes
* @{
*/
/**
* @}
*/
/** @defgroup SN65DP141_Private_Functions
* @{
*/
/**
* @brief Initialize the SN65DP141 and configure the needed hardware resources.
* @param Address Device address on communication Bus.
* @retval None
*/
uint32_t sn65dp141_Init(uint16_t Address)
{
uint32_t err_count = 0;
/* Low level init */
err_count += MUX_IO_Init();
/* Restore SN65DP141 registers reset values */
err_count += MUX_IO_Write(Address, SN65DP141_REG_CFG, 0x00);
err_count += MUX_IO_Write(Address, SN65DP141_REG_CHEN, 0x00);
err_count += MUX_IO_Write(Address, SN65DP141_REG_CH0_CFG, 0x00);
err_count += MUX_IO_Write(Address, SN65DP141_REG_CH0_EN, 0x00);
err_count += MUX_IO_Write(Address, SN65DP141_REG_CH1_CFG, 0x00);
err_count += MUX_IO_Write(Address, SN65DP141_REG_CH1_EN, 0x00);
err_count += MUX_IO_Write(Address, SN65DP141_REG_CH2_CFG, 0x00);
err_count += MUX_IO_Write(Address, SN65DP141_REG_CH2_EN, 0x00);
err_count += MUX_IO_Write(Address, SN65DP141_REG_CH3_CFG, 0x00);
err_count += MUX_IO_Write(Address, SN65DP141_REG_CH3_EN, 0x00);
return err_count;
}
/**
* @brief Release the hardware resources required to use the SN65DP141
* @param Address SN65DP141 address on communication Bus.
* @retval none
*/
void sn65dp141_DeInit(uint16_t Address)
{
/* Restore SN65DP141 registers reset values */
MUX_IO_Write(Address, SN65DP141_REG_CFG, 0x00);
MUX_IO_Write(Address, SN65DP141_REG_CHEN, 0x00);
MUX_IO_Write(Address, SN65DP141_REG_CH0_CFG, 0x00);
MUX_IO_Write(Address, SN65DP141_REG_CH0_EN, 0x00);
MUX_IO_Write(Address, SN65DP141_REG_CH1_CFG, 0x00);
MUX_IO_Write(Address, SN65DP141_REG_CH1_EN, 0x00);
MUX_IO_Write(Address, SN65DP141_REG_CH2_CFG, 0x00);
MUX_IO_Write(Address, SN65DP141_REG_CH2_EN, 0x00);
MUX_IO_Write(Address, SN65DP141_REG_CH3_CFG, 0x00);
MUX_IO_Write(Address, SN65DP141_REG_CH3_EN, 0x00);
/* Low level de-init */
MUX_IO_DeInit();
}
/**
* @brief Power on the SN65DP141.
* @param Address SN65DP141 address on communication Bus.
* @retval 0: successful, else failed
*/
uint32_t sn65dp141_PowerOn(uint16_t Address)
{
uint32_t err_count = 0;
uint8_t cfg;
/* Read General Device Settings register*/
err_count += MUX_IO_Read(Address, SN65DP141_REG_CFG, &cfg);
/* Clear PWRDOWN bit of General Device Settings register */
cfg &= ~SN65DP141_REG_CFG_PWRDOWN;
err_count += MUX_IO_Write(Address, SN65DP141_REG_CFG, cfg);
return err_count;
}
/**
* @brief Power down the SN65DP141.
* @param Address SN65DP141 address on communication Bus.
* @retval 0: successful, else failed
*/
uint32_t sn65dp141_PowerOff(uint16_t Address)
{
uint32_t err_count = 0;
uint8_t cfg;
/* Read General Device Settings register*/
err_count += MUX_IO_Read(Address, SN65DP141_REG_CFG, &cfg);
/* Set PWRDOWN bit of General Device Settings register */
cfg |= SN65DP141_REG_CFG_PWRDOWN;
err_count += MUX_IO_Write(Address, SN65DP141_REG_CFG, cfg);
return err_count;
}
/**
* @brief Set the equalizer gain for a given channel.
* @param Address SN65DP141 address on communication Bus.
* @param ChannelId Channel identifier.
* This parameter can be take one of the following values:
* CHANNEL_DP0
* CHANNEL_DP1
* CHANNEL_DP2
* CHANNEL_DP3
* @param EQGain Equalizer gain.
* This parameter must be a value between 0x00 and 0x07.
* @retval 0: successful, else failed
*/
uint32_t sn65dp141_SetEQGain(uint16_t Address,
DPREDRIVER_ChannelId_t ChannelId,
uint8_t EQGain)
{
uint32_t err_count = 0;
uint8_t chctrl;
uint8_t cfg;
switch(ChannelId)
{
case CHANNEL_DP0:
cfg = SN65DP141_REG_CH0_CFG;
break;
case CHANNEL_DP1:
cfg = SN65DP141_REG_CH1_CFG;
break;
case CHANNEL_DP2:
cfg = SN65DP141_REG_CH2_CFG;
break;
case CHANNEL_DP3:
cfg = SN65DP141_REG_CH3_CFG;
break;
default:
cfg = SN65DP141_REG_CH0_CFG;
break;
}
/* Read Channel x Control Settings register */
err_count += MUX_IO_Read(Address, cfg, &chctrl);
/* Set the equalizer gain bit field (EQ setting) for concerned channel */
chctrl = (chctrl & (~(uint8_t)SN65DP141_REG_CHxCFG_EQ_SETTING_Msk)) | (EQGain << SN65DP141_REG_CHxCFG_EQ_SETTING_Pos);
/* Enable Max gain for TX & RX */
chctrl |= SN65DP141_REG_CHxCFG_RX_GAIN_1 | SN65DP141_REG_CHxCFG_EQ_DC_GAIN | SN65DP141_REG_CHxCFG_TX_GAIN;
/* Update Channel x Control Settings register */
err_count += MUX_IO_Write(Address, cfg, chctrl);
return err_count;
}
/**
* @brief Enable a DP channel.
* @param Address SN65DP141 address on communication Bus.
* @param ChannelId Channel identifier.
* This parameter can be take one of the following values:
* CHANNEL_DP0
* CHANNEL_DP1
* CHANNEL_DP2
* CHANNEL_DP3
* @retval 0: successful, else failed
*/
uint32_t sn65dp141_EnableChannel(uint16_t Address,
DPREDRIVER_ChannelId_t ChannelId)
{
uint32_t err_count = 0;
uint8_t chen;
/* Read Channel Enable register */
err_count += MUX_IO_Read(Address, SN65DP141_REG_CHEN, &chen);
/* Clear LN_EN_CHx bit of Channel Enable register */
switch(ChannelId)
{
case CHANNEL_DP0:
chen &= ~SN65DP141_REG_CHEN_LN_EN_CH0;
break;
case CHANNEL_DP1:
chen &= ~SN65DP141_REG_CHEN_LN_EN_CH1;
break;
case CHANNEL_DP2:
chen &= ~SN65DP141_REG_CHEN_LN_EN_CH2;
break;
case CHANNEL_DP3:
chen &= ~SN65DP141_REG_CHEN_LN_EN_CH3;
break;
default:
/* Nothing to do */
break;
}
err_count += MUX_IO_Write(Address, SN65DP141_REG_CHEN, chen);
return err_count;
}
/**
* @brief Disable a DP channel.
* @param Address SN65DP141 address on communication Bus.
* @param ChannelId Channel identifier.
* This parameter can be take one of the following values:
* CHANNEL_DP0
* CHANNEL_DP1
* CHANNEL_DP2
* CHANNEL_DP3
* @retval 0: successful, else failed
*/
uint32_t sn65dp141_DisableChannel(uint16_t Address,
DPREDRIVER_ChannelId_t ChannelId)
{
uint32_t err_count = 0;
uint8_t chen;
/* Read Channel Enable register */
err_count += MUX_IO_Read(Address, SN65DP141_REG_CHEN, &chen);
/* Set LN_EN_CHx bit of Channel Enable register */
switch(ChannelId)
{
case CHANNEL_DP0:
chen |= SN65DP141_REG_CHEN_LN_EN_CH0;
break;
case CHANNEL_DP1:
chen |= SN65DP141_REG_CHEN_LN_EN_CH1;
break;
case CHANNEL_DP2:
chen |= SN65DP141_REG_CHEN_LN_EN_CH2;
break;
case CHANNEL_DP3:
chen |= SN65DP141_REG_CHEN_LN_EN_CH3;
break;
default:
/* Nothing to do */
break;
}
err_count += MUX_IO_Write(Address, SN65DP141_REG_CHEN, chen);
return err_count;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,395 @@
/**
******************************************************************************
* @file sn65dp141.h
* @author MCD Application Team
* @brief Header for sn65dp141.h module
******************************************************************************
* @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 SN65DP141_H
#define SN65DP141_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
#include "../Common/dpredriver.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup SN65DP141
* @{
*/
/** @defgroup SN65DP141_Exported_Constants
* @{
*/
/******************************* Register Map ********************************/
#define SN65DP141_REG_CFG 0x00 /*!< General Device Settings register */
#define SN65DP141_REG_CHEN 0x01 /*!< Channel Enable register */
#define SN65DP141_REG_CH0_CFG 0x02 /*!< Channel 0 Control Settings register */
#define SN65DP141_REG_CH0_EN 0x03 /*!< Channel 0 Enable Settings register */
#define SN65DP141_REG_CH1_CFG 0x05 /*!< Channel 1 Control Settings register */
#define SN65DP141_REG_CH1_EN 0x06 /*!< Channel 1 Enable Settings register */
#define SN65DP141_REG_CH2_CFG 0x08 /*!< Channel 2 Control Settings register */
#define SN65DP141_REG_CH2_EN 0x09 /*!< Channel 2 Enable Settings register */
#define SN65DP141_REG_CH3_CFG 0x0B /*!< Channel 3 Control Settings register */
#define SN65DP141_REG_CH3_EN 0x0C /*!< Channel 3 Enable Settings register */
/*********** Bit definition for General Device Settings register *************/
#define SN65DP141_REG_CFG_EQ_MODE_Pos (1U)
#define SN65DP141_REG_CFG_EQ_MODE_Msk (0x1U << SN65DP141_REG_CFG_EQ_MODE_Pos) /*!< 0x04*/
#define SN65DP141_REG_CFG_EQ_MODE SN65DP141_REG_CFG_EQ_MODE_Msk /*!< EQ mode (Cable mode v.s. Trace mode) */
#define SN65DP141_REG_CFG_SYNC_ALL_Pos (3U)
#define SN65DP141_REG_CFG_SYNC_ALL_Msk (0x1U << SN65DP141_REG_CFG_SYNC_ALL_Pos) /*!< 0x08*/
#define SN65DP141_REG_CFG_SYNC_ALL SN65DP141_REG_CFG_SYNC_ALL_Msk /*!< All settings from channel 1 will be used on all channels */
#define SN65DP141_REG_CFG_SYNC_23_Pos (4U)
#define SN65DP141_REG_CFG_SYNC_23_Msk (0x1U << SN65DP141_REG_CFG_SYNC23_Pos) /*!< 0x10*/
#define SN65DP141_REG_CFG_SYNC_23 SN65DP141_REG_CFG_SYNC_23_Msk /*!< All settings from channel 2 will be used for channel 2 and 3 */
#define SN65DP141_REG_CFG_SYNC_01_Pos (5U)
#define SN65DP141_REG_CFG_SYNC_01_Msk (0x1U << SN65DP141_REG_CFG_SYNC01_Pos) /*!< 0x20*/
#define SN65DP141_REG_CFG_SYNC_01 SN65DP141_REG_CFG_SYNC_01_Msk /*!< All settings from channel 1 will be used for channel 0 and 1 */
#define SN65DP141_REG_CFG_PWRDOWN_Pos (6U)
#define SN65DP141_REG_CFG_PWRDOWN_Msk (0x1U << SN65DP141_REG_CFG_PWRDOWN_Pos) /*!< 0x40*/
#define SN65DP141_REG_CFG_PWRDOWN SN65DP141_REG_CFG_PWRDOWN_Msk /*!< Power down the device */
#define SN65DP141_REG_CFG_SW_GPIO_Pos (7U)
#define SN65DP141_REG_CFG_SW_GPIO_Msk (0x1U << SN65DP141_REG_CFG_SW_GPIO_Pos) /*!< 0x80*/
#define SN65DP141_REG_CFG_SW_GPIO SN65DP141_REG_CFG_SW_GPIO_Msk /*!< Switching logic is controlled by GPIO or I2C */
/*********** Bit definition for Channel Enable register *************/
#define SN65DP141_REG_CHEN_LN_EN_CH0_Pos (0U)
#define SN65DP141_REG_CHEN_LN_EN_CH0_Msk (0x1U << SN65DP141_REG_CHEN_LN_EN_CH0_Pos) /*!< 0x01 */
#define SN65DP141_REG_CHEN_LN_EN_CH0 SN65DP141_REG_CHEN_LN_EN_CH0_Msk /*!< Channel 0 enable */
#define SN65DP141_REG_CHEN_LN_EN_CH1_Pos (1U)
#define SN65DP141_REG_CHEN_LN_EN_CH1_Msk (0x1U << SN65DP141_REG_CHEN_LN_EN_CH1_Pos) /*!< 0x02 */
#define SN65DP141_REG_CHEN_LN_EN_CH1 SN65DP141_REG_CHEN_LN_EN_CH1_Msk /*!< Channel 1 enable */
#define SN65DP141_REG_CHEN_LN_EN_CH2_Pos (2U)
#define SN65DP141_REG_CHEN_LN_EN_CH2_Msk (0x1U << SN65DP141_REG_CHEN_LN_EN_CH2_Pos) /*!< 0x04 */
#define SN65DP141_REG_CHEN_LN_EN_CH2 SN65DP141_REG_CHEN_LN_EN_CH2_Msk /*!< Channel 2 enable */
#define SN65DP141_REG_CHEN_LN_EN_CH3_Pos (3U)
#define SN65DP141_REG_CHEN_LN_EN_CH3_Msk (0x1U << SN65DP141_REG_CHEN_LN_EN_CH3_Pos) /*!< 0x08 */
#define SN65DP141_REG_CHEN_LN_EN_CH3 SN65DP141_REG_CHEN_LN_EN_CH3_Msk /*!< Channel 3 enable */
/*********** Bit definition for Channel x Control Settings register *************/
#define SN65DP141_REG_CHxCFG_RX_GAIN_Pos (0U)
#define SN65DP141_REG_CHxCFG_RX_GAIN_Msk (0x3U << SN65DP141_REG_CHxCFG_RX_GAIN_Pos) /*!< 0x03 */
#define SN65DP141_REG_CHxCFG_RX_GAIN SN65DP141_REG_CHxCFG_RX_GAIN_Msk /*!< Channel[x] RX_GAIN control */
#define SN65DP141_REG_CHxCFG_RX_GAIN_0 (0x1U << SN65DP141_REG_CHxCFG_RX_GAIN_Pos) /*!< 0x01 */
#define SN65DP141_REG_CHxCFG_RX_GAIN_1 (0x2U << SN65DP141_REG_CHxCFG_RX_GAIN_Pos) /*!< 0x02 */
#define SN65DP141_REG_CHxCFG_EQ_DC_GAIN_Pos (2U)
#define SN65DP141_REG_CHxCFG_EQ_DC_GAIN_Msk (0x1U << SN65DP141_REG_CHxCFG_EQ_DC_GAIN_Pos) /*!< 0x04 */
#define SN65DP141_REG_CHxCFG_EQ_DC_GAIN SN65DP141_REG_CHxCFG_EQ_DC_GAIN_Msk /*!< Channel[x] EQ DC gain */
#define SN65DP141_REG_CHxCFG_TX_GAIN_Pos (3U)
#define SN65DP141_REG_CHxCFG_TX_GAIN_Msk (0x1U << SN65DP141_REG_CHxCFG_TX_GAIN_Pos) /*!< 0x08 */
#define SN65DP141_REG_CHxCFG_TX_GAIN SN65DP141_REG_CHxCFG_TX_GAIN_Msk /*!< Channel[x] TX_DC_GAIN control */
#define SN65DP141_REG_CHxCFG_EQ_SETTING_Pos (4U)
#define SN65DP141_REG_CHxCFG_EQ_SETTING_Msk (0x7U << SN65DP141_REG_CHxCFG_EQ_SETTING_Pos) /*!< 0x70 */
#define SN65DP141_REG_CHxCFG_EQ_SETTING SN65DP141_REG_CHxCFG_EQ_SETTING_Msk /*!< Channel[x] TX_DC_GAIN control */
#define SN65DP141_REG_CHxCFG_EQ_SETTING_0 (0x1U << SN65DP141_REG_CHxCFG_EQ_SETTING_Pos) /*!< 0x10 */
#define SN65DP141_REG_CHxCFG_EQ_SETTING_1 (0x2U << SN65DP141_REG_CHxCFG_EQ_SETTING_Pos) /*!< 0x20 */
#define SN65DP141_REG_CHxCFG_EQ_SETTING_2 (0x4U << SN65DP141_REG_CHxCFG_EQ_SETTING_Pos) /*!< 0x40 */
/*********** Bit definition for Channel x Enable Settings register *************/
#define SN65DP141_REG_CHxCTL_DRV_EN_Pos (0U)
#define SN65DP141_REG_CHxCTL_DRV_EN_Msk (0x1U << SN65DP141_REG_CHxCTL_DRV_EN_Pos) /*!< 0x01 */
#define SN65DP141_REG_CHxCTL_DRV_EN SN65DP141_REG_CHxCTL_DRV_EN_Msk /*!< Channel[0] driver stage enable */
#define SN65DP141_REG_CHxCTL_EQ_EN_Pos (1U)
#define SN65DP141_REG_CHxCTL_EQ_EN_Msk (0x1U << SN65DP141_REG_CHxCTL_EQ_EN_Pos) /*!< 0x02 */
#define SN65DP141_REG_CHxCTL_EQ_EN SN65DP141_REG_CHxCTL_EQ_EN_Msk /*!< Channel[0] EQ stage enable */
#define SN65DP141_REG_CHxCTL_DRV_PEAK_Pos (2U)
#define SN65DP141_REG_CHxCTL_DRV_PEAK_Msk (0x1U << SN65DP141_REG_CHxCTL_DRV_PEAK_Pos) /*!< 0x04 */
#define SN65DP141_REG_CHxCTL_DRV_PEAK SN65DP141_REG_CHxCTL_DRV_PEAK_Msk /*!< Channel[0] driver peaking */
/** @defgroup SN65DP141_Channel_Identifier
* @{
*/
#define SN65DP141_CHANNEL_1 0x00U
#define SN65DP141_CHANNEL_2 0x01U
#define SN65DP141_CHANNEL_3 0x04U
#define SN65DP141_CHANNEL_4 0x08U
#define SN65DP141_CHANNEL_ALL 0x0FU
/**
* @}
*/
/** @defgroup SN65DP141_EQ_Mode
* @{
*/
#define SN65DP141_EQ_MODE_CABLE 0x00U
#define SN65DP141_EQ_MODE_TRACE SN65DP141_REG_CFG_EQ_MODE
/**
* @}
*/
/** @defgroup SN65DP141_Channel_Tracking
* @{
*/
#define SN65DP141_CHANNEL_TRACKING_NONE 0x00U
#define SN65DP141_CHANNEL_TRACKING_01 SN65DP141_REG_CFG_SYNC_01
#define SN65DP141_CHANNEL_TRACKING_23 SN65DP141_REG_CFG_SYNC_23
#define SN65DP141_CHANNEL_TRACKING_ALL SN65DP141_REG_CFG_SYNC_ALL
/**
* @}
*/
/** @defgroup SN65DP141_EQGAIN SN65DP141 Equalizer Gain
* @{
*/
#define SN65DP141_EQGAIN_0 0x0U
#define SN65DP141_EQGAIN_1 0x1U
#define SN65DP141_EQGAIN_2 0x2U
#define SN65DP141_EQGAIN_3 0x3U
#define SN65DP141_EQGAIN_4 0x4U
#define SN65DP141_EQGAIN_5 0x5U
#define SN65DP141_EQGAIN_6 0x6U
#define SN65DP141_EQGAIN_7 0x7U
/**
* @}
*/
/** @defgroup SN65DP141_Channel_RXGAIN
* @{
*/
#define SN65DP141_CHANNEL_RXGAIN_LOW 0x00U
#define SN65DP141_CHANNEL_RXGAIN_HIZ SN65DP141_REG_CHxCFG_RX_GAIN_0
#define SN65DP141_CHANNEL_RXGAIN_HIGH SN65DP141_REG_CHxCFG_RX_GAIN_1
/**
* @}
*/
/** @defgroup SN65DP141_Channel_EQDCGAIN
* @{
*/
#define SN65DP141_CHANNEL_EQDCGAIN_MINUS6DB 0x00U
#define SN65DP141_CHANNEL_EQDCGAIN_0DB SN65DP141_REG_CHxCFG_EQ_DC_GAIN
/**
* @}
*/
/** @defgroup SN65DP141_Channel_TXGAIN
* @{
*/
#define SN65DP141_CHANNEL_RXGAIN_0DB 0x00U
#define SN65DP141_CHANNEL_RXGAIN_6DB SN65DP141_REG_CHxCFG_TX_GAIN
/**
* @}
*/
/**
* @}
*/
#if defined(SN65DP141_DEBUG)
/** @defgroup SN65DP141_Exported_Structure SN65DP141 Exported Structure
* @{
*/
typedef union {
uint8_t Register;
struct {
uint8_t RESERVED :2;
uint8_t EQ_MODE :1;
uint8_t SYNC_ALL :1;
uint8_t SYNC_23 :1;
uint8_t SYNC_01 :1;
uint8_t PWRDOWN :1;
uint8_t SW_GPIO :1;
};
} SN65DP141_GeneralTypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t LN_EN_CH0 :1;
uint8_t LN_EN_CH1 :1;
uint8_t LN_EN_CH2 :1;
uint8_t LN_EN_CH3 :1;
uint8_t RESERVED :4;
};
} SN65DP141_ChannelEnableTypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t RX_GAIN_0 :1;
uint8_t RX_GAIN_1 :1;
uint8_t EQ_DC_GAIN :1;
uint8_t TX_GAIN :1;
uint8_t EQ_Setting_0 :1;
uint8_t EQ_Setting_1 :1;
uint8_t EQ_Setting_2 :1;
uint8_t RESERVED :1;
};
} SN65DP141_Channel0CtrlTypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t RSVDRV_EN :1;
uint8_t EQ_EN :1;
uint8_t DRV_PEAK :1;
uint8_t RESERVED :5;
};
} SN65DP141_Channel0EnableTypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t RX_GAIN_0 :1;
uint8_t RX_GAIN_1 :1;
uint8_t EQ_DC_GAIN :1;
uint8_t TX_GAIN :1;
uint8_t EQ_Setting_0 :1;
uint8_t EQ_Setting_1 :1;
uint8_t EQ_Setting_2 :1;
uint8_t RESERVED :1;
};
} SN65DP141_Channel1CtrlTypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t RSVDRV_EN :1;
uint8_t EQ_EN :1;
uint8_t DRV_PEAK :1;
uint8_t RESERVED :5;
};
} SN65DP141_Channel1EnableTypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t RX_GAIN_0 :1;
uint8_t RX_GAIN_1 :1;
uint8_t EQ_DC_GAIN :1;
uint8_t TX_GAIN :1;
uint8_t EQ_Setting_0 :1;
uint8_t EQ_Setting_1 :1;
uint8_t EQ_Setting_2 :1;
uint8_t RESERVED :1;
};
} SN65DP141_Channel2CtrlTypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t RSVDRV_EN :1;
uint8_t EQ_EN :1;
uint8_t DRV_PEAK :1;
uint8_t RESERVED :5;
};
} SN65DP141_Channel2EnableTypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t RX_GAIN_0 :1;
uint8_t RX_GAIN_1 :1;
uint8_t EQ_DC_GAIN :1;
uint8_t TX_GAIN :1;
uint8_t EQ_Setting_0 :1;
uint8_t EQ_Setting_1 :1;
uint8_t EQ_Setting_2 :1;
uint8_t RESERVED :1;
};
} SN65DP141_Channel3CtrlTypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t RSVDRV_EN :1;
uint8_t EQ_EN :1;
uint8_t DRV_PEAK :1;
uint8_t RESERVED :5;
};
} SN65DP141_Channel3EnableTypeDef;
typedef struct
{
SN65DP141_GeneralTypeDef General; /*!< 0x00 (General Device Settings) */
SN65DP141_ChannelEnableTypeDef ChannelEnable; /*!< 0x01 (Channel Enable) */
SN65DP141_Channel0CtrlTypeDef Channel0Ctrl; /*!< 0x02 (Channel 0 Control Settings) */
SN65DP141_Channel0EnableTypeDef Channel0Enable; /*!< 0x03 (Channel 0 Enable Settings) */
SN65DP141_Channel1CtrlTypeDef Channel1Ctrl; /*!< 0x05 (Channel 1 Control Settings) */
SN65DP141_Channel1EnableTypeDef Channel1Enable; /*!< 0x06 (Channel 1 Enable Settings) */
SN65DP141_Channel2CtrlTypeDef Channel2Ctrl; /*!< 0x08 (Channel 2 Control Settings) */
SN65DP141_Channel2EnableTypeDef Channel2Enable; /*!< 0x09 (Channel 2 Enable Settings) */
SN65DP141_Channel3CtrlTypeDef Channel3Ctrl; /*!< 0x0B (Channel 3 Control Settings) */
SN65DP141_Channel3EnableTypeDef Channel3Enable; /*!< 0x0C (Channel 3 Enable Settings) */
} SN65DP141_RegistersTypeDef;
/**
* @}
*/
#endif /* SN65DP141_DEBUG */
/** @defgroup SN65DP141_Exported_Functions
* @{
*/
uint32_t sn65dp141_Init(uint16_t Address);
void sn65dp141_DeInit(uint16_t Address);
uint32_t sn65dp141_PowerOn(uint16_t Address);
uint32_t sn65dp141_PowerOff(uint16_t Address);
uint32_t sn65dp141_SetEQGain(uint16_t Address, DPREDRIVER_ChannelId_t ChannelId, uint8_t EQGain);
uint32_t sn65dp141_EnableChannel(uint16_t Address, DPREDRIVER_ChannelId_t ChannelId);
uint32_t sn65dp141_DisableChannel(uint16_t Address, DPREDRIVER_ChannelId_t ChannelId);
/* MUX IO functions */
uint8_t MUX_IO_Init(void);
void MUX_IO_DeInit(void);
uint8_t MUX_IO_Write(uint16_t Addr, uint16_t Reg, uint8_t Data);
uint8_t MUX_IO_Read(uint16_t Addr, uint16_t Reg, uint8_t *pData);
uint32_t MUX_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials);
/**
* @}
*/
/** @defgroup SN65DP141_Exported_Variables
* @{
*/
/* DisplayPort Linear Redriver Driver structure */
extern DPREDRIVER_Drv_t sn65dp141_drv;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* SN65DP141_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,260 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head>
<script><endnote><head>
<script><endnote><head>
<script><endnote><head>
<script><endnote><head>
<script><endnote><head>
<script></script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="File-List" href="Release_Notes_files/filelist.xml">
<link rel="Edit-Time-Data" href="Release_Notes_files/editdata.mso"><title>Release Notes for STLM75 Component Drivers</title>
<style>
div.Section1 {
page: Section1;
font-family: Arial,Helvetica,sans-serif;
}
h1 {
font-size: 24pt;
font-weight: bold;
font-family: Arial,Helvetica,sans-serif;
text-align: center;
color: #3366ff;
}
h2 {
margin: 12pt 0in 3pt;
page-break-after: avoid;elease Notes for RK043FN48H-CT672B LCD Component Driver
font-weight: bold;
font-family: Arial,Helvetica,sans-serif;
background-color: #3366ff;
color: white;
padding-left: 5px;
font-size: 16pt;
}
h3 {
margin-left: 0in;
font-weight: bold;
font-family: Arial,Helvetica,sans-serif;
background-color: #3366ff;
width: 200px;
margin-right: 500pt;
color: white;
padding-left: 5px;
padding-top: 2px;
padding-bottom: 2px;
font-size: 12pt;
}
h4 {
font-family: Arial,Helvetica,sans-serif;
font-weight: bold;
text-decoration: underline;
font-size: 12pt;
}
p {
margin: 0px 0px 0px 0in;
font-family: Arial,Helvetica,sans-serif;
padding-top: 3px;
padding-bottom: 3px;
font-size: 12pt;
}
ul {
font-family: Arial,Helvetica,sans-serif;
margin-top: 3px;
margin-bottom: 3px;
font-size: 10pt;
}
caption {
margin-top: 10px;
font-family: Arial,Helvetica,sans-serif;
font-size: 11pt;
}
hr {
width: 100%;
}
.guidance {
background-color: #e5b8b7;
font-style: italic;
font-family: Arial,Helvetica,sans-serif;
padding-top: 3px;
padding-bottom: 3px;
margin-top: 3px;
margin-bottom: 3px;
font-size: 10pt;
}
.guidance_title {
font-style: normal;
font-weight: bold;
text-decoration: underline;
font-family: Arial,Helvetica,sans-serif;
font-size: 10pt;
}
.tickets {
border: 1pt solid #9cc2e5;
font-family: Arial,Helvetica,sans-serif;
margin-bottom: 3px;
margin-top: 3px;
font-size: 10pt;
}
.tickets th {
border: 1pt solid #9cc2e5;
font-size: 12pt;
background-color: #39a9dc;
color: white;
text-align: center;
}
.tickets td {
border: 1pt solid #9cc2e5;
min-height: 32px;
}
tr:nth-child(even) {background-color: #cee2f2;}
tr:nth-child(even) {background-color: #e8f1f9;}
.topic1 {
margin-top: 3px;
margin-bottom: 3px;
margin-left: 40px;
}
.topic2 {
margin-top: 3px;
margin-bottom: 3px;
}
.topic3 {
margin-top: 3px;
margin-bottom: 3px;
margin-left: 20px;
}
#purpose {
margin-top: 3px;
margin-bottom: 3px;
}
#identification {
margin-top: 3px;
margin-bottom: 3px;
}
</style><!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><!--[if gte mso 9]><xml> <o:DocumentProperties> <o:Author>STMicroelectronics</o:Author> <o:LastAuthor>Raouf Hosni</o:LastAuthor> <o:Revision>69</o:Revision> <o:TotalTime>153</o:TotalTime> <o:Created>2009-02-27T19:26:00Z</o:Created> <o:LastSaved>2009-07-21T16:16:00Z</o:LastSaved> <o:Pages>1</o:Pages> <o:Words>410</o:Words> <o:Characters>2339</o:Characters> <o:Company>STMicroelectronics</o:Company> <o:Lines>19</o:Lines> <o:Paragraphs>5</o:Paragraphs> <o:CharactersWithSpaces>2744</o:CharactersWithSpaces> <o:Version>11.8132</o:Version> </o:DocumentProperties> </xml><![endif]--><!--[if gte mso 9]><xml> <w:WordDocument> <w:Zoom>110</w:Zoom> <w:SpellingState>Clean</w:SpellingState> <w:GrammarState>Clean</w:GrammarState> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--><!--[if gte mso 9]><xml> <o:shapedefaults v:ext="edit" spidmax="6146"/> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext="edit"> <o:idmap v:ext="edit" data="1"/> </o:shapelayout></xml><![endif]-->
</head>
<body link="blue" vlink="blue">
<script type="text/javascript">
var toggle_hist_disp = true;
function toggle_history()
{
if (toggle_hist_disp)
{
toggle_hist_disp = false;
var filter_off_text = document.createTextNode("Hide History");
document.getElementById('filter_hist').innerHTML = "";
document.getElementById('filter_hist').appendChild(filter_off_text);
document.getElementById("history").hidden = false;
}
else
{
toggle_hist_disp = true;
var filter_on_text = document.createTextNode("Show History");
document.getElementById('filter_hist').innerHTML = "";
document.getElementById('filter_hist').appendChild(filter_on_text);
document.getElementById("history").hidden = true;
}
}</script>
<div style="width: 1034px;" class="Section1"><span style="font-size: 8pt; font-family: &quot;Arial&quot;,&quot;sans-serif&quot;; color: blue;"></span><small><a href="../../../../Release_Notes.html">Back to Release page</a></small>
<div id="header">
<h1 style="margin-bottom: 18pt; text-align: center;" align="center">Release
Notes for&nbsp;<span style="font-size: 20pt; font-family: Verdana; color: rgb(51, 102, 255);">STLM75
Component Drivers</span></h1>
<p style="text-align: center;">Copyright 2014
STMicroelectronics</p>
<p style="text-align: center;"><span style="font-size: 10pt; font-family: &quot;Arial&quot;,&quot;sans-serif&quot;; color: black;"><img style="border: 0px solid ; width: 112px; height: 83px;" alt="" id="_x0000_i1026" src="../../../../_htmresc/st_logo.png"></span></p>
</div>
<div id="license" class="topic1">
<h2>License</h2>
This software component is licensed by ST under BSD 3-Clause
license, the "License"; You may not use this component except in
compliance with
the License. You may obtain a copy of the License at:
<p style="text-align: center;"><a href="https://opensource.org/licenses/BSD-3-Clause" target="_blank">https://opensource.org/licenses/BSD-3-Clause</a></p>
</div>
<br>
<div id="release_container" class="topic1">
<div class="topic2" id="identification">
<h3 style="width: 220px;">V2.0.2 / 17-December-2018</h3>
</div>
<div class="topic3" id="changes">
<p class="MsoNormal" style="margin-top: 4.5pt; margin-right: 0cm; margin-bottom: 4.5pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main
Changes<o:p></o:p></span></u></b></p>
<ul style="margin-top: 0cm;" type="square">
<li class="MsoNormal"><span style="font-size: 10pt; font-family: Verdana;">Fix "Back to
Release page" link</span></li>
</ul>
</div>
<br>
</div>
<div style="margin-left: 40px;"><button id="filter_hist" onclick="toggle_history()">Show
History</button><br>
</div>
<div id="history" class="topic1" hidden="">
<h2>Update History</h2>
<b><u><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: black;"><br>
</span></u></b>
<h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 223px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.0.1
/ 25-October-2018 <o:p></o:p></span></h3>
<p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main
Changes<o:p></o:p></span></u></b></p>
<span style="font-size: 10pt; font-family: Verdana;"></span>
<span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span>
<span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span>
<ul style="list-style-type: square;">
<li class="MsoNormal"><span style="font-size: 10pt; font-family: Verdana;">Fix
compilation warning in STLM75_Init() with IAR V8.30.1</span></li>
<li class="MsoNormal"><span style="font-size: 10pt; font-family: Verdana;">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)</span></li>
</ul>
<h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 223px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V2.0.0
/ 11-September-2017 <o:p></o:p></span></h3>
<p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main
Changes<o:p></o:p></span></u></b></p>
<span style="font-size: 10pt; font-family: Verdana;"></span>
<span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span>
<span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span>
<ul style="list-style-type: square;">
<li><span style="font-family: Verdana; font-size: 10pt;">Update
STLM75_ReadTemp return float instead of uint16_t</span><span style="font-family: Verdana; font-size: 10pt;"></span></li>
<li><span style="font-family: Verdana; font-size: 10pt;">Remove
date &amp; version from header</span></li>
</ul>
<h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 223px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V1.0.1
/ 24-November-2014 <o:p></o:p></span></h3>
<p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main
Changes<o:p></o:p></span></u></b></p>
<span style="font-size: 10pt; font-family: Verdana;"></span>
<span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span>
<span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span>
<ul style="list-style-type: square;">
<li><span style="font-family: Verdana; font-size: 10pt;">stlm75.h:
change&nbsp;</span><span style="font-family: Verdana; font-size: 10pt;">"\"
by&nbsp;</span><span style="font-family: Verdana; font-size: 10pt;">"/" in the
include path to fix compilation issue under Linux</span></li>
</ul>
<h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V1.0.0
/ 06-May-2014 <o:p></o:p></span></h3>
<p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main
Changes<o:p></o:p></span></u></b></p>
<span style="font-size: 10pt; font-family: Verdana;"></span>
<span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span>
<span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span>
<ul style="list-style-type: square;">
<li><span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;">First
official release of STLM75 Temperature Sensor Component driver</span></li>
</ul>
<span style="font-size: 10pt; font-family: Verdana;"></span>
<ul>
</ul>
</div>
<div id="product_doc" class="topic1">
<hr>
<p style="text-align: center;">For complete
documentation on STM32 Microcontrollers<span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;; color: black;"></span><span style="font-size: 10pt; font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;"><span style="color: black;"></span></span>,
visit:&nbsp;<a href="http://www.st.com/STM32" target="_blank">www.st.com/STM32</a></p>
<br>
</div>
</div>
</body></html>

View file

@ -0,0 +1,180 @@
/**
******************************************************************************
* @file stlm75.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the STLM75
* Temperature Sensor.
******************************************************************************
* @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 "stlm75.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @defgroup STLM75
* @brief This file provides a set of functions needed to drive the
* STLM75 Temperature Sensor.
* @{
*/
/** @defgroup STLM75_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup STLM75_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup STLM75_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup STLM75_Private_Variables
* @{
*/
TSENSOR_DrvTypeDef Stlm75Drv =
{
STLM75_Init,
STLM75_IsReady,
STLM75_ReadStatus,
STLM75_ReadTemp,
};
/**
* @}
*/
/** @defgroup STLM75_Private_FunctionPrototypes
* @{
*/
/**
* @}
*/
/** @defgroup STLM75_Private_Functions
* @{
*/
/**
* @brief Set STLM75 Initialization.
* @param DeviceAddr : Device ID address.
* @param pInitStruct: pointer to a STLM75_InitTypeDef structure
* that contains the configuration setting for the STLM75.
* @retval None
*/
void STLM75_Init(uint16_t DeviceAddr, TSENSOR_InitTypeDef *pInitStruct)
{
uint8_t confreg = 0;
uint16_t tempreg = 0;
/* Set the Configuration Register */
confreg = (uint8_t)(pInitStruct->AlertMode | pInitStruct->ConversionMode);
TSENSOR_IO_Write(DeviceAddr, &confreg, LM75_REG_CONF, 1);
/* Set the Temperature Registers */
/* Keep the sign bit and shift the temperature value (as given value is integer, the 0.5 digit is not set) */
tempreg = (((pInitStruct->TemperatureLimitHigh & 0x7F) << 8) | (pInitStruct->TemperatureLimitHigh & 0x80));
TSENSOR_IO_Write(DeviceAddr, (uint8_t*)(&tempreg), LM75_REG_TOS, 2);
tempreg = (((pInitStruct->TemperatureLimitLow & 0x7F) << 8) | (pInitStruct->TemperatureLimitLow & 0x80));
TSENSOR_IO_Write(DeviceAddr, (uint8_t*)(&tempreg), LM75_REG_THYS, 2);
}
/**
* @brief Check if STLM75 sensor is ready or not
* @param DeviceAddr : Device ID address.
* @param Trials: Number of trials
* @retval READY or NOT
*/
uint8_t STLM75_IsReady(uint16_t DeviceAddr, uint32_t Trials)
{
/* Configure the low level interface ---------------------------------------*/
TSENSOR_IO_Init();
/* Check is Temperature Sensor is Ready to use */
return TSENSOR_IO_IsDeviceReady(DeviceAddr, Trials);
}
/**
* @brief Read The Temperature Sensor Status
* @param DeviceAddr : Device ID address.
* @retval Status
*/
uint8_t STLM75_ReadStatus(uint16_t DeviceAddr)
{
uint8_t tmp = 0;
/* Read Status register */
TSENSOR_IO_Read(DeviceAddr, &tmp, LM75_REG_CONF, 1);
/* Return Temperature Sensor Status */
return (uint8_t)(tmp);
}
/**
* @brief Read temperature value of STLM75
* @param DeviceAddr: Device ID address
* @retval temperature value
*/
float STLM75_ReadTemp(uint16_t DeviceAddr)
{
uint16_t tempreg = 0;
uint16_t tmp = 0;
/* Read Temperature registers */
TSENSOR_IO_Read(DeviceAddr, (uint8_t*)(&tempreg), LM75_REG_TEMP, 2);
tmp = ((tempreg & 0x00FF) << 8) | ((tempreg & 0xFF00) >> 8);
tempreg = (((tmp & 0x7F80) >> 7) | (tmp & 0x8000));
/* Return Temperature value */
return (float)tempreg;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,126 @@
/**
******************************************************************************
* @file stlm75.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the stlm75.c
* temperature sensor 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 __STLM75_H
#define __STLM75_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/tsensor.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup STLM75
* @{
*/
/** @defgroup STLM75_Exported_Constants
* @{
*/
/******************************************************************************/
/*************************** START REGISTER MAPPING **************************/
/******************************************************************************/
/***************************** Read Access Only *******************************/
#define LM75_REG_TEMP 0x00 /*!< Temperature Register of LM75 */
/***************************** Read/Write Access ******************************/
#define LM75_REG_CONF 0x01 /*!< Configuration Register of LM75 */
#define LM75_REG_THYS 0x02 /*!< Temperature Register of LM75 */
#define LM75_REG_TOS 0x03 /*!< Over-temp Shutdown threshold Register of LM75 */
/******************************************************************************/
/**************************** END REGISTER MAPPING ***************************/
/******************************************************************************/
/** @defgroup Conversion_Mode_Selection
* @{
*/
#define STLM75_CONTINUOUS_MODE ((uint8_t)0x00)
#define STLM75_ONE_SHOT_MODE ((uint8_t)0x01)
/**
* @}
*/
/** @defgroup Operation_Mode
* @{
*/
#define STLM75_COMPARATOR_MODE ((uint8_t)0x00)
#define STLM75_INTERRUPT_MODE ((uint8_t)0x02)
/**
* @}
*/
/**
* @}
*/
/** @defgroup STLM75_Exported_Functions
* @{
*/
/* Sensor Configuration Functions */
void STLM75_Init(uint16_t DeviceAddr, TSENSOR_InitTypeDef *pInitStruct);
uint8_t STLM75_IsReady(uint16_t DeviceAddr, uint32_t Trials);
/* Sensor Request Functions */
uint8_t STLM75_ReadStatus(uint16_t DeviceAddr);
float STLM75_ReadTemp(uint16_t DeviceAddr);
/* Temperature Sensor driver structure */
extern TSENSOR_DrvTypeDef Stlm75Drv;
/* Temperature Sensor IO functions */
void TSENSOR_IO_Init(void);
void TSENSOR_IO_Write(uint16_t DevAddress, uint8_t* pBuffer, uint8_t WriteAddr, uint16_t Length);
void TSENSOR_IO_Read(uint16_t DevAddress, uint8_t* pBuffer, uint8_t ReadAddr, uint16_t Length);
uint16_t TSENSOR_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __STTS751_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 TUSB546 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-tusb546-component-drivers"><small>Release Notes for</small> <mark>TUSB546 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 TUSB546 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-section3" checked aria-hidden="true"> <label for="collapse-section3" aria-hidden="true">V1.0.3 / 23-July-2020</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Correct misspelled words</li>
<li>Update Release Notes format</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section4" aria-hidden="true"> <label for="collapse-section4" aria-hidden="true">V1.0.2 / 10-October-2018</label>
<div>
<h2 id="main-changes-1">Main Changes</h2>
<ul>
<li>Fix compilation warnings detected by IAR V8.30.1</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section2" aria-hidden="true"> <label for="collapse-section2" aria-hidden="true">V1.0.1 / 16-March-2018</label>
<div>
<h2 id="main-changes-2">Main Changes</h2>
<ul>
<li>Correct compilation warnings detected by SW4STM32 gcc compiler</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section1" aria-hidden="true"> <label for="collapse-section1" aria-hidden="true">V1.0.0 / 16-November-2017</label>
<div>
<h2 id="main-changes-3">Main Changes</h2>
<ul>
<li>First official release of TUSB546 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,533 @@
/**
******************************************************************************
* @file tusb546.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the TUSB546
* (USB Type-C DP ALT Mode Linear Redriver Crosspoint Switch).
******************************************************************************
* @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 "tusb546.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @defgroup TUSB546
* @brief This file provides a set of functions needed to drive the
* TUSB546 USB Type-C DP ALT Mode Linear Redriver Crosspoint Switch.
* @{
*/
/** @defgroup TUSB546_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup TUSB546_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup TUSB546_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup TUSB546_Private_Variables
* @{
*/
/* Type-C Crosspoint Switch Driver structure initialization */
TYPECSWITCH_Drv_t tusb546_drv_CrossSwitch =
{
tusb546_CrossSwitch_Init,
tusb546_CrossSwitch_DeInit,
tusb546_CrossSwitch_PowerOn,
tusb546_CrossSwitch_PowerOff,
tusb546_CrossSwitch_SetMode,
tusb546_CrossSwitch_IsSupportedMode
};
/* DisplayPort Linear Redriver driver structure initialization*/
DPREDRIVER_Drv_t tusb546_drv_LinearRedriver =
{
tusb546_DPRedriver_Init,
tusb546_DPRedriver_DeInit,
tusb546_DPRedriver_PowerOn,
tusb546_DPRedriver_PowerOff,
tusb546_DPRedriver_SetEQGain,
tusb546_DPRedriver_EnableChannel,
tusb546_DPRedriver_DisableChannel
};
/* Supported USB Type-C pin assignments */
static const uint32_t tusb546_SupportedModes =
( 1 << USB_NORMAL |
1 << USB_FLIPPED |
1 << DFP_D_PIN_ASSIGNMENT_C_NORMAL |
1 << DFP_D_PIN_ASSIGNMENT_C_FLIPPED |
1 << DFP_D_PIN_ASSIGNMENT_D_NORMAL |
1 << DFP_D_PIN_ASSIGNMENT_D_FLIPPED |
1 << DFP_D_PIN_ASSIGNMENT_E_NORMAL |
1 << DFP_D_PIN_ASSIGNMENT_E_FLIPPED |
1 << DFP_D_PIN_ASSIGNMENT_F_NORMAL |
1 << DFP_D_PIN_ASSIGNMENT_F_FLIPPED );
static uint8_t tusb546_IsInitialized_CrossSwitch = 0;
static uint8_t tusb546_IsInitialized_DPRedriver = 0;
/**
* @}
*/
/** @defgroup TUSB546_Private_FunctionPrototypes
* @{
*/
/**
* @}
*/
/** @defgroup TUSB546_Private_Functions
* @{
*/
/**
* @brief Initialize the TUSB546 and configure the needed hardware resources
* (Type-C cross switch part).
* @param Address TUSB546 address on communication Bus.
* @retval 0: successful, else failed
*/
uint32_t tusb546_CrossSwitch_Init(uint16_t Address)
{
uint32_t err_count = 0;
tusb546_IsInitialized_CrossSwitch = 1;
if (!tusb546_IsInitialized_DPRedriver)
{
/* Low level init */
err_count += MUX_IO_Init();
/* Restore TUSB546 registers reset values */
err_count += MUX_IO_Write(Address, TUSB546_REG_CTRL, 0x01);
err_count += MUX_IO_Write(Address, TUSB546_REG_DP_CTRL1, 0x00);
err_count += MUX_IO_Write(Address, TUSB546_REG_DP_CTRL2, 0x00);
err_count += MUX_IO_Write(Address, TUSB546_REG_DP_CTRL4, 0x00);
err_count += MUX_IO_Write(Address, TUSB546_REG_USB3_CTRL1, 0x00);
err_count += MUX_IO_Write(Address, TUSB546_REG_USB3_CTRL2, 0x00);
err_count += MUX_IO_Write(Address, TUSB546_REG_USB3_CTRL3, 0x00);
}
return err_count;
}
/**
* @brief Release the hardware resources required to use the TUSB546
* (Type-C cross switch part).
* @param Address TUSB546 address on communication Bus.
* @retval none
*/
void tusb546_CrossSwitch_DeInit(uint16_t Address)
{
tusb546_IsInitialized_CrossSwitch = 0;
if ((!tusb546_IsInitialized_CrossSwitch) &&
(!tusb546_IsInitialized_DPRedriver))
{
/* Restore TUSB546 registers reset values */
MUX_IO_Write(Address, TUSB546_REG_CTRL, 0x01);
MUX_IO_Write(Address, TUSB546_REG_DP_CTRL1, 0x00);
MUX_IO_Write(Address, TUSB546_REG_DP_CTRL2, 0x00);
MUX_IO_Write(Address, TUSB546_REG_DP_CTRL4, 0x00);
MUX_IO_Write(Address, TUSB546_REG_USB3_CTRL1, 0x00);
MUX_IO_Write(Address, TUSB546_REG_USB3_CTRL2, 0x00);
MUX_IO_Write(Address, TUSB546_REG_USB3_CTRL3, 0x00);
/* Low level de-init */
MUX_IO_DeInit();
}
}
/**
* @brief Power on the TUSB546 (Type-C cross switch part).
* @param Address TUSB546 address on communication Bus.
* @retval 0: successful, else failed
*/
uint32_t tusb546_CrossSwitch_PowerOn(uint16_t Address)
{
uint32_t err_count = 0;
/* Enable USB3x port */
err_count += MUX_IO_Write(Address, TUSB546_REG_CTRL, TUSB546_REG_CTRL_CTLSEL_0);
return err_count;
}
/**
* @brief Power down the TUSB546 (Type-C cross switch part).
* @param Address TUSB546 address on communication Bus.
* @retval 0: successful, else failed
*/
uint32_t tusb546_CrossSwitch_PowerOff(uint16_t Address)
{
uint32_t err_count = 0;
/* All RX and TX for USB3 and DisplayPort are disabled */
err_count += MUX_IO_Write(Address, TUSB546_REG_CTRL, 0);
return err_count;
}
/**
* @brief Configure the TUSB546 according to the requested USB Type-C
* connector pin assignment.
* @param Address TUSB546 address on communication Bus.
* @param Mode USB Type-C connector pin assignment
* @retval 0: success, else error
*/
uint32_t tusb546_CrossSwitch_SetMode(uint16_t Address, TYPECSWITCH_Mode_t Mode)
{
uint32_t err_count = 0;
uint8_t flipsel;
uint8_t ctlsel;
uint8_t ctlreg;
switch(Mode)
{
case USB_NORMAL:
flipsel = 0;
ctlsel = TUSB546_REG_CTRL_CTLSEL_0;
break;
case USB_FLIPPED:
flipsel = TUSB546_REG_CTRL_FLIPSEL;
ctlsel = TUSB546_REG_CTRL_CTLSEL_0;
break;
case DFP_D_PIN_ASSIGNMENT_C_NORMAL:
case DFP_D_PIN_ASSIGNMENT_E_NORMAL:
flipsel = 0;
ctlsel = TUSB546_REG_CTRL_CTLSEL_1;
break;
case DFP_D_PIN_ASSIGNMENT_C_FLIPPED:
case DFP_D_PIN_ASSIGNMENT_E_FLIPPED:
flipsel = TUSB546_REG_CTRL_FLIPSEL;
ctlsel = TUSB546_REG_CTRL_CTLSEL_1;
break;
case DFP_D_PIN_ASSIGNMENT_D_NORMAL:
case DFP_D_PIN_ASSIGNMENT_F_NORMAL:
flipsel = 0;
ctlsel = TUSB546_REG_CTRL_CTLSEL;
break;
case DFP_D_PIN_ASSIGNMENT_D_FLIPPED:
case DFP_D_PIN_ASSIGNMENT_F_FLIPPED:
flipsel = TUSB546_REG_CTRL_FLIPSEL;
ctlsel = TUSB546_REG_CTRL_CTLSEL;
break;
default:
flipsel = 0;
ctlsel = 0;
break;
}
/* Get actual device configuration */
err_count += MUX_IO_Read(Address, TUSB546_REG_CTRL, &ctlreg);
ctlreg = (ctlreg & ~(uint8_t)(TUSB546_REG_CTRL_FLIPSEL | TUSB546_REG_CTRL_CTLSEL)) | (flipsel | ctlsel);
/* Update device configuration */
err_count += MUX_IO_Write(Address, TUSB546_REG_CTRL, ctlreg);
return err_count;
}
/**
* @brief Indicate whether the requested USB Type-C connector pin assignment
* is supported by the TUSB546.
* @param Mode USB Type-C connector pin assignment
* @retval 1: Mode supported, else Mode not supported
*/
uint32_t tusb546_CrossSwitch_IsSupportedMode(TYPECSWITCH_Mode_t Mode)
{
return (((1 << Mode) & tusb546_SupportedModes ) == 0) ? 0 : 1;
}
/**
* @brief Initialize the TUSB546 and configure the needed hardware resources
* (DisplayPort linear redriver part).
* @param Address TUSB546 address on communication Bus.
* @retval 0: successful, else failed
*/
uint32_t tusb546_DPRedriver_Init(uint16_t Address)
{
uint32_t err_count = 0;
tusb546_IsInitialized_DPRedriver = 1;
if (!tusb546_IsInitialized_CrossSwitch)
{
/* Low level init */
err_count += MUX_IO_Init();
}
return err_count;
}
/**
* @brief Release the hardware resources required to use the TUSB546
* (DisplayPort linear redriver part).
* @param Address TUSB546 address on communication Bus.
* @retval none
*/
void tusb546_DPRedriver_DeInit(uint16_t Address)
{
tusb546_IsInitialized_DPRedriver = 0;
if ((!tusb546_IsInitialized_CrossSwitch) &&
(!tusb546_IsInitialized_DPRedriver))
{
/* Restore TUSB546 registers reset values */
MUX_IO_Write(Address, TUSB546_REG_CTRL, 0x01);
MUX_IO_Write(Address, TUSB546_REG_DP_CTRL1, 0x00);
MUX_IO_Write(Address, TUSB546_REG_DP_CTRL2, 0x00);
MUX_IO_Write(Address, TUSB546_REG_DP_CTRL4, 0x00);
MUX_IO_Write(Address, TUSB546_REG_USB3_CTRL1, 0x00);
MUX_IO_Write(Address, TUSB546_REG_USB3_CTRL2, 0x00);
MUX_IO_Write(Address, TUSB546_REG_USB3_CTRL3, 0x00);
/* Low level de-init */
MUX_IO_DeInit();
}
}
/**
* @brief Power on the TUSB546 (DisplayPort linear redriver part).
* @param Address TUSB546 address on communication Bus.
* @retval 0: successful, else failed
*/
uint32_t tusb546_DPRedriver_PowerOn(uint16_t Address)
{
return 0;
}
/**
* @brief Power down the TUSB546 (DisplayPort linear redriver part).
* @param Address TUSB546 address on communication Bus.
* @retval 0: successful, else failed
*/
uint32_t tusb546_DPRedriver_PowerOff(uint16_t Address)
{
return 0;
}
/**
* @brief Set the equalizer gain for a given channel.
* @param Address TUSB546 address on communication Bus.
* @param ChannelId Channel identifier.
* This parameter can be take one of the following values:
* CHANNEL_DP0
* CHANNEL_DP1
* CHANNEL_DP2
* CHANNEL_DP3
* CHANNEL_RX1
* CHANNEL_RX2
* CHANNEL_SSTX
* @param EQGain Equalizer gain.
* This parameter must be a value between 0x00 and 0x0F.
* @retval 0: successful, else failed
*/
uint32_t tusb546_DPRedriver_SetEQGain(uint16_t Address,
DPREDRIVER_ChannelId_t ChannelId,
uint8_t EQGain)
{
uint32_t err_count = 0;
uint8_t eqsel = 0;
uint8_t reg_offset = 0;
uint8_t ctlreg;
uint8_t mask = 0;
switch(ChannelId)
{
case CHANNEL_DP0:
reg_offset = TUSB546_REG_DP_CTRL1;
mask = TUSB546_REG_DP_CTRL1_DP0EQ_SEL_Msk;
eqsel = EQGain;
break;
case CHANNEL_DP1:
reg_offset = TUSB546_REG_DP_CTRL1;
mask = TUSB546_REG_DP_CTRL1_DP1EQ_SEL_Msk;
eqsel = (EQGain << TUSB546_REG_DP_CTRL1_DP1EQ_SEL_Pos);
break;
case CHANNEL_DP2:
reg_offset = TUSB546_REG_DP_CTRL2;
mask = TUSB546_REG_DP_CTRL2_DP2EQ_SEL_Msk;
eqsel = EQGain;
break;
case CHANNEL_DP3:
reg_offset = TUSB546_REG_DP_CTRL2;
mask = TUSB546_REG_DP_CTRL2_DP3EQ_SEL_Msk;
eqsel = (EQGain << TUSB546_REG_DP_CTRL2_DP3EQ_SEL_Pos);
break;
case CHANNEL_RX1:
reg_offset = TUSB546_REG_USB3_CTRL1;
mask = TUSB546_REG_USB3_CTRL1_EQ1_SEL_Msk;
eqsel = EQGain;
break;
case CHANNEL_RX2:
reg_offset = TUSB546_REG_USB3_CTRL1;
mask = TUSB546_REG_USB3_CTRL1_EQ2_SEL_Msk;
eqsel = (EQGain << TUSB546_REG_USB3_CTRL1_EQ2_SEL_Pos);
break;
case CHANNEL_SSTX:
reg_offset = TUSB546_REG_USB3_CTRL2;
mask = TUSB546_USB3_CTRL2_SSEQ_SEL_Msk;
eqsel = EQGain;
break;
}
if (reg_offset != 0)
{
/* Set EQ_OVERRIDE to use EQ settings from registers instead of value sample from pins */
err_count += MUX_IO_Write(Address, TUSB546_REG_CTRL, TUSB546_REG_CTRL_EQ_OVERRIDE);
/* Get actual EQ configuration */
err_count += MUX_IO_Read(Address, reg_offset, &ctlreg);
ctlreg = (ctlreg & ~(mask)) | eqsel;
/* Update EQ configuration */
err_count += MUX_IO_Write(Address, reg_offset, ctlreg);
}
return err_count;
}
/**
* @brief Enable a DP channel.
* @param Address TUSB546 address on communication Bus.
* @param ChannelId Channel identifier.
* This parameter can be take one of the following values:
* CHANNEL_DP0
* CHANNEL_DP1
* CHANNEL_DP2
* CHANNEL_DP3
* @retval 0: successful, else failed
*/
uint32_t tusb546_DPRedriver_EnableChannel(uint16_t Address,
DPREDRIVER_ChannelId_t ChannelId)
{
uint32_t err_count = 0;
uint8_t ctlreg;
err_count += MUX_IO_Read(Address, TUSB546_REG_DP_CTRL4, &ctlreg);
switch(ChannelId)
{
case CHANNEL_DP0:
ctlreg &= ~TUSB546_REG_DP_CTRL4_DP0_DISABLE;
break;
case CHANNEL_DP1:
ctlreg &= ~TUSB546_REG_DP_CTRL4_DP1_DISABLE;
break;
case CHANNEL_DP2:
ctlreg &= ~TUSB546_REG_DP_CTRL4_DP2_DISABLE;
break;
case CHANNEL_DP3:
ctlreg &= ~TUSB546_REG_DP_CTRL4_DP3_DISABLE;
break;
default:
/* Nothing to do */
break;
}
/* Enable the DP line */
err_count += MUX_IO_Write(Address, TUSB546_REG_DP_CTRL4, ctlreg);
return err_count;
}
/**
* @brief Disable a DP channel.
* @param Address TUSB546 address on communication Bus.
* @param ChannelId Channel identifier.
* This parameter can be take one of the following values:
* CHANNEL_DP0
* CHANNEL_DP1
* CHANNEL_DP2
* CHANNEL_DP3
* @retval 0: successful, else failed
*/
uint32_t tusb546_DPRedriver_DisableChannel(uint16_t Address,
DPREDRIVER_ChannelId_t ChannelId)
{
uint32_t err_count = 0;
uint8_t ctlreg;
err_count += MUX_IO_Read(Address, TUSB546_REG_DP_CTRL4, &ctlreg);
switch(ChannelId)
{
case CHANNEL_DP0:
ctlreg |= TUSB546_REG_DP_CTRL4_DP0_DISABLE;
break;
case CHANNEL_DP1:
ctlreg |= TUSB546_REG_DP_CTRL4_DP1_DISABLE;
break;
case CHANNEL_DP2:
ctlreg |= TUSB546_REG_DP_CTRL4_DP2_DISABLE;
break;
case CHANNEL_DP3:
ctlreg |= TUSB546_REG_DP_CTRL4_DP3_DISABLE;
break;
default:
/* Nothing to do */
break;
}
/* Disable the DP line */
err_count += MUX_IO_Write(Address, TUSB546_REG_DP_CTRL4, ctlreg);
return err_count;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,474 @@
/**
******************************************************************************
* @file tusb546.h
* @author MCD Application Team
* @brief Header for tusb546.h module
******************************************************************************
* @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 TUSB546_H
#define TUSB546_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
#include "../Common/usbtypecswitch.h"
#include "../Common/dpredriver.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup TUSB546
* @{
*/
/** @defgroup TUSB546_Exported_Constants
* @{
*/
/******************************* Register Map ********************************/
#define TUSB546_REG_CTRL 0x0A /*!< */
#define TUSB546_REG_DP_CTRL1 0x10 /*!< */
#define TUSB546_REG_DP_CTRL2 0x11 /*!< */
#define TUSB546_REG_DP_CTRL3 0x12 /*!< */
#define TUSB546_REG_DP_CTRL4 0x13 /*!< */
#define TUSB546_REG_USB3_CTRL1 0x20 /*!< */
#define TUSB546_REG_USB3_CTRL2 0x21 /*!< */
#define TUSB546_REG_USB3_CTRL3 0x22 /*!< */
/*********************** Bit definition for CTRL register *******************/
#define TUSB546_REG_CTRL_CTLSEL_Pos (0U)
#define TUSB546_REG_CTRL_CTLSEL_Msk (0x3U << TUSB546_REG_CTRL_CTLSEL_Pos) /*!< 0x03*/
#define TUSB546_REG_CTRL_CTLSEL TUSB546_REG_CTRL_CTLSEL_Msk /*!< DP Alt mode and USB 3.1 Switch Control */
#define TUSB546_REG_CTRL_CTLSEL_0 (0x1 << TUSB546_REG_CTRL_CTLSEL_Pos) /*!< 0x01 */
#define TUSB546_REG_CTRL_CTLSEL_1 (0x2 << TUSB546_REG_CTRL_CTLSEL_Pos) /*!< 0x02 */
#define TUSB546_REG_CTRL_FLIPSEL_Pos (2U)
#define TUSB546_REG_CTRL_FLIPSEL_Msk (0x1U << TUSB546_REG_CTRL_FLIPSEL_Pos) /*!< 0x04*/
#define TUSB546_REG_CTRL_FLIPSEL TUSB546_REG_CTRL_FLIPSEL_Msk /*!< Flip Control */
#define TUSB546_REG_CTRL_HPDIN_OVERRIDE_Pos (3U)
#define TUSB546_REG_CTRL_HPDIN_OVERRIDE_Msk (0x1U << TUSB546_REG_CTRL_HPDIN_OVERRIDE_Pos) /*!< 0x08*/
#define TUSB546_REG_CTRL_HPDIN_OVERRIDE TUSB546_REG_CTRL_HPDIN_OVERRIDE_Msk /*!< HPDIN control */
#define TUSB546_REG_CTRL_EQ_OVERRIDE_Pos (4U)
#define TUSB546_REG_CTRL_EQ_OVERRIDE_Msk (0x1U << TUSB546_REG_CTRL_EQ_OVERRIDE_Pos) /*!< 0x10*/
#define TUSB546_REG_CTRL_EQ_OVERRIDE TUSB546_REG_CTRL_EQ_OVERRIDE_Msk /*!< EQ settings control */
#define TUSB546_REG_CTRL_SWAP_HPDIN_Pos (5U)
#define TUSB546_REG_CTRL_SWAP_HPDIN_Msk (0x1U << TUSB546_REG_CTRL_SWAP_HPDIN_Pos) /*!< 0x20*/
#define TUSB546_REG_CTRL_SWAP_HPDIN TUSB546_REG_CTRL_SWAP_HPDIN_Msk /*!< HPDIN pin control */
/********************* Bit definition for DP_CTRL1 register *****************/
#define TUSB546_REG_DP_CTRL1_DP0EQ_SEL_Pos (0U)
#define TUSB546_REG_DP_CTRL1_DP0EQ_SEL_Msk (0xFU << TUSB546_REG_DP_CTRL1_DP0EQ_SEL_Pos) /*!< 0x0F */
#define TUSB546_REG_DP_CTRL1_DP0EQ_SEL TUSB546_REG_DP_CTRL1_DP0EQ_SEL_Msk /*!< Field selects between 0 to 14dB of EQ for DP lane 0 */
#define TUSB546_REG_DP_CTRL1_DP0EQ_SEL_0 (0x1 << TUSB546_REG_DP_CTRL1_DP0EQ_SEL_Pos) /*!< 0x01 */
#define TUSB546_REG_DP_CTRL1_DP0EQ_SEL_1 (0x2 << TUSB546_REG_DP_CTRL1_DP0EQ_SEL_Pos) /*!< 0x02 */
#define TUSB546_REG_DP_CTRL1_DP0EQ_SEL_2 (0x4 << TUSB546_REG_DP_CTRL1_DP0EQ_SEL_Pos) /*!< 0x04 */
#define TUSB546_REG_DP_CTRL1_DP0EQ_SEL_4 (0x8 << TUSB546_REG_DP_CTRL1_DP0EQ_SEL_Pos) /*!< 0x08 */
#define TUSB546_REG_DP_CTRL1_DP1EQ_SEL_Pos (4U)
#define TUSB546_REG_DP_CTRL1_DP1EQ_SEL_Msk (0xFU << TUSB546_REG_DP_CTRL1_DP1EQ_SEL_Pos) /*!< 0xF0*/
#define TUSB546_REG_DP_CTRL1_DP1EQ_SEL TUSB546_REG_DP_CTRL1_DP1EQ_SEL_Msk /*!< Field selects between 0 to 14dB of EQ for DP lane 1 */
#define TUSB546_REG_DP_CTRL1_DP1EQ_SEL_0 (0x1 << TUSB546_REG_DP_CTRL1_DP1EQ_SEL_Pos) /*!< 0x10 */
#define TUSB546_REG_DP_CTRL1_DP1EQ_SEL_1 (0x2 << TUSB546_REG_DP_CTRL1_DP1EQ_SEL_Pos) /*!< 0x20 */
#define TUSB546_REG_DP_CTRL1_DP1EQ_SEL_2 (0x4 << TUSB546_REG_DP_CTRL1_DP1EQ_SEL_Pos) /*!< 0x40 */
#define TUSB546_REG_DP_CTRL1_DP1EQ_SEL_4 (0x8 << TUSB546_REG_DP_CTRL1_DP1EQ_SEL_Pos) /*!< 0x80 */
/********************* Bit definition for DP_CTRL2 register *****************/
#define TUSB546_REG_DP_CTRL2_DP2EQ_SEL_Pos (0U)
#define TUSB546_REG_DP_CTRL2_DP2EQ_SEL_Msk (0xFU << TUSB546_REG_DP_CTRL2_DP2EQ_SEL_Pos) /*!< 0x0F */
#define TUSB546_REG_DP_CTRL2_DP2EQ_SEL TUSB546_REG_DP_CTRL2_DP2EQ_SEL_Msk /*!< Field selects between 0 to 14dB of EQ for DP lane 2 */
#define TUSB546_REG_DP_CTRL1_DP2EQ_SEL_0 (0x1 << TUSB546_REG_DP_CTRL2_DP2EQ_SEL_Pos) /*!< 0x01 */
#define TUSB546_REG_DP_CTRL1_DP2EQ_SEL_1 (0x2 << TUSB546_REG_DP_CTRL2_DP2EQ_SEL_Pos) /*!< 0x02 */
#define TUSB546_REG_DP_CTRL1_DP2EQ_SEL_2 (0x4 << TUSB546_REG_DP_CTRL2_DP2EQ_SEL_Pos) /*!< 0x04 */
#define TUSB546_REG_DP_CTRL1_DP2EQ_SEL_4 (0x8 << TUSB546_REG_DP_CTRL2_DP2EQ_SEL_Pos) /*!< 0x08 */
#define TUSB546_REG_DP_CTRL2_DP3EQ_SEL_Pos (4U)
#define TUSB546_REG_DP_CTRL2_DP3EQ_SEL_Msk (0xFU << TUSB546_REG_DP_CTRL2_DP3EQ_SEL_Pos) /*!< 0xF0*/
#define TUSB546_REG_DP_CTRL2_DP3EQ_SEL TUSB546_REG_DP_CTRL2_DP3EQ_SEL_Msk /*!< Field selects between 0 to 14dB of EQ for DP lane 3 */
#define TUSB546_REG_DP_CTRL1_DP3EQ_SEL_0 (0x1 << TUSB546_REG_DP_CTRL2_DP3EQ_SEL_Pos) /*!< 0x10 */
#define TUSB546_REG_DP_CTRL1_DP3EQ_SEL_1 (0x2 << TUSB546_REG_DP_CTRL2_DP3EQ_SEL_Pos) /*!< 0x20 */
#define TUSB546_REG_DP_CTRL1_DP3EQ_SEL_2 (0x4 << TUSB546_REG_DP_CTRL2_DP3EQ_SEL_Pos) /*!< 0x40 */
#define TUSB546_REG_DP_CTRL1_DP3EQ_SEL_4 (0x8 << TUSB546_REG_DP_CTRL2_DP3EQ_SEL_Pos) /*!< 0x80 */
/********************* Bit definition for DP_CTRL3 register *****************/
#define TUSB546_REG_DP_CTRL3_LANE_COUNT_SET_Pos (0U)
#define TUSB546_REG_DP_CTRL3_LANE_COUNT_SET_Msk (0x1FU << TUSB546_REG_DP_CTRL3_LANE_COUNT_SET_Pos) /*!< 0x1F */
#define TUSB546_REG_DP_CTRL3_LANE_COUNT_SET TUSB546_REG_DP_CTRL3_LANE_COUNT_SET_Msk /*!< */
#define TUSB546_REG_DP_CTRL3_SET_POWER_STATE_Pos (5U)
#define TUSB546_REG_DP_CTRL3_SET_POWER_STATE_Msk (0x3U << TUSB546_REG_DP_CTRL3_SET_POWER_STATE5_Pos) /*!< 0x60 */
#define TUSB546_REG_DP_CTRL3_SET_POWER_STATE TUSB546_REG_DP_CTRL3_SET_POWER_STATE5_Msk /*!< */
#define TUSB546_REG_DP_CTRL3_SET_POWER_STATE_0 (0x1 << TUSB546_REG_DP_CTRL3_SET_POWER_STATE_Pos) /*!< 0x20 */
#define TUSB546_REG_DP_CTRL3_SET_POWER_STATE_1 (0x2 << TUSB546_REG_DP_CTRL3_SET_POWER_STATE_Pos) /*!< 0x40 */
/********************* Bit definition for DP_CTRL4 register *****************/
#define TUSB546_REG_DP_CTRL4_DP0_DISABLE_Pos (0U)
#define TUSB546_REG_DP_CTRL4_DP0_DISABLE_Msk (0x1U << TUSB546_REG_DP_CTRL4_DP0_DISABLE_Pos) /*!< 0x01 */
#define TUSB546_REG_DP_CTRL4_DP0_DISABLE TUSB546_REG_DP_CTRL4_DP0_DISABLE_Msk /*!< DP Lane 0 disable */
#define TUSB546_REG_DP_CTRL4_DP1_DISABLE_Pos (1U)
#define TUSB546_REG_DP_CTRL4_DP1_DISABLE_Msk (0x1U << TUSB546_REG_DP_CTRL4_DP1_DISABLE_Pos) /*!< 0x02 */
#define TUSB546_REG_DP_CTRL4_DP1_DISABLE TUSB546_REG_DP_CTRL4_DP1_DISABLE_Msk /*!< DP Lane 1 disable */
#define TUSB546_REG_DP_CTRL4_DP2_DISABLE_Pos (2U)
#define TUSB546_REG_DP_CTRL4_DP2_DISABLE_Msk (0x1U << TUSB546_REG_DP_CTRL4_DP2_DISABLE_Pos) /*!< 0x04 */
#define TUSB546_REG_DP_CTRL4_DP2_DISABLE TUSB546_REG_DP_CTRL4_DP2_DISABLE_Msk /*!< DP Lane 2 disable */
#define TUSB546_REG_DP_CTRL4_DP3_DISABLE_Pos (3U)
#define TUSB546_REG_DP_CTRL4_DP3_DISABLE_Msk (0x1U << TUSB546_REG_DP_CTRL4_DP3_DISABLE_Pos) /*!< 0x08 */
#define TUSB546_REG_DP_CTRL4_DP3_DISABLE TUSB546_REG_DP_CTRL4_DP3_DISABLE_Msk /*!< DP Lane 3 disable */
#define TUSB546_REG_DP_CTRL4_AUX_SBU_OVR_Pos (4U)
#define TUSB546_REG_DP_CTRL4_AUX_SBU_OVR_Msk (0x3U << TUSB546_REG_DP_CTRL4_AUX_SBU_OVR_Pos) /*!< 0x30 */
#define TUSB546_REG_DP_CTRL4_AUX_SBU_OVR TUSB546_REG_DP_CTRL4_AUX_SBU_OVR_Msk /*!< AUX to SBU config */
#define TUSB546_REG_DP_CTRL4_AUX_SBU_OVR_0 (0x1 << TUSB546_REG_DP_CTRL4_AUX_SBU_OVR_Pos) /*!< 0x10 */
#define TUSB546_REG_DP_CTRL4_AUX_SBU_OVR_1 (0x2 << TUSB546_REG_DP_CTRL4_AUX_SBU_OVR_Pos) /*!< 0x20 */
#define TUSB546_REG_DP_CTRL4_SNOOP_DISABLE_Pos (7U)
#define TUSB546_REG_DP_CTRL4_SNOOP_DISABLE_Msk (0x1U << TUSB546_REG_DP_CTRL4_SNOOP_DISABLE_Pos) /*!< 0x80 */
#define TUSB546_REG_DP_CTRL4_SNOOP_DISABLE TUSB546_REG_DP_CTRL4_SNOOP_DISABLE_Msk /*!< AUX snoop disable */
/******************** Bit definition for USB3_CTRL1 register ****************/
#define TUSB546_REG_USB3_CTRL1_EQ1_SEL_Pos (0U)
#define TUSB546_REG_USB3_CTRL1_EQ1_SEL_Msk (0xFU << TUSB546_REG_USB3_CTRL1_EQ1_SEL_Pos) /*!< 0x0F */
#define TUSB546_REG_USB3_CTRL1_EQ1_SEL TUSB546_REG_USB3_CTRL1_EQ1_SEL_Msk /*!< Field selects between 0 to 11 dB of EQ for USB3.1 RX1 receiver */
#define TUSB546_REG_USB3_CTRL1_EQ1_SEL_0 (0x1 << TUSB546_REG_USB3_CTRL1_EQ1_SEL_Pos) /*!< 0x01 */
#define TUSB546_REG_USB3_CTRL1_EQ1_SEL_1 (0x2 << TUSB546_REG_USB3_CTRL1_EQ1_SEL_Pos) /*!< 0x02 */
#define TUSB546_REG_USB3_CTRL1_EQ1_SEL_2 (0x4 << TUSB546_REG_USB3_CTRL1_EQ1_SEL_Pos) /*!< 0x04 */
#define TUSB546_REG_USB3_CTRL1_EQ1_SEL_4 (0x8 << TUSB546_REG_USB3_CTRL1_EQ1_SEL_Pos) /*!< 0x08 */
#define TUSB546_REG_USB3_CTRL1_EQ2_SEL_Pos (4U)
#define TUSB546_REG_USB3_CTRL1_EQ2_SEL_Msk (0xFU << TUSB546_REG_USB3_CTRL1_EQ2_SEL_Pos) /*!< 0xF0 */
#define TUSB546_REG_USB3_CTRL1_EQ2_SEL TUSB546_REG_USB3_CTRL1_EQ2_SEL_Msk /*!< Field selects between 0 to 11 dB of EQ for USB3.1 RX2 receiver */
#define TUSB546_REG_USB3_CTRL1_EQ2_SEL_0 (0x1 << TUSB546_REG_USB3_CTRL1_EQ2_SEL_Pos) /*!< 0x10 */
#define TUSB546_REG_USB3_CTRL1_EQ2_SEL_1 (0x2 << TUSB546_REG_USB3_CTRL1_EQ2_SEL_Pos) /*!< 0x20 */
#define TUSB546_REG_USB3_CTRL1_EQ2_SEL_2 (0x4 << TUSB546_REG_USB3_CTRL1_EQ2_SEL_Pos) /*!< 0x40 */
#define TUSB546_REG_USB3_CTRL1_EQ2_SEL_4 (0x8 << TUSB546_REG_USB3_CTRL1_EQ2_SEL_Pos) /*!< 0x80 */
/******************** Bit definition for USB3_CTRL2 register ****************/
#define TUSB546_USB3_CTRL2_SSEQ_SEL_Pos (0U)
#define TUSB546_USB3_CTRL2_SSEQ_SEL_Msk (0xFU << TUSB546_USB3_CTRL2_SSEQ_SEL_Pos) /*!< 0x0F */
#define TUSB546_USB3_CTRL2_SSEQ_SEL TUSB546_USB3_CTRL2_SSEQ_SEL_Msk /*!< Field selects between 0 to 9 dB of EQ for USB3.1 SSTXP/N receiver */
#define TUSB546_USB3_CTRL2_SSEQ_SEL_0 (0x1 << TUSB546_USB3_CTRL2_SSEQ_SEL_Pos) /*!< 0x01 */
#define TUSB546_USB3_CTRL2_SSEQ_SEL_1 (0x2 << TUSB546_USB3_CTRL2_SSEQ_SEL_Pos) /*!< 0x02 */
#define TUSB546_USB3_CTRL2_SSEQ_SEL_2 (0x4 << TUSB546_USB3_CTRL2_SSEQ_SEL_Pos) /*!< 0x04 */
#define TUSB546_USB3_CTRL2_SSEQ_SEL_4 (0x8 << TUSB546_USB3_CTRL2_SSEQ_SEL_Pos) /*!< 0x08 */
/******************** Bit definition for USB3_CTRL3 register ****************/
#define TUSB546_REG_USB3_CTRL3_COMPLIANCE_Pos (0U)
#define TUSB546_REG_USB3_CTRL3_COMPLIANCE_Msk (0x3U << TUSB546_REG_USB3_CTRL3_COMPLIANCE_Pos) /*!< 0x03 */
#define TUSB546_REG_USB3_CTRL3_COMPLIANCE TUSB546_REG_USB3_CTRL3_COMPLIANCE_Msk /*!< Compliance mode */
#define TUSB546_REG_USB3_CTRL3_COMPLIANCE_0 (0x1 << TUSB546_REG_USB3_CTRL3_COMPLIANCE_Pos) /*!< 0x01 */
#define TUSB546_REG_USB3_CTRL3_COMPLIANCE_1 (0x2 << TUSB546_REG_USB3_CTRL3_COMPLIANCE_Pos) /*!< 0x02 */
#define TUSB546_REG_USB3_CTRL3_DFP_RXDET_INTERVAL_Pos (2U)
#define TUSB546_REG_USB3_CTRL3_DFP_RXDET_INTERVAL_Msk (0x3U << TUSB546_REG_USB3_CTRL3_DFP_RXDET_INTERVAL_Pos) /*!< 0x0C */
#define TUSB546_REG_USB3_CTRL3_DFP_RXDET_INTERVAL TUSB546_REG_USB3_CTRL3_DFP_RXDET_INTERVAL_Msk /*!< Rx.Detect interval for the Downstream facing port */
#define TUSB546_REG_USB3_CTRL3_DFP_RXDET_INTERVAL_0 (0x1 << TUSB546_REG_USB3_CTRL3_DFP_RXDET_INTERVAL_Pos) /*!< 0x04 */
#define TUSB546_REG_USB3_CTRL3_DFP_RXDET_INTERVAL_1 (0x2 << TUSB546_REG_USB3_CTRL3_DFP_RXDET_INTERVAL_Pos) /*!< 0x08 */
#define TUSB546_REG_USB3_CTRL3_DISABLE_U2U3_RXDET_Pos (4U)
#define TUSB546_REG_USB3_CTRL3_DISABLE_U2U3_RXDET_Msk (0x1U << TUSB546_REG_USB3_CTRL3_DISABLE_U2U3_RXDET_Pos) /*!< 0x10 */
#define TUSB546_REG_USB3_CTRL3_DISABLE_U2U3_RXDET TUSB546_REG_USB3_CTRL3_DISABLE_U2U3_RXDET_Msk /*!< Rx.Detect in U2/U3 disabled */
#define TUSB546_REG_USB3_CTRL3_U2U3_LFPS_DEBOUNCE_Pos (5U)
#define TUSB546_REG_USB3_CTRL3_U2U3_LFPS_DEBOUNCE_Msk (0x1U << TUSB546_REG_USB3_CTRL3_U2U3_LFPS_DEBOUNCE_Pos) /*!< 0x20 */
#define TUSB546_REG_USB3_CTRL3_U2U3_LFPS_DEBOUNCE TUSB546_REG_USB3_CTRL3_U2U3_LFPS_DEBOUNCE_Msk /*!< Debounce of LFPS before U2/U3 exit enabled */
#define TUSB546_REG_USB3_CTRL3_LFPS_EQ_Pos (6U)
#define TUSB546_REG_USB3_CTRL3_LFPS_EQ_Msk (0x1U << TUSB546_REG_USB3_CTRL3_LFPS_EQ_Pos) /*!< 0x40 */
#define TUSB546_REG_USB3_CTRL3_LFPS_EQ TUSB546_REG_USB3_CTRL3_LFPS_EQ_Msk /*!< EQ settings control */
#define TUSB546_REG_USB3_CM_ACTIVE_EQ_Pos (7U)
#define TUSB546_REG_USB3_CM_ACTIVE_EQ_Msk (0x1U << TUSB546_REG_USB3_CM_ACTIVE_EQ_Pos) /*!< 0x80 */
#define TUSB546_REG_USB3_CM_ACTIVE_EQ TUSB546_REG_USB3_CM_ACTIVE_EQ_Msk /*!< USB 3.1 compliance mode */
/** @defgroup TUSB546_MODE TUSB546 functioning mode
* @{
*/
#define TUSB546_MODE_DISABLED 0x0U
#define TUSB546_MODE_USB3_ONLY TUSB546_REG_CTRL_CTLSEL_0
#define TUSB546_MODE_FOUR_DPLANES TUSB546_REG_CTRL_CTLSEL_1
#define TUSB546_MODE_TWO_DPLANES_USB3 TUSB546_REG_CTRL_CTLSEL
/**
* @}
*/
/** @defgroup TUSB546_ORIENTATION TUSB546 Type-C Cable Orientation
* @{
*/
#define TUSB546_ORIENTATION_NORMAL 0x0U
#define TUSB546_ORIENTATION_FLIPPED TUSB546_REG_CTRL_FLIPSEL
/**
* @}
*/
/** @defgroup TUSB546_DPLANE DP Lane Identifier
* @{
*/
#define TUSB546_DPLANE_0 0x0U
#define TUSB546_DPLANE_1 0x2U
#define TUSB546_DPLANE_2 0x4U
#define TUSB546_DPLANE_3 0x8U
#define TUSB546_DPLANE_ALL 0xFU
/**
* @}
*/
/** @defgroup TUSB546_USBSIGNAL TUSB546 USB 3.1 signal identifier
* @{
*/
#define TUSB546_USBSIGNAL_RX1 0x0U
#define TUSB546_USBSIGNAL_RX2 0x1U
#define TUSB546_USBSIGNAL_SSTX 0x2U
/**
* @}
*/
/** @defgroup TUSB546_EQGAIN TUSB546 Equalizer Gain
* @{
.------------------------.-------------------------.-------------------------.------------------------.
| Equalization setting # | USB3.1 DFP EQ Gain (dB) | USB3.1 UFP EQ Gain (dB) | DISPLAYPORT LANES (dB) |
'------------------------'-------------------------'-------------------------'------------------------'
| 0 | 0.2 | -1.6 | 1.0 |
| 1 | 1.2 | -0.5 | 3.3 |
| 2 | 2.2 | 0.5 | 4.9 |
| 3 | 3.3 | 1.6 | 6.5 |
| 4 | 4.2 | 2.4 | 7.5 |
| 5 | 5.1 | 3.4 | 8.6 |
| 6 | 5.9 | 4.1 | 9.5 |
| 7 | 6.7 | 4.9 | 10.4 |
| 8 | 7.4 | 5.7 | 11.1 |
| 9 | 8.1 | 6.4 | 11.7 |
| 10 | 8.7 | 6.9 | 12.3 |
| 11 | 9.3 | 7.5 | 12.8 |
| 12 | 9.7 | 8.0 | 13.2 |
| 13 | 10.2 | 8.5 | 13.6 |
| 14 | 10.6 | 8.9 | 14.0 |
| 15 | 11.1 | 9.4 | 14.4 |
'------------------------'-------------------------'-------------------------'------------------------'
*/
#define TUSB546_EQGAIN_0 0x0U
#define TUSB546_EQGAIN_1 0x1U
#define TUSB546_EQGAIN_2 0x2U
#define TUSB546_EQGAIN_3 0x3U
#define TUSB546_EQGAIN_4 0x4U
#define TUSB546_EQGAIN_5 0x5U
#define TUSB546_EQGAIN_6 0x6U
#define TUSB546_EQGAIN_7 0x7U
#define TUSB546_EQGAIN_8 0x8U
#define TUSB546_EQGAIN_9 0x9U
#define TUSB546_EQGAIN_10 0xAU
#define TUSB546_EQGAIN_11 0xBU
#define TUSB546_EQGAIN_12 0xCU
#define TUSB546_EQGAIN_13 0xDU
#define TUSB546_EQGAIN_14 0xEU
#define TUSB546_EQGAIN_15 0xFU
/**
* @}
*/
/** @defgroup TUSB546_DPCDREG TUSB546 Display Port Configuration Data (DPCD) register identifier
* @{
*/
#define TUSB546_DPCDREG_LANE_COUNT_SET 0x0U
#define TUSB546_DPCDREG_SET_POWER 0x1U
/**
* @}
*/
/** @defgroup TUSB546_AUXTOSBU TUSB546 AUXp or AUXn to SBU1 or SBU2 connect/disconnect override
* @{
*/
#define TUSB546_AUXTOSBU_DEFAULT 0x0U
#define TUSB546_AUXTOSBU_OVERRIDE 0x1U
#define TUSB546_AUXTOSBU_OPEN 0x2U
/**
* @}
*/
/** @defgroup TUSB546_USB3_COMPLIANCEMODE USB 3.1 Compliance mode
* @{
*/
#define TUSB546_USB3_COMPLIANCEMODE_FSM 0x0U
#define TUSB546_USB3_COMPLIANCEMODE_DFP TUSB546_REG_USB3_CTRL3_COMPLIANCE_0
#define TUSB546_USB3_COMPLIANCEMODE_UFP TUSB546_REG_USB3_CTRL3_COMPLIANCE_1
#define TUSB546_USB3_COMPLIANCEMODE_DISABLED TUSB546_REG_USB3_CTRL3_COMPLIANCE
/**
* @}
*/
/** @defgroup TUSB546_RXDET_INTERVAL USB 3.1 Rx.Detect interval for the Downstream facing port (TX1P/N and TX2P/N)
* @{
*/
#define TUSB546_RXDET_INTERVAL_8MS 0x0U
#define TUSB546_RXDET_INTERVAL_12MS TUSB546_REG_USB3_CTRL3_DFP_RXDET_INTERVAL_0
#define TUSB546_RXDET_INTERVAL_48MS TUSB546_REG_USB3_CTRL3_DFP_RXDET_INTERVAL_1
#define TUSB546_RXDET_INTERVAL_96MS TUSB546_REG_USB3_CTRL3_DFP_RXDET_INTERVAL
/**
* @}
*/
/**
* @}
*/
#if defined(TUSB546_DEBUG)
/** @defgroup TUSB546_Exported_Structure TUSB546 Exported Structure
* @{
*/
typedef union {
uint8_t Register;
struct {
uint8_t CTLSEL:2;
uint8_t FLIPSEL:1;
uint8_t HPDIN_OVRRIDE:1;
uint8_t EQ_OVERRIDE:1;
uint8_t SWAP_HPDIN :1;
uint8_t Reserved:2;
};
} TUSB546_GeneralRegTypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t DP0EQ_SEL:4;
uint8_t DP1EQ_SEL:4;
};
} TUSB546_DPCtrlStatusReg10TypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t DP2EQ_SEL:4;
uint8_t DP3EQ_SEL:4;
};
} TUSB546_DPCtrlStatusReg11TypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t LANE_COUNT_SET :5;
uint8_t SET_POWER_STATE :2;
uint8_t Reserved :1;
};
} TUSB546_DPCtrlStatusReg12TypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t DP0_DISABLE :1;
uint8_t DP1_DISABLE :1;
uint8_t DP2_DISABLE :1;
uint8_t DP3_DISABLE :1;
uint8_t AUX_SBU_OVR :2;
uint8_t Reserved :1;
uint8_t AUX_SNOOP_DISABLE :1;
};
} TUSB546_DPCtrlStatusReg13TypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t Reserved :8;
};
} TUSB546_USBCtrlStatusReg20TypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t Reserved :8;
};
} TUSB546_USBCtrlStatusReg21TypeDef;
typedef union {
uint8_t Register;
struct {
uint8_t Reserved :8;
};
} TUSB546_USBCtrlStatusReg22TypeDef;
typedef struct
{
TUSB546_GeneralRegTypeDef General; /*!< General Registers (0x0A) */
TUSB546_DPCtrlStatusReg10TypeDef DPCtrlStatus10; /*!< DisplayPort Control/Status Registers (0x10)*/
TUSB546_DPCtrlStatusReg11TypeDef DPCtrlStatus11; /*!< DisplayPort Control/Status Registers (0x11)*/
TUSB546_DPCtrlStatusReg12TypeDef DPCtrlStatus12; /*!< DisplayPort Control/Status Registers (0x12) */
TUSB546_DPCtrlStatusReg13TypeDef DPCtrlStatus13; /*!< DisplayPort Control/Status Registers (0x13) */
TUSB546_USBCtrlStatusReg20TypeDef USBCtrlStatus20;/*!< USB3.1 Control/Status Registers (0x20) */
TUSB546_USBCtrlStatusReg21TypeDef USBCtrlStatus21;/*!< USB3.1 Control/Status Registers (0x21) */
TUSB546_USBCtrlStatusReg22TypeDef USBCtrlStatus22;/*!< USB3.1 Control/Status Registers (0x22) */
} TUSB546_RegistersTypeDef;
/**
* @}
*/
#endif /* TUSB546_DEBUG */
/** @defgroup TUSB546_Exported_Functions
* @{
*/
/* USB Type-C cross switch management functions */
uint32_t tusb546_CrossSwitch_Init(uint16_t Address);
void tusb546_CrossSwitch_DeInit(uint16_t Address);
uint32_t tusb546_CrossSwitch_PowerOn(uint16_t Address);
uint32_t tusb546_CrossSwitch_PowerOff(uint16_t Address);
uint32_t tusb546_CrossSwitch_SetMode(uint16_t Address, TYPECSWITCH_Mode_t Mode);
uint32_t tusb546_CrossSwitch_IsSupportedMode(TYPECSWITCH_Mode_t Mode);
/* DisplayPort Linear Redriver management functions */
uint32_t tusb546_DPRedriver_Init(uint16_t Address);
void tusb546_DPRedriver_DeInit(uint16_t Address);
uint32_t tusb546_DPRedriver_PowerOn(uint16_t Address);
uint32_t tusb546_DPRedriver_PowerOff(uint16_t Address);
uint32_t tusb546_DPRedriver_SetEQGain(uint16_t Address, DPREDRIVER_ChannelId_t ChannelId, uint8_t EQGain);
uint32_t tusb546_DPRedriver_EnableChannel(uint16_t Address, DPREDRIVER_ChannelId_t ChannelId);
uint32_t tusb546_DPRedriver_DisableChannel(uint16_t Address, DPREDRIVER_ChannelId_t ChannelId);
/* MUX IO functions */
uint8_t MUX_IO_Init(void);
void MUX_IO_DeInit(void);
uint8_t MUX_IO_Write(uint16_t Addr, uint16_t Reg, uint8_t Data);
uint8_t MUX_IO_Read(uint16_t Addr, uint16_t Reg, uint8_t *pData);
uint32_t MUX_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials);
/**
* @}
*/
/** @defgroup TUSB546_Exported_Variables
* @{
*/
/* USB Type-C crossbar switch driver structure */
extern TYPECSWITCH_Drv_t tusb546_drv_CrossSwitch;
/* Displayport Linear Redriver driver structure */
extern DPREDRIVER_Drv_t tusb546_drv_LinearRedriver;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* TUSB546_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,3 @@
# Copyright (c) 2020 STMicroelectronics
This software component is licensed by STMicroelectronics under the **BSD-3-Clause** license. You may not use this software except in compliance with this license. You may obtain a copy of the license [here](https://opensource.org/licenses/BSD-3-Clause).

View file

@ -0,0 +1,63 @@
<!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 STM32G0C1E-EV Board 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_2020.css" />
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
<link rel="icon" type="image/x-icon" href="_htmresc/favicon.png" />
</head>
<body>
<div class="row">
<div class="col-sm-12 col-lg-4">
<center>
<h1 id="release-notes-for-stm32g0c1e-ev-board-drivers">Release Notes for <mark>STM32G0C1E-EV Board drivers</mark></h1>
<p>Copyright © 2020 STMicroelectronics<br />
</p>
<a href="https://www.st.com" class="logo"><img src="_htmresc/st_logo_2020.png" alt="ST logo" /></a>
</center>
<h1 id="license">License</h1>
<p>This software component is licensed by ST under BSD 3-Clause license, the “License”; You may not use this component 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 driver provides a set of functions to manage:</p>
<ul>
<li>LEDs, Buttons, SD card, temperature sensor, LCD, MUX and PWR on STM32G0C1E-EV board from STMicroelectronics</li>
</ul>
</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.RC1 / 13-October-2020</label>
<div>
<h2 id="main-changes">Main Changes</h2>
<h3 id="first-release">First release</h3>
<h2 id="contents">Contents</h2>
<p>First official release of STM32G0C1E-EV board drivers for STM32Cube G0 FW package.</p>
<h2 id="supported-devices-and-boards">Supported Devices and Boards</h2>
<ul>
<li>STM32G0C1xx/B1xx devices</li>
<li>STM32G0C1E-EV mother board (<strong>MB1581B</strong>)</li>
<li>“Legacy” daughter board (MB1351A)</li>
<li>USBPD daughter board (MB1352C)</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
<p>For complete documentation on STM32G0xx, visit: [<a href="http://www.st.com/stm32g0">www.st.com/stm32g0</a>]</p>
<em>This release note uses up to date web standards and, for this reason, should not be opened with Internet Explorer but preferably with popular browsers such as Google Chrome, Mozilla Firefox, Opera or Microsoft Edge.</em>
</footer>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

File diff suppressed because it is too large Load diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,563 @@
/**
******************************************************************************
* @file stm32g0c1e_eval.h
* @author MCD Application Team
* @brief This file contains definitions for STM32G0C1E-EV's Leds, push-buttons
* and COM port hardware resources.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2020 STMicroelectronics</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 STM32G0C1E_EVAL_H
#define STM32G0C1E_EVAL_H
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup BSP
* @{
*/
/** @defgroup STM32G0C1E_EVAL STM32G0C1E EVAL
* @{
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32g0xx_hal.h"
#include <stdio.h>
/** @defgroup STM32G0C1E_EVAL_Common STM32G0C1E EVAL Common
* @{
*/
/** @defgroup STM32G0C1E_EVAL_Private_Constants Private Constants
* @{
*/
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_Private_Variables Private Variables
* @{
*/
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_Exported_Types Exported Types
* @{
*/
/**
* @brief LED Types Definition
*/
typedef enum
{
LED1 = 0,
LED2 = 1,
LED3 = 2,
LED4 = 3,
/* Color led aliases */
LED_GREEN = LED1,
LED_ORANGE = LED2,
LED_RED = LED3,
LED_BLUE = LED4
} Led_TypeDef;
/**
* @brief BUTTON Types Definition
*/
typedef enum
{
BUTTON_TAMPER = 0
} Button_TypeDef;
typedef enum
{
BUTTON_MODE_GPIO = 0,
BUTTON_MODE_EXTI = 1
} ButtonMode_TypeDef;
/**
* @brief JOYSTICK Types Definition
*/
typedef enum
{
JOY_SEL = 0,
JOY_DOWN = 1,
JOY_LEFT = 2,
JOY_RIGHT = 3,
JOY_UP = 4,
JOY_NONE = 5
} JOYState_TypeDef;
typedef enum
{
JOY_MODE_GPIO = 0,
JOY_MODE_EXTI = 1
} JOYMode_TypeDef;
/**
* @brief COM Types Definition
*/
typedef enum
{
COM1 = 0
} COM_TypeDef;
/**
* @brief Daughter Board (DB) Types Definition
*/
typedef enum
{
DB_ID_NONE = 0,
DB_ID_LEGACY,
DB_ID_UCPD_AB,
DB_ID_UCPD_C
} DBId_TypeDef;
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_Exported_Constants Exported Constants
* @{
*/
/**
* @brief Define for STM32G0C1E_EVAL board
*/
#define EVAL_BOARD_REVISION ((uint8_t *)"REV. B")
/** @defgroup STM32G0C1E_EV_LED STM32G0C1E-EV LED
* @{
*/
#define LEDn 4
#define LED1_PIN GPIO_PIN_5 /* PD.05 */
#define LED1_GPIO_PORT GPIOD
#define LED1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define LED1_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
#define LED2_PIN GPIO_PIN_6 /* PD.06 */
#define LED2_GPIO_PORT GPIOD
#define LED2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define LED2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
#define LED3_PIN GPIO_PIN_8 /* PD.08 */
#define LED3_GPIO_PORT GPIOD
#define LED3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define LED3_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
#define LED4_PIN GPIO_PIN_9 /* PD.09 */
#define LED4_GPIO_PORT GPIOD
#define LED4_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define LED4_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
#define LEDx_GPIO_CLK_ENABLE(__LED__) do { if((__LED__) == LED1) LED1_GPIO_CLK_ENABLE(); else \
if((__LED__) == LED2) LED2_GPIO_CLK_ENABLE(); else \
if((__LED__) == LED3) LED3_GPIO_CLK_ENABLE(); else \
if((__LED__) == LED4) LED4_GPIO_CLK_ENABLE();} while(0)
#define LEDx_GPIO_CLK_DISABLE(__LED__) (((__LED__) == LED1) ? LED1_GPIO_CLK_DISABLE() :\
((__LED__) == LED2) ? LED2_GPIO_CLK_DISABLE() :\
((__LED__) == LED3) ? LED3_GPIO_CLK_DISABLE() :\
((__LED__) == LED4) ? LED4_GPIO_CLK_DISABLE() : 0 )
/**
* @}
*/
/** @defgroup STM32G0C1E_EV_BUTTON STM32G0C1E-EV BUTTON
* @{
*/
#define JOYn 5
#define BUTTONn 1
/**
* @brief Tamper push-button
*/
#define TAMPER_BUTTON_PIN GPIO_PIN_13 /* PC.13 */
#define TAMPER_BUTTON_GPIO_PORT GPIOC
#define TAMPER_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define TAMPER_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
#define TAMPER_BUTTON_EXTI_IRQn EXTI4_15_IRQn
#define TAMPERx_GPIO_CLK_ENABLE(__BUTTON__) do { if((__BUTTON__) == BUTTON_TAMPER) TAMPER_BUTTON_GPIO_CLK_ENABLE();} while(0)
#define TAMPERx_GPIO_CLK_DISABLE(__BUTTON__) (((__BUTTON__) == BUTTON_TAMPER) ? TAMPER_BUTTON_GPIO_CLK_DISABLE(): 0 )
/**
* @brief Joystick Right push-button
*/
#define RIGHT_JOY_PIN GPIO_PIN_7 /* PC.07 */
#define RIGHT_JOY_GPIO_PORT GPIOC
#define RIGHT_JOY_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define RIGHT_JOY_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
#define RIGHT_JOY_EXTI_IRQn EXTI4_15_IRQn
/**
* @brief Joystick Left push-button
*/
#define LEFT_JOY_PIN GPIO_PIN_8 /* PC.08 */
#define LEFT_JOY_EXTI_IRQn EXTI4_15_IRQn
#define LEFT_JOY_GPIO_PORT GPIOC
#define LEFT_JOY_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define LEFT_JOY_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
/**
* @brief Joystick Up push-button
*/
#define UP_JOY_PIN GPIO_PIN_2 /* PC.02 */
#define UP_JOY_GPIO_PORT GPIOC
#define UP_JOY_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define UP_JOY_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
#define UP_JOY_EXTI_IRQn EXTI2_3_IRQn
/**
* @brief Joystick Down push-button
*/
#define DOWN_JOY_PIN GPIO_PIN_3 /* PC.03 */
#define DOWN_JOY_EXTI_IRQn EXTI2_3_IRQn
#define DOWN_JOY_GPIO_PORT GPIOC
#define DOWN_JOY_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define DOWN_JOY_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
/**
* @brief Joystick Sel push-button
*/
#define SEL_JOY_PIN GPIO_PIN_0 /* PA.00 */
#define SEL_JOY_GPIO_PORT GPIOA
#define SEL_JOY_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define SEL_JOY_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
#define SEL_JOY_EXTI_IRQn EXTI0_1_IRQn
#define JOYx_GPIO_CLK_ENABLE(__JOY__) do { if((__JOY__) == JOY_SEL) SEL_JOY_GPIO_CLK_ENABLE(); else \
if((__JOY__) == JOY_DOWN) DOWN_JOY_GPIO_CLK_ENABLE(); else \
if((__JOY__) == JOY_LEFT) LEFT_JOY_GPIO_CLK_ENABLE(); else \
if((__JOY__) == JOY_RIGHT) RIGHT_JOY_GPIO_CLK_ENABLE(); else \
if((__JOY__) == JOY_UP) UP_JOY_GPIO_CLK_ENABLE();} while(0)
#define JOYx_GPIO_CLK_DISABLE(__JOY__) (((__JOY__) == JOY_SEL) ? SEL_JOY_GPIO_CLK_DISABLE() :\
((__JOY__) == JOY_DOWN) ? DOWN_JOY_GPIO_CLK_DISABLE() :\
((__JOY__) == JOY_LEFT) ? LEFT_JOY_GPIO_CLK_DISABLE() :\
((__JOY__) == JOY_RIGHT) ? RIGHT_JOY_GPIO_CLK_DISABLE() :\
((__JOY__) == JOY_UP) ? UP_JOY_GPIO_CLK_DISABLE() : 0 )
/**
* @}
*/
/** @defgroup STM32G0C1E_EV_COM STM32G0C1E-EV COM
* @{
*/
#define COMn 1
/**
* @brief Definition for COM port1, connected to USART1
*/
#define EVAL_COM1 USART1
#define EVAL_COM1_CLK_ENABLE() __HAL_RCC_USART1_CLK_ENABLE()
#define EVAL_COM1_CLK_DISABLE() __HAL_RCC_USART1_CLK_DISABLE()
#define EVAL_COM1_TX_PIN GPIO_PIN_4 /* PC.04 */
#define EVAL_COM1_TX_GPIO_PORT GPIOC
#define EVAL_COM1_TX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define EVAL_COM1_TX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
#define EVAL_COM1_TX_AF GPIO_AF1_USART1
#define EVAL_COM1_RX_PIN GPIO_PIN_5 /* PC.05 */
#define EVAL_COM1_RX_GPIO_PORT GPIOC
#define EVAL_COM1_RX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define EVAL_COM1_RX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
#define EVAL_COM1_RX_AF GPIO_AF1_USART1
#define EVAL_COM1_CTS_PIN GPIO_PIN_11 /* PA.11 */
#define EVAL_COM1_CTS_GPIO_PORT GPIOA
#define EVAL_COM1_CTS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define EVAL_COM1_CTS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
#define EVAL_COM1_CTS_AF GPIO_AF1_USART1
#define EVAL_COM1_RTS_PIN GPIO_PIN_12 /* PA.12 */
#define EVAL_COM1_RTS_GPIO_PORT GPIOA
#define EVAL_COM1_RTS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define EVAL_COM1_RTS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
#define EVAL_COM1_RTS_AF GPIO_AF1_USART1
#define EVAL_COM1_IRQn USART1_IRQn
#define COMx_CLK_ENABLE(__COM__) do { if((__COM__) == COM1) EVAL_COM1_CLK_ENABLE();} while(0)
#define COMx_CLK_DISABLE(__COM__) (((__COM__) == COM1) ? EVAL_COM1_CLK_DISABLE() : 0)
#define COMx_TX_GPIO_CLK_ENABLE(__COM__) do { if((__COM__) == COM1) EVAL_COM1_TX_GPIO_CLK_ENABLE();} while(0)
#define COMx_TX_GPIO_CLK_DISABLE(__COM__) (((__COM__) == COM1) ? EVAL_COM1_TX_GPIO_CLK_DISABLE() : 0)
#define COMx_RX_GPIO_CLK_ENABLE(__COM__) do { if((__COM__) == COM1) EVAL_COM1_RX_GPIO_CLK_ENABLE();} while(0)
#define COMx_RX_GPIO_CLK_DISABLE(__COM__) (((__COM__) == COM1) ? EVAL_COM1_RX_GPIO_CLK_DISABLE() : 0)
#define COMx_CTS_GPIO_CLK_ENABLE(__COM__) do { if((__COM__) == COM1) EVAL_COM1_CTS_GPIO_CLK_ENABLE();} while(0)
#define COMx_CTS_GPIO_CLK_DISABLE(__COM__) (((__COM__) == COM1) ? EVAL_COM1_CTS_GPIO_CLK_DISABLE() : 0)
#define COMx_RTS_GPIO_CLK_ENABLE(__COM__) do { if((__COM__) == COM1) EVAL_COM1_RTS_GPIO_CLK_ENABLE();} while(0)
#define COMx_RTS_GPIO_CLK_DISABLE(__COM__) (((__COM__) == COM1) ? EVAL_COM1_RTS_GPIO_CLK_DISABLE() : 0)
#if defined(HAL_I2C_MODULE_ENABLED)
/*##################### I2Cx ###################################*/
/* User can use this section to tailor I2Cx instance used and associated resources */
/* Definition for I2C1 Pins */
#define EVAL_I2C1 I2C1
#define EVAL_I2C1_CLK_ENABLE() __HAL_RCC_I2C1_CLK_ENABLE()
#define EVAL_I2C1_CLK_DISABLE() __HAL_RCC_I2C1_CLK_DISABLE()
#define EVAL_I2C1_FORCE_RESET() __HAL_RCC_I2C1_FORCE_RESET()
#define EVAL_I2C1_RELEASE_RESET() __HAL_RCC_I2C1_RELEASE_RESET()
#define EVAL_I2C1_SCL_PIN GPIO_PIN_6 /* PB.6 */
#define EVAL_I2C1_SDA_PIN GPIO_PIN_7 /* PB.7 */
#define EVAL_I2C1_GPIO_PORT GPIOB /* GPIOB */
#define EVAL_I2C1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define EVAL_I2C1_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
#define EVAL_I2C1_SCL_SDA_AF GPIO_AF6_I2C1
/* Definition for I2C2 Pins */
#define EVAL_I2C2 I2C2
#define EVAL_I2C2_CLK_ENABLE() __HAL_RCC_I2C2_CLK_ENABLE()
#define EVAL_I2C2_CLK_DISABLE() __HAL_RCC_I2C2_CLK_DISABLE()
#define EVAL_I2C2_FORCE_RESET() __HAL_RCC_I2C2_FORCE_RESET()
#define EVAL_I2C2_RELEASE_RESET() __HAL_RCC_I2C2_RELEASE_RESET()
#define EVAL_I2C2_SCL_PIN GPIO_PIN_13 /* PB.13 */
#define EVAL_I2C2_SDA_PIN GPIO_PIN_14 /* PB.14 */
#define EVAL_I2C2_GPIO_PORT GPIOB /* GPIOB */
#define EVAL_I2C2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define EVAL_I2C2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
#define EVAL_I2C2_AF GPIO_AF6_I2C2
/* Definition for I2C2 NVIC */
#define EVAL_I2C2_IRQn I2C2_IRQn
/* Maximum Timeout values for flags waiting loops. These timeouts are not based
on accurate values, they just guarantee that the application will not remain
stuck if the I2C communication is corrupted.
You may modify these timeout values depending on CPU frequency and application
conditions (interrupts routines ...). */
#define EVAL_I2C1_TIMEOUT_MAX 1000
#define EVAL_I2C2_TIMEOUT_MAX 1000
/* I2C TIMING is calculated in case of the I2C Clock source is the SYSCLK = 48 MHz */
/* Set TIMING to 0x00E0D3FF to reach 100 KHz speed (Rise time = 50ns, Fall time = 10ns) */
#define I2C2_TIMING 0x00E0D3FF
#define I2C1_TIMING 0x00E0D3FF
/* MUX 1 - USB Type-C Crossbar Switch I2C address (0b1000100x) */
#define MUX_1_TYPEC_SWITCH_I2C_ADDRESS 0x88U
/* MUX 1 - DisplayPort Linear Redriver I2C address (0b1000100x) */
#define MUX_1_DP_REDRIVER_I2C_ADDRESS 0x88U
/* MUX 2 - USB Type-C Crossbar Switch I2C address (0b0110000x) */
#define MUX_2_TYPEC_SWITCH_I2C_ADDRESS 0x60U
/* MUX 2 - DisplayPort Linear Redriver I2C address (0b0000000x) */
#define MUX_2_DP_REDRIVER_I2C_ADDRESS 0x00U
#endif /* HAL_I2C_MODULE_ENABLED */
#if defined(HAL_SPI_MODULE_ENABLED)
/**
* @brief Definition for SPI Interface pins (SPI1 used)
*/
#define EVAL_SPIx SPI1
#define EVAL_SPIx_CLK_ENABLE() __HAL_RCC_SPI1_CLK_ENABLE()
#define EVAL_SPIx_CLK_DISABLE() __HAL_RCC_SPI1_CLK_DISABLE()
#define EVAL_SPIx_FORCE_RESET() __HAL_RCC_SPI1_FORCE_RESET()
#define EVAL_SPIx_RELEASE_RESET() __HAL_RCC_SPI1_RELEASE_RESET()
#define EVAL_SPIx_SCK_PIN GPIO_PIN_3 /* PB.03 */
#define EVAL_SPIx_SCK_GPIO_PORT GPIOB /* GPIOB */
#define EVAL_SPIx_SCK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define EVAL_SPIx_SCK_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
#define EVAL_SPIx_SCK_AF GPIO_AF0_SPI1
#define EVAL_SPIx_MISO_PIN GPIO_PIN_4 /* PB.04 */
#define EVAL_SPIx_MISO_GPIO_PORT GPIOB /* GPIOB */
#define EVAL_SPIx_MISO_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define EVAL_SPIx_MISO_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
#define EVAL_SPIx_MISO_AF GPIO_AF0_SPI1
#define EVAL_SPIx_MOSI_PIN GPIO_PIN_7 /* PA.07 */
#define EVAL_SPIx_MOSI_GPIO_PORT GPIOA /* GPIOA */
#define EVAL_SPIx_MOSI_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define EVAL_SPIx_MOSI_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
#define EVAL_SPIx_MOSI_AF GPIO_AF0_SPI1
#define EVAL_SPIx_MOSI_DIR_PIN GPIO_PIN_12 /* PC.12 */
#define EVAL_SPIx_MOSI_DIR_GPIO_PORT GPIOC /* GPIOC */
#define EVAL_SPIx_MOSI_DIR_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define EVAL_SPIx_MOSI_DIR_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
/* Maximum Timeout values for flags waiting loops. These timeouts are not based
on accurate values, they just guarantee that the application will not remain
stuck if the SPI communication is corrupted.
You may modify these timeout values depending on CPU frequency and application
conditions (interrupts routines ...). */
#define EVAL_SPIx_TIMEOUT_MAX 1000
#endif /* HAL_SPI_MODULE_ENABLED */
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_COMPONENT STM32G0C1E_EVAL COMPONENT
* @{
*/
/*##################### LCD ###################################*/
/* Chip Select macro definition */
#define LCD_CS_LOW() HAL_GPIO_WritePin(LCD_NCS_GPIO_PORT, LCD_NCS_PIN, GPIO_PIN_RESET)
#define LCD_CS_HIGH() HAL_GPIO_WritePin(LCD_NCS_GPIO_PORT, LCD_NCS_PIN, GPIO_PIN_SET)
/**
* @brief LCD Control pins
*/
#define LCD_NCS_PIN GPIO_PIN_8 /* PB. 08*/
#define LCD_NCS_GPIO_PORT GPIOB /* GPIOB */
#define LCD_NCS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define LCD_NCS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
/*##################### SD ###################################*/
/* Chip Select macro definition */
#define SD_CS_LOW() HAL_GPIO_WritePin(SD_CS_GPIO_PORT, SD_CS_PIN, GPIO_PIN_RESET)
#define SD_CS_HIGH() HAL_GPIO_WritePin(SD_CS_GPIO_PORT, SD_CS_PIN, GPIO_PIN_SET)
/**
* @brief SD card Control pin
*/
#define SD_CS_PIN GPIO_PIN_1 /* PD.01 */
#define SD_CS_GPIO_PORT GPIOD /* GPIOD */
#define SD_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define SD_CS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
/**
* @brief SD Detect Interface pins
*/
#define SD_DETECT_PIN GPIO_PIN_9 /* PC.09 */
#define SD_DETECT_GPIO_PORT GPIOC /* GPIOC */
#define SD_DETECT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define SD_DETECT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
#define SD_DETECT_EXTI_IRQn EXTI4_15_IRQn
/*##################### HDMI-CEC ###################################*/
/**
* @brief I2C HDMI CEC Interface pins
*/
#define HDMI_CEC_HPD_SINK_PIN GPIO_PIN_2 /* PD.02 */
#define HDMI_CEC_HPD_SINK_GPIO_PORT GPIOD
#define HDMI_CEC_HPD_SINK_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define HDMI_CEC_HPD_SINK_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
#define HDMI_CEC_HPD_SOURCE_PIN GPIO_PIN_6 /* PC.06 */
#define HDMI_CEC_HPD_SOURCE_GPIO_PORT GPIOC
#define HDMI_CEC_HPD_SOURCE_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define HDMI_CEC_HPD_SOURCE_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
#define HDMI_CEC_LINE_PIN GPIO_PIN_10 /* PB.10 */
#define HDMI_CEC_LINE_GPIO_PORT GPIOB
#define HDMI_CEC_LINE_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define HDMI_CEC_LINE_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
#define HDMI_CEC_LINE_AF GPIO_AF0_CEC
#define HDMI_CEC_IRQn CEC_IRQn
/* HDMI-CEC hardware I2C address */
#define HDMI_CEC_I2C_ADDRESS 0xA0
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_DB STM32G0C1E_EVAL DAUGHTER BOARD
* @{
*/
#if defined(HAL_ADC_MODULE_ENABLED)
/**
* @brief Daughter Board detection pin
*/
#define DB_DETECT_PIN GPIO_PIN_11 /* PB.11 */
#define DB_DETECT_GPIO_PORT GPIOB /* GPIOB */
#define DB_DETECT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define DB_DETECT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
#define DB_ADC ADC1
#define DB_ADC_CLK_ENABLE() __HAL_RCC_ADC_CLK_ENABLE();
#define DB_ADC_CLK_DISABLE() __HAL_RCC_ADC_CLK_DISABLE();
#define DB_ADC_CHANNEL ADC_CHANNEL_15
#endif /* HAL_ADC_MODULE_ENABLED*/
/**
* @}
*/
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_Exported_Functions Exported Functions
* @{
*/
uint32_t BSP_GetVersion(void);
#if defined(_GUI_INTERFACE)
const uint8_t* BSP_GetHWBoardVersionName(void);
const uint8_t* BSP_GetPDTypeName(void);
#endif /* _GUI_INTERFACE */
void BSP_LED_Init(Led_TypeDef Led);
void BSP_LED_DeInit(Led_TypeDef Led);
void BSP_LED_On(Led_TypeDef Led);
void BSP_LED_Off(Led_TypeDef Led);
void BSP_LED_Toggle(Led_TypeDef Led);
void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode);
uint32_t BSP_PB_GetState(Button_TypeDef Button);
uint8_t BSP_JOY_Init(JOYMode_TypeDef Joy_Mode);
void BSP_JOY_DeInit(void);
JOYState_TypeDef BSP_JOY_GetState(void);
#if defined(HAL_UART_MODULE_ENABLED)
void BSP_COM_Init(COM_TypeDef COM, UART_HandleTypeDef* huart);
#endif /* HAL_UART_MODULE_ENABLED */
#if defined(HAL_ADC_MODULE_ENABLED)
uint8_t BSP_DB_GetId(DBId_TypeDef *pDaughterBoardId);
#endif /* HAL_ADC_MODULE_ENABLED */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32G0C1E_EVAL_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,896 @@
/**
******************************************************************************
* @file stm32g0c1e_eval_lcd.c
* @author MCD Application Team
* @brief This file includes the driver for Liquid Crystal Display modules
* mounted on STM32G0C1E-EV evaluation board.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2020 STMicroelectronics</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
*
******************************************************************************
@verbatim
==============================================================================
##### How to use this driver #####
==============================================================================
[..]
(#) This driver is used to drive indirectly an LCD TFT.
(#) This driver supports AM240320LGTNQW00H (HX8347D) LCD mounted on MB895 daughter board
(#) The HX8347D components driver MUST be included with this driver.
(#) Initialization steps:
(++) Initialize the LCD using the LCD_Init() function.
(#) Display on LCD
(++) Clear the whole LCD using the LCD_Clear() function or only one specified
string line using the LCD_ClearStringLine() function.
(++) Display a character on the specified line and column using the LCD_DisplayChar()
function or a complete string line using the LCD_DisplayStringAtLine() function.
(++) Display a string line on the specified position (x,y in pixel) and align mode
using the LCD_DisplayStringAtLine() function.
(++) Draw and fill a basic shapes (dot, line, rectangle, circle, ellipse, .. bitmap)
on LCD using a set of functions.
@endverbatim
*/
/*----------------------------------------------------------------------------*/
/* Includes ------------------------------------------------------------------*/
#include "stm32g0c1e_eval_lcd.h"
#include "../../../Utilities/Fonts/fonts.h"
#include "../../../Utilities/Fonts/font24.c"
#include "../../../Utilities/Fonts/font20.c"
#include "../../../Utilities/Fonts/font16.c"
#include "../../../Utilities/Fonts/font12.c"
#include "../../../Utilities/Fonts/font8.c"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32G0C1E_EVAL
* @{
*/
/** @addtogroup STM32G0C1E_EVAL_LCD
* @{
*/
/** @defgroup STM32G0C1E_EVAL_LCD_Private_Constants Private Constants
* @{
*/
#define POLY_X(Z) ((int32_t)((pPoints + (Z))->X))
#define POLY_Y(Z) ((int32_t)((pPoints + (Z))->Y))
#define MAX_HEIGHT_FONT 17
#define MAX_WIDTH_FONT 24
#define OFFSET_BITMAP 54
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_LCD_Private_Macros Private Macros
* @{
*/
#define ABS(X) ((X) > 0 ? (X) : -(X))
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_LCD_Private_Variables Private Variables
* @{
*/
LCD_DrawPropTypeDef DrawProp;
static LCD_DrvTypeDef *lcd_drv;
/* Max size of bitmap will based on a font24 (17x24) */
static uint8_t bitmap[MAX_HEIGHT_FONT*MAX_WIDTH_FONT*2+OFFSET_BITMAP] = {0};
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_LCD_Private_Functions Private Functions
* @{
*/
static void LCD_DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *pChar);
static void LCD_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
/**
* @}
*/
/** @addtogroup STM32G0C1E_EVAL_LCD_Exported_Functions
* @{
*/
/**
* @brief Initializes the LCD.
* @retval LCD state
*/
uint8_t BSP_LCD_Init(void)
{
/* Default value for draw propriety */
DrawProp.BackColor = 0xFFFF;
DrawProp.pFont = &LCD_DEFAULT_FONT;
DrawProp.TextColor = 0x0000;
/*HX8347D_ID connected*/
lcd_drv = &hx8347d_drv;
/* LCD Init */
lcd_drv->Init();
/* Initialize the font */
BSP_LCD_SetFont(&LCD_DEFAULT_FONT);
return LCD_OK;
}
/**
* @brief Gets the LCD X size.
* @retval Used LCD X size
*/
uint32_t BSP_LCD_GetXSize(void)
{
return(lcd_drv->GetLcdPixelWidth());
}
/**
* @brief Gets the LCD Y size.
* @retval Used LCD Y size
*/
uint32_t BSP_LCD_GetYSize(void)
{
return(lcd_drv->GetLcdPixelHeight());
}
/**
* @brief Gets the LCD text color.
* @retval Used text color.
*/
uint16_t BSP_LCD_GetTextColor(void)
{
return DrawProp.TextColor;
}
/**
* @brief Gets the LCD background color.
* @retval Used background color
*/
uint16_t BSP_LCD_GetBackColor(void)
{
return DrawProp.BackColor;
}
/**
* @brief Sets the LCD text color.
* @param Color: Text color code RGB(5-6-5)
* @retval None
*/
void BSP_LCD_SetTextColor(uint16_t Color)
{
DrawProp.TextColor = Color;
}
/**
* @brief Sets the LCD background color.
* @param Color: Background color code RGB(5-6-5)
* @retval None
*/
void BSP_LCD_SetBackColor(uint16_t Color)
{
DrawProp.BackColor = Color;
}
/**
* @brief Sets the LCD text font.
* @param pFonts: Font to be used
* @retval None
*/
void BSP_LCD_SetFont(sFONT *pFonts)
{
DrawProp.pFont = pFonts;
}
/**
* @brief Gets the LCD text font.
* @retval Used font
*/
sFONT *BSP_LCD_GetFont(void)
{
return DrawProp.pFont;
}
/**
* @brief Clears the whole LCD.
* @param Color: Color of the background
* @retval None
*/
void BSP_LCD_Clear(uint16_t Color)
{
uint32_t counter = 0;
uint32_t color_backup = DrawProp.TextColor;
DrawProp.TextColor = Color;
for(counter = 0; counter < BSP_LCD_GetYSize(); counter++)
{
BSP_LCD_DrawHLine(0, counter, BSP_LCD_GetXSize());
}
DrawProp.TextColor = color_backup;
BSP_LCD_SetTextColor(DrawProp.TextColor);
}
/**
* @brief Clears the selected line.
* @param Line: Line to be cleared
* This parameter can be one of the following values:
* @arg 0..9: if the Current fonts is Font16x24
* @arg 0..19: if the Current fonts is Font12x12 or Font8x12
* @arg 0..29: if the Current fonts is Font8x8
* @retval None
*/
void BSP_LCD_ClearStringLine(uint16_t Line)
{
uint32_t colorbackup = DrawProp.TextColor;
DrawProp.TextColor = DrawProp.BackColor;;
/* Draw a rectangle with background color */
BSP_LCD_FillRect(0, (Line * DrawProp.pFont->Height), BSP_LCD_GetXSize(), DrawProp.pFont->Height);
DrawProp.TextColor = colorbackup;
BSP_LCD_SetTextColor(DrawProp.TextColor);
}
/**
* @brief Displays one character.
* @param Xpos: Start column address
* @param Ypos: Line where to display the character shape.
* @param Ascii: Character ascii code
* This parameter must be a number between Min_Data = 0x20 and Max_Data = 0x7E
* @retval None
*/
void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii)
{
LCD_DrawChar(Ypos, Xpos, &DrawProp.pFont->table[(Ascii-' ') *\
DrawProp.pFont->Height * ((DrawProp.pFont->Width + 7) / 8)]);
}
/**
* @brief Displays characters on the LCD.
* @param Xpos: X position (in pixel)
* @param Ypos: Y position (in pixel)
* @param pText: Pointer to string to display on LCD
* @param Mode: Display mode
* This parameter can be one of the following values:
* @arg CENTER_MODE
* @arg RIGHT_MODE
* @arg LEFT_MODE
* @retval None
*/
void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *pText, Line_ModeTypdef Mode)
{
uint16_t refcolumn = 1, counter = 0;
uint32_t size = 0, ysize = 0;
uint8_t *ptr = pText;
/* Get the text size */
while (*ptr++) size ++ ;
/* Characters number per line */
ysize = (BSP_LCD_GetXSize()/DrawProp.pFont->Width);
switch (Mode)
{
case CENTER_MODE:
{
refcolumn = Xpos + ((ysize - size)* DrawProp.pFont->Width) / 2;
break;
}
case LEFT_MODE:
{
refcolumn = Xpos;
break;
}
case RIGHT_MODE:
{
refcolumn = Xpos + ((ysize - size)*DrawProp.pFont->Width);
break;
}
default:
{
refcolumn = Xpos;
break;
}
}
/* Send the string character by character on lCD */
while ((*pText != 0) & (((BSP_LCD_GetXSize() - (counter*DrawProp.pFont->Width)) & 0xFFFF) >= DrawProp.pFont->Width))
{
/* Display one character on LCD */
BSP_LCD_DisplayChar(refcolumn, Ypos, *pText);
/* Decrement the column position by 16 */
refcolumn += DrawProp.pFont->Width;
/* Point on the next character */
pText++;
counter++;
}
}
/**
* @brief Displays a character on the LCD.
* @param Line: Line where to display the character shape
* This parameter can be one of the following values:
* @arg 0..9: if the Current fonts is Font16x24
* @arg 0..19: if the Current fonts is Font12x12 or Font8x12
* @arg 0..29: if the Current fonts is Font8x8
* @param pText: Pointer to string to display on LCD
* @retval None
*/
void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *pText)
{
BSP_LCD_DisplayStringAt(0, LINE(Line),pText, LEFT_MODE);
}
/**
* @brief Reads an LCD pixel.
* @param Xpos: X position
* @param Ypos: Y position
* @retval RGB pixel color
*/
uint16_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos)
{
uint16_t ret = 0;
if(lcd_drv->ReadPixel != NULL)
{
ret = lcd_drv->ReadPixel(Xpos, Ypos);
}
return ret;
}
/**
* @brief Draws an horizontal line.
* @param Xpos: X position
* @param Ypos: Y position
* @param Length: Line length
* @retval None
*/
void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint32_t index = 0;
if(lcd_drv->DrawHLine != NULL)
{
lcd_drv->DrawHLine(DrawProp.TextColor, Ypos, Xpos, Length);
}
else
{
for(index = 0; index < Length; index++)
{
BSP_LCD_DrawPixel((Ypos + index), Xpos, DrawProp.TextColor);
}
}
}
/**
* @brief Draws a vertical line.
* @param Xpos: X position
* @param Ypos: Y position
* @param Length: Line length
* @retval None
*/
void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length)
{
uint32_t index = 0;
if(lcd_drv->DrawVLine != NULL)
{
LCD_SetDisplayWindow(Ypos, Xpos, 1, Length);
lcd_drv->DrawVLine(DrawProp.TextColor, Ypos, Xpos, Length);
LCD_SetDisplayWindow(0, 0, BSP_LCD_GetXSize(), BSP_LCD_GetYSize());
}
else
{
for(index = 0; index < Length; index++)
{
BSP_LCD_DrawPixel(Ypos, Xpos + index, DrawProp.TextColor);
}
}
}
/**
* @brief Draws an uni-line (between two points).
* @param X1: Point 1 X position
* @param Y1: Point 1 Y position
* @param X2: Point 2 X position
* @param Y2: Point 2 Y position
* @retval None
*/
void BSP_LCD_DrawLine(uint16_t X1, uint16_t Y1, uint16_t X2, uint16_t Y2)
{
int16_t deltax = 0, deltay = 0, x = 0, y = 0, xinc1 = 0, xinc2 = 0,
yinc1 = 0, yinc2 = 0, den = 0, num = 0, numadd = 0, numpixels = 0,
curpixel = 0;
deltax = ABS(Y2 - Y1); /* The difference between the x's */
deltay = ABS(X2 - X1); /* The difference between the y's */
x = Y1; /* Start x off at the first pixel */
y = X1; /* Start y off at the first pixel */
if (Y2 >= Y1) /* The x-values are increasing */
{
xinc1 = 1;
xinc2 = 1;
}
else /* The x-values are decreasing */
{
xinc1 = -1;
xinc2 = -1;
}
if (X2 >= X1) /* The y-values are increasing */
{
yinc1 = 1;
yinc2 = 1;
}
else /* The y-values are decreasing */
{
yinc1 = -1;
yinc2 = -1;
}
if (deltax >= deltay) /* There is at least one x-value for every y-value */
{
xinc1 = 0; /* Don't change the x when numerator >= denominator */
yinc2 = 0; /* Don't change the y for every iteration */
den = deltax;
num = deltax / 2;
numadd = deltay;
numpixels = deltax; /* There are more x-values than y-values */
}
else /* There is at least one y-value for every x-value */
{
xinc2 = 0; /* Don't change the x for every iteration */
yinc1 = 0; /* Don't change the y when numerator >= denominator */
den = deltay;
num = deltay / 2;
numadd = deltax;
numpixels = deltay; /* There are more y-values than x-values */
}
for (curpixel = 0; curpixel <= numpixels; curpixel++)
{
BSP_LCD_DrawPixel(x, y, DrawProp.TextColor); /* Draw the current pixel */
num += numadd; /* Increase the numerator by the top of the fraction */
if (num >= den) /* Check if numerator >= denominator */
{
num -= den; /* Calculate the new numerator value */
x += xinc1; /* Change the x as appropriate */
y += yinc1; /* Change the y as appropriate */
}
x += xinc2; /* Change the x as appropriate */
y += yinc2; /* Change the y as appropriate */
}
}
/**
* @brief Draws a rectangle.
* @param Xpos: X position
* @param Ypos: Y position
* @param Width: Rectangle width
* @param Height: Rectangle height
* @retval None
*/
void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
{
/* Draw horizontal lines */
BSP_LCD_DrawHLine(Xpos, Ypos, Width);
BSP_LCD_DrawHLine(Xpos, (Ypos+ Height), Width);
/* Draw vertical lines */
BSP_LCD_DrawVLine(Xpos, Ypos, Height);
BSP_LCD_DrawVLine((Xpos + Width), Ypos, Height);
}
/**
* @brief Draws a circle.
* @param Xpos: X position
* @param Ypos: Y position
* @param Radius: Circle radius
* @retval None
*/
void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius)
{
int32_t decision; /* Decision Variable */
uint32_t curx; /* Current X Value */
uint32_t cury; /* Current Y Value */
decision = 3 - (Radius << 1);
curx = 0;
cury = Radius;
while (curx <= cury)
{
BSP_LCD_DrawPixel((Ypos + curx), (Xpos - cury), DrawProp.TextColor);
BSP_LCD_DrawPixel((Ypos - curx), (Xpos - cury), DrawProp.TextColor);
BSP_LCD_DrawPixel((Ypos + cury), (Xpos - curx), DrawProp.TextColor);
BSP_LCD_DrawPixel((Ypos - cury), (Xpos - curx), DrawProp.TextColor);
BSP_LCD_DrawPixel((Ypos + curx), (Xpos + cury), DrawProp.TextColor);
BSP_LCD_DrawPixel((Ypos - curx), (Xpos + cury), DrawProp.TextColor);
BSP_LCD_DrawPixel((Ypos + cury), (Xpos + curx), DrawProp.TextColor);
BSP_LCD_DrawPixel((Ypos - cury), (Xpos + curx), DrawProp.TextColor);
/* Initialize the font */
BSP_LCD_SetFont(&LCD_DEFAULT_FONT);
if (decision < 0)
{
decision += (curx << 2) + 6;
}
else
{
decision += ((curx - cury) << 2) + 10;
cury--;
}
curx++;
}
}
/**
* @brief Draws an poly-line (between many points).
* @param pPoints: Pointer to the points array
* @param PointCount: Number of points
* @retval None
*/
void BSP_LCD_DrawPolygon(pPoint pPoints, uint16_t PointCount)
{
int16_t x = 0, y = 0;
if(PointCount < 2)
{
return;
}
BSP_LCD_DrawLine(pPoints->X, pPoints->Y, (pPoints+PointCount-1)->X, (pPoints+PointCount-1)->Y);
while(--PointCount)
{
x = pPoints->X;
y = pPoints->Y;
pPoints++;
BSP_LCD_DrawLine(x, y, pPoints->X, pPoints->Y);
}
}
/**
* @brief Draws an ellipse on LCD.
* @param Xpos: X position
* @param Ypos: Y position
* @param XRadius: Ellipse X radius
* @param YRadius: Ellipse Y radius
* @retval None
*/
void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius)
{
int x = 0, y = -XRadius, err = 2-2*YRadius, e2;
float k = 0, rad1 = 0, rad2 = 0;
rad1 = YRadius;
rad2 = XRadius;
k = (float)(rad2/rad1);
do {
BSP_LCD_DrawPixel((Ypos-(uint16_t)(x/k)), (Xpos+y), DrawProp.TextColor);
BSP_LCD_DrawPixel((Ypos+(uint16_t)(x/k)), (Xpos+y), DrawProp.TextColor);
BSP_LCD_DrawPixel((Ypos+(uint16_t)(x/k)), (Xpos-y), DrawProp.TextColor);
BSP_LCD_DrawPixel((Ypos-(uint16_t)(x/k)), (Xpos-y), DrawProp.TextColor);
e2 = err;
if (e2 <= x) {
err += ++x*2+1;
if (-y == x && e2 <= y) e2 = 0;
}
if (e2 > y) err += ++y*2+1;
}
while (y <= 0);
}
/**
* @brief Draws a bitmap picture loaded in the internal Flash (32 bpp).
* @param Xpos: Bmp X position in the LCD
* @param Ypos: Bmp Y position in the LCD
* @param pBmp: Pointer to Bmp picture address in the internal Flash
* @retval None
*/
void BSP_LCD_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pBmp)
{
uint32_t height = 0, width = 0;
/* Read bitmap width */
width = pBmp[18] + (pBmp[19] << 8) + (pBmp[20] << 16) + (pBmp[21] << 24);
/* Read bitmap height */
height = pBmp[22] + (pBmp[23] << 8) + (pBmp[24] << 16) + (pBmp[25] << 24);
/* Remap Ypos, hx8347d works with inverted X in case of bitmap */
/* X = 0, cursor is on Bottom corner */
if(lcd_drv == &hx8347d_drv)
{
Ypos = BSP_LCD_GetYSize() - Ypos - height;
}
LCD_SetDisplayWindow(Ypos, Xpos, width, height);
if(lcd_drv->DrawBitmap != NULL)
{
lcd_drv->DrawBitmap(Ypos, Xpos, pBmp);
}
LCD_SetDisplayWindow(0, 0, BSP_LCD_GetXSize(), BSP_LCD_GetYSize());
}
/**
* @brief Draws a full rectangle.
* @param Xpos: X position
* @param Ypos: Y position
* @param Width: Rectangle width
* @param Height: Rectangle height
* @retval None
*/
void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
{
BSP_LCD_SetTextColor(DrawProp.TextColor);
do
{
BSP_LCD_DrawHLine(Xpos, Ypos++, Width);
}
while(Height--);
}
/**
* @brief Draws a full circle.
* @param Xpos: X position
* @param Ypos: Y position
* @param Radius: Circle radius
* @retval None
*/
void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius)
{
int32_t decision; /* Decision Variable */
uint32_t curx; /* Current X Value */
uint32_t cury; /* Current Y Value */
decision = 3 - (Radius << 1);
curx = 0;
cury = Radius;
BSP_LCD_SetTextColor(DrawProp.TextColor);
while (curx <= cury)
{
if(cury > 0)
{
BSP_LCD_DrawVLine(Xpos + curx, Ypos - cury, 2*cury);
BSP_LCD_DrawVLine(Xpos - curx, Ypos - cury, 2*cury);
}
if(curx > 0)
{
BSP_LCD_DrawVLine(Xpos - cury, Ypos - curx, 2*curx);
BSP_LCD_DrawVLine(Xpos + cury, Ypos - curx, 2*curx);
}
if (decision < 0)
{
decision += (curx << 2) + 6;
}
else
{
decision += ((curx - cury) << 2) + 10;
cury--;
}
curx++;
}
BSP_LCD_SetTextColor(DrawProp.TextColor);
BSP_LCD_DrawCircle(Xpos, Ypos, Radius);
}
/**
* @brief Draws a full ellipse.
* @param Xpos: X position
* @param Ypos: Y position
* @param XRadius: Ellipse X radius
* @param YRadius: Ellipse Y radius
* @retval None
*/
void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius)
{
int x = 0, y = -XRadius, err = 2-2*YRadius, e2;
float k = 0, rad1 = 0, rad2 = 0;
rad1 = YRadius;
rad2 = XRadius;
k = (float)(rad2/rad1);
do
{
BSP_LCD_DrawVLine((Xpos+y), (Ypos-(uint16_t)(x/k)), (2*(uint16_t)(x/k) + 1));
BSP_LCD_DrawVLine((Xpos-y), (Ypos-(uint16_t)(x/k)), (2*(uint16_t)(x/k) + 1));
e2 = err;
if (e2 <= x)
{
err += ++x*2+1;
if (-y == x && e2 <= y) e2 = 0;
}
if (e2 > y) err += ++y*2+1;
}
while (y <= 0);
}
/**
* @brief Enables the display.
* @retval None
*/
void BSP_LCD_DisplayOn(void)
{
lcd_drv->DisplayOn();
}
/**
* @brief Disables the display.
* @retval None
*/
void BSP_LCD_DisplayOff(void)
{
lcd_drv->DisplayOff();
}
/**
* @brief Draws a pixel on LCD.
* @param Xpos: X position
* @param Ypos: Y position
* @param RGBCode: Pixel color in RGB mode (5-6-5)
* @retval None
*/
void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode)
{
if(lcd_drv->WritePixel != NULL)
{
lcd_drv->WritePixel(Xpos, Ypos, RGBCode);
}
}
/**
* @}
*/
/******************************************************************************
Static Function
*******************************************************************************/
/** @addtogroup STM32G0C1E_EVAL_LCD_Private_Functions
* @{
*/
/**
* @brief Draws a character on LCD.
* @param Xpos: Line where to display the character shape
* @param Ypos: Start column address
* @param pChar: Pointer to the character data
* @retval None
*/
static void LCD_DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *pChar)
{
uint32_t counterh = 0, counterw = 0, index = 0;
uint16_t height = 0, width = 0;
uint8_t offset = 0;
uint8_t *pchar = NULL;
uint32_t line = 0;
height = DrawProp.pFont->Height;
width = DrawProp.pFont->Width;
/* Fill bitmap header*/
*(uint16_t *) (bitmap + 2) = (uint16_t)(height*width*2+OFFSET_BITMAP);
*(uint16_t *) (bitmap + 4) = (uint16_t)((height*width*2+OFFSET_BITMAP)>>16);
*(uint16_t *) (bitmap + 10) = OFFSET_BITMAP;
*(uint16_t *) (bitmap + 18) = (uint16_t)(width);
*(uint16_t *) (bitmap + 20) = (uint16_t)((width)>>16);
*(uint16_t *) (bitmap + 22) = (uint16_t)(height);
*(uint16_t *) (bitmap + 24) = (uint16_t)((height)>>16);
offset = 8 *((width + 7)/8) - width ;
for(counterh = 0; counterh < height; counterh++)
{
pchar = ((uint8_t *)pChar + (width + 7)/8 * counterh);
if(((width + 7)/8) == 3)
{
line = (pchar[0]<< 16) | (pchar[1]<< 8) | pchar[2];
}
if(((width + 7)/8) == 2)
{
line = (pchar[0]<< 8) | pchar[1];
}
if(((width + 7)/8) == 1)
{
line = pchar[0];
}
for (counterw = 0; counterw < width; counterw++)
{
/* Image in the bitmap is written from the bottom to the top */
/* Need to invert image in the bitmap */
index = (((height-counterh-1)*width)+(counterw))*2+OFFSET_BITMAP;
if(line & (1 << (width- counterw + offset- 1)))
{
bitmap[index] = (uint8_t)DrawProp.TextColor;
bitmap[index+1] = (uint8_t)(DrawProp.TextColor >> 8);
}
else
{
bitmap[index] = (uint8_t)DrawProp.BackColor;
bitmap[index+1] = (uint8_t)(DrawProp.BackColor >> 8);
}
}
}
BSP_LCD_DrawBitmap(Ypos, Xpos, bitmap);
}
/**
* @brief Sets display window.
* @param Xpos: LCD X position
* @param Ypos: LCD Y position
* @param Width: LCD window width
* @param Height: LCD window height
* @retval None
*/
static void LCD_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
{
if(lcd_drv->SetDisplayWindow != NULL)
{
lcd_drv->SetDisplayWindow(Xpos, Ypos, Width, Height);
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,208 @@
/**
******************************************************************************
* @file STM32G0C1E_EVAL_lcd.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the
* STM32G0C1E_EVAL_lcd.c driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2020 STMicroelectronics</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 STM32G0C1E_EVAL_LCD_H
#define STM32G0C1E_EVAL_LCD_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32g0c1e_eval.h"
/* Include LCD component Driver */
#include "../Components/hx8347d/hx8347d.h"
#include "../../../Utilities/Fonts/fonts.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32G0C1E_EVAL
* @{
*/
/** @defgroup STM32G0C1E_EVAL_LCD STM32G0C1E_EVAL LCD
* @{
*/
/** @defgroup STM32G0C1E_EVAL_LCD_Exported_Types Exported Types
* @{
*/
typedef struct
{
uint32_t TextColor;
uint32_t BackColor;
sFONT *pFont;
} LCD_DrawPropTypeDef;
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_LCD_Exported_Constants Exported Constants
* @{
*/
/**
* @brief LCD status structure definition
*/
#define LCD_OK 0x00
#define LCD_ERROR 0x01
#define LCD_TIMEOUT 0x02
typedef struct
{
int16_t X;
int16_t Y;
} Point, * pPoint;
/**
* @brief Line mode structures definition
*/
typedef enum
{
CENTER_MODE = 0x01, /*!< Center mode */
RIGHT_MODE = 0x02, /*!< Right mode */
LEFT_MODE = 0x03, /*!< Left mode */
NO_MODE
} Line_ModeTypdef;
/**
* @brief LCD color
*/
#define LCD_COLOR_BLUE 0x001F
#define LCD_COLOR_GREEN 0x07E0
#define LCD_COLOR_RED 0xF800
#define LCD_COLOR_CYAN 0x07FF
#define LCD_COLOR_MAGENTA 0xF81F
#define LCD_COLOR_YELLOW 0xFFE0
#define LCD_COLOR_LIGHTBLUE 0x841F
#define LCD_COLOR_LIGHTGREEN 0x87F0
#define LCD_COLOR_LIGHTRED 0xFC10
#define LCD_COLOR_LIGHTCYAN 0x87FF
#define LCD_COLOR_LIGHTMAGENTA 0xFC1F
#define LCD_COLOR_LIGHTYELLOW 0xFFF0
#define LCD_COLOR_DARKBLUE 0x0010
#define LCD_COLOR_DARKGREEN 0x0400
#define LCD_COLOR_DARKRED 0x8000
#define LCD_COLOR_DARKCYAN 0x0410
#define LCD_COLOR_DARKMAGENTA 0x8010
#define LCD_COLOR_DARKYELLOW 0x8400
#define LCD_COLOR_WHITE 0xFFFF
#define LCD_COLOR_LIGHTGRAY 0xD69A
#define LCD_COLOR_GRAY 0x8410
#define LCD_COLOR_DARKGRAY 0x4208
#define LCD_COLOR_BLACK 0x0000
#define LCD_COLOR_BROWN 0xA145
#define LCD_COLOR_ORANGE 0xFD20
/* Macro to convert ST COLOR in RGB 24BIT definition to 16BIT RGB (R5bit,G6bit,B5bit) */
#define LCD_R(__R_COLOR__) (((__R_COLOR__>>3)&0x1F)<<11)
#define LCD_G(__G_COLOR__) (((__G_COLOR__>>2)&0x3F)<<5)
#define LCD_B(__B_COLOR__) ((__B_COLOR__>>3)&0x1F)
/* Definition of Official ST COLOR */
#define LCD_COLOR_ST_BLUE_DARK (LCD_R(0x00)|LCD_G(0x20)|LCD_B(0x52))
#define LCD_COLOR_ST_BLUE (LCD_R(0x39)|LCD_G(0xA9)|LCD_B(0xDC))
#define LCD_COLOR_ST_BLUE_LIGHT (LCD_R(0xD1)|LCD_G(0xE4)|LCD_B(0xF3))
#define LCD_COLOR_ST_GREEN_LIGHT (LCD_R(0xBB)|LCD_G(0xCC)|LCD_B(0x01))
#define LCD_COLOR_ST_GREEN_DARK (LCD_R(0x00)|LCD_G(0x3D)|LCD_B(0x14))
#define LCD_COLOR_ST_YELLOW (LCD_R(0xFF)|LCD_G(0xD3)|LCD_B(0x00))
#define LCD_COLOR_ST_BROWN (LCD_R(0x5C)|LCD_G(0x09)|LCD_B(0x15))
#define LCD_COLOR_ST_PINK (LCD_R(0xD4)|LCD_G(0x00)|LCD_B(0x7A))
#define LCD_COLOR_ST_PURPLE (LCD_R(0x59)|LCD_G(0x0D)|LCD_B(0x58))
#define LCD_COLOR_ST_GRAY_DARK (LCD_R(0x4F)|LCD_G(0x52)|LCD_B(0x51))
#define LCD_COLOR_ST_GRAY (LCD_R(0x90)|LCD_G(0x98)|LCD_B(0x9E))
#define LCD_COLOR_ST_GRAY_LIGHT (LCD_R(0xB9)|LCD_G(0xC4)|LCD_B(0xCA))
/**
* @brief LCD default font
*/
#ifndef LCD_DEFAULT_FONT
#define LCD_DEFAULT_FONT Font8
#endif
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_LCD_Exported_Functions Exported Functions
* @{
*/
uint8_t BSP_LCD_Init(void);
uint32_t BSP_LCD_GetXSize(void);
uint32_t BSP_LCD_GetYSize(void);
uint16_t BSP_LCD_GetTextColor(void);
uint16_t BSP_LCD_GetBackColor(void);
void BSP_LCD_SetTextColor(__IO uint16_t Color);
void BSP_LCD_SetBackColor(__IO uint16_t Color);
void BSP_LCD_SetFont(sFONT *pFonts);
sFONT *BSP_LCD_GetFont(void);
void BSP_LCD_Clear(uint16_t Color);
void BSP_LCD_ClearStringLine(uint16_t Line);
void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *pText);
void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *pText, Line_ModeTypdef Mode);
void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii);
void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode);
uint16_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos);
void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length);
void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length);
void BSP_LCD_DrawLine(uint16_t X1, uint16_t Y1, uint16_t X2, uint16_t Y2);
void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius);
void BSP_LCD_DrawPolygon(pPoint pPoints, uint16_t PointCount);
void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius);
void BSP_LCD_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pBmp);
void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius);
void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius);
void BSP_LCD_DisplayOff(void);
void BSP_LCD_DisplayOn(void);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32G0C1E_EVAL_LCD_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,936 @@
/**
******************************************************************************
* @file stm32g0c1e_eval_mux.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the Type-C
* MUX associated to a Type-C receptacle. These functions allow for
* reconfiguring the pins of the Type-C receptacle when the related
* Type-C port operate in DisplayPort alternate mode or
* when it is used as a USB 3.1 to USB Type-C adapter.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2020 STMicroelectronics</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 <stdio.h>
#include "stm32g0c1e_eval.h"
#include "stm32g0c1e_eval_mux.h"
#include "stm32g0xx_hal.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32G0C1E_EVAL
* @{
*/
/** @addtogroup STM32G0C1E_EVAL_MUX
* @{
*/
/** @defgroup STM32G0C1E_EVAL_MUX_Private_Typedef Private Typedef
* @{
*/
typedef enum {
MUX_NOT_INITIALIZED = 0,
MUX_INITIALIZED
} MUX_StateTypedef;
typedef struct {
MUX_StateTypedef State;
TYPECSWITCH_Drv_t * TypeCSwitch_Drv;
uint16_t I2C_Address_TypeCSwitch;
DPREDRIVER_Drv_t * DPRedriver_Drv;
uint16_t I2C_Address_DPRedriver;
} MuxInfoTypeDef;
typedef struct {
#if defined(TUSB546_DEBUG)
TUSB546_RegistersTypeDef TUSB546_Registers;
#endif /* TUSB546_DEBUG */
#if defined(CBTL08GP053_DEBUG)
CBTL08GP053_RegistersTypeDef CBTL08GP053_Registers;
#endif /* CBTL08GP053_DEBUG */
#if defined(SN65DP141_DEBUG)
SN65DP141_RegistersTypeDef SN65DP141_Registers;
#endif /* CBTL08GP053_DEBUG */
MUX_HPDCallbackFuncTypeDef * pfnHPDCallbackFunc;
MUX_HPDStateTypeDef HPDState;
MuxInfoTypeDef MuxInfo[TYPE_C_MUX_NB];
} ContextTypeDef;
typedef enum
{
DET_HPD_SOURCE = 0
} DetectId_TypeDef;
typedef enum
{
SEL_HPDIN = 0
} SelectId_TypeDef;
typedef enum {
DET_STATE_LOW = 0,
DET_STATE_HIGH
} MUX_DETState_TypeDef;
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_MUX_Private_Macros Private Macros
* @{
*/
#define DETx_GPIO_CLK_ENABLE(__DET__) do { if((__DET__) == DET_HPD_SOURCE) DET_HPD_SOURCE_GPIO_CLK_ENABLE();} while(0)
#define SELx_GPIO_CLK_ENABLE(__SEL__) do { if((__SEL__) == SEL_HPDIN) SEL_HPDIN_GPIO_CLK_ENABLE();} while(0)
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_MUX_Private_Variables Private Variables
* @{
*/
static const TYPECSWITCH_Mode_t ModeSelect[2][13] =
{
/* PLUG_ORIENTATION_NORMAL */
{
DFP_D_PIN_ASSIGNMENT_A_NORMAL, /* DFP_PIN_ASSIGNMMENT_A */
DFP_D_PIN_ASSIGNMENT_B_NORMAL, /* DFP_PIN_ASSIGNMMENT_B */
DFP_D_PIN_ASSIGNMENT_C_NORMAL, /* DFP_PIN_ASSIGNMMENT_C */
DFP_D_PIN_ASSIGNMENT_D_NORMAL, /* DFP_PIN_ASSIGNMMENT_D */
DFP_D_PIN_ASSIGNMENT_E_NORMAL, /* DFP_PIN_ASSIGNMMENT_E */
DFP_D_PIN_ASSIGNMENT_F_NORMAL, /* DFP_PIN_ASSIGNMMENT_F */
UFP_D_PIN_ASSIGNMENT_A_NORMAL, /* UFP_PIN_ASSIGNMMENT_A */
UFP_D_PIN_ASSIGNMENT_B_NORMAL, /* UFP_PIN_ASSIGNMMENT_B */
UFP_D_PIN_ASSIGNMENT_C_NORMAL, /* UFP_PIN_ASSIGNMMENT_C */
UFP_D_PIN_ASSIGNMENT_D_NORMAL, /* UFP_PIN_ASSIGNMMENT_D */
UFP_D_PIN_ASSIGNMENT_E_NORMAL, /* UFP_PIN_ASSIGNMMENT_E */
UFP_D_PIN_ASSIGNMENT_F_NORMAL, /* UFP_PIN_ASSIGNMMENT_F */
USB_NORMAL /* USB_ONLY_PIN_ASSIGNMMENT */
},
/* PLUG_ORIENTATION_FLIPPED */
{
DFP_D_PIN_ASSIGNMENT_A_FLIPPED, /* DFP_PIN_ASSIGNMMENT_A */
DFP_D_PIN_ASSIGNMENT_B_FLIPPED, /* DFP_PIN_ASSIGNMMENT_B */
DFP_D_PIN_ASSIGNMENT_C_FLIPPED, /* DFP_PIN_ASSIGNMMENT_C */
DFP_D_PIN_ASSIGNMENT_D_FLIPPED, /* DFP_PIN_ASSIGNMMENT_D */
DFP_D_PIN_ASSIGNMENT_E_FLIPPED, /* DFP_PIN_ASSIGNMMENT_E */
DFP_D_PIN_ASSIGNMENT_F_FLIPPED, /* DFP_PIN_ASSIGNMMENT_F */
UFP_D_PIN_ASSIGNMENT_A_FLIPPED, /* UFP_PIN_ASSIGNMMENT_A */
UFP_D_PIN_ASSIGNMENT_B_FLIPPED, /* UFP_PIN_ASSIGNMMENT_B */
UFP_D_PIN_ASSIGNMENT_C_FLIPPED, /* UFP_PIN_ASSIGNMMENT_C */
UFP_D_PIN_ASSIGNMENT_D_FLIPPED, /* UFP_PIN_ASSIGNMMENT_D */
UFP_D_PIN_ASSIGNMENT_E_FLIPPED, /* UFP_PIN_ASSIGNMMENT_E */
UFP_D_PIN_ASSIGNMENT_F_FLIPPED, /* UFP_PIN_ASSIGNMMENT_F */
USB_FLIPPED /* USB_ONLY_PIN_ASSIGNMMENT */
}
};
/**
* @brief SEL variables
*/
static GPIO_TypeDef* SEL_PORT[SELn] = {
SEL_HPDIN_GPIO_PORT,
};
static uint16_t SEL_PIN[SELn] = {
SEL_HPDIN_PIN,
};
/* BSP PWR contextual data */
static ContextTypeDef Context =
{
.HPDState = HPD_STATE_LOW,
.pfnHPDCallbackFunc = (MUX_HPDCallbackFuncTypeDef *)NULL,
.MuxInfo =
{
/* TYPE_C_MUX_1 */
{
.State = MUX_NOT_INITIALIZED,
.TypeCSwitch_Drv = &tusb546_drv_CrossSwitch,
.I2C_Address_TypeCSwitch = MUX_1_TYPEC_SWITCH_I2C_ADDRESS,
.DPRedriver_Drv = &tusb546_drv_LinearRedriver,
.I2C_Address_DPRedriver = MUX_1_DP_REDRIVER_I2C_ADDRESS
},
/* TYPE_C_MUX_2 */
{
.State = MUX_NOT_INITIALIZED,
.TypeCSwitch_Drv = &cbtl08gp053_drv,
.I2C_Address_TypeCSwitch = MUX_2_TYPEC_SWITCH_I2C_ADDRESS,
.DPRedriver_Drv = &sn65dp141_drv,
.I2C_Address_DPRedriver = MUX_2_DP_REDRIVER_I2C_ADDRESS
}
}
};
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_MUX_Private_Functions Private Functions
* @{
*/
static void MUX_DET_Init(void);
static void MUX_DET_DeInit(void);
static MUX_DETState_TypeDef MUX_DET_GetState(void);
static void MUX_SEL_Init(SelectId_TypeDef Sel);
static void MUX_SEL_DeInit(SelectId_TypeDef Sel);
static void MUX_SEL_On(SelectId_TypeDef Sel);
static void MUX_SEL_Off(SelectId_TypeDef Sel);
static void MUX_DebounceTimerSetConfig(uint32_t DebounceTime);
static void MUX_DebounceTimerResetConfig(void);
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_MUX_Exported_Variables Exported Variables
* @{
*/
TIM_HandleTypeDef htim = {.Instance = DEBOUNCE_TIM_INSTANCE};
/**
* @}
*/
/** @addtogroup STM32G0C1E_EVAL_MUX_Exported_Functions
* @{
*/
/**
* @brief Initialize the hardware resources used by the Type-C MUX
* assigned to a given Type-C MUX.
* @param TypeCMuxId Type-C MUX identifier
* This parameter can be take one of the following values:
* @arg TYPE_C_MUX_1
* @arg TYPE_C_MUX_2
* @retval mux status
*/
MUX_StatusTypeDef BSP_MUX_Init(MUX_TypeCMuxIdTypeDef TypeCMuxId)
{
uint32_t ret = 0;
if (Context.MuxInfo[TypeCMuxId].State == MUX_NOT_INITIALIZED)
{
switch (TypeCMuxId)
{
case TYPE_C_MUX_1:
case TYPE_C_MUX_2:
/* USB Type-C Crossbar Switch initialization */
ret += Context.MuxInfo[TypeCMuxId].TypeCSwitch_Drv->Init(Context.MuxInfo[TypeCMuxId].I2C_Address_TypeCSwitch);
/* DisplayPort Linear Redriver initialization */
ret += Context.MuxInfo[TypeCMuxId].DPRedriver_Drv->Init(Context.MuxInfo[TypeCMuxId].I2C_Address_DPRedriver);
if (TypeCMuxId == TYPE_C_MUX_1)
{
MUX_SEL_Init(SEL_HPDIN);
}
else
{
/* DET_HPD_SOURCE */
MUX_DET_Init();
}
/* Initialize the debounce timer (if not done already) */
if ((Context.MuxInfo[TYPE_C_MUX_1].State == MUX_NOT_INITIALIZED) &&
(Context.MuxInfo[TYPE_C_MUX_2].State == MUX_NOT_INITIALIZED))
{
MUX_DebounceTimerSetConfig(DEBOUNCE_TIME);
}
/* Update Context */
Context.MuxInfo[TypeCMuxId].State = MUX_INITIALIZED;
break;
default:
ret++;
break;
}
}
return (ret == 0) ? MUX_OK : MUX_ERROR;
}
/**
* @brief Free the hardware resources used by the Type-C MUX
* assigned to a given Type-C MUX.
* @param TypeCMuxId Type-C MUX identifier
* This parameter can be take one of the following values:
* @arg TYPE_C_MUX_1
* @arg TYPE_C_MUX_2
* @retval mux status
*/
MUX_StatusTypeDef BSP_MUX_DeInit(MUX_TypeCMuxIdTypeDef TypeCMuxId)
{
uint32_t ret = 0;
if (Context.MuxInfo[TypeCMuxId].State == MUX_INITIALIZED)
{
switch (TypeCMuxId)
{
case TYPE_C_MUX_1:
case TYPE_C_MUX_2:
/* USB Type-C Crossbar Switch de-initialization */
Context.MuxInfo[TypeCMuxId].TypeCSwitch_Drv->DeInit(Context.MuxInfo[TypeCMuxId].I2C_Address_TypeCSwitch);
/* DisplayPort Linear Redriver de-initialization */
Context.MuxInfo[TypeCMuxId].DPRedriver_Drv->DeInit(Context.MuxInfo[TypeCMuxId].I2C_Address_DPRedriver);
if (TypeCMuxId == TYPE_C_MUX_1)
{
MUX_DebounceTimerResetConfig();
MUX_SEL_DeInit(SEL_HPDIN);
}
else
{
/* DET_HPD_SOURCE */
MUX_DET_DeInit();
}
/* Update Context */
Context.MuxInfo[TypeCMuxId].State = MUX_NOT_INITIALIZED;
/* De-initialize the debounce timer (if not required anymore)*/
if ((Context.MuxInfo[TYPE_C_MUX_1].State == MUX_NOT_INITIALIZED) &&
(Context.MuxInfo[TYPE_C_MUX_2].State == MUX_NOT_INITIALIZED))
{
MUX_DebounceTimerResetConfig();
}
break;
default:
ret++;
break;
}
}
return (ret == 0) ? MUX_OK : MUX_ERROR;
}
/**
* @brief Power on the Type-C MUX.
* @param TypeCMuxId Type-C MUX identifier
* This parameter can be take one of the following values:
* @arg TYPE_C_MUX_1
* @arg TYPE_C_MUX_2
* @retval mux status
*/
MUX_StatusTypeDef BSP_MUX_Enable(MUX_TypeCMuxIdTypeDef TypeCMuxId)
{
uint32_t ret = 0;
switch (TypeCMuxId)
{
case TYPE_C_MUX_1:
case TYPE_C_MUX_2:
/* Power on USB Type-C Crossbar Switch */
ret += Context.MuxInfo[TypeCMuxId].TypeCSwitch_Drv->PowerOn(Context.MuxInfo[TypeCMuxId].I2C_Address_TypeCSwitch);
/* Power on DisplayPort Linear Redriver */
ret += Context.MuxInfo[TypeCMuxId].DPRedriver_Drv->PowerOn(Context.MuxInfo[TypeCMuxId].I2C_Address_DPRedriver);
break;
default:
ret++;
break;
}
return (ret == 0) ? MUX_OK : MUX_ERROR;
}
/**
* @brief Power down the Type-C MUX.
* @param TypeCMuxId Type-C MUX identifier
* This parameter can be take one of the following values:
* @arg TYPE_C_MUX_1
* @arg TYPE_C_MUX_2
* @retval mux status
*/
MUX_StatusTypeDef BSP_MUX_Disable(MUX_TypeCMuxIdTypeDef TypeCMuxId)
{
uint32_t ret = 0;
switch (TypeCMuxId)
{
case TYPE_C_MUX_1:
case TYPE_C_MUX_2:
/* Power off USB Type-C Crossbar Switch */
ret += Context.MuxInfo[TypeCMuxId].TypeCSwitch_Drv->PowerOff(Context.MuxInfo[TypeCMuxId].I2C_Address_TypeCSwitch);
/* Power down DisplayPort Linear Redriver */
ret += Context.MuxInfo[TypeCMuxId].DPRedriver_Drv->PowerOff(Context.MuxInfo[TypeCMuxId].I2C_Address_DPRedriver);
break;
default:
ret++;
break;
}
return (ret == 0) ? MUX_OK : MUX_ERROR;
}
/**
* @brief Set the pin assignment of the USB Type-C connector when it operates
* in one of the following mode:
* DFP_D: Downstream Facing Port associated with a DisplayPort Source device
* UFP_D: Upstream Facing Port associated with a DisplayPort Source device
* @param TypeCMuxId Type-C MUX identifier
* This parameter can be take one of the following values:
* @arg TYPE_C_MUX_1
* @arg TYPE_C_MUX_2
* @param TypeCPlugOrientation Type-C plug orientation
* This parameter can be take one of the following values:
* @arg PLUG_ORIENTATION_NORMAL
* @arg PLUG_ORIENTATION_FLIPPED
* @param TypeCConnectorPinAssignment Type-C connector pin assignment
* This parameter can be take one of the following values:
* @arg DFP_PIN_ASSIGNMMENT_A
* @arg DFP_PIN_ASSIGNMMENT_B
* @arg DFP_PIN_ASSIGNMMENT_C
* @arg DFP_PIN_ASSIGNMMENT_D
* @arg DFP_PIN_ASSIGNMMENT_E
* @arg DFP_PIN_ASSIGNMMENT_F
* @arg UFP_PIN_ASSIGNMMENT_A
* @arg UFP_PIN_ASSIGNMMENT_B
* @arg UFP_PIN_ASSIGNMMENT_C
* @arg UFP_PIN_ASSIGNMMENT_D
* @arg UFP_PIN_ASSIGNMMENT_E
* @arg UFP_PIN_ASSIGNMMENT_F
* @arg USB_ONLY_PIN_ASSIGNMMENT
* @retval mux status
*/
MUX_StatusTypeDef BSP_MUX_SetDPPinAssignment(MUX_TypeCMuxIdTypeDef TypeCMuxId,
MUX_TypeCPlugOrientationTypeDef TypeCPlugOrientation,
MUX_TypeCConnectorPinAssignmentTypeDef TypeCConnectorPinAssignment)
{
uint32_t ret = 0;
TYPECSWITCH_Mode_t Mode;
Mode = ModeSelect[TypeCPlugOrientation][TypeCConnectorPinAssignment];
if (Context.MuxInfo[TypeCMuxId].TypeCSwitch_Drv->IsSupportedMode(Mode))
{
/* Set Alt. mode */
ret += Context.MuxInfo[TypeCMuxId].TypeCSwitch_Drv->SetMode(Context.MuxInfo[TypeCMuxId].I2C_Address_TypeCSwitch, Mode);
/* Enable Display Port channels (if required) */
switch(TypeCConnectorPinAssignment)
{
case USB_ONLY_PIN_ASSIGNMMENT:
/* no DP channel enabled */
ret += Context.MuxInfo[TypeCMuxId].DPRedriver_Drv->DisableChannel(Context.MuxInfo[TypeCMuxId].I2C_Address_DPRedriver, CHANNEL_DP0);
ret += Context.MuxInfo[TypeCMuxId].DPRedriver_Drv->DisableChannel(Context.MuxInfo[TypeCMuxId].I2C_Address_DPRedriver, CHANNEL_DP1);
ret += Context.MuxInfo[TypeCMuxId].DPRedriver_Drv->DisableChannel(Context.MuxInfo[TypeCMuxId].I2C_Address_DPRedriver, CHANNEL_DP2);
ret += Context.MuxInfo[TypeCMuxId].DPRedriver_Drv->DisableChannel(Context.MuxInfo[TypeCMuxId].I2C_Address_DPRedriver, CHANNEL_DP3);
break;
case DFP_PIN_ASSIGNMMENT_B:
case DFP_PIN_ASSIGNMMENT_D:
case DFP_PIN_ASSIGNMMENT_F:
case UFP_PIN_ASSIGNMMENT_B:
case UFP_PIN_ASSIGNMMENT_D:
case UFP_PIN_ASSIGNMMENT_F:
/* Enable Display Port ML0 and ML1 */
ret += Context.MuxInfo[TypeCMuxId].DPRedriver_Drv->EnableChannel(Context.MuxInfo[TypeCMuxId].I2C_Address_DPRedriver, CHANNEL_DP0);
ret += Context.MuxInfo[TypeCMuxId].DPRedriver_Drv->EnableChannel(Context.MuxInfo[TypeCMuxId].I2C_Address_DPRedriver, CHANNEL_DP1);
ret += Context.MuxInfo[TypeCMuxId].DPRedriver_Drv->DisableChannel(Context.MuxInfo[TypeCMuxId].I2C_Address_DPRedriver, CHANNEL_DP2);
ret += Context.MuxInfo[TypeCMuxId].DPRedriver_Drv->DisableChannel(Context.MuxInfo[TypeCMuxId].I2C_Address_DPRedriver, CHANNEL_DP3);
break;
case DFP_PIN_ASSIGNMMENT_A:
case DFP_PIN_ASSIGNMMENT_C:
case DFP_PIN_ASSIGNMMENT_E:
case UFP_PIN_ASSIGNMMENT_A:
case UFP_PIN_ASSIGNMMENT_C:
case UFP_PIN_ASSIGNMMENT_E:
/* Enable Display Port ML0, ML1, ML2 and ML3 */
ret += Context.MuxInfo[TypeCMuxId].DPRedriver_Drv->EnableChannel(Context.MuxInfo[TypeCMuxId].I2C_Address_DPRedriver, CHANNEL_DP0);
ret += Context.MuxInfo[TypeCMuxId].DPRedriver_Drv->EnableChannel(Context.MuxInfo[TypeCMuxId].I2C_Address_DPRedriver, CHANNEL_DP1);
ret += Context.MuxInfo[TypeCMuxId].DPRedriver_Drv->EnableChannel(Context.MuxInfo[TypeCMuxId].I2C_Address_DPRedriver, CHANNEL_DP2);
ret += Context.MuxInfo[TypeCMuxId].DPRedriver_Drv->EnableChannel(Context.MuxInfo[TypeCMuxId].I2C_Address_DPRedriver, CHANNEL_DP3);
break;
}
}
return (ret == 0) ? MUX_OK : MUX_ERROR;
}
/**
* @brief Set the equalizer gain for all the channels
* @param TypeCMuxId Type-C MUX identifier
* This parameter can be take one of the following values:
* @arg TYPE_C_MUX_1
* @arg TYPE_C_MUX_2
* @param EQGain Equalizer gain.
* TYPE_C_MUX_1: This parameter must be a value between 0x00 and @ref MUX_1_EQGAIN_MAX.
* TYPE_C_MUX_2: This parameter must be a value between 0x00 and @ref MUX_2_EQGAIN_MAX.
* @retval mux status
*/
MUX_StatusTypeDef BSP_MUX_SetEQGain(MUX_TypeCMuxIdTypeDef TypeCMuxId,
uint8_t EQGain)
{
uint32_t ret = 1;
if (((TYPE_C_MUX_1 == TypeCMuxId) && (MUX_1_EQGAIN_MAX >= EQGain))
|| ((TYPE_C_MUX_2 == TypeCMuxId) && (MUX_2_EQGAIN_MAX >= EQGain)))
{
ret = 0;
/* Set EQ gain for Port ML0, ML1, ML2 and ML3 */
ret += Context.MuxInfo[TypeCMuxId].DPRedriver_Drv->SetEQGain(Context.MuxInfo[TypeCMuxId].I2C_Address_DPRedriver, CHANNEL_DP0, EQGain);
ret += Context.MuxInfo[TypeCMuxId].DPRedriver_Drv->SetEQGain(Context.MuxInfo[TypeCMuxId].I2C_Address_DPRedriver, CHANNEL_DP1, EQGain);
ret += Context.MuxInfo[TypeCMuxId].DPRedriver_Drv->SetEQGain(Context.MuxInfo[TypeCMuxId].I2C_Address_DPRedriver, CHANNEL_DP2, EQGain);
ret += Context.MuxInfo[TypeCMuxId].DPRedriver_Drv->SetEQGain(Context.MuxInfo[TypeCMuxId].I2C_Address_DPRedriver, CHANNEL_DP3, EQGain);
}
return (ret == 0) ? MUX_OK : MUX_ERROR;
}
/**
* @brief Set the HPD level seen by the DP source device.
* @note This function is used to enable DisplayPort HPD signaling
* through PD messaging.
* @param TypeCMuxId Type-C MUX identifier
* This parameter can be take one of the following values:
* @arg TYPE_C_MUX_1
* @arg TYPE_C_MUX_2
* @param HPDState Hot Plud Detection (HPD) state
* This parameter can be take one of the following values:
* @arg HPD_STATE_LOW
* @arg HPD_STATE_HIGH
* @retval mux status
*/
MUX_StatusTypeDef BSP_MUX_SetHPDState(MUX_TypeCMuxIdTypeDef TypeCMuxId,
MUX_HPDStateTypeDef HPDState)
{
uint32_t ret = 0;
switch (TypeCMuxId)
{
case TYPE_C_MUX_1:
if(HPD_STATE_LOW == HPDState)
{
MUX_SEL_Off(SEL_HPDIN);
}
else
{
MUX_SEL_On(SEL_HPDIN);
}
break;
default:
ret++;
break;
}
return (ret == 0) ? MUX_OK : MUX_ERROR;
}
/**
* @brief Retrieve actual HPD level of the DP source device.
* @param TypeCMuxId Type-C MUX identifier
* This parameter can be take one of the following values:
* @arg TYPE_C_MUX_1
* @arg TYPE_C_MUX_2
* @param pHPDState pointer to the Hot Plud Detection (HPD) state
* This parameter can be take one of the following values:
* @arg HPD_STATE_LOW
* @arg HPD_STATE_HIGH
* @retval mux status
*/
MUX_StatusTypeDef BSP_MUX_GetHPDState(MUX_TypeCMuxIdTypeDef TypeCMuxId,
MUX_HPDStateTypeDef * pHPDState)
{
uint32_t ret = 0;
/* Initialize returned HPDState */
*pHPDState = HPD_STATE_LOW;
/* Read HPDState */
switch (TypeCMuxId)
{
case TYPE_C_MUX_2:
*pHPDState = (MUX_HPDStateTypeDef)MUX_DET_GetState();
break;
default:
ret++;
break;
}
return (ret == 0) ? MUX_OK : MUX_ERROR;
}
/**
* @brief Generate an HPD_IRQ towards the DP source device.
* @note This function must be called every time an HPD_IRQ is detected by the
* PD communication stack.
* @param TypeCMuxId Type-C MUX identifier
* This parameter can be take one of the following values:
* @arg TYPE_C_MUX_1
* @arg TYPE_C_MUX_2
* @retval mux status
*/
MUX_StatusTypeDef BSP_MUX_HPDIRQ(MUX_TypeCMuxIdTypeDef TypeCMuxId)
{
MUX_StatusTypeDef ret = MUX_ERROR;
return ret;
}
/**
* @brief Display port hot plug detection (HPD)function.
* @note This function must be called when a display bort capable device
* is connected to the Display Port source receptacle of the MB1352
* daughter board.
* @retval none
*/
void BSP_MUX_Detect_HPD(void)
{
if (Context.pfnHPDCallbackFunc != (MUX_HPDCallbackFuncTypeDef *)NULL)
{
HAL_TIM_Base_Start_IT(&htim);
}
}
/**
* @brief HPD callback function registration.
* @note The sink device drives a hot plug detect (HPD) signal to notify the
* source that a sink is present.
* @note Once registered, HPD callback function will be called upon connection
* disconnection of a DP Sink device.
* @param TypeCMuxId Type-C MUX identifier
* This parameter can be take one of the following values:
* @arg TYPE_C_MUX_1
* @arg TYPE_C_MUX_2
* @param pHPDCallbackFunc HPD callback function pointer
* @retval mux status
*/
MUX_StatusTypeDef BSP_MUX_RegisterHPDCallbackFunc(MUX_TypeCMuxIdTypeDef TypeCMuxId,
MUX_HPDCallbackFuncTypeDef * pHPDCallbackFunc)
{
uint8_t ret = 0;
if (TypeCMuxId == TYPE_C_MUX_2)
{
Context.pfnHPDCallbackFunc = pHPDCallbackFunc;
}
else
{
ret++;
}
return (ret == 0) ? MUX_OK : MUX_ERROR;
}
/**
* @brief Initializes the TIM Base MSP.
* @param htim TIM handle
* @retval None
*/
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim)
{
/* Enable Debounce Timer clock */
DEBOUNCE_TIM_CLK_ENABLE();
/* NVIC configuration for debounce timer interrupt */
HAL_NVIC_SetPriority(DEBOUNCE_TIM_IRQn, 1, 0);
HAL_NVIC_EnableIRQ(DEBOUNCE_TIM_IRQn);
}
/**
* @brief DeInitialize TIM Base MSP.
* @param htim TIM handle
* @retval None
*/
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim)
{
/* Enable Debounce Timer clock */
DEBOUNCE_TIM_CLK_DISABLE();
/* Disable Debounce timer interrupt */
HAL_NVIC_DisableIRQ(DEBOUNCE_TIM_IRQn);
}
#if defined(TUSB546_DEBUG) || defined(CBTL08GP053_DEBUG) || defined(SN65DP141_DEBUG)
/**
* @brief Dump the register content of a device .
* @param Device device(s)
* This parameter can be any combination of the following values:
* DEVICE_CBTL08GP053
* DEVICE_SN65DP141
* DEVICE_TUSB546
* @retval none
*/
void BSP_MUX_DumpDeviceRegisters(uint32_t Device)
{
#if defined(CBTL08GP053_DEBUG)
if ((Device & DEVICE_CBTL08GP053) == DEVICE_CBTL08GP053)
{
printf("\n\tCBTL08GP053 registers dump:\n");
MUX_IO_Read(MUX_2_TYPEC_SWITCH_I2C_ADDRESS, CBTL08GP053_REG_SYS_CTRL, &Context.CBTL08GP053_Registers.SysCtrl.Register);
printf("\t\tSYS_CTRL : 0x%0.2x\n", Context.CBTL08GP053_Registers.SysCtrl.Register);
MUX_IO_Read(MUX_2_TYPEC_SWITCH_I2C_ADDRESS, CBTL08GP053_REG_OP1_CTRL, &Context.CBTL08GP053_Registers.Op1Ctrl.Register);
printf("\t\tOP1_CTRL : 0x%0.2x\n", Context.CBTL08GP053_Registers.Op1Ctrl.Register);
MUX_IO_Read(MUX_2_TYPEC_SWITCH_I2C_ADDRESS, CBTL08GP053_REG_OP2_CTRL, &Context.CBTL08GP053_Registers.Op2Ctrl.Register);
printf("\t\tOP2_CTRL : 0x%0.2x\n", Context.CBTL08GP053_Registers.Op2Ctrl.Register);
MUX_IO_Read(MUX_2_TYPEC_SWITCH_I2C_ADDRESS, CBTL08GP053_REG_OP3_CTRL, &Context.CBTL08GP053_Registers.Op3Ctrl.Register);
printf("\t\tOP3_CTRL : 0x%0.2x\n", Context.CBTL08GP053_Registers.Op3Ctrl.Register);
MUX_IO_Read(MUX_2_TYPEC_SWITCH_I2C_ADDRESS, CBTL08GP053_REG_OP4_CTRL, &Context.CBTL08GP053_Registers.Op4Ctrl.Register);
printf("\t\tOP4_CTRL : 0x%0.2x\n", Context.CBTL08GP053_Registers.Op4Ctrl.Register);
MUX_IO_Read(MUX_2_TYPEC_SWITCH_I2C_ADDRESS, CBTL08GP053_REG_OP5_CTRL, &Context.CBTL08GP053_Registers.Op5Ctrl.Register);
printf("\t\tOP5_CTRL : 0x%0.2x\n", Context.CBTL08GP053_Registers.Op5Ctrl.Register);
MUX_IO_Read(MUX_2_TYPEC_SWITCH_I2C_ADDRESS, CBTL08GP053_REG_CROSS5_CTRL, &Context.CBTL08GP053_Registers.Cross5Ctrl.Register);
printf("\t\tCROSS5_CTRL: 0x%0.2x\n", Context.CBTL08GP053_Registers.Cross5Ctrl.Register);
MUX_IO_Read(MUX_2_TYPEC_SWITCH_I2C_ADDRESS, CBTL08GP053_REG_SW_CTRL, &Context.CBTL08GP053_Registers.SwCtrl.Register);
printf("\t\tSW_CTRL : 0x%0.2x\n", Context.CBTL08GP053_Registers.SwCtrl.Register);
MUX_IO_Read(MUX_2_TYPEC_SWITCH_I2C_ADDRESS, CBTL08GP053_REG_REVISION, &Context.CBTL08GP053_Registers.Revision);
printf("\t\tREVISION : 0x%0.2x\n", Context.CBTL08GP053_Registers.Revision);
}
#endif /* CBTL08GP053_DEBUG */
#if defined(SN65DP141_DEBUG)
if ((Device & DEVICE_SN65DP141) == DEVICE_SN65DP141)
{
printf("\n\tSN65DP141 registers dump:\n");
MUX_IO_Read(MUX_2_DP_REDRIVER_I2C_ADDRESS, SN65DP141_REG_CFG, &Context.SN65DP141_Registers.General.Register);
printf("\t\tGeneral Device Settings : 0x%0.2x\n", Context.SN65DP141_Registers.General.Register);
MUX_IO_Read(MUX_2_DP_REDRIVER_I2C_ADDRESS, SN65DP141_REG_CHEN, &Context.SN65DP141_Registers.ChannelEnable.Register);
printf("\t\tChannel Enable : 0x%0.2x\n", Context.SN65DP141_Registers.ChannelEnable.Register);
MUX_IO_Read(MUX_2_DP_REDRIVER_I2C_ADDRESS, SN65DP141_REG_CH0_CFG, &Context.SN65DP141_Registers.Channel0Ctrl.Register);
printf("\t\tChannel 0 Control Settings: 0x%0.2x\n", Context.SN65DP141_Registers.Channel0Ctrl.Register);
MUX_IO_Read(MUX_2_DP_REDRIVER_I2C_ADDRESS, SN65DP141_REG_CH0_EN, &Context.SN65DP141_Registers.Channel0Enable.Register);
printf("\t\tChannel 0 Enable Settings : 0x%0.2x\n", Context.SN65DP141_Registers.Channel0Enable.Register);
MUX_IO_Read(MUX_2_DP_REDRIVER_I2C_ADDRESS, SN65DP141_REG_CH1_CFG, &Context.SN65DP141_Registers.Channel1Ctrl.Register);
printf("\t\tChannel 1 Control Settings: 0x%0.2x\n", Context.SN65DP141_Registers.Channel1Ctrl.Register);
MUX_IO_Read(MUX_2_DP_REDRIVER_I2C_ADDRESS, SN65DP141_REG_CH1_EN, &Context.SN65DP141_Registers.Channel1Enable.Register);
printf("\t\tChannel 1 Enable Settings : 0x%0.2x\n", Context.SN65DP141_Registers.Channel1Enable.Register);
MUX_IO_Read(MUX_2_DP_REDRIVER_I2C_ADDRESS, SN65DP141_REG_CH2_CFG, &Context.SN65DP141_Registers.Channel2Ctrl.Register);
printf("\t\tChannel 2 Control Settings: 0x%0.2x\n", Context.SN65DP141_Registers.Channel2Ctrl.Register);
MUX_IO_Read(MUX_2_DP_REDRIVER_I2C_ADDRESS, SN65DP141_REG_CH2_EN, &Context.SN65DP141_Registers.Channel2Enable.Register);
printf("\t\tChannel 2 Enable Settings : 0x%0.2x\n", Context.SN65DP141_Registers.Channel2Enable.Register);
MUX_IO_Read(MUX_2_DP_REDRIVER_I2C_ADDRESS, SN65DP141_REG_CH3_CFG, &Context.SN65DP141_Registers.Channel3Ctrl.Register);
printf("\t\tChannel 3 Control Settings: 0x%0.2x\n", Context.SN65DP141_Registers.Channel3Ctrl.Register);
MUX_IO_Read(MUX_2_DP_REDRIVER_I2C_ADDRESS, SN65DP141_REG_CH3_EN, &Context.SN65DP141_Registers.Channel3Enable.Register);
printf("\t\tChannel 3 Enable Settings : 0x%0.2x\n", Context.SN65DP141_Registers.Channel3Enable.Register);
}
#endif /* SN65DP141_DEBUG */
#if defined(TUSB546_DEBUG)
if ((Device & DEVICE_TUSB546) == DEVICE_TUSB546)
{
MUX_IO_Read(MUX_1_TYPEC_SWITCH_I2C_ADDRESS, TUSB546_REG_CTRL, &Context.TUSB546_Registers.General.Register);
MUX_IO_Read(MUX_1_TYPEC_SWITCH_I2C_ADDRESS, TUSB546_REG_DP_CTRL1, &Context.TUSB546_Registers.DPCtrlStatus10.Register);
MUX_IO_Read(MUX_1_TYPEC_SWITCH_I2C_ADDRESS, TUSB546_REG_DP_CTRL2, &Context.TUSB546_Registers.DPCtrlStatus11.Register);
MUX_IO_Read(MUX_1_TYPEC_SWITCH_I2C_ADDRESS, TUSB546_REG_DP_CTRL3, &Context.TUSB546_Registers.DPCtrlStatus12.Register);
MUX_IO_Read(MUX_1_TYPEC_SWITCH_I2C_ADDRESS, TUSB546_REG_DP_CTRL4, &Context.TUSB546_Registers.DPCtrlStatus13.Register);
}
#endif /* TUSB546_DEBUG */
}
#endif /* TUSB546_DEBUG || CBTL08GP053_DEBUG || SN65DP141_DEBUG */
/**
* @}
*/
/** @addtogroup STM32G0C1E_EVAL_MUX_Private_Functions
* @{
*/
/**
* @brief Configures DET GPIO.
* @note This function configures Detection GPIO pin for DET_HPD_SOURCE
* @retval None
*/
static void MUX_DET_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
/* Enable the GPIO_DET clock */
DET_HPD_SOURCE_GPIO_CLK_ENABLE();
/* Configure the GPIO_MOS pin */
GPIO_InitStruct.Pin = DET_HPD_SOURCE_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(DET_HPD_SOURCE_GPIO_PORT, &GPIO_InitStruct);
/* Enable and set EXTI lines Interrupt to the lowest priority */
HAL_NVIC_SetPriority(DET_EXTI_IRQn, 2, 0);
HAL_NVIC_EnableIRQ(DET_EXTI_IRQn);
}
/**
* @brief Reset DET GPIO configuration.
* @note This function resets configuration of Detection GPIO pin for DET_HPD_SOURCE
* @retval None
*/
static void MUX_DET_DeInit(void)
{
/* Disable EXTI lines Interrupt */
HAL_NVIC_DisableIRQ(DET_EXTI_IRQn);
HAL_GPIO_DeInit(DET_HPD_SOURCE_GPIO_PORT, DET_HPD_SOURCE_PIN);
}
/**
* @brief Returns the selected Detect state.
* @note This function returns GPIO pin state for DET_HPD_SOURCE
* @retval The Detect GPIO pin value
*/
static MUX_DETState_TypeDef MUX_DET_GetState(void)
{
GPIO_PinState PinState;
PinState = HAL_GPIO_ReadPin(DET_HPD_SOURCE_GPIO_PORT, DET_HPD_SOURCE_PIN);
/* Update Context */
Context.HPDState = HPD_STATE_LOW;
if (GPIO_PIN_SET == PinState)
{
Context.HPDState = HPD_STATE_HIGH;
}
return (PinState == GPIO_PIN_RESET) ? DET_STATE_LOW : DET_STATE_HIGH;
}
/**
* @brief Configures SEL GPIO.
* @param Sel Specifies the Select Pin to be configured.
* This parameter can be one of following parameters:
* @arg SEL_HPDIN
* @retval None
*/
static void MUX_SEL_Init(SelectId_TypeDef Sel)
{
GPIO_InitTypeDef GPIO_InitStruct;
/* Enable the GPIO_DET clock */
SELx_GPIO_CLK_ENABLE(Sel);
/* Configure the GPIO_MOS pin */
GPIO_InitStruct.Pin = SEL_PIN[Sel];
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(SEL_PORT[Sel], &GPIO_InitStruct);
HAL_GPIO_WritePin(SEL_PORT[Sel], SEL_PIN[Sel], GPIO_PIN_RESET);
}
/**
* @brief Reset SEL GPIO configuration.
* @param Sel Specifies the Select Pin.
* This parameter can be one of following parameters:
* @arg SEL_HPDIN
* @retval None
*/
static void MUX_SEL_DeInit(SelectId_TypeDef Sel)
{
HAL_GPIO_DeInit(SEL_PORT[Sel], SEL_PIN[Sel]);
}
/**
* @brief Turns selected Sel On.
* @param Sel Specifies the Select Pin to be configured.
* This parameter can be one of following parameters:
* @arg SEL_HPDIN
* @retval None
*/
static void MUX_SEL_On(SelectId_TypeDef Sel)
{
HAL_GPIO_WritePin(SEL_PORT[Sel], SEL_PIN[Sel], GPIO_PIN_SET);
}
/**
* @brief Turns selected Det Off.
* @param Sel Specifies the Select Pin to be configured.
* This parameter can be one of following parameters:
* @arg SEL_HPDIN
* @retval None
*/
static void MUX_SEL_Off(SelectId_TypeDef Sel)
{
HAL_GPIO_WritePin(SEL_PORT[Sel], SEL_PIN[Sel], GPIO_PIN_RESET);
}
/**
* @brief Set debounce timer configuration.
* @param DebounceTime Debounce time (in us)
* @retval None
*/
static void MUX_DebounceTimerSetConfig(uint32_t DebounceTime)
{
__HAL_TIM_RESET_HANDLE_STATE(&htim);
htim.Init.Prescaler = (DEBOUNCE_TIM_COUNTER_CLK_FREQ() / 1000000) -1;
htim.Init.CounterMode = TIM_COUNTERMODE_UP;
htim.Init.Period = DebounceTime - 1;
htim.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim.Init.RepetitionCounter = 0;
htim.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
HAL_TIM_Base_Init(&htim);
}
/**
* @brief Reset debounce timer configuration.
* @retval None
*/
static void MUX_DebounceTimerResetConfig(void)
{
HAL_TIM_Base_DeInit(&htim);
}
/**
* @brief Period elapsed callback in non-blocking mode
* @param htim TIM handle
* @retval None
*/
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
HAL_TIM_Base_Stop_IT(htim);
if ((Context.HPDState == HPD_STATE_LOW) && (DET_STATE_HIGH == MUX_DET_GetState()))
{
/* Invoke registered callback function */
Context.pfnHPDCallbackFunc(TYPE_C_MUX_2, HPD_STATE_HIGH);
}
if ((Context.HPDState == HPD_STATE_HIGH) && (DET_STATE_LOW == MUX_DET_GetState()))
{
/* Invoke registered callback function */
Context.pfnHPDCallbackFunc(TYPE_C_MUX_2, HPD_STATE_LOW);
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,226 @@
/**
******************************************************************************
* @file stm32g0c1e_eval_mux.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the
* stm32g0c1e_eval_mux.c firmware driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2020 STMicroelectronics</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 STM32G0C1E_EVAL_MUX_H
#define STM32G0C1E_EVAL_MUX_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32g0xx.h"
#include "../Components/sn65dp141/sn65dp141.h"
#include "../Components/cbtl08gp053/cbtl08gp053.h"
#include "../Components/tusb546/tusb546.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32G0C1E_EVAL
* @{
*/
/** @defgroup STM32G0C1E_EVAL_MUX STM32G0C1E_EVAL MUX
* @{
*/
/** @defgroup STM32G0C1E_EVAL_MUX_Exported_Defines Exported Defines
* @{
*/
#define MUX_1_EQGAIN_MAX TUSB546_EQGAIN_15
#define MUX_2_EQGAIN_MAX SN65DP141_EQGAIN_7
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_MUX_Exported_Types Exported Types
* @{
*/
/**
* @brief MUX Status
*/
typedef enum
{
MUX_OK = 0,
MUX_ERROR
} MUX_StatusTypeDef;
/**
* @brief Type-C MUX identifier
*/
typedef enum
{
TYPE_C_MUX_1 = 0,
TYPE_C_MUX_2,
TYPE_C_MUX_NB
} MUX_TypeCMuxIdTypeDef;
/**
* @brief Type-C connector pin assignments
*/
typedef enum
{
DFP_PIN_ASSIGNMMENT_A = 0, /*!< USB Type-C to USB Type-C or Protocol Converter */
DFP_PIN_ASSIGNMMENT_B, /*!< USB Type-C to USB Type-C or Protocol Converter */
DFP_PIN_ASSIGNMMENT_C, /*!< USB Type-C to USB Type-C or Protocol Converter */
DFP_PIN_ASSIGNMMENT_D, /*!< USB Type-C to USB Type-C or Protocol Converter */
DFP_PIN_ASSIGNMMENT_E, /*!< USB Type-C to DisplayPort */
DFP_PIN_ASSIGNMMENT_F, /*!< USB Type-C to DisplayPort */
UFP_PIN_ASSIGNMMENT_A, /*!< USB Type-C to USB Type-C or Protocol Converter */
UFP_PIN_ASSIGNMMENT_B, /*!< USB Type-C to USB Type-C or Protocol Converter */
UFP_PIN_ASSIGNMMENT_C, /*!< USB Type-C to USB Type-C or Protocol Converter */
UFP_PIN_ASSIGNMMENT_D, /*!< USB Type-C to USB Type-C or Protocol Converter */
UFP_PIN_ASSIGNMMENT_E, /*!< USB Type-C to USB Type-C or Protocol Converter */
UFP_PIN_ASSIGNMMENT_F, /*!< USB Type-C to USB Type-C or Protocol Converter */
USB_ONLY_PIN_ASSIGNMMENT /*!< USB 3.1 Only */
} MUX_TypeCConnectorPinAssignmentTypeDef;
/**
* @brief Type-C port plug orientation
*/
typedef enum
{
PLUG_ORIENTATION_NORMAL = 0,
PLUG_ORIENTATION_FLIPPED
} MUX_TypeCPlugOrientationTypeDef;
/**
* @brief HDP (Hot Plug Detection) state
*/
typedef enum
{
HPD_STATE_LOW = 0,
HPD_STATE_HIGH
} MUX_HPDStateTypeDef;
/**
* @brief HPD Callback Function Pointer
*/
typedef void MUX_HPDCallbackFuncTypeDef(MUX_TypeCMuxIdTypeDef TypeCMuxId, MUX_HPDStateTypeDef HPDState);
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_MUX_Exported_Constants Exported Constants
* @{
*/
#define DETn 2
#define DET_HPD_SOURCE_PIN GPIO_PIN_6 /* PC.06 */
#define DET_HPD_SOURCE_GPIO_PORT GPIOC
#define DET_HPD_SOURCE_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define DET_HPD_SOURCE_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
#define DET_EXTI_IRQn EXTI4_15_IRQn
#define DET_EXTI_IRQHandler EXTI4_15_IRQHandler
#define SELn 1
#define SEL_HPDIN_PIN GPIO_PIN_5 /* PB.05 */
#define SEL_HPDIN_GPIO_PORT GPIOB
#define SEL_HPDIN_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define SEL_HPDIN_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
#define DEBOUNCE_TIM_INSTANCE TIM6
#define DEBOUNCE_TIM_CLK_ENABLE() __HAL_RCC_TIM6_CLK_ENABLE()
#define DEBOUNCE_TIM_CLK_DISABLE() __HAL_RCC_TIM6_CLK_DISABLE()
#define DEBOUNCE_TIM_COUNTER_CLK_FREQ() HAL_RCC_GetPCLK1Freq()
#define DEBOUNCE_TIM_IRQn TIM6_DAC_LPTIM1_IRQn
#define DEBOUNCE_TIME 1000u /* 1ms */
#define DEBOUNCE_TIM_IRQHandler TIM6_DAC_LPTIM1_IRQHandler
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_MUX_Exported_Variables Exported Variables
* @{
*/
extern TIM_HandleTypeDef htim;
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_MUX_Exported_Functions Exported Functions
* @{
*/
MUX_StatusTypeDef BSP_MUX_Init(MUX_TypeCMuxIdTypeDef TypeCMuxId);
MUX_StatusTypeDef BSP_MUX_DeInit(MUX_TypeCMuxIdTypeDef TypeCMuxId);
MUX_StatusTypeDef BSP_MUX_Enable(MUX_TypeCMuxIdTypeDef TypeCMuxId);
MUX_StatusTypeDef BSP_MUX_Disable(MUX_TypeCMuxIdTypeDef TypeCMuxId);
MUX_StatusTypeDef BSP_MUX_SetDPPinAssignment(MUX_TypeCMuxIdTypeDef TypeCMuxId,
MUX_TypeCPlugOrientationTypeDef TypeCPlugOrientation,
MUX_TypeCConnectorPinAssignmentTypeDef TypeCConnectorPinAssignment);
MUX_StatusTypeDef BSP_MUX_SetEQGain(MUX_TypeCMuxIdTypeDef TypeCMuxId,
uint8_t EQGain);
MUX_StatusTypeDef BSP_MUX_SetHPDState(MUX_TypeCMuxIdTypeDef TypeCMuxId,
MUX_HPDStateTypeDef HPDState);
MUX_StatusTypeDef BSP_MUX_GetHPDState(MUX_TypeCMuxIdTypeDef TypeCMuxId,
MUX_HPDStateTypeDef * pHPDState);
MUX_StatusTypeDef BSP_MUX_HPDIRQ(MUX_TypeCMuxIdTypeDef TypeCMuxId);
void BSP_MUX_Detect_HPD(void);
MUX_StatusTypeDef BSP_MUX_RegisterHPDCallbackFunc(MUX_TypeCMuxIdTypeDef TypeCMuxId,
MUX_HPDCallbackFuncTypeDef * pHPDCallbackFunc);
#if defined(TUSB546_DEBUG) || defined(CBTL08GP053_DEBUG) || defined(SN65DP141_DEBUG)
#define DEVICE_CBTL08GP053 0x00000001U
#define DEVICE_SN65DP141 0x00000002U
#define DEVICE_TUSB546 0x00000004U
void BSP_MUX_DumpDeviceRegisters(uint32_t Device);
#endif /* TUSB546_DEBUG || CBTL08GP053_DEBUG || SN65DP141_DEBUG */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32G0C1E_EVAL_MUX_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,509 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32g0c1e_eval_pwr.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the
* stm32g0c1e_eval_pwr.c firmware driver.
******************************************************************************
*
* <h2><center>&copy; COPYRIGHT(c) 2020 STMicroelectronics</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
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef STM32G0C1E_EVAL_POWER
#define STM32G0C1E_EVAL_POWER
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32g0xx.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32G0C1E_EVAL
* @{
*/
/** @defgroup STM32G0C1E_EVAL_POWER STM32G0C1E_EVAL POWER
* @{
*/
/** @defgroup STM32G0C1E_EVAL_POWER_Exported_Types Exported Types based on BSP V1 specification (keep for legacy)
* @{
*/
/**
* @brief POWER Status
*/
typedef enum
{
PWR_OK = 0,
PWR_ERROR
} PWR_StatusTypeDef;
/**
* @brief Power role
*/
#define PWR_PowerRoleTypeDef USBPD_PWR_PowerRoleTypeDef
/**
* @brief Voltage control mode
*/
#define PWR_DCDCCtrlModeTypeDef USBPD_PWR_DCDCCtrlModeTypeDef
/**
* @brief VBUS connection status
*/
#define PWR_VBUSConnectionStatusTypeDef USBPD_PWR_VBUSConnectionStatusTypeDef
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_POWER_Exported_Types2 Exported Types based on BSP V2 secification
*@{
*/
/**
* @brief Power role
*/
typedef enum
{
POWER_ROLE_SOURCE = 0,
POWER_ROLE_SINK,
POWER_ROLE_DUAL
}
USBPD_PWR_PowerRoleTypeDef;
/**
* @brief Voltage control mode
*/
typedef enum
{
DCDC_CTRL_MODE_UNKNOWN = 0,
DCDC_CTRL_MODE_GPIO,
DCDC_CTRL_MODE_PWM,
} USBPD_PWR_DCDCCtrlModeTypeDef;
/**
* @brief VBUS connection status
*/
typedef enum
{
VBUS_CONNECTED = 0,
VBUS_NOT_CONNECTED
} USBPD_PWR_VBUSConnectionStatusTypeDef;
/* Keep for Legacy BSP V1 */
/**
* @brief VBUS Detection Callback
*/
typedef void PWR_VBUSDetectCallbackFunc(uint32_t Instance,
PWR_VBUSConnectionStatusTypeDef VBUSConnectionStatus);
/**
* @brief VBUS Detection Callback
*/
typedef void USBPD_PWR_VBUSDetectCallbackFunc(uint32_t Instance,
USBPD_PWR_VBUSConnectionStatusTypeDef VBUSConnectionStatus);
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_POWER_Exported_Constants Exported Constants based on BSP V1 specification (keep for legacy)
* @{
*/
/**
* @brief Number of TypeC ports
*/
#define PWR_TYPEC_PORT_NB USBPD_PWR_INSTANCES_NBR
/**
* @brief Type-C port identifier
*/
#define TYPE_C_PORT_1 USBPD_PWR_TYPE_C_PORT_1
#define TYPE_C_PORT_2 USBPD_PWR_TYPE_C_PORT_2
/**
* @brief CC pin identifier
*/
#define TYPE_C_CC1 USBPD_PWR_TYPE_C_CC1
#define TYPE_C_CC2 USBPD_PWR_TYPE_C_CC2
/**
* @brief VBUS disconnection threshold values (in mV)
*/
#define BSP_PWR_HIGH_VBUS_THRESHOLD USBPD_PWR_HIGH_VBUS_THRESHOLD
#define BSP_PWR_LOW_VBUS_THRESHOLD USBPD_PWR_LOW_VBUS_THRESHOLD
/**
* @brief VBUS discharge parameters
*/
#define BSP_PWR_DISCHARGE_MARGIN USBPD_PWR_DISCHARGE_MARGIN
#define BSP_PWR_DISCHARGE_TIME USBPD_PWR_DISCHARGE_TIME
/**
* @brief Calibration settings
*/
#define BSP_PWR_DCDC_PRECISION USBPD_PWR_DCDC_PRECISION
#define BSP_PWR_CALIBRATION_ENABLED USBPD_PWR_CALIBRATION_ENABLED
#define BSP_PWR_CALIBRATION_DISABLED USBPD_PWR_CALIBRATION_DISABLED
/**
* @brief power timeout
*/
#define BSP_PWR_TIMEOUT_PDO USBPD_PWR_TIMEOUT_PDO
#define BSP_PWR_TIMEOUT_APDO USBPD_PWR_TIMEOUT_APDO
/**
* @brief Invalid value set during issue with voltage setting
*/
#define BSP_PWR_INVALID_VALUE USBPD_PWR_INVALID_VALUE
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_USBPD_PWR_Exported_Constants2 Exported Constants on BSP V2 specification
@{
*/
/* Defines error for BSP V2 (copy for legacy reasons) */
/* Common Error codes */
#ifndef BSP_ERROR_NONE
#define BSP_ERROR_NONE 0
#endif
#ifndef BSP_ERROR_NO_INIT
#define BSP_ERROR_NO_INIT -1
#endif
#ifndef BSP_ERROR_WRONG_PARAM
#define BSP_ERROR_WRONG_PARAM -2
#endif
#ifndef BSP_ERROR_PERIPH_FAILURE
#define BSP_ERROR_PERIPH_FAILURE -4
#endif
#ifndef BSP_ERROR_FEATURE_NOT_SUPPORTED
#define BSP_ERROR_FEATURE_NOT_SUPPORTED -11
#endif
/**
* @brief Number of TypeC ports
*/
#define USBPD_PWR_INSTANCES_NBR 2u
/**
* @brief Type-C port identifier
*/
#define USBPD_PWR_TYPE_C_PORT_1 0u
#define USBPD_PWR_TYPE_C_PORT_2 1u
/**
* @brief CC pin identifier
*/
#define USBPD_PWR_TYPE_C_CC1 1u
#define USBPD_PWR_TYPE_C_CC2 2u
/**
* @brief VBUS disconnection threshold values (in mV)
*/
#define USBPD_PWR_HIGH_VBUS_THRESHOLD (2800u)
#define USBPD_PWR_LOW_VBUS_THRESHOLD (750U)
#define USBPD_PWR_VBUS_THRESHOLD_5V (3900u)
#define USBPD_PWR_VBUS_THRESHOLD_9V (7000u)
#define USBPD_PWR_VBUS_THRESHOLD_15V (12500u)
#define USBPD_PWR_VBUS_THRESHOLD_20V (17000u)
#define USBPD_PWR_VBUS_THRESHOLD_APDO (2150u)
/**
* @brief VBUS discharge parameters
*/
#define USBPD_PWR_DISCHARGE_MARGIN (500u)
#define USBPD_PWR_DISCHARGE_TIME (6u)
/**
* @brief Calibration settings
*/
#define USBPD_PWR_DCDC_PRECISION (20u) /* DCDC output precision set to 20mV (Noise)*/
#define USBPD_PWR_CALIBRATION_ENABLED (1u)
#define USBPD_PWR_CALIBRATION_DISABLED (0u)
/**
* @brief Standard VBUS voltage levels
*/
#define USBPD_PWR_VBUS_5V 5000u
#define USBPD_PWR_VBUS_9V 9000u
#define USBPD_PWR_VBUS_15V 15000u
/**
* @brief power timeout
*/
#define USBPD_PWR_TIMEOUT_PDO 250u /* Timeout for PDO to PDO or PDO to APDO at 250ms*/
#define USBPD_PWR_TIMEOUT_APDO 25u /* Timeout for APDO to APDO at 25ms*/
/**
* @brief Invalid value set during issue with voltage setting
*/
#define USBPD_PWR_INVALID_VALUE 0xFFFFFFFFu
#define GPIO_SOURCE_EN_PIN GPIO_PIN_3 /* PD.03 */
#define GPIO_SOURCE_EN_PORT GPIOD
#define GPIO_SOURCE_EN_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define GPIO_VBUS_DISCHARGE1_PIN GPIO_PIN_13 /* PB.13 */
#define GPIO_VBUS_DISCHARGE1_PORT GPIOB
#define GPIO_VBUS_DISCHARGE1_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define GPIO_VBUS_DISCHARGE2_PIN GPIO_PIN_14 /* PB.14 */
#define GPIO_VBUS_DISCHARGE2_PORT GPIOB
#define GPIO_VBUS_DISCHARGE2_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define GPIO_VCONN_EN1_PIN GPIO_PIN_4 /* PD.04 */
#define GPIO_VCONN_EN1_PORT GPIOD
#define GPIO_VCONN_EN1_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define GPIO_VCONN_EN2_PIN GPIO_PIN_9 /* PB.09 */
#define GPIO_VCONN_EN2_PORT GPIOB
#define GPIO_VCONN_EN2_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define GPIO_VCONN_DISCHARGE1_PIN GPIO_PIN_2 /* PA.02 */
#define GPIO_VCONN_DISCHARGE1_PORT GPIOA
#define GPIO_VCONN_DISCHARGE1_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define GPIO_VCONN_DISCHARGE2_PIN GPIO_PIN_0 /* PB.00 */
#define GPIO_VCONN_DISCHARGE2_PORT GPIOB
#define GPIO_VCONN_DISCHARGE2_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define GPIO_V_CTL2_PIN GPIO_PIN_1 /* PA.01 */
#define GPIO_V_CTL2_PORT GPIOA
#define GPIO_V_CTL2_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define GPIO_V_CTL1_PIN GPIO_PIN_1 /* PC.01 */
#define GPIO_V_CTL1_PORT GPIOC
#define GPIO_V_CTL1_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
/* Definition of ADCx clock resources */
#define ADCx ADC1
#define ADCx_CLK_ENABLE() __HAL_RCC_ADC_CLK_ENABLE()
#define ADCx_CLK_DISABLE() __HAL_RCC_ADC_CLK_DISABLE()
#define ADCx_FORCE_RESET() __HAL_RCC_ADC_FORCE_RESET()
#define ADCx_RELEASE_RESET() __HAL_RCC_ADC_RELEASE_RESET()
/* Definition of ADCx channels */
#define ADCx_CHANNEL_VSENSE_1 ADC_CHANNEL_9
#define ADCx_CHANNEL_ISENSE_1 ADC_CHANNEL_11
#define ADCx_CHANNEL_VSENSE_2 ADC_CHANNEL_3
#define ADCx_CHANNEL_ISENSE_2 ADC_CHANNEL_16
#define ADCx_CHANNEL_VSENSE_DCDC ADC_CHANNEL_15
/* Definition of ADCx channels */
#define ADCxChanneln 5u
#define ADCx_CHANNEL_VSENSE_1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define ADCx_CHANNEL_VSENSE_1_GPIO_PORT GPIOB
#define ADCx_CHANNEL_VSENSE_1_GPIO_PIN GPIO_PIN_1
#define ADCx_CHANNEL_ISENSE_1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define ADCx_CHANNEL_ISENSE_1_GPIO_PORT GPIOB
#define ADCx_CHANNEL_ISENSE_1_GPIO_PIN GPIO_PIN_10
#define ADCx_CHANNEL_VSENSE_2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define ADCx_CHANNEL_VSENSE_2_GPIO_PORT GPIOA
#define ADCx_CHANNEL_VSENSE_2_GPIO_PIN GPIO_PIN_3
#define ADCx_CHANNEL_ISENSE_2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define ADCx_CHANNEL_ISENSE_2_GPIO_PORT GPIOB
#define ADCx_CHANNEL_ISENSE_2_GPIO_PIN GPIO_PIN_12
#define ADCx_CHANNEL_VSENSE_DCDC_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define ADCx_CHANNEL_VSENSE_DCDC_GPIO_PORT GPIOB
#define ADCx_CHANNEL_VSENSE_DCDC_GPIO_PIN GPIO_PIN_11
/* Definition of ADCx DMA resources */
#define ADCx_DMA_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE()
#define ADCx_DMA DMA1_Channel1
/* Definition of DMA NVIC resources */
#define ADCx_DMA_IRQn DMA1_Channel1_IRQn
#define ADCx_DMA_IRQHandler DMA1_Channel1_IRQHandler
/* Definition of ADCx NVIC resources */
#define ADCx_IRQn ADC1_COMP_IRQn
#define ADCx_IRQHandler ADC1_COMP_IRQHandler
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_POWER_Exported_Functions Exported Functions based on BSP V1 specification (keep for legacy)
* @{
*/
PWR_StatusTypeDef BSP_PWR_Init(uint32_t PortId);
PWR_StatusTypeDef BSP_PWR_VBUSInit(uint32_t PortId);
PWR_StatusTypeDef BSP_PWR_VBUSDeInit(uint32_t PortId);
void BSP_PWR_VBUSIsGPIO(uint32_t *voltage1, uint32_t *voltage2, uint32_t *voltage3);
PWR_StatusTypeDef BSP_PWR_VBUSOn(uint32_t PortId);
PWR_StatusTypeDef BSP_PWR_VBUSOff(uint32_t PortId);
PWR_StatusTypeDef BSP_PWR_VBUSSetVoltage_Fixed(uint32_t PortNum,
uint32_t VbusTargetInmv,
uint32_t OperatingCurrent,
uint32_t MaxOperatingCurrent);
PWR_StatusTypeDef BSP_PWR_VBUSSetVoltage_Variable(uint32_t PortNum,
uint32_t VbusTargetMaxInmv,
uint32_t VbusTargetMinInmv,
uint32_t OperatingCurrent,
uint32_t MaxOperatingCurrent);
PWR_StatusTypeDef BSP_PWR_VBUSSetVoltage_Battery(uint32_t PortId,
uint32_t VbusTargetMin,
uint32_t VbusTargetMax,
uint32_t OperatingPower,
uint32_t MaxOperatingPower);
PWR_StatusTypeDef BSP_PWR_VBUSSetVoltage_APDO(uint32_t PortId,
uint32_t VbusTargetInmv,
uint32_t OperatingCurrent,
int32_t Delta);
uint32_t BSP_PWR_VBUSGetVoltage(uint32_t PortId);
int32_t BSP_PWR_VBUSGetCurrent(uint32_t PortId);
PWR_StatusTypeDef BSP_PWR_VCONNInit(uint32_t PortId,
uint32_t CCPinId);
PWR_StatusTypeDef BSP_PWR_VCONNDeInit(uint32_t PortId,
uint32_t CCPinId);
PWR_StatusTypeDef BSP_PWR_VCONNOn(uint32_t PortId,
uint32_t CCPinId);
PWR_StatusTypeDef BSP_PWR_VCONNOff(uint32_t PortId,
uint32_t CCPinId);
void BSP_PWR_SetVBUSDisconnectionThreshold(uint32_t PortId,
uint32_t VoltageThreshold);
PWR_StatusTypeDef BSP_PWR_RegisterVBUSDetectCallback(uint32_t PortId,
PWR_VBUSDetectCallbackFunc * pfnVBUSDetectCallback);
uint8_t BSP_PWR_VBUSIsOn(uint32_t PortId);
uint8_t BSP_PWR_VCONNIsOn(uint32_t PortId,
uint32_t CCPinId);
uint32_t BSP_PWR_DCDCGetVoltage(uint32_t PortId);
PWR_DCDCCtrlModeTypeDef BSP_PWR_DCDCGetCtrlMode(uint32_t PortId);
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_USBPD_POWER_Exported_Functions2 Exported Functions based on BSP V2 specification
* @{
*/
/* Common functions */
int32_t BSP_USBPD_PWR_Init(uint32_t Instance);
int32_t BSP_USBPD_PWR_Deinit(uint32_t Instance);
int32_t BSP_USBPD_PWR_VBUSInit(uint32_t Instance);
int32_t BSP_USBPD_PWR_VBUSDeInit(uint32_t Instance);
int32_t BSP_USBPD_PWR_VBUSOn(uint32_t Instance);
int32_t BSP_USBPD_PWR_VBUSOff(uint32_t Instance);
int32_t BSP_USBPD_PWR_VBUSSetVoltage_Fixed(uint32_t Instance,
uint32_t VbusTargetInmv,
uint32_t OperatingCurrent,
uint32_t MaxOperatingCurrent);
int32_t BSP_USBPD_PWR_VBUSSetVoltage_Variable(uint32_t Instance,
uint32_t VbusTargetMaxInmv,
uint32_t VbusTargetMinInmv,
uint32_t OperatingCurrent,
uint32_t MaxOperatingCurrent);
int32_t BSP_USBPD_PWR_VBUSSetVoltage_Battery(uint32_t Instance,
uint32_t VbusTargetMin,
uint32_t VbusTargetMax,
uint32_t OperatingPower,
uint32_t MaxOperatingPower);
int32_t BSP_USBPD_PWR_VBUSSetVoltage_APDO(uint32_t Instance,
uint32_t VbusTargetInmv,
uint32_t OperatingCurrent,
int32_t Delta);
int32_t BSP_USBPD_PWR_VBUSGetVoltage(uint32_t Instance, uint32_t *pVoltage);
int32_t BSP_USBPD_PWR_VBUSGetCurrent(uint32_t Instance, int32_t *pCurrent);
int32_t BSP_USBPD_PWR_VCONNInit(uint32_t Instance,
uint32_t CCPinId);
int32_t BSP_USBPD_PWR_VCONNDeInit(uint32_t Instance,
uint32_t CCPinId);
int32_t BSP_USBPD_PWR_VCONNOn(uint32_t Instance,
uint32_t CCPinId);
int32_t BSP_USBPD_PWR_VCONNOff(uint32_t Instance,
uint32_t CCPinId);
int32_t BSP_USBPD_PWR_SetVBUSDisconnectionThreshold(uint32_t Instance,
uint32_t VoltageThreshold);
int32_t BSP_USBPD_PWR_RegisterVBUSDetectCallback(uint32_t Instance,
USBPD_PWR_VBUSDetectCallbackFunc *pfnVBUSDetectCallback);
int32_t BSP_USBPD_PWR_VBUSIsOn(uint32_t Instance, uint8_t *pState);
int32_t BSP_USBPD_PWR_VCONNIsOn(uint32_t Instance,
uint32_t CCPinId, uint8_t *pState);
int32_t BSP_USBPD_PWR_DCDCGetCtrlMode(uint32_t Instance, USBPD_PWR_DCDCCtrlModeTypeDef *pDCDCCtrl);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32G0C1E_EVAL_POWER */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,234 @@
/**
******************************************************************************
* @file stm32g0c1e_eval_sd.h
* @author MCD Application Team
* @brief This file contains the common defines and functions prototypes for
* the STM32G0C1E_EVAL_sd.c driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2020 STMicroelectronics</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 STM32G0C1E_EVAL_SD_H
#define STM32G0C1E_EVAL_SD_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32g0c1e_eval.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32G0C1E_EVAL
* @{
*/
/** @defgroup STM32G0C1E_EVAL_SD STM32G0C1E_EVAL SD
* @{
*/
/** @defgroup STM32G0C1E_EVAL_SD_Exported_Types Exported Types
* @{
*/
/**
* @brief SD status structure definition
*/
enum {
BSP_SD_OK = 0x00,
MSD_OK = 0x00,
BSP_SD_ERROR = 0x01,
MSD_ERROR = 0x01,
BSP_SD_TIMEOUT
};
/**
* @brief SD transfer state definition
*/
#define SD_TRANSFER_OK ((uint8_t)0x00)
#define SD_TRANSFER_BUSY ((uint8_t)0x01)
#define SD_TRANSFER_ERROR ((uint8_t)0x02)
/**
* @}
*/
/**
* @brief SD status structure definition
*/
typedef struct
{
uint8_t Reserved1:2; /* Reserved */
uint16_t DeviceSize:12; /* Device Size */
uint8_t MaxRdCurrentVDDMin:3; /* Max. read current @ VDD min */
uint8_t MaxRdCurrentVDDMax:3; /* Max. read current @ VDD max */
uint8_t MaxWrCurrentVDDMin:3; /* Max. write current @ VDD min */
uint8_t MaxWrCurrentVDDMax:3; /* Max. write current @ VDD max */
uint8_t DeviceSizeMul:3; /* Device size multiplier */
} struct_v1;
typedef struct
{
uint8_t Reserved1:6; /* Reserved */
uint32_t DeviceSize:22; /* Device Size */
uint8_t Reserved2:1; /* Reserved */
} struct_v2;
/**
* @brief Card Specific Data: CSD Register
*/
typedef struct
{
/* Header part */
uint8_t CSDStruct:2; /* CSD structure */
uint8_t Reserved1:6; /* Reserved */
uint8_t TAAC:8; /* Data read access-time 1 */
uint8_t NSAC:8; /* Data read access-time 2 in CLK cycles */
uint8_t MaxBusClkFrec:8; /* Max. bus clock frequency */
uint16_t CardComdClasses:12; /* Card command classes */
uint8_t RdBlockLen:4; /* Max. read data block length */
uint8_t PartBlockRead:1; /* Partial blocks for read allowed */
uint8_t WrBlockMisalign:1; /* Write block misalignment */
uint8_t RdBlockMisalign:1; /* Read block misalignment */
uint8_t DSRImpl:1; /* DSR implemented */
/* v1 or v2 struct */
union csd_version {
struct_v1 v1;
struct_v2 v2;
} version;
uint8_t EraseSingleBlockEnable:1; /* Erase single block enable */
uint8_t EraseSectorSize:7; /* Erase group size multiplier */
uint8_t WrProtectGrSize:7; /* Write protect group size */
uint8_t WrProtectGrEnable:1; /* Write protect group enable */
uint8_t Reserved2:2; /* Reserved */
uint8_t WrSpeedFact:3; /* Write speed factor */
uint8_t MaxWrBlockLen:4; /* Max. write data block length */
uint8_t WriteBlockPartial:1; /* Partial blocks for write allowed */
uint8_t Reserved3:5; /* Reserved */
uint8_t FileFormatGrouop:1; /* File format group */
uint8_t CopyFlag:1; /* Copy flag (OTP) */
uint8_t PermWrProtect:1; /* Permanent write protection */
uint8_t TempWrProtect:1; /* Temporary write protection */
uint8_t FileFormat:2; /* File Format */
uint8_t Reserved4:2; /* Reserved */
uint8_t crc:7; /* Reserved */
uint8_t Reserved5:1; /* always 1*/
} SD_CSD;
/**
* @brief Card Identification Data: CID Register
*/
typedef struct
{
__IO uint8_t ManufacturerID; /* ManufacturerID */
__IO uint16_t OEM_AppliID; /* OEM/Application ID */
__IO uint32_t ProdName1; /* Product Name part1 */
__IO uint8_t ProdName2; /* Product Name part2*/
__IO uint8_t ProdRev; /* Product Revision */
__IO uint32_t ProdSN; /* Product Serial Number */
__IO uint8_t Reserved1; /* Reserved1 */
__IO uint16_t ManufactDate; /* Manufacturing Date */
__IO uint8_t CID_CRC; /* CID CRC */
__IO uint8_t Reserved2; /* always 1 */
} SD_CID;
/**
* @brief SD Card information
*/
typedef struct
{
SD_CSD Csd;
SD_CID Cid;
uint32_t CardCapacity; /*!< Card Capacity */
uint32_t CardBlockSize; /*!< Card Block Size */
uint32_t LogBlockNbr; /*!< Specifies the Card logical Capacity in blocks */
uint32_t LogBlockSize; /*!< Specifies logical block size in bytes */
} SD_CardInfo;
/** @defgroup STM32G0C1E_EVAL_SPI_SD_Exported_Constants Exported Constants
* @{
*/
/**
* @brief Block Size
*/
#define SD_BLOCK_SIZE 0x200
/**
* @brief SD detection on its memory slot
*/
#define SD_PRESENT ((uint8_t)0x01)
#define SD_NOT_PRESENT ((uint8_t)0x00)
#define SD_DATATIMEOUT ((uint32_t)100000000)
/**
* @brief SD Card information structure
*/
#define BSP_SD_CardInfo SD_CardInfo
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_SD_Exported_Functions Exported Functions
* @{
*/
uint8_t BSP_SD_Init(void);
uint8_t BSP_SD_IsDetected(void);
uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout);
uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout);
uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr);
uint8_t BSP_SD_GetCardState(void);
uint8_t BSP_SD_GetCardInfo(SD_CardInfo *pCardInfo);
/* Link functions for SD Card peripheral */
void SD_IO_Init(void);
void SD_IO_CSState(uint8_t state);
void SD_IO_WriteReadData(const uint8_t *DataIn, uint8_t *DataOut, uint16_t DataLength);
uint8_t SD_IO_WriteByte(uint8_t Data);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32G0C1E_EVAL_SD_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,167 @@
/**
******************************************************************************
* @file stm32g0c1e_eval_tsensor.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the I2C STLM75
* temperature sensor mounted on STM32G0C1E-EV board .
* It implements a high level communication layer for read and write
* from/to this sensor. The needed STM32G0xx hardware resources (I2C and
* GPIO) are defined in stm32g0c1e_eval.h file, and the initialization is
* performed in TSENSOR_IO_Init() function declared in stm32g0c1e_eval.c
* file.
* You can easily tailor this driver to any other development board,
* by just adapting the defines for hardware resources and
* TSENSOR_IO_Init() function.
*
* +-----------------------------------------------------------------+
* | Pin assignment |
* +---------------------------------------+-----------+-------------+
* | STM32G0xx I2C Pins | STLM75 | Pin |
* +---------------------------------------+-----------+-------------+
* | STLM75_I2C_SDA_PIN/ SDA | SDA | 1 |
* | STLM75_I2C_SCL_PIN/ SCL | SCL | 2 |
* | STLM75_I2C_SMBUSALERT_PIN/ SMBUS ALERT| OS/INT | 3 |
* | . | GND | 4 (0V) |
* | . | GND | 5 (0V) |
* | . | GND | 6 (0V) |
* | . | GND | 7 (0V) |
* | . | VDD | 8 (3.3V)|
* +---------------------------------------+-----------+-------------+
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2020 STMicroelectronics</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 "stm32g0c1e_eval_tsensor.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32G0C1E_EVAL
* @{
*/
/** @addtogroup STM32G0C1E_EVAL_TSENSOR
* @brief This file includes the STLM75 Temperature Sensor driver of
* STM32G0C1E-EV boards.
* @{
*/
/** @defgroup STM32G0C1E_EVAL_TSENSOR_Private_Variables Private Variables
* @{
*/
static TSENSOR_DrvTypeDef *tsensor_drv;
__IO uint16_t TSENSORAddress = 0;
/**
* @}
*/
/** @addtogroup STM32G0C1E_EVAL_TSENSOR_Exported_Functions
* @{
*/
/**
* @brief Initializes peripherals used by the I2C Temperature Sensor driver.
* @retval TSENSOR status
*/
uint32_t BSP_TSENSOR_Init(void)
{
uint8_t ret = TSENSOR_ERROR;
TSENSOR_InitTypeDef STLM75_InitStructure;
/* Temperature Sensor Initialization */
if(Stlm75Drv.IsReady(TSENSOR_I2C_ADDRESS_A01, TSENSOR_MAX_TRIALS) == HAL_OK)
{
/* Initialize the temperature sensor driver structure */
TSENSORAddress = TSENSOR_I2C_ADDRESS_A01;
tsensor_drv = &Stlm75Drv;
ret = TSENSOR_OK;
}
else
{
if(Stlm75Drv.IsReady(TSENSOR_I2C_ADDRESS_A02, TSENSOR_MAX_TRIALS) == HAL_OK)
{
/* Initialize the temperature sensor driver structure */
TSENSORAddress = TSENSOR_I2C_ADDRESS_A02;
tsensor_drv = &Stlm75Drv;
ret = TSENSOR_OK;
}
else
{
ret = TSENSOR_ERROR;
}
}
if (ret == TSENSOR_OK)
{
/* Configure Temperature Sensor : Conversion 9 bits in continuous mode */
/* Alert outside range Limit Temperature 12° <-> 24°c */
STLM75_InitStructure.AlertMode = STLM75_INTERRUPT_MODE;
STLM75_InitStructure.ConversionMode = STLM75_CONTINUOUS_MODE;
STLM75_InitStructure.TemperatureLimitHigh = 24;
STLM75_InitStructure.TemperatureLimitLow = 12;
/* TSENSOR Init */
tsensor_drv->Init(TSENSORAddress, &STLM75_InitStructure);
ret = TSENSOR_OK;
}
return ret;
}
/**
* @brief Returns the Temperature Sensor status.
* @retval The Temperature Sensor status.
*/
uint8_t BSP_TSENSOR_ReadStatus(void)
{
return (tsensor_drv->ReadStatus(TSENSORAddress));
}
/**
* @brief Read Temperature register of STLM75.
* @retval STLM75 measured temperature value.
*/
float BSP_TSENSOR_ReadTemp(void)
{
return tsensor_drv->ReadTemp(TSENSORAddress);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View file

@ -0,0 +1,104 @@
/**
******************************************************************************
* @file stm32g0c1e_eval_tsensor.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the
* stm32g0c1e_eval_tsensor.c firmware driver.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2020 STMicroelectronics</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 STM32G0C1E_EVAL_TSENSOR_H
#define STM32G0C1E_EVAL_TSENSOR_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32g0c1e_eval.h"
#include "../Components/stlm75/stlm75.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32G0C1E_EVAL
* @{
*/
/** @defgroup STM32G0C1E_EVAL_TSENSOR STM32G0C1E_EVAL TSENSOR
* @{
*/
/** @defgroup STM32G0C1E_EVAL_TSENSOR_Exported_Types Exported Types
* @{
*/
/**
* @brief TSENSOR Status
*/
typedef enum
{
TSENSOR_OK = 0,
TSENSOR_ERROR
} TSENSOR_Status_TypDef;
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_TSENSOR_Exported_Constants Exported Constants
* @{
*/
/* Temperature Sensor hardware I2C address */
#define TSENSOR_I2C_ADDRESS_A01 0x90
#define TSENSOR_I2C_ADDRESS_A02 0x92
/* Maximum number of trials use for STTS751_IsReady function */
#define TSENSOR_MAX_TRIALS 50
/**
* @}
*/
/** @defgroup STM32G0C1E_EVAL_TSENSOR_Exported_Functions Exported Functions
* @{
*/
uint32_t BSP_TSENSOR_Init(void);
uint8_t BSP_TSENSOR_ReadStatus(void);
float BSP_TSENSOR_ReadTemp(void);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32G0C1E_EVAL_TSENSOR_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/