在人工智能课上拿到了Taurus & Pegasus AI计算机视觉基础开发套件,我们将用它实现可以智能识别垃圾类别的垃圾桶吗,核心板Hi3516DV300主要用于垃圾识别并分类,Hi3861主要用于基础外设的控制。


Hi3861板子的开发

Hi3861实物图

OpenHarmony轻量系统开发入门资料

舵机驱动

基本原理

微处理器产生的 PWM信号脉冲宽度调制信号,可调节信号的占空比 通过信号线进入舵机产生直流偏置电压,与舵机内部的基准电压作比较,电压差的正负输出到电机驱动芯片上,从而决定正反转。

高电平在一个周期(20ms)的持续时间对应的舵机角度可参考如下(以实际调节值为准)

t / ms对应角度 / ^{\circ}
0.50
1.045
5.090
2.0135
2.5180

注意点

注意引脚的功能复用,由于引脚数量有限,往往有多个功能复用一个引脚,在使用引脚时要选择引脚的初始化。套件中舵机的型号为SG90,虽然板子自带有pwm的功能,但在测试过程中该功能无法使舵机工作。

我们可以根据pwm的逻辑直接使用引脚的GPIO功能来完成pwm信号的实现。实现逻辑就是先设置20ms的周期,然后根据所需角度调节GPIO输出高电平的时间,周期其余时间输出低电平即可。

另外还需要注意根据板子结构图选择合适的GPIO引脚。

Hi3861结构图

根据上图还可以控制相应的LED灯的点亮。

OLED屏幕显示

套件中还提供了一块OLED屏,通过基础教程可以很容易的复现出来。

oled演示

成果展示

源代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#include <hi_types_base.h>
#include <stdio.h>
#include <unistd.h>
#include <stdint.h>
#include <string.h>
#include "hi_gpio.h"
#include "hi_io.h"
#include "hi_time.h"
#include "iot_gpio.h"
#include "ohos_init.h" //在//utils/native/lite/include"里,负责系统任务,如SYS_RUN
#include "cmsis_os2.h" //在//kernel/liteos_m/kal/cmsis"里,负责线程,如osThreadAttr_t
#include "iot_i2c.h" //在 "//base/iot_hardware/peripheral/interfaces/kits"里,负责各种接口,如IoTGpioSetOutputVal
#include "iot_gpio.h"
#include "iot_errno.h"
#include "iot_uart.h"
#include "oled_ssd1306.h"

#define AHT20_BAUDRATE (400 * 1000)
#define AHT20_I2C_IDX 13

/*舵机线程*/
static void *Servo_Task(const char *arg)
{
(void)arg;
printf("Enter Servo_Task\n");
int gpio_id[] = {6,7,9,10};
int led_id[] = {2,8,11,12};
printf("1\n");
IoTGpioSetOutputVal(led_id[0],HI_GPIO_VALUE1);
set_angle(1800,gpio_id[0]);
hi_udelay(1000000);
set_angle(2477,gpio_id[0]);
IoTGpioSetOutputVal(led_id[0],HI_GPIO_VALUE0);
printf("2\n");
IoTGpioSetOutputVal(led_id[1],HI_GPIO_VALUE1);
set_angle(1700,gpio_id[1]);
hi_udelay(1000000);
set_angle(2460,gpio_id[1]);
IoTGpioSetOutputVal(led_id[1],HI_GPIO_VALUE0);
printf("3\n");
IoTGpioSetOutputVal(led_id[2],HI_GPIO_VALUE1);
set_angle(1500,gpio_id[2]);
hi_udelay(1000000);
set_angle(2477,gpio_id[2]);
IoTGpioSetOutputVal(led_id[2],HI_GPIO_VALUE0);
printf("4\n");
IoTGpioSetOutputVal(led_id[3],HI_GPIO_VALUE1);
set_angle(1850,gpio_id[3]);
hi_udelay(1000000);
set_angle(2477,gpio_id[3]);
IoTGpioSetOutputVal(led_id[3],HI_GPIO_VALUE0);

//惊喜
for(int i = 0;i<5;i++){
IoTGpioSetOutputVal(led_id[0],HI_GPIO_VALUE1);
set_angle(1800,gpio_id[0]);
IoTGpioSetOutputVal(led_id[1],HI_GPIO_VALUE1);
set_angle(1850,gpio_id[1]);
IoTGpioSetOutputVal(led_id[2],HI_GPIO_VALUE1);
set_angle(1500,gpio_id[2]);
IoTGpioSetOutputVal(led_id[3],HI_GPIO_VALUE1);
set_angle(1850,gpio_id[3]);
hi_udelay(100000);
set_angle(2477,gpio_id[0]);
IoTGpioSetOutputVal(led_id[0],HI_GPIO_VALUE0);
set_angle(2460,gpio_id[1]);
IoTGpioSetOutputVal(led_id[1],HI_GPIO_VALUE0);
set_angle(2477,gpio_id[2]);
IoTGpioSetOutputVal(led_id[2],HI_GPIO_VALUE0);
set_angle(2477,gpio_id[3]);
IoTGpioSetOutputVal(led_id[3],HI_GPIO_VALUE0);
hi_udelay(100000);
}

return NULL;
}

