/
test.c
52 lines (36 loc) · 1.06 KB
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#define F_CPU 8000000UL
#define BAUD 19200UL
#define MY_UBRR F_CPU/(16*BAUD)-1
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include "uart_interface.h"
#include "twi_interface.h"
#include "LSM6DS3.h"
//*****************************************************************************
// Main Program
//*****************************************************************************
int main(){
uint8_t rd_buf[1];
char str[6];
// Initialize UART
UART_Init(MY_UBRR);
init_twi();
sei();
init_LSM6DS3();
rd_buf[0] = check_bit(CTRL9_XL,SOFT_EN);
sprintf(str,"%02X\r\n",rd_buf[0]);
UART_Transmit_String(str);
set_bits(CTRL9_XL, SOFT_EN);
rd_buf[0] = check_bit(CTRL9_XL,SOFT_EN);
sprintf(str,"%02X\r\n",rd_buf[0]);
UART_Transmit_String(str);
clear_bits(CTRL9_XL, SOFT_EN);
rd_buf[0] = check_bit(CTRL9_XL,SOFT_EN);
sprintf(str,"%02X\r\n",rd_buf[0]);
UART_Transmit_String(str);
return 0;
}