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

📄 cc1100._h

📁 chipcom公司CC1100无线模块底层驱动程序
💻 _H
字号:
#ifndef __CC1100_h
#define __CC1100_h


#define CC1100_IOCFG2       0x00
#define CC1100_IOCFG1       0x01
#define CC1100_IOCFG0       0x02
#define CC1100_FIFOTHR      0x03
#define CC1100_SYNC1        0x04
#define CC1100_SYNC0        0x05
#define CC1100_PKTLEN       0x06
#define CC1100_PKTCTRL1     0x07
#define CC1100_PKTCTRL0     0x08
#define CC1100_ADDR         0x09
#define CC1100_CHANNR       0x0A
#define CC1100_FSCTRL1      0x0B
#define CC1100_FSCTRL0      0x0C
#define CC1100_FREQ2        0x0D
#define CC1100_FREQ1        0x0E
#define CC1100_FREQ0        0x0F
#define CC1100_MDMCFG4      0x10
#define CC1100_MDMCFG3      0x11
#define CC1100_MDMCFG2      0x12
#define CC1100_MDMCFG1      0x13
#define CC1100_MDMCFG0      0x14
#define CC1100_DEVIATN      0x15
#define CC1100_MCSM2        0x16
#define CC1100_MCSM1        0x17
#define CC1100_MCSM0        0x18
#define CC1100_FOCCFG       0x19
#define CC1100_BSCFG        0x1A
#define CC1100_AGCCTRL2     0x1B
#define CC1100_AGCCTRL1     0x1C
#define CC1100_AGCCTRL0     0x1D
#define CC1100_WOREVT1      0x1E
#define CC1100_WOREVT0      0x1F
#define CC1100_WORCTRL      0x20
#define CC1100_FREND1       0x21
#define CC1100_FREND0       0x22
#define CC1100_FSCAL3       0x23
#define CC1100_FSCAL2       0x24
#define CC1100_FSCAL1       0x25
#define CC1100_FSCAL0       0x26
#define CC1100_RCCTRL1      0x27
#define CC1100_RCCTRL0      0x28
#define CC1100_FSTEST       0x29
#define CC1100_PTEST        0x2A
#define CC1100_AGCTEST      0x2B
#define CC1100_TEST2        0x2C
#define CC1100_TEST1        0x2D
#define CC1100_TEST0        0x2E
#define CC1100_SRES         0x30
#define CC1100_SFSTXON      0x31
#define CC1100_SXOFF        0x32
#define CC1100_SCAL         0x33
#define CC1100_SRX          0x34
#define CC1100_STX          0x35
#define CC1100_SIDLE        0x36
#define CC1100_SAFC         0x37
#define CC1100_SWOR         0x38
#define CC1100_SPWD         0x39
#define CC1100_SFRX         0x3A
#define CC1100_SFTX         0x3B
#define CC1100_SWORRST      0x3C
#define CC1100_SNOP         0x3D
#define CC1100_PARTNUM      0x30
#define CC1100_VERSION      0x31
#define CC1100_FREQEST      0x32
#define CC1100_LQI          0x33
#define CC1100_RSSI         0x34
#define CC1100_MARCSTATE    0x35
#define CC1100_WORTIME1     0x36
#define CC1100_WORTIME0     0x37
#define CC1100_PKTSTATUS    0x38
#define CC1100_VCO_VC_DAC   0x39
#define CC1100_TXBYTES      0x3A
#define CC1100_RXBYTES      0x3B
#define CC1100_PATABLE      0x3E
#define CC1100_TXFIFO       0x3F
#define CC1100_RXFIFO       0x3F

#define CRC_OK	0x80
#define MARC_SLEEP        0
#define MARC_IDLE         1
#define MARC_XOFF         2
#define MARC_VCOON_MC     3
#define MARC_REGON_MC     4
#define MARC_MANCAL       5
#define MARC_VCOON        6
#define MARC_REGON        7
#define MARC_STARTCAL     8
#define MARC_BWBOOST      9
#define MARC_FS_LOCK      10
#define MARC_IFADCON      11
#define MARC_ENDCAL       12
#define MARC_RX           13
#define MARC_RX_END       14
#define MARC_RX_RST       15
#define MARC_TXRX_SWITCH  16
#define MARC_RX_OVERFLOW  17
#define MARC_FSTXON       18
#define MARC_TX           19
#define MARC_TX_END       20
#define MARC_RXTX_SWITCH  21
#define MARC_TX_UNDERFLOW 22

/*
#define SI_IN       DDRC  &= ~BIT(PC5)
#define SI_OUT      DDRC  |= BIT(PC5)
#define SI_H        PORTC |= BIT(PC5)
#define SI_L        PORTC &= ~BIT(PC5)
#define SI_STATE    (PIND & BIT(PC5))

#define SO_IN       DDRC  &= ~BIT(PC3)
#define SO_OUT      DDRC  |= BIT(PC3)
#define SO_H        PORTC |= BIT(PC3)
#define SO_L        PORTC &= ~BIT(PC3)
#define SO_STATE    (PINC & BIT(PC3))

#define SCLK_IN     DDRC  &= ~BIT(PC4)
#define SCLK_OUT    DDRC  |= BIT(PC4)
#define SCLK_H      PORTC |= BIT(PC4)
#define SCLK_L      PORTC &= ~BIT(PC4)
#define SCLK_STATE  (PINC & BIT(PC4))

#define CS_IN       DDRC  &= ~BIT(PC0)
#define CS_OUT      DDRC  |= BIT(PC0)
#define CS_H        PORTC |= BIT(PC0)
#define CS_L        PORTC &= ~BIT(PC0)
#define CS_STATE    (PINC & BIT(PC0))

#define GDO0_IN     DDRC  &= ~BIT(PC1)
#define GDO0_OUT    DDRC  |= BIT(PC1)
#define GDO0_H      PORTC |= BIT(PC1)
#define GDO0_L      PORTC &= ~BIT(PC1)
#define GDO0_STATE  (PINC & BIT(PC1))

#define GDO2_IN     DDRC  &= ~BIT(PC2)
#define GDO2_OUT    DDRC  |= BIT(PC2)
#define GDO2_H      PORTC |= BIT(PC2)
#define GDO2_L      PORTC &= ~BIT(PC2)
#define GDO2_STATE  (PINC & BIT(PC2))*/


#define SI_IN       DDRC  &= ~BIT(PC4)
#define SI_OUT      DDRC  |= BIT(PC4)
#define SI_H        PORTC |= BIT(PC4)
#define SI_L        PORTC &= ~BIT(PC4)
#define SI_STATE    (PIND & BIT(PC4))

#define SO_IN       DDRC  &= ~BIT(PC2)
#define SO_OUT      DDRC  |= BIT(PC2)
#define SO_H        PORTC |= BIT(PC2)
#define SO_L        PORTC &= ~BIT(PC2)
#define SO_STATE    (PINC & BIT(PC2))

#define SCLK_IN     DDRC  &= ~BIT(PC5)
#define SCLK_OUT    DDRC  |= BIT(PC5)
#define SCLK_H      PORTC |= BIT(PC5)
#define SCLK_L      PORTC &= ~BIT(PC5)
#define SCLK_STATE  (PINC & BIT(PC5))

#define CS_IN       DDRC  &= ~BIT(PC3)
#define CS_OUT      DDRC  |= BIT(PC3)
#define CS_H        PORTC |= BIT(PC3)
#define CS_L        PORTC &= ~BIT(PC3)
#define CS_STATE    (PINC & BIT(PC3))

//#define GDO0_IN     DDRC  &= ~BIT(PC1)
//#define GDO0_OUT    DDRC  |= BIT(PC1)
//#define GDO0_H      PORTC |= BIT(PC1)
//#define GDO0_L      PORTC &= ~BIT(PC1)
//#define GDO0_STATE  (PINC & BIT(PC1))

#define GDO2_IN     DDRD  &= ~BIT(PD2)
#define GDO2_OUT    DDRD  |= BIT(PD2)
#define GDO2_H      PORTD |= BIT(PD2)
#define GDO2_L      PORTD &= ~BIT(PD2)
#define GDO2_STATE  (PIND & BIT(PD2))

#define TXEN_OUT	DDRC  |= BIT(PC0)
#define TXEN_SET_H	PORTC |= BIT(PC0)
#define TXEN_SET_L	PORTC &= ~BIT(PC0)

#define RXEN_OUT	DDRC  |= BIT(PC1)
#define RXEN_SET_H	PORTC |= BIT(PC1)
#define RXEN_SET_L	PORTC &= ~BIT(PC1)

#define WRITE_BURST   0x40
#define READ_SINGLE   0x80
#define READ_BURST    0xC0

#define TRUE  0xFF
#define FALSE 0x00


#define CC1100_RX_STATE  0x00
#define CC1100_TX_STATE  0xFF


/*
************************************************************
*Description:复位CC1100
*Arguments  :none
*Returns    :none
*Notes      :
************************************************************
*/
extern void CC1100Rst(void);


/*
************************************************************
*Description:写CC1100控制命令
*Arguments  :strobe:控制命令
*Returns    :none
*Notes      :
************************************************************
*/
extern void CC1100Strobe(INT8U strobe);


/*
************************************************************
*Description:读CC1100单个寄存器
*Arguments  :addr:地址
*Returns    :数据
*Notes      :
************************************************************
*/
extern INT8U CC1100ReadReg(INT8U addr);


/*
************************************************************
*Description:写CC1100单个寄存器
*Arguments  :addr:地址; value:数据
*Returns    :none
*Notes      :
************************************************************
*/
extern void CC1100WriteReg(INT8U addr, INT8U value);


/*
************************************************************
*Description:读CC1100状态寄存器
*Arguments  :addr:地址
*Returns    :状态值
*Notes      :
************************************************************
*/
extern INT8U CC1100ReadStatus(INT8U addr);


/*
************************************************************
*Description:连续读CC1100状态寄存器
*Arguments  :addr:地址; *buf:读取数据存放寄存器; cnt:所要读取字节个数
*Returns    :none
*Notes      :
************************************************************
*/
extern void CC1100ReadBurstReg(INT8U addr, INT8U *buf, INT8U cnt);


/*
************************************************************
*Description:连续写CC1100状态寄存器
*Arguments  :addr:地址; *buf:写数据寄存器; cnt:所要写字节个数
*Returns    :none
*Notes      :
************************************************************
*/
extern void CC1100WriteBurstReg(INT8U addr, INT8U *buf, INT8U cnt);


/*
************************************************************
*Description:利用SPI从CC1100读一个字节
*Arguments  :none
*Returns    :返回所读字节
*Notes      :
************************************************************
*/
extern INT8U ShiftInByte(void);


/*
************************************************************
*Description:利用SPI向CC1100写一个字节
*Arguments  :value:所写字节
*Returns    :none
*Notes      :
************************************************************
*/
extern void ShiftOutByte(INT8U value);



#endif

⌨️ 快捷键说明

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