/************************** Copyright (c) **********************************
|
** FUZHOU FUGUANG ELECTRONICS Co.,LTD.
|
** ¸£Öݸ£¹âµç×ÓÓÐÏÞ¹«Ë¾
|
** http://www.fuguang.com
|
**
|
**-------------- File Info -------------------------------------------------
|
** File name: NRF905_Driver.h
|
** Last modified Date: 2008-11-16
|
** Last Version: 1.0
|
** Descriptions: NRF905 Drivers lib
|
**
|
**--------------------------------------------------------------------------
|
** Created by: mxpopstar
|
** Created date: 2008-11-16
|
** Version: 1.0
|
** Descriptions: The original version
|
**
|
**--------------------------------------------------------------------------
|
** Modified by: mxpopstar
|
** Modified date: 2008-11-20
|
** Version:
|
** Descriptions: NRF905 Drivers lib
|
**
|
***************************************************************************/
|
//
|
|
#ifndef NRF905Dri_H
|
#define NRF905Dri_H
|
|
#include<avr/io.h>
|
#include<util/delay.h>
|
#include<string.h>
|
#include<stdio.h>
|
#include "Define.h"
|
#include "Delay.h"
|
|
void InitIO_NRF905(void); // Initialize IO port
|
void SpiWrite(const unsigned char byte); // Write data to nRF905
|
unsigned char SpiRead(void); // Read data to nRF905
|
void Write_Config905(void); // Config nRF905 module
|
void Read_Config905(unsigned char *buf);
|
void SetTxMode(void); // Set nRF905 in Tx mode
|
void SetRxMode(void); // Set nRF905 in Rx mode
|
void TxPacket(const unsigned char *addr, const void *datas); // Send data by nRF905
|
void RxPacket(void *rxdata); // Recive data by nRF905
|
void Set905Fre(const unsigned char fre);
|
|
void Get_Vol_Datas(volatile FBO_Data *FBOdata, volatile SYS_State *SYSstateconst, unsigned int MStopV);
|
void SetModuleSum(const unsigned int eachgroupbattsum, const unsigned char group);
|
unsigned int GetModuleSum(void);
|
void GetAndDSPMasterADDR(void);
|
unsigned char GetMasterADDR(void);
|
void SetMasterADDR(const unsigned char settype);
|
void GetAndDSPMonomerOrder(void);
|
void SetMonomerOrder(void);
|
unsigned char GetMonomerOrder(void);
|
void GetAndDSPModuleStartIndex(void);
|
unsigned char GetModuleStartindex(void);
|
void SetModuleStartindex(const unsigned char settype);
|
unsigned int GetMonomerMaxVol(unsigned char index);
|
unsigned int GetMonomerMinVol(unsigned char index);
|
unsigned char GetStopMonomerVolStop(void);
|
unsigned int GetStopMVolCountSet(void);
|
void SetStopMVolCountSet(unsigned char value);
|
unsigned int GetMonomerMaxIndex(unsigned char index);
|
unsigned int GetMonomerMinIndex(unsigned char index);
|
void EnableMonomerVolGether(void);
|
void DisableMonomerVolGether(void);
|
unsigned char GetMonomerVolGetherState(void);
|
void SetEachGroupBattSum(unsigned int value);
|
unsigned int GetEachGroupBattSum(void);
|
void GetEachBattGroupCurrent(volatile FBO_Data *FBOdata);
|
void GetAndDspStopMVolCountSet(void);
|
unsigned int GetMLimitVolCount(void);
|
unsigned int GetEachGroupModule(void);
|
|
void ClearModuleError(void);
|
unsigned char GetModuleDropIndex(void);
|
unsigned char GetClampDropIndex(void);
|
unsigned char GetClampType(void);
|
unsigned char ExchangeMonomerData(const unsigned char *TX_ADDR, void *DataTX, void *DataRX);
|
void DSPMonomerModuleType(const unsigned int px, const unsigned int py, const unsigned char color);
|
//void SetModuleDropNum(const unsigned char num);
|
|
|
typedef struct RFData_tag
|
{
|
unsigned char Addr[4];
|
unsigned int CMD;
|
unsigned int VolData[4];
|
unsigned int CRC;
|
}RFData;
|
//
|
|
typedef struct MonomerVolState_tag
|
{
|
unsigned int MonomerVolRate; //µ¥Ìå²É¼¯ËÙÂÊ
|
unsigned int StopMVolCount; //´ïµ½µ¥ÌåÏÂÏ޵ĵ¥ÌåÊýÁ¿
|
unsigned int MonomerMaxVol[4]; //×î¸ßµ¥Ìå
|
unsigned int MonomerMinVol[4]; //×îµÍµ¥Ìå
|
unsigned int MonomerMaxIndex[4]; //×î¸ßµ¥ÌåË÷Òý
|
unsigned int MonomerMinIndex[4]; //×îµÍµ¥ÌåË÷Òý
|
unsigned int EachGroupBattSum; //ÿ×éµç³Øµ¥Ìå¸öÊý;
|
|
unsigned char ModuleDropCount; //µ¥ÌåÄ£¿éÍÑÂä×ÜÊý
|
unsigned char ModuleDropIndex; //ÍÑÂäµÄµ¥ÌåÄ£¿éºÅ
|
|
unsigned char ClampDropCount; //µçÁ÷ǯÒì³£×ÜÊý
|
unsigned char ClampDropIndex; //Òì³£µçÁ÷ǯ±àºÅ
|
unsigned char ClampType;
|
|
unsigned char MonomerEnabled; //ÎÞÏßµ¥Ìåµçѹ²É¼¯Ê¹ÄÜ
|
|
unsigned char ModuleSum; //µ¥ÌåÄ£¿éµÄ×ÜÊý
|
unsigned char EachGroupModule; //ÿ×éÄ£¿éÊýÁ¿
|
unsigned char MasterADDR; //±¾Ö÷»úÎÞÏßͨÐŵØÖ·
|
unsigned char MonomerOder; //µ¥ÌåÄ£¿éµç³ØÐòºÅ
|
unsigned char ModuleStartIndex; //µ¥ÌåÄ£¿éÆðʼµØÖ·
|
}MonomerVolState;
|
//
|
|
#define SLAVE 1
|
#define MASTER 0
|
#define MS MASTER
|
|
|
//*********************************************************************
|
#define WC 0x00 // Write configuration register command
|
#define RC 0x10 // Read configuration register command
|
#define WTP 0x20 // Write TX Payload command
|
#define RTP 0x21 // Read TX Payload command
|
#define WTA 0x22 // Write TX Address command
|
#define RTA 0x23 // Read TX Address command
|
#define RRP 0x24 // Read RX Payload command
|
|
#define ADDR_len 4
|
#define TRDATA_len 16
|
//**********************************************************************
|
|
//**********************************************************************
|
#define MOSI_1 PORTB |= 0x04 //PINB2
|
#define MOSI_0 PORTB &= (~0x04)
|
#define MISO_1 PINB & 0x08 //PINB3
|
|
#define SCK_1 PORTB |= 0x02 //PINB1
|
#define SCK_0 PORTB &= (~0x02)
|
|
#define TX_EN_1 PORTB |= 0x80 //PINB7
|
#define TX_EN_0 PORTB &= (~0x80)
|
|
#define NRF905_SPI_EN PORTD &= (~0x10) //PIND4
|
#define NRF905_SPI_OFF PORTD |= 0x10
|
|
#define TRX_CE_1 PORTG |= 0x08 //PING3
|
#define TRX_CE_0 PORTG &= (~0x08)
|
|
#define PWR_UP_1 PORTG |= 0x10 //PING4
|
#define PWR_UP_0 PORTG &= (~0x10)
|
|
#define DR (PIND & 0x01) //PIND0
|
//#define CD PINC & 0x01 //PINC0
|
|
//---------------------- max485ÖÐ¼Ì -------------------
|
#define Max485SPI_CS_0 PORTD &= ~(1<<PD5)
|
#define Max485SPI_CS_1 PORTD |= (1<<PD5)
|
//-----------------------------------------------------
|
|
#define ClampTypeNull 0
|
#define ClampType7100 1
|
#define ClampTypeWireless 2
|
//***********************************************************************
|
|
#define MonomeTypeNull 0
|
#define MonomeWireless 1
|
#define MonomeLine 2
|
|
#endif
|
//
|