配置 PWM ADC LCD
This commit is contained in:
41
STM32F103C8T6/Drivers/BSP/LCD/hz16_data.c
Normal file
41
STM32F103C8T6/Drivers/BSP/LCD/hz16_data.c
Normal file
@@ -0,0 +1,41 @@
|
||||
/* 16×16 CJK 字库,由 font_gen.py 生成(自定义) */
|
||||
|
||||
#include "hz16_data.h"
|
||||
|
||||
static const uint8_t cjk_bitmaps[][32] = {
|
||||
{ 0x00, 0x00, 0x01, 0x00, 0x03, 0x80, 0x02, 0xC0, 0x06, 0x60, 0x0C, 0x30, 0x18, 0x3E, 0x3F, 0xFE, 0x41, 0x80, 0x01, 0x90, 0x1F, 0xF8, 0x01, 0x80, 0x01, 0x80, 0x01, 0x84, 0x7F, 0xFE, 0x00, 0x00 }, /* U+5168 全 */
|
||||
{ 0x00, 0x00, 0x3F, 0xFC, 0x30, 0x14, 0x3F, 0xFC, 0x31, 0x84, 0x31, 0x84, 0x27, 0xF4, 0x35, 0xC4, 0x31, 0xE4, 0x31, 0xA4, 0x31, 0xBC, 0x3F, 0xFC, 0x30, 0x0C, 0x3F, 0xFC, 0x20, 0x04, 0x00, 0x00 }, /* U+56FD 国 */
|
||||
{ 0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x86, 0x7F, 0xFE, 0x01, 0x80, 0x01, 0x80, 0x03, 0xC0, 0x03, 0x40, 0x02, 0x60, 0x06, 0x30, 0x0C, 0x18, 0x18, 0x0E, 0x70, 0x06, 0x00, 0x00 }, /* U+5927 大 */
|
||||
{ 0x00, 0x00, 0x1F, 0xFC, 0x00, 0x38, 0x00, 0x60, 0x01, 0xC0, 0x01, 0x80, 0x01, 0x86, 0x7F, 0xFE, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x07, 0x80, 0x03, 0x00, 0x00, 0x00 }, /* U+5B50 子 */
|
||||
{ 0x00, 0x00, 0x1B, 0x18, 0x0D, 0xB0, 0x0D, 0xB0, 0x2D, 0xE6, 0x3F, 0xFE, 0x60, 0x34, 0x6F, 0xF0, 0x00, 0x60, 0x01, 0x84, 0x7F, 0xFE, 0x01, 0x80, 0x01, 0x80, 0x07, 0x80, 0x03, 0x80, 0x00, 0x00 }, /* U+5B66 学 */
|
||||
{ 0x00, 0x00, 0x0C, 0x06, 0x0B, 0xFE, 0x68, 0x20, 0x6B, 0x66, 0x6B, 0xFE, 0x6B, 0x26, 0x6B, 0x26, 0x6B, 0x26, 0x6B, 0x26, 0x7B, 0x26, 0x1B, 0x2E, 0x30, 0x24, 0x20, 0x20, 0x40, 0x60, 0x00, 0x00 }, /* U+5E08 师 */
|
||||
{ 0x00, 0x00, 0x19, 0x80, 0x19, 0x80, 0x33, 0xFC, 0x32, 0x6C, 0x75, 0x60, 0x53, 0x78, 0x12, 0x6C, 0x15, 0xE4, 0x10, 0xC0, 0x05, 0x80, 0x14, 0x8C, 0x34, 0x16, 0x64, 0x3A, 0x07, 0xF0, 0x00, 0x00 }, /* U+60A8 您 */
|
||||
{ 0x00, 0x00, 0x00, 0x60, 0x06, 0xC0, 0x7E, 0xC0, 0x06, 0xFE, 0x64, 0xA4, 0x3D, 0x20, 0x19, 0x60, 0x18, 0x70, 0x1C, 0x70, 0x36, 0x50, 0x26, 0xD8, 0x63, 0x8C, 0x43, 0x0E, 0x06, 0x06, 0x00, 0x00 }, /* U+6B22 欢 */
|
||||
{ 0x00, 0x00, 0x01, 0x80, 0x09, 0x80, 0x19, 0x80, 0x19, 0x8C, 0x1F, 0xFC, 0x31, 0x80, 0x21, 0x80, 0x41, 0x88, 0x1F, 0xF8, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x86, 0x7F, 0xFE, 0x00, 0x00 }, /* U+751F 生 */
|
||||
{ 0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x01, 0x00, 0x3F, 0xF8, 0x31, 0x08, 0x31, 0x08, 0x3F, 0xF8, 0x31, 0x08, 0x31, 0x08, 0x3F, 0xF8, 0x31, 0x00, 0x01, 0x06, 0x01, 0x06, 0x01, 0xFE, 0x00, 0x00 }, /* U+7535 电 */
|
||||
{ 0x01, 0x00, 0x01, 0x80, 0x1F, 0xFC, 0x16, 0x30, 0x06, 0x60, 0x7F, 0xFE, 0x00, 0x10, 0x0F, 0xF0, 0x08, 0x30, 0x08, 0x30, 0x0F, 0xF0, 0x0A, 0xC2, 0x06, 0xC2, 0x0C, 0xC6, 0x38, 0x7E, 0x40, 0x00 }, /* U+7ADE 竞 */
|
||||
{ 0x00, 0x00, 0x06, 0x60, 0x7F, 0xFE, 0x06, 0x60, 0x06, 0x40, 0x19, 0x18, 0x1B, 0xF8, 0x65, 0x18, 0x35, 0x18, 0x29, 0x18, 0x09, 0x38, 0x39, 0x36, 0x11, 0x06, 0x19, 0xFE, 0x18, 0xFC, 0x00, 0x00 }, /* U+8303 范 */
|
||||
{ 0x00, 0x00, 0x10, 0x60, 0x18, 0x60, 0x08, 0x60, 0x00, 0x60, 0x18, 0x62, 0x7B, 0xFE, 0x10, 0x60, 0x18, 0x60, 0x18, 0x60, 0x12, 0x60, 0x1C, 0x60, 0x1C, 0x60, 0x18, 0x60, 0x00, 0x60, 0x00, 0x00 }, /* U+8BA1 计 */
|
||||
{ 0x00, 0x00, 0x11, 0xF8, 0x19, 0x98, 0x01, 0x90, 0x01, 0x1E, 0x7B, 0x1E, 0x1E, 0x08, 0x19, 0xFC, 0x18, 0x98, 0x18, 0x98, 0x1E, 0xF0, 0x1C, 0x60, 0x18, 0xF0, 0x03, 0x9E, 0x0E, 0x06, 0x00, 0x00 }, /* U+8BBE 设 */
|
||||
{ 0x01, 0x00, 0x01, 0x80, 0x3F, 0xFC, 0x36, 0x7C, 0x3F, 0xF8, 0x06, 0x78, 0x0F, 0xF8, 0x7F, 0xFE, 0x0E, 0x70, 0x1F, 0xF8, 0x3D, 0xBE, 0x4D, 0xB0, 0x0D, 0xA0, 0x07, 0x70, 0x1C, 0x38, 0x00, 0x00 }, /* U+8D5B 赛 */
|
||||
{ 0x00, 0x00, 0x20, 0xC0, 0x33, 0xC0, 0x12, 0x3E, 0x02, 0x26, 0x02, 0x26, 0x72, 0x26, 0x12, 0x26, 0x12, 0xE6, 0x13, 0xAE, 0x13, 0x2C, 0x10, 0x20, 0x7C, 0x20, 0x47, 0xFE, 0x01, 0xFE, 0x00, 0x00 }, /* U+8FCE 迎 */
|
||||
{ 0x01, 0x00, 0x01, 0x00, 0x1F, 0xF8, 0x18, 0x18, 0x1F, 0xF8, 0x18, 0x10, 0x1F, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x1F, 0xF8, 0x01, 0x82, 0x7F, 0xFE, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x00, 0x00 }, /* U+961C 阜 */
|
||||
{ 0x00, 0x00, 0x7E, 0x84, 0x65, 0xFC, 0x6D, 0x84, 0x69, 0x84, 0x69, 0x84, 0x6D, 0x8C, 0x67, 0xFC, 0x67, 0x84, 0x67, 0x84, 0x7D, 0x84, 0x61, 0x84, 0x61, 0xFC, 0x61, 0x84, 0x60, 0x00, 0x00, 0x00 }, /* U+9633 阳 */
|
||||
};
|
||||
|
||||
static const uint16_t cjk_unicodes[18] = {
|
||||
0x5168, 0x56FD, 0x5927, 0x5B50, 0x5B66, 0x5E08, 0x60A8, 0x6B22, 0x751F, 0x7535, 0x7ADE, 0x8303, 0x8BA1, 0x8BBE, 0x8D5B, 0x8FCE,
|
||||
0x961C, 0x9633,
|
||||
};
|
||||
|
||||
const uint8_t* cjk_get_bitmap(uint16_t unicode)
|
||||
{
|
||||
int lo = 0, hi = 18;
|
||||
while (lo < hi) {
|
||||
int mid = (lo + hi) >> 1;
|
||||
if (cjk_unicodes[mid] < unicode) lo = mid + 1;
|
||||
else if (cjk_unicodes[mid] > unicode) hi = mid;
|
||||
else return cjk_bitmaps[mid];
|
||||
}
|
||||
return (const uint8_t*)0;
|
||||
}
|
||||
15
STM32F103C8T6/Drivers/BSP/LCD/hz16_data.h
Normal file
15
STM32F103C8T6/Drivers/BSP/LCD/hz16_data.h
Normal file
@@ -0,0 +1,15 @@
|
||||
/* 16×16 CJK 字库,由 font_gen.py 生成(自定义) */
|
||||
|
||||
#ifndef HZ16_DATA_H
|
||||
#define HZ16_DATA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define CJK_BYTES_PER_CHAR 32
|
||||
#define CJK_WIDTH 16
|
||||
#define CJK_HEIGHT 16
|
||||
#define CJK_NUM_CHARS 18
|
||||
|
||||
const uint8_t* cjk_get_bitmap(uint16_t unicode);
|
||||
|
||||
#endif /* HZ16_DATA_H */
|
||||
328
STM32F103C8T6/Drivers/BSP/LCD/lcd.c
Normal file
328
STM32F103C8T6/Drivers/BSP/LCD/lcd.c
Normal file
@@ -0,0 +1,328 @@
|
||||
/*
|
||||
* 模块名称:LCD 绘图模块
|
||||
* 模块功能:提供字符、字符串(中英文混合)、线条、矩形、圆形等图形绘制
|
||||
* 适用平台:STM32F103C8T6 + ST7735S + 底层 st7735s.c
|
||||
* 作者:王建锋
|
||||
* 创建日期:2026-07-14
|
||||
* 修改记录:
|
||||
* 2026-07-14 王建锋 从 st7735s.c 拆分
|
||||
*/
|
||||
|
||||
#include "lcd.h"
|
||||
#include "lcd_data.h"
|
||||
#include "hz16_data.h"
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* 函数功能:UTF-8字符转Unicode(辅助)
|
||||
* 入口参数:str - UTF-8字符串指针(会被推进到下一字符起始)
|
||||
* 返回值:Unicode码点,或0(异常/结束)
|
||||
* 函数说明:支持1~3字节UTF-8,推进str
|
||||
*/
|
||||
static uint16_t utf8_to_unicode(const char **str)
|
||||
{
|
||||
uint16_t code;
|
||||
uint8_t c;
|
||||
|
||||
c = (uint8_t)(**str);
|
||||
if (c == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (c < 0x80) {
|
||||
code = c;
|
||||
(*str)++;
|
||||
} else if ((c & 0xE0) == 0xC0) {
|
||||
code = c & 0x1F;
|
||||
(*str)++;
|
||||
code = (code << 6) | ((uint8_t)(**str) & 0x3F);
|
||||
(*str)++;
|
||||
} else if ((c & 0xF0) == 0xE0) {
|
||||
code = c & 0x0F;
|
||||
(*str)++;
|
||||
code = (code << 6) | ((uint8_t)(**str) & 0x3F);
|
||||
(*str)++;
|
||||
code = (code << 6) | ((uint8_t)(**str) & 0x3F);
|
||||
(*str)++;
|
||||
} else {
|
||||
(*str)++;
|
||||
return 0;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:显示一个8x16 ASCII字符
|
||||
* 入口参数:x - 列坐标
|
||||
* y - 行坐标
|
||||
* ch - 字符 (ASCII 32-126)
|
||||
* color - 字符颜色 (RGB565)
|
||||
* bg_color - 背景颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:框选8x16区域→遍历字模bit→发送color或bg_color
|
||||
*/
|
||||
void lcd_draw_char(uint16_t x, uint16_t y, char ch, uint16_t color, uint16_t bg_color)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t j;
|
||||
uint8_t line;
|
||||
|
||||
if (ch < 32 || ch > 126) {
|
||||
ch = ' ';
|
||||
}
|
||||
|
||||
st7735s_set_window(x, y, x + 7, y + 15);
|
||||
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(LCD_DC_PORT, LCD_DC_PIN, GPIO_PIN_SET);
|
||||
for (i = 0; i < 16; i++) {
|
||||
line = LCD_F8x16[ch - 32][i];
|
||||
for (j = 0; j < 8; j++) {
|
||||
if (line & 0x80) {
|
||||
st7735s_spi_write_byte((uint8_t)(color >> 8));
|
||||
st7735s_spi_write_byte((uint8_t)(color & 0xFF));
|
||||
} else {
|
||||
st7735s_spi_write_byte((uint8_t)(bg_color >> 8));
|
||||
st7735s_spi_write_byte((uint8_t)(bg_color & 0xFF));
|
||||
}
|
||||
line <<= 1;
|
||||
}
|
||||
}
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:显示字符串
|
||||
* 入口参数:x - 列坐标
|
||||
* y - 行坐标
|
||||
* str - 字符串指针
|
||||
* color - 字符颜色 (RGB565)
|
||||
* bg_color - 背景颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:连续显示字符串,自动换行
|
||||
*/
|
||||
void lcd_draw_string(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bg_color)
|
||||
{
|
||||
uint16_t start_x = x;
|
||||
|
||||
while (*str != '\0') {
|
||||
if (*str == '\n') {
|
||||
y += FONT_HEIGHT_16;
|
||||
x = start_x;
|
||||
str++;
|
||||
continue;
|
||||
}
|
||||
if (x + 8 > s_lcd_width) {
|
||||
y += FONT_HEIGHT_16;
|
||||
x = start_x;
|
||||
}
|
||||
if (y + 16 > s_lcd_height) {
|
||||
break;
|
||||
}
|
||||
lcd_draw_char(x, y, *str, color, bg_color);
|
||||
x += FONT_WIDTH_8;
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:显示一个16x16 CJK汉字
|
||||
* 入口参数:x - 列坐标
|
||||
* y - 行坐标
|
||||
* unicode - Unicode码点 (如 0x4E00="一")
|
||||
* color - 字符颜色 (RGB565)
|
||||
* bg_color - 背景颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:框选16x16区域→遍历字模bit→发送color或bg_color
|
||||
*/
|
||||
void lcd_draw_chinese(uint16_t x, uint16_t y, uint16_t unicode,
|
||||
uint16_t color, uint16_t bg_color)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t j;
|
||||
uint8_t k;
|
||||
uint8_t line;
|
||||
const uint8_t *bitmap;
|
||||
|
||||
bitmap = cjk_get_bitmap(unicode);
|
||||
if (bitmap == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
st7735s_set_window(x, y, x + CJK_WIDTH - 1, y + CJK_HEIGHT - 1);
|
||||
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(LCD_DC_PORT, LCD_DC_PIN, GPIO_PIN_SET);
|
||||
for (i = 0; i < CJK_HEIGHT; i++) {
|
||||
for (j = 0; j < CJK_WIDTH / 8; j++) {
|
||||
line = bitmap[i * (CJK_WIDTH / 8) + j];
|
||||
for (k = 0; k < 8; k++) {
|
||||
if (line & 0x80) {
|
||||
st7735s_spi_write_byte((uint8_t)(color >> 8));
|
||||
st7735s_spi_write_byte((uint8_t)(color & 0xFF));
|
||||
} else {
|
||||
st7735s_spi_write_byte((uint8_t)(bg_color >> 8));
|
||||
st7735s_spi_write_byte((uint8_t)(bg_color & 0xFF));
|
||||
}
|
||||
line <<= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:显示UTF-8字符串(自动中英文混合)
|
||||
* 入口参数:x - 列坐标
|
||||
* y - 行坐标
|
||||
* str - UTF-8字符串指针
|
||||
* color - 字符颜色 (RGB565)
|
||||
* bg_color - 背景颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:自动识别ASCII(8x16)和CJK(16x16),自动换行
|
||||
*/
|
||||
void lcd_draw_chinese_string(uint16_t x, uint16_t y,
|
||||
const char *str,
|
||||
uint16_t color, uint16_t bg_color)
|
||||
{
|
||||
uint16_t start_x = x;
|
||||
|
||||
while (*str != '\0') {
|
||||
uint8_t c = (uint8_t)(*str);
|
||||
|
||||
if (*str == '\n') {
|
||||
y += CJK_HEIGHT;
|
||||
x = start_x;
|
||||
str++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c < 0x80) {
|
||||
if (x + 8 > s_lcd_width) {
|
||||
y += CJK_HEIGHT;
|
||||
x = start_x;
|
||||
}
|
||||
if (y + 16 > s_lcd_height) {
|
||||
break;
|
||||
}
|
||||
lcd_draw_char(x, y, (char)c, color, bg_color);
|
||||
x += 8;
|
||||
str++;
|
||||
} else {
|
||||
const char *p = str;
|
||||
uint16_t unicode = utf8_to_unicode(&p);
|
||||
if (unicode == 0) {
|
||||
str = p;
|
||||
continue;
|
||||
}
|
||||
if (x + CJK_WIDTH > s_lcd_width) {
|
||||
y += CJK_HEIGHT;
|
||||
x = start_x;
|
||||
}
|
||||
if (y + CJK_HEIGHT > s_lcd_height) {
|
||||
break;
|
||||
}
|
||||
lcd_draw_chinese(x, y, unicode, color, bg_color);
|
||||
x += CJK_WIDTH;
|
||||
str = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:画线(Bresenham算法)
|
||||
* 入口参数:x1 - 起始列
|
||||
* y1 - 起始行
|
||||
* x2 - 结束列
|
||||
* y2 - 结束行
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
*/
|
||||
void lcd_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
|
||||
{
|
||||
int16_t dx;
|
||||
int16_t dy;
|
||||
int16_t sx;
|
||||
int16_t sy;
|
||||
int16_t err;
|
||||
int16_t e2;
|
||||
int16_t x = (int16_t)x1;
|
||||
int16_t y = (int16_t)y1;
|
||||
|
||||
dx = (x1 < x2) ? (int16_t)(x2 - x1) : (int16_t)(x1 - x2);
|
||||
dy = (y1 < y2) ? (int16_t)(y2 - y1) : (int16_t)(y1 - y2);
|
||||
sx = (x1 < x2) ? 1 : -1;
|
||||
sy = (y1 < y2) ? 1 : -1;
|
||||
err = dx - dy;
|
||||
|
||||
while (1) {
|
||||
st7735s_draw_pixel((uint16_t)x, (uint16_t)y, color);
|
||||
if (x == (int16_t)x2 && y == (int16_t)y2) {
|
||||
break;
|
||||
}
|
||||
e2 = 2 * err;
|
||||
if (e2 > -dy) {
|
||||
err -= dy;
|
||||
x += sx;
|
||||
}
|
||||
if (e2 < dx) {
|
||||
err += dx;
|
||||
y += sy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:画空心矩形
|
||||
* 入口参数:x - 左上角列
|
||||
* y - 左上角行
|
||||
* width - 宽度
|
||||
* height - 高度
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
*/
|
||||
void lcd_draw_rect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color)
|
||||
{
|
||||
uint16_t x2 = x + width - 1;
|
||||
uint16_t y2 = y + height - 1;
|
||||
|
||||
lcd_draw_line(x, y, x2, y, color);
|
||||
lcd_draw_line(x, y, x, y2, color);
|
||||
lcd_draw_line(x2, y, x2, y2, color);
|
||||
lcd_draw_line(x, y2, x2, y2, color);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:画空心圆(Bresenham算法)
|
||||
* 入口参数:x0 - 圆心列
|
||||
* y0 - 圆心行
|
||||
* radius - 半径
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
*/
|
||||
void lcd_draw_circle(uint16_t x0, uint16_t y0, uint16_t radius, uint16_t color)
|
||||
{
|
||||
int16_t x = 0;
|
||||
int16_t y = (int16_t)radius;
|
||||
int16_t err = 1 - (int16_t)radius;
|
||||
int16_t xc = (int16_t)x0;
|
||||
int16_t yc = (int16_t)y0;
|
||||
|
||||
while (x <= y) {
|
||||
st7735s_draw_pixel((uint16_t)(xc + x), (uint16_t)(yc + y), color);
|
||||
st7735s_draw_pixel((uint16_t)(xc - x), (uint16_t)(yc + y), color);
|
||||
st7735s_draw_pixel((uint16_t)(xc + x), (uint16_t)(yc - y), color);
|
||||
st7735s_draw_pixel((uint16_t)(xc - x), (uint16_t)(yc - y), color);
|
||||
st7735s_draw_pixel((uint16_t)(xc + y), (uint16_t)(yc + x), color);
|
||||
st7735s_draw_pixel((uint16_t)(xc - y), (uint16_t)(yc + x), color);
|
||||
st7735s_draw_pixel((uint16_t)(xc + y), (uint16_t)(yc - x), color);
|
||||
st7735s_draw_pixel((uint16_t)(xc - y), (uint16_t)(yc - x), color);
|
||||
x++;
|
||||
if (err < 0) {
|
||||
err += 2 * x + 1;
|
||||
} else {
|
||||
y--;
|
||||
err += 2 * (x - y) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
109
STM32F103C8T6/Drivers/BSP/LCD/lcd.h
Normal file
109
STM32F103C8T6/Drivers/BSP/LCD/lcd.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 模块名称:LCD 绘图模块
|
||||
* 模块功能:提供字符、字符串(中英文混合)、线条、矩形、圆形等图形绘制
|
||||
* 适用平台:STM32F103C8T6 + ST7735S + 底层 st7735s.c
|
||||
* 作者:王建锋
|
||||
* 创建日期:2026-07-14
|
||||
* 修改记录:
|
||||
* 2026-07-14 王建锋 从 st7735s.c 拆分
|
||||
*/
|
||||
|
||||
#ifndef __LCD_H
|
||||
#define __LCD_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "st7735s.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/* 字体定义 */
|
||||
#define FONT_WIDTH_8 8 /* 8x16字体宽度(含间距) */
|
||||
#define FONT_HEIGHT_16 16 /* 8x16字体高度 */
|
||||
|
||||
/* === 字符/字符串绘制 === */
|
||||
|
||||
/*
|
||||
* 函数功能:显示一个8x16 ASCII字符
|
||||
* 入口参数:x - 列坐标
|
||||
* y - 行坐标
|
||||
* ch - 字符 (ASCII 32-126)
|
||||
* color - 字符颜色 (RGB565)
|
||||
* bg_color - 背景颜色 (RGB565)
|
||||
* 返回值:无
|
||||
*/
|
||||
void lcd_draw_char(uint16_t x, uint16_t y, char ch, uint16_t color, uint16_t bg_color);
|
||||
|
||||
/*
|
||||
* 函数功能:显示字符串(ASCII)
|
||||
* 入口参数:x - 列坐标
|
||||
* y - 行坐标
|
||||
* str - 字符串指针
|
||||
* color - 字符颜色 (RGB565)
|
||||
* bg_color - 背景颜色 (RGB565)
|
||||
* 返回值:无
|
||||
*/
|
||||
void lcd_draw_string(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bg_color);
|
||||
|
||||
/*
|
||||
* 函数功能:显示一个16x16 CJK汉字
|
||||
* 入口参数:x - 列坐标
|
||||
* y - 行坐标
|
||||
* unicode - Unicode码点 (如 0x4E00="一")
|
||||
* color - 字符颜色 (RGB565)
|
||||
* bg_color - 背景颜色 (RGB565)
|
||||
* 返回值:无
|
||||
*/
|
||||
void lcd_draw_chinese(uint16_t x, uint16_t y, uint16_t unicode, uint16_t color, uint16_t bg_color);
|
||||
|
||||
/*
|
||||
* 函数功能:显示UTF-8字符串(自动中英文混合)
|
||||
* 入口参数:x - 列坐标
|
||||
* y - 行坐标
|
||||
* str - UTF-8字符串指针
|
||||
* color - 字符颜色 (RGB565)
|
||||
* bg_color - 背景颜色 (RGB565)
|
||||
* 返回值:无
|
||||
*/
|
||||
void lcd_draw_chinese_string(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bg_color);
|
||||
|
||||
/* === 图形绘制 === */
|
||||
|
||||
/*
|
||||
* 函数功能:画线(Bresenham算法)
|
||||
* 入口参数:x1 - 起始列
|
||||
* y1 - 起始行
|
||||
* x2 - 结束列
|
||||
* y2 - 结束行
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
*/
|
||||
void lcd_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
|
||||
|
||||
/*
|
||||
* 函数功能:画空心矩形
|
||||
* 入口参数:x - 左上角列
|
||||
* y - 左上角行
|
||||
* width - 宽度
|
||||
* height - 高度
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
*/
|
||||
void lcd_draw_rect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color);
|
||||
|
||||
/*
|
||||
* 函数功能:画空心圆(Bresenham算法)
|
||||
* 入口参数:x0 - 圆心列
|
||||
* y0 - 圆心行
|
||||
* radius - 半径
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
*/
|
||||
void lcd_draw_circle(uint16_t x0, uint16_t y0, uint16_t radius, uint16_t color);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __LCD_H */
|
||||
@@ -2,296 +2,297 @@
|
||||
/*ASCII字模数据*********************/
|
||||
|
||||
/*宽8像素,高16像素*/
|
||||
/* 字体: simsun.ttc, 字号: 64, 阈值: 50 */
|
||||
const uint8_t LCD_F8x16[][16] =
|
||||
{
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0
|
||||
0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,// ! 1
|
||||
0x00,0x16,0x0E,0x00,0x16,0x0E,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// " 2
|
||||
0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,
|
||||
0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,// # 3
|
||||
0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,
|
||||
0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,// $ 4
|
||||
0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,
|
||||
0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,// % 5
|
||||
0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,
|
||||
0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,// & 6
|
||||
0x00,0x00,0x00,0x16,0x0E,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// ' 7
|
||||
0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,
|
||||
0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,// ( 8
|
||||
0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,
|
||||
0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,// ) 9
|
||||
0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,
|
||||
0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,// * 10
|
||||
0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,
|
||||
0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,// + 11
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,// , 12
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,// - 13
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,// . 14
|
||||
0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,
|
||||
0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,// / 15
|
||||
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,// 0 16
|
||||
0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,
|
||||
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,// 1 17
|
||||
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,
|
||||
0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,// 2 18
|
||||
0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,
|
||||
0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,// 3 19
|
||||
0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,
|
||||
0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,// 4 20
|
||||
0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,
|
||||
0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,// 5 21
|
||||
0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,
|
||||
0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,// 6 22
|
||||
0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,
|
||||
0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,// 7 23
|
||||
0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,
|
||||
0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,// 8 24
|
||||
0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,// 9 25
|
||||
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,// : 26
|
||||
0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,
|
||||
0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,// ; 27
|
||||
0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,
|
||||
0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,// < 28
|
||||
0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,
|
||||
0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,// = 29
|
||||
0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,
|
||||
0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,// > 30
|
||||
0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,
|
||||
0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,// ? 31
|
||||
0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,
|
||||
0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,// @ 32
|
||||
0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,
|
||||
0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,// A 33
|
||||
0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,
|
||||
0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,// B 34
|
||||
0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,
|
||||
0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,// C 35
|
||||
0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,// D 36
|
||||
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,
|
||||
0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,// E 37
|
||||
0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,
|
||||
0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,// F 38
|
||||
0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,
|
||||
0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,// G 39
|
||||
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,
|
||||
0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,// H 40
|
||||
0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,
|
||||
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,// I 41
|
||||
0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,
|
||||
0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,// J 42
|
||||
0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,
|
||||
0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,// K 43
|
||||
0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,
|
||||
0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,// L 44
|
||||
0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,
|
||||
0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,// M 45
|
||||
0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,
|
||||
0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,// N 46
|
||||
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,// O 47
|
||||
0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,
|
||||
0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,// P 48
|
||||
0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,
|
||||
0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,// Q 49
|
||||
0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,
|
||||
0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,// R 50
|
||||
0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,
|
||||
0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,// S 51
|
||||
0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,
|
||||
0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,// T 52
|
||||
0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,
|
||||
0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,// U 53
|
||||
0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,
|
||||
0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,// V 54
|
||||
0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,
|
||||
0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,// W 55
|
||||
0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,
|
||||
0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,// X 56
|
||||
0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,
|
||||
0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,// Y 57
|
||||
0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,
|
||||
0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,// Z 58
|
||||
0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,
|
||||
0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,// [ 59
|
||||
0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,// \ 60
|
||||
0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,
|
||||
0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,// ] 61
|
||||
0x00,0x20,0x10,0x08,0x04,0x08,0x10,0x20,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// ^ 62
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,// _ 63
|
||||
0x00,0x02,0x04,0x08,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// ` 64
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,
|
||||
0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,// a 65
|
||||
0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,
|
||||
0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,// b 66
|
||||
0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,
|
||||
0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,// c 67
|
||||
0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,
|
||||
0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,// d 68
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,
|
||||
0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,// e 69
|
||||
0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,
|
||||
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,// f 70
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,
|
||||
0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,// g 71
|
||||
0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,
|
||||
0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,// h 72
|
||||
0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,
|
||||
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,// i 73
|
||||
0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,
|
||||
0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,// j 74
|
||||
0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,
|
||||
0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,// k 75
|
||||
0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,
|
||||
0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,// l 76
|
||||
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
|
||||
0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,// m 77
|
||||
0x00,0x80,0x80,0x00,0x80,0x80,0x00,0x00,
|
||||
0x00,0x20,0x3F,0x21,0x00,0x20,0x3F,0x20,// n 78
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,
|
||||
0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,// o 79
|
||||
0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,
|
||||
0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,// p 80
|
||||
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,
|
||||
0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,// q 81
|
||||
0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,
|
||||
0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,// r 82
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,
|
||||
0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,// s 83
|
||||
0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,
|
||||
0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,// t 84
|
||||
0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,
|
||||
0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,// u 85
|
||||
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,
|
||||
0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,// v 86
|
||||
0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,
|
||||
0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,// w 87
|
||||
0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,
|
||||
0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,// x 88
|
||||
0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,
|
||||
0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,// y 89
|
||||
0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
|
||||
0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,// z 90
|
||||
0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,
|
||||
0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,// { 91
|
||||
0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,// | 92
|
||||
0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,
|
||||
0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,// } 93
|
||||
0x00,0x80,0x40,0x40,0x80,0x00,0x00,0x80,
|
||||
0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,// ~ 94
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0
|
||||
0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, // ! 1
|
||||
0x00, 0x16, 0x36, 0x3C, 0x68, 0x40, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // " 2
|
||||
0x00, 0x00, 0x20, 0x26, 0x26, 0xFF, 0x7E, 0x24,
|
||||
0x64, 0xFF, 0xFE, 0x64, 0x64, 0x00, 0x00, 0x00, // # 3
|
||||
0x00, 0x18, 0x3C, 0x7E, 0x7E, 0x78, 0x38, 0x18,
|
||||
0x1C, 0x1E, 0x7E, 0x56, 0x7C, 0x18, 0x18, 0x00, // $ 4
|
||||
0x00, 0x00, 0x60, 0xF4, 0x94, 0x9C, 0x98, 0xFC,
|
||||
0x1E, 0x1B, 0x3B, 0x2B, 0x6E, 0x04, 0x00, 0x00, // % 5
|
||||
0x00, 0x00, 0x30, 0x78, 0x68, 0x78, 0x78, 0x76,
|
||||
0xF4, 0xD4, 0xDC, 0xCC, 0x7F, 0x22, 0x00, 0x00, // & 6
|
||||
0x00, 0x60, 0x70, 0x30, 0x60, 0x40, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ' 7
|
||||
0x00, 0x02, 0x06, 0x0C, 0x0C, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x0C, 0x0C, 0x06, 0x02, 0x00, // ( 8
|
||||
0x00, 0x40, 0x60, 0x30, 0x30, 0x10, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x30, 0x30, 0x60, 0x40, 0x00, // ) 9
|
||||
0x00, 0x00, 0x00, 0x18, 0x18, 0xFF, 0x7E, 0x3C,
|
||||
0xFF, 0xDB, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, // * 10
|
||||
0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0xFF, 0x18,
|
||||
0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 11
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x70,
|
||||
0x20, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // , 12
|
||||
0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // - 13
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60,
|
||||
0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // . 14
|
||||
0x00, 0x02, 0x02, 0x06, 0x04, 0x0C, 0x08, 0x18,
|
||||
0x10, 0x30, 0x20, 0x60, 0x40, 0xC0, 0x80, 0x00, // / 15
|
||||
0x00, 0x00, 0x3C, 0x66, 0x66, 0x42, 0xC3, 0xC3,
|
||||
0xC3, 0xC3, 0x42, 0x66, 0x3C, 0x18, 0x00, 0x00, // 0 16
|
||||
0x00, 0x00, 0x18, 0x38, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x3C, 0x3C, 0x00, 0x00, // 1 17
|
||||
0x00, 0x00, 0x3C, 0x66, 0x62, 0x62, 0x06, 0x04,
|
||||
0x08, 0x10, 0x20, 0x42, 0xFE, 0x7C, 0x00, 0x00, // 2 18
|
||||
0x00, 0x00, 0x3C, 0x64, 0x66, 0x06, 0x0C, 0x1C,
|
||||
0x06, 0x02, 0x62, 0x66, 0x7C, 0x18, 0x00, 0x00, // 3 19
|
||||
0x00, 0x00, 0x04, 0x0C, 0x1C, 0x1C, 0x2C, 0x6C,
|
||||
0x4C, 0xFE, 0x0C, 0x0C, 0x0E, 0x1E, 0x00, 0x00, // 4 20
|
||||
0x00, 0x00, 0x3E, 0x7E, 0x60, 0x40, 0x7C, 0x66,
|
||||
0x06, 0x02, 0x62, 0x66, 0x7C, 0x18, 0x00, 0x00, // 5 21
|
||||
0x00, 0x00, 0x1C, 0x26, 0x62, 0x40, 0xDC, 0xF6,
|
||||
0xC2, 0xC3, 0x43, 0x62, 0x3E, 0x18, 0x00, 0x00, // 6 22
|
||||
0x00, 0x00, 0x7E, 0x7E, 0x44, 0x04, 0x0C, 0x08,
|
||||
0x18, 0x18, 0x18, 0x38, 0x38, 0x10, 0x00, 0x00, // 7 23
|
||||
0x00, 0x00, 0x3C, 0x66, 0x42, 0x62, 0x76, 0x3C,
|
||||
0x6E, 0x46, 0xC2, 0x46, 0x7C, 0x18, 0x00, 0x00, // 8 24
|
||||
0x00, 0x00, 0x3C, 0x66, 0x46, 0xC2, 0xC2, 0x66,
|
||||
0x7E, 0x16, 0x06, 0x64, 0x7C, 0x10, 0x00, 0x00, // 9 25
|
||||
0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00,
|
||||
0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, // : 26
|
||||
0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00,
|
||||
0x00, 0x18, 0x18, 0x18, 0x10, 0x00, 0x00, 0x00, // ; 27
|
||||
0x00, 0x00, 0x02, 0x06, 0x0C, 0x18, 0x30, 0x60,
|
||||
0x60, 0x30, 0x18, 0x0C, 0x06, 0x00, 0x00, 0x00, // < 28
|
||||
0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // = 29
|
||||
0x00, 0x00, 0x40, 0x60, 0x30, 0x18, 0x0C, 0x06,
|
||||
0x06, 0x0C, 0x18, 0x30, 0x60, 0x00, 0x00, 0x00, // > 30
|
||||
0x00, 0x00, 0x3C, 0x66, 0xC3, 0xC3, 0x46, 0x0C,
|
||||
0x18, 0x10, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, // ? 31
|
||||
0x00, 0x00, 0x1C, 0x36, 0x6F, 0x5F, 0xD7, 0xF5,
|
||||
0xF5, 0xFE, 0x7E, 0x63, 0x3E, 0x18, 0x00, 0x00, // @ 32
|
||||
0x00, 0x00, 0x18, 0x18, 0x18, 0x3C, 0x2C, 0x2C,
|
||||
0x3C, 0x7E, 0x46, 0x46, 0xC7, 0xC7, 0x00, 0x00, // A 33
|
||||
0x00, 0x00, 0xFC, 0x66, 0x62, 0x62, 0x66, 0x7C,
|
||||
0x66, 0x63, 0x63, 0x63, 0x7E, 0xF8, 0x00, 0x00, // B 34
|
||||
0x00, 0x00, 0x1E, 0x63, 0x41, 0xC0, 0xC0, 0xC0,
|
||||
0xC0, 0xC0, 0xC1, 0x62, 0x3E, 0x18, 0x00, 0x00, // C 35
|
||||
0x00, 0x00, 0xF8, 0x6C, 0x66, 0x63, 0x63, 0x63,
|
||||
0x63, 0x63, 0x62, 0x66, 0x7C, 0xF0, 0x00, 0x00, // D 36
|
||||
0x00, 0x00, 0x7E, 0x66, 0x62, 0x60, 0x64, 0x7C,
|
||||
0x64, 0x60, 0x60, 0x63, 0x7E, 0x7E, 0x00, 0x00, // E 37
|
||||
0x00, 0x00, 0x7E, 0x63, 0x61, 0x60, 0x64, 0x7C,
|
||||
0x64, 0x64, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, // F 38
|
||||
0x00, 0x00, 0x3C, 0x66, 0x42, 0xC0, 0xC0, 0xC0,
|
||||
0xC7, 0xC6, 0x46, 0x66, 0x3E, 0x18, 0x00, 0x00, // G 39
|
||||
0x00, 0x00, 0xE7, 0x66, 0x66, 0x66, 0x66, 0x7E,
|
||||
0x66, 0x66, 0x66, 0x66, 0x66, 0xE7, 0x00, 0x00, // H 40
|
||||
0x00, 0x00, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x3C, 0x3C, 0x00, 0x00, // I 41
|
||||
0x00, 0x3F, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C,
|
||||
0x0C, 0x0C, 0x0C, 0x0C, 0xCC, 0xF8, 0x20, 0x00, // J 42
|
||||
0x00, 0x00, 0xE6, 0x66, 0x6C, 0x68, 0x70, 0x78,
|
||||
0x68, 0x6C, 0x6C, 0x66, 0x67, 0x67, 0x00, 0x00, // K 43
|
||||
0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60,
|
||||
0x60, 0x60, 0x60, 0x63, 0x7E, 0x7E, 0x00, 0x00, // L 44
|
||||
0x00, 0x00, 0xC3, 0x66, 0x66, 0x66, 0x66, 0x6E,
|
||||
0x7E, 0x7A, 0x5A, 0x5A, 0xD7, 0xC7, 0x00, 0x00, // M 45
|
||||
0x00, 0x00, 0xC7, 0x62, 0x72, 0x72, 0x52, 0x5A,
|
||||
0x4A, 0x4E, 0x46, 0x46, 0xE2, 0xE0, 0x00, 0x00, // N 46
|
||||
0x00, 0x00, 0x3C, 0x66, 0x42, 0xC3, 0xC3, 0xC3,
|
||||
0xC3, 0xC3, 0x43, 0x66, 0x3C, 0x18, 0x00, 0x00, // O 47
|
||||
0x00, 0x00, 0x7C, 0x66, 0x63, 0x63, 0x62, 0x7E,
|
||||
0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, 0x00, // P 48
|
||||
0x00, 0x18, 0x3C, 0x66, 0xC3, 0xC3, 0xC3, 0xC3,
|
||||
0xC3, 0xFB, 0x7A, 0x6E, 0x3C, 0x06, 0x00, 0x00, // Q 49
|
||||
0x00, 0x00, 0x7C, 0x66, 0x62, 0x62, 0x66, 0x7C,
|
||||
0x68, 0x6C, 0x64, 0x66, 0x67, 0x63, 0x00, 0x00, // R 50
|
||||
0x00, 0x00, 0x3C, 0x66, 0x42, 0x60, 0x70, 0x3C,
|
||||
0x0E, 0x06, 0xC2, 0x46, 0x7E, 0x18, 0x00, 0x00, // S 51
|
||||
0x00, 0x00, 0x7E, 0xDB, 0x99, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, // T 52
|
||||
0x00, 0x00, 0xE7, 0x62, 0x62, 0x62, 0x62, 0x62,
|
||||
0x62, 0x62, 0x62, 0x62, 0x3C, 0x18, 0x00, 0x00, // U 53
|
||||
0x00, 0x00, 0xE7, 0x66, 0x66, 0x64, 0x24, 0x24,
|
||||
0x3C, 0x38, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, // V 54
|
||||
0x00, 0x00, 0xDB, 0xDB, 0x5A, 0x5A, 0x5A, 0x7E,
|
||||
0x7C, 0x7C, 0x2C, 0x2C, 0x24, 0x00, 0x00, 0x00, // W 55
|
||||
0x00, 0x00, 0x66, 0x66, 0x24, 0x3C, 0x18, 0x18,
|
||||
0x18, 0x3C, 0x2C, 0x24, 0x66, 0x66, 0x00, 0x00, // X 56
|
||||
0x00, 0x00, 0xE7, 0x62, 0x66, 0x34, 0x34, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, // Y 57
|
||||
0x00, 0x00, 0x7E, 0x66, 0x46, 0x0C, 0x08, 0x18,
|
||||
0x10, 0x30, 0x20, 0x62, 0xFE, 0x7C, 0x00, 0x00, // Z 58
|
||||
0x00, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
|
||||
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1E, 0x00, // [ 59
|
||||
0x00, 0x40, 0x60, 0x20, 0x30, 0x30, 0x10, 0x18,
|
||||
0x08, 0x0C, 0x0C, 0x04, 0x06, 0x02, 0x02, 0x00, // \ 60
|
||||
0x00, 0x78, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
|
||||
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x78, 0x00, // ] 61
|
||||
0x00, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ^ 62
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, // _ 63
|
||||
0x00, 0x70, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ` 64
|
||||
0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0x46, 0x3E,
|
||||
0x66, 0xC6, 0x6F, 0x36, 0x00, 0x00, 0x00, 0x00, // a 65
|
||||
0x00, 0x00, 0xC0, 0x60, 0x60, 0x60, 0x7C, 0x76,
|
||||
0x66, 0x62, 0x62, 0x66, 0x66, 0x5C, 0x00, 0x00, // b 66
|
||||
0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0x66, 0x40,
|
||||
0x40, 0x62, 0x76, 0x1C, 0x00, 0x00, 0x00, 0x00, // c 67
|
||||
0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x76,
|
||||
0x66, 0x46, 0x46, 0x66, 0x6E, 0x3E, 0x00, 0x00, // d 68
|
||||
0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0x42, 0x7E,
|
||||
0x40, 0x62, 0x76, 0x1C, 0x00, 0x00, 0x00, 0x00, // e 69
|
||||
0x00, 0x00, 0x0E, 0x1B, 0x31, 0x30, 0x7C, 0x30,
|
||||
0x30, 0x30, 0x30, 0x30, 0x38, 0x7C, 0x00, 0x00, // f 70
|
||||
0x00, 0x00, 0x00, 0x1B, 0x2F, 0x66, 0x66, 0x3C,
|
||||
0x78, 0x7E, 0x46, 0x66, 0x3C, 0x00, 0x00, 0x00, // g 71
|
||||
0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x7C, 0x66,
|
||||
0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, // h 72
|
||||
0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x38, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x3C, 0x3C, 0x00, 0x00, // i 73
|
||||
0x00, 0x04, 0x06, 0x00, 0x00, 0x1E, 0x06, 0x06,
|
||||
0x06, 0x06, 0x06, 0x06, 0x04, 0x6C, 0x38, 0x00, // j 74
|
||||
0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x66, 0x6C,
|
||||
0x68, 0x78, 0x6C, 0x6C, 0x66, 0x67, 0x00, 0x00, // k 75
|
||||
0x00, 0x00, 0x38, 0x38, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, // l 76
|
||||
0x00, 0x00, 0x00, 0x00, 0xFE, 0xDB, 0xDB, 0xDB,
|
||||
0xDB, 0xDB, 0xDB, 0xDB, 0x00, 0x00, 0x00, 0x00, // m 77
|
||||
0x00, 0x00, 0x00, 0x00, 0xFC, 0x76, 0x66, 0x66,
|
||||
0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, // n 78
|
||||
0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0x42, 0xC3,
|
||||
0xC3, 0x42, 0x66, 0x38, 0x00, 0x00, 0x00, 0x00, // o 79
|
||||
0x00, 0x00, 0x00, 0x7C, 0x76, 0x62, 0x63, 0x63,
|
||||
0x62, 0x66, 0x7C, 0x60, 0x70, 0x00, 0x00, 0x00, // p 80
|
||||
0x00, 0x00, 0x00, 0x3E, 0x66, 0x46, 0xC6, 0xC6,
|
||||
0x46, 0x7E, 0x16, 0x06, 0x0E, 0x00, 0x00, 0x00, // q 81
|
||||
0x00, 0x00, 0x00, 0x00, 0xFE, 0x3B, 0x30, 0x30,
|
||||
0x30, 0x30, 0x30, 0xF8, 0x00, 0x00, 0x00, 0x00, // r 82
|
||||
0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0x60, 0x38,
|
||||
0x0E, 0x46, 0x66, 0x7C, 0x00, 0x00, 0x00, 0x00, // s 83
|
||||
0x00, 0x00, 0x00, 0x10, 0x10, 0x7C, 0x10, 0x10,
|
||||
0x10, 0x10, 0x10, 0x1E, 0x0C, 0x00, 0x00, 0x00, // t 84
|
||||
0x00, 0x00, 0x00, 0x00, 0xE6, 0x66, 0x66, 0x66,
|
||||
0x66, 0x66, 0x6E, 0x3E, 0x00, 0x00, 0x00, 0x00, // u 85
|
||||
0x00, 0x00, 0x00, 0x00, 0xE6, 0x66, 0x24, 0x34,
|
||||
0x38, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, // v 86
|
||||
0x00, 0x00, 0x00, 0x00, 0xDB, 0xDA, 0x5A, 0x7E,
|
||||
0x7C, 0x2C, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, // w 87
|
||||
0x00, 0x00, 0x00, 0x00, 0x76, 0x34, 0x38, 0x18,
|
||||
0x18, 0x2C, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, // x 88
|
||||
0x00, 0x00, 0x00, 0x67, 0x66, 0x34, 0x34, 0x1C,
|
||||
0x18, 0x18, 0x18, 0x70, 0x60, 0x00, 0x00, 0x00, // y 89
|
||||
0x00, 0x00, 0x00, 0x00, 0x7E, 0x4C, 0x08, 0x18,
|
||||
0x30, 0x22, 0x7E, 0x7C, 0x00, 0x00, 0x00, 0x00, // z 90
|
||||
0x00, 0x06, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x18,
|
||||
0x18, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x06, 0x00, // { 91
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, // | 92
|
||||
0x00, 0x60, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18,
|
||||
0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x60, 0x00, // } 93
|
||||
0x00, 0x70, 0x59, 0x0E, 0x04, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // ~ 94
|
||||
};
|
||||
|
||||
/*宽6像素,高8像素*/
|
||||
const uint8_t LCD_F6x8[][6] =
|
||||
/*宽6像素,高8像素(未使用)*/
|
||||
const uint8_t LCD_F6x8[][6] =
|
||||
{
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,// 0
|
||||
0x00,0x00,0x00,0x2F,0x00,0x00,// ! 1
|
||||
0x00,0x00,0x07,0x00,0x07,0x00,// " 2
|
||||
0x00,0x14,0x7F,0x14,0x7F,0x14,// # 3
|
||||
0x00,0x24,0x2A,0x7F,0x2A,0x12,// $ 4
|
||||
0x00,0x23,0x13,0x08,0x64,0x62,// % 5
|
||||
0x00,0x36,0x49,0x55,0x22,0x50,// & 6
|
||||
0x00,0x00,0x00,0x07,0x00,0x00,// ' 7
|
||||
0x00,0x00,0x1C,0x22,0x41,0x00,// ( 8
|
||||
0x00,0x00,0x41,0x22,0x1C,0x00,// ) 9
|
||||
0x00,0x14,0x08,0x3E,0x08,0x14,// * 10
|
||||
0x00,0x08,0x08,0x3E,0x08,0x08,// + 11
|
||||
0x00,0x00,0x00,0xA0,0x60,0x00,// , 12
|
||||
0x00,0x08,0x08,0x08,0x08,0x08,// - 13
|
||||
0x00,0x00,0x60,0x60,0x00,0x00,// . 14
|
||||
0x00,0x20,0x10,0x08,0x04,0x02,// / 15
|
||||
0x00,0x3E,0x51,0x49,0x45,0x3E,// 0 16
|
||||
0x00,0x00,0x42,0x7F,0x40,0x00,// 1 17
|
||||
0x00,0x42,0x61,0x51,0x49,0x46,// 2 18
|
||||
0x00,0x21,0x41,0x45,0x4B,0x31,// 3 19
|
||||
0x00,0x18,0x14,0x12,0x7F,0x10,// 4 20
|
||||
0x00,0x27,0x45,0x45,0x45,0x39,// 5 21
|
||||
0x00,0x3C,0x4A,0x49,0x49,0x30,// 6 22
|
||||
0x00,0x01,0x71,0x09,0x05,0x03,// 7 23
|
||||
0x00,0x36,0x49,0x49,0x49,0x36,// 8 24
|
||||
0x00,0x06,0x49,0x49,0x29,0x1E,// 9 25
|
||||
0x00,0x00,0x36,0x36,0x00,0x00,// : 26
|
||||
0x00,0x00,0x56,0x36,0x00,0x00,// ; 27
|
||||
0x00,0x08,0x14,0x22,0x41,0x00,// < 28
|
||||
0x00,0x14,0x14,0x14,0x14,0x14,// = 29
|
||||
0x00,0x00,0x41,0x22,0x14,0x08,// > 30
|
||||
0x00,0x02,0x01,0x51,0x09,0x06,// ? 31
|
||||
0x00,0x3E,0x49,0x55,0x59,0x2E,// @ 32
|
||||
0x00,0x7C,0x12,0x11,0x12,0x7C,// A 33
|
||||
0x00,0x7F,0x49,0x49,0x49,0x36,// B 34
|
||||
0x00,0x3E,0x41,0x41,0x41,0x22,// C 35
|
||||
0x00,0x7F,0x41,0x41,0x22,0x1C,// D 36
|
||||
0x00,0x7F,0x49,0x49,0x49,0x41,// E 37
|
||||
0x00,0x7F,0x09,0x09,0x09,0x01,// F 38
|
||||
0x00,0x3E,0x41,0x49,0x49,0x7A,// G 39
|
||||
0x00,0x7F,0x08,0x08,0x08,0x7F,// H 40
|
||||
0x00,0x00,0x41,0x7F,0x41,0x00,// I 41
|
||||
0x00,0x20,0x40,0x41,0x3F,0x01,// J 42
|
||||
0x00,0x7F,0x08,0x14,0x22,0x41,// K 43
|
||||
0x00,0x7F,0x40,0x40,0x40,0x40,// L 44
|
||||
0x00,0x7F,0x02,0x0C,0x02,0x7F,// M 45
|
||||
0x00,0x7F,0x04,0x08,0x10,0x7F,// N 46
|
||||
0x00,0x3E,0x41,0x41,0x41,0x3E,// O 47
|
||||
0x00,0x7F,0x09,0x09,0x09,0x06,// P 48
|
||||
0x00,0x3E,0x41,0x51,0x21,0x5E,// Q 49
|
||||
0x00,0x7F,0x09,0x19,0x29,0x46,// R 50
|
||||
0x00,0x46,0x49,0x49,0x49,0x31,// S 51
|
||||
0x00,0x01,0x01,0x7F,0x01,0x01,// T 52
|
||||
0x00,0x3F,0x40,0x40,0x40,0x3F,// U 53
|
||||
0x00,0x1F,0x20,0x40,0x20,0x1F,// V 54
|
||||
0x00,0x3F,0x40,0x38,0x40,0x3F,// W 55
|
||||
0x00,0x63,0x14,0x08,0x14,0x63,// X 56
|
||||
0x00,0x07,0x08,0x70,0x08,0x07,// Y 57
|
||||
0x00,0x61,0x51,0x49,0x45,0x43,// Z 58
|
||||
0x00,0x00,0x7F,0x41,0x41,0x00,// [ 59
|
||||
0x00,0x02,0x04,0x08,0x10,0x20,// \ 60
|
||||
0x00,0x00,0x41,0x41,0x7F,0x00,// ] 61
|
||||
0x00,0x04,0x02,0x01,0x02,0x04,// ^ 62
|
||||
0x00,0x40,0x40,0x40,0x40,0x40,// _ 63
|
||||
0x00,0x00,0x01,0x02,0x04,0x00,// ` 64
|
||||
0x00,0x20,0x54,0x54,0x54,0x78,// a 65
|
||||
0x00,0x7F,0x48,0x44,0x44,0x38,// b 66
|
||||
0x00,0x38,0x44,0x44,0x44,0x20,// c 67
|
||||
0x00,0x38,0x44,0x44,0x48,0x7F,// d 68
|
||||
0x00,0x38,0x54,0x54,0x54,0x18,// e 69
|
||||
0x00,0x08,0x7E,0x09,0x01,0x02,// f 70
|
||||
0x00,0x18,0xA4,0xA4,0xA4,0x7C,// g 71
|
||||
0x00,0x7F,0x08,0x04,0x04,0x78,// h 72
|
||||
0x00,0x00,0x44,0x7D,0x40,0x00,// i 73
|
||||
0x00,0x40,0x80,0x84,0x7D,0x00,// j 74
|
||||
0x00,0x7F,0x10,0x28,0x44,0x00,// k 75
|
||||
0x00,0x00,0x41,0x7F,0x40,0x00,// l 76
|
||||
0x00,0x7C,0x04,0x18,0x04,0x78,// m 77
|
||||
0x00,0x7C,0x08,0x04,0x04,0x78,// n 78
|
||||
0x00,0x38,0x44,0x44,0x44,0x38,// o 79
|
||||
0x00,0xFC,0x24,0x24,0x24,0x18,// p 80
|
||||
0x00,0x18,0x24,0x24,0x18,0xFC,// q 81
|
||||
0x00,0x7C,0x08,0x04,0x04,0x08,// r 82
|
||||
0x00,0x48,0x54,0x54,0x54,0x20,// s 83
|
||||
0x00,0x04,0x3F,0x44,0x40,0x20,// t 84
|
||||
0x00,0x3C,0x40,0x40,0x20,0x7C,// u 85
|
||||
0x00,0x1C,0x20,0x40,0x20,0x1C,// v 86
|
||||
0x00,0x3C,0x40,0x30,0x40,0x3C,// w 87
|
||||
0x00,0x44,0x28,0x10,0x28,0x44,// x 88
|
||||
0x00,0x1C,0xA0,0xA0,0xA0,0x7C,// y 89
|
||||
0x00,0x44,0x64,0x54,0x4C,0x44,// z 90
|
||||
0x00,0x00,0x08,0x7F,0x41,0x00,// { 91
|
||||
0x00,0x00,0x00,0x7F,0x00,0x00,// | 92
|
||||
0x00,0x00,0x41,0x7F,0x08,0x00,// } 93
|
||||
0x00,0x08,0x04,0x08,0x10,0x08,// ~ 94
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // 0
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // ! 1
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // " 2
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // # 3
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // $ 4
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // % 5
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // & 6
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // ' 7
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // ( 8
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // ) 9
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // * 10
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // + 11
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // , 12
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // - 13
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // . 14
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // / 15
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // 0 16
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // 1 17
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // 2 18
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // 3 19
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // 4 20
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // 5 21
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // 6 22
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // 7 23
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // 8 24
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // 9 25
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // : 26
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // ; 27
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // < 28
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // = 29
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // > 30
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // ? 31
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // @ 32
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // A 33
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // B 34
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // C 35
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // D 36
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // E 37
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // F 38
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // G 39
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // H 40
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // I 41
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // J 42
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // K 43
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // L 44
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // M 45
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // N 46
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // O 47
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // P 48
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // Q 49
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // R 50
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // S 51
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // T 52
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // U 53
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // V 54
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // W 55
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // X 56
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // Y 57
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // Z 58
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // [ 59
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // \ 60
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // ] 61
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // ^ 62
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // _ 63
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // ` 64
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // a 65
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // b 66
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // c 67
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // d 68
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // e 69
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // f 70
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // g 71
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // h 72
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // i 73
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // j 74
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // k 75
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // l 76
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // m 77
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // n 78
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // o 79
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // p 80
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // q 81
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // r 82
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // s 83
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // t 84
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // u 85
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // v 86
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // w 87
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // x 88
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // y 89
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // z 90
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // { 91
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // | 92
|
||||
0x00,0x00,0x00,0x00,0x00,0x00, // } 93
|
||||
0x00,0x00,0x00,0x00,0x00,0x00 // ~ 94
|
||||
};
|
||||
|
||||
@@ -1,59 +1,62 @@
|
||||
/*
|
||||
* 模块名称:ST7735S LCD驱动
|
||||
* 模块功能:提供128x160 RGB TFT屏幕的初始化、画点、画线、填充、显示字符串等功能
|
||||
* 适用平台:STM32F103C8T6 + SPI2
|
||||
* 模块名称:ST7735S LCD驱动(底层)
|
||||
* 模块功能:提供ST7735S屏幕的硬件SPI通信、初始化、填充、画点、方向控制等底层操作
|
||||
* 绘图函数见 lcd.c
|
||||
* 适用平台:STM32F103C8T6 + 硬件SPI2
|
||||
* 作者:王建锋
|
||||
* 创建日期:2026-07-13
|
||||
* 修改记录:
|
||||
* 2026-07-13 王建锋 创建初始版本
|
||||
* 2026-07-14 王建锋 软件SPI -> 硬件SPI2
|
||||
* 2026-07-14 王建锋 拆分:绘图函数移入 lcd.c
|
||||
*/
|
||||
|
||||
#include "st7735s.h"
|
||||
#include "lcd_data.h"
|
||||
#include "spi.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static uint16_t s_lcd_width = LCD_WIDTH;
|
||||
static uint16_t s_lcd_height = LCD_HEIGHT;
|
||||
|
||||
extern DMA_HandleTypeDef hdma_spi2_tx;
|
||||
|
||||
/* 8x16 ASCII字体(ASCII 32-126),每字符16字节 - 定义在 lcd_data.c 中 */
|
||||
|
||||
/*
|
||||
* 函数功能:软件SPI写一个字节
|
||||
* 部分屏幕厂家虽然标称128x160,但实际使用132x162驱动晶片,
|
||||
* 左右各偏移2列,上下偏移1行才能正确显示。
|
||||
* 根据自己的屏幕实测调整这两个值。
|
||||
*/
|
||||
#define X_OFFSET 2
|
||||
#define Y_OFFSET 1
|
||||
|
||||
uint16_t s_lcd_width = LCD_WIDTH;
|
||||
uint16_t s_lcd_height = LCD_HEIGHT;
|
||||
|
||||
/*
|
||||
* 函数功能:硬件SPI写一个字节
|
||||
* 入口参数:data - 要发送的数据
|
||||
* 返回值:无
|
||||
* 函数说明:模拟SPI时序发送一个字节,MSB先
|
||||
* 函数说明:使用SPI2外设发送一个字节
|
||||
*/
|
||||
static void st7735s_spi_write_byte(uint8_t data)
|
||||
void st7735s_spi_write_byte(uint8_t data)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
HAL_GPIO_WritePin(LCD_SCL_PORT, LCD_SCL_PIN, GPIO_PIN_RESET);
|
||||
if (data & 0x80) {
|
||||
HAL_GPIO_WritePin(LCD_SDA_PORT, LCD_SDA_PIN, GPIO_PIN_SET);
|
||||
} else {
|
||||
HAL_GPIO_WritePin(LCD_SDA_PORT, LCD_SDA_PIN, GPIO_PIN_RESET);
|
||||
}
|
||||
__NOP();
|
||||
__NOP();
|
||||
HAL_GPIO_WritePin(LCD_SCL_PORT, LCD_SCL_PIN, GPIO_PIN_SET);
|
||||
__NOP();
|
||||
__NOP();
|
||||
data <<= 1;
|
||||
}
|
||||
HAL_SPI_Transmit(&hspi2, &data, 1, HAL_MAX_DELAY);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:写入命令
|
||||
* 函数功能:硬件SPI批量写数据
|
||||
* 入口参数:data - 数据缓冲区
|
||||
* len - 字节数
|
||||
* 返回值:无
|
||||
* 函数说明:使用DMA批量发送
|
||||
*/
|
||||
void st7735s_spi_write_bulk(const uint8_t *data, uint32_t len)
|
||||
{
|
||||
HAL_SPI_Transmit_DMA(&hspi2, (uint8_t *)data, len);
|
||||
while (HAL_SPI_GetState(&hspi2) != HAL_SPI_STATE_READY);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:写入命令(CS+DC管理,单字节)
|
||||
* 入口参数:cmd - 命令字节
|
||||
* 返回值:无
|
||||
* 函数说明:拉低DC,选择芯片,发送命令,释放芯片
|
||||
* 函数说明:拉低DC,发送命令
|
||||
*/
|
||||
static void st7735s_write_cmd(uint8_t cmd)
|
||||
void st7735s_write_cmd(uint8_t cmd)
|
||||
{
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(LCD_DC_PORT, LCD_DC_PIN, GPIO_PIN_RESET);
|
||||
@@ -62,12 +65,12 @@ static void st7735s_write_cmd(uint8_t cmd)
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:写入数据
|
||||
* 函数功能:写入数据(CS+DC管理,单字节)
|
||||
* 入口参数:data - 数据字节
|
||||
* 返回值:无
|
||||
* 函数说明:拉高DC,选择芯片,发送数据,释放芯片
|
||||
* 函数说明:拉高DC,发送数据
|
||||
*/
|
||||
static void st7735s_write_data(uint8_t data)
|
||||
void st7735s_write_data(uint8_t data)
|
||||
{
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(LCD_DC_PORT, LCD_DC_PIN, GPIO_PIN_SET);
|
||||
@@ -76,119 +79,83 @@ static void st7735s_write_data(uint8_t data)
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:写入多字节数据(CS保持低)
|
||||
* 入口参数:p_data - 数据缓冲区指针
|
||||
* len - 字节数
|
||||
* 函数功能:设置显示窗口(框选区域)
|
||||
* 入口参数:x1 - 起始列(屏幕坐标,含偏移处理)
|
||||
* y1 - 起始行
|
||||
* x2 - 结束列
|
||||
* y2 - 结束行
|
||||
* 返回值:无
|
||||
* 函数说明:用于连续写入多个数据字节,省去中间CS跳变
|
||||
* 函数说明:发送CASET(2Ah)+RASET(2Bh)+RAMWR(2Ch),
|
||||
* 后续写入的数据将填充在此区域内
|
||||
*/
|
||||
static void st7735s_write_data_multi(const uint8_t *p_data, uint16_t len)
|
||||
void st7735s_set_window(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
|
||||
{
|
||||
uint16_t i;
|
||||
st7735s_write_cmd(LCD_CMD_CASET);
|
||||
st7735s_write_data(0x00);
|
||||
st7735s_write_data(x1 + X_OFFSET);
|
||||
st7735s_write_data(0x00);
|
||||
st7735s_write_data(x2 + X_OFFSET);
|
||||
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(LCD_DC_PORT, LCD_DC_PIN, GPIO_PIN_SET);
|
||||
for (i = 0; i < len; i++) {
|
||||
st7735s_spi_write_byte(p_data[i]);
|
||||
}
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_SET);
|
||||
}
|
||||
st7735s_write_cmd(LCD_CMD_RASET);
|
||||
st7735s_write_data(0x00);
|
||||
st7735s_write_data(y1 + Y_OFFSET);
|
||||
st7735s_write_data(0x00);
|
||||
st7735s_write_data(y2 + Y_OFFSET);
|
||||
|
||||
/*
|
||||
* 函数功能:写入16位颜色数据
|
||||
* 入口参数:p_color - 16位颜色缓冲区指针
|
||||
* len - 像素个数
|
||||
* 返回值:无
|
||||
* 函数说明:MSB先发送RGB565数据
|
||||
*/
|
||||
static void st7735s_write_colors(uint16_t *p_color, uint16_t len)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(LCD_DC_PORT, LCD_DC_PIN, GPIO_PIN_SET);
|
||||
for (i = 0; i < len; i++) {
|
||||
st7735s_spi_write_byte((uint8_t)(p_color[i] >> 8));
|
||||
st7735s_spi_write_byte((uint8_t)(p_color[i] & 0xFF));
|
||||
}
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_SET);
|
||||
st7735s_write_cmd(LCD_CMD_RAMWR);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:LCD初始化
|
||||
* 入口参数:无
|
||||
* 返回值:无
|
||||
* 函数说明:执行ST7735S标准初始化序列
|
||||
* 函数说明:初始化ST7735S屏幕,依赖MX_SPI2_Init()提前配置好SPI2
|
||||
*/
|
||||
void st7735s_init(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
printf("LCD init start (HW SPI2)...\r\n");
|
||||
|
||||
printf("LCD init start (soft SPI)...\r\n");
|
||||
|
||||
/* 将SCL和SDA引脚切换为GPIO输出(软件SPI) */
|
||||
GPIO_InitStruct.Pin = LCD_SCL_PIN | LCD_SDA_PIN;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
HAL_GPIO_WritePin(LCD_SCL_PORT, LCD_SCL_PIN, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(LCD_SDA_PORT, LCD_SDA_PIN, GPIO_PIN_SET);
|
||||
|
||||
/* 确保CS和RST初始为高,避免LCD在初始化期间被错误选中 */
|
||||
/* CS初始高电平 */
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(LCD_RST_PORT, LCD_RST_PIN, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(LCD_DC_PORT, LCD_DC_PIN, GPIO_PIN_RESET);
|
||||
HAL_Delay(10);
|
||||
|
||||
printf("IO: RST=%d DC=%d CS=%d\r\n",
|
||||
(int)HAL_GPIO_ReadPin(LCD_RST_PORT, LCD_RST_PIN),
|
||||
(int)HAL_GPIO_ReadPin(LCD_DC_PORT, LCD_DC_PIN),
|
||||
(int)HAL_GPIO_ReadPin(LCD_CS_PORT, LCD_CS_PIN));
|
||||
|
||||
/* 硬件复位 */
|
||||
printf("HW reset...\r\n");
|
||||
HAL_GPIO_WritePin(LCD_RST_PORT, LCD_RST_PIN, GPIO_PIN_RESET);
|
||||
HAL_Delay(10);
|
||||
HAL_Delay(20);
|
||||
HAL_GPIO_WritePin(LCD_RST_PORT, LCD_RST_PIN, GPIO_PIN_SET);
|
||||
HAL_Delay(120);
|
||||
HAL_Delay(150);
|
||||
|
||||
/* 软件复位 */
|
||||
printf("SW reset...\r\n");
|
||||
st7735s_write_cmd(LCD_CMD_SWRESET);
|
||||
HAL_Delay(150);
|
||||
|
||||
/* 退出睡眠模式 */
|
||||
printf("Sleep out...\r\n");
|
||||
st7735s_write_cmd(LCD_CMD_SLPOUT);
|
||||
HAL_Delay(500);
|
||||
HAL_Delay(120);
|
||||
|
||||
/* 帧率控制 */
|
||||
printf("Frame rate...\r\n");
|
||||
st7735s_write_cmd(LCD_CMD_FRMCTR1);
|
||||
st7735s_write_data(0x01);
|
||||
st7735s_write_data(0x2C);
|
||||
st7735s_write_data(0x2D);
|
||||
st7735s_write_data(0x05);
|
||||
st7735s_write_data(0x3C);
|
||||
st7735s_write_data(0x3C);
|
||||
|
||||
st7735s_write_cmd(LCD_CMD_FRMCTR2);
|
||||
st7735s_write_data(0x01);
|
||||
st7735s_write_data(0x2C);
|
||||
st7735s_write_data(0x2D);
|
||||
st7735s_write_data(0x05);
|
||||
st7735s_write_data(0x3C);
|
||||
st7735s_write_data(0x3C);
|
||||
|
||||
st7735s_write_cmd(LCD_CMD_FRMCTR3);
|
||||
st7735s_write_data(0x01);
|
||||
st7735s_write_data(0x2C);
|
||||
st7735s_write_data(0x2D);
|
||||
st7735s_write_data(0x01);
|
||||
st7735s_write_data(0x2C);
|
||||
st7735s_write_data(0x2D);
|
||||
st7735s_write_data(0x05);
|
||||
st7735s_write_data(0x3C);
|
||||
st7735s_write_data(0x3C);
|
||||
st7735s_write_data(0x05);
|
||||
st7735s_write_data(0x3C);
|
||||
st7735s_write_data(0x3C);
|
||||
|
||||
/* 显示反转控制 */
|
||||
/* 显示反转控制(列反转) */
|
||||
st7735s_write_cmd(LCD_CMD_INVCTR);
|
||||
st7735s_write_data(0x07);
|
||||
st7735s_write_data(0x03);
|
||||
|
||||
/* 功率控制 */
|
||||
printf("Power ctrl...\r\n");
|
||||
st7735s_write_cmd(LCD_CMD_PWCTR1);
|
||||
st7735s_write_data(0xA2);
|
||||
st7735s_write_data(0x02);
|
||||
@@ -198,108 +165,113 @@ void st7735s_init(void)
|
||||
st7735s_write_data(0xC5);
|
||||
|
||||
st7735s_write_cmd(LCD_CMD_PWCTR3);
|
||||
st7735s_write_data(0x0A);
|
||||
st7735s_write_data(0x0D);
|
||||
st7735s_write_data(0x00);
|
||||
|
||||
st7735s_write_cmd(LCD_CMD_PWCTR4);
|
||||
st7735s_write_data(0x8A);
|
||||
st7735s_write_data(0x8D);
|
||||
st7735s_write_data(0x2A);
|
||||
|
||||
st7735s_write_cmd(LCD_CMD_PWCTR5);
|
||||
st7735s_write_data(0x8A);
|
||||
st7735s_write_data(0x8D);
|
||||
st7735s_write_data(0xEE);
|
||||
|
||||
/* VCOM控制 */
|
||||
st7735s_write_cmd(LCD_CMD_VMCTR1);
|
||||
st7735s_write_data(0x0E);
|
||||
|
||||
/* 竖屏模式 */
|
||||
printf("MADCTL...\r\n");
|
||||
st7735s_write_cmd(LCD_CMD_MADCTL);
|
||||
st7735s_write_data(0xC8);
|
||||
/* 关闭反转显示 */
|
||||
st7735s_write_cmd(0x20);
|
||||
/* 关闭空闲模式 */
|
||||
st7735s_write_cmd(0x38);
|
||||
/* 正常模式(非部分模式) */
|
||||
st7735s_write_cmd(0x13);
|
||||
|
||||
/* 像素格式: 16位RGB565 */
|
||||
printf("COLMOD...\r\n");
|
||||
/* 存储器访问控制 (MADCTL)
|
||||
* MY=0 MX=0 MV=0 ML=0 RGB=0 MH=0 → 0x00
|
||||
* 左上角为坐标原点,列从左到右,行从上到下
|
||||
*/
|
||||
st7735s_write_cmd(LCD_CMD_MADCTL);
|
||||
st7735s_write_data(0x00);
|
||||
|
||||
/* 像素格式:16位 RGB565 */
|
||||
st7735s_write_cmd(LCD_CMD_COLMOD);
|
||||
st7735s_write_data(0x05);
|
||||
|
||||
/* Gamma校正 */
|
||||
printf("Gamma...\r\n");
|
||||
st7735s_write_cmd(LCD_CMD_GMCTRP1);
|
||||
st7735s_write_data(0x02);
|
||||
st7735s_write_data(0x1C);
|
||||
st7735s_write_data(0x07);
|
||||
st7735s_write_data(0x12);
|
||||
st7735s_write_data(0x37);
|
||||
st7735s_write_data(0x32);
|
||||
st7735s_write_data(0x29);
|
||||
st7735s_write_data(0x2D);
|
||||
st7735s_write_data(0x29);
|
||||
st7735s_write_data(0x25);
|
||||
st7735s_write_data(0x2B);
|
||||
st7735s_write_data(0x39);
|
||||
st7735s_write_data(0x00);
|
||||
st7735s_write_data(0x01);
|
||||
st7735s_write_data(0x03);
|
||||
st7735s_write_data(0x10);
|
||||
st7735s_write_data(0x0F);
|
||||
st7735s_write_data(0x1A);
|
||||
st7735s_write_data(0x0F);
|
||||
st7735s_write_data(0x18);
|
||||
st7735s_write_data(0x2F);
|
||||
st7735s_write_data(0x28);
|
||||
st7735s_write_data(0x22);
|
||||
st7735s_write_data(0x26);
|
||||
st7735s_write_data(0x31);
|
||||
st7735s_write_data(0x1B);
|
||||
st7735s_write_data(0x13);
|
||||
st7735s_write_data(0x1E);
|
||||
st7735s_write_data(0x13);
|
||||
st7735s_write_data(0x11);
|
||||
st7735s_write_data(0x06);
|
||||
|
||||
st7735s_write_cmd(LCD_CMD_GMCTRN1);
|
||||
st7735s_write_data(0x03);
|
||||
st7735s_write_data(0x1D);
|
||||
st7735s_write_data(0x07);
|
||||
st7735s_write_data(0x06);
|
||||
st7735s_write_data(0x2E);
|
||||
st7735s_write_data(0x0F);
|
||||
st7735s_write_data(0x1B);
|
||||
st7735s_write_data(0x0F);
|
||||
st7735s_write_data(0x17);
|
||||
st7735s_write_data(0x33);
|
||||
st7735s_write_data(0x2C);
|
||||
st7735s_write_data(0x29);
|
||||
st7735s_write_data(0x2D);
|
||||
st7735s_write_data(0x2E);
|
||||
st7735s_write_data(0x2E);
|
||||
st7735s_write_data(0x37);
|
||||
st7735s_write_data(0x30);
|
||||
st7735s_write_data(0x30);
|
||||
st7735s_write_data(0x39);
|
||||
st7735s_write_data(0x3F);
|
||||
st7735s_write_data(0x00);
|
||||
st7735s_write_data(0x00);
|
||||
st7735s_write_data(0x02);
|
||||
st7735s_write_data(0x10);
|
||||
st7735s_write_data(0x34);
|
||||
st7735s_write_data(0x14);
|
||||
st7735s_write_data(0x06);
|
||||
|
||||
/* 关闭反转 */
|
||||
st7735s_write_cmd(0x20);
|
||||
|
||||
/* 进入正常显示模式(关键!) */
|
||||
printf("NORON...\r\n");
|
||||
st7735s_write_cmd(0x13);
|
||||
HAL_Delay(10);
|
||||
|
||||
/* 开启显示 */
|
||||
printf("DISPON...\r\n");
|
||||
/* 显示开启 */
|
||||
st7735s_write_cmd(LCD_CMD_DISPON);
|
||||
HAL_Delay(100);
|
||||
printf("LCD init done\r\n");
|
||||
|
||||
printf("LCD init OK\r\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:设置显示窗口
|
||||
* 入口参数:x1 - 起始列
|
||||
* y1 - 起始行
|
||||
* x2 - 结束列
|
||||
* y2 - 结束行
|
||||
* 函数功能:全屏填充
|
||||
* 入口参数:color - 填充颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:设置后续写入操作的窗口区域
|
||||
* 函数说明:用指定颜色填充整个屏幕
|
||||
*/
|
||||
void st7735s_set_window(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
|
||||
void st7735s_fill_screen(uint16_t color)
|
||||
{
|
||||
st7735s_write_cmd(LCD_CMD_CASET);
|
||||
st7735s_write_data(0x00);
|
||||
st7735s_write_data((uint8_t)x1);
|
||||
st7735s_write_data(0x00);
|
||||
st7735s_write_data((uint8_t)x2);
|
||||
uint32_t i;
|
||||
uint32_t total = (uint32_t)s_lcd_width * s_lcd_height;
|
||||
uint8_t buf[32];
|
||||
uint8_t hi = (uint8_t)(color >> 8);
|
||||
uint8_t lo = (uint8_t)(color & 0xFF);
|
||||
|
||||
st7735s_write_cmd(LCD_CMD_RASET);
|
||||
st7735s_write_data(0x00);
|
||||
st7735s_write_data((uint8_t)y1);
|
||||
st7735s_write_data(0x00);
|
||||
st7735s_write_data((uint8_t)y2);
|
||||
for (i = 0; i < sizeof(buf) / 2; i++) {
|
||||
buf[i * 2] = hi;
|
||||
buf[i * 2 + 1] = lo;
|
||||
}
|
||||
|
||||
st7735s_write_cmd(LCD_CMD_RAMWR);
|
||||
st7735s_set_window(0, 0, s_lcd_width - 1, s_lcd_height - 1);
|
||||
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(LCD_DC_PORT, LCD_DC_PIN, GPIO_PIN_SET);
|
||||
i = total * 2;
|
||||
while (i > 0) {
|
||||
uint32_t n = (i > sizeof(buf)) ? sizeof(buf) : i;
|
||||
st7735s_spi_write_bulk(buf, n);
|
||||
i -= n;
|
||||
}
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -314,50 +286,33 @@ void st7735s_set_window(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
|
||||
*/
|
||||
void st7735s_fill_rect(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
|
||||
{
|
||||
uint32_t pixel_count;
|
||||
uint16_t i;
|
||||
uint16_t buf[64];
|
||||
uint32_t i;
|
||||
uint32_t total;
|
||||
uint8_t buf[32];
|
||||
uint8_t hi = (uint8_t)(color >> 8);
|
||||
uint8_t lo = (uint8_t)(color & 0xFF);
|
||||
|
||||
if (x1 > x2) {
|
||||
uint16_t t = x1;
|
||||
x1 = x2;
|
||||
x2 = t;
|
||||
}
|
||||
if (y1 > y2) {
|
||||
uint16_t t = y1;
|
||||
y1 = y2;
|
||||
y2 = t;
|
||||
if (x1 > x2) { uint16_t t = x1; x1 = x2; x2 = t; }
|
||||
if (y1 > y2) { uint16_t t = y1; y1 = y2; y2 = t; }
|
||||
|
||||
for (i = 0; i < sizeof(buf) / 2; i++) {
|
||||
buf[i * 2] = hi;
|
||||
buf[i * 2 + 1] = lo;
|
||||
}
|
||||
|
||||
pixel_count = (uint32_t)(x2 - x1 + 1) * (y2 - y1 + 1);
|
||||
|
||||
/* 预填充颜色缓冲区 */
|
||||
for (i = 0; i < 64; i++) {
|
||||
buf[i] = color;
|
||||
}
|
||||
total = (uint32_t)(x2 - x1 + 1) * (y2 - y1 + 1);
|
||||
|
||||
st7735s_set_window(x1, y1, x2, y2);
|
||||
|
||||
/* 分块发送 */
|
||||
while (pixel_count >= 64) {
|
||||
st7735s_write_colors(buf, 64);
|
||||
pixel_count -= 64;
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(LCD_DC_PORT, LCD_DC_PIN, GPIO_PIN_SET);
|
||||
i = total * 2;
|
||||
while (i > 0) {
|
||||
uint32_t n = (i > sizeof(buf)) ? sizeof(buf) : i;
|
||||
st7735s_spi_write_bulk(buf, n);
|
||||
i -= n;
|
||||
}
|
||||
if (pixel_count > 0) {
|
||||
st7735s_write_colors(buf, (uint16_t)pixel_count);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:全屏填充
|
||||
* 入口参数:color - 填充颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:用指定颜色填充整个屏幕
|
||||
*/
|
||||
void st7735s_fill_screen(uint16_t color)
|
||||
{
|
||||
printf("fill_screen 0x%04X\r\n", color);
|
||||
st7735s_fill_rect(0, 0, s_lcd_width - 1, s_lcd_height - 1, color);
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -370,252 +325,65 @@ void st7735s_fill_screen(uint16_t color)
|
||||
*/
|
||||
void st7735s_draw_pixel(uint16_t x, uint16_t y, uint16_t color)
|
||||
{
|
||||
if (x >= s_lcd_width || y >= s_lcd_height) {
|
||||
return;
|
||||
}
|
||||
st7735s_set_window(x, y, x, y);
|
||||
st7735s_write_data((uint8_t)(color >> 8));
|
||||
st7735s_write_data((uint8_t)color);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:画线
|
||||
* 入口参数:x1 - 起始列
|
||||
* y1 - 起始行
|
||||
* x2 - 结束列
|
||||
* y2 - 结束行
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:画一条直线(Bresenham算法)
|
||||
*/
|
||||
void st7735s_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
|
||||
{
|
||||
int16_t dx;
|
||||
int16_t dy;
|
||||
int16_t sx;
|
||||
int16_t sy;
|
||||
int16_t err;
|
||||
int16_t e2;
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
|
||||
if (x1 == x2) {
|
||||
/* 垂直线 */
|
||||
if (y1 > y2) {
|
||||
y = y1;
|
||||
y1 = y2;
|
||||
y2 = y;
|
||||
}
|
||||
st7735s_fill_rect(x1, y1, x1, y2, color);
|
||||
return;
|
||||
}
|
||||
|
||||
if (y1 == y2) {
|
||||
/* 水平线 */
|
||||
if (x1 > x2) {
|
||||
x = x1;
|
||||
x1 = x2;
|
||||
x2 = x;
|
||||
}
|
||||
st7735s_fill_rect(x1, y1, x2, y1, color);
|
||||
return;
|
||||
}
|
||||
|
||||
dx = (int16_t)x2 - (int16_t)x1;
|
||||
if (dx < 0) {
|
||||
dx = -dx;
|
||||
}
|
||||
sx = x1 < x2 ? 1 : -1;
|
||||
dy = (int16_t)y2 - (int16_t)y1;
|
||||
if (dy < 0) {
|
||||
dy = -dy;
|
||||
}
|
||||
sy = y1 < y2 ? 1 : -1;
|
||||
err = (dx > dy ? dx : -dy) / 2;
|
||||
|
||||
x = x1;
|
||||
y = y1;
|
||||
|
||||
while (1) {
|
||||
st7735s_draw_pixel(x, y, color);
|
||||
if (x == x2 && y == y2) {
|
||||
break;
|
||||
}
|
||||
e2 = err;
|
||||
if (e2 > -dx) {
|
||||
err -= dy;
|
||||
x += sx;
|
||||
}
|
||||
if (e2 < dy) {
|
||||
err += dx;
|
||||
y += sy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:画矩形
|
||||
* 入口参数:x - 左上角列
|
||||
* y - 左上角行
|
||||
* width - 宽度
|
||||
* height - 高度
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:画一个空心矩形
|
||||
*/
|
||||
void st7735s_draw_rect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color)
|
||||
{
|
||||
st7735s_draw_line(x, y, x + width - 1, y, color);
|
||||
st7735s_draw_line(x, y + height - 1, x + width - 1, y + height - 1, color);
|
||||
st7735s_draw_line(x, y, x, y + height - 1, color);
|
||||
st7735s_draw_line(x + width - 1, y, x + width - 1, y + height - 1, color);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:画圆
|
||||
* 入口参数:x0 - 圆心列
|
||||
* y0 - 圆心行
|
||||
* radius - 半径
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:画一个空心圆(Bresenham算法)
|
||||
*/
|
||||
void st7735s_draw_circle(uint16_t x0, uint16_t y0, uint16_t radius, uint16_t color)
|
||||
{
|
||||
int16_t f = 1 - radius;
|
||||
int16_t ddf_x = 1;
|
||||
int16_t ddf_y = -2 * radius;
|
||||
int16_t x = 0;
|
||||
int16_t y = radius;
|
||||
|
||||
st7735s_draw_pixel(x0, y0 + radius, color);
|
||||
st7735s_draw_pixel(x0, y0 - radius, color);
|
||||
st7735s_draw_pixel(x0 + radius, y0, color);
|
||||
st7735s_draw_pixel(x0 - radius, y0, color);
|
||||
|
||||
while (x < y) {
|
||||
if (f >= 0) {
|
||||
y--;
|
||||
ddf_y += 2;
|
||||
f += ddf_y;
|
||||
}
|
||||
x++;
|
||||
ddf_x += 2;
|
||||
f += ddf_x;
|
||||
|
||||
st7735s_draw_pixel(x0 + x, y0 + y, color);
|
||||
st7735s_draw_pixel(x0 - x, y0 + y, color);
|
||||
st7735s_draw_pixel(x0 + x, y0 - y, color);
|
||||
st7735s_draw_pixel(x0 - x, y0 - y, color);
|
||||
st7735s_draw_pixel(x0 + y, y0 + x, color);
|
||||
st7735s_draw_pixel(x0 - y, y0 + x, color);
|
||||
st7735s_draw_pixel(x0 + y, y0 - x, color);
|
||||
st7735s_draw_pixel(x0 - y, y0 - x, color);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:显示字符
|
||||
* 入口参数:x - 列坐标
|
||||
* y - 行坐标
|
||||
* ch - 字符 (ASCII 32-126)
|
||||
* color - 字符颜色 (RGB565)
|
||||
* bg_color - 背景颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:在指定位置显示一个8x16 ASCII字符
|
||||
*/
|
||||
void st7735s_draw_char(uint16_t x, uint16_t y, char ch, uint16_t color, uint16_t bg_color)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t j;
|
||||
uint8_t line;
|
||||
|
||||
if (ch < 32 || ch > 126) {
|
||||
ch = ' ';
|
||||
}
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
line = LCD_F8x16[ch - 32][i];
|
||||
for (j = 0; j < 8; j++) {
|
||||
if (line & 0x80) {
|
||||
st7735s_draw_pixel(x + j, y + i, color);
|
||||
} else {
|
||||
st7735s_draw_pixel(x + j, y + i, bg_color);
|
||||
}
|
||||
line <<= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:显示字符串
|
||||
* 入口参数:x - 列坐标
|
||||
* y - 行坐标
|
||||
* str - 字符串指针
|
||||
* color - 字符颜色 (RGB565)
|
||||
* bg_color - 背景颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:在指定位置显示字符串
|
||||
*/
|
||||
void st7735s_draw_string(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bg_color)
|
||||
{
|
||||
while (*str) {
|
||||
if (x + 8 > s_lcd_width) {
|
||||
x = 0;
|
||||
y += 16;
|
||||
}
|
||||
if (y + 16 > s_lcd_height) {
|
||||
break;
|
||||
}
|
||||
st7735s_draw_char(x, y, *str, color, bg_color);
|
||||
x += FONT_WIDTH_8;
|
||||
str++;
|
||||
}
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(LCD_DC_PORT, LCD_DC_PIN, GPIO_PIN_SET);
|
||||
st7735s_spi_write_byte((uint8_t)(color >> 8));
|
||||
st7735s_spi_write_byte((uint8_t)(color & 0xFF));
|
||||
HAL_GPIO_WritePin(LCD_CS_PORT, LCD_CS_PIN, GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:设置屏幕方向
|
||||
* 入口参数:rotation - 方向 (0-3)
|
||||
* 返回值:无
|
||||
* 函数说明:0:竖屏 1:横屏 2:竖屏反转 3:横屏反转
|
||||
* 函数说明:通过修改MADCTL(36h)寄存器控制显示方向
|
||||
* 0: 竖屏 1: 横屏 2: 竖屏反转 3: 横屏反转
|
||||
*/
|
||||
void st7735s_set_rotation(uint8_t rotation)
|
||||
{
|
||||
st7735s_write_cmd(LCD_CMD_MADCTL);
|
||||
uint8_t madctl = 0xC0;
|
||||
|
||||
switch (rotation) {
|
||||
case 0:
|
||||
st7735s_write_data(0xC8);
|
||||
s_lcd_width = 128;
|
||||
s_lcd_height = 160;
|
||||
break;
|
||||
case 1:
|
||||
st7735s_write_data(0x78);
|
||||
s_lcd_width = 160;
|
||||
s_lcd_height = 128;
|
||||
break;
|
||||
case 2:
|
||||
st7735s_write_data(0x08);
|
||||
s_lcd_width = 128;
|
||||
s_lcd_height = 160;
|
||||
break;
|
||||
case 3:
|
||||
st7735s_write_data(0xA8);
|
||||
s_lcd_width = 160;
|
||||
s_lcd_height = 128;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case 0:
|
||||
madctl = 0xC0;
|
||||
s_lcd_width = LCD_WIDTH;
|
||||
s_lcd_height = LCD_HEIGHT;
|
||||
break;
|
||||
case 1:
|
||||
madctl = 0xA0;
|
||||
s_lcd_width = LCD_HEIGHT;
|
||||
s_lcd_height = LCD_WIDTH;
|
||||
break;
|
||||
case 2:
|
||||
madctl = 0x00;
|
||||
s_lcd_width = LCD_WIDTH;
|
||||
s_lcd_height = LCD_HEIGHT;
|
||||
break;
|
||||
case 3:
|
||||
madctl = 0x60;
|
||||
s_lcd_width = LCD_HEIGHT;
|
||||
s_lcd_height = LCD_WIDTH;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
st7735s_write_cmd(LCD_CMD_MADCTL);
|
||||
st7735s_write_data(madctl);
|
||||
}
|
||||
|
||||
/*
|
||||
* 函数功能:设置背光
|
||||
* 入口参数:state - 1:开 0:关
|
||||
* 返回值:无
|
||||
* 函数说明:控制LCD背光(如有硬件背光控制)
|
||||
* 函数说明:通过PC13控制背光(如果有背光控制引脚则修改)
|
||||
*/
|
||||
void st7735s_backlight(uint8_t state)
|
||||
{
|
||||
(void)state;
|
||||
/* 当前硬件未连接背光控制引脚,预留接口 */
|
||||
if (state) {
|
||||
printf("backlight on\r\n");
|
||||
} else {
|
||||
printf("backlight off\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
/*
|
||||
* 模块名称:ST7735S LCD驱动
|
||||
* 模块功能:提供128x160 RGB TFT屏幕的初始化、画点、画线、填充、显示字符串等功能
|
||||
* 适用平台:STM32F103C8T6 + SPI2
|
||||
* 模块名称:ST7735S LCD驱动(底层)
|
||||
* 模块功能:提供ST7735S屏幕的硬件SPI通信、初始化、填充、画点、方向控制等底层操作
|
||||
* 绘图函数见 lcd.h
|
||||
* 适用平台:STM32F103C8T6 + 硬件SPI2
|
||||
* 作者:王建锋
|
||||
* 创建日期:2026-07-13
|
||||
* 修改记录:
|
||||
* 2026-07-13 王建锋 创建初始版本
|
||||
* 2026-07-14 王建锋 软件SPI -> 硬件SPI2
|
||||
* 2026-07-14 王建锋 拆分:绘图函数移入 lcd.h
|
||||
*/
|
||||
|
||||
#ifndef __ST7735S_H
|
||||
@@ -40,16 +43,13 @@ extern "C" {
|
||||
#define RGB565(r, g, b) ((uint16_t)(((r) & 0xF8) << 8 | ((g) & 0xFC) << 3 | ((b) >> 3)))
|
||||
|
||||
/* LCD控制引脚定义 - 根据CubeMX配置修改 */
|
||||
/* SCL(PB13)和SDA(PB15)由SPI2外设管理,无需GPIO定义 */
|
||||
#define LCD_CS_PORT LCD_CS_GPIO_Port
|
||||
#define LCD_CS_PIN LCD_CS_Pin
|
||||
#define LCD_DC_PORT LCD_DC_GPIO_Port
|
||||
#define LCD_DC_PIN LCD_DC_Pin
|
||||
#define LCD_RST_PORT LCD_RST_GPIO_Port
|
||||
#define LCD_RST_PIN LCD_RST_Pin
|
||||
#define LCD_SCL_PORT GPIOB
|
||||
#define LCD_SCL_PIN GPIO_PIN_13
|
||||
#define LCD_SDA_PORT GPIOB
|
||||
#define LCD_SDA_PIN GPIO_PIN_15
|
||||
|
||||
/* LCD命令定义 */
|
||||
#define LCD_CMD_SWRESET 0x01 /* 软件复位 */
|
||||
@@ -74,17 +74,42 @@ extern "C" {
|
||||
#define LCD_CMD_GMCTRP1 0xE0 /* Gamma正向校正 */
|
||||
#define LCD_CMD_GMCTRN1 0xE1 /* Gamma反向校正 */
|
||||
|
||||
/* 字体定义 */
|
||||
#define FONT_WIDTH_8 8 /* 8x16字体宽度(含间距) */
|
||||
#define FONT_HEIGHT_16 16 /* 8x16字体高度 */
|
||||
/* 外部变量 - LCD宽高,由旋转函数更新 */
|
||||
extern uint16_t s_lcd_width;
|
||||
extern uint16_t s_lcd_height;
|
||||
|
||||
/* === 底层SPI通信函数 === */
|
||||
|
||||
/*
|
||||
* 函数功能:LCD初始化
|
||||
* 入口参数:无
|
||||
* 函数功能:硬件SPI写一个字节
|
||||
* 入口参数:data - 要发送的数据
|
||||
* 返回值:无
|
||||
* 函数说明:初始化ST7735S屏幕,包括SPI、GPIO、显示参数配置
|
||||
*/
|
||||
void st7735s_init(void);
|
||||
void st7735s_spi_write_byte(uint8_t data);
|
||||
|
||||
/*
|
||||
* 函数功能:硬件SPI批量写数据
|
||||
* 入口参数:data - 数据缓冲区
|
||||
* len - 字节数
|
||||
* 返回值:无
|
||||
*/
|
||||
void st7735s_spi_write_bulk(const uint8_t *data, uint32_t len);
|
||||
|
||||
/*
|
||||
* 函数功能:写入命令(CS+DC管理,单字节)
|
||||
* 入口参数:cmd - 命令字节
|
||||
* 返回值:无
|
||||
*/
|
||||
void st7735s_write_cmd(uint8_t cmd);
|
||||
|
||||
/*
|
||||
* 函数功能:写入数据(CS+DC管理,单字节)
|
||||
* 入口参数:data - 数据字节
|
||||
* 返回值:无
|
||||
*/
|
||||
void st7735s_write_data(uint8_t data);
|
||||
|
||||
/* === 驱动控制函数 === */
|
||||
|
||||
/*
|
||||
* 函数功能:设置显示窗口
|
||||
@@ -93,10 +118,23 @@ void st7735s_init(void);
|
||||
* x2 - 结束列
|
||||
* y2 - 结束行
|
||||
* 返回值:无
|
||||
* 函数说明:设置后续写入操作的窗口区域
|
||||
*/
|
||||
void st7735s_set_window(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
|
||||
|
||||
/*
|
||||
* 函数功能:LCD初始化
|
||||
* 入口参数:无
|
||||
* 返回值:无
|
||||
*/
|
||||
void st7735s_init(void);
|
||||
|
||||
/*
|
||||
* 函数功能:全屏填充
|
||||
* 入口参数:color - 填充颜色 (RGB565)
|
||||
* 返回值:无
|
||||
*/
|
||||
void st7735s_fill_screen(uint16_t color);
|
||||
|
||||
/*
|
||||
* 函数功能:填充矩形区域
|
||||
* 入口参数:x1 - 起始列
|
||||
@@ -105,96 +143,22 @@ void st7735s_set_window(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
|
||||
* y2 - 结束行
|
||||
* color - 填充颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:用指定颜色填充矩形区域
|
||||
*/
|
||||
void st7735s_fill_rect(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
|
||||
|
||||
/*
|
||||
* 函数功能:全屏填充
|
||||
* 入口参数:color - 填充颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:用指定颜色填充整个屏幕
|
||||
*/
|
||||
void st7735s_fill_screen(uint16_t color);
|
||||
|
||||
/*
|
||||
* 函数功能:画点
|
||||
* 入口参数:x - 列坐标
|
||||
* y - 行坐标
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:在指定位置画一个点
|
||||
*/
|
||||
void st7735s_draw_pixel(uint16_t x, uint16_t y, uint16_t color);
|
||||
|
||||
/*
|
||||
* 函数功能:画线
|
||||
* 入口参数:x1 - 起始列
|
||||
* y1 - 起始行
|
||||
* x2 - 结束列
|
||||
* y2 - 结束行
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:画一条直线(Bresenham算法)
|
||||
*/
|
||||
void st7735s_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
|
||||
|
||||
/*
|
||||
* 函数功能:画矩形
|
||||
* 入口参数:x - 左上角列
|
||||
* y - 左上角行
|
||||
* width - 宽度
|
||||
* height - 高度
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:画一个空心矩形
|
||||
*/
|
||||
void st7735s_draw_rect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color);
|
||||
|
||||
/*
|
||||
* 函数功能:画圆
|
||||
* 入口参数:x0 - 圆心列
|
||||
* y0 - 圆心行
|
||||
* radius - 半径
|
||||
* color - 颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:画一个空心圆(Bresenham算法)
|
||||
*/
|
||||
void st7735s_draw_circle(uint16_t x0, uint16_t y0, uint16_t radius, uint16_t color);
|
||||
|
||||
/*
|
||||
* 函数功能:显示字符
|
||||
* 入口参数:x - 列坐标
|
||||
* y - 行坐标
|
||||
* ch - 字符 (ASCII 32-126)
|
||||
* color - 字符颜色 (RGB565)
|
||||
* bg_color - 背景颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:在指定位置显示一个8x16 ASCII字符
|
||||
*/
|
||||
void st7735s_draw_char(uint16_t x, uint16_t y, char ch, uint16_t color, uint16_t bg_color);
|
||||
|
||||
/*
|
||||
* 函数功能:显示字符串
|
||||
* 入口参数:x - 列坐标
|
||||
* y - 行坐标
|
||||
* str - 字符串指针
|
||||
* color - 字符颜色 (RGB565)
|
||||
* bg_color - 背景颜色 (RGB565)
|
||||
* 返回值:无
|
||||
* 函数说明:在指定位置显示字符串
|
||||
*/
|
||||
void st7735s_draw_string(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bg_color);
|
||||
|
||||
/*
|
||||
* 函数功能:设置屏幕方向
|
||||
* 入口参数:rotation - 方向 (0-3)
|
||||
* 返回值:无
|
||||
* 函数说明:设置屏幕显示方向
|
||||
* 0: 竖屏
|
||||
* 1: 横屏
|
||||
* 2: 竖屏反转
|
||||
* 3: 横屏反转
|
||||
*/
|
||||
void st7735s_set_rotation(uint8_t rotation);
|
||||
|
||||
@@ -202,7 +166,6 @@ void st7735s_set_rotation(uint8_t rotation);
|
||||
* 函数功能:设置背光
|
||||
* 入口参数:state - 1:开 0:关
|
||||
* 返回值:无
|
||||
* 函数说明:控制LCD背光(如有硬件背光控制)
|
||||
*/
|
||||
void st7735s_backlight(uint8_t state);
|
||||
|
||||
|
||||
1000
STM32F103C8T6/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc.h
Normal file
1000
STM32F103C8T6/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,706 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32f1xx_hal_adc_ex.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header file of ADC HAL extension module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32F1xx_HAL_ADC_EX_H
|
||||
#define __STM32F1xx_HAL_ADC_EX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f1xx_hal_def.h"
|
||||
|
||||
/** @addtogroup STM32F1xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup ADCEx
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup ADCEx_Exported_Types ADCEx Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief ADC Configuration injected Channel structure definition
|
||||
* @note Parameters of this structure are shared within 2 scopes:
|
||||
* - Scope channel: InjectedChannel, InjectedRank, InjectedSamplingTime, InjectedOffset
|
||||
* - Scope injected group (affects all channels of injected group): InjectedNbrOfConversion, InjectedDiscontinuousConvMode,
|
||||
* AutoInjectedConv, ExternalTrigInjecConvEdge, ExternalTrigInjecConv.
|
||||
* @note The setting of these parameters with function HAL_ADCEx_InjectedConfigChannel() is conditioned to ADC state.
|
||||
* ADC state can be either:
|
||||
* - For all parameters: ADC disabled (this is the only possible ADC state to modify parameter 'ExternalTrigInjecConv')
|
||||
* - For all except parameters 'ExternalTrigInjecConv': ADC enabled without conversion on going on injected group.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t InjectedChannel; /*!< Selection of ADC channel to configure
|
||||
This parameter can be a value of @ref ADC_channels
|
||||
Note: Depending on devices, some channels may not be available on package pins. Refer to device datasheet for channels availability.
|
||||
Note: On STM32F1 devices with several ADC: Only ADC1 can access internal measurement channels (VrefInt/TempSensor)
|
||||
Note: On STM32F10xx8 and STM32F10xxB devices: A low-amplitude voltage glitch may be generated (on ADC input 0) on the PA0 pin, when the ADC is converting with injection trigger.
|
||||
It is advised to distribute the analog channels so that Channel 0 is configured as an injected channel.
|
||||
Refer to errata sheet of these devices for more details. */
|
||||
uint32_t InjectedRank; /*!< Rank in the injected group sequencer
|
||||
This parameter must be a value of @ref ADCEx_injected_rank
|
||||
Note: In case of need to disable a channel or change order of conversion sequencer, rank containing a previous channel setting can be overwritten by the new channel setting (or parameter number of conversions can be adjusted) */
|
||||
uint32_t InjectedSamplingTime; /*!< Sampling time value to be set for the selected channel.
|
||||
Unit: ADC clock cycles
|
||||
Conversion time is the addition of sampling time and processing time (12.5 ADC clock cycles at ADC resolution 12 bits).
|
||||
This parameter can be a value of @ref ADC_sampling_times
|
||||
Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups.
|
||||
If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting.
|
||||
Note: In case of usage of internal measurement channels (VrefInt/TempSensor),
|
||||
sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting)
|
||||
Refer to device datasheet for timings values, parameters TS_vrefint, TS_temp (values rough order: 5us to 17.1us min). */
|
||||
uint32_t InjectedOffset; /*!< Defines the offset to be subtracted from the raw converted data (for channels set on injected group only).
|
||||
Offset value must be a positive number.
|
||||
Depending of ADC resolution selected (12, 10, 8 or 6 bits),
|
||||
this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF, 0x3FF, 0xFF or 0x3F respectively. */
|
||||
uint32_t InjectedNbrOfConversion; /*!< Specifies the number of ranks that will be converted within the injected group sequencer.
|
||||
To use the injected group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
|
||||
This parameter must be a number between Min_Data = 1 and Max_Data = 4.
|
||||
Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
|
||||
configure a channel on injected group can impact the configuration of other channels previously set. */
|
||||
FunctionalState InjectedDiscontinuousConvMode; /*!< Specifies whether the conversions sequence of injected group is performed in Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts).
|
||||
Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
|
||||
Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded.
|
||||
This parameter can be set to ENABLE or DISABLE.
|
||||
Note: For injected group, number of discontinuous ranks increment is fixed to one-by-one.
|
||||
Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
|
||||
configure a channel on injected group can impact the configuration of other channels previously set. */
|
||||
FunctionalState AutoInjectedConv; /*!< Enables or disables the selected ADC automatic injected group conversion after regular one
|
||||
This parameter can be set to ENABLE or DISABLE.
|
||||
Note: To use Automatic injected conversion, discontinuous mode must be disabled ('DiscontinuousConvMode' and 'InjectedDiscontinuousConvMode' set to DISABLE)
|
||||
Note: To use Automatic injected conversion, injected group external triggers must be disabled ('ExternalTrigInjecConv' set to ADC_SOFTWARE_START)
|
||||
Note: In case of DMA used with regular group: if DMA configured in normal mode (single shot) JAUTO will be stopped upon DMA transfer complete.
|
||||
To maintain JAUTO always enabled, DMA must be configured in circular mode.
|
||||
Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
|
||||
configure a channel on injected group can impact the configuration of other channels previously set. */
|
||||
uint32_t ExternalTrigInjecConv; /*!< Selects the external event used to trigger the conversion start of injected group.
|
||||
If set to ADC_INJECTED_SOFTWARE_START, external triggers are disabled.
|
||||
If set to external trigger source, triggering is on event rising edge.
|
||||
This parameter can be a value of @ref ADCEx_External_trigger_source_Injected
|
||||
Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion).
|
||||
If ADC is enabled, this parameter setting is bypassed without error reporting (as it can be the expected behaviour in case of another parameter update on the fly)
|
||||
Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
|
||||
configure a channel on injected group can impact the configuration of other channels previously set. */
|
||||
}ADC_InjectionConfTypeDef;
|
||||
|
||||
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
|
||||
/**
|
||||
* @brief Structure definition of ADC multimode
|
||||
* @note The setting of these parameters with function HAL_ADCEx_MultiModeConfigChannel() is conditioned to ADCs state (both ADCs of the common group).
|
||||
* State of ADCs of the common group must be: disabled.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Mode; /*!< Configures the ADC to operate in independent or multi mode.
|
||||
This parameter can be a value of @ref ADCEx_Common_mode
|
||||
Note: In dual mode, a change of channel configuration generates a restart that can produce a loss of synchronization. It is recommended to disable dual mode before any configuration change.
|
||||
Note: In case of simultaneous mode used: Exactly the same sampling time should be configured for the 2 channels that will be sampled simultaneously by ACD1 and ADC2.
|
||||
Note: In case of interleaved mode used: To avoid overlap between conversions, maximum sampling time allowed is 7 ADC clock cycles for fast interleaved mode and 14 ADC clock cycles for slow interleaved mode.
|
||||
Note: Some multimode parameters are fixed on STM32F1 and can be configured on other STM32 devices with several ADC (multimode configuration structure can have additional parameters).
|
||||
The equivalences are:
|
||||
- Parameter 'DMAAccessMode': On STM32F1, this parameter is fixed to 1 DMA channel (one DMA channel for both ADC, DMA of ADC master). On other STM32 devices with several ADC, this is equivalent to parameter 'ADC_DMAACCESSMODE_12_10_BITS'.
|
||||
- Parameter 'TwoSamplingDelay': On STM32F1, this parameter is fixed to 7 or 14 ADC clock cycles depending on fast or slow interleaved mode selected. On other STM32 devices with several ADC, this is equivalent to parameter 'ADC_TWOSAMPLINGDELAY_7CYCLES' (for fast interleaved mode). */
|
||||
|
||||
|
||||
}ADC_MultiModeTypeDef;
|
||||
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/** @defgroup ADCEx_Exported_Constants ADCEx Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup ADCEx_injected_rank ADCEx rank into injected group
|
||||
* @{
|
||||
*/
|
||||
#define ADC_INJECTED_RANK_1 0x00000001U
|
||||
#define ADC_INJECTED_RANK_2 0x00000002U
|
||||
#define ADC_INJECTED_RANK_3 0x00000003U
|
||||
#define ADC_INJECTED_RANK_4 0x00000004U
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADCEx_External_trigger_edge_Injected ADCEx external trigger enable for injected group
|
||||
* @{
|
||||
*/
|
||||
#define ADC_EXTERNALTRIGINJECCONV_EDGE_NONE 0x00000000U
|
||||
#define ADC_EXTERNALTRIGINJECCONV_EDGE_RISING ((uint32_t)ADC_CR2_JEXTTRIG)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_External_trigger_source_Regular ADC External trigger selection for regular group
|
||||
* @{
|
||||
*/
|
||||
/*!< List of external triggers with generic trigger name, independently of */
|
||||
/* ADC target, sorted by trigger name: */
|
||||
|
||||
/*!< External triggers of regular group for ADC1&ADC2 only */
|
||||
#define ADC_EXTERNALTRIGCONV_T1_CC1 ADC1_2_EXTERNALTRIG_T1_CC1
|
||||
#define ADC_EXTERNALTRIGCONV_T1_CC2 ADC1_2_EXTERNALTRIG_T1_CC2
|
||||
#define ADC_EXTERNALTRIGCONV_T2_CC2 ADC1_2_EXTERNALTRIG_T2_CC2
|
||||
#define ADC_EXTERNALTRIGCONV_T3_TRGO ADC1_2_EXTERNALTRIG_T3_TRGO
|
||||
#define ADC_EXTERNALTRIGCONV_T4_CC4 ADC1_2_EXTERNALTRIG_T4_CC4
|
||||
#define ADC_EXTERNALTRIGCONV_EXT_IT11 ADC1_2_EXTERNALTRIG_EXT_IT11
|
||||
|
||||
#if defined (STM32F103xE) || defined (STM32F103xG)
|
||||
/*!< External triggers of regular group for ADC3 only */
|
||||
#define ADC_EXTERNALTRIGCONV_T2_CC3 ADC3_EXTERNALTRIG_T2_CC3
|
||||
#define ADC_EXTERNALTRIGCONV_T3_CC1 ADC3_EXTERNALTRIG_T3_CC1
|
||||
#define ADC_EXTERNALTRIGCONV_T5_CC1 ADC3_EXTERNALTRIG_T5_CC1
|
||||
#define ADC_EXTERNALTRIGCONV_T5_CC3 ADC3_EXTERNALTRIG_T5_CC3
|
||||
#define ADC_EXTERNALTRIGCONV_T8_CC1 ADC3_EXTERNALTRIG_T8_CC1
|
||||
#endif /* STM32F103xE || defined STM32F103xG */
|
||||
|
||||
/*!< External triggers of regular group for all ADC instances */
|
||||
#define ADC_EXTERNALTRIGCONV_T1_CC3 ADC1_2_3_EXTERNALTRIG_T1_CC3
|
||||
|
||||
#if defined (STM32F101xE) || defined (STM32F103xE) || defined (STM32F103xG) || defined (STM32F105xC) || defined (STM32F107xC)
|
||||
/*!< Note: TIM8_TRGO is available on ADC1 and ADC2 only in high-density and */
|
||||
/* XL-density devices. */
|
||||
/* To use it on ADC or ADC2, a remap of trigger must be done from */
|
||||
/* EXTI line 11 to TIM8_TRGO with macro: */
|
||||
/* __HAL_AFIO_REMAP_ADC1_ETRGREG_ENABLE() */
|
||||
/* __HAL_AFIO_REMAP_ADC2_ETRGREG_ENABLE() */
|
||||
|
||||
/* Note for internal constant value management: If TIM8_TRGO is available, */
|
||||
/* its definition is set to value for ADC1&ADC2 by default and changed to */
|
||||
/* value for ADC3 by HAL ADC driver if ADC3 is selected. */
|
||||
#define ADC_EXTERNALTRIGCONV_T8_TRGO ADC1_2_EXTERNALTRIG_T8_TRGO
|
||||
#endif /* STM32F101xE || STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
|
||||
|
||||
#define ADC_SOFTWARE_START ADC1_2_3_SWSTART
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADCEx_External_trigger_source_Injected ADCEx External trigger selection for injected group
|
||||
* @{
|
||||
*/
|
||||
/*!< List of external triggers with generic trigger name, independently of */
|
||||
/* ADC target, sorted by trigger name: */
|
||||
|
||||
/*!< External triggers of injected group for ADC1&ADC2 only */
|
||||
#define ADC_EXTERNALTRIGINJECCONV_T2_TRGO ADC1_2_EXTERNALTRIGINJEC_T2_TRGO
|
||||
#define ADC_EXTERNALTRIGINJECCONV_T2_CC1 ADC1_2_EXTERNALTRIGINJEC_T2_CC1
|
||||
#define ADC_EXTERNALTRIGINJECCONV_T3_CC4 ADC1_2_EXTERNALTRIGINJEC_T3_CC4
|
||||
#define ADC_EXTERNALTRIGINJECCONV_T4_TRGO ADC1_2_EXTERNALTRIGINJEC_T4_TRGO
|
||||
#define ADC_EXTERNALTRIGINJECCONV_EXT_IT15 ADC1_2_EXTERNALTRIGINJEC_EXT_IT15
|
||||
|
||||
#if defined (STM32F103xE) || defined (STM32F103xG)
|
||||
/*!< External triggers of injected group for ADC3 only */
|
||||
#define ADC_EXTERNALTRIGINJECCONV_T4_CC3 ADC3_EXTERNALTRIGINJEC_T4_CC3
|
||||
#define ADC_EXTERNALTRIGINJECCONV_T8_CC2 ADC3_EXTERNALTRIGINJEC_T8_CC2
|
||||
#define ADC_EXTERNALTRIGINJECCONV_T5_TRGO ADC3_EXTERNALTRIGINJEC_T5_TRGO
|
||||
#define ADC_EXTERNALTRIGINJECCONV_T5_CC4 ADC3_EXTERNALTRIGINJEC_T5_CC4
|
||||
#endif /* STM32F103xE || defined STM32F103xG */
|
||||
|
||||
/*!< External triggers of injected group for all ADC instances */
|
||||
#define ADC_EXTERNALTRIGINJECCONV_T1_CC4 ADC1_2_3_EXTERNALTRIGINJEC_T1_CC4
|
||||
#define ADC_EXTERNALTRIGINJECCONV_T1_TRGO ADC1_2_3_EXTERNALTRIGINJEC_T1_TRGO
|
||||
|
||||
#if defined (STM32F101xE) || defined (STM32F103xE) || defined (STM32F103xG) || defined (STM32F105xC) || defined (STM32F107xC)
|
||||
/*!< Note: TIM8_CC4 is available on ADC1 and ADC2 only in high-density and */
|
||||
/* XL-density devices. */
|
||||
/* To use it on ADC1 or ADC2, a remap of trigger must be done from */
|
||||
/* EXTI line 11 to TIM8_CC4 with macro: */
|
||||
/* __HAL_AFIO_REMAP_ADC1_ETRGINJ_ENABLE() */
|
||||
/* __HAL_AFIO_REMAP_ADC2_ETRGINJ_ENABLE() */
|
||||
|
||||
/* Note for internal constant value management: If TIM8_CC4 is available, */
|
||||
/* its definition is set to value for ADC1&ADC2 by default and changed to */
|
||||
/* value for ADC3 by HAL ADC driver if ADC3 is selected. */
|
||||
#define ADC_EXTERNALTRIGINJECCONV_T8_CC4 ADC1_2_EXTERNALTRIGINJEC_T8_CC4
|
||||
#endif /* STM32F101xE || STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
|
||||
|
||||
#define ADC_INJECTED_SOFTWARE_START ADC1_2_3_JSWSTART
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
|
||||
/** @defgroup ADCEx_Common_mode ADC Extended Dual ADC Mode
|
||||
* @{
|
||||
*/
|
||||
#define ADC_MODE_INDEPENDENT 0x00000000U /*!< ADC dual mode disabled (ADC independent mode) */
|
||||
#define ADC_DUALMODE_REGSIMULT_INJECSIMULT ((uint32_t)( ADC_CR1_DUALMOD_0)) /*!< ADC dual mode enabled: Combined regular simultaneous + injected simultaneous mode, on groups regular and injected */
|
||||
#define ADC_DUALMODE_REGSIMULT_ALTERTRIG ((uint32_t)( ADC_CR1_DUALMOD_1 )) /*!< ADC dual mode enabled: Combined regular simultaneous + alternate trigger mode, on groups regular and injected */
|
||||
#define ADC_DUALMODE_INJECSIMULT_INTERLFAST ((uint32_t)( ADC_CR1_DUALMOD_1 | ADC_CR1_DUALMOD_0)) /*!< ADC dual mode enabled: Combined injected simultaneous + fast interleaved mode, on groups regular and injected (delay between ADC sampling phases: 7 ADC clock cycles (equivalent to parameter "TwoSamplingDelay" set to "ADC_TWOSAMPLINGDELAY_7CYCLES" on other STM32 devices)) */
|
||||
#define ADC_DUALMODE_INJECSIMULT_INTERLSLOW ((uint32_t)( ADC_CR1_DUALMOD_2 )) /*!< ADC dual mode enabled: Combined injected simultaneous + slow Interleaved mode, on groups regular and injected (delay between ADC sampling phases: 14 ADC clock cycles (equivalent to parameter "TwoSamplingDelay" set to "ADC_TWOSAMPLINGDELAY_7CYCLES" on other STM32 devices)) */
|
||||
#define ADC_DUALMODE_INJECSIMULT ((uint32_t)( ADC_CR1_DUALMOD_2 | ADC_CR1_DUALMOD_0)) /*!< ADC dual mode enabled: Injected simultaneous mode, on group injected */
|
||||
#define ADC_DUALMODE_REGSIMULT ((uint32_t)( ADC_CR1_DUALMOD_2 | ADC_CR1_DUALMOD_1 )) /*!< ADC dual mode enabled: Regular simultaneous mode, on group regular */
|
||||
#define ADC_DUALMODE_INTERLFAST ((uint32_t)( ADC_CR1_DUALMOD_2 | ADC_CR1_DUALMOD_1 | ADC_CR1_DUALMOD_0)) /*!< ADC dual mode enabled: Fast interleaved mode, on group regular (delay between ADC sampling phases: 7 ADC clock cycles (equivalent to parameter "TwoSamplingDelay" set to "ADC_TWOSAMPLINGDELAY_7CYCLES" on other STM32 devices)) */
|
||||
#define ADC_DUALMODE_INTERLSLOW ((uint32_t)(ADC_CR1_DUALMOD_3 )) /*!< ADC dual mode enabled: Slow interleaved mode, on group regular (delay between ADC sampling phases: 14 ADC clock cycles (equivalent to parameter "TwoSamplingDelay" set to "ADC_TWOSAMPLINGDELAY_7CYCLES" on other STM32 devices)) */
|
||||
#define ADC_DUALMODE_ALTERTRIG ((uint32_t)(ADC_CR1_DUALMOD_3 | ADC_CR1_DUALMOD_0)) /*!< ADC dual mode enabled: Alternate trigger mode, on group injected */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
|
||||
/** @addtogroup ADCEx_Private_Constants ADCEx Private Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup ADCEx_Internal_HAL_driver_Ext_trig_src_Regular ADC Extended Internal HAL driver trigger selection for regular group
|
||||
* @{
|
||||
*/
|
||||
/* List of external triggers of regular group for ADC1, ADC2, ADC3 (if ADC */
|
||||
/* instance is available on the selected device). */
|
||||
/* (used internally by HAL driver. To not use into HAL structure parameters) */
|
||||
|
||||
/* External triggers of regular group for ADC1&ADC2 (if ADCx available) */
|
||||
#define ADC1_2_EXTERNALTRIG_T1_CC1 0x00000000U
|
||||
#define ADC1_2_EXTERNALTRIG_T1_CC2 ((uint32_t)( ADC_CR2_EXTSEL_0))
|
||||
#define ADC1_2_EXTERNALTRIG_T2_CC2 ((uint32_t)( ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
|
||||
#define ADC1_2_EXTERNALTRIG_T3_TRGO ((uint32_t)(ADC_CR2_EXTSEL_2 ))
|
||||
#define ADC1_2_EXTERNALTRIG_T4_CC4 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0))
|
||||
#define ADC1_2_EXTERNALTRIG_EXT_IT11 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 ))
|
||||
#if defined (STM32F101xE) || defined (STM32F103xE) || defined (STM32F103xG)
|
||||
/* Note: TIM8_TRGO is available on ADC1 and ADC2 only in high-density and */
|
||||
/* XL-density devices. */
|
||||
#define ADC1_2_EXTERNALTRIG_T8_TRGO ADC1_2_EXTERNALTRIG_EXT_IT11
|
||||
#endif
|
||||
|
||||
#if defined (STM32F103xE) || defined (STM32F103xG)
|
||||
/* External triggers of regular group for ADC3 */
|
||||
#define ADC3_EXTERNALTRIG_T3_CC1 ADC1_2_EXTERNALTRIG_T1_CC1
|
||||
#define ADC3_EXTERNALTRIG_T2_CC3 ADC1_2_EXTERNALTRIG_T1_CC2
|
||||
#define ADC3_EXTERNALTRIG_T8_CC1 ADC1_2_EXTERNALTRIG_T2_CC2
|
||||
#define ADC3_EXTERNALTRIG_T8_TRGO ADC1_2_EXTERNALTRIG_T3_TRGO
|
||||
#define ADC3_EXTERNALTRIG_T5_CC1 ADC1_2_EXTERNALTRIG_T4_CC4
|
||||
#define ADC3_EXTERNALTRIG_T5_CC3 ADC1_2_EXTERNALTRIG_EXT_IT11
|
||||
#endif
|
||||
|
||||
/* External triggers of regular group for ADC1&ADC2&ADC3 (if ADCx available) */
|
||||
#define ADC1_2_3_EXTERNALTRIG_T1_CC3 ((uint32_t)( ADC_CR2_EXTSEL_1 ))
|
||||
#define ADC1_2_3_SWSTART ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADCEx_Internal_HAL_driver_Ext_trig_src_Injected ADC Extended Internal HAL driver trigger selection for injected group
|
||||
* @{
|
||||
*/
|
||||
/* List of external triggers of injected group for ADC1, ADC2, ADC3 (if ADC */
|
||||
/* instance is available on the selected device). */
|
||||
/* (used internally by HAL driver. To not use into HAL structure parameters) */
|
||||
|
||||
/* External triggers of injected group for ADC1&ADC2 (if ADCx available) */
|
||||
#define ADC1_2_EXTERNALTRIGINJEC_T2_TRGO ((uint32_t)( ADC_CR2_JEXTSEL_1 ))
|
||||
#define ADC1_2_EXTERNALTRIGINJEC_T2_CC1 ((uint32_t)( ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0))
|
||||
#define ADC1_2_EXTERNALTRIGINJEC_T3_CC4 ((uint32_t)(ADC_CR2_JEXTSEL_2 ))
|
||||
#define ADC1_2_EXTERNALTRIGINJEC_T4_TRGO ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_0))
|
||||
#define ADC1_2_EXTERNALTRIGINJEC_EXT_IT15 ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 ))
|
||||
#if defined (STM32F101xE) || defined (STM32F103xE) || defined (STM32F103xG)
|
||||
/* Note: TIM8_CC4 is available on ADC1 and ADC2 only in high-density and */
|
||||
/* XL-density devices. */
|
||||
#define ADC1_2_EXTERNALTRIGINJEC_T8_CC4 ADC1_2_EXTERNALTRIGINJEC_EXT_IT15
|
||||
#endif
|
||||
|
||||
#if defined (STM32F103xE) || defined (STM32F103xG)
|
||||
/* External triggers of injected group for ADC3 */
|
||||
#define ADC3_EXTERNALTRIGINJEC_T4_CC3 ADC1_2_EXTERNALTRIGINJEC_T2_TRGO
|
||||
#define ADC3_EXTERNALTRIGINJEC_T8_CC2 ADC1_2_EXTERNALTRIGINJEC_T2_CC1
|
||||
#define ADC3_EXTERNALTRIGINJEC_T8_CC4 ADC1_2_EXTERNALTRIGINJEC_T3_CC4
|
||||
#define ADC3_EXTERNALTRIGINJEC_T5_TRGO ADC1_2_EXTERNALTRIGINJEC_T4_TRGO
|
||||
#define ADC3_EXTERNALTRIGINJEC_T5_CC4 ADC1_2_EXTERNALTRIGINJEC_EXT_IT15
|
||||
#endif /* STM32F103xE || defined STM32F103xG */
|
||||
|
||||
/* External triggers of injected group for ADC1&ADC2&ADC3 (if ADCx available) */
|
||||
#define ADC1_2_3_EXTERNALTRIGINJEC_T1_TRGO 0x00000000U
|
||||
#define ADC1_2_3_EXTERNALTRIGINJEC_T1_CC4 ((uint32_t)( ADC_CR2_JEXTSEL_0))
|
||||
#define ADC1_2_3_JSWSTART ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
|
||||
/** @defgroup ADCEx_Private_Macro ADCEx Private Macro
|
||||
* @{
|
||||
*/
|
||||
/* Macro reserved for internal HAL driver usage, not intended to be used in */
|
||||
/* code of final user. */
|
||||
|
||||
|
||||
/**
|
||||
* @brief For devices with 3 ADCs: Defines the external trigger source
|
||||
* for regular group according to ADC into common group ADC1&ADC2 or
|
||||
* ADC3 (some triggers with same source have different value to
|
||||
* be programmed into ADC EXTSEL bits of CR2 register).
|
||||
* For devices with 2 ADCs or less: this macro makes no change.
|
||||
* @param __HANDLE__: ADC handle
|
||||
* @param __EXT_TRIG_CONV__: External trigger selected for regular group.
|
||||
* @retval External trigger to be programmed into EXTSEL bits of CR2 register
|
||||
*/
|
||||
#if defined (STM32F103xE) || defined (STM32F103xG)
|
||||
#define ADC_CFGR_EXTSEL(__HANDLE__, __EXT_TRIG_CONV__) \
|
||||
(( (((__HANDLE__)->Instance) == ADC3) \
|
||||
)? \
|
||||
( ( (__EXT_TRIG_CONV__) == ADC_EXTERNALTRIGCONV_T8_TRGO \
|
||||
)? \
|
||||
(ADC3_EXTERNALTRIG_T8_TRGO) \
|
||||
: \
|
||||
(__EXT_TRIG_CONV__) \
|
||||
) \
|
||||
: \
|
||||
(__EXT_TRIG_CONV__) \
|
||||
)
|
||||
#else
|
||||
#define ADC_CFGR_EXTSEL(__HANDLE__, __EXT_TRIG_CONV__) \
|
||||
(__EXT_TRIG_CONV__)
|
||||
#endif /* STM32F103xE || STM32F103xG */
|
||||
|
||||
/**
|
||||
* @brief For devices with 3 ADCs: Defines the external trigger source
|
||||
* for injected group according to ADC into common group ADC1&ADC2 or
|
||||
* ADC3 (some triggers with same source have different value to
|
||||
* be programmed into ADC JEXTSEL bits of CR2 register).
|
||||
* For devices with 2 ADCs or less: this macro makes no change.
|
||||
* @param __HANDLE__: ADC handle
|
||||
* @param __EXT_TRIG_INJECTCONV__: External trigger selected for injected group.
|
||||
* @retval External trigger to be programmed into JEXTSEL bits of CR2 register
|
||||
*/
|
||||
#if defined (STM32F103xE) || defined (STM32F103xG)
|
||||
#define ADC_CFGR_JEXTSEL(__HANDLE__, __EXT_TRIG_INJECTCONV__) \
|
||||
(( (((__HANDLE__)->Instance) == ADC3) \
|
||||
)? \
|
||||
( ( (__EXT_TRIG_INJECTCONV__) == ADC_EXTERNALTRIGINJECCONV_T8_CC4 \
|
||||
)? \
|
||||
(ADC3_EXTERNALTRIGINJEC_T8_CC4) \
|
||||
: \
|
||||
(__EXT_TRIG_INJECTCONV__) \
|
||||
) \
|
||||
: \
|
||||
(__EXT_TRIG_INJECTCONV__) \
|
||||
)
|
||||
#else
|
||||
#define ADC_CFGR_JEXTSEL(__HANDLE__, __EXT_TRIG_INJECTCONV__) \
|
||||
(__EXT_TRIG_INJECTCONV__)
|
||||
#endif /* STM32F103xE || STM32F103xG */
|
||||
|
||||
|
||||
/**
|
||||
* @brief Verification if multimode is enabled for the selected ADC (multimode ADC master or ADC slave) (applicable for devices with several ADCs)
|
||||
* @param __HANDLE__: ADC handle
|
||||
* @retval Multimode state: RESET if multimode is disabled, other value if multimode is enabled
|
||||
*/
|
||||
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
|
||||
#define ADC_MULTIMODE_IS_ENABLE(__HANDLE__) \
|
||||
(( (((__HANDLE__)->Instance) == ADC1) || (((__HANDLE__)->Instance) == ADC2) \
|
||||
)? \
|
||||
(ADC1->CR1 & ADC_CR1_DUALMOD) \
|
||||
: \
|
||||
(RESET) \
|
||||
)
|
||||
#else
|
||||
#define ADC_MULTIMODE_IS_ENABLE(__HANDLE__) \
|
||||
(RESET)
|
||||
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
|
||||
|
||||
/**
|
||||
* @brief Verification of condition for ADC start conversion: ADC must be in non-multimode, or multimode with handle of ADC master (applicable for devices with several ADCs)
|
||||
* @param __HANDLE__: ADC handle
|
||||
* @retval None
|
||||
*/
|
||||
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
|
||||
#define ADC_NONMULTIMODE_OR_MULTIMODEMASTER(__HANDLE__) \
|
||||
(( (((__HANDLE__)->Instance) == ADC2) \
|
||||
)? \
|
||||
((ADC1->CR1 & ADC_CR1_DUALMOD) == RESET) \
|
||||
: \
|
||||
(!RESET) \
|
||||
)
|
||||
#else
|
||||
#define ADC_NONMULTIMODE_OR_MULTIMODEMASTER(__HANDLE__) \
|
||||
(!RESET)
|
||||
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
|
||||
|
||||
/**
|
||||
* @brief Check ADC multimode setting: In case of multimode, check whether ADC master of the selected ADC has feature auto-injection enabled (applicable for devices with several ADCs)
|
||||
* @param __HANDLE__: ADC handle
|
||||
* @retval None
|
||||
*/
|
||||
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
|
||||
#define ADC_MULTIMODE_AUTO_INJECTED(__HANDLE__) \
|
||||
(( (((__HANDLE__)->Instance) == ADC1) || (((__HANDLE__)->Instance) == ADC2) \
|
||||
)? \
|
||||
(ADC1->CR1 & ADC_CR1_JAUTO) \
|
||||
: \
|
||||
(RESET) \
|
||||
)
|
||||
#else
|
||||
#define ADC_MULTIMODE_AUTO_INJECTED(__HANDLE__) \
|
||||
(RESET)
|
||||
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
|
||||
|
||||
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
|
||||
/**
|
||||
* @brief Set handle of the other ADC sharing the common multimode settings
|
||||
* @param __HANDLE__: ADC handle
|
||||
* @param __HANDLE_OTHER_ADC__: other ADC handle
|
||||
* @retval None
|
||||
*/
|
||||
#define ADC_COMMON_ADC_OTHER(__HANDLE__, __HANDLE_OTHER_ADC__) \
|
||||
((__HANDLE_OTHER_ADC__)->Instance = ADC2)
|
||||
|
||||
/**
|
||||
* @brief Set handle of the ADC slave associated to the ADC master
|
||||
* On STM32F1 devices, ADC slave is always ADC2 (this can be different
|
||||
* on other STM32 devices)
|
||||
* @param __HANDLE_MASTER__: ADC master handle
|
||||
* @param __HANDLE_SLAVE__: ADC slave handle
|
||||
* @retval None
|
||||
*/
|
||||
#define ADC_MULTI_SLAVE(__HANDLE_MASTER__, __HANDLE_SLAVE__) \
|
||||
((__HANDLE_SLAVE__)->Instance = ADC2)
|
||||
|
||||
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
|
||||
|
||||
#define IS_ADC_INJECTED_RANK(CHANNEL) (((CHANNEL) == ADC_INJECTED_RANK_1) || \
|
||||
((CHANNEL) == ADC_INJECTED_RANK_2) || \
|
||||
((CHANNEL) == ADC_INJECTED_RANK_3) || \
|
||||
((CHANNEL) == ADC_INJECTED_RANK_4))
|
||||
|
||||
#define IS_ADC_EXTTRIGINJEC_EDGE(EDGE) (((EDGE) == ADC_EXTERNALTRIGINJECCONV_EDGE_NONE) || \
|
||||
((EDGE) == ADC_EXTERNALTRIGINJECCONV_EDGE_RISING))
|
||||
|
||||
/** @defgroup ADCEx_injected_nb_conv_verification ADCEx injected nb conv verification
|
||||
* @{
|
||||
*/
|
||||
#define IS_ADC_INJECTED_NB_CONV(LENGTH) (((LENGTH) >= 1U) && ((LENGTH) <= 4U))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if defined (STM32F100xB) || defined (STM32F100xE) || defined (STM32F101x6) || defined (STM32F101xB) || defined (STM32F102x6) || defined (STM32F102xB) || defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC)
|
||||
#define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
|
||||
((REGTRIG) == ADC_SOFTWARE_START))
|
||||
#endif
|
||||
#if defined (STM32F101xE)
|
||||
#define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_TRGO) || \
|
||||
((REGTRIG) == ADC_SOFTWARE_START))
|
||||
#endif
|
||||
#if defined (STM32F101xG)
|
||||
#define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
|
||||
((REGTRIG) == ADC_SOFTWARE_START))
|
||||
#endif
|
||||
#if defined (STM32F103xE) || defined (STM32F103xG)
|
||||
#define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_CC1) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC3) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_CC1) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T5_CC1) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T5_CC3) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC3) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_TRGO) || \
|
||||
((REGTRIG) == ADC_SOFTWARE_START))
|
||||
#endif
|
||||
|
||||
#if defined (STM32F100xB) || defined (STM32F100xE) || defined (STM32F101x6) || defined (STM32F101xB) || defined (STM32F102x6) || defined (STM32F102xB) || defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC)
|
||||
#define IS_ADC_EXTTRIGINJEC(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \
|
||||
((REGTRIG) == ADC_INJECTED_SOFTWARE_START))
|
||||
#endif
|
||||
#if defined (STM32F101xE)
|
||||
#define IS_ADC_EXTTRIGINJEC(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC4) || \
|
||||
((REGTRIG) == ADC_INJECTED_SOFTWARE_START))
|
||||
#endif
|
||||
#if defined (STM32F101xG)
|
||||
#define IS_ADC_EXTTRIGINJEC(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \
|
||||
((REGTRIG) == ADC_INJECTED_SOFTWARE_START))
|
||||
#endif
|
||||
#if defined (STM32F103xE) || defined (STM32F103xG)
|
||||
#define IS_ADC_EXTTRIGINJEC(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T5_CC4) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC3) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC2) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T5_TRGO) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T5_CC4) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC4) || \
|
||||
((REGTRIG) == ADC_INJECTED_SOFTWARE_START))
|
||||
#endif
|
||||
|
||||
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
|
||||
#define IS_ADC_MODE(MODE) (((MODE) == ADC_MODE_INDEPENDENT) || \
|
||||
((MODE) == ADC_DUALMODE_REGSIMULT_INJECSIMULT) || \
|
||||
((MODE) == ADC_DUALMODE_REGSIMULT_ALTERTRIG) || \
|
||||
((MODE) == ADC_DUALMODE_INJECSIMULT_INTERLFAST) || \
|
||||
((MODE) == ADC_DUALMODE_INJECSIMULT_INTERLSLOW) || \
|
||||
((MODE) == ADC_DUALMODE_INJECSIMULT) || \
|
||||
((MODE) == ADC_DUALMODE_REGSIMULT) || \
|
||||
((MODE) == ADC_DUALMODE_INTERLFAST) || \
|
||||
((MODE) == ADC_DUALMODE_INTERLSLOW) || \
|
||||
((MODE) == ADC_DUALMODE_ALTERTRIG) )
|
||||
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @addtogroup ADCEx_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* IO operation functions *****************************************************/
|
||||
/** @addtogroup ADCEx_Exported_Functions_Group1
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* ADC calibration */
|
||||
HAL_StatusTypeDef HAL_ADCEx_Calibration_Start(ADC_HandleTypeDef* hadc);
|
||||
|
||||
/* Blocking mode: Polling */
|
||||
HAL_StatusTypeDef HAL_ADCEx_InjectedStart(ADC_HandleTypeDef* hadc);
|
||||
HAL_StatusTypeDef HAL_ADCEx_InjectedStop(ADC_HandleTypeDef* hadc);
|
||||
HAL_StatusTypeDef HAL_ADCEx_InjectedPollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
|
||||
|
||||
/* Non-blocking mode: Interruption */
|
||||
HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT(ADC_HandleTypeDef* hadc);
|
||||
HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT(ADC_HandleTypeDef* hadc);
|
||||
|
||||
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
|
||||
/* ADC multimode */
|
||||
HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA(ADC_HandleTypeDef *hadc, uint32_t *pData, uint32_t Length);
|
||||
HAL_StatusTypeDef HAL_ADCEx_MultiModeStop_DMA(ADC_HandleTypeDef *hadc);
|
||||
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
|
||||
|
||||
/* ADC retrieve conversion value intended to be used with polling or interruption */
|
||||
uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef* hadc, uint32_t InjectedRank);
|
||||
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
|
||||
uint32_t HAL_ADCEx_MultiModeGetValue(ADC_HandleTypeDef *hadc);
|
||||
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
|
||||
|
||||
/* ADC IRQHandler and Callbacks used in non-blocking modes (Interruption) */
|
||||
void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Peripheral Control functions ***********************************************/
|
||||
/** @addtogroup ADCEx_Exported_Functions_Group2
|
||||
* @{
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef* hadc,ADC_InjectionConfTypeDef* sConfigInjected);
|
||||
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
|
||||
HAL_StatusTypeDef HAL_ADCEx_MultiModeConfigChannel(ADC_HandleTypeDef *hadc, ADC_MultiModeTypeDef *multimode);
|
||||
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32F1xx_HAL_ADC_EX_H */
|
||||
2153
STM32F103C8T6/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h
Normal file
2153
STM32F103C8T6/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,261 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32f1xx_hal_tim_ex.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header file of TIM HAL Extended module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef STM32F1xx_HAL_TIM_EX_H
|
||||
#define STM32F1xx_HAL_TIM_EX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f1xx_hal_def.h"
|
||||
|
||||
/** @addtogroup STM32F1xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup TIMEx
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup TIMEx_Exported_Types TIM Extended Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief TIM Hall sensor Configuration Structure definition
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t IC1Polarity; /*!< Specifies the active edge of the input signal.
|
||||
This parameter can be a value of @ref TIM_Input_Capture_Polarity */
|
||||
|
||||
uint32_t IC1Prescaler; /*!< Specifies the Input Capture Prescaler.
|
||||
This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
|
||||
|
||||
uint32_t IC1Filter; /*!< Specifies the input capture filter.
|
||||
This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
|
||||
|
||||
uint32_t Commutation_Delay; /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
|
||||
This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
|
||||
} TIM_HallSensor_InitTypeDef;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* End of exported types -----------------------------------------------------*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup TIMEx_Exported_Constants TIM Extended Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup TIMEx_Remap TIM Extended Remapping
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* End of exported constants -------------------------------------------------*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup TIMEx_Exported_Macros TIM Extended Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* End of exported macro -----------------------------------------------------*/
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/** @defgroup TIMEx_Private_Macros TIM Extended Private Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* End of private macro ------------------------------------------------------*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @addtogroup TIMEx_Exported_Functions TIM Extended Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup TIMEx_Exported_Functions_Group1 Extended Timer Hall Sensor functions
|
||||
* @brief Timer Hall Sensor functions
|
||||
* @{
|
||||
*/
|
||||
/* Timer Hall Sensor functions **********************************************/
|
||||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, const TIM_HallSensor_InitTypeDef *sConfig);
|
||||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim);
|
||||
|
||||
void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim);
|
||||
|
||||
/* Blocking mode: Polling */
|
||||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim);
|
||||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim);
|
||||
/* Non-Blocking mode: Interrupt */
|
||||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim);
|
||||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim);
|
||||
/* Non-Blocking mode: DMA */
|
||||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
|
||||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup TIMEx_Exported_Functions_Group2 Extended Timer Complementary Output Compare functions
|
||||
* @brief Timer Complementary Output Compare functions
|
||||
* @{
|
||||
*/
|
||||
/* Timer Complementary Output Compare functions *****************************/
|
||||
/* Blocking mode: Polling */
|
||||
HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
|
||||
/* Non-Blocking mode: Interrupt */
|
||||
HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
|
||||
/* Non-Blocking mode: DMA */
|
||||
HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, const uint32_t *pData,
|
||||
uint16_t Length);
|
||||
HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup TIMEx_Exported_Functions_Group3 Extended Timer Complementary PWM functions
|
||||
* @brief Timer Complementary PWM functions
|
||||
* @{
|
||||
*/
|
||||
/* Timer Complementary PWM functions ****************************************/
|
||||
/* Blocking mode: Polling */
|
||||
HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
|
||||
/* Non-Blocking mode: Interrupt */
|
||||
HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
/* Non-Blocking mode: DMA */
|
||||
HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, const uint32_t *pData,
|
||||
uint16_t Length);
|
||||
HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup TIMEx_Exported_Functions_Group4 Extended Timer Complementary One Pulse functions
|
||||
* @brief Timer Complementary One Pulse functions
|
||||
* @{
|
||||
*/
|
||||
/* Timer Complementary One Pulse functions **********************************/
|
||||
/* Blocking mode: Polling */
|
||||
HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
|
||||
HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
|
||||
|
||||
/* Non-Blocking mode: Interrupt */
|
||||
HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
|
||||
HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions
|
||||
* @brief Peripheral Control functions
|
||||
* @{
|
||||
*/
|
||||
/* Extended Control functions ************************************************/
|
||||
HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
|
||||
uint32_t CommutationSource);
|
||||
HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_IT(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
|
||||
uint32_t CommutationSource);
|
||||
HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_DMA(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
|
||||
uint32_t CommutationSource);
|
||||
HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim,
|
||||
const TIM_MasterConfigTypeDef *sMasterConfig);
|
||||
HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim,
|
||||
const TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig);
|
||||
HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup TIMEx_Exported_Functions_Group6 Extended Callbacks functions
|
||||
* @brief Extended Callbacks functions
|
||||
* @{
|
||||
*/
|
||||
/* Extended Callback **********************************************************/
|
||||
void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIMEx_CommutHalfCpltCallback(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup TIMEx_Exported_Functions_Group7 Extended Peripheral State functions
|
||||
* @brief Extended Peripheral State functions
|
||||
* @{
|
||||
*/
|
||||
/* Extended Peripheral State functions ***************************************/
|
||||
HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(const TIM_HandleTypeDef *htim);
|
||||
HAL_TIM_ChannelStateTypeDef HAL_TIMEx_GetChannelNState(const TIM_HandleTypeDef *htim, uint32_t ChannelN);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* End of exported functions -------------------------------------------------*/
|
||||
|
||||
/* Private functions----------------------------------------------------------*/
|
||||
/** @addtogroup TIMEx_Private_Functions TIM Extended Private Functions
|
||||
* @{
|
||||
*/
|
||||
void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma);
|
||||
void TIMEx_DMACommutationHalfCplt(DMA_HandleTypeDef *hdma);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* End of private functions --------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* STM32F1xx_HAL_TIM_EX_H */
|
||||
3929
STM32F103C8T6/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_adc.h
Normal file
3929
STM32F103C8T6/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_adc.h
Normal file
File diff suppressed because it is too large
Load Diff
3901
STM32F103C8T6/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_tim.h
Normal file
3901
STM32F103C8T6/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_tim.h
Normal file
File diff suppressed because it is too large
Load Diff
2428
STM32F103C8T6/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c
Normal file
2428
STM32F103C8T6/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
7629
STM32F103C8T6/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c
Normal file
7629
STM32F103C8T6/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user