⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lmx9820.h

📁 the code connect Atmega 32 uC to 1 module Bluetooth ARF32
💻 H
字号:
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <stdio.h>
/***************************************
***************************************/
#define TRUE 	1
#define FALSE	0
#define TIME_OUT	10

/*---Dinh nghia Frame truyen tin cho cac cau lenh dieu khien LMX9820 theo giao thuc UART*/

/*Start delimiter : 1 byte---Start Frame*/
#define STX			0x02
/*---End frame---*/
#define ETX			0x03			

/*---Dinh nghia cac Packet Type cho khung truyen---*/
#define REQ			0x52		//Request
#define CFM			0x43		//Confirm
#define IND			0x69		//Indication	
#define RES			0x72		//Respond

/*------------------------------------------------------------*/
/*---Dinh nghia cac Opcode cho khung truyen tin---*/
#define GAP_INQUIRY					0x00
#define	GAP_DEVICE_FOUND			0x01
#define GAP_REMOTE_DEVICE_NAME		0x02
#define	GAP_READ_LOCAL_NAME			0x03
#define	GAP_WRITE_LOCAL_NAME		0x04
#define	GAP_READ_LOCAL_BDA			0x05

#define	GAP_ENTER_SNIFF_MODE		0x21

#define	GAP_EXIT_SNIFF_MODE			0x37
#define	GAP_ENTER_HOLD_MODE			0x3A

#define	SPP_SET_PORT_CONFIG			0x07
#define	SPP_GET_PORT_CONFIG			0x08
#define	SPP_PORT_CONFIG_CHANGED		0x09

#define	SPP_ESTABLISH_LINK			0x0A
#define	SPP_LINK_ESTABLISHED		0x0B
#define	SPP_INCOMMING_LINK_ESTABLISHED	0x0C
#define	SPP_RELEASE_LINK			0x0D
#define	SPP_LINK_RELEASED			0x0E
#define	SPP_SEND_DATA				0x0F
#define	SPP_INCOMING_DATA			0x10
#define	SPP_TRANSPARENT_MODE		0x11

#define SDAP_CONNECT				0x32
#define	SDAP_DISCONNECT				0x33
#define	SDAP_SERVICE_BROWSE			0x35

#define SET_PORTS_TO_OPEN			0x22
#define RESET						0x26
#define	DEVICE_READY				0x25

#define ERROR_OK					0x00

/*----------------------------------*/
#define PAYLOAD_MAX 				30		// Dinh nghia chieu dai toi da cua Pay Load la 30 bytes
#define RECEIVE_MAX		PAYLOAD_MAX+7		// Dinh nghia chieu dai khung truyen toi da

/*Mang dung de luu cac lenh truyen tu Module toi Host*/
char Receive_Cmd[RECEIVE_MAX];

/*------------------------------------------------------------------------*/
/*---Dinh nghia cac ham su dung cho module Bluetooth qua giao thuc UART---*/

/*---Ham Reset Module---*/
 void Reset_Module(void);

/*---Ham nhan cac du lieu tra ve tu Module toi Vi dieu khien---*/
 unsigned char Get_Data_From_Module(void);

/*---Ham tim kiem cac thiet bi xung quanh---*/
 void Search_Device(void);

/*---Ham thong tin ve thiet bi duoc tim thay trong qua trinh Search---*/
 void Get_Device_Found(unsigned char *bd_addr, unsigned char *bd_ip);

/*---Ham Confirm qua trinh tim kiem cac thiet bi xung quanh---*/
 unsigned char Search_Confirm(void);

/*---Ham Create SDAP Connection---*/
 void Create_SDAP_Connection(unsigned char *bd_addr);

/*---Ham SDAP Confirm---*/
 unsigned char SDAP_Confirm(void);

/*---Ham SDAP Service Browse---*/
 void SDAP_Service_Browse(void);

/*---Ham SDAP Service Browse Confirm---*/
 unsigned char SDAP_Service_Confirm(unsigned char *port_number);

/*---Ham SDAP Disconnect---*/
 void SDAP_Disconnect(void);

/*---Ham SDAP Disconnect Confirm---*/
 unsigned char SDAP_Disconnect_Confirm(void);

/*---Ham Establish SPP Connection---*/
 void Create_SPP_Link(unsigned char *bd_addr,unsigned char local_port, unsigned char remote_port);

/*---Ham Create SPP Link Confirm---*/
 unsigned char SPP_Link_Confirm(unsigned char *local_port);

/*---Ham Establish SPP Link Indication---*/
 unsigned char SPP_Link_Indication(unsigned char *remote_addr, unsigned char *local_port, unsigned char *remote_port);

/*---Ham Send Data o che do Master Command Mode----*/
 void Send_Data_To_Remote(unsigned char local_port,unsigned char data_length,char *data);

/*---Ham Release Link--*/
 void Release_Link(unsigned char local_port);

/*---Ham Release Link Confirm---*/
 unsigned char Release_Link_Confirm(void);

/*---Ham Release link indication---*/
 unsigned char Release_Link_Indication(unsigned char *local_port);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -