本文來(lái)源電子發(fā)燒友社區(qū),作者:盧松濤, 帖子地址:https://bbs.elecfans.com/jishu_2249213_1_1.html
在"【南京中科微CSM32RV20開(kāi)發(fā)板試用體驗(yàn)】+1-GPIO口串口的使用"基礎(chǔ)上增加oled rtc
硬件IIC非中斷的使用:
///---- Chapter 12 I2C Test Init -------------------------------------------------------------------------------------
uint8_t i2c_data;
I2C_Init_case1();//非中斷模式
rtc的使用:
///---- Chapter 7 RTC Test Init --------------------------------------------------------------------------------------
//RTC_Init_case1();
RTC_Init_case2();
Interrupt_Level(MtiMER_int_ID, INT_LEVEL2 );//CLIC設(shè)置中斷搶占級(jí)別
Interrupt_Enable(MTIMER_int_ID);//CLIC使能中斷
SYS_Interrupt_Enable();//CLIC開(kāi)總中斷
復(fù)制代碼
com:
Hello CSM32RV20:
mcycle:112549883
read_csr(mcycle):2
CMU->OSC_SR:d2
CMU->OSC_SR:210,OSC 時(shí)鐘已穩(wěn)定,RCOSC 時(shí)鐘已穩(wěn)定,:OSC 在為 MCU 提供時(shí)鐘;OSC 在為外設(shè)提供時(shí)鐘;
請(qǐng)輸入:on ???者off (開(kāi)燈/關(guān)燈)
收到數(shù)據(jù):
rt_tick_get:11529
RTC_MTIME->mtime:36899472 RTC_MTIME->mtime0-7B:4a 4c 33 2 0 0 0 0
RTC_MTIME->mtime:0
RTC_MTIMECMP->mtimecmp:36934400
->?RTC_MTIME->mtime:0233b880
RTC_MTIMECMP->mtimecmp0-7B:0 3 34 2 0 0 0 0
val:95avr:14062100 13.9mV 2047.5mV
time:0 day 0 hour' 0:16
收到數(shù)據(jù):0
RTC_MTIME->mtimelo:63461288
RTC_MTIME->mtimehi:0
rt_tick_get:21537
RTC_MTIME->mtime:68924127 RTC_MTIME->mtime0-7B:99 f5 1b 4 0 0 0 0
RTC_MTIME->mtime:0
RTC_MTIMECMP->mtimecmp:68960000
->?RTC_MTIME->mtime:041c6480
RTC_MTIMECMP->mtimecmp0-7B:0 a3 1c 4 0 0 0 0
在"【南京中科微CSM32RV20開(kāi)發(fā)板試用體驗(yàn)】+1-GPIO口串口的使用"基礎(chǔ)上增加oled rtc
硬件IIC非中斷的使用:
///---- Chapter 12 I2C Test Init -------------------------------------------------------------------------------------
uint8_t i2c_data;
I2C_Init_case1();//非中斷模式
rtc的使用:
///---- Chapter 7 RTC Test Init --------------------------------------------------------------------------------------
//RTC_Init_case1();
RTC_Init_case2();
Interrupt_Level(MtiMER_int_ID, INT_LEVEL2 );//CLIC設(shè)置中斷搶占級(jí)別
Interrupt_Enable(MTIMER_int_ID);//CLIC使能中斷
SYS_Interrupt_Enable();//CLIC開(kāi)總中斷
- #include "headfile.h"
- #ifndef __OLEDFONT_H
- #define __OLEDFONT_H
- //常用ASCII表
- //偏移量32
- //ASCII字符集
- //偏移量32
- //大小:12*6
- /************************************6*8的點(diǎn)陣************************************/
- 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的點(diǎn)陣************************************/
- 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
- };
- /***********************************************
- PCtoLCD2002設(shè)置
- 陰碼,逆向,C51格式,十六進(jìn)制數(shù)據(jù),列行式,輸出三個(gè)全選中
- 每行顯示點(diǎn)陣9999,索引9999
- 格式: 段前綴 【無(wú)】;
- 段后綴 【無(wú)】;
- 注釋前綴(右邊空格去掉) 【/ *"】;
- 注釋后綴 【",】;
- 數(shù)據(jù)后綴 【,】;
- 行前綴 【{】;
- 行后綴 【},】
- **********************************************/
- /***********************************
- 16x16漢字
- 取字軟件:PCtoLCD2002
- 使用方法見(jiàn)文檔
- ***********************************/
- const unsigned char Chinese_Word_16[][32]= {
- {0x84,0x84,0xFC,0x84,0x84,0x40,0x64,0x54,0x4C,0x47,0x4C,0x54,0xE4,0x44,0x40,0x00,0x10,0x30,0x1F,0x08,0x08,0x00,0x1F,0x11,0x11,0x1F,0x40,0x80,0x7F,0x00,0x00,0x00},/*"琦",0*/
- {0x00,0x02,0x02,0x7A,0x4A,0x4A,0x4A,0x4A,0x7A,0x02,0x02,0x7E,0x02,0x02,0x00,0x00,0x01,0x01,0x01,0x3D,0x25,0x25,0x25,0x25,0x3D,0x41,0x81,0x7F,0x01,0x01,0x01,0x00},/*"哥",1*/
- {0x00,0x40,0x20,0x1E,0x10,0x10,0x10,0xFF,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0xFF,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00},/*"牛",2*/
- {0x40,0x40,0x42,0xCC,0x00,0x82,0xBA,0xAA,0xAA,0xAA,0xAA,0xAA,0xBA,0x82,0x00,0x00,0x00,0x40,0x20,0x1F,0x20,0x5F,0x4A,0x4A,0x4A,0x4F,0x4A,0x4A,0x4A,0x5F,0x40,0x00},/*"逼",3*/
- };
- #endif
- void mp_receive_data(uint8_t *buf, uint16_t *len)
- {
- uint8_t rxlen = UART1_RX_CNT;
- uint16_t i = 0;
- *len = 0; //默認(rèn)為0
- Delay32M_ms(10); //等待40ms,連續(xù)超過(guò)10ms沒(méi)有接收到一個(gè)數(shù)據(jù),則認(rèn)為接收結(jié)束
- if (rxlen == UART1_RX_CNT && rxlen) //接收到了數(shù)據(jù),且接收完成了
- {
- for (i = 0; i < rxlen; i++)
- {
- buf[i] = uart_dev.rxbuf[i];
- }
- *len = UART1_RX_CNT; //記錄本次數(shù)據(jù)長(zhǎng)度
- UART1_RX_CNT = 0; //清零
- uart_dev.frameok=1; //標(biāo)記完成一幀數(shù)據(jù)接收
- // getData=0;//數(shù)據(jù)接收完成,標(biāo)志位清零
- }
- }
- #define Max_Column 128
- void OLED_Write_IIC_Command(uint8_t IIC_Command)
- {
- I2C_Write(0x00,IIC_Command);
- }
- void OLED_Write_IIC_Data(uint8_t IIC_Data)
- {
- I2C_Write(0x40,IIC_Data);
- }
- /**
- * @brief :OLED_Clear
- * [url=home.php?mod=space&uid=1902110]@NOTE[/url] : --清屏函數(shù)
- --清完屏,整個(gè)屏幕是黑色的!和沒(méi)點(diǎn)亮一樣
- * @param : >>
- >>
- * @return :void
- *
- * @date :2021/01/29
- * [url=home.php?mod=space&uid=44345]@design[/url] :
- **/
- void OLED_Clear(void)
- {
- uint8_t i,n;
- for(i=0; i<8; i++)
- {
- OLED_Write_IIC_Command (0xb0+i); //設(shè)置頁(yè)地址(0~7)
- OLED_Write_IIC_Command (0x00); //設(shè)置顯示位置—列低地址
- OLED_Write_IIC_Command (0x10); //設(shè)置顯示位置—列高地址
- for(n=0; n<128; n++)
- {
- OLED_Write_IIC_Data(0x00);
- }
- }
- //更新顯示
- }
- /**
- * @brief :OLED_Set_Pos
- * @note : --坐標(biāo)設(shè)置
- * @param : >>
- >>
- * @return :void
- *
- * @date :2021/01/29
- * @design :
- **/
- void OLED_Set_Pos(uint8_t x, uint8_t y)
- { OLED_Write_IIC_Command(0xb0+y);
- OLED_Write_IIC_Command(((x&0xf0)>>4)|0x10);
- OLED_Write_IIC_Command((x&0x0f));
- }
- /**
- * @brief :OLED_ShowChar
- * @note : --在指定位置顯示一個(gè)字符,包括部分字符
- --例如:OLED_ShowChar(20,6,'A',16);
- * @param : >>
- >>x:0~127
- >>y:0~6
- >>mode:0,反白顯示;1,正常顯示
- >>size:選擇字體 8/16
- * @return :void
- *
- * @date :2021/01/29
- * @design :
- **/
- void OLED_ShowChar(uint8_t x,uint8_t y,uint8_t chr,uint8_t Char_Size)
- {
- uint8_t c=0,i=0;
- c=chr-' ';//得到偏移后的值
- if(x>Max_Column-1) {
- x=0;
- y=y+2;
- }
- if(Char_Size ==16)
- {
- OLED_Set_Pos(x,y);
- for(i=0; i<8; i++)
- OLED_Write_IIC_Data(F8X16[c*16+i]);
- OLED_Set_Pos(x,y+1);
- for(i=0; i<8; i++)
- OLED_Write_IIC_Data(F8X16[c*16+i+8]);
- }
- else
- {
- OLED_Set_Pos(x,y);
- for(i=0; i<6; i++)
- OLED_Write_IIC_Data(F6x8[c][i]);
- }
- }
- /**
- * @brief :OLED_ShowString
- * @note : --顯示一個(gè)字符號(hào)串
- --例如:
- u8 SET[2][3] = {{"ON "},{"OFF"}};
- OLED_ShowString(0,0,SET[0],8);
- * @param : >>
- >>size:選擇字體 8/16
- * @return :void
- *
- * @date :2021/01/29
- * @design :
- **/
- void OLED_ShowString(uint8_t x,uint8_t y,uint8_t *chr,uint8_t Char_Size)
- {
- while (*chr!='')
- { OLED_ShowChar(x,y,*chr,Char_Size);
- x+=8;
- if(x>120) {
- x=0;
- y+=2;
- }
- chr++;
- }
- }
- /**********************************************
- //m^n函數(shù)
- **********************************************/
- uint32_t oled_pow(uint8_t m,uint8_t n)
- {
- uint32_t result=1;
- while(n--)result*=m;
- return result;
- }
- /**
- * @brief :OLED_ShowNumber
- * @note : --顯示數(shù)字
- --例如:OLED_ShowNumber(0,0,45125215,10);
- * @param : >>x,y :起點(diǎn)坐標(biāo)
- >>len :數(shù)字的位數(shù)
- >>size:字體大小默認(rèn)16
- >>num:數(shù)值(0~4294967295);
- * @return :void
- *
- * @date :2021/01/29
- * @design :
- **/
- void OLED_ShowNumber(uint8_t x,uint8_t y,uint32_t num,uint8_t len)
- {
- uint8_t size2 = 16;
- uint8_t t,temp;
- uint8_t enshow=0;
- for(t=0; t;>
- {
- temp=(num/oled_pow(10,len-t-1))%10;
- if(enshow==0&&t<(len-1))
- {
- if(temp==0)
- {
- OLED_ShowChar(x+(size2/2)*t,y,' ',size2);
- continue;
- } else enshow=1;
- }
- OLED_ShowChar(x+(size2/2)*t,y,temp+'0',size2);
- }
- }
- //初始化SSD1306
- void OLED_Init(void)
- {
- // OLED_GPIO_Init();
- Delay32M_ms(1500);
- // OLED_WR_Byte(0xAE,OLED_CMD);//--display off
- // OLED_WR_Byte(0x00,OLED_CMD);//---set low column address
- // OLED_WR_Byte(0x10,OLED_CMD);//---set high column address
- // OLED_WR_Byte(0x40,OLED_CMD);//--set start line address
- // OLED_WR_Byte(0xB0,OLED_CMD);//--set page address
- // OLED_WR_Byte(0x81,OLED_CMD); // contract control
- // OLED_WR_Byte(0xFF,OLED_CMD);//--128
- // OLED_WR_Byte(0xA1,OLED_CMD);//set segment remap
- // OLED_WR_Byte(0xA6,OLED_CMD);//--normal / reverse
- // OLED_WR_Byte(0xA8,OLED_CMD);//--set multiplex ratio(1 to 64)
- // OLED_WR_Byte(0x3F,OLED_CMD);//--1/32 duty
- // OLED_WR_Byte(0xC8,OLED_CMD);//Com scan direction
- // OLED_WR_Byte(0xD3,OLED_CMD);//-set display offset
- // OLED_WR_Byte(0x00,OLED_CMD);//
- // OLED_WR_Byte(0xD5,OLED_CMD);//set osc division
- // OLED_WR_Byte(0x80,OLED_CMD);//
- // OLED_WR_Byte(0xD8,OLED_CMD);//set area color mode off
- // OLED_WR_Byte(0x05,OLED_CMD);//
- // OLED_WR_Byte(0xD9,OLED_CMD);//Set Pre-Charge Period
- // OLED_WR_Byte(0xF1,OLED_CMD);//
- // OLED_WR_Byte(0xDA,OLED_CMD);//set com pin configuartion
- // OLED_WR_Byte(0x12,OLED_CMD);//
- // OLED_WR_Byte(0xDB,OLED_CMD);//set Vcomh
- // OLED_WR_Byte(0x30,OLED_CMD);//
- // OLED_WR_Byte(0x8D,OLED_CMD);//set charge pump enable
- // OLED_WR_Byte(0x14,OLED_CMD);//
- // OLED_WR_Byte(0xAF,OLED_CMD);//--turn on oled panel
- OLED_Write_IIC_Command(0xAE); //display off
- OLED_Write_IIC_Command(0x20); //Set Memory Addressing Mode
- OLED_Write_IIC_Command(0x10); //00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid
- OLED_Write_IIC_Command(0xb0); //Set Page Start Address for Page Addressing Mode,0-7
- OLED_Write_IIC_Command(0xc8); //Set COM Output Scan Direction
- OLED_Write_IIC_Command(0x00); //---set low column address
- OLED_Write_IIC_Command(0x10); //---set high column address
- OLED_Write_IIC_Command(0x40); //--set start line address
- OLED_Write_IIC_Command(0x81); //--set contrast control register
- OLED_Write_IIC_Command(0xff); //亮度調(diào)節(jié) 0x00~0xff
- OLED_Write_IIC_Command(0xa1); //--set segment re-map 0 to 127
- OLED_Write_IIC_Command(0xa6); //--set normal display
- OLED_Write_IIC_Command(0xa8); //--set multiplex ratio(1 to 64)
- OLED_Write_IIC_Command(0x3F); //
- OLED_Write_IIC_Command(0xa4); //0xa4,Output follows RAM content;0xa5,Output ignores RAM content
- OLED_Write_IIC_Command(0xd3); //-set display offset
- OLED_Write_IIC_Command(0x00); //-not offset
- OLED_Write_IIC_Command(0xd5); //--set display clock divide ratio/oscillator frequency
- OLED_Write_IIC_Command(0xf0); //--set divide ratio
- OLED_Write_IIC_Command(0xd9); //--set pre-charge period
- OLED_Write_IIC_Command(0x22); //
- OLED_Write_IIC_Command(0xda); //--set com pins hardware configuration
- OLED_Write_IIC_Command(0x12);
- OLED_Write_IIC_Command(0xdb); //--set vcomh
- OLED_Write_IIC_Command(0x20); //0x20,0.77xVcc
- OLED_Write_IIC_Command(0x8d); //--set DC-DC enable
- OLED_Write_IIC_Command(0x14); //
- OLED_Write_IIC_Command(0xaf); //--turn on oled panel
- }
- uint8_t ReceiveBuff[RECV_LEN];
- int main(void)
- {
- uint16_t rlen=0;
- uart_dev.rxlen=0;
- ///----System Init ---------------------------------------------------------------------------------------------
- CLIC_Init();//系統(tǒng)中斷配置
- System_Clock_Init();//系統(tǒng)時(shí)鐘初始化
- ///----Chapter 3 LowPower Test Init ---------------------------------------------------------------------------------
- //低功耗測(cè)功耗需要IO不能懸空
- //Delay32M_ms(5000);
- //LowPower_Config_case1();//所有IO設(shè)置為輸入,下拉
- //LowPower_Config_case2();//所有IO設(shè)置為輸入,上拉
- //使用外部中斷喚醒
- //GPIO_EXIT_Init_case1(GPIOA, PIN2);//檢測(cè)高電平
- //Interrupt_Level(EXIT2_int_ID, INT_LEVEL0);//CLIC設(shè)置中斷搶占級(jí)別
- //Interrupt_Enable(EXIT2_int_ID);//CLIC使能EXIT中斷
- //SYS_Interrupt_Enable();//CLIC開(kāi)總中斷
- //配置不同低功耗模式
- //System_Halt();//待機(jī)模式 halt1
- //System_Sleep();//睡眠模式 halt2
- //System_Powerdown();//掉電模式 powerdown1
- //System_DeepPwd();//掉電模式 powerdown2
- ///----Chapter 5 GPIO Test Init ---------------------------------------------------------------------------------
- GPIO_MODE_Init(GPIOA,PIN8,GPIO_MODE_OUTPUT); //GPIO 模式
- GPIO_MODE_Init(GPIOA,PIN10,GPIO_MODE_OUTPUT); //GPIO 模式
- GPIO_MODE_Init(GPIOA,PIN12,GPIO_MODE_OUTPUT); //GPIO 模式
- //GPIO_MODE_Init(GPIOA,PIN14,GPIO_MODE_OUTPUT); //GPIO 模式
- //GPIO_MODE_Init(GPIOA,PIN15,GPIO_MODE_OUTPUT); //GPIO 模式
- //GPIO_Write(GPIOA,PIN8,GPIO_SET); //GPIO 輸出
- //GPIO_Write(GPIOA,PIN10,GPIO_SET); //GPIO 輸出
- //GPIO_Write(GPIOA,PIN12,GPIO_SET); //GPIO 輸出
- //GPIO_Write(GPIOA,PIN14,GPIO_RESET); //GPIO 輸出
- //GPIO_Write(GPIOA,PIN15,GPIO_RESET); //GPIO 輸出
- //GPIO_Toggle(GPIOA,PIN15); //GPIO 翻轉(zhuǎn)
- //GPIO_MODE_Init(GPIOA,PIN15,GPIO_MODE_INTPUT); //GPIO 模式
- for(uint8_t i=0;i<10;i++)
- {
- GPIO_Toggle(GPIOA,PIN8); //GPIO 翻轉(zhuǎn)
- Delay32M_ms(100);
- }
- ///---- Chapter 6 EXIT Test Init -------------------------------------------------------------------------------------
- //GPIO_EXIT_Init_case1(GPIOA, PIN2);//檢測(cè)高電平
- //GPIO_EXIT_Init_case2(GPIOA, PIN2);//檢測(cè)低電平
- //GPIO_EXIT_Init_case3(GPIOA, PIN2);//檢測(cè)上升沿
- //GPIO_EXIT_Init_case4(GPIOA, PIN2);//檢測(cè)下降沿
- //Interrupt_Level(EXIT2_int_ID, INT_LEVEL0);//CLIC設(shè)置中斷搶占級(jí)別
- //Interrupt_Enable(EXIT2_int_ID);//CLIC使能EXIT中斷
- //載波檢測(cè)中斷
- //CAW_Init();//載波檢測(cè)
- //Interrupt_Enable(CAW_int_ID);//CLIC使能中斷
- //SYS_Interrupt_Enable();//CLIC開(kāi)總中斷
- ///---- Chapter 7 RTC Test Init --------------------------------------------------------------------------------------
- //RTC_Init_case1();
- RTC_Init_case2();
- Interrupt_Level(MTIMER_int_ID, INT_LEVEL2 );//CLIC設(shè)置中斷搶占級(jí)別
- Interrupt_Enable(MTIMER_int_ID);//CLIC使能中斷
- SYS_Interrupt_Enable();//CLIC開(kāi)總中斷
- ///---- Chapter 8 IWDG Test Init -------------------------------------------------------------------------------------
- //IWDG_Init(9000); //配置看門(mén)狗計(jì)數(shù)值(時(shí)鐘頻率3K)
- //Delay32M_ms(1000);
- //IWDG_Start(); //啟動(dòng)看門(mén)狗
- //IWDG_Refresh(); //喂狗
- ///---- Chapter 9 Timer Test Init ------------------------------------------------------------------------------------
- //GPIO_MODE_Init(GPIOB,PIN11,GPIO_MODE_OUTPUT); //GPIO 模式
- //GPIO_MODE_Init(GPIOA,PIN9,GPIO_MODE_OUTPUT);
- //GPIO_MODE_Init(GPIOA,PIN11,GPIO_MODE_OUTPUT);
- //GPIO_MODE_Init(GPIOA,PIN13,GPIO_MODE_OUTPUT);
- //外設(shè)配置
- //Timer1_UpCounting_Mode_Init();//向上計(jì)數(shù)
- //Timer1_6StepPWM_Mode_Init();//6stepPWM輸出
- //Timer2_UpCounting_Mode_Init();//向上計(jì)數(shù)
- //Timer2_DownCounting_Mode_Init();//向下計(jì)數(shù)
- //Timer2_ExternalClock_Mode_Init();//外部時(shí)鐘
- //Timer2_InputCapture_Mode_Init();//輸入捕獲
- //Timer2_PWM_InputCapture_Mode_Init();//PWM輸入捕獲
- //Timer2_Input_XOR_Mode_Init();//輸入異或
- //Timer2_PWM_Mode_Init();//PWM輸出
- //Timer2_6StepPWM_Mode_Init();//6stepPWM輸出
- //設(shè)置中斷優(yōu)先級(jí)
- //Interrupt_Level(TIMER1_updata_int_ID, INT_LEVEL1);//CLIC設(shè)置中斷搶占級(jí)別
- //使能外設(shè)中斷
- //Interrupt_Enable(TIMER1_break_int_ID);//CLIC使能中斷
- //Interrupt_Enable(TIMER1_updata_int_ID);//CLIC使能中斷
- //Interrupt_Enable(TIMER1_capture_compare_int_ID);//CLIC使能中斷
- //Interrupt_Enable(TIMER1_trigger_comm_int_ID);//CLIC使能中斷
- //Interrupt_Enable(TIMER2_break_int_ID);//CLIC使能中斷
- //Interrupt_Enable(TIMER2_updata_int_ID);//CLIC使能中斷
- //Interrupt_Enable(TIMER2_capture_compare_int_ID);//CLIC使能中斷
- //Interrupt_Enable(TIMER2_trigger_comm_int_ID);//CLIC使能中斷
- //使能系統(tǒng)總中斷
- //SYS_Interrupt_Enable();//CLIC開(kāi)總中斷
- ///---- Chapter 10 WUP Test Init -------------------------------------------------------------------------------------
- //GPIO_MODE_Init(GPIOA,PIN2,GPIO_MODE_OUTPUT);
- //GPIO_MODE_Init(GPIOA,PIN3,GPIO_MODE_OUTPUT);
- //WUP_Init_case1(9000);//設(shè)置中斷周期,使能WUP中斷
- //Interrupt_Enable(WUP_int_ID);//CLIC使能中斷
- //SYS_Interrupt_Enable();//CLIC開(kāi)總中斷
- //配置不同低功耗模式
- //System_Halt();//待機(jī)模式 halt1
- //System_Sleep();//睡眠模式 halt2
- //System_Powerdown();//掉電模式 powerdown1
- //System_DeepPwd();//掉電模式 powerdown2
- ///---- Chapter 11 ADC Test Init -------------------------------------------------------------------------------------
- uint32_t adc_result;
- uint32_t adc_pack[16];
- uint32_t adc_sum;
- uint32_t adc_count;
- uint32_t adc_avr;
- uint32_t voltage_avr;
- ADC_Init_case1();//內(nèi)部基準(zhǔn),測(cè)PA4
- //ADC_Init_case2();//外部基準(zhǔn),測(cè)PA4
- ///---- Chapter 12 I2C Test Init -------------------------------------------------------------------------------------
- uint8_t i2c_data;
- I2C_Init_case1();//非中斷模式
- //I2C_Init_case2();//ready中斷模式
- //I2C_Init_case3();//error中斷模式
- //I2C_Init_case4();//ready & error中斷模式
- //Interrupt_Enable(I2C_ready_int_ID);//CLIC使能i2c_ready中斷
- //Interrupt_Enable(I2C_error_int_ID);//CLIC使能i2c_error中斷
- //SYS_Interrupt_Enable();//CLIC開(kāi)總中斷
- OLED_Init();
- ///---- Chapter 13 SPI1 Test Init ------------------------------------------------------------------------------------
- //uint8_t sTxpack[10] = {0,1,2,3,4,5,6,7,8,9};
- //uint8_t sRxpack[10] = {0,1,2,3,4,5,6,7,8,9};
- //uint8_t REG_Data;
- //SPI1 Init Test
- //SPI_Init_case1(SPI1);//非中斷模式
- //SPI1_CSN_Init_case1();//CFG: CE-GPIO7,CSN-GPIO8
- //SPI_Init_case2(SPI1);//中斷模式
- //Interrupt_Enable(SPI1_int_ID);//CLIC使能單個(gè)中斷
- //SPI2 Init Test
- //SPI_Init_case1(SPI2);//非中斷模式
- //SPI2_CSN_Init_case1();//CFG: CE-GPIO7,CSN-GPIO8
- //SPI_Init_case2(SPI2);//中斷模式
- //Interrupt_Enable(SPI2_int_ID);//CLIC使能單個(gè)中斷
- ///---- Chapter 15 UART Test Init -------------------------------------------------------------------------------
- //uint8_t upack1[20] = {0,1,2,3,4,5,6,7,8,9};
- //uint8_t upack2[20] = {0,1,2,3,4,5,6,7,8,9};
- //uint8_t upack3[20] = {0,1,2,3,4,5,6,7,8,9};
- //uint8_t upack4[20] = {10,1,2,3,4,5,6,7,8,9};
- //UART_Init_case1(UART2);//非中斷模式
- //UART_Init_case1(UART3);//非中斷模式
- //UART_Init_case1(UART4);//非中斷模式
- UART_Init_IT_case1(UART1);//中斷模式
- //UART_Init_IT_case1(UART4);//中斷模式
- Interrupt_Enable(UART1_int_ID);//CLIC使能單個(gè)中斷
- UART1->CTRL |= 0x00000001U;//清除中斷標(biāo)志位,防止開(kāi)機(jī)先進(jìn)一次中斷
- //Interrupt_Enable(UART4_int_ID);//CLIC使能單個(gè)中斷
- SYS_Interrupt_Enable();//CLIC開(kāi)總中斷
- //printf("uart init:rn");
- ///---- Chapter 16 LV Test Init --------------------------------------------------------------------------------------
- //LV_Init_case1(12);//設(shè)置低壓報(bào)警閾值
- //LV_Interrupt_Enable();//使能低壓報(bào)警中斷
- //Interrupt_Enable(LV_int_ID);//CLIC使能單個(gè)中斷
- //SYS_Interrupt_Enable();//CLIC開(kāi)總中斷
- ///---- Chapter 17 RANDGEN Test Init ---------------------------------------------------------------------------------
- //uint32_t rand_data;
- ///---- Chapter 18 compare Test Init ---------------------------------------------------------------------------------
- //COPM1_Init();//COPM1
- //Interrupt_Enable(COMP1_int_ID);//CLIC使能單個(gè)中斷
- //COPM2_Init();//COPM2
- //Interrupt_Enable(COMP2_int_ID);//CLIC使能單個(gè)中斷
- //COPM3_Init();//COPM3
- //Interrupt_Enable(COMP3_int_ID);//CLIC使能單個(gè)中斷
- //SYS_Interrupt_Enable();//CLIC開(kāi)總中斷
- ///---- Chapter 22 flash Test Init ----------------------------------------------------------------------------------
- //NVR_RW_Test();//NVR read and write test
- //Flash_RW_Test();
- ///---- 系統(tǒng)總中斷控制 -------------------------------------------------------------------------------------------------
- //SYS_Interrupt_Enable();//CLIC開(kāi)總中斷
- //SYS_Interrupt_Disable();//CLIC關(guān)總中斷
- adc_pack[0]=read_csr(mcycle);
- adc_pack[1]=read_csr(mcycle);
- ee_printf("nHello CSM32RV20:n");
- ee_printf("mcycle:%d n",read_csr(mcycle));//比如mcycle這一CSR用于處理器運(yùn)行的時(shí)鐘周期計(jì)數(shù)
- ee_printf("read_csr(mcycle):%d n",adc_pack[1]-adc_pack[0]);//比如mcycle這一CSR用于處理器運(yùn)行的時(shí)鐘周期計(jì)數(shù)
- ee_printf("CMU->OSC_SR:%x n",CMU->OSC_SR );
- if(CMU->OSC_SR==210 ) ee_printf("CMU->OSC_SR:210,OSC 時(shí)鐘已穩(wěn)定,RCOSC 時(shí)鐘已穩(wěn)定,:OSC 在為 MCU 提供時(shí)鐘;OSC 在為外設(shè)提供時(shí)鐘; n" );
- //printf("Hello CSM32RV20:rn");
- ee_printf("請(qǐng)輸入:on 或者off (開(kāi)燈/關(guān)燈)rn");
- uint32_t rt_tick1 = rt_tick_get();
- uint32_t rt_tick2 = rt_tick_get();
- OLED_Clear();
- Delay32M_ms(1000);
- // OLED_Light();
- // OLED_DrawBMP(0,0,128,8,BAD_APPLE);
- OLED_ShowString(0,0,"CSM32 TEST",16);
- while(1)
- {
- mp_receive_data(ReceiveBuff, &rlen);
- if(uart_dev.frameok==1)//如果接收到數(shù)據(jù)
- {
- ee_printf("收到數(shù)據(jù):");
- OLED_ShowString(0,2,"in:",16);
- Uart_Send(UART1,(uint8_t *)ReceiveBuff,rlen);
- OLED_ShowString(28,2,(uint8_t *)ReceiveBuff,16);
- ee_printf("rn");
- uint8_t aton= (uint8_t)ReceiveBuff[0];
- uint32_t data=0;
- switch (aton) {
- case 111://"o"
- if(1==rlen) break;
- if(ReceiveBuff[1]=='n')
- {
- GPIO_Write(GPIOA,PIN8,GPIO_RESET);
- ee_printf("燈開(kāi)了!rn");
- }
- else if((ReceiveBuff[1]=='f')&&(ReceiveBuff[2]=='f'))
- {
- GPIO_Write(GPIOA,PIN8,GPIO_SET);
- ee_printf("關(guān)燈了!rn");
- }
- else
- {
- ee_printf("請(qǐng)輸入:on 或者off (開(kāi)燈/關(guān)燈)rn");
- }
- break;
- case 48://"0"
- ee_printf("nRTC_MTIME->mtimelo:%u n",_REG32(RTC_MTIME,0));
- ee_printf("nRTC_MTIME->mtimehi:%u n",_REG32(0x0200bff8UL,4));
- // uint64_t mtime1=RTC_MTIME->mtime;
- // ee_printf("nRTC_MTIME->mtime-all:%lu n",mtime1);
- break;
- default:
- break;
- }
- // if((ReceiveBuff[0]=='o')&&(ReceiveBuff[1]=='n'))
- // {
- // GPIO_Write(GPIOA,PIN8,GPIO_RESET);
- // ee_printf("燈開(kāi)了!rn");
- // }
- // else if((ReceiveBuff[0]=='o')&&(ReceiveBuff[1]=='f')&&(ReceiveBuff[2]=='f'))
- // {
- // GPIO_Write(GPIOA,PIN8,GPIO_SET);
- // ee_printf("關(guān)燈了!rn");
- // }
- // else
- // {
- // ee_printf("請(qǐng)輸入:on 或者off (開(kāi)燈/關(guān)燈)rn");
- // }
- uart_dev.frameok=0;
- uart_dev.rxlen=0;
- }
- if( rt_tick_get()%1000==0) ee_printf("time is %u s n",rt_tick_get()/1000);
- if(!( rt_tick_get()- rt_tick1< 10000)){
- rt_tick1 = rt_tick_get() ;
- GPIO_Toggle(GPIOB,PIN8);
- GPIO_Toggle(GPIOA,PIN10); //GPIO 翻轉(zhuǎn)
- // ee_printf("mcycle:%u n",read_csr(mcycle));
- ee_printf("rt_tick_get:%u n", rt_tick_get());
- ee_printf("RTC_MTIME->mtime:%lu ",RTC_MTIME->mtime);
- // ee_printf("type?RTC_MTIME->mtime:%lu n",type(RTC_MTIME->mtime));
- ee_printf("RTC_MTIME->mtime0-7B:");
- for (uint8_t i = 0; i < 8; i++)
- {
- ee_printf("%x ",_REG8(0x0200bff8UL,i));
- }
- ee_printf("nRTC_MTIME->mtime:%u n",_REG32(0x0200bff8UL,4));
- ee_printf("RTC_MTIMECMP->mtimecmp:%lu n",RTC_MTIMECMP->mtimecmp);
- // ee_printf("type?RTC_MTIME->mtime:%lu n",type(RTC_MTIMECMP->mtimecmp));
- ee_printf("->?RTC_MTIME->mtime:%p n",RTC_MTIMECMP->mtimecmp);
- ee_printf("RTC_MTIMECMP->mtimecmp0-7B:");
- for (uint8_t i = 0; i < 8; i++)
- {
- ee_printf("%x ",_REG8(0x02004000UL,i));
- }
- ee_printf(" n");
- }
- // Delay32M_ms(500);
- //Delay16M_ms(500);
- //Delay16M_us(500000);
- //GPIO_Toggle(GPIOA,PIN15);
- //printf("main:rn");
- ///---- Chapter 6 EXIT test ---------------------------------------------------------------------------------
- //delay16M_ms(500);
- //GPIO_Toggle(GPIOA,PIN15);
- ///---- Chapter 8 IWDG test ---------------------------------------------------------------------------------
- //IWDG_Refresh();
- //delay16M_ms(500);
- //GPIO_Toggle(GPIOA,PIN15);
- ///---- Chapter 9 Timer test --------------------------------------------------------------------------------
- //---- soft break --------------------------------------------------------------------------------------
- //delay16M_ms(100);
- //TIMER2->BDTR |= 1 <<15;//BDTR[15]-MOE-主輸出使能:0-關(guān)閉,1-使能
- //delay16M_ms(100);
- //TIMER2->EGR |= 1 <<7;//EGR[7]-BG-產(chǎn)生剎車(chē)事件
- //---- soft COM ----------------------------------------------------------------------------------------
- //delay16M_ms(100);
- //TIMER2->EGR = 1 <<5;//EGR[5]-COMG-捕獲/比較事件,產(chǎn)生控制更新
- //---- generate oxr ------------------------------------------------------------------------------------
- /*
- Delay16M_ms(10);//1
- GPIO_Write(GPIOA,PIN9,GPIO_SET);
- GPIO_Write(GPIOA,PIN11,GPIO_RESET);
- GPIO_Write(GPIOA,PIN13,GPIO_SET);
- Delay16M_ms(10);//2
- GPIO_Write(GPIOA,PIN9,GPIO_SET);
- GPIO_Write(GPIOA,PIN11,GPIO_RESET);
- GPIO_Write(GPIOA,PIN13,GPIO_RESET);
- Delay16M_ms(10);//3
- GPIO_Write(GPIOA,PIN9,GPIO_SET);
- GPIO_Write(GPIOA,PIN11,GPIO_SET);
- GPIO_Write(GPIOA,PIN13,GPIO_RESET);
- Delay16M_ms(10);//4
- GPIO_Write(GPIOA,PIN9,GPIO_RESET);
- GPIO_Write(GPIOA,PIN11,GPIO_SET);
- GPIO_Write(GPIOA,PIN13,GPIO_RESET);
- Delay16M_ms(10);//5
- GPIO_Write(GPIOA,PIN9,GPIO_RESET);
- GPIO_Write(GPIOA,PIN11,GPIO_SET);
- GPIO_Write(GPIOA,PIN13,GPIO_SET);
- Delay16M_ms(10);//6
- GPIO_Write(GPIOA,PIN9,GPIO_RESET);
- GPIO_Write(GPIOA,PIN11,GPIO_RESET);
- GPIO_Write(GPIOA,PIN13,GPIO_SET);
- */
- ///---- Chapter 11 ADC test ---------------------------------------------------------------------------------
- ///---- Chapter 12 I2C test ---------------------------------------------------------------------------------
- //I2C_Write(0x2d,0x55);//適用于非中斷模式
- //i2c_data = I2C_Read(0x2d);//適用于非中斷模式
- //printf("data:%xrn",i2c_data);
- //I2C_Write(0x2d,0xaa);//適用于非中斷模式
- //i2c_data = I2C_Read(0x2d);//適用于非中斷模式
- //printf("data:%xrn",i2c_data);
- //I2C_Write_IT(0x2d,0x55);//適用于中斷模式
- ///---- Chapter 13 SPI test --------------------------------------------------------------------------------
- //SPI1 Test
- //SPI_Transceive(SPI1,sTxpack,sRxpack,10);//非中斷模式
- //SPI1_RW_reg(WRITE_REG+0x05,0x53);//讀寫(xiě)Si24R1寄存器
- //REG_Data = SPI1_RW_reg(READ_REG+0x05,0);//讀寫(xiě)Si24R1寄存器
- //printf("rnREG5:%02x",REG_Data);
- //delay16M_ms(500);
- //SPI2 Test
- //SPI_Transceive(SPI2,sTxpack,sRxpack,10);//非中斷模式
- //SPI2_RW_reg(WRITE_REG+0x05,0x53);//讀寫(xiě)Si24R1寄存器
- //REG_Data = SPI2_RW_reg(READ_REG+0x05,0);//讀寫(xiě)Si24R1寄存器
- //printf("rnREG5:%02x",REG_Data);
- //delay16M_ms(500);
- ///---- Chapter 15 UART Test ------------------------------------------------------------------------------------
- //---- 非中斷模式數(shù)據(jù)回環(huán)測(cè)試 -------------------------------------------------------------------------------------
- //Uart_Reveive(UART1,upack1,10);//適用于非中斷發(fā)送模式
- //Uart_Send(UART1,upack1,10);//適用于非中斷發(fā)送模式
- //Uart_Reveive(UART2,upack2,10);//適用于非中斷發(fā)送模式
- //Uart_Send(UART2,upack2,10);//適用于非中斷發(fā)送模式
- //Uart_Reveive(UART3,upack3,10);//適用于非中斷發(fā)送模式
- //Uart_Send(UART3,upack3,10);//適用于非中斷發(fā)送模式
- //Uart_Reveive(UART4,upack4,10);//適用于非中斷發(fā)送模式
- //Uart_Send(UART4,upack4,10);//適用于非中斷發(fā)送模式
- //---- 中斷模式數(shù)據(jù)回環(huán)測(cè)試 --------------------------------------------------------------------------------------
- //UART1_putbuf(UART1_getbuf());
- //---- printf測(cè)試 ----------------------------------------------------------------------------------------
- //printf("Hellow-01234568789abcdefghijklmnopqrstuvwxyzrn");
- ///---- Chapter 17 RANDGEN test -----------------------------------------------------------------------------
- //rand_data = RAND_Get();//生成隨機(jī)數(shù)
- //printf("rand:0x%08x,%urn",rand_data,rand_data);
- //delay16M_ms(500);
- ///---- Chapter 18 COMPARE test -----------------------------------------------------------------------------
- //if(COMP1->irq&0x1)
- //{
- //GPIO_Toggle(GPIOA,PIN15);
- //COMP1->irq = 1;
- //}
- //delay16M_ms(10);
- }
- return 0;
- }
com:
Hello CSM32RV20:
mcycle:112549883
read_csr(mcycle):2
CMU->OSC_SR:d2
CMU->OSC_SR:210,OSC 時(shí)鐘已穩(wěn)定,RCOSC 時(shí)鐘已穩(wěn)定,:OSC 在為 MCU 提供時(shí)鐘;OSC 在為外設(shè)提供時(shí)鐘;
請(qǐng)輸入:on ???者off (開(kāi)燈/關(guān)燈)
收到數(shù)據(jù):
rt_tick_get:11529
RTC_MTIME->mtime:36899472 RTC_MTIME->mtime0-7B:4a 4c 33 2 0 0 0 0
RTC_MTIME->mtime:0
RTC_MTIMECMP->mtimecmp:36934400
->?RTC_MTIME->mtime:0233b880
RTC_MTIMECMP->mtimecmp0-7B:0 3 34 2 0 0 0 0
val:95avr:14062100 13.9mV 2047.5mV
time:0 day 0 hour' 0:16
收到數(shù)據(jù):0
RTC_MTIME->mtimelo:63461288
RTC_MTIME->mtimehi:0
rt_tick_get:21537
RTC_MTIME->mtime:68924127 RTC_MTIME->mtime0-7B:99 f5 1b 4 0 0 0 0
RTC_MTIME->mtime:0
RTC_MTIMECMP->mtimecmp:68960000
->?RTC_MTIME->mtime:041c6480
RTC_MTIMECMP->mtimecmp0-7B:0 a3 1c 4 0 0 0 0
聲明:本文內(nèi)容及配圖由入駐作者撰寫(xiě)或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。
舉報(bào)投訴
-
南京中科微
+關(guān)注
關(guān)注
0文章
60瀏覽量
789 -
CSM32RV20
+關(guān)注
關(guān)注
0文章
40瀏覽量
233
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
瑞芯微開(kāi)發(fā)板/主板Android系統(tǒng)APK簽名文件使用方法,實(shí)用干貨
瑞芯微主板/開(kāi)發(fā)板Android系統(tǒng),APK系統(tǒng)簽名文件使用方法
有獎(jiǎng)丨米爾 全志T536開(kāi)發(fā)板免費(fèi)試用
米爾與全志合作發(fā)布的新品基于全志T536應(yīng)用處理器的MYD-LT536-GK開(kāi)發(fā)板免費(fèi)試用活動(dòng)來(lái)啦~~米爾提供了3塊價(jià)值750元的MYD-LT536-GK開(kāi)發(fā)板發(fā)起試用活動(dòng)您不僅可以免
【敏矽微ME32G070開(kāi)發(fā)板免費(fèi)體驗(yàn)】開(kāi)箱+點(diǎn)燈+點(diǎn)亮OLED
ME32G070 支持硬件 I2C,這里偷個(gè)懶,不想使用繁瑣的跳線(xiàn),直接在開(kāi)發(fā)板上隨意插入 OLED 顯示屏的引腳,如下:
直接插上 OLED 顯示屏即可
由于 PB6、PB4
發(fā)表于 12-19 00:25
瑞芯微主板/開(kāi)發(fā)板Linux系統(tǒng)播放音頻方法,觸覺(jué)智能RK3562開(kāi)發(fā)板演示
本文介紹瑞芯微方案主板/開(kāi)發(fā)板Linux系統(tǒng)播放音頻的方法,觸覺(jué)智能RK3562開(kāi)發(fā)板演示,通用RK3566、RK3568、RK3588等
追加名額丨米爾瑞芯微RK3576開(kāi)發(fā)板有獎(jiǎng)試用
米爾與瑞芯微合作發(fā)布的新品基于瑞芯微RK3576應(yīng)用處理器的MYD-LR3576開(kāi)發(fā)板免費(fèi)試用活動(dòng)加碼啦~~米爾追加了2塊價(jià)值849元的MY
常用在工業(yè)控制系統(tǒng)上的MCU芯片資料:CSM32RV20
CSM32RV20是一款基于RISC-V核的低功耗MCU芯片。 內(nèi)置RISC-V RV32IMAC內(nèi)核(2.6CoreMark/MHz); 蕞高32MHz工作頻率; 內(nèi)置4kB的SRAM; 內(nèi)置8B
有獎(jiǎng)丨米爾 瑞芯微RK3576開(kāi)發(fā)板免費(fèi)試用
米爾與瑞芯微合作發(fā)布的新品基于瑞芯微RK3576應(yīng)用處理器的MYD-LR3576開(kāi)發(fā)板免費(fèi)試用活動(dòng)來(lái)啦~~米爾提供了7塊價(jià)值849元的MYD-LR3576
有獎(jiǎng)試用?。A-Eco-RA4E2-64PIN-V1.0開(kāi)發(fā)板試用活動(dòng)開(kāi)始報(bào)名
有獎(jiǎng)試用??!RA-Eco-RA4E2-64PIN-V1.0開(kāi)發(fā)板試用活動(dòng)開(kāi)始報(bào)名
【作品合集】龍芯2K0300蜂鳥(niǎo)開(kāi)發(fā)板試用精選
】+4.libmodbus移植【龍芯2K0300蜂鳥(niǎo)板試用】+3.移植lua到loongarch【龍芯2K0300蜂鳥(niǎo)板
發(fā)表于 09-10 18:17
【龍芯2K0300蜂鳥(niǎo)板試用】開(kāi)箱體驗(yàn)
本帖最后由 ele2022 于 2024-8-13 19:54 編輯
首先感謝電子發(fā)燒友和龍芯中科提供的試用機(jī)會(huì)。
今天開(kāi)箱體驗(yàn)龍芯中科的一款2K0300蜂鳥(niǎo)
發(fā)表于 08-12 19:59
點(diǎn)擊參與米爾NXP i.MX 93開(kāi)發(fā)板有獎(jiǎng)試用
米爾與NXP合作發(fā)布的新品基于NXPi.MX93應(yīng)用處理器的MYD-LMX9X開(kāi)發(fā)板免費(fèi)試用活動(dòng)來(lái)啦~~米爾提供了3塊價(jià)值678元的MYD-LMX9X開(kāi)發(fā)板發(fā)起試用活動(dòng)您不僅可以免費(fèi)體
免費(fèi)!NXP i.MX 93開(kāi)發(fā)板有獎(jiǎng)試用
米爾與NXP合作發(fā)布的新品基于NXPi.MX93應(yīng)用處理器的MYD-LMX9X開(kāi)發(fā)板免費(fèi)試用活動(dòng)來(lái)啦~~米爾提供了2塊價(jià)值678
香橙派發(fā)布首款RISC-V開(kāi)發(fā)板OrangePi RV
2024年3月,香橙派在全球開(kāi)發(fā)者會(huì)議上發(fā)布了其首款基于RISC-V開(kāi)發(fā)的OrangePi RV主板。這款開(kāi)發(fā)板擁有四核RISC-V U74與S7協(xié)處理器,配備
rv1126和rk3568對(duì)比
視頻編解碼。而RK3568開(kāi)發(fā)板創(chuàng)龍科技旗下工業(yè)開(kāi)發(fā)板,基于瑞芯微RK3568J/RK3568B2處理器設(shè)計(jì),四核ARM Cortex-A55,每核主頻高達(dá)1.8GHz/2.0GHz。
評(píng)論