0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示

【南京中科微CSM32RV20开发板试用体验】+3-adc DHT11的使用

开发板试用精选 来源:开发板试用 作者:电子发烧友论坛 2022-11-30 10:43 次阅读
本文来源电子发烧友社区,作者:卢松涛, 帖子地址:https://bbs.elecfans.com/jishu_2249215_1_1.html

在"
【南京中科微CSM32RV20开发板试用体验】+2-oled rtc的使用"基础上增加adc DHT11


adc的使用:
///---- 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();//内部基准,测PA4
//ADC_Init_case2();//外部基准,测PA4


10000ms ADC->SEL = 3; //测量通道选择:3-PAD4
串口控制 case 50://"2"
ADC->SEL = 0; //测量通道选择:0-PTAT 显示内部adc温度
DHT11的使用:
DHT11 GPIOB6
串口控制 case 49://"1"显示温度湿度



  1. #include "headfile.h"
  2. #ifndef __OLEDFONT_H
  3. #define __OLEDFONT_H
  4. #define DHT11_REV_DATAGPIO_Read(GPIOB,PIN6)
  5. //常用ASCII表
  6. //偏移量32
  7. //ASCII字符集
  8. //偏移量32
  9. //大小:12*6
  10. /************************************6*8的点阵************************************/
  11. const unsigned char F6x8[][6] =
  12. {
  13. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,// sp
  14. 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00,// !
  15. 0x00, 0x00, 0x07, 0x00, 0x07, 0x00,// "
  16. 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14,// #
  17. 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12,// $
  18. 0x00, 0x62, 0x64, 0x08, 0x13, 0x23,// %
  19. 0x00, 0x36, 0x49, 0x55, 0x22, 0x50,// &
  20. 0x00, 0x00, 0x05, 0x03, 0x00, 0x00,// '
  21. 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00,// (
  22. 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00,// )
  23. 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14,// *
  24. 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08,// +
  25. 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00,// ,
  26. 0x00, 0x08, 0x08, 0x08, 0x08, 0x08,// -
  27. 0x00, 0x00, 0x60, 0x60, 0x00, 0x00,// .
  28. 0x00, 0x20, 0x10, 0x08, 0x04, 0x02,// /
  29. 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0
  30. 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00,// 1
  31. 0x00, 0x42, 0x61, 0x51, 0x49, 0x46,// 2
  32. 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31,// 3
  33. 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10,// 4
  34. 0x00, 0x27, 0x45, 0x45, 0x45, 0x39,// 5
  35. 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6
  36. 0x00, 0x01, 0x71, 0x09, 0x05, 0x03,// 7
  37. 0x00, 0x36, 0x49, 0x49, 0x49, 0x36,// 8
  38. 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E,// 9
  39. 0x00, 0x00, 0x36, 0x36, 0x00, 0x00,// :
  40. 0x00, 0x00, 0x56, 0x36, 0x00, 0x00,// ;
  41. 0x00, 0x08, 0x14, 0x22, 0x41, 0x00,// <
  42. 0x00, 0x14, 0x14, 0x14, 0x14, 0x14,// =
  43. 0x00, 0x00, 0x41, 0x22, 0x14, 0x08,// >
  44. 0x00, 0x02, 0x01, 0x51, 0x09, 0x06,// ?
  45. 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E,// @
  46. 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C,// A
  47. 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36,// B
  48. 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22,// C
  49. 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C,// D
  50. 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41,// E
  51. 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01,// F
  52. 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A,// G
  53. 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F,// H
  54. 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00,// I
  55. 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01,// J
  56. 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41,// K
  57. 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40,// L
  58. 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F,// M
  59. 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F,// N
  60. 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E,// O
  61. 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06,// P
  62. 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q
  63. 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46,// R
  64. 0x00, 0x46, 0x49, 0x49, 0x49, 0x31,// S
  65. 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01,// T
  66. 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F,// U
  67. 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F,// V
  68. 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F,// W
  69. 0x00, 0x63, 0x14, 0x08, 0x14, 0x63,// X
  70. 0x00, 0x07, 0x08, 0x70, 0x08, 0x07,// Y
  71. 0x00, 0x61, 0x51, 0x49, 0x45, 0x43,// Z
  72. 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00,// [
  73. 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55,// 55
  74. 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00,// ]
  75. 0x00, 0x04, 0x02, 0x01, 0x02, 0x04,// ^
  76. 0x00, 0x40, 0x40, 0x40, 0x40, 0x40,// _
  77. 0x00, 0x00, 0x01, 0x02, 0x04, 0x00,// '
  78. 0x00, 0x20, 0x54, 0x54, 0x54, 0x78,// a
  79. 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38,// b
  80. 0x00, 0x38, 0x44, 0x44, 0x44, 0x20,// c
  81. 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F,// d
  82. 0x00, 0x38, 0x54, 0x54, 0x54, 0x18,// e
  83. 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02,// f
  84. 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C,// g
  85. 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78,// h
  86. 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00,// i
  87. 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00,// j
  88. 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00,// k
  89. 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00,// l
  90. 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78,// m
  91. 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78,// n
  92. 0x00, 0x38, 0x44, 0x44, 0x44, 0x38,// o
  93. 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18,// p
  94. 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC,// q
  95. 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08,// r
  96. 0x00, 0x48, 0x54, 0x54, 0x54, 0x20,// s
  97. 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20,// t
  98. 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C,// u
  99. 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C,// v
  100. 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C,// w
  101. 0x00, 0x44, 0x28, 0x10, 0x28, 0x44,// x
  102. 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C,// y
  103. 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44,// z
  104. 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,// horiz lines
  105. };
  106. /****************************************8*16的点阵************************************/
  107. const unsigned char F8X16[]=
  108. {
  109. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//0
  110. 0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//! 1
  111. 0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" 2
  112. 0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//# 3
  113. 0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$ 4
  114. 0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//% 5
  115. 0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//& 6
  116. 0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//' 7
  117. 0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//( 8
  118. 0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//) 9
  119. 0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//* 10
  120. 0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+ 11
  121. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//, 12
  122. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//- 13
  123. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//. 14
  124. 0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,/// 15
  125. 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//0 16
  126. 0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//1 17
  127. 0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//2 18
  128. 0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//3 19
  129. 0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//4 20
  130. 0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//5 21
  131. 0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//6 22
  132. 0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//7 23
  133. 0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//8 24
  134. 0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//9 25
  135. 0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//: 26
  136. 0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//; 27
  137. 0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//< 28
  138. 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//= 29
  139. 0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//> 30
  140. 0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//? 31
  141. 0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@ 32
  142. 0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A 33
  143. 0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B 34
  144. 0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C 35
  145. 0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D 36
  146. 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E 37
  147. 0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F 38
  148. 0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G 39
  149. 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H 40
  150. 0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I 41
  151. 0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J 42
  152. 0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K 43
  153. 0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L 44
  154. 0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M 45
  155. 0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N 46
  156. 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O 47
  157. 0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P 48
  158. 0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q 49
  159. 0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R 50
  160. 0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S 51
  161. 0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T 52
  162. 0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U 53
  163. 0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V 54
  164. 0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W 55
  165. 0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X 56
  166. 0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y 57
  167. 0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z 58
  168. 0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[ 59
  169. 0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,// 60
  170. 0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//] 61
  171. 0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^ 62
  172. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_ 63
  173. 0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//` 64
  174. 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a 65
  175. 0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b 66
  176. 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c 67
  177. 0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d 68
  178. 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e 69
  179. 0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f 70
  180. 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g 71
  181. 0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h 72
  182. 0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i 73
  183. 0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j 74
  184. 0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k 75
  185. 0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l 76
  186. 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m 77
  187. 0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n 78
  188. 0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o 79
  189. 0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p 80
  190. 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q 81
  191. 0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r 82
  192. 0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s 83
  193. 0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t 84
  194. 0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u 85
  195. 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v 86
  196. 0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w 87
  197. 0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x 88
  198. 0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y 89
  199. 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z 90
  200. 0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{ 91
  201. 0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//| 92
  202. 0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//} 93
  203. 0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~ 94
  204. };
  205. /***********************************************
  206. PCtoLCD2002设置
  207. 阴码,逆向,C51格式,十六进制数据,列行式,输出三个全选中
  208. 每行显示点阵9999,索引9999
  209. 格式: 段前缀 【无】;
  210. 段后缀 【无】;
  211. 注释前缀(右边空格去掉) 【/ *"】;
  212. 注释后缀 【",】;
  213. 数据后缀 【,】;
  214. 行前缀 【{】;
  215. 行后缀 【},】
  216. **********************************************/
  217. /***********************************
  218. 16x16汉字
  219. 取字软件:PCtoLCD2002
  220. 使用方法见文档
  221. ***********************************/
  222. const unsigned char Chinese_Word_16[][32]= {
  223. {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*/
  224. {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*/
  225. {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*/
  226. {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*/
  227. };
  228. #endif
  229. void mp_receive_data(uint8_t *buf, uint16_t *len)
  230. {
  231. uint8_t rxlen = UART1_RX_CNT;
  232. uint16_t i = 0;
  233. *len = 0; //默认为0
  234. Delay32M_ms(10); //等待40ms,连续超过10ms没有接收到一个数据,则认为接收结束
  235. if (rxlen == UART1_RX_CNT && rxlen) //接收到了数据,且接收完成了
  236. {
  237. for (i = 0; i < rxlen; i++)
  238. {
  239. buf[i] = uart_dev.rxbuf[i];
  240. }
  241. *len = UART1_RX_CNT; //记录本次数据长度
  242. UART1_RX_CNT = 0; //清零
  243. uart_dev.frameok=1; //标记完成一帧数据接收
  244. // getData=0;//数据接收完成,标志位清零
  245. }
  246. }
  247. #define Max_Column 128
  248. void OLED_Write_IIC_Command(uint8_t IIC_Command)
  249. {
  250. I2C_Write(0x00,IIC_Command);
  251. }
  252. void OLED_Write_IIC_Data(uint8_t IIC_Data)
  253. {
  254. I2C_Write(0x40,IIC_Data);
  255. }
  256. /**
  257. * @brief :OLED_Clear
  258. * [url=home.php?mod=space&uid=1902110]@NOTE[/url] : --清屏函数
  259. --清完屏,整个屏幕是黑色的!和没点亮一样
  260. * @param : >>
  261. >>
  262. * @return :void
  263. *
  264. * @date :2021/01/29
  265. * [url=home.php?mod=space&uid=44345]@design[/url] :
  266. **/
  267. void OLED_Clear(void)
  268. {
  269. uint8_t i,n;
  270. for(i=0; i<8; i++)
  271. {
  272. OLED_Write_IIC_Command (0xb0+i); //设置页地址(0~7)
  273. OLED_Write_IIC_Command (0x00); //设置显示位置—列低地址
  274. OLED_Write_IIC_Command (0x10); //设置显示位置—列高地址
  275. for(n=0; n<128; n++)
  276. {
  277. OLED_Write_IIC_Data(0x00);
  278. }
  279. }
  280. //更新显示
  281. }
  282. /**
  283. * @brief :OLED_Set_Pos
  284. * @note : --坐标设置
  285. * @param : >>
  286. >>
  287. * @return :void
  288. *
  289. * @date :2021/01/29
  290. * @design :
  291. **/
  292. void OLED_Set_Pos(uint8_t x, uint8_t y)
  293. { OLED_Write_IIC_Command(0xb0+y);
  294. OLED_Write_IIC_Command(((x&0xf0)>>4)|0x10);
  295. OLED_Write_IIC_Command((x&0x0f));
  296. }
  297. /**
  298. * @brief :OLED_ShowChar
  299. * @note : --在指定位置显示一个字符,包括部分字符
  300. --例如:OLED_ShowChar(20,6,'A',16);
  301. * @param : >>
  302. >>x:0~127
  303. >>y:0~6
  304. >>mode:0,反白显示;1,正常显示
  305. >>size:选择字体 8/16
  306. * @return :void
  307. *
  308. * @date :2021/01/29
  309. * @design :
  310. **/
  311. void OLED_ShowChar(uint8_t x,uint8_t y,uint8_t chr,uint8_t Char_Size)
  312. {
  313. uint8_t c=0,i=0;
  314. c=chr-' ';//得到偏移后的值
  315. if(x>Max_Column-1) {
  316. x=0;
  317. y=y+2;
  318. }
  319. if(Char_Size ==16)
  320. {
  321. OLED_Set_Pos(x,y);
  322. for(i=0; i<8; i++)
  323. OLED_Write_IIC_Data(F8X16[c*16+i]);
  324. OLED_Set_Pos(x,y+1);
  325. for(i=0; i<8; i++)
  326. OLED_Write_IIC_Data(F8X16[c*16+i+8]);
  327. }
  328. else
  329. {
  330. OLED_Set_Pos(x,y);
  331. for(i=0; i<6; i++)
  332. OLED_Write_IIC_Data(F6x8[c][i]);
  333. }
  334. }
  335. /**
  336. * @brief :OLED_ShowString
  337. * @note : --显示一个字符号串
  338. --例如:
  339. u8 SET[2][3] = {{"ON "},{"OFF"}};
  340. OLED_ShowString(0,0,SET[0],8);
  341. * @param : >>
  342. >>size:选择字体 8/16
  343. * @return :void
  344. *
  345. * @date :2021/01/29
  346. * @design :
  347. **/
  348. void OLED_ShowString(uint8_t x,uint8_t y,uint8_t *chr,uint8_t Char_Size)
  349. {
  350. while (*chr!='')
  351. { OLED_ShowChar(x,y,*chr,Char_Size);
  352. x+=8;
  353. if(x>120) {
  354. x=0;
  355. y+=2;
  356. }
  357. chr++;
  358. }
  359. }
  360. /**********************************************
  361. //m^n函数
  362. **********************************************/
  363. uint32_t oled_pow(uint8_t m,uint8_t n)
  364. {
  365. uint32_t result=1;
  366. while(n--)result*=m;
  367. return result;
  368. }
  369. /**
  370. * @brief :OLED_ShowNumber
  371. * @note : --显示数字
  372. --例如:OLED_ShowNumber(0,0,45125215,10);
  373. * @param : >>x,y :起点坐标
  374. >>len :数字的位数
  375. >>size:字体大小默认16
  376. >>num:数值(0~4294967295);
  377. * @return :void
  378. *
  379. * @date :2021/01/29
  380. * @design :
  381. **/
  382. void OLED_ShowNumber(uint8_t x,uint8_t y,uint32_t num,uint8_t len)
  383. {
  384. uint8_t size2 = 16;
  385. uint8_t t,temp;
  386. uint8_t enshow=0;
  387. for(t=0; t;>
  388. {
  389. temp=(num/oled_pow(10,len-t-1))%10;
  390. if(enshow==0&&t<(len-1))
  391. {
  392. if(temp==0)
  393. {
  394. OLED_ShowChar(x+(size2/2)*t,y,' ',size2);
  395. continue;
  396. } else enshow=1;
  397. }
  398. OLED_ShowChar(x+(size2/2)*t,y,temp+'0',size2);
  399. }
  400. }
  401. //初始化SSD1306
  402. void OLED_Init(void)
  403. {
  404. // OLED_GPIO_Init();
  405. Delay32M_ms(1500);
  406. // OLED_WR_Byte(0xAE,OLED_CMD);//--display off
  407. // OLED_WR_Byte(0x00,OLED_CMD);//---set low column address
  408. // OLED_WR_Byte(0x10,OLED_CMD);//---set high column address
  409. // OLED_WR_Byte(0x40,OLED_CMD);//--set start line address
  410. // OLED_WR_Byte(0xB0,OLED_CMD);//--set page address
  411. // OLED_WR_Byte(0x81,OLED_CMD); // contract control
  412. // OLED_WR_Byte(0xFF,OLED_CMD);//--128
  413. // OLED_WR_Byte(0xA1,OLED_CMD);//set segment remap
  414. // OLED_WR_Byte(0xA6,OLED_CMD);//--normal / reverse
  415. // OLED_WR_Byte(0xA8,OLED_CMD);//--set multiplex ratio(1 to 64)
  416. // OLED_WR_Byte(0x3F,OLED_CMD);//--1/32 duty
  417. // OLED_WR_Byte(0xC8,OLED_CMD);//Com scan direction
  418. // OLED_WR_Byte(0xD3,OLED_CMD);//-set display offset
  419. // OLED_WR_Byte(0x00,OLED_CMD);//
  420. // OLED_WR_Byte(0xD5,OLED_CMD);//set osc division
  421. // OLED_WR_Byte(0x80,OLED_CMD);//
  422. // OLED_WR_Byte(0xD8,OLED_CMD);//set area color mode off
  423. // OLED_WR_Byte(0x05,OLED_CMD);//
  424. // OLED_WR_Byte(0xD9,OLED_CMD);//Set Pre-Charge Period
  425. // OLED_WR_Byte(0xF1,OLED_CMD);//
  426. // OLED_WR_Byte(0xDA,OLED_CMD);//set com pin configuartion
  427. // OLED_WR_Byte(0x12,OLED_CMD);//
  428. // OLED_WR_Byte(0xDB,OLED_CMD);//set Vcomh
  429. // OLED_WR_Byte(0x30,OLED_CMD);//
  430. // OLED_WR_Byte(0x8D,OLED_CMD);//set charge pump enable
  431. // OLED_WR_Byte(0x14,OLED_CMD);//
  432. // OLED_WR_Byte(0xAF,OLED_CMD);//--turn on oled panel
  433. OLED_Write_IIC_Command(0xAE); //display off
  434. OLED_Write_IIC_Command(0x20); //Set Memory Addressing Mode
  435. OLED_Write_IIC_Command(0x10); //00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid
  436. OLED_Write_IIC_Command(0xb0); //Set Page Start Address for Page Addressing Mode,0-7
  437. OLED_Write_IIC_Command(0xc8); //Set COM Output Scan Direction
  438. OLED_Write_IIC_Command(0x00); //---set low column address
  439. OLED_Write_IIC_Command(0x10); //---set high column address
  440. OLED_Write_IIC_Command(0x40); //--set start line address
  441. OLED_Write_IIC_Command(0x81); //--set contrast control register
  442. OLED_Write_IIC_Command(0xff); //亮度调节 0x00~0xff
  443. OLED_Write_IIC_Command(0xa1); //--set segment re-map 0 to 127
  444. OLED_Write_IIC_Command(0xa6); //--set normal display
  445. OLED_Write_IIC_Command(0xa8); //--set multiplex ratio(1 to 64)
  446. OLED_Write_IIC_Command(0x3F); //
  447. OLED_Write_IIC_Command(0xa4); //0xa4,Output follows RAM content;0xa5,Output ignores RAM content
  448. OLED_Write_IIC_Command(0xd3); //-set display offset
  449. OLED_Write_IIC_Command(0x00); //-not offset
  450. OLED_Write_IIC_Command(0xd5); //--set display clock divide ratio/oscillator frequency
  451. OLED_Write_IIC_Command(0xf0); //--set divide ratio
  452. OLED_Write_IIC_Command(0xd9); //--set pre-charge period
  453. OLED_Write_IIC_Command(0x22); //
  454. OLED_Write_IIC_Command(0xda); //--set com pins hardware configuration
  455. OLED_Write_IIC_Command(0x12);
  456. OLED_Write_IIC_Command(0xdb); //--set vcomh
  457. OLED_Write_IIC_Command(0x20); //0x20,0.77xVcc
  458. OLED_Write_IIC_Command(0x8d); //--set DC-DC enable
  459. OLED_Write_IIC_Command(0x14); //
  460. OLED_Write_IIC_Command(0xaf); //--turn on oled panel
  461. }
  462. uint16_t Tempture=0;
  463. uint16_t Humi=0;
  464. //void DHT11_Init(void);
  465. //int DHT11_Read_Data(void);
  466. static void DHT11_SEND_DATA(uint8_t value)
  467. {
  468. if(value==1)
  469. {
  470. GPIO_Write(GPIOB,PIN6,GPIO_SET);
  471. }
  472. else
  473. {
  474. GPIO_Write(GPIOB,PIN6,GPIO_RESET);
  475. }
  476. }
  477. #if 0//0---库函数1---寄存器
  478. // DTH11---> PB6
  479. // 输出模式(GPIOB,PIN6)
  480. void DHT11_OUT(void)
  481. {
  482. GPIOB->CRL &=~ (0xf<<24);
  483. GPIOB->CRL |=(3<<24);//通用推挽输出模式 50M
  484. }
  485. // 输入模式
  486. void DHT11_IN(void)
  487. {
  488. GPIOB->CRL &=~ (0xf<<24);
  489. GPIOB->CRL |=(4<<24);//配置浮空输入(外接上拉电阻)
  490. }
  491. //DHT11初始化
  492. void DHT11_Init(void)
  493. {
  494. RCC->APB2ENR |= (1<<3); // 开启PB端口时钟
  495. DHT11_IN( );// DHT11 的DATA 引脚处于输入状态,时刻检测外部信号
  496. Delay32M_ms(500);
  497. Delay32M_ms(500);//DHT11 上电后要等待 1S 以越过不稳定状态在此期间不能发送任何指令
  498. }
  499. #else
  500. // DTH11---> PB6
  501. // 输出模式
  502. void DHT11_OUT(void)
  503. {
  504. GPIO_MODE_Init(GPIOB,PIN6,GPIO_MODE_OUTPUT); //GPIO 模式
  505. GPIO_PULL_Init(GPIOB,PIN6,GPIO_PULLUP); //GPIO 上拉//PB6
  506. }
  507. // 输入模式
  508. void DHT11_IN(void)
  509. {
  510. GPIO_MODE_Init(GPIOB,PIN6,GPIO_MODE_INPUT); //GPIO 模式
  511. GPIO_PULL_Init(GPIOB,PIN6,GPIO_PULLUP); //GPIO
  512. }
  513. //DHT11初始化
  514. void DHT11_Init(void)
  515. {
  516. DHT11_OUT( );// DHT11 的DATA 引脚处于输出状态
  517. Delay32M_ms(500);
  518. Delay32M_ms(500);//DHT11 上电后要等待 1S 以越过不稳定状态在此期间不能发送任何指令
  519. }
  520. #endif
  521. //起始信号
  522. void DHT11_Start(void)
  523. {
  524. DHT11_SEND_DATA(0);
  525. Delay32M_ms(20);
  526. DHT11_SEND_DATA(1);
  527. Delay32M_us(35);//释放总线
  528. }
  529. //应答信号
  530. //返回值 0--无应答1--有应答
  531. uint8_t DHT11_Ack(void)
  532. {
  533. uint8_t count=20;
  534. while(count-->0)
  535. {
  536. if(DHT11_REV_DATA!=0)
  537. {
  538. Delay16M_us(2);
  539. continue;
  540. }
  541. while(DHT11_REV_DATA==0);//等待80us低电平应答结束
  542. while(DHT11_REV_DATA==1);//等待80us高电平应答结束
  543. return 1;
  544. }
  545. return 0;
  546. }
  547. //读取一个字节数据
  548. uint8_t DHT11_Read_Byte(void)
  549. {
  550. uint8_t data=0;
  551. uint8_t i;
  552. //接受数据,每个数据以50us低电平开始
  553. for(i=0;i<8;i++)
  554. {
  555. data <<= 1;
  556. while(!DHT11_REV_DATA);//等待发送数据的时序变为高电平
  557. Delay32M_us(40);//23~27u为数据0,68~74us为u数据1
  558. if(DHT11_REV_DATA==1)
  559. {
  560. data |=1;//数据1
  561. while(DHT11_REV_DATA);//等待高电平应答结束
  562. }
  563. }
  564. return data;
  565. }
  566. //读取温湿度
  567. int DHT11_Read_Data()
  568. {
  569. uint8_t check;
  570. uint8_t Humi_H,Humi_L,Temp_H,Temp_L;
  571. DHT11_OUT( );
  572. DHT11_Start( );
  573. DHT11_IN( );//切换为输入
  574. if( DHT11_Ack( )==0 )
  575. {
  576. return -1;
  577. }
  578. //读取数据
  579. Temp_H=DHT11_Read_Byte( );
  580. Temp_L=DHT11_Read_Byte( );
  581. Humi_H=DHT11_Read_Byte( );
  582. Humi_L=DHT11_Read_Byte( );
  583. check=DHT11_Read_Byte( );
  584. // ee_printf("rn%02xrn",Temp_H);
  585. // ee_printf("%02xrn",Temp_L);
  586. // ee_printf("%02xrn",Humi_H);
  587. // ee_printf("%02xrn",Humi_L);
  588. //结束读取
  589. Delay32M_ms(50);
  590. DHT11_OUT( );//切换为输出
  591. DHT11_SEND_DATA(1);//释放总线
  592. //校验数据
  593. if(check !=(Temp_H+Temp_L+Humi_H+Humi_L) )
  594. {
  595. return -2;
  596. }
  597. Tempture=(Temp_H&0xFF)<<8+Temp_L;
  598. Humi=(Humi_H&0xFF)<<8+Humi_L;
  599. return 0;
  600. }
  601. uint8_t ReceiveBuff[RECV_LEN];
  602. int main(void)
  603. {
  604. uint16_t rlen=0;
  605. uart_dev.rxlen=0;
  606. ///----System Init ---------------------------------------------------------------------------------------------
  607. CLIC_Init();//系统中断配置
  608. System_Clock_Init();//系统时钟初始化
  609. DHT11_Init();
  610. ///----Chapter 3 LowPower Test Init ---------------------------------------------------------------------------------
  611. //低功耗测功耗需要IO不能悬空
  612. //Delay32M_ms(5000);
  613. //LowPower_Config_case1();//所有IO设置为输入,下拉
  614. //LowPower_Config_case2();//所有IO设置为输入,上拉
  615. //使用外部中断唤醒
  616. //GPIO_EXIT_Init_case1(GPIOA, PIN2);//检测高电平
  617. //Interrupt_Level(EXIT2_int_ID, INT_LEVEL0);//CLIC设置中断抢占级别
  618. //Interrupt_Enable(EXIT2_int_ID);//CLIC使能EXIT中断
  619. //SYS_Interrupt_Enable();//CLIC开总中断
  620. //配置不同低功耗模式
  621. //System_Halt();//待机模式 halt1
  622. //System_Sleep();//睡眠模式 halt2
  623. //System_Powerdown();//掉电模式 powerdown1
  624. //System_DeepPwd();//掉电模式 powerdown2
  625. ///----Chapter 5 GPIO Test Init ---------------------------------------------------------------------------------
  626. GPIO_MODE_Init(GPIOA,PIN8,GPIO_MODE_OUTPUT); //GPIO 模式
  627. GPIO_MODE_Init(GPIOA,PIN10,GPIO_MODE_OUTPUT); //GPIO 模式
  628. GPIO_MODE_Init(GPIOA,PIN12,GPIO_MODE_OUTPUT); //GPIO 模式
  629. //GPIO_MODE_Init(GPIOA,PIN14,GPIO_MODE_OUTPUT); //GPIO 模式
  630. //GPIO_MODE_Init(GPIOA,PIN15,GPIO_MODE_OUTPUT); //GPIO 模式
  631. //GPIO_Write(GPIOA,PIN8,GPIO_SET); //GPIO 输出
  632. //GPIO_Write(GPIOA,PIN10,GPIO_SET); //GPIO 输出
  633. //GPIO_Write(GPIOA,PIN12,GPIO_SET); //GPIO 输出
  634. //GPIO_Write(GPIOA,PIN14,GPIO_RESET); //GPIO 输出
  635. //GPIO_Write(GPIOA,PIN15,GPIO_RESET); //GPIO 输出
  636. //GPIO_Toggle(GPIOA,PIN15); //GPIO 翻转
  637. //GPIO_MODE_Init(GPIOA,PIN15,GPIO_MODE_INTPUT); //GPIO 模式
  638. for(uint8_t i=0;i<10;i++)
  639. {
  640. GPIO_Toggle(GPIOA,PIN8); //GPIO 翻转
  641. Delay32M_ms(100);
  642. }
  643. ///---- Chapter 6 EXIT Test Init -------------------------------------------------------------------------------------
  644. //GPIO_EXIT_Init_case1(GPIOA, PIN2);//检测高电平
  645. //GPIO_EXIT_Init_case2(GPIOA, PIN2);//检测低电平
  646. //GPIO_EXIT_Init_case3(GPIOA, PIN2);//检测上升沿
  647. //GPIO_EXIT_Init_case4(GPIOA, PIN2);//检测下降沿
  648. //Interrupt_Level(EXIT2_int_ID, INT_LEVEL0);//CLIC设置中断抢占级别
  649. //Interrupt_Enable(EXIT2_int_ID);//CLIC使能EXIT中断
  650. //载波检测中断
  651. //CAW_Init();//载波检测
  652. //Interrupt_Enable(CAW_int_ID);//CLIC使能中断
  653. //SYS_Interrupt_Enable();//CLIC开总中断
  654. ///---- Chapter 7 RTC Test Init --------------------------------------------------------------------------------------
  655. //RTC_Init_case1();
  656. RTC_Init_case2();
  657. Interrupt_Level(MTIMER_int_ID, INT_LEVEL2 );//CLIC设置中断抢占级别
  658. Interrupt_Enable(MTIMER_int_ID);//CLIC使能中断
  659. SYS_Interrupt_Enable();//CLIC开总中断
  660. ///---- Chapter 8 IWDG Test Init -------------------------------------------------------------------------------------
  661. //IWDG_Init(9000); //配置看门狗计数值(时钟频率3K)
  662. //Delay32M_ms(1000);
  663. //IWDG_Start(); //启动看门狗
  664. //IWDG_Refresh(); //喂狗
  665. ///---- Chapter 9 Timer Test Init ------------------------------------------------------------------------------------
  666. //GPIO_MODE_Init(GPIOB,PIN11,GPIO_MODE_OUTPUT); //GPIO 模式
  667. //GPIO_MODE_Init(GPIOA,PIN9,GPIO_MODE_OUTPUT);
  668. //GPIO_MODE_Init(GPIOA,PIN11,GPIO_MODE_OUTPUT);
  669. //GPIO_MODE_Init(GPIOA,PIN13,GPIO_MODE_OUTPUT);
  670. //外设配置
  671. //Timer1_UpCounting_Mode_Init();//向上计数
  672. //Timer1_6StepPWM_Mode_Init();//6stepPWM输出
  673. //Timer2_UpCounting_Mode_Init();//向上计数
  674. //Timer2_DownCounting_Mode_Init();//向下计数
  675. //Timer2_ExternalClock_Mode_Init();//外部时钟
  676. //Timer2_InputCapture_Mode_Init();//输入捕获
  677. //Timer2_PWM_InputCapture_Mode_Init();//PWM输入捕获
  678. //Timer2_Input_XOR_Mode_Init();//输入异或
  679. //Timer2_PWM_Mode_Init();//PWM输出
  680. //Timer2_6StepPWM_Mode_Init();//6stepPWM输出
  681. //设置中断优先级
  682. //Interrupt_Level(TIMER1_updata_int_ID, INT_LEVEL1);//CLIC设置中断抢占级别
  683. //使能外设中断
  684. //Interrupt_Enable(TIMER1_break_int_ID);//CLIC使能中断
  685. //Interrupt_Enable(TIMER1_updata_int_ID);//CLIC使能中断
  686. //Interrupt_Enable(TIMER1_capture_compare_int_ID);//CLIC使能中断
  687. //Interrupt_Enable(TIMER1_trigger_comm_int_ID);//CLIC使能中断
  688. //Interrupt_Enable(TIMER2_break_int_ID);//CLIC使能中断
  689. //Interrupt_Enable(TIMER2_updata_int_ID);//CLIC使能中断
  690. //Interrupt_Enable(TIMER2_capture_compare_int_ID);//CLIC使能中断
  691. //Interrupt_Enable(TIMER2_trigger_comm_int_ID);//CLIC使能中断
  692. //使能系统总中断
  693. //SYS_Interrupt_Enable();//CLIC开总中断
  694. ///---- Chapter 10 WUP Test Init -------------------------------------------------------------------------------------
  695. //GPIO_MODE_Init(GPIOA,PIN2,GPIO_MODE_OUTPUT);
  696. //GPIO_MODE_Init(GPIOA,PIN3,GPIO_MODE_OUTPUT);
  697. //WUP_Init_case1(9000);//设置中断周期,使能WUP中断
  698. //Interrupt_Enable(WUP_int_ID);//CLIC使能中断
  699. //SYS_Interrupt_Enable();//CLIC开总中断
  700. //配置不同低功耗模式
  701. //System_Halt();//待机模式 halt1
  702. //System_Sleep();//睡眠模式 halt2
  703. //System_Powerdown();//掉电模式 powerdown1
  704. //System_DeepPwd();//掉电模式 powerdown2
  705. ///---- Chapter 11 ADC Test Init -------------------------------------------------------------------------------------
  706. uint32_t adc_result;
  707. uint32_t adc_pack[16];
  708. uint32_t adc_sum;
  709. uint32_t adc_count;
  710. uint32_t adc_avr;
  711. uint32_t voltage_avr;
  712. ADC_Init_case1();//内部基准,测PA4
  713. //ADC_Init_case2();//外部基准,测PA4
  714. ///---- Chapter 12 I2C Test Init -------------------------------------------------------------------------------------
  715. uint8_t i2c_data;
  716. I2C_Init_case1();//非中断模式
  717. //I2C_Init_case2();//ready中断模式
  718. //I2C_Init_case3();//error中断模式
  719. //I2C_Init_case4();//ready & error中断模式
  720. //Interrupt_Enable(I2C_ready_int_ID);//CLIC使能i2c_ready中断
  721. //Interrupt_Enable(I2C_error_int_ID);//CLIC使能i2c_error中断
  722. //SYS_Interrupt_Enable();//CLIC开总中断
  723. OLED_Init();
  724. ///---- Chapter 13 SPI1 Test Init ------------------------------------------------------------------------------------
  725. //uint8_t sTxpack[10] = {0,1,2,3,4,5,6,7,8,9};
  726. //uint8_t sRxpack[10] = {0,1,2,3,4,5,6,7,8,9};
  727. //uint8_t REG_Data;
  728. //SPI1 Init Test
  729. //SPI_Init_case1(SPI1);//非中断模式
  730. //SPI1_CSN_Init_case1();//CFG: CE-GPIO7,CSN-GPIO8
  731. //SPI_Init_case2(SPI1);//中断模式
  732. //Interrupt_Enable(SPI1_int_ID);//CLIC使能单个中断
  733. //SPI2 Init Test
  734. //SPI_Init_case1(SPI2);//非中断模式
  735. //SPI2_CSN_Init_case1();//CFG: CE-GPIO7,CSN-GPIO8
  736. //SPI_Init_case2(SPI2);//中断模式
  737. //Interrupt_Enable(SPI2_int_ID);//CLIC使能单个中断
  738. ///---- Chapter 15 UART Test Init -------------------------------------------------------------------------------
  739. //uint8_t upack1[20] = {0,1,2,3,4,5,6,7,8,9};
  740. //uint8_t upack2[20] = {0,1,2,3,4,5,6,7,8,9};
  741. //uint8_t upack3[20] = {0,1,2,3,4,5,6,7,8,9};
  742. //uint8_t upack4[20] = {10,1,2,3,4,5,6,7,8,9};
  743. //UART_Init_case1(UART2);//非中断模式
  744. //UART_Init_case1(UART3);//非中断模式
  745. //UART_Init_case1(UART4);//非中断模式
  746. UART_Init_IT_case1(UART1);//中断模式
  747. //UART_Init_IT_case1(UART4);//中断模式
  748. Interrupt_Enable(UART1_int_ID);//CLIC使能单个中断
  749. UART1->CTRL |= 0x00000001U;//清除中断标志位,防止开机先进一次中断
  750. //Interrupt_Enable(UART4_int_ID);//CLIC使能单个中断
  751. SYS_Interrupt_Enable();//CLIC开总中断
  752. //printf("uart init:rn");
  753. ///---- Chapter 16 LV Test Init --------------------------------------------------------------------------------------
  754. //LV_Init_case1(12);//设置低压报警阈值
  755. //LV_Interrupt_Enable();//使能低压报警中断
  756. //Interrupt_Enable(LV_int_ID);//CLIC使能单个中断
  757. //SYS_Interrupt_Enable();//CLIC开总中断
  758. ///---- Chapter 17 RANDGEN Test Init ---------------------------------------------------------------------------------
  759. //uint32_t rand_data;
  760. ///---- Chapter 18 compare Test Init ---------------------------------------------------------------------------------
  761. //COPM1_Init();//COPM1
  762. //Interrupt_Enable(COMP1_int_ID);//CLIC使能单个中断
  763. //COPM2_Init();//COPM2
  764. //Interrupt_Enable(COMP2_int_ID);//CLIC使能单个中断
  765. //COPM3_Init();//COPM3
  766. //Interrupt_Enable(COMP3_int_ID);//CLIC使能单个中断
  767. //SYS_Interrupt_Enable();//CLIC开总中断
  768. ///---- Chapter 22 flash Test Init ----------------------------------------------------------------------------------
  769. //NVR_RW_Test();//NVR read and write test
  770. //Flash_RW_Test();
  771. ///---- 系统总中断控制 -------------------------------------------------------------------------------------------------
  772. //SYS_Interrupt_Enable();//CLIC开总中断
  773. //SYS_Interrupt_Disable();//CLIC关总中断
  774. adc_pack[0]=read_csr(mcycle);
  775. adc_pack[1]=read_csr(mcycle);
  776. ee_printf("nHello CSM32RV20:n");
  777. ee_printf("mcycle:%d n",read_csr(mcycle));//比如mcycle这一CSR用于处理器运行的时钟周期计数
  778. ee_printf("read_csr(mcycle):%d n",adc_pack[1]-adc_pack[0]);//比如mcycle这一CSR用于处理器运行的时钟周期计数
  779. ee_printf("CMU->OSC_SR:%x n",CMU->OSC_SR );
  780. if(CMU->OSC_SR==210 ) ee_printf("CMU->OSC_SR:210,OSC 时钟已稳定,RCOSC 时钟已稳定,:OSC 在为 MCU 提供时钟;OSC 在为外设提供时钟; n" );
  781. //printf("Hello CSM32RV20:rn");
  782. ee_printf("请输入:on 或者off (开灯/关灯)rn");
  783. uint32_t rt_tick1 = rt_tick_get();
  784. uint32_t rt_tick2 = rt_tick_get();
  785. OLED_Clear();
  786. Delay32M_ms(1000);
  787. // OLED_Light();
  788. // OLED_DrawBMP(0,0,128,8,BAD_APPLE);
  789. OLED_ShowString(0,0,"CSM32 TEST",16);
  790. while(1)
  791. {
  792. mp_receive_data(ReceiveBuff, &rlen);
  793. if(uart_dev.frameok==1)//如果接收到数据
  794. {
  795. ee_printf("收到数据:");
  796. OLED_ShowString(0,2,"in:",16);
  797. Uart_Send(UART1,(uint8_t *)ReceiveBuff,rlen);
  798. OLED_ShowString(28,2,(uint8_t *)ReceiveBuff,16);
  799. ee_printf("rn");
  800. uint8_t aton= (uint8_t)ReceiveBuff[0];
  801. uint32_t data=0;
  802. switch (aton) {
  803. case 111://"o"
  804. if(1==rlen) break;
  805. if(ReceiveBuff[1]=='n')
  806. {
  807. GPIO_Write(GPIOA,PIN8,GPIO_RESET);
  808. ee_printf("灯开了!rn");
  809. }
  810. else if((ReceiveBuff[1]=='f')&&(ReceiveBuff[2]=='f'))
  811. {
  812. GPIO_Write(GPIOA,PIN8,GPIO_SET);
  813. ee_printf("关灯了!rn");
  814. }
  815. else
  816. {
  817. ee_printf("请输入:on 或者off (开灯/关灯)rn");
  818. }
  819. break;
  820. case 48://"0"
  821. ee_printf("nRTC_MTIME->mtimelo:%u n",_REG32(RTC_MTIME,0));
  822. ee_printf("nRTC_MTIME->mtimehi:%u n",_REG32(0x0200bff8UL,4));
  823. // uint64_t mtime1=RTC_MTIME->mtime;
  824. // ee_printf("nRTC_MTIME->mtime-all:%lu n",mtime1);
  825. break;
  826. case 49://"1"
  827. data=DHT11_Read_Data();
  828. if(data==0)
  829. {
  830. OLED_ShowString(0,2,"T:",16);
  831. OLED_ShowNumber(20,2,Tempture/1000,2);
  832. OLED_ShowString(36,2,".",16);
  833. OLED_ShowNumber(46,2,Tempture%1000,3);
  834. OLED_ShowString(0,4,"H:",16);
  835. OLED_ShowNumber(20,4,Humi/1000,2);
  836. OLED_ShowString(36,4,".",16);
  837. OLED_ShowNumber(40,4,Humi%1000,3);
  838. }
  839. ee_printf("Tempture:%u.%u Humi:%u.%un",Tempture/1000 ,Tempture%1000,Humi/1000,Humi%1000);
  840. adc_pack[0]=read_csr(mcycle);
  841. adc_pack[1]=read_csr(mcycle);
  842. ee_printf("read_csr(mcycle):%d n",adc_pack[1]-adc_pack[0]);//比如mcycle这一CSR用于处理器运行的时钟周期计数
  843. ee_printf("mcycle:%d n",read_csr(mcycle));//比如mcycle这一CSR用于处理器运行的时钟周期计数
  844. Delay32M_ms(2000);
  845. data=DHT11_Read_Data();
  846. if(data==0)
  847. {
  848. OLED_ShowString(0,2,"T:",16);
  849. OLED_ShowNumber(20,2,Tempture/1000,2);
  850. OLED_ShowString(36,2,".",16);
  851. OLED_ShowNumber(46,2,Tempture%1000,3);
  852. OLED_ShowString(0,4,"H:",16);
  853. OLED_ShowNumber(20,4,Humi/1000,2);
  854. OLED_ShowString(36,4,".",16);
  855. OLED_ShowNumber(40,4,Humi%1000,3);
  856. }
  857. ee_printf("Tempture:%u.%u Humi:%u.%un",Tempture/1000 ,Tempture%1000,Humi/1000,Humi%1000);
  858. // ee_printf("type?RTC_MTIME->mtime:%lu n",type(RTC_MTIME->mtime));
  859. break;//
  860. case 50://"2"
  861. ADC->SEL = 0; //测量通道选择:0-PTAT,1-1/2VDD,2-PAD3,3-PAD4,4-PAD5,5-PAD6,6-PAD7,7-PAD8,8-PAD9,9-PAD10,10-NTC,11-VDD,其它-无
  862. Delay32M_us(20);//ADC电源开启需要时间
  863. //
  864. for(uint8_t i=0;i<16;i++)
  865. {
  866. adc_result = ADC_Conversion();//适用于非中断模式 adc_sum += adc_pack[i];
  867. printf("adc_val:%urn",adc_result);
  868. ee_printf("%d.%dmV rn",(adc_result*4*12000/32768)/10,(adc_result*4*12000/32768)%10);
  869. Delay32M_ms(20); }
  870. ADC->SEL = 3; //测量通道选择:0-PTAT,1-1/2VDD,2-PAD3,3-PAD4,4-PAD5,5-PAD6,6-PAD7,7-PAD8,8-PAD9,9-PAD10,10-NTC,11-VDD,其它-无
  871. Delay32M_us(20);//ADC电源开启需要时间
  872. GPIO_MODE_Init(GPIOA,PIN4,GPIO_MODE_ANALOG);//设置GPIO为ADC输入
  873. break;
  874. // case 49 ... 57://"1~9"
  875. // timeProducing[9]=rt_tick_get();
  876. // timeProducing[6]=timeProducing[6]*10+a;
  877. // timeProducing[7]++;
  878. // if ( timeProducing[7]==2) {
  879. // date[1]=timeProducing[6];
  880. // timeProducing[9]=rt_tick_get();
  881. // timeProducing[8]++;
  882. // timeProducing[7]=0;
  883. //
  884. // rt_kprintf("pleases input month :");
  885. //
  886. // }
  887. //
  888. // break;
  889. //
  890. //
  891. // case 21:
  892. // timeProducing[9]=rt_tick_get();
  893. // timeProducing[6]=timeProducing[6]*10+date_a;
  894. // timeProducing[7]++;
  895. // if ( timeProducing[7]==4) {
  896. // date[0]=timeProducing[6];
  897. // timeProducing[9]=rt_tick_get();
  898. // timeProducing[8]=11;
  899. // timeProducing[7]=0;
  900. //
  901. // rt_kprintf("year is %d,pleases input month :",date[0]);
  902. //
  903. // }
  904. //
  905. // break;
  906. default:
  907. break;
  908. }
  909. // if((ReceiveBuff[0]=='o')&&(ReceiveBuff[1]=='n'))
  910. // {
  911. // GPIO_Write(GPIOA,PIN8,GPIO_RESET);
  912. // ee_printf("灯开了!rn");
  913. // }
  914. // else if((ReceiveBuff[0]=='o')&&(ReceiveBuff[1]=='f')&&(ReceiveBuff[2]=='f'))
  915. // {
  916. // GPIO_Write(GPIOA,PIN8,GPIO_SET);
  917. // ee_printf("关灯了!rn");
  918. // }
  919. // else
  920. // {
  921. // ee_printf("请输入:on 或者off (开灯/关灯)rn");
  922. // }
  923. uart_dev.frameok=0;
  924. uart_dev.rxlen=0;
  925. }
  926. if( rt_tick_get()%1000==0) ee_printf("time is %u s n",rt_tick_get()/1000);
  927. if(!( rt_tick_get()- rt_tick1< 10000)){
  928. rt_tick1 = rt_tick_get() ;
  929. GPIO_Toggle(GPIOB,PIN8);
  930. GPIO_Toggle(GPIOA,PIN10); //GPIO 翻转
  931. // ee_printf("mcycle:%u n",read_csr(mcycle));
  932. ee_printf("rt_tick_get:%u n", rt_tick_get());
  933. ee_printf("RTC_MTIME->mtime:%lu ",RTC_MTIME->mtime);
  934. // ee_printf("type?RTC_MTIME->mtime:%lu n",type(RTC_MTIME->mtime));
  935. ee_printf("RTC_MTIME->mtime0-7B:");
  936. for (uint8_t i = 0; i < 8; i++)
  937. {
  938. ee_printf("%x ",_REG8(0x0200bff8UL,i));
  939. }
  940. ee_printf("nRTC_MTIME->mtime:%u n",_REG32(0x0200bff8UL,4));
  941. ee_printf("RTC_MTIMECMP->mtimecmp:%lu n",RTC_MTIMECMP->mtimecmp);
  942. // ee_printf("type?RTC_MTIME->mtime:%lu n",type(RTC_MTIMECMP->mtimecmp));
  943. ee_printf("->?RTC_MTIME->mtime:%p n",RTC_MTIMECMP->mtimecmp);
  944. ee_printf("RTC_MTIMECMP->mtimecmp0-7B:");
  945. for (uint8_t i = 0; i < 8; i++)
  946. {
  947. ee_printf("%x ",_REG8(0x02004000UL,i));
  948. }
  949. ee_printf(" n");
  950. }
  951. // Delay32M_ms(500);
  952. //Delay16M_ms(500);
  953. //Delay16M_us(500000);
  954. //GPIO_Toggle(GPIOA,PIN15);
  955. //printf("main:rn");
  956. ///---- Chapter 6 EXIT test ---------------------------------------------------------------------------------
  957. //delay16M_ms(500);
  958. //GPIO_Toggle(GPIOA,PIN15);
  959. ///---- Chapter 8 IWDG test ---------------------------------------------------------------------------------
  960. //IWDG_Refresh();
  961. //delay16M_ms(500);
  962. //GPIO_Toggle(GPIOA,PIN15);
  963. ///---- Chapter 9 Timer test --------------------------------------------------------------------------------
  964. //---- soft break --------------------------------------------------------------------------------------
  965. //delay16M_ms(100);
  966. //TIMER2->BDTR |= 1 <<15;//BDTR[15]-MOE-主输出使能:0-关闭,1-使能
  967. //delay16M_ms(100);
  968. //TIMER2->EGR |= 1 <<7;//EGR[7]-BG-产生刹车事件
  969. //---- soft COM ----------------------------------------------------------------------------------------
  970. //delay16M_ms(100);
  971. //TIMER2->EGR = 1 <<5;//EGR[5]-COMG-捕获/比较事件,产生控制更新
  972. //---- generate oxr ------------------------------------------------------------------------------------
  973. /*
  974. Delay16M_ms(10);//1
  975. GPIO_Write(GPIOA,PIN9,GPIO_SET);
  976. GPIO_Write(GPIOA,PIN11,GPIO_RESET);
  977. GPIO_Write(GPIOA,PIN13,GPIO_SET);
  978. Delay16M_ms(10);//2
  979. GPIO_Write(GPIOA,PIN9,GPIO_SET);
  980. GPIO_Write(GPIOA,PIN11,GPIO_RESET);
  981. GPIO_Write(GPIOA,PIN13,GPIO_RESET);
  982. Delay16M_ms(10);//3
  983. GPIO_Write(GPIOA,PIN9,GPIO_SET);
  984. GPIO_Write(GPIOA,PIN11,GPIO_SET);
  985. GPIO_Write(GPIOA,PIN13,GPIO_RESET);
  986. Delay16M_ms(10);//4
  987. GPIO_Write(GPIOA,PIN9,GPIO_RESET);
  988. GPIO_Write(GPIOA,PIN11,GPIO_SET);
  989. GPIO_Write(GPIOA,PIN13,GPIO_RESET);
  990. Delay16M_ms(10);//5
  991. GPIO_Write(GPIOA,PIN9,GPIO_RESET);
  992. GPIO_Write(GPIOA,PIN11,GPIO_SET);
  993. GPIO_Write(GPIOA,PIN13,GPIO_SET);
  994. Delay16M_ms(10);//6
  995. GPIO_Write(GPIOA,PIN9,GPIO_RESET);
  996. GPIO_Write(GPIOA,PIN11,GPIO_RESET);
  997. GPIO_Write(GPIOA,PIN13,GPIO_SET);
  998. */
  999. ///---- Chapter 11 ADC test ---------------------------------------------------------------------------------
  1000. if(!( rt_tick_get()- rt_tick2< 15000)){
  1001. rt_tick2 = rt_tick_get();
  1002. adc_result = ADC_Conversion();//适用于非中断模式
  1003. //printf("adc_val:%drn",adc_result);
  1004. adc_pack[(adc_count++)&0xf] = adc_result;
  1005. adc_sum=0;
  1006. for(uint8_t i=0;i<16;i++)
  1007. {
  1008. adc_sum += adc_pack[i];
  1009. }
  1010. adc_avr = adc_sum/16;
  1011. ee_printf("val:%davr:%d %d.%dmV %d.%dmVrn",adc_result,adc_avr,(adc_result*4*12000/32768)/10,(adc_result*4*12000/32768)%10,(adc_avr*4*12000/32768)/10,(adc_avr*4*12000/32768)%10);
  1012. //ADC_Soft_Start();//软件触发ADC,适用于中断模式
  1013. OLED_ShowString(0,4,"adc:",16);
  1014. OLED_ShowNumber(40,4,(adc_avr*4*12000/32768)/10,2);
  1015. OLED_ShowString(76,4,".",16);
  1016. OLED_ShowNumber(80,4,(adc_avr*4*12000/32768)%10,3);
  1017. adc_result =rt_tick_get()/1000;
  1018. adc_sum=adc_result /60;
  1019. adc_avr = adc_sum/60;
  1020. ee_printf("time:%d day %d hour' %d:%dn",adc_avr/24,adc_avr%24,adc_sum%60,adc_result %60);
  1021. OLED_ShowString(0,6,"time:",16);
  1022. OLED_ShowNumber(40,6,adc_avr/24,2);
  1023. OLED_ShowString(56,6,"d",16);
  1024. OLED_ShowNumber(64,6,adc_avr%24,2);
  1025. OLED_ShowString(80,6,":",16);
  1026. OLED_ShowNumber(88,6,adc_sum%60,2);
  1027. OLED_ShowString(104,6,":",16);
  1028. OLED_ShowNumber(112,6,adc_result %60,2);
  1029. }
  1030. ///---- Chapter 12 I2C test ---------------------------------------------------------------------------------
  1031. //I2C_Write(0x2d,0x55);//适用于非中断模式
  1032. //i2c_data = I2C_Read(0x2d);//适用于非中断模式
  1033. //printf("data:%xrn",i2c_data);
  1034. //I2C_Write(0x2d,0xaa);//适用于非中断模式
  1035. //i2c_data = I2C_Read(0x2d);//适用于非中断模式
  1036. //printf("data:%xrn",i2c_data);
  1037. //I2C_Write_IT(0x2d,0x55);//适用于中断模式
  1038. ///---- Chapter 13 SPI test --------------------------------------------------------------------------------
  1039. //SPI1 Test
  1040. //SPI_Transceive(SPI1,sTxpack,sRxpack,10);//非中断模式
  1041. //SPI1_RW_reg(WRITE_REG+0x05,0x53);//读写Si24R1寄存器
  1042. //REG_Data = SPI1_RW_reg(READ_REG+0x05,0);//读写Si24R1寄存器
  1043. //printf("rnREG5:%02x",REG_Data);
  1044. //delay16M_ms(500);
  1045. //SPI2 Test
  1046. //SPI_Transceive(SPI2,sTxpack,sRxpack,10);//非中断模式
  1047. //SPI2_RW_reg(WRITE_REG+0x05,0x53);//读写Si24R1寄存器
  1048. //REG_Data = SPI2_RW_reg(READ_REG+0x05,0);//读写Si24R1寄存器
  1049. //printf("rnREG5:%02x",REG_Data);
  1050. //delay16M_ms(500);
  1051. ///---- Chapter 15 UART Test ------------------------------------------------------------------------------------
  1052. //---- 非中断模式数据回环测试 -------------------------------------------------------------------------------------
  1053. //Uart_Reveive(UART1,upack1,10);//适用于非中断发送模式
  1054. //Uart_Send(UART1,upack1,10);//适用于非中断发送模式
  1055. //Uart_Reveive(UART2,upack2,10);//适用于非中断发送模式
  1056. //Uart_Send(UART2,upack2,10);//适用于非中断发送模式
  1057. //Uart_Reveive(UART3,upack3,10);//适用于非中断发送模式
  1058. //Uart_Send(UART3,upack3,10);//适用于非中断发送模式
  1059. //Uart_Reveive(UART4,upack4,10);//适用于非中断发送模式
  1060. //Uart_Send(UART4,upack4,10);//适用于非中断发送模式
  1061. //---- 中断模式数据回环测试 --------------------------------------------------------------------------------------
  1062. //UART1_putbuf(UART1_getbuf());
  1063. //---- printf测试 ----------------------------------------------------------------------------------------
  1064. //printf("Hellow-01234568789abcdefghijklmnopqrstuvwxyzrn");
  1065. ///---- Chapter 17 RANDGEN test -----------------------------------------------------------------------------
  1066. //rand_data = RAND_Get();//生成随机数
  1067. //printf("rand:0x%08x,%urn",rand_data,rand_data);
  1068. //delay16M_ms(500);
  1069. ///---- Chapter 18 COMPARE test -----------------------------------------------------------------------------
  1070. //if(COMP1->irq&0x1)
  1071. //{
  1072. //GPIO_Toggle(GPIOA,PIN15);
  1073. //COMP1->irq = 1;
  1074. //}
  1075. //delay16M_ms(10);
  1076. }
  1077. return 0;
  1078. }
  1079. //}
复制代码

poYBAGIDZpaAP2OhAAF-4-x2PJQ628.png

poYBAGIDYVCABk08AABEk5Mxom8209.jpg

com:
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
time is 1478 s
rt_tick_get:1482292
RTC_MTIME->mtime:448375682 RTC_MTIME->mtime0-7B:52 ee b9 1a 1 0 0 0
RTC_MTIME->mtime:1
RTC_MTIMECMP->mtimecmp:448411904
->?RTC_MTIME->mtime:1aba5e80
RTC_MTIMECMP->mtimecmp0-7B:0 9d ba 1a 1 0 0 0
val:9231avr:4887 1352.1mV 715.8mV

time:0 day 0 hour' 24:46
收到数据:1

Tempture:0.0 Humi:0.0
read_csr(mcycle):2
mcycle:413283856
Tempture:23.808 Humi:0.0
time is 1492 s
rt_tick_get:1492301
RTC_MTIME->mtime:480404340 RTC_MTIME->mtime0-7B:44 a6 a2 1c 1 0 0 0
RTC_MTIME->mtime:1
RTC_MTIMECMP->mtimecmp:480440704
->?RTC_MTIME->mtime:1ca31700
RTC_MTIMECMP->mtimecmp0-7B:80 55 a3 1c 1 0 0 0
收到数据:2

adc_val:5430
795.4mV

adc_val:5426
794.8mV

adc_val:5430
795.4mV

adc_val:5419
793.7mV

adc_val:5417
793.5mV

adc_val:5416
793.3mV

adc_val:5427
794.9mV

adc_val:5432
795.7mV

adc_val:5421
794.0mV

adc_val:5421
794.0mV

adc_val:5428
795.1mV

adc_val:5419
793.7mV

adc_val:5424
794.5mV

adc_val:5417
793.5mV

adc_val:5420
793.9mV

adc_val:5429
795.2mV

val:9623avr:51657617 1409.6mV 4179.3mV

time:0 day 0 hour' 25:2
rt_tick_get:1502303
RTC_MTIME->mtime:512409229 RTC_MTIME->mtime0-7B:5d 1 8b 1e 1 0 0 0
RTC_MTIME->mtime:1
RTC_MTIMECMP->mtimecmp:512443904
->?RTC_MTIME->mtime:1e8b6b80
RTC_MTIMECMP->mtimecmp0-7B:0 b6 8b 1e 1 0 0 0

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
  • 南京中科微
    +关注

    关注

    0

    文章

    60

    浏览量

    646
  • CSM32RV20
    +关注

    关注

    0

    文章

    40

    浏览量

    177
收藏 人收藏

    评论

    相关推荐

    中科CSM32RV003绿色开发板免费体验】环境配置

    CSM32RV003】中科CSM32RV003绿色开发板环境配置 视频中详细介绍了开发板
    发表于 10-23 19:17

    中科CSM32RV003绿色开发板免费体验】3.使用流程

    试用机会,非常感谢电子发烧友论坛! 南京中科公司CSM32RV003开发板使用心得体会 这篇
    发表于 10-14 00:05

    中科CSM32RV003绿色开发板免费体验】+ISP下载测试

    在收到中科CSM32RV003绿色开发板后,首先到官网和技术支持信群寻找资料。要实现CSM32RV
    发表于 10-11 08:58

    中科CSM32RV003绿色开发板免费体验】2.RISC-V RV32IMAC内核

    CSM32RV003绿色开发板免费体验】1.上手 我要感谢南京中科微电子有限公司提供的CSM32RV003绿色
    发表于 10-10 00:03

    中科CSM32RV003绿色开发板免费体验】 开箱和安装工具帖

    我申请项目:滑翔伞空中速率计。 我于2023年9月9日下午收到中科CSM32RV003开发板快递包裹。拿回后立马打开包裹,出现南京
    发表于 10-09 23:34

    中科CSM32RV003绿色开发板免费体验】1.上手

    首先,我要感谢南京中科微电子有限公司提供的CSM32RV003绿色开发板试用机会,这让我有机会深入了解并使用该公司的产品。经过几天的熟悉和
    发表于 10-09 23:21

    中科CSM32RV003绿色开发板免费体验】了解和认识中科CSM32RV003绿色开发板

    芯片,最高主频32MHz,最大支持32KB嵌入式FlASH、4KB SRAM和4.5KB NVM,集成ADC和UART、I2C、SPI等通用外设接口。 中科CSM32RV003绿色
    发表于 09-22 16:56

    中科CSM32RV003绿色开发板免费体验】中科CSM32RV003绿色开发板初次使用测试

    今天拿到中科CSM32RV003绿色开发板做一下上电及初次使用的介绍视频及文字介绍, 中科
    发表于 09-22 16:35

    中科CSM32RV003绿色开发板免费体验】中科CSM32RV003绿色开发板初体验

    收到南京中科CSM32RV003绿色开发板,板子做的很小巧,绿色阻焊也很漂亮,板子布局合理,功能也很强大。
    发表于 09-22 16:25

    中科CSM32RV003绿色开发板免费体验】开发板使用2 CJlink 调试器

    接上文 【中科CSM32RV003绿色开发板免费体验】开发板使用1 南京
    发表于 09-21 05:32

    中科CSM32RV003绿色开发板免费体验】开发板使用1

    接上文 【中科CSM32RV003绿色开发板免费体验】环境搭建 南京中科
    发表于 09-20 21:33

    中科CSM32RV003绿色开发板免费体验】第一帖-开箱体验

    本帖最后由 ele2022 于 2023-9-20 16:40 编辑 今天开箱体验南京中科推出的CSM32RV003
    发表于 09-20 13:56

    中科CSM32RV003绿色开发板免费体验】开箱+资料准备

    很高兴能参加【RISC-V】中科CSM32RV003绿色开发板免费体验的活动。本次的中科
    发表于 09-17 22:15

    中科CSM32RV003绿色开发板免费体验】环境搭建

    感谢 发烧友学院以及南京中科公司为我和孩子提供此产品CSM32RV003开发板。收到了CSM32RV
    发表于 09-17 20:57

    试用南京中科微电子CSM32RV003开发板

    非常迅速头一天接收信息,第二天雨中快递送到南京中科微电子有限公司CSM32RV003开发板(TSSOP20)封装的RISC-V处理器芯片。迷
    发表于 09-09 19:01