/*设置旋转角度*/
hi_void set_angle(hi_u32 utime, char gpio_id)
{
IoTGpioSetOutputVal(gpio_id,HI_GPIO_VALUE1);
hi_udelay(utime); //单位为微秒

IoTGpioSetOutputVal(gpio_id,HI_GPIO_VALUE0);
hi_udelay(20000-utime);
}


/*oled显示线程*/
static void Oled_Task(const char *arg)
{
printf("Enter Oled_Task\n");
(void)arg;
OledInit();
OledFillScreen(0);
IoTI2cInit(AHT20_I2C_IDX, AHT20_BAUDRATE);
OledShowString(0, 2, "Pursue G-fashion", 1);/* 屏幕第0列2行显示1行 */
OledShowString(5, 4, "Embrace G-life", 1);
return NULL;
}

/*UART线程
static void* Uart_Task(const char* arg)
{
unsigned int len = 0;
//unsigned char uartWriteBuff[] = "hello uart!";
//unsigned int uartReadBuff = 0;
int Identification = 0;
(void)arg;
printf("Enter Uart_Task\n");

IoTGpioInit(1); // 使用GPIO,都需要调用该接口
// 初始化UART配置,115200,数据bit为8,停止位1,奇偶校验为NONE,流控为NONE
IotUartAttribute g_uart_cfg = {115200, 8, 1, IOT_UART_PARITY_NONE, 0,0};
hi_io_set_func(1,HI_IO_FUNC_GPIO_1_UART1_RXD);
IoTUartInit(1, &g_uart_cfg);

//UartWrite(WIFI_IOT_UART_IDX_2, (unsigned char *)uartWriteBuff, sizeof(uartWriteBuff));
printf("Uart reading...\n");
while (1) {
IoTUartRead(1, Identification, sizeof(Identification));
if (Identification != 0) {
printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
printf("Uart read data:%d\n", Identification);
printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
hi_udelay(1200000);
}
else{
usleep(100000);
}
}
return NULL;
}
*/


/*入口函数*/
static void duojiEntry(void)
{
/*GPIO初始化*/
int GPIO[] = {2,6,7,8,9,10,11,12};
char *GPIO_func[] = {"HI_IO_FUNC_GPIO_2_GPIO","HI_IO_FUNC_GPIO_6_GPIO",\
"HI_IO_FUNC_GPIO_7_GPIO","HI_IO_FUNC_GPIO_8_GPIO","HI_IO_FUNC_GPIO_9_GPIO",\
"HI_IO_FUNC_GPIO_10_GPIO","HI_IO_FUNC_GPIO_11_GPIO","HI_IO_FUNC_GPIO_12_GPIO"};
for(int i = 0;i<8;i++)
{
IoTGpioInit(GPIO[i]);
hi_io_set_func(GPIO[i],GPIO_func[i]);
IoTGpioSetDir(GPIO[i], HI_GPIO_DIR_OUT);
}

osThreadAttr_t servo_attr; //定义舵机线程
servo_attr.name = "Servo_Task";
servo_attr.attr_bits = 0U;
servo_attr.cb_mem = NULL;
servo_attr.cb_size = 0U;
servo_attr.stack_mem = NULL;
servo_attr.stack_size = 1024;
servo_attr.priority = osPriorityNormal;
//创建舵机线程并判断是否创建成功
if (osThreadNew((osThreadFunc_t)Servo_Task, NULL, &servo_attr) != NULL) {
printf("\nSucceed to create Servo_Task!\n");
}

osThreadAttr_t Oled_attr; //定义oled显示线程
Oled_attr.name = "Oled_Task";
Oled_attr.attr_bits = 0U;
Oled_attr.cb_mem = NULL;
Oled_attr.cb_size = 0U;
Oled_attr.stack_mem = NULL;
Oled_attr.stack_size = 4096; /* 任务大小4096 */
Oled_attr.priority = osPriorityNormal;

//创建oled显示线程并判断是否创建成功
if (osThreadNew((osThreadFunc_t)Oled_Task, NULL, &Oled_attr) != NULL) {
printf("Succeed to create Oled_Task!\n");
}

/*
osThreadAttr_t Uart_attr; //定义UART线程
Uart_attr.name = "Uart_Task";
Uart_attr.attr_bits = 0U;
Uart_attr.cb_mem = NULL;
Uart_attr.cb_size = 0U;
Uart_attr.stack_mem = NULL;
Uart_attr.stack_size = 4096; // 堆栈大小
Uart_attr.priority = osPriorityNormal; // 优先级

//创建UART线程并判断是否创建成功
if (osThreadNew((osThreadFunc_t)Uart_Task, NULL, &Uart_attr) != NULL) {
printf("Succeed to create Uart_Task!\n");
}
*/
}
SYS_RUN(duojiEntry);

