GD32F103 — 12-软件IIC访问LM75AD
来源: DRG GD-1 开发板例程
源文件: GD32/drg_gd_1_gd32f103c8t6-master/12-软件IIC访问LM75AD/test/APP/main.c
子模块
关键代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#include <stdio.h>
#include "systick.h"
#include "usart_comm.h"
#include "lm75a_temp.h"
int main(){
systick_config();
usart0_init(9600);
float temp_result;
char temp_string[80];
lm75a_init();
while(1){
temp_result = lm75a_get_temp();
sprintf(temp_string, "temperature is: %.3f C.\n", temp_result);
usart0_send_string((uint8_t *)temp_string);
delay_1ms(1000); //ȴ1s
}
}
|