|
The BK4815N is a half duplex TDD FM
transceiver operating from 124 MHz to 560 MHz band for worldwide personalradio. Besides speech communication, the BK4815N on-chip FSK data modem
supports F2D and F1W emission to be
used in both FRS and DPMR band for textmessage and GPS information exchange.
單片機源程序如下:
- #include"system.h"
- #include"math.h"
- #include"bk4815.h"
- #include"memory.h"
- #include"voice.h"
- #include"uart.h"
- #include"time.h"
- #define OUT_BK4815_SCK P06
- #define OUT_BK4815_SCN P05
- #define OUT_BK4815_SDATA P04
- #define IN_BK4815_SDATA P04
- #define IN_BK4815_IO0 P03
- #define IN_BK4815_IO1 P02
- #define IN_BK4815_INIT P01
- #define SET_BK4815_DATA_IN {P0MDH &= 0xFC; P0MDH |= 0x01;}
- #define SET_BK4815_DATA_OUT {P0MDH &= 0xFC; P0MDH |= 0x02;}
- #define OSC 26000000L
- #define IF IF_137K
- #define DIV DIV_8
- #define VCC_TX 0x0491
- #define VCC_RX 0x048a
- #define VCC_NO 0x0492
- u16 readBK4815Reg(u8 reg)
- {
- u8 i;
- u16 dat;
-
- reg <<= 1;
- reg |= 0x01; //讀的地址
- OUT_BK4815_SCK = 0;
- OUT_BK4815_SCN = 0;
-
- for(i=0; i<8; i++)
- {
- if(reg & 0x80) OUT_BK4815_SDATA = 1;
- else OUT_BK4815_SDATA = 0;
- OUT_BK4815_SCK = 1;
- OUT_BK4815_SCK = 0;
- reg <<= 1;
- }
- SET_BK4815_DATA_IN
- for(i=0; i<16; i++)
- {
- dat <<= 1;
- dat |= IN_BK4815_SDATA;
- OUT_BK4815_SCK = 1;
- OUT_BK4815_SCK = 0;
- }
- OUT_BK4815_SCN = 1;
- SET_BK4815_DATA_OUT
- return dat;
- }
- void writeBK4815Reg(u8 reg, u16 dat)
- {
- u8 i;
-
- reg <<= 1; //寫的地址
- OUT_BK4815_SCK = 0;
- OUT_BK4815_SCN = 0;
-
- for(i=0; i<8; i++)
- {
- if(reg & 0x80) OUT_BK4815_SDATA = 1;
- else OUT_BK4815_SDATA = 0;
- OUT_BK4815_SCK = 1;
- OUT_BK4815_SCK = 0;
- reg <<= 1;
- }
- for(i=0; i<16; i++)
- {
- if(dat & 0x8000) OUT_BK4815_SDATA = 1;
- else OUT_BK4815_SDATA = 0;
- OUT_BK4815_SCK = 1;
- OUT_BK4815_SCK = 0;
- dat <<= 1;
- }
- OUT_BK4815_SCN = 1;
- }
- void initBK4815Port(void)
- {
- //#define OUT_BK4815_SCK P06
- //#define OUT_BK4815_SCN P05
- //#define OUT_BK4815_SDATA P04
- P0MDH &= 0XC0;
- P0MDH |= 0X2A;
- OUT_BK4815_SCN = 1;
- }
復制代碼
|
-
-
BK4815.zip
2021-5-12 10:51 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
3.72 MB, 下載次數: 64, 下載積分: 黑幣 -5
|