BUILD.gn文件设置如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
static_library("duoji") {
sources = [
"hal_iot_gpio_ex.c",
"duoji.c",
"oled_ssd1306.c",
]

include_dirs = [
"//utils/native/lite/include",
"//kernel/liteos_m/kal/cmsis",
"//base/iot_hardware/peripheral/interfaces/kits",
]
}

辅助代码如下,与上面的文件放在同一个文件夹即可。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "iot_errno.h"
#include "iot_gpio_ex.h"
#include "hi_gpio.h"
#include "hi_io.h"
#include "hi_task.h"
#include "hi_types_base.h"


unsigned int IoSetPull(unsigned int id, IotIoPull val)
{
if (id >= HI_GPIO_IDX_MAX) {
return IOT_FAILURE;
}
return hi_io_set_pull((hi_io_name)id, (hi_io_pull)val);
}

unsigned int IoSetFunc(unsigned int id, unsigned char val)
{
if (id >= HI_GPIO_IDX_MAX) {
return IOT_FAILURE;
}
return hi_io_set_func((hi_io_name)id, val);
}

unsigned int TaskMsleep(unsigned int ms)
{
if (ms <= 0) {
return IOT_FAILURE;
}
return hi_sleep((hi_u32)ms);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#include <stddef.h>
#include <stdio.h>
#include "ohos_types.h"
#include "iot_errno.h"
#include "iot_gpio.h"
#include "iot_i2c.h"
#include "iot_gpio_ex.h"
#include "oled_fonts.h"
#include "oled_ssd1306.h"

#define OLED_I2C_IDX 0

#define OLED_WIDTH (128)
#define OLED_I2C_ADDR 0x78 // 默认地址为 0x78
#define OLED_I2C_CMD 0x00 // 0000 0000 写命令
#define OLED_I2C_DATA 0x40 // 0100 0000(0x40) 写数据
#define OLED_I2C_BAUDRATE (400 * 1000) // 400k

#define DELAY_100_MS (100 * 1000)

typedef struct {
/** Pointer to the buffer storing data to send */
unsigned char *sendBuf;
/** Length of data to send */
unsigned int sendLen;
/** Pointer to the buffer for storing data to receive */
unsigned char *receiveBuf;
/** Length of data received */
unsigned int receiveLen;
} IotI2cData;

static uint32_t I2cWiteByte(uint8_t regAddr, uint8_t byte)
{
unsigned int id = OLED_I2C_IDX;
uint8_t buffer[] = {regAddr, byte};
IotI2cData i2cData = {0};

i2cData.sendBuf = buffer;
i2cData.sendLen = sizeof(buffer) / sizeof(buffer[0]);

return IoTI2cWrite(id, OLED_I2C_ADDR, i2cData.sendBuf, i2cData.sendLen);
}

/**
* @brief Write a command byte to OLED device.
*
* @param cmd the commnad byte to be writen.
* @return Returns {@link IOT_SUCCESS} if the operation is successful;
* returns an error code defined in {@link wifiiot_errno.h} otherwise.
*/
static uint32_t WriteCmd(uint8_t cmd)
{
return I2cWiteByte(OLED_I2C_CMD, cmd);
}

/**
* @brief Write a data byte to OLED device.
*
* @param cmd the data byte to be writen.
* @return Returns {@link IOT_SUCCESS} if the operation is successful;
* returns an error code defined in {@link wifiiot_errno.h} otherwise.
*/
static uint32_t WriteData(uint8_t data)
{
return I2cWiteByte(OLED_I2C_DATA, data);
}

/**
* @brief ssd1306 OLED Initialize.
*/
uint32_t OledInit(void)
{
static const uint8_t initCmds[] = {
0xAE, // --display off
0x00, // ---set low column address
0x10, // ---set high column address
0x40, // --set start line address
0xB0, // --set page address
0x81, // contract control
0xFF, // --128
0xA1, // set segment remap
0xA6, // --normal / reverse
0xA8, // --set multiplex ratio(1 to 64)
0x3F, // --1/32 duty
0xC8, // Com scan direction
0xD3, // -set display offset
0x00,
0xD5, // set osc division
0x80,
0xD8, // set area color mode off
0x05,
0xD9, // Set Pre-Charge Period
0xF1,
0xDA, // set com pin configuartion
0x12,
0xDB, // set Vcomh
0x30,
0x8D, // set charge pump enable
0x14,
0xAF, // --turn on oled panel
};

IoTGpioInit(13); /* 初始化gpio13 */
IoSetFunc(13, 6); /* gpio13使用6功能 */
IoTGpioInit(14); /* 初始化gpio14 */
IoSetFunc(14, 6); /* gpio14使用6功能 */

IoTI2cInit(0, OLED_I2C_BAUDRATE);

for (size_t i = 0; i < ARRAY_SIZE(initCmds); i++) {
uint32_t status = WriteCmd(initCmds[i]);
if (status != IOT_SUCCESS) {
return status;
}
}
return IOT_SUCCESS;
}

void OledSetPosition(uint8_t x, uint8_t y)
{
WriteCmd(0xb0 + y);
WriteCmd(((x & 0xf0) >> 4) | 0x10); /* 在0xf0右移4位,与0x10或,实现了写数据 */
WriteCmd(x & 0x0f);
}

/* 全屏填充 */
void OledFillScreen(uint8_t fillData)
{
for (uint8_t m = 0; m < 8; m++) { /* 循环8次实现横屏填充 */
WriteCmd(0xb0 + m);
WriteCmd(0x00);
WriteCmd(0x10);

for (uint8_t n = 0; n < 128; n++) { /* 循环128次实现竖屏填充 */
WriteData(fillData);
}
}
}

/**
* @brief 8*16 typeface
* @param x: write positon start from x axis
* @param y: write positon start from y axis
* @param ch: write data
* @param font: selected font
*/
void OledShowChar(uint8_t x, uint8_t y, uint8_t ch, Font font)
{
uint8_t c = ch - ' '; // 得到偏移后的值
uint8_t b = x;
uint8_t d = y;
if (b > OLED_WIDTH - 1) {
b = 0;
d = d + 2; /* 得到偏移后的值2 */
}

if (font == FONT8_X16) {
OledSetPosition(b, d);
for (uint8_t i = 0; i < 8; i++) { /* 循环8次实现横屏填充 */
WriteData(g_f8X16[c * 16 + i]); /* 循环16次实现横屏填充 */
}

OledSetPosition(b, d + 1);
for (uint8_t i = 0; i < 8; i++) { /* 循环8次实现横屏填充 */
WriteData(g_f8X16[c * 16 + i + 8]); /* 循环16次实现横屏填充8列 */
}
} else {
OledSetPosition(b, d);
for (uint8_t i = 0; i < 6; i++) { /* 循环6次实现横屏填充 */
WriteData(g_f6X8[c][i]);
}
}
}

void OledShowString(uint8_t x, uint8_t y, const char* str, Font font)
{
uint8_t j = 0;
uint8_t b = x;
uint8_t d = y;
if (str == NULL) {
printf("param is NULL,Please check!!!\r\n");
return;
}

while (str[j]) {
OledShowChar(b, d, str[j], font);
b += 8; /* 循环8次实现横屏填充 */
if (b > 120) { /* 循环120次实现横屏填充 */
b = 0;
d += 2; /* 循环2次实现横屏填充 */
}
j++;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
#ifndef IOT_GPIO_EX_H
#define IOT_GPIO_EX_H

/**
* @brief Enumerates GPIO pull-up or pull-down settings.
*/
typedef enum {
/** No pull */
IOT_IO_PULL_NONE,
/** Pull-up */
IOT_IO_PULL_UP,
/** Pull-down */
IOT_IO_PULL_DOWN,
/** Maximum value */
IOT_IO_PULL_MAX,
} IotIoPull;

/**
* @ingroup iot_io
*
* GPIO pin ID. CNcomment:IO硬件管脚编号。CNend
*/
typedef enum {
IOT_IO_NAME_GPIO_0, /* <GPIO0 */
IOT_IO_NAME_GPIO_1, /* <GPIO1 */
IOT_IO_NAME_GPIO_2, /* <GPIO2 */
IOT_IO_NAME_GPIO_3, /* <GPIO3 */
IOT_IO_NAME_GPIO_4, /* <GPIO4 */
IOT_IO_NAME_GPIO_5, /* <GPIO5 */
IOT_IO_NAME_GPIO_6, /* <GPIO6 */
IOT_IO_NAME_GPIO_7, /* <GPIO7 */
IOT_IO_NAME_GPIO_8, /* <GPIO8 */
IOT_IO_NAME_GPIO_9, /* <GPIO9 */
IOT_IO_NAME_GPIO_10, /* <GPIO10 */
IOT_IO_NAME_GPIO_11, /* <GPIO11 */
IOT_IO_NAME_GPIO_12, /* <GPIO12 */
IOT_IO_NAME_GPIO_13, /* <GPIO13 */
IOT_IO_NAME_GPIO_14, /* <GPIO14 */
IOT_IO_NAME_SFC_CSN, /* <SFC_CSN */
IOT_IO_NAME_SFC_IO1, /* <SFC_IO1 */
IOT_IO_NAME_SFC_IO2, /* <SFC_IO2 */
IOT_IO_NAME_SFC_IO0, /* <SFC_IO0 */
IOT_IO_NAME_SFC_CLK, /* <SFC_CLK */
IOT_IO_NAME_SFC_IO3, /* <SFC_IO3 */
IOT_IO_NAME_MAX,
} IotIoName;

/**
* @ingroup iot_io
*
* GPIO_0 pin function.CNcomment:GPIO_0管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_GPIO_0_GPIO,
IOT_IO_FUNC_GPIO_0_UART1_TXD = 2,
IOT_IO_FUNC_GPIO_0_SPI1_CK,
IOT_IO_FUNC_GPIO_0_JTAG_TDO,
IOT_IO_FUNC_GPIO_0_PWM3_OUT,
IOT_IO_FUNC_GPIO_0_I2C1_SDA,
} IotIoFuncGpio0;

/**
* @ingroup iot_io
*
* GPIO_1 pin function.CNcomment:GPIO_1管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_GPIO_1_GPIO,
IOT_IO_FUNC_GPIO_1_UART1_RXD = 2,
IOT_IO_FUNC_GPIO_1_SPI1_RXD,
IOT_IO_FUNC_GPIO_1_JTAG_TCK,
IOT_IO_FUNC_GPIO_1_PWM4_OUT,
IOT_IO_FUNC_GPIO_1_I2C1_SCL,
IOT_IO_FUNC_GPIO_1_BT_FREQ,
} IotIoFuncGpio1;

/**
* @ingroup iot_io
*
* GPIO_2 pin function.CNcomment:GPIO_2管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_GPIO_2_GPIO,
IOT_IO_FUNC_GPIO_2_UART1_RTS_N = 2,
IOT_IO_FUNC_GPIO_2_SPI1_TXD,
IOT_IO_FUNC_GPIO_2_JTAG_TRSTN,
IOT_IO_FUNC_GPIO_2_PWM2_OUT,
IOT_IO_FUNC_GPIO_2_SSI_CLK = 7,
} IotIoFuncGpio2;

/**
* @ingroup iot_io
*
* GPIO_3 pin function.CNcomment:GPIO_3管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_GPIO_3_GPIO,
IOT_IO_FUNC_GPIO_3_UART0_TXD,
IOT_IO_FUNC_GPIO_3_UART1_CTS_N,
IOT_IO_FUNC_GPIO_3_SPI1_CSN,
IOT_IO_FUNC_GPIO_3_JTAG_TDI,
IOT_IO_FUNC_GPIO_3_PWM5_OUT,
IOT_IO_FUNC_GPIO_3_I2C1_SDA,
IOT_IO_FUNC_GPIO_3_SSI_DATA,
} IotIoFuncGpio3;

/**
* @ingroup iot_io
*
* GPIO_4 pin function.CNcomment:GPIO_4管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_GPIO_4_GPIO,
IOT_IO_FUNC_GPIO_4_UART0_RXD = 2,
IOT_IO_FUNC_GPIO_4_JTAG_TMS = 4,
IOT_IO_FUNC_GPIO_4_PWM1_OUT,
IOT_IO_FUNC_GPIO_4_I2C1_SCL,
} IotIoFuncGpio4;

/**
* @ingroup iot_io
*
* GPIO_5 pin function.CNcomment:GPIO_5管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_GPIO_5_GPIO,
IOT_IO_FUNC_GPIO_5_UART1_RXD = 2,
IOT_IO_FUNC_GPIO_5_SPI0_CSN,
IOT_IO_FUNC_GPIO_5_PWM2_OUT = 5,
IOT_IO_FUNC_GPIO_5_I2S0_MCLK,
IOT_IO_FUNC_GPIO_5_BT_STATUS,
} IotIoFuncGpio5;

/**
* @ingroup iot_io
*
* GPIO_6 pin function.CNcomment:GPIO_6管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_GPIO_6_GPIO,
IOT_IO_FUNC_GPIO_6_UART1_TXD = 2,
IOT_IO_FUNC_GPIO_6_SPI0_CK,
IOT_IO_FUNC_GPIO_6_PWM3_OUT = 5,
IOT_IO_FUNC_GPIO_6_I2S0_TX,
IOT_IO_FUNC_GPIO_6_COEX_SWITCH,
} IotIoFuncGpio6;

/**
* @ingroup iot_io
*
* GPIO_7 pin function.CNcomment:GPIO_7管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_GPIO_7_GPIO,
IOT_IO_FUNC_GPIO_7_UART1_CTS_N = 2,
IOT_IO_FUNC_GPIO_7_SPI0_RXD,
IOT_IO_FUNC_GPIO_7_PWM0_OUT = 5,
IOT_IO_FUNC_GPIO_7_I2S0_BCLK,
IOT_IO_FUNC_GPIO_7_BT_ACTIVE,
} IotIoFuncGpio7;

/**
* @ingroup iot_io
*
* GPIO_8 pin function.CNcomment:GPIO_8管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_GPIO_8_GPIO,
IOT_IO_FUNC_GPIO_8_UART1_RTS_N = 2,
IOT_IO_FUNC_GPIO_8_SPI0_TXD,
IOT_IO_FUNC_GPIO_8_PWM1_OUT = 5,
IOT_IO_FUNC_GPIO_8_I2S0_WS,
IOT_IO_FUNC_GPIO_8_WLAN_ACTIVE,
} IotIoFuncGpio8;

/**
* @ingroup iot_io
*
* GPIO_9 pin function.CNcomment:GPIO_9管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_GPIO_9_GPIO,
IOT_IO_FUNC_GPIO_9_I2C0_SCL,
IOT_IO_FUNC_GPIO_9_UART2_RTS_N,
IOT_IO_FUNC_GPIO_9_SDIO_D2,
IOT_IO_FUNC_GPIO_9_SPI0_TXD,
IOT_IO_FUNC_GPIO_9_PWM0_OUT,
IOT_IO_FUNC_GPIO_9_I2S0_MCLK = 7,
} IotIoFuncGpio9;

/**
* @ingroup iot_io
*
* GPIO_10 pin function.CNcomment:GPIO_10管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_GPIO_10_GPIO,
IOT_IO_FUNC_GPIO_10_I2C0_SDA,
IOT_IO_FUNC_GPIO_10_UART2_CTS_N,
IOT_IO_FUNC_GPIO_10_SDIO_D3,
IOT_IO_FUNC_GPIO_10_SPI0_CK,
IOT_IO_FUNC_GPIO_10_PWM1_OUT,
IOT_IO_FUNC_GPIO_10_I2S0_TX = 7,
} IotIoFuncGpio10;

/**
* @ingroup iot_io
*
* GPIO_11 pin function.CNcomment:GPIO_11管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_GPIO_11_GPIO,
IOT_IO_FUNC_GPIO_11_UART2_TXD = 2,
IOT_IO_FUNC_GPIO_11_SDIO_CMD,
IOT_IO_FUNC_GPIO_11_SPI0_RXD,
IOT_IO_FUNC_GPIO_11_PWM2_OUT,
IOT_IO_FUNC_GPIO_11_RF_TX_EN_EXT,
IOT_IO_FUNC_GPIO_11_I2S0_RX,
} IotIoFuncGpio11;

/**
* @ingroup iot_io
*
* GPIO_12 pin function.CNcomment:GPIO_12管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_GPIO_12_GPIO,
IOT_IO_FUNC_GPIO_12_UART2_RXD = 2,
IOT_IO_FUNC_GPIO_12_SDIO_CLK,
IOT_IO_FUNC_GPIO_12_SPI0_CSN,
IOT_IO_FUNC_GPIO_12_PWM3_OUT,
IOT_IO_FUNC_GPIO_12_RF_RX_EN_EXT,
IOT_IO_FUNC_GPIO_12_I2S0_BCLK,
} IotIoFuncGpio12;

/**
* @ingroup iot_io
*
* GPIO_13 pin function.CNcomment:GPIO_13管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_GPIO_13_SSI_DATA,
IOT_IO_FUNC_GPIO_13_UART0_TXD,
IOT_IO_FUNC_GPIO_13_UART2_RTS_N,
IOT_IO_FUNC_GPIO_13_SDIO_D0,
IOT_IO_FUNC_GPIO_13_GPIO,
IOT_IO_FUNC_GPIO_13_PWM4_OUT,
IOT_IO_FUNC_GPIO_13_I2C0_SDA,
IOT_IO_FUNC_GPIO_13_I2S0_WS,
} IotIoFuncGpio13;

/**
* @ingroup iot_io
*
* GPIO_14 pin function.CNcomment:GPIO_14管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_GPIO_14_SSI_CLK,
IOT_IO_FUNC_GPIO_14_UART0_RXD,
IOT_IO_FUNC_GPIO_14_UART2_CTS_N,
IOT_IO_FUNC_GPIO_14_SDIO_D1,
IOT_IO_FUNC_GPIO_14_GPIO,
IOT_IO_FUNC_GPIO_14_PWM5_OUT,
IOT_IO_FUNC_GPIO_14_I2C0_SCL,
} IotIoFuncGpio14;

/**
* @ingroup iot_io
*
* SFC_CSN pin function.CNcomment:SFC_CSN管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_SFC_CSN_SFC_CSN,
IOT_IO_FUNC_SFC_CSN_SDIO_D2,
IOT_IO_FUNC_SFC_CSN_GPIO9,
IOT_IO_FUNC_SFC_CSN_SPI0_TXD = 4,
} IotIoFuncSfcCsn;

/**
* @ingroup iot_io
*
* SFC_DO pin function.CNcomment:SFC_DO管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_SFC_IO_1_SFC_DO,
IOT_IO_FUNC_SFC_IO_1_SDIO_D3,
IOT_IO_FUNC_SFC_IO_1_GPIO10,
IOT_IO_FUNC_SFC_IO_1_SPI0_CK = 4,
} IotIoFuncSfcIo1;

/**
* @ingroup iot_io
*
* SFC_WPN pin function.CNcomment:SFC_WPN管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_SFC_IO_2_SFC_WPN,
IOT_IO_FUNC_SFC_IO_2_SDIO_CMD,
IOT_IO_FUNC_SFC_IO_2_GPIO11,
IOT_IO_FUNC_SFC_IO_2_RF_TX_EN_EXT,
IOT_IO_FUNC_SFC_IO_2_SPI0_RXD,
} IotIoFuncSfcIo2;

/**
* @ingroup iot_io
*
* SFC_DI pin function.CNcomment:SFC_DI管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_SFC_IO_0_SFC_DI,
IOT_IO_FUNC_SFC_IO_0_SDIO_CLK,
IOT_IO_FUNC_SFC_IO_0_GPIO12,
IOT_IO_FUNC_SFC_IO_0_RF_RX_EN_EXT,
IOT_IO_FUNC_SFC_IO_0_SPI0_CSN,
} IotIoFuncSfcIo0;

/**
* @ingroup iot_io
*
* SFC_CLK pin function.CNcomment:SFC_CLK管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_SFC_CLK_SFC_CLK,
IOT_IO_FUNC_SFC_CLK_SDIO_D0,
IOT_IO_FUNC_SFC_CLK_GPIO13,
IOT_IO_FUNC_SFC_CLK_SSI_DATA = 4,
} IotIoFuncSfcClk;

/**
* @ingroup iot_io
*
* SFC_HOLDN pin function.CNcomment:SFC_HOLDN管脚功能。CNend
*/
typedef enum {
IOT_IO_FUNC_SFC_IO_3_SFC_HOLDN,
IOT_IO_FUNC_SFC_IO_3_SDIO_D1,
IOT_IO_FUNC_SFC_IO_3_GPIO14,
IOT_IO_FUNC_SFC_IO_3_SSI_CLK = 4,
} IotIoFuncSfcIo3;

/**
* @ingroup iot_io
*
* I/O drive capability.CNcomment:IO驱动能力。CNend
* Note: The HI_IO_NAME_GPIO_0~HI_IO_NAME_GPIO_11 and HI_IO_NAME_GPIO_13~HI_IO_NAME_GPIO_14 driver capabilities are
* optional.The value range is HI_IO_DRIVER_STRENGTH_0~HI_IO_DRIVER_STRENGTH_3, and the other I/O ranges are
* HI_IO_DRIVER_STRENGTH_0~HI_IO_DRIVER_STRENGTH_7.CNcomment:注意:HI_IO_NAME_GPIO_0~HI_IO_NAME_GPIO_11、
* HI_IO_NAME_GPIO_13~HI_IO_NAME_GPIO_14驱动能力可选范围是HI_IO_DRIVER_STRENGTH_0~HI_IO_DRIVER_STRENGTH_3,
* 其余IO范围是HI_IO_DRIVER_STRENGTH_0~HI_IO_DRIVER_STRENGTH_7。CNend
*/
typedef enum {
IOT_IO_DRIVER_STRENGTH_0 = 0, /* <Drive strength level 0 (highest).CNcomment:驱动能力0级,驱动能力最高CNend */
IOT_IO_DRIVER_STRENGTH_1, /* <Drive strength level 1.CNcomment:驱动能力1级CNend */
IOT_IO_DRIVER_STRENGTH_2, /* <Drive strength level 2.CNcomment:驱动能力2级CNend */
IOT_IO_DRIVER_STRENGTH_3, /* <Drive strength level 3.CNcomment:驱动能力3级CNend */
IOT_IO_DRIVER_STRENGTH_4, /* <Drive strength level 4.CNcomment:驱动能力4级CNend */
IOT_IO_DRIVER_STRENGTH_5, /* <Drive strength level 5.CNcomment:驱动能力5级CNend */
IOT_IO_DRIVER_STRENGTH_6, /* <Drive strength level 6.CNcomment:驱动能力6级CNend */
IOT_IO_DRIVER_STRENGTH_7, /* <Drive strength level 7 (lowest).CNcomment:驱动能力7级,驱动能力最低CNend */
IOT_IO_DRIVER_STRENGTH_MAX,
} IotIoDriverStrength;


unsigned int IoSetPull(unsigned int id, IotIoPull val);


unsigned int IoSetFunc(unsigned int id, unsigned char val);

unsigned int TaskMsleep(unsigned int ms);

#endif
/** @} */
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#ifndef OLED_FONTS_H
#define OLED_FONTS_H

/************************************6*8的点阵************************************/
static unsigned char g_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的点阵************************************/
static const unsigned char g_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
};

#endif
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef OLED_SSD1306_H
#define OLED_SSD1306_H

#include <stdint.h>

/**
* @brief ssd1306 OLED Initialize.
*/
uint32_t OledInit(void);

/**
* @brief Set cursor position
* @param x the horizontal posistion of cursor
* @param y the vertical position of cursor
* @return Returns {@link WIFI_IOT_SUCCESS} if the operation is successful;
* returns an error code defined in {@link wifiiot_errno.h} otherwise.
*/
void OledSetPosition(uint8_t x, uint8_t y);

void OledFillScreen(uint8_t fillData);

enum Font {
FONT6_X8 = 1,
FONT8_X16
};
typedef enum Font Font;

void OledShowChar(uint8_t x, uint8_t y, uint8_t ch, Font font);
void OledShowString(uint8_t x, uint8_t y, const char* str, Font font);

#endif // OLED_SSD1306_H


Hi3516DV300板子开发

由于篇幅问题,点击这里阅读分类网模型的训练。