mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-17 08:25:53 +08:00
删除stm32代码
This commit is contained in:
@@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2018 Zibin Zheng
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
# MultiButton
|
|
||||||
|
|
||||||
## 简介
|
|
||||||
MultiButton 是一个小巧简单易用的事件驱动型按键驱动模块,可无限量扩展按键,按键事件的回调异步处理方式可以简化你的程序结构,去除冗余的按键处理硬编码,让你的按键业务逻辑更清晰。
|
|
||||||
|
|
||||||
## 使用方法
|
|
||||||
1.先申请一个按键结构
|
|
||||||
|
|
||||||
```c
|
|
||||||
struct Button button1;
|
|
||||||
```
|
|
||||||
2.初始化按键对象,绑定按键的GPIO电平读取接口**read_button_pin()** ,后一个参数设置有效触发电平
|
|
||||||
|
|
||||||
```c
|
|
||||||
button_init(&button1, read_button_pin, 0);
|
|
||||||
```
|
|
||||||
3.注册按键事件
|
|
||||||
|
|
||||||
```c
|
|
||||||
button_attach(&button1, SINGLE_CLICK, Callback_SINGLE_CLICK_Handler);
|
|
||||||
button_attach(&button1, DOUBLE_CLICK, Callback_DOUBLE_Click_Handler);
|
|
||||||
...
|
|
||||||
```
|
|
||||||
4.启动按键
|
|
||||||
|
|
||||||
```c
|
|
||||||
button_start(&button1);
|
|
||||||
```
|
|
||||||
5.设置一个5ms间隔的定时器循环调用后台处理函数
|
|
||||||
|
|
||||||
```c
|
|
||||||
while(1) {
|
|
||||||
...
|
|
||||||
if(timer_ticks == 5) {
|
|
||||||
timer_ticks = 0;
|
|
||||||
|
|
||||||
button_ticks();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 特性
|
|
||||||
|
|
||||||
MultiButton 使用C语言实现,基于面向对象方式设计思路,每个按键对象单独用一份数据结构管理:
|
|
||||||
|
|
||||||
```c
|
|
||||||
struct Button {
|
|
||||||
uint16_t ticks;
|
|
||||||
uint8_t repeat: 4;
|
|
||||||
uint8_t event : 4;
|
|
||||||
uint8_t state : 3;
|
|
||||||
uint8_t debounce_cnt : 3;
|
|
||||||
uint8_t active_level : 1;
|
|
||||||
uint8_t button_level : 1;
|
|
||||||
uint8_t (*hal_button_Level)(void);
|
|
||||||
BtnCallback cb[number_of_event];
|
|
||||||
struct Button* next;
|
|
||||||
};
|
|
||||||
```
|
|
||||||
这样每个按键使用单向链表相连,依次进入 button_handler(struct Button* handle) 状态机处理,所以每个按键的状态彼此独立。
|
|
||||||
|
|
||||||
|
|
||||||
## 按键事件
|
|
||||||
|
|
||||||
事件 | 说明
|
|
||||||
---|---
|
|
||||||
PRESS_DOWN | 按键按下,每次按下都触发
|
|
||||||
PRESS_UP | 按键弹起,每次松开都触发
|
|
||||||
PRESS_REPEAT | 重复按下触发,变量repeat计数连击次数
|
|
||||||
SINGLE_CLICK | 单击按键事件
|
|
||||||
DOUBLE_CLICK | 双击按键事件
|
|
||||||
LONG_PRESS_START | 达到长按时间阈值时触发一次
|
|
||||||
LONG_PRESS_HOLD | 长按期间一直触发
|
|
||||||
|
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
```c
|
|
||||||
#include "button.h"
|
|
||||||
|
|
||||||
struct Button btn1;
|
|
||||||
|
|
||||||
int read_button1_GPIO()
|
|
||||||
{
|
|
||||||
return HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
button_init(&btn1, read_button1_GPIO, 0);
|
|
||||||
button_attach(&btn1, PRESS_DOWN, BTN1_PRESS_DOWN_Handler);
|
|
||||||
button_attach(&btn1, PRESS_UP, BTN1_PRESS_UP_Handler);
|
|
||||||
button_attach(&btn1, PRESS_REPEAT, BTN1_PRESS_REPEAT_Handler);
|
|
||||||
button_attach(&btn1, SINGLE_CLICK, BTN1_SINGLE_Click_Handler);
|
|
||||||
button_attach(&btn1, DOUBLE_CLICK, BTN1_DOUBLE_Click_Handler);
|
|
||||||
button_attach(&btn1, LONG_PRESS_START, BTN1_LONG_PRESS_START_Handler);
|
|
||||||
button_attach(&btn2, LONG_PRESS_HOLD, BTN1_LONG_PRESS_HOLD_Handler);
|
|
||||||
button_start(&btn1);
|
|
||||||
|
|
||||||
//make the timer invoking the button_ticks() interval 5ms.
|
|
||||||
//This function is implemented by yourself.
|
|
||||||
__timer_start(button_ticks, 0, 5);
|
|
||||||
|
|
||||||
while(1)
|
|
||||||
{}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BTN1_PRESS_DOWN_Handler(void* btn)
|
|
||||||
{
|
|
||||||
//do something...
|
|
||||||
}
|
|
||||||
|
|
||||||
void BTN1_PRESS_UP_Handler(void* btn)
|
|
||||||
{
|
|
||||||
//do something...
|
|
||||||
}
|
|
||||||
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
#include "multi_button.h"
|
|
||||||
|
|
||||||
struct Button btn1;
|
|
||||||
struct Button btn2;
|
|
||||||
|
|
||||||
uint8_t read_button1_GPIO()
|
|
||||||
{
|
|
||||||
return HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t read_button2_GPIO()
|
|
||||||
{
|
|
||||||
return HAL_GPIO_ReadPin(B2_GPIO_Port, B2_Pin);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
button_init(&btn1, read_button1_GPIO, 0);
|
|
||||||
button_init(&btn2, read_button2_GPIO, 0);
|
|
||||||
|
|
||||||
button_attach(&btn1, PRESS_DOWN, BTN1_PRESS_DOWN_Handler);
|
|
||||||
button_attach(&btn1, PRESS_UP, BTN1_PRESS_UP_Handler);
|
|
||||||
button_attach(&btn1, PRESS_REPEAT, BTN1_PRESS_REPEAT_Handler);
|
|
||||||
button_attach(&btn1, SINGLE_CLICK, BTN1_SINGLE_Click_Handler);
|
|
||||||
button_attach(&btn1, DOUBLE_CLICK, BTN1_DOUBLE_Click_Handler);
|
|
||||||
button_attach(&btn1, LONG_PRESS_START, BTN1_LONG_PRESS_START_Handler);
|
|
||||||
button_attach(&btn1, LONG_PRESS_HOLD, BTN1_LONG_PRESS_HOLD_Handler);
|
|
||||||
|
|
||||||
button_attach(&btn2, PRESS_DOWN, BTN2_PRESS_DOWN_Handler);
|
|
||||||
button_attach(&btn2, PRESS_UP, BTN2_PRESS_UP_Handler);
|
|
||||||
button_attach(&btn2, PRESS_REPEAT, BTN2_PRESS_REPEAT_Handler);
|
|
||||||
button_attach(&btn2, SINGLE_CLICK, BTN2_SINGLE_Click_Handler);
|
|
||||||
button_attach(&btn2, DOUBLE_CLICK, BTN2_DOUBLE_Click_Handler);
|
|
||||||
button_attach(&btn2, LONG_PRESS_START, BTN2_LONG_PRESS_START_Handler);
|
|
||||||
button_attach(&btn2, LONG_PRESS_HOLD, BTN2_LONG_PRESS_HOLD_Handler);
|
|
||||||
|
|
||||||
button_start(&btn1);
|
|
||||||
button_start(&btn2);
|
|
||||||
|
|
||||||
//make the timer invoking the button_ticks() interval 5ms.
|
|
||||||
//This function is implemented by yourself.
|
|
||||||
__timer_start(button_ticks, 0, 5);
|
|
||||||
|
|
||||||
while(1)
|
|
||||||
{}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BTN1_PRESS_DOWN_Handler(void* btn)
|
|
||||||
{
|
|
||||||
//do something...
|
|
||||||
}
|
|
||||||
|
|
||||||
void BTN1_PRESS_UP_Handler(void* btn)
|
|
||||||
{
|
|
||||||
//do something...
|
|
||||||
}
|
|
||||||
|
|
||||||
...
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
#include "multi_button.h"
|
|
||||||
|
|
||||||
struct Button btn1;
|
|
||||||
|
|
||||||
uint8_t read_button1_GPIO()
|
|
||||||
{
|
|
||||||
return HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
static uint8_t btn1_event_val;
|
|
||||||
|
|
||||||
button_init(&btn1, read_button1_GPIO, 0);
|
|
||||||
button_start(&btn1);
|
|
||||||
|
|
||||||
//make the timer invoking the button_ticks() interval 5ms.
|
|
||||||
//This function is implemented by yourself.
|
|
||||||
__timer_start(button_ticks, 0, 5);
|
|
||||||
|
|
||||||
while(1)
|
|
||||||
{
|
|
||||||
if(btn1_event_val != get_button_event(&btn1)) {
|
|
||||||
btn1_event_val = get_button_event(&btn1);
|
|
||||||
|
|
||||||
if(btn1_event_val == PRESS_DOWN) {
|
|
||||||
//do something
|
|
||||||
} else if(btn1_event_val == PRESS_UP) {
|
|
||||||
//do something
|
|
||||||
} else if(btn1_event_val == LONG_PRESS_HOLD) {
|
|
||||||
//do something
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,197 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 Zibin Zheng <znbin@qq.com>
|
|
||||||
* All rights reserved
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "multi_button.h"
|
|
||||||
|
|
||||||
#define EVENT_CB(ev) if(handle->cb[ev])handle->cb[ev]((Button*)handle)
|
|
||||||
|
|
||||||
//button handle list head.
|
|
||||||
static struct Button* head_handle = NULL;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initializes the button struct handle.
|
|
||||||
* @param handle: the button handle strcut.
|
|
||||||
* @param pin_level: read the HAL GPIO of the connet button level.
|
|
||||||
* @param active_level: pressed GPIO level.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void button_init(struct Button* handle, uint8_t(*pin_level)(), uint8_t active_level)
|
|
||||||
{
|
|
||||||
memset(handle, 0, sizeof(struct Button));
|
|
||||||
handle->event = (uint8_t)NONE_PRESS;
|
|
||||||
handle->hal_button_Level = pin_level;
|
|
||||||
handle->button_level = handle->hal_button_Level();
|
|
||||||
handle->active_level = active_level;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Attach the button event callback function.
|
|
||||||
* @param handle: the button handle strcut.
|
|
||||||
* @param event: trigger event type.
|
|
||||||
* @param cb: callback function.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void button_attach(struct Button* handle, PressEvent event, BtnCallback cb)
|
|
||||||
{
|
|
||||||
handle->cb[event] = cb;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Inquire the button event happen.
|
|
||||||
* @param handle: the button handle strcut.
|
|
||||||
* @retval button event.
|
|
||||||
*/
|
|
||||||
PressEvent get_button_event(struct Button* handle)
|
|
||||||
{
|
|
||||||
return (PressEvent)(handle->event);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Button driver core function, driver state machine.
|
|
||||||
* @param handle: the button handle strcut.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void button_handler(struct Button* handle)
|
|
||||||
{
|
|
||||||
uint8_t read_gpio_level = handle->hal_button_Level();
|
|
||||||
|
|
||||||
//ticks counter working..
|
|
||||||
if((handle->state) > 0) handle->ticks++;
|
|
||||||
|
|
||||||
/*------------button debounce handle---------------*/
|
|
||||||
if(read_gpio_level != handle->button_level) { //not equal to prev one
|
|
||||||
//continue read 3 times same new level change
|
|
||||||
if(++(handle->debounce_cnt) >= DEBOUNCE_TICKS) {
|
|
||||||
handle->button_level = read_gpio_level;
|
|
||||||
handle->debounce_cnt = 0;
|
|
||||||
}
|
|
||||||
} else { //leved not change ,counter reset.
|
|
||||||
handle->debounce_cnt = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*-----------------State machine-------------------*/
|
|
||||||
switch (handle->state) {
|
|
||||||
case 0:
|
|
||||||
if(handle->button_level == handle->active_level) { //start press down
|
|
||||||
handle->event = (uint8_t)PRESS_DOWN;
|
|
||||||
EVENT_CB(PRESS_DOWN);
|
|
||||||
handle->ticks = 0;
|
|
||||||
handle->repeat = 1;
|
|
||||||
handle->state = 1;
|
|
||||||
} else {
|
|
||||||
handle->event = (uint8_t)NONE_PRESS;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
if(handle->button_level != handle->active_level) { //released press up
|
|
||||||
handle->event = (uint8_t)PRESS_UP;
|
|
||||||
EVENT_CB(PRESS_UP);
|
|
||||||
handle->ticks = 0;
|
|
||||||
handle->state = 2;
|
|
||||||
|
|
||||||
} else if(handle->ticks > LONG_TICKS) {
|
|
||||||
handle->event = (uint8_t)LONG_PRESS_START;
|
|
||||||
EVENT_CB(LONG_PRESS_START);
|
|
||||||
handle->state = 5;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
if(handle->button_level == handle->active_level) { //press down again
|
|
||||||
handle->event = (uint8_t)PRESS_DOWN;
|
|
||||||
EVENT_CB(PRESS_DOWN);
|
|
||||||
handle->repeat++;
|
|
||||||
EVENT_CB(PRESS_REPEAT); // repeat hit
|
|
||||||
handle->ticks = 0;
|
|
||||||
handle->state = 3;
|
|
||||||
} else if(handle->ticks > SHORT_TICKS) { //released timeout
|
|
||||||
if(handle->repeat == 1) {
|
|
||||||
handle->event = (uint8_t)SINGLE_CLICK;
|
|
||||||
EVENT_CB(SINGLE_CLICK);
|
|
||||||
} else if(handle->repeat == 2) {
|
|
||||||
handle->event = (uint8_t)DOUBLE_CLICK;
|
|
||||||
EVENT_CB(DOUBLE_CLICK); // repeat hit
|
|
||||||
}
|
|
||||||
handle->state = 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
if(handle->button_level != handle->active_level) { //released press up
|
|
||||||
handle->event = (uint8_t)PRESS_UP;
|
|
||||||
EVENT_CB(PRESS_UP);
|
|
||||||
if(handle->ticks < SHORT_TICKS) {
|
|
||||||
handle->ticks = 0;
|
|
||||||
handle->state = 2; //repeat press
|
|
||||||
} else {
|
|
||||||
handle->state = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
if(handle->button_level == handle->active_level) {
|
|
||||||
//continue hold trigger
|
|
||||||
handle->event = (uint8_t)LONG_PRESS_HOLD;
|
|
||||||
EVENT_CB(LONG_PRESS_HOLD);
|
|
||||||
|
|
||||||
} else { //releasd
|
|
||||||
handle->event = (uint8_t)PRESS_UP;
|
|
||||||
EVENT_CB(PRESS_UP);
|
|
||||||
handle->state = 0; //reset
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Start the button work, add the handle into work list.
|
|
||||||
* @param handle: target handle strcut.
|
|
||||||
* @retval 0: succeed. -1: already exist.
|
|
||||||
*/
|
|
||||||
int button_start(struct Button* handle)
|
|
||||||
{
|
|
||||||
struct Button* target = head_handle;
|
|
||||||
while(target) {
|
|
||||||
if(target == handle) return -1; //already exist.
|
|
||||||
target = target->next;
|
|
||||||
}
|
|
||||||
handle->next = head_handle;
|
|
||||||
head_handle = handle;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Stop the button work, remove the handle off work list.
|
|
||||||
* @param handle: target handle strcut.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void button_stop(struct Button* handle)
|
|
||||||
{
|
|
||||||
struct Button** curr;
|
|
||||||
for(curr = &head_handle; *curr; ) {
|
|
||||||
struct Button* entry = *curr;
|
|
||||||
if (entry == handle) {
|
|
||||||
*curr = entry->next;
|
|
||||||
// free(entry);
|
|
||||||
} else
|
|
||||||
curr = &entry->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief background ticks, timer repeat invoking interval 5ms.
|
|
||||||
* @param None.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void button_ticks()
|
|
||||||
{
|
|
||||||
struct Button* target;
|
|
||||||
for(target=head_handle; target; target=target->next) {
|
|
||||||
button_handler(target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 Zibin Zheng <znbin@qq.com>
|
|
||||||
* All rights reserved
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _MULTI_BUTTON_H_
|
|
||||||
#define _MULTI_BUTTON_H_
|
|
||||||
|
|
||||||
#include "stdint.h"
|
|
||||||
#include "string.h"
|
|
||||||
|
|
||||||
//According to your need to modify the constants.
|
|
||||||
#define TICKS_INTERVAL 5 //ms
|
|
||||||
#define DEBOUNCE_TICKS 3 //MAX 8
|
|
||||||
#define SHORT_TICKS (300 /TICKS_INTERVAL)
|
|
||||||
#define LONG_TICKS (1000 /TICKS_INTERVAL)
|
|
||||||
|
|
||||||
|
|
||||||
typedef void (*BtnCallback)(void*);
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
PRESS_DOWN = 0,
|
|
||||||
PRESS_UP,
|
|
||||||
PRESS_REPEAT,
|
|
||||||
SINGLE_CLICK,
|
|
||||||
DOUBLE_CLICK,
|
|
||||||
LONG_PRESS_START,
|
|
||||||
LONG_PRESS_HOLD,
|
|
||||||
number_of_event,
|
|
||||||
NONE_PRESS
|
|
||||||
}PressEvent;
|
|
||||||
|
|
||||||
typedef struct Button {
|
|
||||||
uint16_t ticks;
|
|
||||||
uint8_t repeat : 4;
|
|
||||||
uint8_t event : 4;
|
|
||||||
uint8_t state : 3;
|
|
||||||
uint8_t debounce_cnt : 3;
|
|
||||||
uint8_t active_level : 1;
|
|
||||||
uint8_t button_level : 1;
|
|
||||||
uint8_t (*hal_button_Level)(void);
|
|
||||||
BtnCallback cb[number_of_event];
|
|
||||||
struct Button* next;
|
|
||||||
}Button;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void button_init(struct Button* handle, uint8_t(*pin_level)(), uint8_t active_level);
|
|
||||||
void button_attach(struct Button* handle, PressEvent event, BtnCallback cb);
|
|
||||||
PressEvent get_button_event(struct Button* handle);
|
|
||||||
int button_start(struct Button* handle);
|
|
||||||
void button_stop(struct Button* handle);
|
|
||||||
void button_ticks(void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
/****************************************Copyright (c)****************************************************
|
|
||||||
**
|
|
||||||
** File name: process.c
|
|
||||||
** Created by: XiaoYi
|
|
||||||
** Created date: 2020-10-16
|
|
||||||
** Version: v1.0
|
|
||||||
** Descriptions: The original
|
|
||||||
** Link address: https://blog.csdn.net/weixin_45006076
|
|
||||||
**
|
|
||||||
*********************************************************************************************************/
|
|
||||||
|
|
||||||
#include "process.h"
|
|
||||||
#include "gpio.h"
|
|
||||||
#include "flash.h"
|
|
||||||
#include "tim.h"
|
|
||||||
#include "oled.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
SG90<39>Ķ<EFBFBD><C4B6><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD> PWM <20>ź<EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD>50Hz<48><7A><EFBFBD>ң<EFBFBD><D2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ 20ms <20><> PWM <20>źţ<C5BA><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źŵĸߵ<C4B8>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0.5ms - 2.5ms֮<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD>ĽǶȣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
value<75><65><EFBFBD><EFBFBD>ֵ <20>ߵ<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>Ƕ<EFBFBD>
|
|
||||||
50 0.5ms 0<><30>
|
|
||||||
100 1ms 45<34><35>
|
|
||||||
150 1.5ms 90<39><30>
|
|
||||||
200 2ms 135<33><35>
|
|
||||||
250 2.5ms 180<38><30>
|
|
||||||
*/
|
|
||||||
void set_sg90(int value) // ģ<><EFBFBD><E2BFAA>
|
|
||||||
{
|
|
||||||
__HAL_TIM_SET_COMPARE(&htim4, TIM_CHANNEL_1, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void start_buzz(void)
|
|
||||||
{
|
|
||||||
BUZZ = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void stop_buzz(void)
|
|
||||||
{
|
|
||||||
BUZZ = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void process_local_handle(uint16_t value_humi)
|
|
||||||
{
|
|
||||||
/* <20><><EFBFBD><EFBFBD>ʪ<EFBFBD><CAAA>С<EFBFBD><D0A1>ϵͳ<CFB5><CDB3><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>Сֵ<D0A1><D6B5>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE><EFBFBD><EFBFBD>ʪ<EFBFBD>ȳ<EFBFBD><C8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵʱ<D6B5><CAB1><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9>ˮ<EFBFBD><CBAE><EFBFBD>رյ<D8B1><D5B5><EFBFBD> */
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
void process_report_data(void)
|
|
||||||
{
|
|
||||||
uint8_t send_buff[12];
|
|
||||||
|
|
||||||
// <20><>ǰϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ʱ<CCAC><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void process_handle_wifi_data(void)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/****************************************Copyright (c)****************************************************
|
|
||||||
**
|
|
||||||
** File name: process.h
|
|
||||||
** Created by: XiaoYi
|
|
||||||
** Created date: 2020-10-16
|
|
||||||
** Version: v1.0
|
|
||||||
** Descriptions: The original
|
|
||||||
** Link address: https://blog.csdn.net/weixin_45006076
|
|
||||||
**
|
|
||||||
*********************************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __PROCESS_H__
|
|
||||||
#define __PROCESS_H__
|
|
||||||
|
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
/* ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
||||||
#define BUZZ PBout(0)
|
|
||||||
|
|
||||||
void start_buzz(void);
|
|
||||||
|
|
||||||
void stop_buzz(void);
|
|
||||||
|
|
||||||
void process_local_handle(uint16_t value_humi);
|
|
||||||
|
|
||||||
void process_report_data(void);
|
|
||||||
|
|
||||||
void process_handle_wifi_data(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,616 +0,0 @@
|
|||||||
#include "rc522.h"
|
|
||||||
#include "spi.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20>Ӵ<EFBFBD><D3B4><EFBFBD>Flash<73><68>ȡһ<C8A1><D2BB><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
|
||||||
* <20><> <20><> ֵ: uint8_t<5F><74><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
* ˵ <20><><EFBFBD><EFBFBD>This function must be used only if the Start_Read_Sequence
|
|
||||||
* function has been previously called.
|
|
||||||
*/
|
|
||||||
uint8_t SPI_FLASH_ReadByte(void)
|
|
||||||
{
|
|
||||||
uint8_t d_read,d_send=Dummy_Byte;
|
|
||||||
if(HAL_SPI_TransmitReceive(&hspi2,&d_send,&d_read,1,0xFFFFFF)!=HAL_OK)
|
|
||||||
d_read=Dummy_Byte;
|
|
||||||
|
|
||||||
return d_read;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Flash<73><68>ȡд<C8A1><D0B4>һ<EFBFBD><D2BB><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: byte<74><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
* <20><> <20><> ֵ: uint8_t<5F><74><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
* ˵ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
uint8_t SPI_FLASH_SendByte(uint8_t byte)
|
|
||||||
{
|
|
||||||
uint8_t d_read,d_send=byte;
|
|
||||||
if(HAL_SPI_TransmitReceive(&hspi2,&d_send,&d_read,1,0xFFFFFF)!=HAL_OK)
|
|
||||||
d_read=Dummy_Byte;
|
|
||||||
|
|
||||||
return d_read;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ReadRawRC
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>RC522<32>Ĵ<EFBFBD><C4B4><EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><>ucAddress<73><73><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
||||||
* <20><><EFBFBD><EFBFBD> : <20>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>ĵ<EFBFBD>ǰֵ
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
uint8_t ReadRawRC ( uint8_t ucAddress )
|
|
||||||
{
|
|
||||||
uint8_t ucAddr, ucReturn;
|
|
||||||
|
|
||||||
ucAddr = ( ( ucAddress << 1 ) & 0x7E ) | 0x80;
|
|
||||||
|
|
||||||
macRC522_CS_Enable() ;
|
|
||||||
|
|
||||||
SPI_FLASH_SendByte ( ucAddr );
|
|
||||||
|
|
||||||
ucReturn = SPI_FLASH_ReadByte ();
|
|
||||||
|
|
||||||
macRC522_CS_Disable();
|
|
||||||
|
|
||||||
return ucReturn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>WriteRawRC
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><>дRC522<32>Ĵ<EFBFBD><C4B4><EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><>ucAddress<73><73><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
||||||
* ucValue<75><65>д<EFBFBD><D0B4><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
||||||
* <20><><EFBFBD><EFBFBD> : <20><>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
void WriteRawRC ( uint8_t ucAddress, uint8_t ucValue )
|
|
||||||
{
|
|
||||||
uint8_t ucAddr;
|
|
||||||
|
|
||||||
ucAddr = ( ucAddress << 1 ) & 0x7E;
|
|
||||||
|
|
||||||
macRC522_CS_Enable() ;
|
|
||||||
SPI_FLASH_SendByte ( ucAddr );
|
|
||||||
SPI_FLASH_SendByte ( ucValue );
|
|
||||||
|
|
||||||
macRC522_CS_Disable();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SetBitMask
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>RC522<32>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>λ
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><>ucReg<65><67><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
||||||
* ucMask<73><6B><EFBFBD><EFBFBD>λֵ
|
|
||||||
* <20><><EFBFBD><EFBFBD> : <20><>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
void SetBitMask ( uint8_t ucReg, uint8_t ucMask )
|
|
||||||
{
|
|
||||||
uint8_t ucTemp;
|
|
||||||
|
|
||||||
ucTemp = ReadRawRC ( ucReg );
|
|
||||||
WriteRawRC ( ucReg, ucTemp | ucMask ); // set bit mask
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ClearBitMask
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>RC522<32>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>λ
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><>ucReg<65><67><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
||||||
* ucMask<73><6B><EFBFBD><EFBFBD>λֵ
|
|
||||||
* <20><><EFBFBD><EFBFBD> : <20><>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
void ClearBitMask ( uint8_t ucReg, uint8_t ucMask )
|
|
||||||
{
|
|
||||||
uint8_t ucTemp;
|
|
||||||
|
|
||||||
ucTemp = ReadRawRC ( ucReg );
|
|
||||||
|
|
||||||
WriteRawRC ( ucReg, ucTemp & ( ~ ucMask) ); // clear bit mask
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PcdAntennaOn
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> : <20><>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
void PcdAntennaOn ( void )
|
|
||||||
{
|
|
||||||
uint8_t uc;
|
|
||||||
|
|
||||||
uc = ReadRawRC ( TxControlReg );
|
|
||||||
|
|
||||||
if ( ! ( uc & 0x03 ) )
|
|
||||||
SetBitMask(TxControlReg, 0x03);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PcdAntennaOff
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> : <20><>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
void PcdAntennaOff ( void )
|
|
||||||
{
|
|
||||||
ClearBitMask ( TxControlReg, 0x03 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PcdRese
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>λRC522
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> : <20><>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
void PcdReset ( void )
|
|
||||||
{
|
|
||||||
macRC522_Reset_Disable();
|
|
||||||
|
|
||||||
HAL_Delay ( 1 );
|
|
||||||
|
|
||||||
macRC522_Reset_Enable();
|
|
||||||
|
|
||||||
HAL_Delay ( 1 );
|
|
||||||
|
|
||||||
macRC522_Reset_Disable();
|
|
||||||
|
|
||||||
HAL_Delay ( 1 );
|
|
||||||
|
|
||||||
WriteRawRC ( CommandReg, 0x0f );
|
|
||||||
|
|
||||||
while ( ReadRawRC ( CommandReg ) & 0x10 );
|
|
||||||
|
|
||||||
HAL_Delay ( 1 );
|
|
||||||
|
|
||||||
WriteRawRC ( ModeReg, 0x3D ); //<2F><><EFBFBD>巢<EFBFBD>ͺͽ<CDBA><CDBD>ճ<EFBFBD><D5B3><EFBFBD>ģʽ <20><>Mifare<72><65>ͨѶ<CDA8><D1B6>CRC<52><43>ʼֵ0x6363
|
|
||||||
|
|
||||||
WriteRawRC ( TReloadRegL, 30 ); //16λ<36><CEBB>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>λ
|
|
||||||
WriteRawRC ( TReloadRegH, 0 ); //16λ<36><CEBB>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>λ
|
|
||||||
|
|
||||||
WriteRawRC ( TModeReg, 0x8D ); //<2F><><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
WriteRawRC ( TPrescalerReg, 0x3E ); //<2F><><EFBFBD>ö<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ƶϵ<C6B5><CFB5>
|
|
||||||
|
|
||||||
WriteRawRC ( TxAutoReg, 0x40 ); //<2F><><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>ź<EFBFBD>Ϊ100%ASK
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>M500PcdConfigISOType
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RC522<32>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD>ʽ
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><>ucType<70><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
|
||||||
* <20><><EFBFBD><EFBFBD> : <20><>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
void M500PcdConfigISOType ( uint8_t ucType )
|
|
||||||
{
|
|
||||||
if ( ucType == 'A') //ISO14443_A
|
|
||||||
{
|
|
||||||
ClearBitMask ( Status2Reg, 0x08 );
|
|
||||||
|
|
||||||
WriteRawRC ( ModeReg, 0x3D );//3F
|
|
||||||
|
|
||||||
WriteRawRC ( RxSelReg, 0x86 );//84
|
|
||||||
|
|
||||||
WriteRawRC( RFCfgReg, 0x7F ); //4F
|
|
||||||
|
|
||||||
WriteRawRC( TReloadRegL, 30 );//tmoLength);// TReloadVal = 'h6a =tmoLength(dec)
|
|
||||||
|
|
||||||
WriteRawRC ( TReloadRegH, 0 );
|
|
||||||
|
|
||||||
WriteRawRC ( TModeReg, 0x8D );
|
|
||||||
|
|
||||||
WriteRawRC ( TPrescalerReg, 0x3E );
|
|
||||||
|
|
||||||
HAL_Delay ( 2 );
|
|
||||||
|
|
||||||
PcdAntennaOn ();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PcdComMF522
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><>ͨ<EFBFBD><CDA8>RC522<32><32>ISO14443<34><33>ͨѶ
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><>ucCommand<6E><64>RC522<32><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
* pInData<74><61>ͨ<EFBFBD><CDA8>RC522<32><32><EFBFBD>͵<EFBFBD><CDB5><EFBFBD>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
* ucInLenByte<74><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5>ֽڳ<D6BD><DAB3><EFBFBD>
|
|
||||||
* pOutData<74><61><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5>Ŀ<EFBFBD>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
* pOutLenBit<69><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> : ״ֵ̬
|
|
||||||
* = MI_OK<4F><4B><EFBFBD>ɹ<EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
char PcdComMF522 ( uint8_t ucCommand, uint8_t * pInData, uint8_t ucInLenByte, uint8_t * pOutData, uint32_t * pOutLenBit )
|
|
||||||
{
|
|
||||||
char cStatus = MI_ERR;
|
|
||||||
uint8_t ucIrqEn = 0x00;
|
|
||||||
uint8_t ucWaitFor = 0x00;
|
|
||||||
uint8_t ucLastBits;
|
|
||||||
uint8_t ucN;
|
|
||||||
uint32_t ul;
|
|
||||||
|
|
||||||
switch ( ucCommand )
|
|
||||||
{
|
|
||||||
case PCD_AUTHENT: //Mifare<72><65>֤
|
|
||||||
ucIrqEn = 0x12; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>ErrIEn <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>IdleIEn
|
|
||||||
ucWaitFor = 0x10; //<2F><>֤Ѱ<D6A4><D1B0><EFBFBD>ȴ<EFBFBD>ʱ<EFBFBD><CAB1> <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־λ
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PCD_TRANSCEIVE: //<2F><><EFBFBD>շ<EFBFBD><D5B7><EFBFBD> <20><><EFBFBD>ͽ<EFBFBD><CDBD><EFBFBD>
|
|
||||||
ucIrqEn = 0x77; //<2F><><EFBFBD><EFBFBD>TxIEn RxIEn IdleIEn LoAlertIEn ErrIEn TimerIEn
|
|
||||||
ucWaitFor = 0x30; //Ѱ<><D1B0><EFBFBD>ȴ<EFBFBD>ʱ<EFBFBD><CAB1> <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־λ<D6BE><CEBB> <20><><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־λ
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
WriteRawRC ( ComIEnReg, ucIrqEn | 0x80 ); //IRqInv<6E><76>λ<EFBFBD>ܽ<EFBFBD>IRQ<52><51>Status1Reg<65><67>IRqλ<71><CEBB>ֵ<EFBFBD>෴
|
|
||||||
ClearBitMask ( ComIrqReg, 0x80 ); //Set1<74><31>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>CommIRqReg<65><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
|
||||||
WriteRawRC ( CommandReg, PCD_IDLE ); //д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
SetBitMask ( FIFOLevelReg, 0x80 ); //<2F><>λFlushBuffer<65><72><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD>FIFO<46>Ķ<EFBFBD><C4B6><EFBFBD>дָ<D0B4><D6B8><EFBFBD>Լ<EFBFBD>ErrReg<65><67>BufferOvfl<66><6C>־λ<D6BE><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
for ( ul = 0; ul < ucInLenByte; ul ++ )
|
|
||||||
WriteRawRC ( FIFODataReg, pInData [ ul ] ); //д<><D0B4><EFBFBD>ݽ<EFBFBD>FIFOdata
|
|
||||||
|
|
||||||
WriteRawRC ( CommandReg, ucCommand ); //д<><D0B4><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
if ( ucCommand == PCD_TRANSCEIVE )
|
|
||||||
SetBitMask(BitFramingReg,0x80); //StartSend<6E><64>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD> <20><>λ<EFBFBD><CEBB><EFBFBD>շ<EFBFBD><D5B7><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ч
|
|
||||||
|
|
||||||
ul = 1000;//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Ƶ<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>M1<4D><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD>ʱ<EFBFBD><CAB1>25ms
|
|
||||||
do //<2F><>֤ <20><>Ѱ<EFBFBD><D1B0><EFBFBD>ȴ<EFBFBD>ʱ<EFBFBD><CAB1>
|
|
||||||
{
|
|
||||||
ucN = ReadRawRC ( ComIrqReg ); //<2F><>ѯ<EFBFBD>¼<EFBFBD><C2BC>ж<EFBFBD>
|
|
||||||
ul --;
|
|
||||||
} while ( ( ul != 0 ) && ( ! ( ucN & 0x01 ) ) && ( ! ( ucN & ucWaitFor ) ) ); //<2F>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>i=0,<2C><>ʱ<EFBFBD><CAB1><EFBFBD>жϣ<D0B6><CFA3><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
ClearBitMask ( BitFramingReg, 0x80 ); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>StartSendλ
|
|
||||||
if ( ul != 0 )
|
|
||||||
{
|
|
||||||
if ( ! ( ReadRawRC ( ErrorReg ) & 0x1B ) ) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>BufferOfI CollErr ParityErr ProtocolErr
|
|
||||||
{
|
|
||||||
cStatus = MI_OK;
|
|
||||||
if ( ucN & ucIrqEn & 0x01 ) //<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ж<EFBFBD>
|
|
||||||
cStatus = MI_NOTAGERR;
|
|
||||||
|
|
||||||
if ( ucCommand == PCD_TRANSCEIVE )
|
|
||||||
{
|
|
||||||
ucN = ReadRawRC ( FIFOLevelReg ); //<2F><>FIFO<46>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>
|
|
||||||
|
|
||||||
ucLastBits = ReadRawRC ( ControlReg ) & 0x07; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD>ֽڵ<D6BD><DAB5><EFBFBD>Чλ<D0A7><CEBB>
|
|
||||||
|
|
||||||
if ( ucLastBits )
|
|
||||||
* pOutLenBit = ( ucN - 1 ) * 8 + ucLastBits; //N<><4E><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>ȥ1<C8A5><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ֽڣ<D6BD>+<2B><><EFBFBD><EFBFBD>һλ<D2BB><CEBB>λ<EFBFBD><CEBB> <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|
||||||
else
|
|
||||||
* pOutLenBit = ucN * 8; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>Ч
|
|
||||||
|
|
||||||
if ( ucN == 0 )
|
|
||||||
ucN = 1;
|
|
||||||
|
|
||||||
if ( ucN > MAXRLEN )
|
|
||||||
ucN = MAXRLEN;
|
|
||||||
|
|
||||||
for ( ul = 0; ul < ucN; ul ++ )
|
|
||||||
pOutData [ ul ] = ReadRawRC ( FIFODataReg );
|
|
||||||
}
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
cStatus = MI_ERR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SetBitMask ( ControlReg, 0x80 ); // stop timer now
|
|
||||||
WriteRawRC ( CommandReg, PCD_IDLE );
|
|
||||||
|
|
||||||
return cStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PcdRequest
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><>Ѱ<EFBFBD><D1B0>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><>ucReq_code<64><65>Ѱ<EFBFBD><D1B0><EFBFBD><EFBFBD>ʽ
|
|
||||||
* = 0x52<35><32>Ѱ<EFBFBD><D1B0>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD>14443A<33><41><EFBFBD>Ŀ<EFBFBD>
|
|
||||||
* = 0x26<32><36>Ѱδ<D1B0><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4>Ŀ<EFBFBD>
|
|
||||||
* pTagType<70><65><EFBFBD><EFBFBD>Ƭ<EFBFBD><C6AC><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>
|
|
||||||
* = 0x4400<30><30>Mifare_UltraLight
|
|
||||||
* = 0x0400<30><30>Mifare_One(S50)
|
|
||||||
* = 0x0200<30><30>Mifare_One(S70)
|
|
||||||
* = 0x0800<30><30>Mifare_Pro(X))
|
|
||||||
* = 0x4403<30><33>Mifare_DESFire
|
|
||||||
* <20><><EFBFBD><EFBFBD> : ״ֵ̬
|
|
||||||
* = MI_OK<4F><4B><EFBFBD>ɹ<EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
char PcdRequest ( uint8_t ucReq_code, uint8_t * pTagType )
|
|
||||||
{
|
|
||||||
char cStatus;
|
|
||||||
uint8_t ucComMF522Buf [ MAXRLEN ];
|
|
||||||
uint32_t ulLen;
|
|
||||||
|
|
||||||
|
|
||||||
ClearBitMask ( Status2Reg, 0x08 ); //<2F><><EFBFBD><EFBFBD>ָʾMIFARECyptol<6F><6C>Ԫ<EFBFBD><D4AA>ͨ<EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD>ű<EFBFBD><C5B1><EFBFBD><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
WriteRawRC ( BitFramingReg, 0x07 ); // <09><><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ֽڵ<D6BD> <20><>λ
|
|
||||||
SetBitMask ( TxControlReg, 0x03 ); //TX1,TX2<58>ܽŵ<DCBD><C5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>źŴ<C5BA><C5B4>ݾ<EFBFBD><DDBE><EFBFBD><EFBFBD>͵<EFBFBD><CDB5>Ƶ<EFBFBD>13.56<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD>ź<EFBFBD>
|
|
||||||
|
|
||||||
ucComMF522Buf [ 0 ] = ucReq_code; //<2F><><EFBFBD><EFBFBD> <20><>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
cStatus = PcdComMF522 ( PCD_TRANSCEIVE, ucComMF522Buf, 1, ucComMF522Buf, & ulLen ); //Ѱ<><D1B0>
|
|
||||||
|
|
||||||
if ( ( cStatus == MI_OK ) && ( ulLen == 0x10 ) ) //Ѱ<><D1B0><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
{
|
|
||||||
* pTagType = ucComMF522Buf [ 0 ];
|
|
||||||
* ( pTagType + 1 ) = ucComMF522Buf [ 1 ];
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
cStatus = MI_ERR;
|
|
||||||
|
|
||||||
return cStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PcdAnticoll
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ײ
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><>pSnr<6E><72><EFBFBD><EFBFBD>Ƭ<EFBFBD><C6AC><EFBFBD>кţ<D0BA>4<EFBFBD>ֽ<EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> : ״ֵ̬
|
|
||||||
* = MI_OK<4F><4B><EFBFBD>ɹ<EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
char PcdAnticoll ( uint8_t * pSnr )
|
|
||||||
{
|
|
||||||
char cStatus;
|
|
||||||
uint8_t uc, ucSnr_check = 0;
|
|
||||||
uint8_t ucComMF522Buf [ MAXRLEN ];
|
|
||||||
uint32_t ulLen;
|
|
||||||
|
|
||||||
ClearBitMask ( Status2Reg, 0x08 ); //<2F><>MFCryptol Onλ ֻ<>гɹ<D0B3>ִ<EFBFBD><D6B4>MFAuthent<6E><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
|
||||||
WriteRawRC ( BitFramingReg, 0x00); //<2F><><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD> ֹͣ<CDA3>շ<EFBFBD>
|
|
||||||
ClearBitMask ( CollReg, 0x80 ); //<2F><>ValuesAfterColl<6C><6C><EFBFBD>н<EFBFBD><D0BD>յ<EFBFBD>λ<EFBFBD>ڳ<EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
ucComMF522Buf [ 0 ] = 0x93; //<2F><>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD>
|
|
||||||
ucComMF522Buf [ 1 ] = 0x20;
|
|
||||||
|
|
||||||
cStatus = PcdComMF522 ( PCD_TRANSCEIVE, ucComMF522Buf, 2, ucComMF522Buf, & ulLen);//<2F>뿨Ƭͨ<C6AC><CDA8>
|
|
||||||
|
|
||||||
if ( cStatus == MI_OK) //ͨ<>ųɹ<C5B3>
|
|
||||||
{
|
|
||||||
for ( uc = 0; uc < 4; uc ++ )
|
|
||||||
{
|
|
||||||
* ( pSnr + uc ) = ucComMF522Buf [ uc ]; //<2F><><EFBFBD><EFBFBD>UID
|
|
||||||
ucSnr_check ^= ucComMF522Buf [ uc ];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ucSnr_check != ucComMF522Buf [ uc ] )
|
|
||||||
{
|
|
||||||
cStatus = MI_ERR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SetBitMask ( CollReg, 0x80 );
|
|
||||||
|
|
||||||
return cStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CalulateCRC
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>RC522<32><32><EFBFBD><EFBFBD>CRC16
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><>pIndata<74><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CRC16<31><36><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
* ucLen<65><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CRC16<31><36><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽڳ<D6BD><DAB3><EFBFBD>
|
|
||||||
* pOutData<74><61><EFBFBD><EFBFBD><EFBFBD>ż<EFBFBD><C5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD>ַ
|
|
||||||
* <20><><EFBFBD><EFBFBD> : <20><>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
void CalulateCRC ( uint8_t * pIndata, uint8_t ucLen, uint8_t * pOutData )
|
|
||||||
{
|
|
||||||
uint8_t uc, ucN;
|
|
||||||
|
|
||||||
ClearBitMask(DivIrqReg,0x04);
|
|
||||||
WriteRawRC(CommandReg,PCD_IDLE);
|
|
||||||
SetBitMask(FIFOLevelReg,0x80);
|
|
||||||
|
|
||||||
for ( uc = 0; uc < ucLen; uc ++)
|
|
||||||
WriteRawRC ( FIFODataReg, * ( pIndata + uc ) );
|
|
||||||
|
|
||||||
WriteRawRC ( CommandReg, PCD_CALCCRC );
|
|
||||||
|
|
||||||
uc = 0xFF;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
ucN = ReadRawRC ( DivIrqReg );
|
|
||||||
uc --;
|
|
||||||
} while ( ( uc != 0 ) && ! ( ucN & 0x04 ) );
|
|
||||||
|
|
||||||
pOutData [ 0 ] = ReadRawRC ( CRCResultRegL );
|
|
||||||
pOutData [ 1 ] = ReadRawRC ( CRCResultRegM );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PcdSelect
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>Ƭ
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><>pSnr<6E><72><EFBFBD><EFBFBD>Ƭ<EFBFBD><C6AC><EFBFBD>кţ<D0BA>4<EFBFBD>ֽ<EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> : ״ֵ̬
|
|
||||||
* = MI_OK<4F><4B><EFBFBD>ɹ<EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
char PcdSelect ( uint8_t * pSnr )
|
|
||||||
{
|
|
||||||
char ucN;
|
|
||||||
uint8_t uc;
|
|
||||||
uint8_t ucComMF522Buf [ MAXRLEN ];
|
|
||||||
uint32_t ulLen;
|
|
||||||
|
|
||||||
ucComMF522Buf [ 0 ] = PICC_ANTICOLL1;
|
|
||||||
ucComMF522Buf [ 1 ] = 0x70;
|
|
||||||
ucComMF522Buf [ 6 ] = 0;
|
|
||||||
|
|
||||||
for ( uc = 0; uc < 4; uc ++ )
|
|
||||||
{
|
|
||||||
ucComMF522Buf [ uc + 2 ] = * ( pSnr + uc );
|
|
||||||
ucComMF522Buf [ 6 ] ^= * ( pSnr + uc );
|
|
||||||
}
|
|
||||||
|
|
||||||
CalulateCRC ( ucComMF522Buf, 7, & ucComMF522Buf [ 7 ] );
|
|
||||||
ClearBitMask ( Status2Reg, 0x08 );
|
|
||||||
|
|
||||||
ucN = PcdComMF522 ( PCD_TRANSCEIVE, ucComMF522Buf, 9, ucComMF522Buf, & ulLen );
|
|
||||||
|
|
||||||
if ( ( ucN == MI_OK ) && ( ulLen == 0x18 ) )
|
|
||||||
ucN = MI_OK;
|
|
||||||
else
|
|
||||||
ucN = MI_ERR;
|
|
||||||
|
|
||||||
return ucN;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PcdAuthState
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>֤<EFBFBD><D6A4>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><>ucAuth_mode<64><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤ģʽ
|
|
||||||
* = 0x60<36><30><EFBFBD><EFBFBD>֤A<D6A4><41>Կ
|
|
||||||
* = 0x61<36><31><EFBFBD><EFBFBD>֤B<D6A4><42>Կ
|
|
||||||
* uint8_t ucAddr<64><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
||||||
* pKey<65><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
* pSnr<6E><72><EFBFBD><EFBFBD>Ƭ<EFBFBD><C6AC><EFBFBD>кţ<D0BA>4<EFBFBD>ֽ<EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> : ״ֵ̬
|
|
||||||
* = MI_OK<4F><4B><EFBFBD>ɹ<EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
char PcdAuthState ( uint8_t ucAuth_mode, uint8_t ucAddr, uint8_t * pKey, uint8_t * pSnr )
|
|
||||||
{
|
|
||||||
char cStatus;
|
|
||||||
uint8_t uc, ucComMF522Buf [ MAXRLEN ];
|
|
||||||
uint32_t ulLen;
|
|
||||||
|
|
||||||
ucComMF522Buf [ 0 ] = ucAuth_mode;
|
|
||||||
ucComMF522Buf [ 1 ] = ucAddr;
|
|
||||||
|
|
||||||
for ( uc = 0; uc < 6; uc ++ )
|
|
||||||
ucComMF522Buf [ uc + 2 ] = * ( pKey + uc );
|
|
||||||
|
|
||||||
for ( uc = 0; uc < 6; uc ++ )
|
|
||||||
ucComMF522Buf [ uc + 8 ] = * ( pSnr + uc );
|
|
||||||
|
|
||||||
cStatus = PcdComMF522 ( PCD_AUTHENT, ucComMF522Buf, 12, ucComMF522Buf, & ulLen );
|
|
||||||
|
|
||||||
if ( ( cStatus != MI_OK ) || ( ! ( ReadRawRC ( Status2Reg ) & 0x08 ) ) )
|
|
||||||
cStatus = MI_ERR;
|
|
||||||
|
|
||||||
return cStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PcdWrite
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><>д<EFBFBD><D0B4><EFBFBD>ݵ<EFBFBD>M1<4D><31>һ<EFBFBD><D2BB>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><>uint8_t ucAddr<64><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
||||||
* pData<74><61>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>16<31>ֽ<EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> : ״ֵ̬
|
|
||||||
* = MI_OK<4F><4B><EFBFBD>ɹ<EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
char PcdWrite ( uint8_t ucAddr, uint8_t * pData )
|
|
||||||
{
|
|
||||||
char cStatus;
|
|
||||||
uint8_t uc, ucComMF522Buf [ MAXRLEN ];
|
|
||||||
uint32_t ulLen;
|
|
||||||
|
|
||||||
ucComMF522Buf [ 0 ] = PICC_WRITE;
|
|
||||||
ucComMF522Buf [ 1 ] = ucAddr;
|
|
||||||
|
|
||||||
CalulateCRC ( ucComMF522Buf, 2, & ucComMF522Buf [ 2 ] );
|
|
||||||
|
|
||||||
cStatus = PcdComMF522 ( PCD_TRANSCEIVE, ucComMF522Buf, 4, ucComMF522Buf, & ulLen );
|
|
||||||
|
|
||||||
if ( ( cStatus != MI_OK ) || ( ulLen != 4 ) || ( ( ucComMF522Buf [ 0 ] & 0x0F ) != 0x0A ) )
|
|
||||||
cStatus = MI_ERR;
|
|
||||||
|
|
||||||
if ( cStatus == MI_OK )
|
|
||||||
{
|
|
||||||
//memcpy(ucComMF522Buf, pData, 16);
|
|
||||||
for ( uc = 0; uc < 16; uc ++ )
|
|
||||||
ucComMF522Buf [ uc ] = * ( pData + uc );
|
|
||||||
|
|
||||||
CalulateCRC ( ucComMF522Buf, 16, & ucComMF522Buf [ 16 ] );
|
|
||||||
|
|
||||||
cStatus = PcdComMF522 ( PCD_TRANSCEIVE, ucComMF522Buf, 18, ucComMF522Buf, & ulLen );
|
|
||||||
|
|
||||||
if ( ( cStatus != MI_OK ) || ( ulLen != 4 ) || ( ( ucComMF522Buf [ 0 ] & 0x0F ) != 0x0A ) )
|
|
||||||
cStatus = MI_ERR;
|
|
||||||
}
|
|
||||||
return cStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PcdRead
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ȡM1<4D><31>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><>uint8_t ucAddr<64><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
||||||
* pData<74><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>16<31>ֽ<EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> : ״ֵ̬
|
|
||||||
* = MI_OK<4F><4B><EFBFBD>ɹ<EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
char PcdRead ( uint8_t ucAddr, uint8_t * pData )
|
|
||||||
{
|
|
||||||
char cStatus;
|
|
||||||
uint8_t uc, ucComMF522Buf [ MAXRLEN ];
|
|
||||||
uint32_t ulLen;
|
|
||||||
|
|
||||||
ucComMF522Buf [ 0 ] = PICC_READ;
|
|
||||||
ucComMF522Buf [ 1 ] = ucAddr;
|
|
||||||
|
|
||||||
CalulateCRC ( ucComMF522Buf, 2, & ucComMF522Buf [ 2 ] );
|
|
||||||
cStatus = PcdComMF522 ( PCD_TRANSCEIVE, ucComMF522Buf, 4, ucComMF522Buf, & ulLen );
|
|
||||||
|
|
||||||
if ( ( cStatus == MI_OK ) && ( ulLen == 0x90 ) )
|
|
||||||
{
|
|
||||||
for ( uc = 0; uc < 16; uc ++ )
|
|
||||||
* ( pData + uc ) = ucComMF522Buf [ uc ];
|
|
||||||
}else
|
|
||||||
cStatus = MI_ERR;
|
|
||||||
return cStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PcdHalt
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ƭ<EEBFA8><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> : ״ֵ̬
|
|
||||||
* = MI_OK<4F><4B><EFBFBD>ɹ<EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
char PcdHalt( void )
|
|
||||||
{
|
|
||||||
uint8_t ucComMF522Buf [ MAXRLEN ];
|
|
||||||
uint32_t ulLen;
|
|
||||||
|
|
||||||
ucComMF522Buf [ 0 ] = PICC_HALT;
|
|
||||||
ucComMF522Buf [ 1 ] = 0;
|
|
||||||
|
|
||||||
CalulateCRC ( ucComMF522Buf, 2, & ucComMF522Buf [ 2 ] );
|
|
||||||
PcdComMF522 ( PCD_TRANSCEIVE, ucComMF522Buf, 4, ucComMF522Buf, & ulLen );
|
|
||||||
|
|
||||||
return MI_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IC_CMT ( uint8_t * UID, uint8_t * KEY, uint8_t RW, uint8_t * Dat )
|
|
||||||
{
|
|
||||||
uint8_t ucArray_ID [ 4 ] = { 0 };//<2F>Ⱥ<EFBFBD><C8BA><EFBFBD><EFBFBD><EFBFBD>IC<49><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͺ<EFBFBD>UID(IC<49><43><EFBFBD><EFBFBD><EFBFBD>к<EFBFBD>)
|
|
||||||
|
|
||||||
PcdRequest ( 0x52, ucArray_ID );//Ѱ<><D1B0>
|
|
||||||
PcdAnticoll ( ucArray_ID );//<2F><><EFBFBD><EFBFBD>ײ
|
|
||||||
PcdSelect ( UID );//ѡ<><D1A1><EFBFBD><EFBFBD>
|
|
||||||
PcdAuthState ( 0x60, 0x10, KEY, UID );//У<><D0A3>
|
|
||||||
|
|
||||||
if ( RW )//<2F><>дѡ<D0B4><D1A1><EFBFBD><EFBFBD>1<EFBFBD>Ƕ<EFBFBD><C7B6><EFBFBD>0<EFBFBD><30>д
|
|
||||||
PcdRead ( 0x10, Dat );
|
|
||||||
else
|
|
||||||
PcdWrite ( 0x10, Dat );
|
|
||||||
|
|
||||||
PcdHalt ();
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,175 +0,0 @@
|
|||||||
/****************************************Copyright (c)****************************************************
|
|
||||||
**
|
|
||||||
** File name: light.h
|
|
||||||
** Created by: XiaoYi
|
|
||||||
** Created date: 2020-10-16
|
|
||||||
** Version: v1.0
|
|
||||||
** Descriptions: The original
|
|
||||||
** Link address: https://blog.csdn.net/weixin_45006076
|
|
||||||
**
|
|
||||||
*********************************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __RC522_H__
|
|
||||||
#define __RC522_H__
|
|
||||||
|
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
//MF522<32><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#define PCD_IDLE 0x00 //ȡ<><C8A1><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
|
||||||
#define PCD_AUTHENT 0x0E //<2F><>֤<EFBFBD><D6A4>Կ
|
|
||||||
#define PCD_RECEIVE 0x08 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
#define PCD_TRANSMIT 0x04 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
#define PCD_TRANSCEIVE 0x0C //<2F><><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
#define PCD_RESETPHASE 0x0F //<2F><>λ
|
|
||||||
#define PCD_CALCCRC 0x03 //CRC<52><43><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
//Mifare_One<6E><65>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#define PICC_REQIDL 0x26 //Ѱ<><D1B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
|
||||||
#define PICC_REQALL 0x52 //Ѱ<><D1B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>
|
|
||||||
#define PICC_ANTICOLL1 0x93 //<2F><><EFBFBD><EFBFBD>ײ
|
|
||||||
#define PICC_ANTICOLL2 0x95 //<2F><><EFBFBD><EFBFBD>ײ
|
|
||||||
#define PICC_AUTHENT1A 0x60 //<2F><>֤A<D6A4><41>Կ
|
|
||||||
#define PICC_AUTHENT1B 0x61 //<2F><>֤B<D6A4><42>Կ
|
|
||||||
#define PICC_READ 0x30 //<2F><><EFBFBD><EFBFBD>
|
|
||||||
#define PICC_WRITE 0xA0 //д<><D0B4>
|
|
||||||
#define PICC_DECREMENT 0xC0 //<2F>ۿ<EFBFBD>
|
|
||||||
#define PICC_INCREMENT 0xC1 //<2F><>ֵ
|
|
||||||
#define PICC_RESTORE 0xC2 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
#define PICC_TRANSFER 0xB0 //<2F><><EFBFBD>滺<EFBFBD><E6BBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
#define PICC_HALT 0x50 //<2F><><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
//MF522 FIFO<46><4F><EFBFBD>ȶ<EFBFBD><C8B6><EFBFBD>
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#define DEF_FIFO_LENGTH 64 //FIFO size=64byte
|
|
||||||
#define MAXRLEN 18
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
//MF522<32>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
// PAGE 0
|
|
||||||
#define RFU00 0x00
|
|
||||||
#define CommandReg 0x01
|
|
||||||
#define ComIEnReg 0x02
|
|
||||||
#define DivlEnReg 0x03
|
|
||||||
#define ComIrqReg 0x04
|
|
||||||
#define DivIrqReg 0x05
|
|
||||||
#define ErrorReg 0x06
|
|
||||||
#define Status1Reg 0x07
|
|
||||||
#define Status2Reg 0x08
|
|
||||||
#define FIFODataReg 0x09
|
|
||||||
#define FIFOLevelReg 0x0A
|
|
||||||
#define WaterLevelReg 0x0B
|
|
||||||
#define ControlReg 0x0C
|
|
||||||
#define BitFramingReg 0x0D
|
|
||||||
#define CollReg 0x0E
|
|
||||||
#define RFU0F 0x0F
|
|
||||||
// PAGE 1
|
|
||||||
#define RFU10 0x10
|
|
||||||
#define ModeReg 0x11
|
|
||||||
#define TxModeReg 0x12
|
|
||||||
#define RxModeReg 0x13
|
|
||||||
#define TxControlReg 0x14
|
|
||||||
#define TxAutoReg 0x15
|
|
||||||
#define TxSelReg 0x16
|
|
||||||
#define RxSelReg 0x17
|
|
||||||
#define RxThresholdReg 0x18
|
|
||||||
#define DemodReg 0x19
|
|
||||||
#define RFU1A 0x1A
|
|
||||||
#define RFU1B 0x1B
|
|
||||||
#define MifareReg 0x1C
|
|
||||||
#define RFU1D 0x1D
|
|
||||||
#define RFU1E 0x1E
|
|
||||||
#define SerialSpeedReg 0x1F
|
|
||||||
// PAGE 2
|
|
||||||
#define RFU20 0x20
|
|
||||||
#define CRCResultRegM 0x21
|
|
||||||
#define CRCResultRegL 0x22
|
|
||||||
#define RFU23 0x23
|
|
||||||
#define ModWidthReg 0x24
|
|
||||||
#define RFU25 0x25
|
|
||||||
#define RFCfgReg 0x26
|
|
||||||
#define GsNReg 0x27
|
|
||||||
#define CWGsCfgReg 0x28
|
|
||||||
#define ModGsCfgReg 0x29
|
|
||||||
#define TModeReg 0x2A
|
|
||||||
#define TPrescalerReg 0x2B
|
|
||||||
#define TReloadRegH 0x2C
|
|
||||||
#define TReloadRegL 0x2D
|
|
||||||
#define TCounterValueRegH 0x2E
|
|
||||||
#define TCounterValueRegL 0x2F
|
|
||||||
// PAGE 3
|
|
||||||
#define RFU30 0x30
|
|
||||||
#define TestSel1Reg 0x31
|
|
||||||
#define TestSel2Reg 0x32
|
|
||||||
#define TestPinEnReg 0x33
|
|
||||||
#define TestPinValueReg 0x34
|
|
||||||
#define TestBusReg 0x35
|
|
||||||
#define AutoTestReg 0x36
|
|
||||||
#define VersionReg 0x37
|
|
||||||
#define AnalogTestReg 0x38
|
|
||||||
#define TestDAC1Reg 0x39
|
|
||||||
#define TestDAC2Reg 0x3A
|
|
||||||
#define TestADCReg 0x3B
|
|
||||||
#define RFU3C 0x3C
|
|
||||||
#define RFU3D 0x3D
|
|
||||||
#define RFU3E 0x3E
|
|
||||||
#define RFU3F 0x3F
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
//<2F><>MF522ͨѶʱ<D1B6><CAB1><EFBFBD>صĴ<D8B5><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
#define MI_OK 0x26
|
|
||||||
#define MI_NOTAGERR 0xcc
|
|
||||||
#define MI_ERR 0xbb
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/************************<2A>˿ں궨<DABA><EAB6A8>**********************************/
|
|
||||||
#define macRC522_GPIO_CS_PORT GPIOB
|
|
||||||
#define macRC522_GPIO_CS_PIN GPIO_PIN_12
|
|
||||||
|
|
||||||
#define macRC522_GPIO_RST_PORT GPIOB
|
|
||||||
#define macRC522_GPIO_RST_PIN GPIO_PIN_7
|
|
||||||
|
|
||||||
#define macRC522_GPIO_SCK_PORT GPIOB
|
|
||||||
#define macRC522_GPIO_SCK_PIN GPIO_PIN_13
|
|
||||||
|
|
||||||
#define macRC522_GPIO_MOSI_PORT GPIOB
|
|
||||||
#define macRC522_GPIO_MOSI_PIN GPIO_PIN_15
|
|
||||||
|
|
||||||
#define macRC522_GPIO_MISO_PORT GPIOB
|
|
||||||
#define macRC522_GPIO_MISO_PIN GPIO_PIN_14
|
|
||||||
/*********************************** RC522 <20><><EFBFBD><EFBFBD><EFBFBD>궨<EFBFBD><EAB6A8>*********************************************/
|
|
||||||
#define macRC522_CS_Enable() HAL_GPIO_WritePin ( macRC522_GPIO_CS_PORT, macRC522_GPIO_CS_PIN ,GPIO_PIN_RESET)
|
|
||||||
#define macRC522_CS_Disable() HAL_GPIO_WritePin ( macRC522_GPIO_CS_PORT, macRC522_GPIO_CS_PIN ,GPIO_PIN_SET)
|
|
||||||
|
|
||||||
#define macRC522_Reset_Enable() HAL_GPIO_WritePin( macRC522_GPIO_RST_PORT, macRC522_GPIO_RST_PIN,GPIO_PIN_RESET )
|
|
||||||
#define macRC522_Reset_Disable() HAL_GPIO_WritePin ( macRC522_GPIO_RST_PORT, macRC522_GPIO_RST_PIN,GPIO_PIN_SET)
|
|
||||||
|
|
||||||
#define macRC522_SCK_0() HAL_GPIO_WritePin( macRC522_GPIO_SCK_PORT, macRC522_GPIO_SCK_PIN,GPIO_PIN_RESET )
|
|
||||||
#define macRC522_SCK_1() HAL_GPIO_WritePin ( macRC522_GPIO_SCK_PORT, macRC522_GPIO_SCK_PIN,GPIO_PIN_SET )
|
|
||||||
|
|
||||||
#define macRC522_MOSI_0() HAL_GPIO_WritePin( macRC522_GPIO_MOSI_PORT, macRC522_GPIO_MOSI_PIN,GPIO_PIN_RESET )
|
|
||||||
#define macRC522_MOSI_1() HAL_GPIO_WritePin ( macRC522_GPIO_MOSI_PORT, macRC522_GPIO_MOSI_PIN,GPIO_PIN_SET )
|
|
||||||
|
|
||||||
#define macRC522_MISO_GET() HAL_GPIO_ReadPin ( macRC522_GPIO_MISO_PORT, macRC522_GPIO_MISO_PIN )
|
|
||||||
|
|
||||||
#define macRC522_DELAY() HAL_Delay(20)
|
|
||||||
|
|
||||||
#define Dummy_Byte 0xFF
|
|
||||||
|
|
||||||
|
|
||||||
void PcdReset ( void ); //<2F><>λ
|
|
||||||
void M500PcdConfigISOType ( uint8_t type ); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
|
||||||
char PcdRequest ( uint8_t req_code, uint8_t * pTagType ); //Ѱ<><D1B0>
|
|
||||||
char PcdAnticoll ( uint8_t * pSnr); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
char PcdAuthState ( uint8_t ucAuth_mode, uint8_t ucAddr, uint8_t * pKey, uint8_t * pSnr );//<2F><>֤<EFBFBD><D6A4>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD>
|
|
||||||
char PcdRead ( uint8_t ucAddr, uint8_t * pData ); //<2F><><EFBFBD><EFBFBD>
|
|
||||||
char PcdSelect ( uint8_t * pSnr ); //ѡ<><D1A1>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,196 +0,0 @@
|
|||||||
/****************************************Copyright (c)****************************************************
|
|
||||||
**
|
|
||||||
** File name: humi.c
|
|
||||||
** Created by: XiaoYi
|
|
||||||
** Created date: 2020-10-16
|
|
||||||
** Version: v1.0
|
|
||||||
** Descriptions: The original
|
|
||||||
** Link address: https://blog.csdn.net/weixin_45006076
|
|
||||||
**
|
|
||||||
*********************************************************************************************************/
|
|
||||||
|
|
||||||
#include "dht11.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* ˽<><CBBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD> --------------------------------------------------------------*/
|
|
||||||
/* ˽<>к궨<D0BA><EAB6A8> ----------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* ˽<>б<EFBFBD><D0B1><EFBFBD> ------------------------------------------------------------------*/
|
|
||||||
/* <20><>չ<EFBFBD><D5B9><EFBFBD><EFBFBD> ------------------------------------------------------------------*/
|
|
||||||
/* ˽<>к<EFBFBD><D0BA><EFBFBD>ԭ<EFBFBD><D4AD> --------------------------------------------------------------*/
|
|
||||||
static void DHT11_Mode_IPU(void);
|
|
||||||
static void DHT11_Mode_Out_PP(void);
|
|
||||||
static uint8_t dht11_readByte(void);
|
|
||||||
|
|
||||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> --------------------------------------------------------------------*/
|
|
||||||
/**
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
|
||||||
* <20><> <20><> ֵ: <20><>
|
|
||||||
* ˵ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
static void dht11_delay(uint16_t time)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
|
|
||||||
while(time)
|
|
||||||
{
|
|
||||||
for (i = 0; i < 10; i++)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
time--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: DHT11 <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
|
||||||
* <20><> <20><> ֵ: <20><>
|
|
||||||
* ˵ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
void dht11_init ( void )
|
|
||||||
{
|
|
||||||
DHT11_Dout_GPIO_CLK_ENABLE();
|
|
||||||
|
|
||||||
DHT11_Mode_Out_PP();
|
|
||||||
|
|
||||||
DHT11_Dout_HIGH(); // <20><><EFBFBD><EFBFBD>GPIO
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ʹDHT11-DATA<54><41><EFBFBD>ű<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
|
||||||
* <20><> <20><> ֵ: <20><>
|
|
||||||
* ˵ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
static void DHT11_Mode_IPU(void)
|
|
||||||
{
|
|
||||||
GPIO_InitTypeDef GPIO_InitStruct;
|
|
||||||
|
|
||||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>蹦<EFBFBD><E8B9A6>GPIO<49><4F><EFBFBD><EFBFBD> */
|
|
||||||
GPIO_InitStruct.Pin = DHT11_Dout_PIN;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|
||||||
HAL_GPIO_Init(DHT11_Dout_PORT, &GPIO_InitStruct);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ʹDHT11-DATA<54><41><EFBFBD>ű<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
|
||||||
* <20><> <20><> ֵ: <20><>
|
|
||||||
* ˵ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
static void DHT11_Mode_Out_PP(void)
|
|
||||||
{
|
|
||||||
GPIO_InitTypeDef GPIO_InitStruct;
|
|
||||||
|
|
||||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>蹦<EFBFBD><E8B9A6>GPIO<49><4F><EFBFBD><EFBFBD> */
|
|
||||||
GPIO_InitStruct.Pin = DHT11_Dout_PIN;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
|
||||||
HAL_GPIO_Init(DHT11_Dout_PORT, &GPIO_InitStruct);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>DHT11<31><31>ȡһ<C8A1><D2BB><EFBFBD>ֽڣ<D6BD>MSB<53><42><EFBFBD><EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
|
|
||||||
* <20><> <20><> ֵ: <20><>
|
|
||||||
* ˵ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
static uint8_t dht11_readByte ( void )
|
|
||||||
{
|
|
||||||
uint8_t i, temp=0;
|
|
||||||
|
|
||||||
for(i=0;i<8;i++)
|
|
||||||
{
|
|
||||||
/*ÿbit<69><74>50us<75>͵<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD>ÿ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ѯֱ<D1AF><D6B1><EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD><EFBFBD><EFBFBD> <20><>50us <20>͵<EFBFBD>ƽ <20><><EFBFBD><EFBFBD>*/
|
|
||||||
while(DHT11_Data_IN()==GPIO_PIN_RESET);
|
|
||||||
|
|
||||||
/*DHT11 <20><>26~28us<75>ĸߵ<C4B8>ƽ<EFBFBD><C6BD>ʾ<EFBFBD><CABE>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>70us<75>ߵ<EFBFBD>ƽ<EFBFBD><C6BD>ʾ<EFBFBD><CABE>1<EFBFBD><31><EFBFBD><EFBFBD>
|
|
||||||
*ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> x us<75><73><EFBFBD>ĵ<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״ <20><>x <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
|
|
||||||
*/
|
|
||||||
dht11_delay(40); //<2F><>ʱx us <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>伴<EFBFBD><E4BCB4>
|
|
||||||
|
|
||||||
if(DHT11_Data_IN()==GPIO_PIN_SET)/* x us<75><73><EFBFBD><EFBFBD>Ϊ<EFBFBD>ߵ<EFBFBD>ƽ<EFBFBD><C6BD>ʾ<EFBFBD><CABE><EFBFBD>ݡ<EFBFBD>1<EFBFBD><31> */
|
|
||||||
{
|
|
||||||
/* <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD>ĸߵ<C4B8>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD> */
|
|
||||||
while(DHT11_Data_IN()==GPIO_PIN_SET);
|
|
||||||
|
|
||||||
temp|=(uint8_t)(0x01<<(7-i)); //<2F>ѵ<EFBFBD>7-iλ<69><CEBB>1<EFBFBD><31>MSB<53><42><EFBFBD><EFBFBD>
|
|
||||||
}
|
|
||||||
else // x us<75><73>Ϊ<EFBFBD>͵<EFBFBD>ƽ<EFBFBD><C6BD>ʾ<EFBFBD><CABE><EFBFBD>ݡ<EFBFBD>0<EFBFBD><30>
|
|
||||||
{
|
|
||||||
temp&=(uint8_t)~(0x01<<(7-i)); //<2F>ѵ<EFBFBD>7-iλ<69><CEBB>0<EFBFBD><30>MSB<53><42><EFBFBD><EFBFBD>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>Ϊ40bit<69><74><EFBFBD><EFBFBD>λ<EFBFBD>ȳ<EFBFBD>
|
|
||||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: DHT11_Data:DHT11<31><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
* <20><> <20><> ֵ: ERROR<4F><52> <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|
||||||
* SUCCESS<53><53><EFBFBD><EFBFBD>ȡ<EFBFBD>ɹ<EFBFBD>
|
|
||||||
* ˵ <20><><EFBFBD><EFBFBD>8bit ʪ<><CAAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD> + 8bit ʪ<><CAAA>С<EFBFBD><D0A1> + 8bit <20>¶<EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD> + 8bit <20>¶<EFBFBD>С<EFBFBD><D0A1> + 8bit У<><D0A3><EFBFBD><EFBFBD>
|
|
||||||
*/
|
|
||||||
uint8_t dht11_get_tempHumi(DHT11_Data_TypeDef *DHT11_Data)
|
|
||||||
{
|
|
||||||
uint8_t temp;
|
|
||||||
uint16_t humi_temp;
|
|
||||||
|
|
||||||
/*<2A><><EFBFBD><EFBFBD>ģʽ*/
|
|
||||||
DHT11_Mode_Out_PP();
|
|
||||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
||||||
DHT11_Dout_LOW();
|
|
||||||
/*<2A><>ʱ18ms*/
|
|
||||||
delay_ms(18);
|
|
||||||
|
|
||||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ30us*/
|
|
||||||
DHT11_Dout_HIGH();
|
|
||||||
|
|
||||||
dht11_delay(30); //<2F><>ʱ30us
|
|
||||||
|
|
||||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD> <20>жϴӻ<CFB4><D3BB><EFBFBD>Ӧ<EFBFBD>ź<EFBFBD>*/
|
|
||||||
DHT11_Mode_IPU();
|
|
||||||
|
|
||||||
/*<2A>жϴӻ<CFB4><D3BB>Ƿ<EFBFBD><C7B7>е͵<D0B5>ƽ<EFBFBD><C6BD>Ӧ<EFBFBD>ź<EFBFBD> <20>粻<EFBFBD><E7B2BB>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
||||||
if(DHT11_Data_IN()==GPIO_PIN_RESET)
|
|
||||||
{
|
|
||||||
/*<2A><>ѯֱ<D1AF><D6B1><EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD><EFBFBD><EFBFBD> <20><>80us <20>͵<EFBFBD>ƽ <20><>Ӧ<EFBFBD>źŽ<C5BA><C5BD><EFBFBD>*/
|
|
||||||
while(DHT11_Data_IN()==GPIO_PIN_RESET);
|
|
||||||
|
|
||||||
/*<2A><>ѯֱ<D1AF><D6B1><EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 80us <20>ߵ<EFBFBD>ƽ <20><><EFBFBD><EFBFBD><EFBFBD>źŽ<C5BA><C5BD><EFBFBD>*/
|
|
||||||
while(DHT11_Data_IN()==GPIO_PIN_SET);
|
|
||||||
|
|
||||||
/*<2A><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
||||||
DHT11_Data->humi_high8bit= dht11_readByte();
|
|
||||||
DHT11_Data->humi_low8bit = dht11_readByte();
|
|
||||||
DHT11_Data->temp_high8bit= dht11_readByte();
|
|
||||||
DHT11_Data->temp_low8bit = dht11_readByte();
|
|
||||||
DHT11_Data->check_sum = dht11_readByte();
|
|
||||||
|
|
||||||
/*<2A><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ÿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ģʽ*/
|
|
||||||
DHT11_Mode_Out_PP();
|
|
||||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
||||||
DHT11_Dout_HIGH();
|
|
||||||
|
|
||||||
/* <20><><EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD>д<EFBFBD><D0B4><EFBFBD> */
|
|
||||||
humi_temp=DHT11_Data->humi_high8bit*100+DHT11_Data->humi_low8bit;
|
|
||||||
DHT11_Data->humidity =(float)humi_temp/100;
|
|
||||||
|
|
||||||
humi_temp=DHT11_Data->temp_high8bit*100+DHT11_Data->temp_low8bit;
|
|
||||||
DHT11_Data->temperature=(float)humi_temp/100;
|
|
||||||
|
|
||||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ȷ*/
|
|
||||||
temp = DHT11_Data->humi_high8bit + DHT11_Data->humi_low8bit +
|
|
||||||
DHT11_Data->temp_high8bit+ DHT11_Data->temp_low8bit;
|
|
||||||
if(DHT11_Data->check_sum==temp)
|
|
||||||
{
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return ERROR;
|
|
||||||
}else
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
/****************************************Copyright (c)****************************************************
|
|
||||||
**
|
|
||||||
** File name: dht11.h
|
|
||||||
** Created by: xxx
|
|
||||||
** Created date: 2020-10-16
|
|
||||||
** Version: v1.0
|
|
||||||
** Descriptions: The original
|
|
||||||
**
|
|
||||||
*********************************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __DHT11_H__
|
|
||||||
#define __DHT11_H__
|
|
||||||
|
|
||||||
#include "main.h"
|
|
||||||
/* <20><><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD> ------------------------------------------------------------------*/
|
|
||||||
/************************ DHT11 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD>******************************/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint8_t humi_high8bit; //ԭʼ<D4AD><CABC><EFBFBD>ݣ<EFBFBD>ʪ<EFBFBD>ȸ<EFBFBD>8λ
|
|
||||||
uint8_t humi_low8bit; //ԭʼ<D4AD><CABC><EFBFBD>ݣ<EFBFBD>ʪ<EFBFBD>ȵ<EFBFBD>8λ
|
|
||||||
uint8_t temp_high8bit; //ԭʼ<D4AD><CABC><EFBFBD>ݣ<EFBFBD><DDA3>¶ȸ<C2B6>8λ
|
|
||||||
uint8_t temp_low8bit; //ԭʼ<D4AD><CABC><EFBFBD>ݣ<EFBFBD><DDA3>¶ȸ<C2B6>8λ
|
|
||||||
uint8_t check_sum; //У<><D0A3><EFBFBD><EFBFBD>
|
|
||||||
float humidity; //ʵ<><CAB5>ʪ<EFBFBD><CAAA>
|
|
||||||
float temperature; //ʵ<><CAB5><EFBFBD>¶<EFBFBD>
|
|
||||||
} DHT11_Data_TypeDef;
|
|
||||||
|
|
||||||
/* <20>궨<EFBFBD><EAB6A8> -------------------------------------------------------------------*/
|
|
||||||
/*********************** DHT11 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD> **************************/
|
|
||||||
#define DHT11_Dout_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
|
||||||
#define DHT11_Dout_PORT GPIOB
|
|
||||||
#define DHT11_Dout_PIN GPIO_PIN_5
|
|
||||||
|
|
||||||
/*********************** DHT11 <20><><EFBFBD><EFBFBD><EFBFBD>궨<EFBFBD><EAB6A8> ****************************/
|
|
||||||
#define DHT11_Dout_LOW() HAL_GPIO_WritePin(DHT11_Dout_PORT,DHT11_Dout_PIN,GPIO_PIN_RESET)
|
|
||||||
#define DHT11_Dout_HIGH() HAL_GPIO_WritePin(DHT11_Dout_PORT,DHT11_Dout_PIN,GPIO_PIN_SET)
|
|
||||||
#define DHT11_Data_IN() HAL_GPIO_ReadPin(DHT11_Dout_PORT,DHT11_Dout_PIN)
|
|
||||||
|
|
||||||
/* <20><>չ<EFBFBD><D5B9><EFBFBD><EFBFBD> ------------------------------------------------------------------*/
|
|
||||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ------------------------------------------------------------------*/
|
|
||||||
void dht11_init( void );
|
|
||||||
uint8_t dht11_get_tempHumi(DHT11_Data_TypeDef * DHT11_Data);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
/****************************************Copyright (c)****************************************************
|
|
||||||
**
|
|
||||||
** File name: humi.c
|
|
||||||
** Created by: Brown Lee
|
|
||||||
** Created date: 2020-10-16
|
|
||||||
** Version: v1.0
|
|
||||||
** Descriptions: The original
|
|
||||||
** Link address: https://blog.csdn.net/weixin_45006076
|
|
||||||
**
|
|
||||||
*********************************************************************************************************/
|
|
||||||
|
|
||||||
#include "flash.h"
|
|
||||||
|
|
||||||
//<2F><>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>ʼ<EFBFBD><CABC>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
void FLASH_ReadMoreData(uint32_t startAddress,uint16_t *readData,uint16_t countToRead)
|
|
||||||
{
|
|
||||||
uint16_t dataIndex;
|
|
||||||
for(dataIndex=0;dataIndex<countToRead;dataIndex++)
|
|
||||||
{
|
|
||||||
readData[dataIndex]=FLASH_ReadHalfWord(startAddress+dataIndex*2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//<2F><>ȡָ<C8A1><D6B8><EFBFBD><EFBFBD>ַ<EFBFBD>İ<EFBFBD><C4B0><EFBFBD>(16λ<36><CEBB><EFBFBD><EFBFBD>)
|
|
||||||
uint16_t FLASH_ReadHalfWord(uint32_t address)
|
|
||||||
{
|
|
||||||
return *(__IO uint16_t*)address;
|
|
||||||
}
|
|
||||||
|
|
||||||
//<2F><>ȡָ<C8A1><D6B8><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>ȫ<EFBFBD><C8AB>(32λ<32><CEBB><EFBFBD><EFBFBD>)
|
|
||||||
uint32_t FLASH_ReadWord(uint32_t address)
|
|
||||||
{
|
|
||||||
uint32_t temp1,temp2;
|
|
||||||
temp1=*(__IO uint16_t*)address;
|
|
||||||
temp2=*(__IO uint16_t*)(address+2);
|
|
||||||
return (temp2<<16)+temp1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//<2F><>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>ʼд<CABC><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
void FLASH_WriteMoreData(uint32_t startAddress, uint16_t *writeData, uint16_t countToWrite)
|
|
||||||
{
|
|
||||||
uint32_t dataIndex;
|
|
||||||
FLASH_EraseInitTypeDef User_Flash; //<2F><><EFBFBD><EFBFBD> FLASH_EraseInitTypeDef <20>ṹ<EFBFBD><E1B9B9>Ϊ User_Flash
|
|
||||||
|
|
||||||
if(startAddress < FLASH_BASE || ((startAddress+countToWrite * 2) >= (FLASH_BASE + 1024 * FLASH_SIZE)))
|
|
||||||
{
|
|
||||||
return;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>ַ
|
|
||||||
}
|
|
||||||
HAL_FLASH_Unlock(); //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
|
|
||||||
// offsetAddress=startAddress-FLASH_BASE; //<2F><><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5>0X08000000<30><30><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>ƫ<EFBFBD>Ƶ<EFBFBD>ַ
|
|
||||||
// sectorPosition=offsetAddress/FLASH_SIZE; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>STM32F103VET6Ϊ0~255
|
|
||||||
//
|
|
||||||
// sectorStartAddress=sectorPosition*SECTOR_SIZE+FLASH_BASE; //<2F><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
||||||
|
|
||||||
HAL_FLASH_Unlock(); //<2F><><EFBFBD><EFBFBD>Flash
|
|
||||||
|
|
||||||
User_Flash.TypeErase = FLASH_TYPEERASE_PAGES; //<2F><><EFBFBD><EFBFBD>Flashִ<68><D6B4>ҳ<EFBFBD><D2B3>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
User_Flash.PageAddress = startAddress; //<2F><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ
|
|
||||||
User_Flash.NbPages = 1; //˵<><CBB5>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Min_Data = 1<><31>Max_Data =(<28><><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>-<2D><>ʼҳ<CABC><D2B3>ֵ)֮<><D6AE><EFBFBD><EFBFBD>ֵ
|
|
||||||
|
|
||||||
uint32_t PageError = 0; //<2F><><EFBFBD><EFBFBD>PageError,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ᱻ<EFBFBD><E1B1BB><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FLASH<53><48>ַ
|
|
||||||
HAL_FLASHEx_Erase(&User_Flash, &PageError); //<2F><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
for(dataIndex=0;dataIndex<countToWrite;dataIndex++)
|
|
||||||
{
|
|
||||||
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,startAddress+dataIndex*2,writeData[dataIndex]);
|
|
||||||
}
|
|
||||||
|
|
||||||
HAL_FLASH_Lock();//<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/****************************************Copyright (c)****************************************************
|
|
||||||
**
|
|
||||||
** File name: flash.h
|
|
||||||
** Created by: XiaoYi
|
|
||||||
** Created date: 2020-10-16
|
|
||||||
** Version: v1.0
|
|
||||||
** Descriptions: The original
|
|
||||||
** Link address: https://blog.csdn.net/weixin_45006076
|
|
||||||
**
|
|
||||||
*********************************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __FLASH_H__
|
|
||||||
#define __FLASH_H__
|
|
||||||
|
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
#define FLASH_WRITE_START_ADDR 0x0800FC00 //<2F><><EFBFBD><EFBFBD>1K<31><4B><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
#define FLASH_SIZE 64 //<2F><>ѡMCU<43><55>FLASH<53><48><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С(<28><>λΪK)
|
|
||||||
|
|
||||||
#if FLASH_SIZE < 256
|
|
||||||
#define SECTOR_SIZE 1024 //<2F>ֽ<EFBFBD>
|
|
||||||
#else
|
|
||||||
#define SECTOR_SIZE 2048 //<2F>ֽ<EFBFBD>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
uint16_t FLASH_ReadHalfWord(uint32_t address);
|
|
||||||
|
|
||||||
void FLASH_ReadMoreData(uint32_t startAddress,uint16_t *readData,uint16_t countToRead);
|
|
||||||
|
|
||||||
void FLASH_WriteMoreData(uint32_t startAddress,uint16_t *writeData,uint16_t countToWrite);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,124 +0,0 @@
|
|||||||
/****************************************Copyright (c)****************************************************
|
|
||||||
**
|
|
||||||
** File name: humi.c
|
|
||||||
** Created by: XiaoYi
|
|
||||||
** Created date: 2020-10-16
|
|
||||||
** Version: v1.0
|
|
||||||
** Descriptions: The original
|
|
||||||
** Link address: https://blog.csdn.net/weixin_45006076
|
|
||||||
**
|
|
||||||
*********************************************************************************************************/
|
|
||||||
|
|
||||||
#include "key_scan.h"
|
|
||||||
#include "multi_button.h"
|
|
||||||
#include "tim.h"
|
|
||||||
#include "gpio.h"
|
|
||||||
|
|
||||||
struct Button key1_mode;
|
|
||||||
struct Button key2_mode;
|
|
||||||
struct Button key3_mode;
|
|
||||||
|
|
||||||
uint8_t btn1_event_val;
|
|
||||||
uint8_t btn2_event_val;
|
|
||||||
uint8_t btn3_event_val;
|
|
||||||
|
|
||||||
key_status_t key_status = { 0x00 };
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* @brief ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
|
|
||||||
*
|
|
||||||
* @retval PIN's status
|
|
||||||
*******************************************************************************/
|
|
||||||
uint8_t read_key1_mode_pin()
|
|
||||||
{
|
|
||||||
return HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_4);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t read_key2_mode_pin()
|
|
||||||
{
|
|
||||||
return HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_3);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t read_key3_mode_pin()
|
|
||||||
{
|
|
||||||
return HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void key1_short_presssed_cb(void *param)
|
|
||||||
{
|
|
||||||
key_status.enable = 1;
|
|
||||||
key_status.key = KEY1;
|
|
||||||
key_status.type = KEY_SHORT_PRESS;
|
|
||||||
|
|
||||||
printf("key1_short_pressed\r\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void key1_long_presssed_cb(void *param)
|
|
||||||
{
|
|
||||||
// key_status.enable = 1;
|
|
||||||
// key_status.key = KEY1;
|
|
||||||
// key_status.type = KEY_LONG_PRESS;
|
|
||||||
printf("key1_long_pressed\r\n");
|
|
||||||
key_status.enable = 1;
|
|
||||||
key_status.key = KEY1;
|
|
||||||
key_status.type = KEY_LONG_PRESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
void key2_short_presssed_cb(void *param)
|
|
||||||
{
|
|
||||||
key_status.enable = 1;
|
|
||||||
key_status.key = KEY2;
|
|
||||||
key_status.type = KEY_SHORT_PRESS;
|
|
||||||
printf("key2_short_pressed\r\n");
|
|
||||||
}
|
|
||||||
void key3_short_presssed_cb(void *param)
|
|
||||||
{
|
|
||||||
key_status.enable = 1;
|
|
||||||
key_status.key = KEY3;
|
|
||||||
key_status.type = KEY_SHORT_PRESS;
|
|
||||||
printf("key3_short_pressed\r\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* @brief : key_scan
|
|
||||||
* Description : scan key's status
|
|
||||||
* Input : None
|
|
||||||
* Output : None
|
|
||||||
* Return : Return the clicked button
|
|
||||||
* Attention : None
|
|
||||||
*******************************************************************************/
|
|
||||||
void key_init(void)
|
|
||||||
{
|
|
||||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
||||||
/*Configure GPIO pins : PB3 PB4 */
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|
||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
button_init(&key1_mode, read_key1_mode_pin, 0);
|
|
||||||
button_attach(&key1_mode, SINGLE_CLICK, key1_short_presssed_cb);
|
|
||||||
button_attach(&key1_mode, LONG_PRESS_START, key1_long_presssed_cb);
|
|
||||||
button_start(&key1_mode);
|
|
||||||
|
|
||||||
button_init(&key2_mode, read_key2_mode_pin, 0);
|
|
||||||
button_attach(&key2_mode, PRESS_UP, key2_short_presssed_cb);
|
|
||||||
button_start(&key2_mode);
|
|
||||||
|
|
||||||
button_init(&key3_mode, read_key3_mode_pin, 0);
|
|
||||||
button_attach(&key3_mode, PRESS_UP, key3_short_presssed_cb);
|
|
||||||
button_start(&key3_mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief T = 5ms
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef* tim_baseHandle)
|
|
||||||
{
|
|
||||||
if(tim_baseHandle->Instance == htim2.Instance)
|
|
||||||
{
|
|
||||||
button_ticks();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
#ifndef __KEY_SCAN_H
|
|
||||||
#define __KEY_SCAN_H
|
|
||||||
|
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
#define KEY1 0x40
|
|
||||||
#define KEY2 0x41
|
|
||||||
#define KEY3 0x42
|
|
||||||
|
|
||||||
typedef enum{
|
|
||||||
KEY_NONE_PRESS,
|
|
||||||
KEY_SHORT_PRESS,
|
|
||||||
KEY_LONG_PRESS,
|
|
||||||
}key_event_e;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int enable; // ʹ<>ܣ<EFBFBD><DCA3>жϰ<D0B6><CFB0><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
int key; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
int type; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD>key_event_e<5F>ж<EFBFBD><D0B6><EFBFBD>
|
|
||||||
}key_status_t;
|
|
||||||
extern key_status_t key_status;
|
|
||||||
|
|
||||||
|
|
||||||
void key_init(void);
|
|
||||||
|
|
||||||
int key_scan(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
/****************************************Copyright (c)****************************************************
|
|
||||||
**
|
|
||||||
** File name: process.c
|
|
||||||
** Created by: XiaoYi
|
|
||||||
** Created date: 2020-10-16
|
|
||||||
** Version: v1.0
|
|
||||||
** Descriptions: The original
|
|
||||||
** Link address: https://blog.csdn.net/weixin_45006076
|
|
||||||
**
|
|
||||||
*********************************************************************************************************/
|
|
||||||
|
|
||||||
#include "sensor_light.h"
|
|
||||||
#include "gpio.h"
|
|
||||||
#include "adc.h"
|
|
||||||
|
|
||||||
uint16_t light_get_value(void)
|
|
||||||
{
|
|
||||||
// <20><><EFBFBD><EFBFBD>ADCת<43><D7AA>
|
|
||||||
HAL_ADC_Start(&hadc1);
|
|
||||||
// <20>ȴ<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ʱʱ<CAB1>䣬<EFBFBD><E4A3AC>λms
|
|
||||||
HAL_ADC_PollForConversion(&hadc1, 100);
|
|
||||||
return HAL_ADC_GetValue(&hadc1);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t light_get_average_value(uint8_t times) //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
{
|
|
||||||
uint32_t temp_val=0;
|
|
||||||
uint8_t t;
|
|
||||||
float temp_avrg=0;
|
|
||||||
|
|
||||||
for(t=0;t<times;t++) //LSENS_READ_TIMES<45><53>lsens.h<>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>Ĭ<EFBFBD><C4AC>10//
|
|
||||||
{
|
|
||||||
temp_val += light_get_value(); //<2F><>ȡADCֵ
|
|
||||||
delay_ms(5);
|
|
||||||
}
|
|
||||||
temp_val/=times; //<2F><><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD>ֵ//
|
|
||||||
if(temp_val>4000)
|
|
||||||
temp_val=4000; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>4000ʱ<30><CAB1>ǿ<EFBFBD><C7BF>ת<EFBFBD><D7AA>Ϊ4000//
|
|
||||||
|
|
||||||
return (100-(temp_val/40)); //<2F><>temp_valֵ<6C><D6B5>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>0-100֮<30><D6AE>//
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
/****************************************Copyright (c)****************************************************
|
|
||||||
**
|
|
||||||
** File name: light.h
|
|
||||||
** Created by: XiaoYi
|
|
||||||
** Created date: 2020-10-16
|
|
||||||
** Version: v1.0
|
|
||||||
** Descriptions: The original
|
|
||||||
** Link address: https://blog.csdn.net/weixin_45006076
|
|
||||||
**
|
|
||||||
*********************************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __SENSOR_LIGHT_H__
|
|
||||||
#define __SENSOR_LIGHT_H__
|
|
||||||
|
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
uint8_t light_get_average_value(uint8_t times);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,299 +0,0 @@
|
|||||||
/****************************************Copyright (c)****************************************************
|
|
||||||
**
|
|
||||||
** File name: process.c
|
|
||||||
** Created by: XiaoYi
|
|
||||||
** Created date: 2020-10-16
|
|
||||||
** Version: v1.0
|
|
||||||
** Descriptions: The original
|
|
||||||
** Link address: https://blog.csdn.net/weixin_45006076
|
|
||||||
**
|
|
||||||
*********************************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __CODETAB_H__
|
|
||||||
#define __CODETAB_H__
|
|
||||||
|
|
||||||
/***************************16*16<31>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡģ<C8A1><C4A3>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*********/
|
|
||||||
unsigned char F16x16[] =
|
|
||||||
{
|
|
||||||
0x00,0x02,0x02,0xFA,0xFA,0xAA,0xAA,0xFF,0xFF,0xAA,0xAA,0xFA,0xFA,0x02,0x02,0x00,
|
|
||||||
0x00,0x42,0x72,0x72,0x3A,0x7A,0x42,0x4B,0x5B,0x52,0x62,0x62,0x13,0x77,0x66,0x00,/*"<22><>",0*/
|
|
||||||
|
|
||||||
0x20,0x3C,0x1C,0xFF,0xFF,0xB0,0xB4,0x24,0x24,0x3F,0x3F,0xE4,0xE4,0x24,0x24,0x20,
|
|
||||||
0x02,0x02,0x03,0xFF,0xFF,0x00,0x01,0x05,0x1D,0x59,0xC1,0xFF,0x7F,0x01,0x01,0x01,/*"<22><>",1*/
|
|
||||||
|
|
||||||
0x00,0x00,0x00,0xF8,0xF8,0x48,0x4C,0x4F,0x4B,0x4A,0x48,0x48,0xF8,0xF8,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0xFF,0xFF,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0xFF,0xFF,0x00,0x00,/*"<22><>",2*/
|
|
||||||
|
|
||||||
0x20,0x24,0x24,0xE4,0xE4,0x24,0x24,0x24,0x30,0x10,0xFF,0xFF,0x10,0xF0,0xF0,0x00,
|
|
||||||
0x08,0x1C,0x1F,0x0B,0x0C,0x0D,0x4F,0x6E,0x34,0x1C,0x0F,0x23,0x60,0x7F,0x3F,0x00,/*"<22><>",3*/
|
|
||||||
|
|
||||||
0x80,0xC0,0x60,0xF8,0xFF,0x07,0x02,0x00,0xFF,0xFF,0xE0,0x70,0x3C,0x1C,0x08,0x00,
|
|
||||||
0x00,0x00,0x00,0x7F,0x7F,0x04,0x06,0x03,0x3F,0x7F,0x40,0x40,0x40,0x78,0x78,0x00,/*"<22><>",4*/
|
|
||||||
};
|
|
||||||
|
|
||||||
/************************************6*8<>ĵ<EFBFBD><C4B5><EFBFBD>************************************/
|
|
||||||
const unsigned char F6x8[][6] =
|
|
||||||
{
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,// sp
|
|
||||||
0x00, 0x00, 0x00, 0x2f, 0x00, 0x00,// !
|
|
||||||
0x00, 0x00, 0x07, 0x00, 0x07, 0x00,// "
|
|
||||||
0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14,// #
|
|
||||||
0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12,// $
|
|
||||||
0x00, 0x62, 0x64, 0x08, 0x13, 0x23,// %
|
|
||||||
0x00, 0x36, 0x49, 0x55, 0x22, 0x50,// &
|
|
||||||
0x00, 0x00, 0x05, 0x03, 0x00, 0x00,// '
|
|
||||||
0x00, 0x00, 0x1c, 0x22, 0x41, 0x00,// (
|
|
||||||
0x00, 0x00, 0x41, 0x22, 0x1c, 0x00,// )
|
|
||||||
0x00, 0x14, 0x08, 0x3E, 0x08, 0x14,// *
|
|
||||||
0x00, 0x08, 0x08, 0x3E, 0x08, 0x08,// +
|
|
||||||
0x00, 0x00, 0x00, 0xA0, 0x60, 0x00,// ,
|
|
||||||
0x00, 0x08, 0x08, 0x08, 0x08, 0x08,// -
|
|
||||||
0x00, 0x00, 0x60, 0x60, 0x00, 0x00,// .
|
|
||||||
0x00, 0x20, 0x10, 0x08, 0x04, 0x02,// /
|
|
||||||
0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0
|
|
||||||
0x00, 0x00, 0x42, 0x7F, 0x40, 0x00,// 1
|
|
||||||
0x00, 0x42, 0x61, 0x51, 0x49, 0x46,// 2
|
|
||||||
0x00, 0x21, 0x41, 0x45, 0x4B, 0x31,// 3
|
|
||||||
0x00, 0x18, 0x14, 0x12, 0x7F, 0x10,// 4
|
|
||||||
0x00, 0x27, 0x45, 0x45, 0x45, 0x39,// 5
|
|
||||||
0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6
|
|
||||||
0x00, 0x01, 0x71, 0x09, 0x05, 0x03,// 7
|
|
||||||
0x00, 0x36, 0x49, 0x49, 0x49, 0x36,// 8
|
|
||||||
0x00, 0x06, 0x49, 0x49, 0x29, 0x1E,// 9
|
|
||||||
0x00, 0x00, 0x36, 0x36, 0x00, 0x00,// :
|
|
||||||
0x00, 0x00, 0x56, 0x36, 0x00, 0x00,// ;
|
|
||||||
0x00, 0x08, 0x14, 0x22, 0x41, 0x00,// <
|
|
||||||
0x00, 0x14, 0x14, 0x14, 0x14, 0x14,// =
|
|
||||||
0x00, 0x00, 0x41, 0x22, 0x14, 0x08,// >
|
|
||||||
0x00, 0x02, 0x01, 0x51, 0x09, 0x06,// ?
|
|
||||||
0x00, 0x32, 0x49, 0x59, 0x51, 0x3E,// @
|
|
||||||
0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C,// A
|
|
||||||
0x00, 0x7F, 0x49, 0x49, 0x49, 0x36,// B
|
|
||||||
0x00, 0x3E, 0x41, 0x41, 0x41, 0x22,// C
|
|
||||||
0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C,// D
|
|
||||||
0x00, 0x7F, 0x49, 0x49, 0x49, 0x41,// E
|
|
||||||
0x00, 0x7F, 0x09, 0x09, 0x09, 0x01,// F
|
|
||||||
0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A,// G
|
|
||||||
0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F,// H
|
|
||||||
0x00, 0x00, 0x41, 0x7F, 0x41, 0x00,// I
|
|
||||||
0x00, 0x20, 0x40, 0x41, 0x3F, 0x01,// J
|
|
||||||
0x00, 0x7F, 0x08, 0x14, 0x22, 0x41,// K
|
|
||||||
0x00, 0x7F, 0x40, 0x40, 0x40, 0x40,// L
|
|
||||||
0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F,// M
|
|
||||||
0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F,// N
|
|
||||||
0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E,// O
|
|
||||||
0x00, 0x7F, 0x09, 0x09, 0x09, 0x06,// P
|
|
||||||
0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q
|
|
||||||
0x00, 0x7F, 0x09, 0x19, 0x29, 0x46,// R
|
|
||||||
0x00, 0x46, 0x49, 0x49, 0x49, 0x31,// S
|
|
||||||
0x00, 0x01, 0x01, 0x7F, 0x01, 0x01,// T
|
|
||||||
0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F,// U
|
|
||||||
0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F,// V
|
|
||||||
0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F,// W
|
|
||||||
0x00, 0x63, 0x14, 0x08, 0x14, 0x63,// X
|
|
||||||
0x00, 0x07, 0x08, 0x70, 0x08, 0x07,// Y
|
|
||||||
0x00, 0x61, 0x51, 0x49, 0x45, 0x43,// Z
|
|
||||||
0x00, 0x00, 0x7F, 0x41, 0x41, 0x00,// [
|
|
||||||
0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55,// 55
|
|
||||||
0x00, 0x00, 0x41, 0x41, 0x7F, 0x00,// ]
|
|
||||||
0x00, 0x04, 0x02, 0x01, 0x02, 0x04,// ^
|
|
||||||
0x00, 0x40, 0x40, 0x40, 0x40, 0x40,// _
|
|
||||||
0x00, 0x00, 0x01, 0x02, 0x04, 0x00,// '
|
|
||||||
0x00, 0x20, 0x54, 0x54, 0x54, 0x78,// a
|
|
||||||
0x00, 0x7F, 0x48, 0x44, 0x44, 0x38,// b
|
|
||||||
0x00, 0x38, 0x44, 0x44, 0x44, 0x20,// c
|
|
||||||
0x00, 0x38, 0x44, 0x44, 0x48, 0x7F,// d
|
|
||||||
0x00, 0x38, 0x54, 0x54, 0x54, 0x18,// e
|
|
||||||
0x00, 0x08, 0x7E, 0x09, 0x01, 0x02,// f
|
|
||||||
0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C,// g
|
|
||||||
0x00, 0x7F, 0x08, 0x04, 0x04, 0x78,// h
|
|
||||||
0x00, 0x00, 0x44, 0x7D, 0x40, 0x00,// i
|
|
||||||
0x00, 0x40, 0x80, 0x84, 0x7D, 0x00,// j
|
|
||||||
0x00, 0x7F, 0x10, 0x28, 0x44, 0x00,// k
|
|
||||||
0x00, 0x00, 0x41, 0x7F, 0x40, 0x00,// l
|
|
||||||
0x00, 0x7C, 0x04, 0x18, 0x04, 0x78,// m
|
|
||||||
0x00, 0x7C, 0x08, 0x04, 0x04, 0x78,// n
|
|
||||||
0x00, 0x38, 0x44, 0x44, 0x44, 0x38,// o
|
|
||||||
0x00, 0xFC, 0x24, 0x24, 0x24, 0x18,// p
|
|
||||||
0x00, 0x18, 0x24, 0x24, 0x18, 0xFC,// q
|
|
||||||
0x00, 0x7C, 0x08, 0x04, 0x04, 0x08,// r
|
|
||||||
0x00, 0x48, 0x54, 0x54, 0x54, 0x20,// s
|
|
||||||
0x00, 0x04, 0x3F, 0x44, 0x40, 0x20,// t
|
|
||||||
0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C,// u
|
|
||||||
0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C,// v
|
|
||||||
0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C,// w
|
|
||||||
0x00, 0x44, 0x28, 0x10, 0x28, 0x44,// x
|
|
||||||
0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C,// y
|
|
||||||
0x00, 0x44, 0x64, 0x54, 0x4C, 0x44,// z
|
|
||||||
0x14, 0x14, 0x14, 0x14, 0x14, 0x14,// horiz lines
|
|
||||||
};
|
|
||||||
/****************************************8*16<31>ĵ<EFBFBD><C4B5><EFBFBD>************************************/
|
|
||||||
const unsigned char F8X16[]=
|
|
||||||
{
|
|
||||||
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,0x10,0x0C,0x06,0x10,0x0C,0x06,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
|
|
||||||
0x10,0x16,0x0E,0x00,0x00,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,0x80,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,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,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,0x00,0x04,0x02,0x02,0x02,0x04,0x00,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,0x02,0x04,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
|
|
||||||
0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,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,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~ 94
|
|
||||||
};
|
|
||||||
|
|
||||||
unsigned char BMP1[] =
|
|
||||||
{
|
|
||||||
0x00,0x03,0x05,0x09,0x11,0xFF,0x11,0x89,0x05,0xC3,0x00,0xE0,0x00,0xF0,0x00,0xF8,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x28,0xFF,0x11,0xAA,0x44,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x83,0x01,0x38,0x44,0x82,0x92,
|
|
||||||
0x92,0x74,0x01,0x83,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x44,0xC7,0x01,0x7D,
|
|
||||||
0x7D,0x7D,0x7D,0x01,0x7D,0x7D,0x7D,0x7D,0x01,0x7D,0x7D,0x7D,0x7D,0x01,0xFF,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,
|
|
||||||
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x00,0x00,
|
|
||||||
0x6D,0x6D,0x6D,0x6D,0x6D,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x40,0x40,
|
|
||||||
0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xDB,0xDB,0xDB,0xDB,0xDB,0x00,0x00,
|
|
||||||
0xDB,0xDB,0xDB,0xDB,0xDB,0x00,0x00,0xDB,0xDB,0xDB,0xDB,0xDB,0x00,0x00,0xDB,0xDB,
|
|
||||||
0xDB,0xDB,0xDB,0x00,0x00,0xDA,0xDA,0xDA,0xDA,0xDA,0x00,0x00,0xD8,0xD8,0xD8,0xD8,
|
|
||||||
0xD8,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,
|
|
||||||
0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x80,
|
|
||||||
0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,0x00,
|
|
||||||
0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x06,0x06,
|
|
||||||
0x06,0x06,0x06,0x00,0x00,0x06,0x06,0x06,0xE6,0x66,0x20,0x00,0x06,0x06,0x86,0x06,
|
|
||||||
0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x86,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,
|
|
||||||
0x00,0x86,0x86,0x86,0x86,0x86,0x80,0x80,0x86,0x86,0x06,0x86,0x86,0xC0,0xC0,0x86,
|
|
||||||
0x86,0x86,0x06,0x06,0xD0,0x30,0x76,0x06,0x06,0x06,0x06,0x00,0x00,0x06,0x06,0x06,
|
|
||||||
0x06,0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x06,
|
|
||||||
0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x1C,0x00,0xFE,0x00,0x01,
|
|
||||||
0x02,0x00,0xC4,0x18,0x20,0x02,0x9E,0x63,0xB2,0x0E,0x00,0xFF,0x81,0x81,0xFF,0x00,
|
|
||||||
0x00,0x80,0x40,0x30,0x0F,0x00,0x00,0x00,0x00,0xFF,0x00,0x23,0xEA,0xAA,0xBF,0xAA,
|
|
||||||
0xEA,0x03,0x3F,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x0C,0x08,0x00,0x00,0x01,0x01,0x01,
|
|
||||||
0x01,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x81,0x80,0x80,0x81,0x80,
|
|
||||||
0x81,0x80,0x80,0x80,0x80,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
|
|
||||||
0x01,0x00,0x01,0x01,0x09,0x0C,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,
|
|
||||||
0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,
|
|
||||||
0x00,0x1E,0x21,0x40,0x40,0x50,0x21,0x5E,0x00,0x1E,0x21,0x40,0x40,0x50,0x21,0x5E,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xC1,0xC1,0xFF,
|
|
||||||
0xFF,0xC1,0xC1,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x80,0xFC,0xF3,0xEF,0xF3,0xFC,
|
|
||||||
0x80,0xFF,0x80,0xEE,0xEE,0xEE,0xF5,0xFB,0xFF,0x9C,0xBE,0xB6,0xB6,0x88,0xFF,0x00,/*"D:\DreamSpark\OLED\MP3_UI.bmp",0*/
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,215 +0,0 @@
|
|||||||
/****************************************Copyright (c)****************************************************
|
|
||||||
**
|
|
||||||
** File name: lcd.c
|
|
||||||
** Created by: XiaoYi
|
|
||||||
** Created date: 2020-10-16
|
|
||||||
** Version: v1.0
|
|
||||||
** Descriptions: The original
|
|
||||||
** Link address: https://blog.csdn.net/weixin_45006076
|
|
||||||
**
|
|
||||||
*********************************************************************************************************/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "main.h"
|
|
||||||
#include "i2c.h"
|
|
||||||
#include "oled.h"
|
|
||||||
#include "codetab.h"
|
|
||||||
|
|
||||||
void oled_write_cmd(unsigned char cmd)//д<><D0B4><EFBFBD><EFBFBD>
|
|
||||||
{
|
|
||||||
HAL_I2C_Mem_Write(&hi2c1 ,0x78,0x00,I2C_MEMADD_SIZE_8BIT,&cmd,1,0x100);
|
|
||||||
}
|
|
||||||
|
|
||||||
void oled_write_data(unsigned char data)//д<><D0B4><EFBFBD><EFBFBD>
|
|
||||||
{
|
|
||||||
HAL_I2C_Mem_Write(&hi2c1 ,0x78,0x40,I2C_MEMADD_SIZE_8BIT,&data,1,0x100);
|
|
||||||
}
|
|
||||||
|
|
||||||
void oled_set_pos(unsigned char x, unsigned char y) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
{
|
|
||||||
oled_write_cmd(0xb0+y);
|
|
||||||
oled_write_cmd(((x&0xf0)>>4)|0x10);
|
|
||||||
oled_write_cmd((x&0x0f)|0x01);
|
|
||||||
}
|
|
||||||
|
|
||||||
void oled_fill(unsigned char fill_Data)//ȫ<><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
{
|
|
||||||
unsigned char m,n;
|
|
||||||
for(m=0;m<8;m++)
|
|
||||||
{
|
|
||||||
oled_write_cmd(0xb0+m); //page0-page1
|
|
||||||
oled_write_cmd(0x00); //low column start address
|
|
||||||
oled_write_cmd(0x10); //high column start address
|
|
||||||
for(n=0;n<128;n++)
|
|
||||||
{
|
|
||||||
oled_write_data(fill_Data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void oled_clear_screen(void)//<2F><><EFBFBD><EFBFBD>
|
|
||||||
{
|
|
||||||
oled_fill(0x00);
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
// Prototype : void oled_wakeup(void)
|
|
||||||
// Calls :
|
|
||||||
// Parameters : none
|
|
||||||
// Description : <20><>OLED<45><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD>
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
void oled_wakeup(void)
|
|
||||||
{
|
|
||||||
oled_write_cmd(0X8D); //<2F><><EFBFBD>õ<EFBFBD><C3B5>ɱ<EFBFBD>
|
|
||||||
oled_write_cmd(0X14); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD>
|
|
||||||
oled_write_cmd(0XAF); //OLED<45><44><EFBFBD><EFBFBD>
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
// Prototype : void oled_sleep(void)
|
|
||||||
// Calls :
|
|
||||||
// Parameters : none
|
|
||||||
// Description : <20><>OLED<45><44><EFBFBD><EFBFBD> -- <20><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>,OLED<45><44><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>10uA
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
void oled_sleep(void)
|
|
||||||
{
|
|
||||||
oled_write_cmd(0X8D); //<2F><><EFBFBD>õ<EFBFBD><C3B5>ɱ<EFBFBD>
|
|
||||||
oled_write_cmd(0X10); //<2F>رյ<D8B1><D5B5>ɱ<EFBFBD>
|
|
||||||
oled_write_cmd(0XAE); //OLED<45><44><EFBFBD><EFBFBD>
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
// Prototype : void OLED_ShowChar(unsigned char x, unsigned char y, unsigned char ch[], unsigned char TextSize)
|
|
||||||
// Calls :
|
|
||||||
// Parameters : x,y -- <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(x:0~127, y:0~7); ch[] -- Ҫ<><D2AA>ʾ<EFBFBD><CABE><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>; TextSize -- <20>ַ<EFBFBD><D6B7><EFBFBD>С(1:6*8 ; 2:8*16)
|
|
||||||
// Description : <20><>ʾcodetab.h<>е<EFBFBD>ASCII<49>ַ<EFBFBD>,<2C><>6*8<><38>8*16<31><36>ѡ<EFBFBD><D1A1>
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
void oled_show_string(unsigned char x, unsigned char y, unsigned char ch[], unsigned char TextSize)
|
|
||||||
{
|
|
||||||
unsigned char c = 0,i = 0,j = 0;
|
|
||||||
switch(TextSize)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
while(ch[j] != '\0')
|
|
||||||
{
|
|
||||||
c = ch[j] - 32;
|
|
||||||
if(x > 126)
|
|
||||||
{
|
|
||||||
x = 0;
|
|
||||||
y++;
|
|
||||||
}
|
|
||||||
oled_set_pos(x,y);
|
|
||||||
for(i=0;i<6;i++)
|
|
||||||
oled_write_data(F6x8[c][i]);
|
|
||||||
x += 6;
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
}break;
|
|
||||||
case 2:
|
|
||||||
{
|
|
||||||
while(ch[j] != '\0')
|
|
||||||
{
|
|
||||||
c = ch[j] - 32;
|
|
||||||
if(x > 120)
|
|
||||||
{
|
|
||||||
x = 0;
|
|
||||||
y++;
|
|
||||||
}
|
|
||||||
oled_set_pos(x,y);
|
|
||||||
for(i=0;i<8;i++)
|
|
||||||
oled_write_data(F8X16[c*16+i]);
|
|
||||||
oled_set_pos(x,y+1);
|
|
||||||
for(i=0;i<8;i++)
|
|
||||||
oled_write_data(F8X16[c*16+i+8]);
|
|
||||||
x += 8;
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
}break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
// Prototype : void oled_show_chinese(unsigned char x, unsigned char y, unsigned char N)
|
|
||||||
// Calls :
|
|
||||||
// Parameters : x,y -- <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(x:0~127, y:0~7); N:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>codetab.h<>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
// Description : <20><>ʾcodetab.h<>еĺ<D0B5><C4BA><EFBFBD>,16*16<31><36><EFBFBD><EFBFBD>
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
void oled_show_chinese(unsigned char x, unsigned char y, unsigned char N)
|
|
||||||
{
|
|
||||||
unsigned char wm=0;
|
|
||||||
unsigned int adder=32*N;
|
|
||||||
oled_set_pos(x , y);
|
|
||||||
for(wm = 0;wm < 16;wm++)
|
|
||||||
{
|
|
||||||
oled_write_data(F16x16[adder]);
|
|
||||||
adder += 1;
|
|
||||||
}
|
|
||||||
oled_set_pos(x,y + 1);
|
|
||||||
for(wm = 0;wm < 16;wm++)
|
|
||||||
{
|
|
||||||
oled_write_data(F16x16[adder]);
|
|
||||||
adder += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
// Prototype : void oled_draw_bmp(unsigned char x0,unsigned char y0,unsigned char x1,unsigned char y1,unsigned char BMP[]);
|
|
||||||
// Calls :
|
|
||||||
// Parameters : x0,y0 -- <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(x0:0~127, y0:0~7); x1,y1 -- <20><><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(x1:1~128,y1:1~8)
|
|
||||||
// Description : <20><>ʾBMPλͼ
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
void oled_draw_bmp(unsigned char x0,unsigned char y0,unsigned char x1,unsigned char y1,unsigned char *bmp)
|
|
||||||
{
|
|
||||||
unsigned int j=0;
|
|
||||||
unsigned char x,y;
|
|
||||||
|
|
||||||
if(y1%8==0)
|
|
||||||
y = y1/8;
|
|
||||||
else
|
|
||||||
y = y1/8 + 1;
|
|
||||||
for(y=y0;y<y1;y++)
|
|
||||||
{
|
|
||||||
oled_set_pos(x0,y);
|
|
||||||
for(x=x0;x<x1;x++)
|
|
||||||
{
|
|
||||||
oled_write_data(bmp[j++]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void oled_init(void)
|
|
||||||
{
|
|
||||||
delay_ms(100); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ҫ
|
|
||||||
|
|
||||||
oled_write_cmd(0xAE); //display off
|
|
||||||
oled_write_cmd(0x20); //Set Memory Addressing Mode
|
|
||||||
oled_write_cmd(0x10); //00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid
|
|
||||||
oled_write_cmd(0xb0); //Set Page Start Address for Page Addressing Mode,0-7
|
|
||||||
oled_write_cmd(0xc8); //Set COM Output Scan Direction
|
|
||||||
oled_write_cmd(0x00); //---set low column address
|
|
||||||
oled_write_cmd(0x10); //---set high column address
|
|
||||||
oled_write_cmd(0x40); //--set start line address
|
|
||||||
oled_write_cmd(0x81); //--set contrast control register
|
|
||||||
oled_write_cmd(0xff); //<2F><><EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD> 0x00~0xff
|
|
||||||
oled_write_cmd(0xa1); //--set segment re-map 0 to 127
|
|
||||||
oled_write_cmd(0xa6); //--set normal display
|
|
||||||
oled_write_cmd(0xa8); //--set multiplex ratio(1 to 64)
|
|
||||||
oled_write_cmd(0x3F); //
|
|
||||||
oled_write_cmd(0xa4); //0xa4,Output follows RAM content;0xa5,Output ignores RAM content
|
|
||||||
oled_write_cmd(0xd3); //-set display offset
|
|
||||||
oled_write_cmd(0x00); //-not offset
|
|
||||||
oled_write_cmd(0xd5); //--set display clock divide ratio/oscillator frequency
|
|
||||||
oled_write_cmd(0xf0); //--set divide ratio
|
|
||||||
oled_write_cmd(0xd9); //--set pre-charge period
|
|
||||||
oled_write_cmd(0x22); //
|
|
||||||
oled_write_cmd(0xda); //--set com pins hardware configuration
|
|
||||||
oled_write_cmd(0x12);
|
|
||||||
oled_write_cmd(0xdb); //--set vcomh
|
|
||||||
oled_write_cmd(0x20); //0x20,0.77xVcc
|
|
||||||
oled_write_cmd(0x8d); //--set DC-DC enable
|
|
||||||
oled_write_cmd(0x14); //
|
|
||||||
oled_write_cmd(0xaf); //--turn on oled panel
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
/****************************************Copyright (c)****************************************************
|
|
||||||
**
|
|
||||||
** File name: process.c
|
|
||||||
** Created by: XiaoYi
|
|
||||||
** Created date: 2020-10-16
|
|
||||||
** Version: v1.0
|
|
||||||
** Descriptions: The original
|
|
||||||
** Link address: https://blog.csdn.net/weixin_45006076
|
|
||||||
**
|
|
||||||
*********************************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __OLED_H__
|
|
||||||
#define __OLED_H__
|
|
||||||
|
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
|
|
||||||
typedef enum{
|
|
||||||
CURSOR_INIT,
|
|
||||||
CURSOR_HIGH,
|
|
||||||
CURSOR_LOW,
|
|
||||||
}eStatus;
|
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
|
||||||
void oled_init(void);
|
|
||||||
|
|
||||||
void oled_write_cmd(unsigned char cmd);
|
|
||||||
|
|
||||||
void oled_write_data(unsigned char data);
|
|
||||||
|
|
||||||
void oled_set_pos(unsigned char x, unsigned char y);
|
|
||||||
|
|
||||||
void oled_fill(unsigned char fill_Data);
|
|
||||||
|
|
||||||
void oled_clear_screen(void);
|
|
||||||
|
|
||||||
void oled_wakeup(void);
|
|
||||||
|
|
||||||
void oled_sleep(void);
|
|
||||||
|
|
||||||
void oled_show_string(unsigned char x, unsigned char y, unsigned char ch[], unsigned char TextSize);
|
|
||||||
|
|
||||||
void oled_show_chinese(unsigned char x, unsigned char y, unsigned char N);
|
|
||||||
|
|
||||||
void oled_draw_bmp(unsigned char x0,unsigned char y0,unsigned char x1,unsigned char y1,unsigned char *bmp);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,381 +0,0 @@
|
|||||||
#ifndef __OLEDFONT_H
|
|
||||||
#define __OLEDFONT_H
|
|
||||||
// ------------------ ASCII<49><49>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD> ------------------------ //
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0x20~0x7e //
|
|
||||||
// <20>ֿ<EFBFBD>: <20><><EFBFBD><EFBFBD>ȡģ<C8A1>¸<EFBFBD>λ// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱҪ<CAB1><D2AA>512<31><32>
|
|
||||||
// -------------------------------------------------------------- //
|
|
||||||
|
|
||||||
unsigned char F16x16[] =
|
|
||||||
{
|
|
||||||
// 0x00,0x00,0x00,0x00,0x00,0xF0,0x08,0x04,0x04,0x08,0xF0,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
// 0x00,0x00,0x00,0x00,0x00,0x07,0x08,0x10,0x10,0x08,0x07,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
|
|
||||||
0x10,0x94,0x53,0x32,0x1E,0x32,0x52,0x10,0x00,0x7E,0x42,0x42,0x42,0x7E,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0xFF,0x49,0x49,0x49,0x49,0x49,0x49,0x49,0xFF,0x00,0x00,0x00,0x00,/*"<22>ǡ<EFBFBD>,0*/
|
|
||||||
|
|
||||||
0x08,0xCC,0x4A,0x49,0x48,0x4A,0xCC,0x18,0x00,0x7F,0x88,0x88,0x84,0x82,0xE0,0x00,
|
|
||||||
0x00,0xFF,0x12,0x12,0x52,0x92,0x7F,0x00,0x00,0x7E,0x88,0x88,0x84,0x82,0xE0,0x00,/*"<22><>",1*/
|
|
||||||
|
|
||||||
0x40,0x20,0xF0,0x28,0x24,0x27,0x24,0xE4,0x24,0x34,0x2C,0x20,0xE0,0x00,0x00,0x00,
|
|
||||||
0x40,0x40,0x4F,0x49,0x49,0x49,0x49,0x4F,0x49,0x49,0x49,0x49,0x4F,0x40,0x40,0x00,/*"<22><>",2*/
|
|
||||||
|
|
||||||
0x50,0x48,0x47,0x44,0xFC,0x44,0x44,0x44,0x00,0x04,0x04,0xFC,0x04,0x04,0x04,0x00,
|
|
||||||
0x00,0x3E,0x20,0x20,0x3F,0x10,0x10,0x7E,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x00,/*"<22><>",3*/
|
|
||||||
|
|
||||||
0x04,0x24,0x44,0x84,0x64,0x9C,0x40,0x30,0x0F,0xC8,0x08,0x08,0x28,0x18,0x00,0x00,
|
|
||||||
0x10,0x08,0x06,0x01,0x82,0x4C,0x20,0x18,0x06,0x01,0x06,0x18,0x20,0x40,0x80,0x00,/*"<22><>",4*/
|
|
||||||
|
|
||||||
0x40,0x40,0x42,0xCC,0x00,0x00,0xFC,0x04,0x02,0x00,0xFC,0x04,0x04,0xFC,0x00,0x00,
|
|
||||||
0x00,0x40,0x20,0x1F,0x20,0x40,0x4F,0x44,0x42,0x40,0x7F,0x42,0x44,0x43,0x40,0x00,//ӭ5
|
|
||||||
|
|
||||||
0x40,0x40,0x42,0xCC,0x00,0x80,0x88,0x88,0xFF,0x88,0x88,0xFF,0x88,0x88,0x80,0x00,
|
|
||||||
0x00,0x40,0x20,0x1F,0x20,0x40,0x50,0x4C,0x43,0x40,0x40,0x5F,0x40,0x40,0x40,0x00,//<2F><>6
|
|
||||||
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x01,0xE2,0x1C,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x00,0x03,0x0C,0x30,0x40,0x80,0x80,0x00,//<2F><>7
|
|
||||||
|
|
||||||
0x00,0x02,0x02,0xC2,0x02,0x02,0x02,0xFE,0x82,0x82,0x82,0x82,0x82,0x02,0x00,0x00,
|
|
||||||
0x40,0x40,0x40,0x7F,0x40,0x40,0x40,0x7F,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,//<2F><>8
|
|
||||||
|
|
||||||
0x08,0x08,0x88,0xC8,0x38,0x0C,0x0B,0x08,0x08,0xE8,0x08,0x08,0x08,0x08,0x08,0x00,
|
|
||||||
0x02,0x01,0x00,0xFF,0x40,0x41,0x41,0x41,0x41,0x7F,0x41,0x41,0x41,0x41,0x40,0x00,//<2F><>9
|
|
||||||
|
|
||||||
0x02,0xFE,0x92,0x92,0xFE,0x02,0x00,0x10,0x11,0x16,0xF0,0x14,0x13,0x10,0x00,0x00,
|
|
||||||
0x10,0x1F,0x08,0x08,0xFF,0x04,0x81,0x41,0x31,0x0D,0x03,0x0D,0x31,0x41,0x81,0x00,//<2F><>10
|
|
||||||
|
|
||||||
0x00,0xFE,0x02,0x22,0x42,0x82,0x72,0x02,0x22,0x42,0x82,0x72,0x02,0xFE,0x00,0x00,
|
|
||||||
0x00,0xFF,0x10,0x08,0x06,0x01,0x0E,0x10,0x08,0x06,0x01,0x4E,0x80,0x7F,0x00,0x00,//<2F><>11
|
|
||||||
|
|
||||||
0x10,0x60,0x02,0x8C,0x00,0x00,0xFE,0x92,0x92,0x92,0x92,0x92,0xFE,0x00,0x00,0x00,
|
|
||||||
0x04,0x04,0x7E,0x01,0x40,0x7E,0x42,0x42,0x7E,0x42,0x7E,0x42,0x42,0x7E,0x40,0x00,//<2F><>12
|
|
||||||
|
|
||||||
0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0x25,0x26,0x24,0xFC,0x24,0x24,0x24,0x04,0x00,
|
|
||||||
0x40,0x30,0x8F,0x80,0x84,0x4C,0x55,0x25,0x25,0x25,0x55,0x4C,0x80,0x80,0x80,0x00,//<2F><>13
|
|
||||||
|
|
||||||
0x40,0x40,0x42,0xCC,0x00,0x08,0x48,0x88,0x08,0x08,0x08,0xFF,0x08,0x08,0x08,0x00,
|
|
||||||
0x00,0x40,0x20,0x1F,0x20,0x40,0x40,0x41,0x40,0x48,0x50,0x4F,0x40,0x40,0x40,0x00,/*"<22><>",14*/
|
|
||||||
|
|
||||||
0x10,0x60,0x02,0x8C,0x00,0xF8,0x48,0x48,0x48,0xFF,0x2A,0x2A,0x0A,0xCA,0x18,0x00,
|
|
||||||
0x04,0x04,0x7E,0x81,0x60,0x1F,0x80,0x70,0x00,0x78,0x83,0x8D,0xC1,0x09,0x70,0x00,/*"<22><>",15*/
|
|
||||||
|
|
||||||
0x08,0x24,0x23,0x6A,0xAA,0x2A,0xAA,0x6A,0x2A,0x2A,0x2A,0xEA,0x02,0x02,0x00,0x00,
|
|
||||||
0x10,0x11,0x15,0x15,0x15,0xFF,0x15,0x15,0x15,0x11,0x10,0x0F,0x30,0x40,0xF8,0x00,/*"<22><>",16*/
|
|
||||||
|
|
||||||
0x42,0x42,0x22,0x12,0xFA,0x96,0x92,0x92,0x92,0x92,0x92,0xF2,0x02,0x02,0x02,0x00,
|
|
||||||
0x40,0x44,0x24,0x14,0x0C,0x44,0x80,0x7F,0x04,0x08,0x10,0x28,0x24,0x42,0x40,0x00,/*"<22><>",17*/
|
|
||||||
|
|
||||||
0x80,0x82,0x82,0x82,0xFE,0x82,0x82,0x82,0x82,0x82,0xFE,0x82,0x82,0x82,0x80,0x00,
|
|
||||||
0x00,0x80,0x40,0x30,0x0F,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,/*"<22><>",18*/
|
|
||||||
|
|
||||||
|
|
||||||
0x00,0x00,0x10,0x11,0x16,0x10,0x10,0xF0,0x10,0x10,0x14,0x13,0x10,0x00,0x00,0x00,
|
|
||||||
0x81,0x81,0x41,0x41,0x21,0x11,0x0D,0x03,0x0D,0x11,0x21,0x41,0x41,0x81,0x81,0x00,/*"<22><>",18*/
|
|
||||||
|
|
||||||
//0x00,0xfc,0x84,0x84,0x84,0xfc,0x00,0x10,0x10,0x10,0x10,0x10,0xff,0x10,0x10,0x00,
|
|
||||||
//0x00,0x3f,0x10,0x10,0x10,0x3f,0x00,0x00,0x01,0x06,0x40,0x80,0x7F,0x00,0x00,0x00,/*"ʱ",14*/
|
|
||||||
|
|
||||||
//0x00,0xf8,0x01,0x06,0x00,0xf0,0x12,0x12,0x12,0xf2,0x02,0x02,0x02,0xfe,0x00,0x00,
|
|
||||||
//0x00,0xff,0x00,0x00,0x00,0x1f,0x11,0x11,0x11,0x1f,0x00,0x40,0x80,0x7f,0x00,0x00,/*"<22><>,15*/
|
|
||||||
|
|
||||||
//0x80,0x40,0x20,0x90,0x88,0x86,0x80,0x80,0x80,0x83,0x8c,0x10,0x20,0x40,0x80,0x00,
|
|
||||||
//0x00,0x80,0x40,0x20,0x18,0x07,0x00,0x40,0x80,0x40,0x3f,0x00,0x00,0x00,0x00,0x00,/*"<22><>",16*/
|
|
||||||
|
|
||||||
//0x24,0x24,0xa4,0xfe,0x23,0x22,0x00,0xc0,0x38,0x00,0xff,0x00,0x08,0x10,0x60,0x00,
|
|
||||||
//0x08,0x06,0x01,0xff,0x01,0x06,0x81,0x80,0x40,0x40,0x27,0x10,0x0c,0x03,0x00,0x00,/*"<22><>",17*/
|
|
||||||
|
|
||||||
//0x00,0x00,0x00,0xbe,0x2a,0x2a,0x2a,0xea,0x2a,0x2a,0x2a,0x3e,0x00,0x00,0x00,0x00,
|
|
||||||
//0x00,0x44,0x42,0x49,0x49,0x49,0x49,0x7F,0x49,0x49,0x49,0x49,0x41,0x40,0x00,0x00,/*"<22><>,18*/
|
|
||||||
|
|
||||||
//0x00,0x04,0xFf,0x24,0x24,0x24,0xff,0x04,0x00,0xfe,0x22,0x22,0x22,0xfe,0x00,0x00,
|
|
||||||
//0x88,0x48,0x2f,0x09,0x09,0x19,0xaf,0x48,0x30,0x0f,0x02,0x42,0x82,0x7f,0x00,0x00,/*"<22><>,19*/
|
|
||||||
|
|
||||||
//0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,
|
|
||||||
//0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"һ",20*/
|
|
||||||
|
|
||||||
//0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x00,
|
|
||||||
//0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,/*"<22><>",21*/
|
|
||||||
|
|
||||||
//0x00,0x04,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x04,0x00,0x00,
|
|
||||||
//0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,/*"<22><>",22*/
|
|
||||||
|
|
||||||
//0x00,0xfc,0x04,0x04,0x04,0xfc,0x04,0x04,0x04,0xfc,0x04,0x04,0x04,0xfc,0x00,0x00,
|
|
||||||
//0x00,0x7f,0x28,0x24,0x23,0x20,0x20,0x20,0x20,0x21,0x22,0x22,0x22,0x7f,0x00,0x00,/*"<22><>",23*/
|
|
||||||
|
|
||||||
//0x00,0x02,0x42,0x42,0x42,0xc2,0x7e,0x42,0x42,0x42,0x42,0xc2,0x02,0x02,0x00,0x00,
|
|
||||||
//0x40,0x40,0x40,0x40,0x78,0x47,0x40,0x40,0x40,0x40,0x40,0x7f,0x40,0x40,0x40,0x00,/*"<22><>?24*/
|
|
||||||
|
|
||||||
//0x20,0x20,0x20,0x20,0x20,0x20,0x21,0x22,0x2c,0x20,0x20,0x20,0x20,0x20,0x20,0x00,
|
|
||||||
//0x00,0x40,0x20,0x10,0x0c,0x03,0x00,0x00,0x00,0x01,0x02,0x04,0x18,0x60,0x00,0x00,/*"<22><>?,25*/
|
|
||||||
|
|
||||||
//0x00,0x00,0x00,0xfe,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0xfe,0x00,0x00,0x00,0x00,
|
|
||||||
//0x00,0x00,0x00,0xfe,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xfe,0x00,0x00,0x00,0x00,/*"<22><>",26*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/************************************6*8<>ĵ<EFBFBD><C4B5><EFBFBD>************************************/
|
|
||||||
const unsigned char F6x8[][6] =
|
|
||||||
{
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,// sp
|
|
||||||
0x00, 0x00, 0x00, 0x2f, 0x00, 0x00,// !
|
|
||||||
0x00, 0x00, 0x07, 0x00, 0x07, 0x00,// "
|
|
||||||
0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14,// #
|
|
||||||
0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12,// $
|
|
||||||
0x00, 0x62, 0x64, 0x08, 0x13, 0x23,// %
|
|
||||||
0x00, 0x36, 0x49, 0x55, 0x22, 0x50,// &
|
|
||||||
0x00, 0x00, 0x05, 0x03, 0x00, 0x00,// '
|
|
||||||
0x00, 0x00, 0x1c, 0x22, 0x41, 0x00,// (
|
|
||||||
0x00, 0x00, 0x41, 0x22, 0x1c, 0x00,// )
|
|
||||||
0x00, 0x14, 0x08, 0x3E, 0x08, 0x14,// *
|
|
||||||
0x00, 0x08, 0x08, 0x3E, 0x08, 0x08,// +
|
|
||||||
0x00, 0x00, 0x00, 0xA0, 0x60, 0x00,// ,
|
|
||||||
0x00, 0x08, 0x08, 0x08, 0x08, 0x08,// -
|
|
||||||
0x00, 0x00, 0x60, 0x60, 0x00, 0x00,// .
|
|
||||||
0x00, 0x20, 0x10, 0x08, 0x04, 0x02,// /
|
|
||||||
0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0
|
|
||||||
0x00, 0x00, 0x42, 0x7F, 0x40, 0x00,// 1
|
|
||||||
0x00, 0x42, 0x61, 0x51, 0x49, 0x46,// 2
|
|
||||||
0x00, 0x21, 0x41, 0x45, 0x4B, 0x31,// 3
|
|
||||||
0x00, 0x18, 0x14, 0x12, 0x7F, 0x10,// 4
|
|
||||||
0x00, 0x27, 0x45, 0x45, 0x45, 0x39,// 5
|
|
||||||
0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6
|
|
||||||
0x00, 0x01, 0x71, 0x09, 0x05, 0x03,// 7
|
|
||||||
0x00, 0x36, 0x49, 0x49, 0x49, 0x36,// 8
|
|
||||||
0x00, 0x06, 0x49, 0x49, 0x29, 0x1E,// 9
|
|
||||||
0x00, 0x00, 0x36, 0x36, 0x00, 0x00,// :
|
|
||||||
0x00, 0x00, 0x56, 0x36, 0x00, 0x00,// ;
|
|
||||||
0x00, 0x08, 0x14, 0x22, 0x41, 0x00,// <
|
|
||||||
0x00, 0x14, 0x14, 0x14, 0x14, 0x14,// =
|
|
||||||
0x00, 0x00, 0x41, 0x22, 0x14, 0x08,// >
|
|
||||||
0x00, 0x02, 0x01, 0x51, 0x09, 0x06,// ?
|
|
||||||
0x00, 0x32, 0x49, 0x59, 0x51, 0x3E,// @
|
|
||||||
0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C,// A
|
|
||||||
0x00, 0x7F, 0x49, 0x49, 0x49, 0x36,// B
|
|
||||||
0x00, 0x3E, 0x41, 0x41, 0x41, 0x22,// C
|
|
||||||
0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C,// D
|
|
||||||
0x00, 0x7F, 0x49, 0x49, 0x49, 0x41,// E
|
|
||||||
0x00, 0x7F, 0x09, 0x09, 0x09, 0x01,// F
|
|
||||||
0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A,// G
|
|
||||||
0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F,// H
|
|
||||||
0x00, 0x00, 0x41, 0x7F, 0x41, 0x00,// I
|
|
||||||
0x00, 0x20, 0x40, 0x41, 0x3F, 0x01,// J
|
|
||||||
0x00, 0x7F, 0x08, 0x14, 0x22, 0x41,// K
|
|
||||||
0x00, 0x7F, 0x40, 0x40, 0x40, 0x40,// L
|
|
||||||
0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F,// M
|
|
||||||
0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F,// N
|
|
||||||
0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E,// O
|
|
||||||
0x00, 0x7F, 0x09, 0x09, 0x09, 0x06,// P
|
|
||||||
0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q
|
|
||||||
0x00, 0x7F, 0x09, 0x19, 0x29, 0x46,// R
|
|
||||||
0x00, 0x46, 0x49, 0x49, 0x49, 0x31,// S
|
|
||||||
0x00, 0x01, 0x01, 0x7F, 0x01, 0x01,// T
|
|
||||||
0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F,// U
|
|
||||||
0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F,// V
|
|
||||||
0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F,// W
|
|
||||||
0x00, 0x63, 0x14, 0x08, 0x14, 0x63,// X
|
|
||||||
0x00, 0x07, 0x08, 0x70, 0x08, 0x07,// Y
|
|
||||||
0x00, 0x61, 0x51, 0x49, 0x45, 0x43,// Z
|
|
||||||
0x00, 0x00, 0x7F, 0x41, 0x41, 0x00,// [
|
|
||||||
0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55,// 55
|
|
||||||
0x00, 0x00, 0x41, 0x41, 0x7F, 0x00,// ]
|
|
||||||
0x00, 0x04, 0x02, 0x01, 0x02, 0x04,// ^
|
|
||||||
0x00, 0x40, 0x40, 0x40, 0x40, 0x40,// _
|
|
||||||
0x00, 0x00, 0x01, 0x02, 0x04, 0x00,// '
|
|
||||||
0x00, 0x20, 0x54, 0x54, 0x54, 0x78,// a
|
|
||||||
0x00, 0x7F, 0x48, 0x44, 0x44, 0x38,// b
|
|
||||||
0x00, 0x38, 0x44, 0x44, 0x44, 0x20,// c
|
|
||||||
0x00, 0x38, 0x44, 0x44, 0x48, 0x7F,// d
|
|
||||||
0x00, 0x38, 0x54, 0x54, 0x54, 0x18,// e
|
|
||||||
0x00, 0x08, 0x7E, 0x09, 0x01, 0x02,// f
|
|
||||||
0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C,// g
|
|
||||||
0x00, 0x7F, 0x08, 0x04, 0x04, 0x78,// h
|
|
||||||
0x00, 0x00, 0x44, 0x7D, 0x40, 0x00,// i
|
|
||||||
0x00, 0x40, 0x80, 0x84, 0x7D, 0x00,// j
|
|
||||||
0x00, 0x7F, 0x10, 0x28, 0x44, 0x00,// k
|
|
||||||
0x00, 0x00, 0x41, 0x7F, 0x40, 0x00,// l
|
|
||||||
0x00, 0x7C, 0x04, 0x18, 0x04, 0x78,// m
|
|
||||||
0x00, 0x7C, 0x08, 0x04, 0x04, 0x78,// n
|
|
||||||
0x00, 0x38, 0x44, 0x44, 0x44, 0x38,// o
|
|
||||||
0x00, 0xFC, 0x24, 0x24, 0x24, 0x18,// p
|
|
||||||
0x00, 0x18, 0x24, 0x24, 0x18, 0xFC,// q
|
|
||||||
0x00, 0x7C, 0x08, 0x04, 0x04, 0x08,// r
|
|
||||||
0x00, 0x48, 0x54, 0x54, 0x54, 0x20,// s
|
|
||||||
0x00, 0x04, 0x3F, 0x44, 0x40, 0x20,// t
|
|
||||||
0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C,// u
|
|
||||||
0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C,// v
|
|
||||||
0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C,// w
|
|
||||||
0x00, 0x44, 0x28, 0x10, 0x28, 0x44,// x
|
|
||||||
0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C,// y
|
|
||||||
0x00, 0x44, 0x64, 0x54, 0x4C, 0x44,// z
|
|
||||||
0x14, 0x14, 0x14, 0x14, 0x14, 0x14,// horiz lines
|
|
||||||
};
|
|
||||||
/****************************************8*16<31>ĵ<EFBFBD><C4B5><EFBFBD>************************************/
|
|
||||||
const unsigned char F8X16[]=
|
|
||||||
{
|
|
||||||
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,0x10,0x0C,0x06,0x10,0x0C,0x06,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
|
|
||||||
0x10,0x16,0x0E,0x00,0x00,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,0x80,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,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,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,0x00,0x04,0x02,0x02,0x02,0x04,0x00,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,0x02,0x04,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
|
|
||||||
0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,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,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~ 94
|
|
||||||
};
|
|
||||||
|
|
||||||
unsigned char BMP1[] =
|
|
||||||
{
|
|
||||||
0x00,0x03,0x05,0x09,0x11,0xFF,0x11,0x89,0x05,0xC3,0x00,0xE0,0x00,0xF0,0x00,0xF8,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x28,0xFF,0x11,0xAA,0x44,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x83,0x01,0x38,0x44,0x82,0x92,
|
|
||||||
0x92,0x74,0x01,0x83,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x44,0xC7,0x01,0x7D,
|
|
||||||
0x7D,0x7D,0x7D,0x01,0x7D,0x7D,0x7D,0x7D,0x01,0x7D,0x7D,0x7D,0x7D,0x01,0xFF,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,
|
|
||||||
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x00,0x00,
|
|
||||||
0x6D,0x6D,0x6D,0x6D,0x6D,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x40,0x40,
|
|
||||||
0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xDB,0xDB,0xDB,0xDB,0xDB,0x00,0x00,
|
|
||||||
0xDB,0xDB,0xDB,0xDB,0xDB,0x00,0x00,0xDB,0xDB,0xDB,0xDB,0xDB,0x00,0x00,0xDB,0xDB,
|
|
||||||
0xDB,0xDB,0xDB,0x00,0x00,0xDA,0xDA,0xDA,0xDA,0xDA,0x00,0x00,0xD8,0xD8,0xD8,0xD8,
|
|
||||||
0xD8,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,
|
|
||||||
0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x80,
|
|
||||||
0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,0x00,
|
|
||||||
0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x06,0x06,
|
|
||||||
0x06,0x06,0x06,0x00,0x00,0x06,0x06,0x06,0xE6,0x66,0x20,0x00,0x06,0x06,0x86,0x06,
|
|
||||||
0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x86,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,
|
|
||||||
0x00,0x86,0x86,0x86,0x86,0x86,0x80,0x80,0x86,0x86,0x06,0x86,0x86,0xC0,0xC0,0x86,
|
|
||||||
0x86,0x86,0x06,0x06,0xD0,0x30,0x76,0x06,0x06,0x06,0x06,0x00,0x00,0x06,0x06,0x06,
|
|
||||||
0x06,0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x06,0x06,0x06,0x06,0x06,
|
|
||||||
0x00,0x00,0x06,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x1C,0x00,0xFE,0x00,0x01,
|
|
||||||
0x02,0x00,0xC4,0x18,0x20,0x02,0x9E,0x63,0xB2,0x0E,0x00,0xFF,0x81,0x81,0xFF,0x00,
|
|
||||||
0x00,0x80,0x40,0x30,0x0F,0x00,0x00,0x00,0x00,0xFF,0x00,0x23,0xEA,0xAA,0xBF,0xAA,
|
|
||||||
0xEA,0x03,0x3F,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x0C,0x08,0x00,0x00,0x01,0x01,0x01,
|
|
||||||
0x01,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x81,0x80,0x80,0x81,0x80,
|
|
||||||
0x81,0x80,0x80,0x80,0x80,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
|
|
||||||
0x01,0x00,0x01,0x01,0x09,0x0C,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,
|
|
||||||
0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,
|
|
||||||
0x00,0x1E,0x21,0x40,0x40,0x50,0x21,0x5E,0x00,0x1E,0x21,0x40,0x40,0x50,0x21,0x5E,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xC1,0xC1,0xFF,
|
|
||||||
0xFF,0xC1,0xC1,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x80,0xFC,0xF3,0xEF,0xF3,0xFC,
|
|
||||||
0x80,0xFF,0x80,0xEE,0xEE,0xEE,0xF5,0xFB,0xFF,0x9C,0xBE,0xB6,0xB6,0x88,0xFF,0x00,/*"D:\DreamSpark\OLED\MP3_UI.bmp",0*/
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,478 +0,0 @@
|
|||||||
#include "esp8266.h"
|
|
||||||
#include "usart.h"
|
|
||||||
|
|
||||||
|
|
||||||
struct STRUCT_USART_Fram ESP8266_Fram_Record_Struct= { 0 }; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ṹ<EFBFBD><E1B9B9>
|
|
||||||
void ESP8266_Init(uint32_t bound)
|
|
||||||
{
|
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
|
||||||
|
|
||||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
|
||||||
|
|
||||||
// GPIO_InitStructure.Pin = ESP8266_RST_Pin;
|
|
||||||
// GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
// GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH;
|
|
||||||
// HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
|
|
||||||
//
|
|
||||||
// GPIO_InitStructure.Pin = ESP8266_CH_PD_Pin;
|
|
||||||
// HAL_GPIO_Init(ESP8266_CH_PD_Pin_Port, &GPIO_InitStructure);
|
|
||||||
//
|
|
||||||
ESP8266_Rst();
|
|
||||||
}
|
|
||||||
|
|
||||||
//<2F><>ESP8266ģ<36>鷢<EFBFBD><E9B7A2>ATָ<54><D6B8>
|
|
||||||
// cmd <20><><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>ָ<EFBFBD><D6B8>
|
|
||||||
// ack1,ack2;<3B>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>ΪNULL<4C><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><DFBC><EFBFBD>ϵ
|
|
||||||
// time <20>ȴ<EFBFBD><C8B4><EFBFBD>Ӧʱ<D3A6><CAB1>
|
|
||||||
//<2F><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD>ͳɹ<CDB3><C9B9><EFBFBD> 0ʧ<30><CAA7>
|
|
||||||
bool ESP8266_Send_AT_Cmd(char *cmd,char *ack1,char *ack2,uint32_t time)
|
|
||||||
{
|
|
||||||
ESP8266_Fram_Record_Struct.InfBit .FramLength = 0; //<2F><><EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD>ݰ<EFBFBD>
|
|
||||||
ESP8266_USART("%s\r\n", cmd);
|
|
||||||
if(ack1==0&&ack2==0) //<2F><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
delay_ms(time); //<2F><>ʱ
|
|
||||||
delay_ms(1000);
|
|
||||||
ESP8266_Fram_Record_Struct.Data_RX_BUF[ESP8266_Fram_Record_Struct.InfBit.FramLength ] = '\0';
|
|
||||||
|
|
||||||
printf("------ %s", ESP8266_Fram_Record_Struct.Data_RX_BUF);
|
|
||||||
if(ack1!=0&&ack2!=0)
|
|
||||||
{
|
|
||||||
return ( ( bool ) strstr ( ESP8266_Fram_Record_Struct.Data_RX_BUF, ack1 ) ||
|
|
||||||
( bool ) strstr ( ESP8266_Fram_Record_Struct.Data_RX_BUF, ack2 ) );
|
|
||||||
}
|
|
||||||
else if( ack1 != 0 ) //strstr(s1,s2);<3B><><EFBFBD><EFBFBD>s2<73>Ƿ<EFBFBD>Ϊs1<73><31>һ<EFBFBD><D2BB><EFBFBD>֣<EFBFBD><D6A3>Ƿ<EFBFBD><C7B7>ظ<EFBFBD>λ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD>false<73><65><EFBFBD><EFBFBD>ǿ<EFBFBD><C7BF>ת<EFBFBD><D7AA>Ϊbool<6F><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
return ( ( bool ) strstr ( ESP8266_Fram_Record_Struct.Data_RX_BUF, ack1 ) );
|
|
||||||
|
|
||||||
else
|
|
||||||
return ( ( bool ) strstr ( ESP8266_Fram_Record_Struct.Data_RX_BUF, ack2 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//<2F><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
|
||||||
void ESP8266_Rst(void)
|
|
||||||
{
|
|
||||||
// ESP8266_RST_Pin_SetL;
|
|
||||||
// delay_ms(500);
|
|
||||||
// ESP8266_RST_Pin_SetH;
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//<2F><><EFBFBD>ͻָ<CDBB><D6B8><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>ģ<EEBDAB><C4A3><EFBFBD>ָ<EFBFBD><D6B8>ɳ<EFBFBD><C9B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
void ESP8266_ATE0(void)
|
|
||||||
{
|
|
||||||
char count=0;
|
|
||||||
delay_ms(1000);
|
|
||||||
while(count < 10)
|
|
||||||
{
|
|
||||||
if(ESP8266_Send_AT_Cmd("ATE0","OK",NULL,500))
|
|
||||||
{
|
|
||||||
printf("OK\r\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
++ count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//<2F><><EFBFBD>ͻָ<CDBB><D6B8><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>ģ<EEBDAB><C4A3><EFBFBD>ָ<EFBFBD><D6B8>ɳ<EFBFBD><C9B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
void ESP8266_AT_Restore(void)
|
|
||||||
{
|
|
||||||
char count=0;
|
|
||||||
delay_ms(1000);
|
|
||||||
while(count < 10)
|
|
||||||
{
|
|
||||||
if(ESP8266_Send_AT_Cmd("AT+RESTORE","OK",NULL,500))
|
|
||||||
{
|
|
||||||
printf("OK\r\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
++ count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//ѡ<><D1A1>ESP8266<36>Ĺ<EFBFBD><C4B9><EFBFBD>ģʽ
|
|
||||||
// enumMode ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
|
|
||||||
//<2F>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>true<75><65>ʧ<EFBFBD>ܷ<EFBFBD><DCB7><EFBFBD>false
|
|
||||||
bool ESP8266_Net_Mode_Choose(ENUM_Net_ModeTypeDef enumMode)
|
|
||||||
{
|
|
||||||
switch ( enumMode )
|
|
||||||
{
|
|
||||||
case STA:
|
|
||||||
return ESP8266_Send_AT_Cmd ( "AT+CWMODE=1", "OK", "no change", 2500 );
|
|
||||||
|
|
||||||
case AP:
|
|
||||||
return ESP8266_Send_AT_Cmd ( "AT+CWMODE=2", "OK", "no change", 2500 );
|
|
||||||
|
|
||||||
case STA_AP:
|
|
||||||
return ESP8266_Send_AT_Cmd ( "AT+CWMODE=3", "OK", "no change", 2500 );
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//ESP8266<36><36><EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD><E2B2BF>WIFI
|
|
||||||
//pSSID WiFi<46>ʺ<EFBFBD>
|
|
||||||
//pPassWord WiFi<46><69><EFBFBD><EFBFBD>
|
|
||||||
//<2F><><EFBFBD>óɹ<C3B3><C9B9><EFBFBD><EFBFBD><EFBFBD>true <20><>֮false
|
|
||||||
bool ESP8266_JoinAP( char * pSSID, char * pPassWord)
|
|
||||||
{
|
|
||||||
char cCmd [120];
|
|
||||||
|
|
||||||
sprintf ( cCmd, "AT+CWJAP=\"%s\",\"%s\"", pSSID, pPassWord );
|
|
||||||
return ESP8266_Send_AT_Cmd( cCmd, "OK", NULL, 5000 );
|
|
||||||
}
|
|
||||||
|
|
||||||
//ESP8266 <><CDB8>ʹ<EFBFBD><CAB9>
|
|
||||||
//enumEnUnvarnishTx <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>bool<6F><6C><EFBFBD><EFBFBD>
|
|
||||||
//<2F><><EFBFBD>óɹ<C3B3><C9B9><EFBFBD><EFBFBD><EFBFBD>true<75><65><EFBFBD><EFBFBD>֮false
|
|
||||||
bool ESP8266_Enable_MultipleId (FunctionalState enumEnUnvarnishTx )
|
|
||||||
{
|
|
||||||
char cStr [20];
|
|
||||||
|
|
||||||
sprintf ( cStr, "AT+CIPMUX=%d", ( enumEnUnvarnishTx ? 1 : 0 ) );
|
|
||||||
|
|
||||||
return ESP8266_Send_AT_Cmd ( cStr, "OK", 0, 500 );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//ESP8266 <20><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
//enumE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
//ip <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP
|
|
||||||
//ComNum <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|
||||||
//id<69><64><EFBFBD><EFBFBD><EFBFBD>Ӻţ<D3BA>ȷ<EFBFBD><C8B7>ͨ<EFBFBD>Ų<EFBFBD><C5B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
//<2F><><EFBFBD>óɹ<C3B3><C9B9><EFBFBD><EFBFBD><EFBFBD>true<75><65><EFBFBD><EFBFBD>֮fasle
|
|
||||||
bool ESP8266_Link_Server(ENUM_NetPro_TypeDef enumE, char * ip, char * ComNum, ENUM_ID_NO_TypeDef id)
|
|
||||||
{
|
|
||||||
char cStr [100] = { 0 }, cCmd [120];
|
|
||||||
|
|
||||||
switch ( enumE )
|
|
||||||
{
|
|
||||||
case enumTCP:
|
|
||||||
sprintf ( cStr, "\"%s\",\"%s\",%s", "TCP", ip, ComNum );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case enumUDP:
|
|
||||||
sprintf ( cStr, "\"%s\",\"%s\",%s", "UDP", ip, ComNum );
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( id < 5 )
|
|
||||||
sprintf ( cCmd, "AT+CIPSTART=%d,%s", id, cStr);
|
|
||||||
|
|
||||||
else
|
|
||||||
sprintf ( cCmd, "AT+CIPSTART=%s", cStr );
|
|
||||||
|
|
||||||
return ESP8266_Send_AT_Cmd ( cCmd, "OK", "ALREAY CONNECT", 4000 );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//<><CDB8>ʹ<EFBFBD><CAB9>
|
|
||||||
//<2F><><EFBFBD>óɹ<C3B3><C9B9><EFBFBD><EFBFBD><EFBFBD>true<75><65> <20><>֮false
|
|
||||||
bool ESP8266_UnvarnishSend ( void )
|
|
||||||
{
|
|
||||||
if (!ESP8266_Send_AT_Cmd ( "AT+CIPMODE=1", "OK", 0, 500 ))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return
|
|
||||||
ESP8266_Send_AT_Cmd( "AT+CIPSEND", "OK", ">", 500 );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//ESP8266<36><36><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
||||||
//enumEnUnvarnishTx<54>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><CDB8>ģʽ
|
|
||||||
//pStr<74>ַ<EFBFBD><D6B7><EFBFBD>
|
|
||||||
//ulStrLength<74>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
//ucId <20><><EFBFBD>Ӻ<EFBFBD>
|
|
||||||
//<2F><><EFBFBD>óɹ<C3B3><C9B9><EFBFBD><EFBFBD><EFBFBD>true<75><65> <20><>֮false
|
|
||||||
bool ESP8266_SendString(FunctionalState enumEnUnvarnishTx, char * pStr, uint32_t ulStrLength, ENUM_ID_NO_TypeDef ucId )
|
|
||||||
{
|
|
||||||
char cStr [20];
|
|
||||||
bool bRet = false;
|
|
||||||
|
|
||||||
|
|
||||||
if ( enumEnUnvarnishTx )
|
|
||||||
{
|
|
||||||
ESP8266_USART ( "%s", pStr );
|
|
||||||
|
|
||||||
bRet = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( ucId < 5 )
|
|
||||||
sprintf ( cStr, "AT+CIPSEND=%d,%d", ucId, ulStrLength + 2 );
|
|
||||||
else
|
|
||||||
sprintf ( cStr, "AT+CIPSEND=%d", ulStrLength + 2 );
|
|
||||||
|
|
||||||
ESP8266_Send_AT_Cmd ( cStr, "> ", 0, 1000 );
|
|
||||||
|
|
||||||
bRet = ESP8266_Send_AT_Cmd ( pStr, "SEND OK", 0, 1000 );
|
|
||||||
}
|
|
||||||
|
|
||||||
return bRet;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//ESP8266<36>˳<EFBFBD><EFBFBD><CDB8>ģʽ
|
|
||||||
void ESP8266_ExitUnvarnishSend ( void )
|
|
||||||
{
|
|
||||||
delay_ms(1000);
|
|
||||||
ESP8266_USART( "+++" );
|
|
||||||
delay_ms( 500 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//ESP8266 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
|
||||||
//<2F><><EFBFBD><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD>ȡ״̬ʧ<CCAC><CAA7>
|
|
||||||
//<2F><><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ip
|
|
||||||
//<2F><><EFBFBD><EFBFBD>3<EFBFBD><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
//<2F><><EFBFBD><EFBFBD>4<EFBFBD><34>ʧȥ<CAA7><C8A5><EFBFBD><EFBFBD>
|
|
||||||
uint8_t ESP8266_Get_LinkStatus ( void )
|
|
||||||
{
|
|
||||||
if (ESP8266_Send_AT_Cmd( "AT+CIPSTATUS", "OK", 0, 500 ) )
|
|
||||||
{
|
|
||||||
if ( strstr ( ESP8266_Fram_Record_Struct.Data_RX_BUF, "STATUS:2\r\n" ) )
|
|
||||||
return 2;
|
|
||||||
|
|
||||||
else if ( strstr ( ESP8266_Fram_Record_Struct.Data_RX_BUF, "STATUS:3\r\n" ) )
|
|
||||||
return 3;
|
|
||||||
|
|
||||||
else if ( strstr ( ESP8266_Fram_Record_Struct.Data_RX_BUF, "STATUS:4\r\n" ) )
|
|
||||||
return 4;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *itoa( int value, char *string, int radix )
|
|
||||||
{
|
|
||||||
int i, d;
|
|
||||||
int flag = 0;
|
|
||||||
char *ptr = string;
|
|
||||||
|
|
||||||
/* This implementation only works for decimal numbers. */
|
|
||||||
if (radix != 10)
|
|
||||||
{
|
|
||||||
*ptr = 0;
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!value)
|
|
||||||
{
|
|
||||||
*ptr++ = 0x30;
|
|
||||||
*ptr = 0;
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if this is a negative value insert the minus sign. */
|
|
||||||
if (value < 0)
|
|
||||||
{
|
|
||||||
*ptr++ = '-';
|
|
||||||
|
|
||||||
/* Make the value positive. */
|
|
||||||
value *= -1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 10000; i > 0; i /= 10)
|
|
||||||
{
|
|
||||||
d = value / i;
|
|
||||||
|
|
||||||
if (d || flag)
|
|
||||||
{
|
|
||||||
*ptr++ = (char)(d + 0x30);
|
|
||||||
value -= (d * i);
|
|
||||||
flag = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Null terminate the string. */
|
|
||||||
*ptr = 0;
|
|
||||||
|
|
||||||
return string;
|
|
||||||
|
|
||||||
} /* NCL_Itoa */
|
|
||||||
|
|
||||||
|
|
||||||
void USART_printf ( char * Data, ... )
|
|
||||||
{
|
|
||||||
const char *s;
|
|
||||||
int d;
|
|
||||||
char buf[16];
|
|
||||||
uint8_t ch = 0;
|
|
||||||
|
|
||||||
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, Data);
|
|
||||||
|
|
||||||
while ( * Data != 0 ) // <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<C7B7><F1B5BDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
{
|
|
||||||
if ( * Data == 0x5c ) //'\'
|
|
||||||
{
|
|
||||||
switch ( *++Data )
|
|
||||||
{
|
|
||||||
case 'r': //<2F>س<EFBFBD><D8B3><EFBFBD>
|
|
||||||
ch = 0x0d;
|
|
||||||
HAL_UART_Transmit(&huart3, (uint8_t *)&ch, 1, 0xFFFF);
|
|
||||||
Data ++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'n': //<2F><><EFBFBD>з<EFBFBD>
|
|
||||||
ch = 0x0a;
|
|
||||||
HAL_UART_Transmit(&huart3, (uint8_t *)&ch, 1, 0xFFFF);
|
|
||||||
Data ++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
Data ++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else if ( * Data == '%')
|
|
||||||
{
|
|
||||||
switch ( *++Data )
|
|
||||||
{
|
|
||||||
case 's': //<2F>ַ<EFBFBD><D6B7><EFBFBD>
|
|
||||||
s = va_arg(ap, const char *);
|
|
||||||
for ( ; *s; s++)
|
|
||||||
{
|
|
||||||
HAL_UART_Transmit(&huart3, (uint8_t *)s, 1, 0xFFFF);
|
|
||||||
while( __HAL_UART_GET_FLAG(&huart3, UART_FLAG_TXE) == false);
|
|
||||||
}
|
|
||||||
Data++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'd':
|
|
||||||
//ʮ<><CAAE><EFBFBD><EFBFBD>
|
|
||||||
d = va_arg(ap, int);
|
|
||||||
itoa(d, buf, 10);
|
|
||||||
for (s = buf; *s; s++)
|
|
||||||
{
|
|
||||||
HAL_UART_Transmit(&huart3, (uint8_t *)s, 1, 0xFFFF);
|
|
||||||
while( __HAL_UART_GET_FLAG(&huart3, UART_FLAG_TXE) == false);
|
|
||||||
}
|
|
||||||
Data++;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Data++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
HAL_UART_Transmit(&huart3, (uint8_t *)Data, 1, 0xFFFF);
|
|
||||||
Data++;
|
|
||||||
while( __HAL_UART_GET_FLAG(&huart3, UART_FLAG_TXE) == false);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//<2F><><EFBFBD><EFBFBD>ΪESP8266MQTT<54><54><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
|
||||||
|
|
||||||
/*
|
|
||||||
*MQTT<54><54><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*LinkID <20><><EFBFBD><EFBFBD>ID,Ŀǰֻ֧<D6BB><D6A7>0
|
|
||||||
*scheme <20><><EFBFBD>ӷ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>MQTT over TCP,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ1
|
|
||||||
*client_id MQTTclientID <20><><EFBFBD>ڱ<EFBFBD>־client<6E><74><EFBFBD><EFBFBD>
|
|
||||||
*username <20><><EFBFBD>ڵ<EFBFBD>¼ MQTT <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> username
|
|
||||||
*password <20><><EFBFBD>ڵ<EFBFBD>¼ MQTT <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> password
|
|
||||||
*cert_key_ID ֤<><D6A4> ID, Ŀǰ֧<C7B0><D6A7>һ<EFBFBD><D2BB> cert ֤<><D6A4>, <20><><EFBFBD><EFBFBD>Ϊ 0
|
|
||||||
*CA_ID Ŀǰ֧<C7B0><D6A7>һ<EFBFBD><D2BB> CA ֤<><D6A4>, <20><><EFBFBD><EFBFBD>Ϊ 0
|
|
||||||
*path <20><>Դ·<D4B4><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ""
|
|
||||||
*<2A><><EFBFBD>óɹ<C3B3><C9B9><EFBFBD><EFBFBD><EFBFBD>true <20><>֮false
|
|
||||||
*/
|
|
||||||
bool ESP8266_MQTTUSERCFG( char * pClient_Id, char * pUserName,char * PassWord)
|
|
||||||
{
|
|
||||||
char cCmd [120];
|
|
||||||
sprintf ( cCmd, "AT+MQTTUSERCFG=0,1,\"%s\",\"%s\",\"%s\",0,0,\"\"", pClient_Id,pUserName,PassWord );
|
|
||||||
return ESP8266_Send_AT_Cmd( cCmd, "OK", NULL, 500 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
*<2A><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>MQTT<54><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
*LinkID <20><><EFBFBD><EFBFBD>ID,Ŀǰֻ֧<D6BB><D6A7>0
|
|
||||||
*IP<49><50>MQTT<54><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD>Ӧ<EFBFBD><D3A6>IP<49><50>ַ
|
|
||||||
*ComNum MQTT<54><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD>Ӧ<EFBFBD>Ķ˿ںţ<DABA>һ<EFBFBD><D2BB>Ϊ1883
|
|
||||||
*<2A><><EFBFBD>óɹ<C3B3><C9B9><EFBFBD><EFBFBD><EFBFBD>true <20><>֮false
|
|
||||||
*/
|
|
||||||
bool ESP8266_MQTTCONN( char * Ip, int Num)
|
|
||||||
{
|
|
||||||
char cCmd [120];
|
|
||||||
sprintf ( cCmd,"AT+MQTTCONN=0,\"%s\",%d,0", Ip,Num);
|
|
||||||
return ESP8266_Send_AT_Cmd( cCmd, "OK", NULL, 500 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
*<2A><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD> MQTT <20><><EFBFBD><EFBFBD>, <20><><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD>ζ<EFBFBD><CEB6>IJ<EFBFBD>ͬ topic
|
|
||||||
*LinkID <20><><EFBFBD><EFBFBD>ID,Ŀǰֻ֧<D6BB><D6A7>0
|
|
||||||
*Topic <20><><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD><D6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪTopic
|
|
||||||
*Qosֵ<73><D6B5>һ<EFBFBD><D2BB>Ϊ0<CEAA><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ1
|
|
||||||
*<2A><><EFBFBD>óɹ<C3B3><C9B9><EFBFBD><EFBFBD><EFBFBD>true <20><>֮false
|
|
||||||
*/
|
|
||||||
bool ESP8266_MQTTSUB(char * Topic)
|
|
||||||
{
|
|
||||||
char cCmd [120];
|
|
||||||
sprintf ( cCmd, "AT+MQTTSUB=0,\"%s\",1",Topic );
|
|
||||||
return ESP8266_Send_AT_Cmd( cCmd, "OK", NULL, 500 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
*<2A><>LinkID<49><44>ͨ<EFBFBD><CDA8> topic <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> data, <20><><EFBFBD><EFBFBD> data Ϊ<>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
||||||
*LinkID <20><><EFBFBD><EFBFBD>ID,Ŀǰֻ֧<D6BB><D6A7>0
|
|
||||||
*Topic <20><><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD><D6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪTopic
|
|
||||||
*data<74><61><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
||||||
*<2A><><EFBFBD>óɹ<C3B3><C9B9><EFBFBD><EFBFBD><EFBFBD>true <20><>֮false
|
|
||||||
*/
|
|
||||||
bool ESP8266_MQTTPUB( char * Topic,char *temp)
|
|
||||||
{
|
|
||||||
char cCmd [512];
|
|
||||||
sprintf (cCmd, "AT+MQTTPUB=0,\"%s\",\"%s\",0,0", Topic ,temp);
|
|
||||||
return ESP8266_Send_AT_Cmd( cCmd, "OK", NULL, 1000 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
*<2A>ر<EFBFBD> MQTT Client Ϊ LinkID <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD>ͷ<EFBFBD><CDB7>ڲ<EFBFBD>ռ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD>Դ
|
|
||||||
*LinkID <20><><EFBFBD><EFBFBD>ID,Ŀǰֻ֧<D6BB><D6A7>0
|
|
||||||
*Topic <20><><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD><D6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪTopic
|
|
||||||
*data<74><61><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
||||||
*<2A><><EFBFBD>óɹ<C3B3><C9B9><EFBFBD><EFBFBD><EFBFBD>true <20><>֮false
|
|
||||||
*/
|
|
||||||
bool ESP8266_MQTTCLEAN(void)
|
|
||||||
{
|
|
||||||
char cCmd [120];
|
|
||||||
sprintf ( cCmd, "AT+MQTTCLEAN=0");
|
|
||||||
return ESP8266_Send_AT_Cmd( cCmd, "OK", NULL, 500 );
|
|
||||||
}
|
|
||||||
|
|
||||||
//ESP8266<36><36><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
||||||
//enumEnUnvarnishTx<54>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><CDB8>ģʽ
|
|
||||||
//pStr<74>ַ<EFBFBD><D6B7><EFBFBD>
|
|
||||||
//ulStrLength<74>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
//ucId <20><><EFBFBD>Ӻ<EFBFBD>
|
|
||||||
//<2F><><EFBFBD>óɹ<C3B3><C9B9><EFBFBD><EFBFBD><EFBFBD>true<75><65> <20><>֮false
|
|
||||||
bool MQTT_SendString(char * pTopic,char *temp2)
|
|
||||||
{
|
|
||||||
bool bRet = false;
|
|
||||||
|
|
||||||
bRet = ESP8266_MQTTPUB(pTopic,temp2);
|
|
||||||
|
|
||||||
return bRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
#ifndef __ESP8266_H
|
|
||||||
#define __ESP8266_H
|
|
||||||
|
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#if defined ( __CC_ARM )
|
|
||||||
#pragma anon_unions
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//ESP8266ģʽѡ<CABD><D1A1>
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
STA,
|
|
||||||
AP,
|
|
||||||
STA_AP
|
|
||||||
}ENUM_Net_ModeTypeDef;
|
|
||||||
|
|
||||||
//<2F><><EFBFBD>紫<EFBFBD><E7B4AB><EFBFBD><EFBFBD>Э<EFBFBD>飬ö<E9A3AC><C3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
typedef enum{
|
|
||||||
enumTCP,
|
|
||||||
enumUDP,
|
|
||||||
} ENUM_NetPro_TypeDef;
|
|
||||||
//<2F><><EFBFBD>Ӻţ<D3BA>ָ<EFBFBD><D6B8>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>Ӻſ<D3BA><C5BF>Է<EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬһ<CDAC>˿ڶ<CBBF><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
typedef enum{
|
|
||||||
Multiple_ID_0 = 0,
|
|
||||||
Multiple_ID_1 = 1,
|
|
||||||
Multiple_ID_2 = 2,
|
|
||||||
Multiple_ID_3 = 3,
|
|
||||||
Multiple_ID_4 = 4,
|
|
||||||
Single_ID_0 = 5,
|
|
||||||
} ENUM_ID_NO_TypeDef;
|
|
||||||
|
|
||||||
#define ESP8266_RST_Pin GPIO_PIN_4 //<2F><>λ<EFBFBD>ܽ<EFBFBD>
|
|
||||||
#define ESP8266_RST_Pin_Port GPIOA //<2F><>λ
|
|
||||||
|
|
||||||
#define ESP8266_CH_PD_Pin GPIO_PIN_5 //ʹ<>ܹܽ<DCB9>
|
|
||||||
#define ESP8266_CH_PD_Pin_Port GPIOA //ʹ<>ܶ˿<DCB6>
|
|
||||||
|
|
||||||
|
|
||||||
#define ESP8266_RST_Pin_SetH HAL_GPIO_WritePin(ESP8266_RST_Pin_Port, ESP8266_RST_Pin, GPIO_PIN_SET)
|
|
||||||
#define ESP8266_RST_Pin_SetL HAL_GPIO_WritePin(ESP8266_RST_Pin_Port, ESP8266_RST_Pin, GPIO_PIN_RESET)
|
|
||||||
|
|
||||||
|
|
||||||
#define ESP8266_CH_PD_Pin_SetH HAL_GPIO_WritePin(ESP8266_CH_PD_Pin_Port,ESP8266_CH_PD_Pin, GPIO_PIN_SET)
|
|
||||||
#define ESP8266_CH_PD_Pin_SetL HAL_GPIO_WritePin(ESP8266_CH_PD_Pin_Port,ESP8266_CH_PD_Pin, GPIO_PIN_RESET)
|
|
||||||
|
|
||||||
|
|
||||||
#define ESP8266_USART(fmt, ...) USART_printf (fmt, ##__VA_ARGS__)
|
|
||||||
#define PC_USART(fmt, ...) printf(fmt, ##__VA_ARGS__) //<2F><><EFBFBD>Ǵ<EFBFBD><C7B4>ڴ<EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31>ִ<EFBFBD><D6B4>printf<74><66><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD>ִ<EFBFBD><D6B4>fput<75><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD>printf<74><66>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define RX_BUF_MAX_LEN 1024 //<2F><><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>
|
|
||||||
extern struct STRUCT_USART_Fram //<2F><><EFBFBD><EFBFBD>֡<EFBFBD>ṹ<EFBFBD><E1B9B9>
|
|
||||||
{
|
|
||||||
char Data_RX_BUF[RX_BUF_MAX_LEN];
|
|
||||||
union
|
|
||||||
{
|
|
||||||
__IO uint16_t InfAll;
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
__IO uint16_t FramLength :15; // 14:0
|
|
||||||
__IO uint16_t FramFinishFlag :1; // 15
|
|
||||||
}InfBit;
|
|
||||||
};
|
|
||||||
|
|
||||||
}ESP8266_Fram_Record_Struct;
|
|
||||||
|
|
||||||
|
|
||||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>TCP<43><50><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
|
|
||||||
void ESP8266_Init(uint32_t bound);
|
|
||||||
void ESP8266_ATE0(void);
|
|
||||||
bool ESP8266_Send_AT_Cmd(char *cmd,char *ack1,char *ack2,uint32_t time);
|
|
||||||
void ESP8266_Rst(void);
|
|
||||||
bool ESP8266_Net_Mode_Choose(ENUM_Net_ModeTypeDef enumMode);
|
|
||||||
bool ESP8266_JoinAP( char * pSSID, char * pPassWord );
|
|
||||||
bool ESP8266_Enable_MultipleId ( FunctionalState enumEnUnvarnishTx );
|
|
||||||
bool ESP8266_Link_Server(ENUM_NetPro_TypeDef enumE, char * ip, char * ComNum, ENUM_ID_NO_TypeDef id);
|
|
||||||
bool ESP8266_SendString(FunctionalState enumEnUnvarnishTx, char * pStr, uint32_t ulStrLength, ENUM_ID_NO_TypeDef ucId );
|
|
||||||
bool ESP8266_UnvarnishSend ( void );
|
|
||||||
void ESP8266_ExitUnvarnishSend ( void );
|
|
||||||
uint8_t ESP8266_Get_LinkStatus ( void );
|
|
||||||
void USART_printf( char * Data, ... );
|
|
||||||
|
|
||||||
//MQTT<54><54><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
|
|
||||||
bool ESP8266_MQTTUSERCFG( char * pClient_Id, char * pUserName,char * PassWord);
|
|
||||||
bool ESP8266_MQTTCONN( char * Ip, int Num);
|
|
||||||
bool ESP8266_MQTTSUB(char * Topic);
|
|
||||||
bool ESP8266_MQTTPUB( char * Topic,char *temp);
|
|
||||||
bool ESP8266_MQTTCLEAN(void);
|
|
||||||
bool MQTT_SendString(char * pTopic,char *temp2);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
#include "mqtt.h"
|
|
||||||
|
|
||||||
void ESP8266_STA_MQTTClient_Init(void)
|
|
||||||
{
|
|
||||||
char str[] = "{\"deviceNum\":\"863488052352477\"\,\"relayStatus\":0\,\
|
|
||||||
\"lightStatus\":0\,\"isOnline\":1\,\"rssi\":-54\,\"deviceTemperature\":40\,\"airTemperature\":0\,\
|
|
||||||
\"airHumidity\":0\,\"triggerSource\":0\,\"brightness\":11\,\"lightInterval\":432\,\
|
|
||||||
\"lightMode\":0\,\"fadeTime\":259\,\"red\":255\,\"green\":0\,\"blue\":0}";
|
|
||||||
|
|
||||||
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ESP8266<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\r\n");
|
|
||||||
ESP8266_ATE0();//ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
ESP8266_Net_Mode_Choose(STA);
|
|
||||||
while(!ESP8266_JoinAP(WIFI_SSID, WIFI_PWD));
|
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
ESP8266_MQTTUSERCFG(WIFI_client_id,WIFI_username,WIFI_password);
|
|
||||||
delay_ms(200);
|
|
||||||
// <20><><EFBFBD><EFBFBD>MQTT<54><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
ESP8266_MQTTCONN( WIFI_MQTTServer_IP, WIFI_MQTTServer_PORT);
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
ESP8266_MQTTSUB( WIFI_MQTTServer_Topic_SUB);
|
|
||||||
printf("\r\nMQTT<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
||||||
|
|
||||||
delay_ms(200);
|
|
||||||
|
|
||||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>MQTT<54><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
if (MQTT_SendString (WIFI_MQTTServer_Topic_PUB, str))
|
|
||||||
{
|
|
||||||
printf("send data to mqtt server success\r\n");
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
printf("send data to mqtt server error\r\n");
|
|
||||||
printf(": %s\r\n", str);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
#ifndef __MQTT_H
|
|
||||||
#define __MQTT_H
|
|
||||||
|
|
||||||
#include "main.h"
|
|
||||||
#include "esp8266.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
*<2A><><EFBFBD>²<EFBFBD><C2B2><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<DEB8><C4B2>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD>ù<EFBFBD>
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#define WIFI_SSID "DianJing" //wifi<66><69>
|
|
||||||
#define WIFI_PWD "wzry6666" //wifi<66><69><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
#define WIFI_client_id "50fccfefb50a48b98a93ce27bb04591f" //MQTTclientID <20><><EFBFBD>ڱ<EFBFBD>־client<6E><74><EFBFBD><EFBFBD> <20>256<35>ֽ<EFBFBD>
|
|
||||||
#define WIFI_username "admin" //<2F><><EFBFBD>ڵ<EFBFBD>¼ MQTT <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> username, <20> 64 <20>ֽ<EFBFBD>
|
|
||||||
#define WIFI_password "admin13" //<2F><><EFBFBD>ڵ<EFBFBD>¼ MQTT <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> password, <20> 64 <20>ֽ<EFBFBD>
|
|
||||||
#define WIFI_MQTTServer_IP "106.12.9.213" //MQTT<54><54><EFBFBD>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD>IP
|
|
||||||
#define WIFI_MQTTServer_PORT 1883 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿ں<CBBF>
|
|
||||||
#define WIFI_MQTTServer_Topic_PUB "status" //<2F><><EFBFBD><EFBFBD>MQTT<54><54><EFBFBD><EFBFBD>
|
|
||||||
#define WIFI_MQTTServer_Topic_SUB "status/set/863488052352477" //<2F><><EFBFBD><EFBFBD>MQTT<54><54><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
|
|
||||||
void ESP8266_STA_MQTTClient_Init(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
#include "tcp.h"
|
|
||||||
|
|
||||||
volatile uint8_t TcpClosedFlag = 0;
|
|
||||||
|
|
||||||
void ESP8266_STA_TCPClient_Test(void)
|
|
||||||
{
|
|
||||||
uint8_t res;
|
|
||||||
|
|
||||||
char str[100]={0};
|
|
||||||
ESP8266_ATE0();
|
|
||||||
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ESP8266\r\n");
|
|
||||||
ESP8266_Net_Mode_Choose(STA);
|
|
||||||
while(!ESP8266_JoinAP(User_ESP8266_SSID, User_ESP8266_PWD));
|
|
||||||
ESP8266_Enable_MultipleId ( DISABLE );
|
|
||||||
while(!ESP8266_Link_Server(enumTCP, User_ESP8266_TCPServer_IP, User_ESP8266_TCPServer_PORT, Single_ID_0));
|
|
||||||
while(!ESP8266_UnvarnishSend());
|
|
||||||
printf("\r\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
||||||
while ( 1 )
|
|
||||||
{
|
|
||||||
sprintf (str,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>а<EFBFBD><EFBFBD>ſɿƼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˾" );//<2F><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>TCP<43><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
ESP8266_SendString ( ENABLE, str, 0, Single_ID_0 );
|
|
||||||
delay_ms(1000);
|
|
||||||
if(TcpClosedFlag) //<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD>ʧȥ<CAA7><C8A5><EFBFBD><EFBFBD>
|
|
||||||
{
|
|
||||||
ESP8266_ExitUnvarnishSend(); //<2F>˳<EFBFBD><EFBFBD><CDB8>ģʽ
|
|
||||||
do
|
|
||||||
{
|
|
||||||
res = ESP8266_Get_LinkStatus(); //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>״̬
|
|
||||||
}
|
|
||||||
while(!res);
|
|
||||||
|
|
||||||
if(res == 4) //ȷ<><C8B7>ʧȥ<CAA7><C8A5><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
while (!ESP8266_JoinAP(User_ESP8266_SSID, User_ESP8266_PWD ) );
|
|
||||||
while (!ESP8266_Link_Server(enumTCP, User_ESP8266_TCPServer_IP, User_ESP8266_TCPServer_PORT, Single_ID_0 ) );
|
|
||||||
}
|
|
||||||
while(!ESP8266_UnvarnishSend());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#ifndef __TCP_H
|
|
||||||
#define __TCP_H
|
|
||||||
|
|
||||||
#include "main.h"
|
|
||||||
#include "esp8266.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
*<2A><><EFBFBD>²<EFBFBD><C2B2><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<DEB8><C4B2>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD>ù<EFBFBD>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define User_ESP8266_SSID "miot_default" //wifi<66><69>
|
|
||||||
#define User_ESP8266_PWD "123456789x" //wifi<66><69><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
#define User_ESP8266_TCPServer_IP "192.168.31.16" //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP
|
|
||||||
#define User_ESP8266_TCPServer_PORT "8888" //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿ں<CBBF>
|
|
||||||
|
|
||||||
|
|
||||||
extern volatile uint8_t TcpClosedFlag; //<2F><><EFBFBD><EFBFBD>״̬<D7B4><CCAC>־
|
|
||||||
|
|
||||||
void ESP8266_STA_TCPClient_Test(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user